PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 2.1.4
MxChat – AI Chatbot & Content Generation for WordPress v2.1.4
3.2.21 3.2.20 3.2.19 3.2.18 3.2.17 3.2.16 3.2.15 3.2.14 3.2.12 3.2.13 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 2.0.3 2.0.4 2.0.5 2.0.6 All 152 releases
mxchat-basic / js / admin-status.js

admin-status.js in MxChat – AI Chatbot & Content Generation for WordPress 2.1.4, at js/admin-status.js

94 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Admin status auto-update functionality
3 */
4 (function($) {
5 'use strict';
6
7 // Status update interval ID
8 let statusInterval = null;
9 const refreshInterval = 3000; // 3 seconds
10
11 /**
12 * Updates the status cards with fresh data
13 */
14 function updateStatus() {
15 $.ajax({
16 url: mxchat_status_data.ajax_url,
17 type: 'POST',
18 data: {
19 action: 'mxchat_get_status_updates',
20 nonce: mxchat_status_data.nonce
21 },
22 success: function(response) {
23 // Update sitemap status if it exists
24 if (response.sitemap_status) {
25 // Update progress bar
26 $('.mxchat-status-card:contains("Sitemap Processing") .mxchat-progress-fill')
27 .css('width', response.sitemap_status.percentage + '%');
28
29 // Update status text
30 $('.mxchat-status-card:contains("Sitemap Processing") .mxchat-status-details p:first')
31 .text('Progress: ' + response.sitemap_status.processed_urls + ' of ' +
32 response.sitemap_status.total_urls + ' URLs (' +
33 response.sitemap_status.percentage + '%)');
34
35 // If complete, refresh the page to clean up
36 if (response.sitemap_status.status === 'complete') {
37 location.reload();
38 }
39 } else {
40 // If no more sitemap status, remove the card with animation
41 $('.mxchat-status-card:contains("Sitemap Processing")').fadeOut(300);
42 }
43
44 // Update PDF status if it exists
45 if (response.pdf_status) {
46 // Update progress bar
47 $('.mxchat-status-card:contains("PDF Processing") .mxchat-progress-fill')
48 .css('width', response.pdf_status.percentage + '%');
49
50 // Update status text
51 $('.mxchat-status-card:contains("PDF Processing") .mxchat-status-details p:first')
52 .text('Progress: ' + response.pdf_status.processed_pages + ' of ' +
53 response.pdf_status.total_pages + ' pages (' +
54 response.pdf_status.percentage + '%)');
55
56 // If complete, refresh the page to clean up
57 if (response.pdf_status.status === 'complete') {
58 location.reload();
59 }
60 } else {
61 // If no more PDF status, remove the card with animation
62 $('.mxchat-status-card:contains("PDF Processing")').fadeOut(300);
63 }
64
65 // If nothing is processing anymore, stop checking
66 if (!response.is_processing) {
67 clearInterval(statusInterval);
68 // Maybe reload the page to refresh the table with new data
69 location.reload();
70 }
71 }
72 });
73 }
74
75 // Initialize when the document is ready
76 $(document).ready(function() {
77 // Change the text in the status headers
78 $('.mxchat-status-header h4:contains("Refresh for update")').each(function() {
79 $(this).text($(this).text().replace('(Refresh for update)', '(Auto-updating)'));
80 });
81
82 // Start auto-updating if we have status cards
83 if ($('.mxchat-status-card').length > 0) {
84 updateStatus(); // Run once immediately
85 statusInterval = setInterval(updateStatus, refreshInterval);
86 }
87
88 // Monitor for form submissions to start the updates
89 $('#mxchat-sitemap-form').on('submit', function() {
90 // We'll start the updating when the page reloads and shows a status card
91 });
92 });
93
94 })(jQuery);