-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
128 lines (113 loc) · 3.28 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
<style>
.container {
align-items: center;
display: flex;
flex-direction: column;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
margin: 0 auto;
text-align: center;
line-height: 1;
}
.headline {
font-weight: {{headline_weight}};
letter-spacing: 0.125rem;
text-transform: uppercase;
color: {{headline_color}};
}
.countdown ul li {
display: inline-block;
font-size: 1.5em;
list-style-type: none;
padding: 1em;
text-transform: uppercase;
color: {{count_txt_color}};
}
.countdown ul li span {
display: block;
font-size: 4.5rem;
color: {{count_num_color}};
}
.emoji {
display: none;
padding: 1rem;
}
.emoji span {
font-size: 4rem;
padding: 0 0.5rem;
}
@media all and (max-width: 425px) {
.headline {
font-size: calc(1.5rem * var(--smaller));
}
.countdown ul li {
font-size: calc(1.125rem * var(--smaller));
}
.countdown ul li span {
font-size: calc(3.375rem * var(--smaller));
}
}
</style>
<div class="container">
<h1 class="headline" id="headline">{{headline}}</h1>
<div class="countdown" id="countdown">
<ul>
<li><span class="days" id="days"></span>days</li>
<li><span class="hours" id="hours"></span>Hours</li>
<li><span class="minutes" id="minutes"></span>Minutes</li>
<li><span class="seconds" id="seconds"></span>Seconds</li>
</ul>
</div>
<div id="content" class="emoji">
<span>{{emoji1}}</span>
<span>{{emoji2}}</span>
<span>{{emoji3}}</span>
</div>
</div>
<script>
(function () {
const second = 1000,
minute = second * 60,
hour = minute * 60,
day = hour * 24;
//I'm adding this section so I don't have to keep updating this pen every year :-)
//remove this if you don't need it
let today = new Date(),
dd = String(today.getDate()).padStart(2, "0"),
mm = String(today.getMonth() + 1).padStart(2, "0"),
yyyy = today.getFullYear(),
nextYear = yyyy + 1,
dayMonth = "{{month}}/{{day}}/",
eventdate = dayMonth + yyyy;
today = mm + "/" + dd + "/" + yyyy;
if (today > eventdate) {
eventdate = dayMonth + nextYear;
}
//end
const countDown = new Date(eventdate).getTime(),
x = setInterval(function () {
const now = new Date().getTime(),
distance = countDown - now;
(document.getElementById("days").innerText = Math.floor(
distance / day
)),
(document.getElementById("hours").innerText = Math.floor(
(distance % day) / hour
)),
(document.getElementById("minutes").innerText = Math.floor(
(distance % hour) / minute
)),
(document.getElementById("seconds").innerText = Math.floor(
(distance % minute) / second
));
//do something later when date is reached
if (distance < 0) {
document.getElementById("headline").innerText = "It's my birthday!";
document.getElementById("countdown").style.display = "none";
document.getElementById("content").style.display = "block";
clearInterval(x);
}
//seconds
}, 0);
})();
</script>