]> git.datanom.net - qtadmin.git/blob - js/timer.js
initial release
[qtadmin.git] / js / timer.js
1 /* vim: set ts=4 tw=0 sw=4 noet: */
2 var timerRef=setInterval(function(){myTimer()},1000);
3 var timeStart = new Date().getTime() + timeout;
4
5 function myTimer() {
6 var elapsed = new Date().getTime();
7 var expire = timeStart - elapsed;
8 var timeLeft = Math.round(((expire % 86400000) % 3600000) / 60000);
9
10 if (timeLeft < 0) {
11 timeLeft = 'Expired';
12 document.getElementById("time").style.background = "red";
13 clearInterval(timerRef);
14 } else {
15 timeLeft += 1;
16 timeLeft = '< ' + timeLeft + ' min';
17 }
18
19 document.getElementById("timer").innerHTML = timeLeft;
20 }
This page took 0.057635 seconds and 6 git commands to generate.