-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
78 lines (65 loc) · 2.86 KB
/
index.html
File metadata and controls
78 lines (65 loc) · 2.86 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
<html>
<head>
<style>
/* @import url('https://fonts.googleapis.com/css2?family=Jost:ital,wght@1,500&display=swap'); */
/* @import url('https://fonts.googleapis.com/css2?family=Jost:ital@1&display=swap'); */
/* @import url('https://fonts.googleapis.com/css2?family=Jost&display=swap'); */
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital@1&display=swap');
/* @import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital@1&display=swap'); */
body {
background-color: black;
color: white;
}
#countdownContainer {
/* font-family: 'Jost', sans-serif; */
font-family: 'Roboto', sans-serif;
/* font-family: 'Open Sans', sans-serif; */
font-size: 2rem;
width: 100%;
text-align: center;
}
</style>
<script>
// Calculate target time to everday at 1:00pm
let targetTime = new Date();
targetTime.setHours(13, 0, 0);
const TARGET_TIME = targetTime;
const COUNTDOWN_COMPLETE_MESSAGE = "Service will begin soon";
let currentCountdownText = "";
let countdownContainer = null;
function getCountdownMessage(timeLeftMs) {
const timeLeftS = Math.floor(timeLeftMs / 1000);
const timeLeftMinutes = Math.floor(timeLeftMs / 1000 / 60);
let countdownMessage = null;
if (timeLeftMinutes > 0) {
let minuteText = (timeLeftMinutes > 1) ? "minutes" : "minute"
countdownMessage = `Service will begin in ${timeLeftMinutes} ${minuteText}`;
}
return countdownMessage;
}
function tick() {
const currentTime = new Date();
const timeLeftMs = TARGET_TIME - currentTime;
let countdownMessage = getCountdownMessage(timeLeftMs);
if (countdownMessage === null) {
countdownMessage = COUNTDOWN_COMPLETE_MESSAGE;
}
// Reduce draws to the screen
if (currentCountdownText !== countdownMessage) {
countdownContainer.innerHTML = countdownMessage;
currentCountdownText = countdownMessage;
}
// Calls tick whenever the next frame is available
window.requestAnimationFrame(tick);
}
function main() {
countdownContainer = document.getElementById("countdownContainer");
tick();
}
window.onload = main;
</script>
</head>
<body>
<div id="countdownContainer"></div>
</body>
</html>