diff --git a/js/batch.js b/js/batch.js index b159df0..36b2eec 100644 --- a/js/batch.js +++ b/js/batch.js @@ -1,26 +1,30 @@ -jQuery(document).ready(function($) { +jQuery( document ).ready( function($) { var batch_progress = function ( data ) { $( '.batch-progress-message' ).html( data['progress_message'] ); - $( '.batch-percent' ).html( data['percent'] + "%" ); - $( '.batch-progress > span' ).animate({ width: data['percent'] + "%" }, 500); + var percent = 0; + if ( 'undefined' != typeof data['percent'] ) { + percent = data['percent']; + } + $( '.batch-percent' ).html( percent + "%" ); + $( '.batch-progress > span' ).animate({ width: percent + "%" }, 500); }; function batch_process() { $.post( - ajaxurl+'?action=batch_operations&id='+batch_id, - function(data){ - if (data['do']=='finish') + ajaxurl + '?action=batch_operations&id=' + batch_id, + function( data ) { + if ( 'finish' == data['do'] ) { batch_progress( data ); - $('.batch-message').html(data['message']).delay(1500).queue(function () { - $(location).attr('href',successful_page); - $(this).dequeue(); + $( '.batch-message' ).html( data['message'] ).delay( 1500 ).queue( function () { + $( location ).attr( 'href', successful_page ); + $( this ).dequeue(); } ); } else { - $('.batch-message').html(data['message']); + $( '.batch-message' ).html( data['message'] ); batch_progress( data ); batch_process() } diff --git a/js/batch.min.js b/js/batch.min.js index 5d64cea..9f06938 100644 --- a/js/batch.min.js +++ b/js/batch.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){function b(){a.post(ajaxurl+"?action=batch_operations&id="+batch_id,function(d){"finish"==d["do"]?(c(d),a(".batch-message").html(d.message).delay(1500).queue(function(){a(location).attr("href",successful_page),a(this).dequeue()})):(a(".batch-message").html(d.message),c(d),b())})}var c=function(b){a(".batch-progress-message").html(b.progress_message),a(".batch-percent").html(b.percent+"%"),a(".batch-progress > span").animate({width:b.percent+"%"},500)};b()}); \ No newline at end of file +jQuery(document).ready(function(a){function b(){a.post(ajaxurl+"?action=batch_operations&id="+batch_id,function(d){"finish"==d["do"]?(c(d),a(".batch-message").html(d.message).delay(1500).queue(function(){a(location).attr("href",successful_page),a(this).dequeue()})):(a(".batch-message").html(d.message),c(d),b())})}var c=function(b){a(".batch-progress-message").html(b.progress_message);var c=0;"undefined"!=typeof b.percent&&(c=b.percent),a(".batch-percent").html(c+"%"),a(".batch-progress > span").animate({width:c+"%"},500)};b()}); \ No newline at end of file