]>
iEval git - plack-app-gruntmaster.git/blob - js/90-timers.js
4 function update_timer(timer
){
5 var start
= parseInt(timer
.dataset
.start
);
6 var stop
= parseInt(timer
.dataset
.stop
);
7 var value
= parseInt(timer
.dataset
.value
);
8 var now
= Math
.floor(Date
.now() / 1000);
10 var left
= stop
- now
;
11 var total
= stop
- start
;
16 value
= Math
.max(value
* 3 / 10, value
* left
/ total
);
17 timer
.innerHTML
= Math
.floor(value
);
19 var hours
= left
/ 60 / 60;
20 hours
= hours
< 10 ? '0' : hours
: hours
;
21 var minutes
= left
/ 60 % 60;
22 minutes
= minutes
< 10 ? '0' : minutes
: minutes
;
23 var seconds
= left
% 60;
24 seconds
= seconds
< 10 ? '0' : seconds
: seconds
;
25 timer
.innerHTML
= hours
+ ':' + minutes
+ ':' + seconds
;
29 $( document
).ready(function() {
30 $('.timer').each(function(index
, item
){
32 setInterval(function(){update_timer(item
)}, 1000);
This page took 0.048263 seconds and 5 git commands to generate.