server/htdocs/js/countdown.js

25 lines
550 B
JavaScript

function update_end()
{
var left;
if (typeof end_challenge === 'undefined')
left = 14400;
else
left = (end_challenge - new Date())/1000;
if (left < 0) left = 0;
var heure = Math.floor(left / 3600);
var min = Math.floor((left / 60) % 60);
var sec = Math.floor(left % 60);
$("#hours").html(( heure < 10 ? "0" : "" ) + heure);
$("#min").html(( min < 10 ? "0" : "" ) + min);
$("#sec").html(( sec < 10 ? "0" : "" ) + sec);
}
$(document).ready(function() {
setInterval( function() {
update_end();
}, 1000);
});