HEX
Server: Apache
System: Linux vps-3158868-x.dattaweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: emerlux (1185)
PHP: 8.3.1
Disabled: system, shell, exec, system_exec, shell_exec, mysql_pconnect, passthru, popen, proc_open, proc_close, proc_nice, proc_terminate, proc_get_status, escapeshellarg, escapeshellcmd, eval
Upload Files
File: /home/emerlux/public_html/wp-content/plugins/wpvulnerability/assets/admin.js
/**
 * WPvulnerability admin scripts.
 *
 * @package WPVulnerability
 */

if ( typeof jQuery !== 'undefined' ) {
		jQuery( document ).on(
			'wp-plugin-update-success',
			function ( event, args ) {
				jQuery( 'tr[data-plugin="' + args.plugin + '"]' ).nextAll( '.wpvulnerability' ).first().remove();
			}
		);
}

document.addEventListener(
	'DOMContentLoaded',
	function () {
		var periodRadios = document.querySelectorAll( 'input[name="wpvulnerability-config[period]"]' );
		var dayWrap      = document.getElementById( 'wpvulnerability_day_wrap' );
		var timeWrap     = document.getElementById( 'wpvulnerability_time_wrap' );

		if ( ! periodRadios.length || ! dayWrap || ! timeWrap ) {
			return;
		}

		function toggleFields() {
			var checked = document.querySelector( 'input[name="wpvulnerability-config[period]"]:checked' );
			var value   = checked ? checked.value : null;

			if ( value === 'daily' ) {
					dayWrap.style.display  = 'none';
					timeWrap.style.display = '';
			} else if ( value === 'weekly' ) {
				dayWrap.style.display  = '';
				timeWrap.style.display = '';
			} else {
				dayWrap.style.display  = 'none';
				timeWrap.style.display = 'none';
			}
		}

		toggleFields();
		periodRadios.forEach(
			function ( radio ) {
				radio.addEventListener( 'change', toggleFields );
			}
		);

		var notifyOptions = [
				{
					checkboxSelector: 'input[name="wpvulnerability-config[notify][email]"]',
					fieldId: 'wpvulnerability_emails',
		},
				{
					checkboxSelector: 'input[name="wpvulnerability-config[notify][slack]"]',
					fieldId: 'wpvulnerability_slack_webhook',
		},
				{
					checkboxSelector: 'input[name="wpvulnerability-config[notify][teams]"]',
					fieldId: 'wpvulnerability_teams_webhook',
		},
		];

		function toggleRow( checkbox, row ) {
			if ( ! checkbox || ! row ) {
					return;
			}

			row.style.display = checkbox.checked ? '' : 'none';
		}

		notifyOptions.forEach(
			function ( option ) {
				var checkbox = document.querySelector( option.checkboxSelector );
				var row      = document.getElementById( option.fieldId );
				row          = row ? row.closest( 'tr' ) : null;

				toggleRow( checkbox, row );

				if ( checkbox ) {
					checkbox.addEventListener(
						'change',
						function () {
							toggleRow( checkbox, row );
						}
					);
				}
			}
		);
	}
);