Skip to content

Instantly share code, notes, and snippets.

@dsaiztc
Created June 1, 2017 12:54
Show Gist options
  • Save dsaiztc/1ef4a56fc9ade46665871f16758d0804 to your computer and use it in GitHub Desktop.
Save dsaiztc/1ef4a56fc9ade46665871f16758d0804 to your computer and use it in GitHub Desktop.
Reload page on timeout.
function reloadPageOnTimeout(duration, display) {
var timer = duration, minutes, seconds;
setInterval(function () {
minutes = parseInt(timer / 60, 10);
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.text(minutes + ":" + seconds);
if (--timer < 0) {
//timer = duration;
location.reload();
}
}, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment