-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
132 lines (106 loc) · 3 KB
/
index.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Lazy Countdown</title>
<link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/comic-neue" type="text/css"/>
<style type="text/css" media="screen">
body {
margin: 0;
background-color: #000;
}
.container {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.container h1 {
color: #fff;
font-size: 20vw;
font-family: "ComicNeueAngularRegular","Helvetica Neue", sans-serif;
font-weight: 300;
margin: 0;
}
#newYearText {
font-size: 5vw;
}
.container .critical {
color: #FF5355;
font-weight: bold;
}
canvas{
background-color: transparent;
z-index: -1;
position: absolute;
top: 0px;
left: 0px;
}
</style>
<script src="firework.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
console.log('Loaded')
var container = document.querySelector('.container')
var countdown = document.querySelector('#countdown')
var newYear = document.querySelector('#newyear')
var newYearText = document.querySelector('#newYearText')
var NEW_YEAR = 15462756e5
var isResumed = false
var isNewYear = false
document.querySelector('body').addEventListener('click', function() {
if (isNewYear) {
var audioEl = document.querySelector('audio')
if (audioEl) {
audioEl.play()
} else {
window.createAudio()
}
}
})
window.createAudio = function() {
var audio = document.createElement('audio')
audio.src = 'newyear.mp3'
audio.play()
container.appendChild(audio)
}
window.itsNewYear = function() {
isNewYear = true
countdown.style.display = 'none'
newYear.style.display = 'block'
newYearText.style.display = 'block'
createAudio()
}
window.timer = setInterval(function() {
var ms = NEW_YEAR - Date.now()
var secs = Math.floor(ms / 1000)
var hours = Math.floor(secs / 3600);
var minutes = Math.floor((secs - (hours * 3600)) / 60);
var seconds = secs - (hours * 3600) - (minutes * 60);
document.querySelector('#countdown').innerHTML = hours.toFixed(0).padStart(2, '0') + ":" + minutes.toFixed(0).padStart(2, '0') + ":" + seconds.toFixed(0).padStart(2, '0');
// Happy New Year!
if (Date.now() >= NEW_YEAR) {
clearInterval(timer)
itsNewYear()
return
}
// 60 Seconds before New Year
if (secs <= 60) {
document.querySelector('#countdown').className = 'critical'
}
}, 1000)
var controller = new Controller()
controller.init()
requestAnimationFrame(controller.animation)
})
</script>
</head>
<body>
<div class="container">
<h1 id="countdown"></h1>
<h1 id="newYearText" style="display: none;">Happy New Year 2019 🎉</h1>
</div>
<canvas id="newyear" style="display: none;"></canvas>
</body>
</html>