-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.html
More file actions
143 lines (117 loc) · 3.92 KB
/
timer.html
File metadata and controls
143 lines (117 loc) · 3.92 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html>
<head>
<style>
h1
{
text-align: center;
font-family: "Jokerman";
font-size:350%%;
font-style:bold;
}
button
{
background-color: #555555;
border: 2px solid #e7e7e7;
color: white;
padding: 15px 32px;
border-radius: 50%;
text-align: center;
text-decoration: none;
font-family: "Jokerman";
display: inline-block;
font-size: 20px;
margin: 4px 2px;
left:25em;
top:4em;
}
input[type=number]{
width: 40px;
border: 2px solid #555555;
padding: 15px;
border-radius: 50%;
text-align: center;
font-family: "Jokerman";
display: inline-block;
font-size: 20px;
margin: 4px 2px;
left:30em;
}
body{background-color:red;}
label{margin-left:30em;}
</style>
<h1>COUNTDOWN BEGINS!!!</h1>
</head>
<body>
<form>
<label for="days">ENTER TIME IN DAYS</label>
<input id="days" type="number" name="countdown"><br>
<label for="hours">ENTER TIME IN HOURS</label>
<input id="hr" type="number" name="countdown"><br>
<label for="minutes">ENTER TIME IN MINUTES</label>
<input id="min" type="number" name="countdown"><br>
<label for="seconds">ENTER TIME IN SECONDS</label>
<input id="sec" type="number" name="countdown"><br>
</form>
<button id="submit" onclick="startFunction()" >START</button>
<button id="stop"onclick="stopFunction()" >STOP</button>
<button id="reset"onclick="resetFunction()" >RESET</button>
<h1 id="message" ></h1>
<div style="margin-top:6px;margin-left:5em;"><span id="time" style="font-size:200%;font-family:Jokerman;"></span></div>
<script>
var det;
function startFunction() {
document.getElementById("message").innerHTML="COUNTING";
clearInterval(det);
var days=document.getElementById("days").value;
var hr=document.getElementById("hr").value;
var min=document.getElementById("min").value;
var sec=document.getElementById("sec").value;
var dur=Number(days)*86400+Number(hr)*3600+Number(min)*60+Number(sec);
var timer = dur,days,hours,minutes, seconds;
var display=document.getElementById("time");
det=setInterval(function () {
days=parseInt(timer / 86400, 10);
hours = parseInt((timer % 86400)/3600, 10);
minutes = parseInt(((timer % 86400)%3600)/60, 10);
seconds = parseInt(((timer % 86400)%3600)%60, 10);
days = days< 10 ? "0" + days : days;
hours = hours < 10 ? "0" + hours : hours;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = days + " -DAYS-" + hours + " -HOURS-" + minutes + " -MIN- " + seconds +"-SECONDS ";
if (timer <= 0) {
timer = 0;
document.getElementById("message").innerHTML="COUNTDOWN COMPLETE";
}else --timer;
}, 1000);
}
function stopFunction()
{
var display=document.getElementById("time");
document.getElementById("message").innerHTML="COUNTDOWN COMPLETE";
clearInterval(det);
}
function resetFunction()
{ var display=document.getElementById("time");
clearInterval(det);
document.getElementById("message").innerHTML="RESETING...";
var days=document.getElementById("days").value;
var hr=document.getElementById("hr").value;
var min=document.getElementById("min").value;
var sec=document.getElementById("sec").value;
var dur=Number(days)*86400+Number(hr)*3600+Number(min)*60+Number(sec);
var timer = duration,days,hours,minutes, seconds;
days=parseInt(timer / 86400, 10);
hours = parseInt((timer % 86400)/3600, 10);
minutes = parseInt(((timer % 86400)%3600)/60, 10);
seconds = parseInt(((timer % 86400)%3600)%60, 10);
days = days< 10 ? "0" + days : days;
hours = hours < 10 ? "0" + hours : hours;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = days + " -DAYS-" + hours + " -HOURS-" + minutes + " -MIN- " + seconds +"- SECONDS ";
}
</script>
</body>
</html>