-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava.js
36 lines (33 loc) · 959 Bytes
/
java.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
window.onload = init;
function init(){
document.getElementById("iniciar").addEventListener("click",cro);
document.getElementById("parar").addEventListener("click",parar);
document.getElementById("reiniciar").addEventListener("click",reiniciar);
h = 0;
m = 0;
s = 0;
document.getElementById("hms").innerHTML="00:00:00";
}
function cro(){
iniciar();
id = setInterval(iniciar,1000);
document.getElementById("iniciar").removeEventListener("click",cro);
}
function iniciar(){
s++;
if (s>59){m++;s=0;}
if (m>59){h++;m=0;}
if (h>24){h=0;}
document.getElementById("hms").innerHTML = h + ":" + m + ":" + s;
}
function parar(){
clearInterval(id);
document.getElementById("iniciar").addEventListener("click",cro);
}
function reiniciar(){
clearInterval(id);
h=0;
s=0;
m=0;
document.getElementById("hms").innerHTML = h + ":" + m + ":" + s;
}