Created
September 4, 2015 16:20
-
-
Save nguyenvanduocit/b29cb9c7ef09e5ce7c7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
function($){ | |
$( document ).ready(function() { | |
var isProcessing = false; | |
var regenerateStatus = $('#regenerateStatus'); | |
var statusString = $('#statusString'); | |
var processedCountText = $('#processed'); | |
var totalCountText = $('#total'); | |
var startStopRegenerateButton = $('#startStopRegenerate'); | |
$(document).on('click', '#startStopRegenerate', function(e){ | |
e.preventDefault(); | |
if(!isProcessing){ | |
isProcessing = true; | |
regenerateStatus.show(); | |
startStopRegenerateButton.text('Dừng lại'); | |
requestNextStep(); | |
} | |
else | |
{ | |
isProcessing = false; | |
startStopRegenerateButton.text('Bắt đầu'); | |
} | |
}); | |
function requestNextStep(){ | |
$.ajax({ | |
method: "POST", | |
url: ajaxurl , | |
data: { | |
action:'regeneratethumbnail-next-step' | |
} | |
}).success(function( data ) { | |
console.log(data); | |
if(data.success){ | |
processedCountText.text(data.proccessed); | |
totalCountText.text(data.total); | |
if(typeof data.done == 'undefined'){ | |
requestNextStep(); | |
} | |
else{ | |
startStopRegenerateButton.click(); | |
alert('Done'); | |
} | |
} | |
}); | |
} | |
}); | |
} | |
)(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment