jQuery(document).ready(function($) { var sessionTotal = 0; function checkStatus() { $.post(ajaxurl, { action: 'v1_sync_init', security: v1_nonce }, function(res) { if (res.success) { $('#sync-status').html('Resume point: ' + res.data.last_date + ''); } }); } checkStatus(); $('#btn-sync').on('click', function() { var $btn = $(this); $btn.prop('disabled', true).text('Syncing...'); $('#sync-progress-wrap, #sync-msg').show(); function shovelData() { $.post(ajaxurl, { action: 'v1_sync_batch', security: v1_nonce }, function(res) { if (res.success) { var moved = res.data.count; if (moved > 0) { sessionTotal += moved; $('#sync-msg').text('Moved ' + sessionTotal.toLocaleString() + ' records so far...'); // Smooth progress bar simulation var simulatedPct = Math.min((sessionTotal / 210000) * 100, 99); $('#sync-progress-bar').css('width', simulatedPct + '%'); shovelData(); // GO AGAIN } else { $('#sync-msg').text('Finished! Everything is synced.'); $('#sync-progress-bar').css({'width': '100%', 'background': '#46b450'}); $btn.prop('disabled', false).text('Sync Complete'); checkStatus(); } } }).fail(function(xhr) { $('#sync-msg').html('Paused. Moved ' + sessionTotal.toLocaleString() + ' this session. Refresh to continue.'); $btn.prop('disabled', false).text('Resume Sync'); }); } shovelData(); }); $('#v1-dashboard').on('click', '#btn-wipe', function() { if(confirm('Wipe and restart?')) { $.post(ajaxurl, {action:'v1_sync_wipe', security:v1_nonce}, function() { location.reload(); }); } }); }); s386 Archives - Institute for Sound Public Policy

Tag Archives: s386

Sen. Mike Lee: Architect Behind Anti-American Bill

It’s an appalling reality that in the entire U.S. Senate not one single member is  [...]