You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
onthedots/code/timer.js

33 lines
1.1 KiB

var fin = new Date();
fin.setMinutes(fin.getMinutes()+tpsRem[1]);
document.getElementById("timer").innerHTML = tpsRem[0] + ":" + tpsRem[1] + ":" + tpsRem[2];
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();;
// Find the distance between now and the count down date
var distance = fin - now;
// Time calculations for days, hours, minutes and seconds
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("timer").innerHTML = hours + ":" + minutes + ":" + seconds;
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
console.log("OUT");
window.location.replace("./score.php?pts="+points+"&mode="+get['mode']+"&diff="+get['diff']+"&pseudo="+get['pseudo']);
}
}, 1000);
function addTime(secs)
{
fin.setSeconds(fin.getSeconds()+secs);
}