stop the refresh countdown once we hit zero

This commit is contained in:
Stephen Birarda 2014-09-26 14:15:56 -07:00
parent 80f1594a17
commit 2a7626159c

View file

@ -193,13 +193,14 @@ function showRestartModal() {
refreshSpan.html(numberOfSecondsToWait + " seconds"); refreshSpan.html(numberOfSecondsToWait + " seconds");
// call ourselves every 1 second to countdown // call ourselves every 1 second to countdown
window.setInterval(function(){ var refreshCountdown = setInterval(function(){
secondsElapsed++; secondsElapsed++;
secondsLeft = numberOfSecondsToWait - secondsElapsed secondsLeft = numberOfSecondsToWait - secondsElapsed
refreshSpan.html(secondsLeft + (secondsLeft == 1 ? " second" : " seconds")) refreshSpan.html(secondsLeft + (secondsLeft == 1 ? " second" : " seconds"))
if (secondsElapsed == numberOfSecondsToWait) { if (secondsElapsed == numberOfSecondsToWait) {
location.reload(true); location.reload(true);
clearInterval(refreshCountdown);
} }
}, 1000); }, 1000);
} }