-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
77 lines (58 loc) · 1.55 KB
/
script.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
72
73
74
75
76
77
const hrs = document.getElementById("hours");
const min = document.getElementById("minutes");
const sec = document.getElementById("seconds");
const startButton = document.getElementById("start")
let timer;
let hours = 0;
let minutes = 0;
let seconds = 0;
var lapCount = 1;
function updateTime(){
seconds++;
if (seconds>=60){
minutes++;
seconds=0;
}
if (minutes>=60){
hours++;
minutes=0;
}
hrs.textContent = hours? (hours>9? hours : "0"+hours) : "00";
min.textContent = minutes? (minutes>9? minutes : "0"+minutes) : "00";
sec.textContent = seconds? (seconds>9? seconds : "0"+seconds) : "00";
start();
}
function start(){
timer = setTimeout(updateTime,1000);
startButton.disabled = true;
}
function stop(){
clearTimeout(timer);
startButton.disabled = false;
}
function reset(){
seconds = 0;
minutes = 0;
hours = 0;
hrs.textContent = "00";
min.textContent = "00";
sec.textContent = "00";
stop();
lapReset();
}
var list = document.getElementById('para')
function lap(){
if (lapCount<=5){
var para1 = document.createElement("li");
var lap1 = document.createTextNode("Lap "+lapCount+" = "+hours+" : "+minutes+" : "+seconds);
para1.appendChild(lap1);
list.appendChild(para1);
lapCount++;
}
}
function lapReset(){
lapCount=1;
while(list.hasChildNodes()){
list.removeChild(list.firstChild);
}
}