/* vim: set ts=4 tw=4 sw=4 noet: */ var timerRef=setInterval(function(){myTimer()},1000); var timeStart = new Date().getTime() + timeout; function myTimer() { var elapsed = new Date().getTime(); var expire = timeStart - elapsed; var timeLeft = Math.round(((expire % 86400000) % 3600000) / 60000); if (timeLeft < 1) { /*timeLeft = 'Expired'; document.getElementById("time").style.background = "red";*/ clearInterval(timerRef); location.reload(); } else { //timeLeft += 1; timeLeft = '< ' + timeLeft + ' min'; } document.getElementById("timer").innerHTML = timeLeft; }