-
Notifications
You must be signed in to change notification settings - Fork 0
/
newscript.txt
76 lines (66 loc) · 1.51 KB
/
newscript.txt
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
<!DOCTYPE html>
<html>
<body>
<p>A counter that you can Start/Stop/Pause</p>
<p id="timer"></p>
<button onclick="ReStartFunction()">ReStart</button>
<button onclick="StopFunction()">Stop</button>
<button id="pause" onclick="PauseFunction()">pause</button>
<script>
var pause=0;
var count=0;
var counter=setInterval(timer, 1000);
var stoped=0
function timer()
{
count=count+1;
document.getElementById("timer").innerHTML=count + " secs";
}
function StopFunction()
{
clearInterval(counter);
window.count=0;
window.pause=0;
document.getElementById("pause").innerHTML="Pause"
window.stoped=1
document.getElementById("timer").innerHTML=count + " secs";
}
function ReStartFunction()
{
if (counter)
{
clearInterval(counter);
window.pause=0;
window.count=0;
window.stoped=0
window.counter=setInterval(timer, 1000);
count=count+1;
document.getElementById("pause").innerHTML="Pause"
document.getElementById("timer").innerHTML=count + " secs";
}
}
function PauseFunction()
{
if (stoped==0)
{
if (pause==0)
{
clearInterval(counter);
document.getElementById("pause").innerHTML="Resume"
pause=1;
return;
}
if (pause==1)
{
window.counter=setInterval(timer, 1000);
document.getElementById("timer").innerHTML=count + " secs";
document.getElementById("pause").innerHTML="Pause"
pause=0;
return;
}
}
return;
}
</script>
</body>
</html>