PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.6.9
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.6.9
2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 2.6.4 2.6.3 2.5.23 All 138 releases
metasync / admin / js / metasync-debug-mode.js

metasync-debug-mode.js in Search Atlas SEO – OTTO AI SEO Automation for WordPress 2.6.9, at admin/js/metasync-debug-mode.js

72 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global metasyncDebugData */
2 /**
3 * MetaSync Debug Mode
4 *
5 * Extracted for Phase 5, #887 — Part B JS extraction.
6 * Handles the debug-mode timer UI and auto-refresh when debug mode expires.
7 *
8 * Localized data object: metasyncDebugData
9 * - enabled (bool) — whether debug mode is currently enabled
10 * - indefinite (bool) — whether debug mode is set to indefinite
11 * - timeRemaining (int) — seconds remaining for debug mode
12 * - statusUrl (string) — REST endpoint for debug-mode status
13 * - restNonce (string) — wp_rest nonce for REST requests
14 *
15 * @since Phase 5
16 * @see wp_localize_script() call in class-metasync-admin.php
17 */
18
19 jQuery(document).ready(function($) {
20 // Show warning when indefinite mode is checked
21 $('#indefinite-mode-advanced').on('change', function() {
22 if ($(this).is(':checked')) {
23 $('#indefinite-warning-advanced').slideDown();
24 } else {
25 $('#indefinite-warning-advanced').slideUp();
26 }
27 });
28
29 // Auto-update time remaining every minute
30 var initialTimeRemaining = metasyncDebugData.enabled && !metasyncDebugData.indefinite ? metasyncDebugData.timeRemaining : 0;
31 var hasReloaded = false;
32
33 function updateDebugTimeRemaining() {
34 if (initialTimeRemaining <= 0 || hasReloaded) {
35 return;
36 }
37
38 $.ajax({
39 url: metasyncDebugData.statusUrl,
40 method: 'GET',
41 beforeSend: function(xhr) {
42 xhr.setRequestHeader('X-WP-Nonce', metasyncDebugData.restNonce);
43 },
44 success: function(response) {
45 console.log('MetaSync Debug Mode Status:', response);
46
47 if (response && typeof response.time_remaining !== 'undefined') {
48 if (response.time_remaining_formatted) {
49 $('.debug-time-remaining').text(response.time_remaining_formatted);
50 }
51
52 if (response.time_remaining <= 0 && initialTimeRemaining > 0 && !hasReloaded) {
53 hasReloaded = true;
54 console.log('Debug mode expired, reloading page...');
55 setTimeout(function() {
56 window.location.reload();
57 }, 2000);
58 }
59 }
60 },
61 error: function(xhr, status, error) {
62 console.error('MetaSync Debug Mode: Failed to update time remaining', error);
63 }
64 });
65 }
66
67 if (metasyncDebugData.enabled && !metasyncDebugData.indefinite && initialTimeRemaining > 0) {
68 setTimeout(updateDebugTimeRemaining, 2000);
69 setInterval(updateDebugTimeRemaining, 60000);
70 }
71 });
72