]>
iEval git - gruntmaster-page.git/blob - js/90-timers.js
e03ae08dcf3171a13ad872225f1a94da512d0efa
3 function update_timer(timer
){
4 var start
= parseInt(timer
.dataset
.start
);
5 var stop
= parseInt(timer
.dataset
.stop
);
6 var value
= parseInt(timer
.dataset
.value
);
7 var now
= Math
.floor(Date
.now() / 1000) + offset
;
10 var total
= stop
- start
;
15 value
= Math
.max(value
* 3 / 10, value
* left
/ total
);
16 timer
.innerHTML
= Math
.floor(value
);
18 var hours
= Math
.floor(left
/ 60 / 60);
19 hours
= hours
< 10 ? '0' + hours
: hours
;
20 var minutes
= Math
.floor(left
/ 60) % 60;
21 minutes
= minutes
< 10 ? '0' + minutes
: minutes
;
22 var seconds
= left
% 60;
23 seconds
= seconds
< 10 ? '0' + seconds
: seconds
;
24 timer
.innerHTML
= hours
+ ':' + minutes
+ ':' + seconds
;
29 $('.timer').each(item
=> {
31 setInterval(() => update_timer(item
), 1000);
33 let xhr
= new XMLHttpRequest();
34 xhr
.open('HEAD', '/');
36 let srvtime
= Date
.parse(xhr
.getResponseHeader('Date'));
37 offset
= Math
.ceil((srvtime
- Date
.now()) / 1000);
38 console
.log("Offset from server: " + offset
);
This page took 0.049084 seconds and 3 git commands to generate.