HEX
Server: LiteSpeed
System: Linux onyx.7ho.st 5.14.0-611.13.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 11 04:57:59 EST 2025 x86_64
User: atiscoir (1242)
PHP: 8.1.34
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: /home/atiscoir/public_html/wp-content/plugins/simple-history/js/scripts.js
/**
 * When the clear-log-button in admin is clicked then check that users really wants to clear the log
 */
jQuery( '.js-SimpleHistory-Settings-ClearLog' ).on( 'click', function ( e ) {
	if ( ! confirm( simpleHistoryScriptVars.settingsConfirmClearLog ) ) {
		e.preventDefault();
	}
} );

/**
 * Handle dev mode toggle badge clicks (premium, experimental, etc.)
 */
jQuery( document ).ready( function ( $ ) {
	$( '.sh-PageHeader-badge--toggle' ).on( 'click', function ( e ) {
		e.preventDefault();

		const $button = $( this );
		const nonce = $button.data( 'nonce' );
		const endpoint = $button.data( 'endpoint' );

		// Disable button during request.
		$button.prop( 'disabled', true );

		// Get REST API root URL.
		let apiRoot = '/wp-json/';
		if ( typeof wpApiSettings !== 'undefined' && wpApiSettings.root ) {
			apiRoot = wpApiSettings.root;
		}

		// Collect any extra data- attributes (e.g. data-plugin).
		const data = {};
		$.each( $button.data(), function ( key, value ) {
			if ( key !== 'nonce' && key !== 'endpoint' ) {
				data[ key ] = value;
			}
		} );

		$.ajax( {
			url: apiRoot + 'simple-history/v1/dev-tools/' + endpoint,
			method: 'POST',
			beforeSend: function ( xhr ) {
				xhr.setRequestHeader( 'X-WP-Nonce', nonce );
			},
			data: data,
			success: function () {
				window.location.reload();
			},
			error: function ( xhr ) {
				let errorMessage = 'Toggle failed.';

				if ( xhr.responseJSON && xhr.responseJSON.message ) {
					errorMessage = xhr.responseJSON.message;
				}

				alert( errorMessage );
				$button.prop( 'disabled', false );
			},
		} );
	} );
} );