-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchronometre.js
71 lines (58 loc) · 1.72 KB
/
chronometre.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var startTime = new Date();
var phase_actuelle = "off";
var start = new Date();;
var end = 0;
var diff = 0;
var tDiff = 0;
var timerID = 0;
function chrono(){
end = new Date();
diff = end - start;
diff = new Date(diff);
var sec = diff.getSeconds();
var min = diff.getMinutes();
var hr = diff.getHours()-1;
if (min < 10) min = "0" + min;
if (sec < 10) sec = "0" + sec;
//TOTAL
tDiff = new Date(end-startTime);
var tSec = tDiff.getSeconds();
var tMin = tDiff.getMinutes();
var tHr = tDiff.getHours()-1;
if (tMin < 10) tMin = "0" + tMin;
if (tSec < 10) tSec = "0" + tSec;
document.getElementById("chronotime").innerHTML = hr + ":" + min + ":" + sec;
document.getElementById("total").innerText = tHr + ":" + tMin + ":" + tSec;
timerID = setTimeout("chrono()", 1000)
}
function setOn() {
if(phase_actuelle!="on") {
phase_actuelle = "on";
document.getElementById("phase").innerText = "ON";
document.body.className = "on";
chronoReset();
$("#cOn").html(((parseInt($("#cOn").html()))+1));
}
}
function setOff() {
if(phase_actuelle!="off") {
phase_actuelle = "off";
document.getElementById("phase").innerText = "OFF";
document.body.className = "off";
chronoReset();
$("#cOff").html(((parseInt($("#cOff").html()))+1));
}
}
function setNormale() {
if(phase_actuelle!="normale") {
phase_actuelle = "normale";
document.getElementById("phase").innerText = "NORMALE";
document.body.className = "normale";
chronoReset();
$("#cNormale").html(((parseInt($("#cNormale").html()))+1));
}
}
function chronoReset() {
start = new Date();
chrono();
}