- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.html
More file actions
Latest commit
143 lines (117 loc) · 3.92 KB
/
Copy pathtimer.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:15px32px;
border-radius:50%;
text-align: center;
text-decoration: none;
font-family:"Jokerman";
display: inline-block;
font-size:20px;
margin:4px2px;
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:4px2px;
left:30em;
}
body{background-color:red;}
label{margin-left:30em;}
</style>
<h1>COUNTDOWN BEGINS!!!</h1>
</head>
<body>
<form>
<labelfor="days">ENTER TIME IN DAYS</label>
<inputid="days" type="number" name="countdown"><br>
<labelfor="hours">ENTER TIME IN HOURS</label>
<inputid="hr" type="number" name="countdown"><br>
<labelfor="minutes">ENTER TIME IN MINUTES</label>
<inputid="min" type="number" name="countdown"><br>
<labelfor="seconds">ENTER TIME IN SECONDS</label>
<inputid="sec" type="number" name="countdown"><br>
</form>
<buttonid="submit" onclick="startFunction()" >START</button>
<buttonid="stop"onclick="stopFunction()" >STOP</button>
<buttonid="reset"onclick="resetFunction()" >RESET</button>
<h1id="message" ></h1>
<divstyle="margin-top:6px;margin-left:5em;"><spanid="time" style="font-size:200%;font-family:Jokerman;"></span></div>
<script>
vardet;
functionstartFunction(){
document.getElementById("message").innerHTML="COUNTING";
clearInterval(det);
vardays=document.getElementById("days").value;
varhr=document.getElementById("hr").value;
varmin=document.getElementById("min").value;
varsec=document.getElementById("sec").value;
vardur=Number(days)*86400+Number(hr)*3600+Number(min)*60+Number(sec);
vartimer=dur,days,hours,minutes,seconds;
vardisplay=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);
}
functionstopFunction()
{
vardisplay=document.getElementById("time");
document.getElementById("message").innerHTML="COUNTDOWN COMPLETE";
clearInterval(det);
}
functionresetFunction()
{vardisplay=document.getElementById("time");
clearInterval(det);
document.getElementById("message").innerHTML="RESETING...";
vardays=document.getElementById("days").value;
varhr=document.getElementById("hr").value;
varmin=document.getElementById("min").value;
varsec=document.getElementById("sec").value;
vardur=Number(days)*86400+Number(hr)*3600+Number(min)*60+Number(sec);
vartimer=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>