-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.html
67 lines (67 loc) · 1.89 KB
/
timer.html
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
<!DOCTYPE html>
<html>
<head>
<title>Solar Meditation</title>
</head>
<body>
<div id="timerDiv"><p id="timer">00:00</p></div>
<button type="button" id="exit" onclick="window.location.href = 'index.html';">Exit</button>
</body>
<style>
body{
background: #2d84a9;
}
#timerDiv{
width: 97%;
margin: 0 auto;
height: 69vh;
font-size: 72px;
border-width: 0;
border-radius: 26px;
background: #2d84a9;
box-shadow: inset 5px 5px 10px #266f8e,
inset -5px -5px 10px #3499c4;
text-align: center;
position: relative;
}
#timerDiv p{
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#exit{
width: 97%;
margin: 0 auto;
height: 29vh;
font-size: 72px;
text-align: center;
border-radius: 26px;
border-width: 0;
background: #2d84a9;
box-shadow: 5px 5px 10px #266f8e,
-5px -5px 10px #3499c4;
}
</style>
<script>
var url = new URL(window.location.href);
var params = url.searchParams;
var minutes = params.get("time");
var seconds = minutes * 60;
var bell = new Audio("bell.ogx");
bell.play();
var x = setInterval( () =>{
var min = Math.floor(seconds/60);
var sec = Math.floor((seconds/60 - min) * 60);
document.getElementById("timer").innerHTML = min + ":" + sec;
console.log(min + ":" + sec);
seconds--;
if(seconds < 0){
clearInterval(x);
document.getElementById("timer").innterHTML = "Done";
bell.play();
}
}, 1000);
</script>
</html>