This repository has been archived on 2025-06-10. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
server/htdocs/js/countdown.js

34 lines
902 B
JavaScript

function update_end(server_time, receive_date)
{
var elapsed = new Date() - receive_date;
var left = 10800;
if (typeof end_challenge !== 'undefined')
left = (end_challenge - server_time - elapsed)/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);
}
function getHeader(name, def) {
for (var j = 0; j < getHttp.length(); j++) {
if (getHttp.header(j) == name)
return getHttp.data(j);
}
return def;
}
$(document).ready(function() {
server_time = new Date(getHeader("X-FIC-time"));
receive_date = new Date();
setInterval( function() {
update_end(server_time, receive_date);
}, 1000);
});