-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchrono.js
More file actions
35 lines (34 loc) · 808 Bytes
/
chrono.js
File metadata and controls
35 lines (34 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var start = 0;
var end = 0;
var diff = 0;
var timer = 0;
var time;
var test;
// Chrono for each flag , star after flag load, stop when answer is found
function chrono() {
end = new Date();
diff = end - start;
test = diff;
diff = new Date(diff);
var msec = diff.getMilliseconds();
var sec = diff.getSeconds();
var min = diff.getMinutes();
if (msec < 10) {
msec = "00" + msec
} else if (msec < 100) {
msec = "0" + msec
}
time = addZero(min) + ":" + addZero(sec) + ":" + msec;
$('#time').html(time);
if (!stopChrono) {
timer = setTimeout("chrono()", 10);
}
}
// add a zero to sec and min for display purpose
function addZero(nombre) {
if (nombre < 10) {
return "0" + nombre;
} else {
return nombre;
}
}