PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.6.10
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.6.10
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-tab-switcher.js

metasync-tab-switcher.js in Search Atlas SEO – OTTO AI SEO Automation for WordPress 2.6.10, at admin/js/metasync-tab-switcher.js

82 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * MetaSync tab switcher for redirections / 404-monitor page.
3 *
4 * Extracted from admin/class-metasync-admin.php (Phase 5, #887).
5 */
6 jQuery(document).ready(function($) {
7 // Function to switch to a specific tab
8 function switchToTab(targetTab) {
9 // Update active tab
10 $('.metasync-tab-nav a').removeClass('active');
11 $('.metasync-tab-nav a[data-tab="' + targetTab + '"]').addClass('active');
12
13 // Show target content
14 $('.metasync-tab-content').removeClass('active');
15 $('#' + targetTab + '-content').addClass('active');
16 }
17
18 // Initialize tabs immediately
19 function initializeTabs() {
20 // Check URL parameter on page load
21 var urlParams = new URLSearchParams(window.location.search);
22 var currentTab = urlParams.get('tab');
23
24 // Always ensure a tab is active
25 if (currentTab && (currentTab === 'redirections' || currentTab === '404-monitor')) {
26 // Switch to the tab specified in URL
27 switchToTab(currentTab);
28 } else {
29 // No tab parameter or invalid tab, ensure redirections is active
30 switchToTab('redirections');
31 currentTab = 'redirections';
32 }
33
34 // Clean up irrelevant pagination parameters based on active tab
35 var needsCleanup = false;
36 if (currentTab === '404-monitor') {
37 if (urlParams.has('paged') || urlParams.has('paged_redir')) {
38 urlParams.delete('paged');
39 urlParams.delete('paged_redir');
40 needsCleanup = true;
41 }
42 } else if (currentTab === 'redirections') {
43 if (urlParams.has('paged') || urlParams.has('paged_404')) {
44 urlParams.delete('paged');
45 urlParams.delete('paged_404');
46 needsCleanup = true;
47 }
48 }
49
50 // Update URL if cleanup was needed
51 if (needsCleanup) {
52 var newUrl = window.location.pathname + '?' + urlParams.toString();
53 window.history.replaceState({}, '', newUrl);
54 }
55 }
56
57 // Initialize tabs immediately
58 initializeTabs();
59
60 // Also initialize after a short delay as backup
61 setTimeout(initializeTabs, 100);
62
63 // Handle tab switching on click
64 $('.metasync-tab-nav a').on('click', function(e) {
65 e.preventDefault();
66
67 var targetTab = $(this).data('tab');
68 switchToTab(targetTab);
69
70 // Update URL without page reload and clean up pagination parameters
71 var url = new URL(window.location);
72 url.searchParams.set('tab', targetTab);
73
74 // Remove all pagination parameters when switching tabs
75 url.searchParams.delete('paged');
76 url.searchParams.delete('paged_404');
77 url.searchParams.delete('paged_redir');
78
79 window.history.pushState({}, '', url);
80 });
81 });
82