-
Notifications
You must be signed in to change notification settings - Fork 0
/
soup_countdown.html
98 lines (84 loc) · 3.56 KB
/
soup_countdown.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
<!DOCTYPE html>
<html>
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: 'Bebas Neue', cursive;
/* font-size: 14vw; */
}
.soup {
/* background-color: rgb(219, 185, 195); */
/* background-color: #233486; */
display: flex;
padding: 15px;
max-width: 370px;
flex-shrink: 1;
align-items: center;
font-size: 3em;
line-height: 1;
color: white;
text-align: center;
/* border: solid 3px #c1c1c1; */
/* height: 200px; */
}
.icon_left {
flex: 1.4;
/* outline: 1px solid black; */
}
.text_right {
flex: 2;
}
img {
max-width: 100%;
}
p {
line-height: 0;
}
</style>
</head>
<body>
<div class="soup">
<div class="icon_left">
<img src="soup.png" alt="soup">
</div>
<div class="text_right">
<span id="soup_text"></span></br>
<span id="soup_timer"></span>
</div>
</div>
<script>
const start = [[0, 00], [1, 30], [3, 00], [4, 30], [6, 00], [7, 30], [9, 00], [10, 30], [12, 00], [13, 30], [15, 00], [16, 30], [18, 00], [18, 00], [19, 30], [21, 00], [22, 30]]
const end = [[0,15], [1, 45], [3, 15], [4, 45], [6, 15], [7, 45], [9, 15], [10, 45], [12, 15], [13, 45], [15, 15], [16, 45], [18, 15], [18, 15], [19, 45], [21, 15], [22, 45]]
setInterval(function() {
const now = new Date();
const nextSoup = start.find(it => it[0] > now.getHours() || it[0] == now.getHours() && it[1] >= now.getMinutes()) || times[0];
const nextEnd = end.find(it => it[0] > now.getHours() || it[0] == now.getHours() && it[1] >= now.getMinutes()) || times[0];
var hours = nextSoup[0] - now.getHours();
var minutes = nextSoup[1] - now.getMinutes();
if(minutes < 0) { minutes += 60; hours -= 1 }
if(hours < 0) { hours += 24; }
var seconds = 60 - now.getSeconds();
if(hours == 1 && minutes >= 15) {
var hours = nextEnd[0] - now.getHours();
var minutes = nextEnd[1] - now.getMinutes();
if(minutes < 0) { minutes += 60; hours -= 1 }
if(hours < 0) { hours += 24; }
var seconds = 60 - now.getSeconds();
document.getElementById("soup_text").innerHTML = "YES CHEF!"
document.getElementById("soup_text").style = "color: #d43d0b"
document.getElementById("soup_timer").style = "color: #d43d0b"
}
else {
document.getElementById("soup_text").innerHTML = "NEXT SOUP"
document.getElementById("soup_text").style = "color: #c1c1c1"
document.getElementById("soup_timer").style = "color: #c1c1c1"
}
document.getElementById("soup_timer").innerHTML = `${hours.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})}:${minutes.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})}:${seconds.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false})}`
}, 1000);
</script>
</body>
</html>