-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
147 lines (136 loc) · 4.2 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raid Timer</title>
<style>
body {
background-color: #333;
color: #ccc;
font-size: clamp(1rem, -0.875rem + 8.333333vw, 3.5rem);
text-align: center;
margin: 0;
padding: 0;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-family: monospace;
}
.sm {
font-size: clamp(1rem, -0.875rem + 7.333333vw, 2.5rem);
}
</style>
</head>
<body>
<script>
// init variables
const raidTimeWednesday = 3 * 60 + 30; // 3:30am in minutes
const raidTimeThursday = 4 * 60; // 4:00am in minutes
const now = new Date();
const day = now.getUTCDay();
const localDay = now.getDay();
const hours = now.getUTCHours();
const minutes = now.getUTCMinutes();
const offset = now.getTimezoneOffset();
// convert raid time to local time
const localRTWeds = raidTimeWednesday + offset * 60000;
const localRTThurs = raidTimeThursday + offset * 60000;
// INT; check if it is raid day
/* OUTPUTS:
1: it is raid1 today
2: it is raid2 today
0: not raid day
*/
function isRaidDay() {
// if local raid time is on previous day local time
if (localRTWeds < 0 || localRTThurs < 0) {
// then check if it is tuesday or wednesday UTC
if (localDay == 2) {
return 1;
} else if (localDay == 3) {
return 2;
} else {
return 0;
}
// if local raid time is on same day as UTC
} else if (localRTWeds > 0 || localRTThurs > 0) {
// check if it's wednesday or thursday
if (localDay == 3) {
return 1;
} else if (localDay == 4) {
return 2;
} else {
return 0;
}
}
}
// check local time versus raid time UTC
/* OUTPUTS:
1: it is at most 3 hours before raid time on UTC Weds
2: it is at most 4 hours before raid time on UTC thurs
0: raid has ended
null: it is not a raid day
*/
function isRaidTime() {
const timeInMins = hours * 60 + minutes;
if (day == 3) {
// raid on UTC wednesday
// if it is before 3:30am UTC
if (timeInMins < raidTimeWednesday) {
return 1;
} else {
return 0;
}
} else if (day == 4) {
// raid on UTC thursday
if (timeInMins < raidTimeThursday) {
return 2;
} else {
return 0;
}
} else {
// it is not a raid day
return null;
}
}
function updateDisplay() {
// init variablles
const isItToday = isRaidDay();
const isItRaidTime = isRaidTime();
// always display
document.body.innerHTML =
"<p class='sm'>is it a raid day???</p><p id='answer'> </p><p id='Timer'> </p>";
// conditional displays
switch (isItToday) {
case 1: // wednesday UTC
if (isItRaidTime == 1) {
document.getElementById("answer").innerText =
"It is a raid day, and we're raiding soon!";
} else if (isItRaidTime == 0) {
document.getElementById("answer").innerText =
"It is a raid day, but the raid has ended.";
}
break;
case 2: // thursday UTC
if (isItRaidTime == 2) {
document.getElementById("answer").innerText =
"It is a raid day, and we're raiding soon!";
} else if (isItRaidTime == 0) {
document.getElementById("answer").innerText =
"It is a raid day, but the raid has ended.";
}
break;
default:
document.getElementById("answer").innerText =
"It is NOT a raid day.";
break;
}
}
// run
updateDisplay();
</script>
</body>
</html>