-
Notifications
You must be signed in to change notification settings - Fork 5
/
v3.html
308 lines (275 loc) · 13.3 KB
/
v3.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="favicon_icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon_icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon_icons/favicon-16x16.png">
<link rel="manifest" href="favicon_icons/site.webmanifest">
<link rel="shortcut icon" type="image/x-icon" href="favicon_icons/favicon.ico">
<link href="font/webfontkit-20220210-002804/stylesheet.css" type="text/css" rel="stylesheet">
<title>Hypixel Pit Events Tracker</title>
<meta name="description" content="This program allows you to view the upcoming events in the Hypixel Pit in real time.">
</head>
<body style="font-family: minecraftregular" background-color="black">
<div class="img-with-text"><img src="3457688aa57c4d71ab9d22b04f9160db.png" alt="hi!" width=50px, height=auto, style="float:left"><p style="padding: 15px; padding-left: 60px; padding-top: 8px">brookeafk.com</p><span style="position:relative; left:60px; top:-40px;" id="settings" onclick="SettingsMenu()" class="hand_cursor">View Settings</span></div>
<div id="settings-section">
<p style="font-size:15px"><span>Theme: </span><span id="settings-theme-dark" onclick='ChangeTheme("dark")'>Dark</span><span> / </span><span id="settings-theme-light" onclick='ChangeTheme("light")'>Light</span></p>
<!--<p style="font-size:15px"><span>Timestamps: </span><span id="settings-ts-tod" onclick='ToggleTimestamps("tod");'>Time of Day</span><span> / </span><span id="settings-ts-tue" onclick='ToggleTimestamps("tue");'>Time Until Event</span></p>-->
</div>
<script>
var HiddenEventCount = 0;
var EventsToLoad = 1;
var version_number = "0.2.1 (alpha)"
var counter = 4;
var settingsOpened = false;
var NormalText = "#000000";
var theme = "dark";
var showEventToD = "true"; //Time of Day
var showEventTuE = "true"; //Time until Event
document.getElementById('settings').style.color = NormalText;
function MakeFunTimestamps(convertible) {
let currentTime = (Date.now);
if (convertible - currentTime() <= 0) {
convertible = "Passed!"
}
if (convertible - currentTime() <= 60000) {
convertible = (((Math.floor(((convertible - currentTime())*100))/100000).toFixed(2)) + "s");
} else if (convertible - currentTime() <= 3600000) {
convertible = ((Math.floor(((convertible - currentTime()))/60000) + "m" + (Math.floor(((convertible - currentTime()))/1000) % 60) + "s"));
} else if (convertible - currentTime() > 1) {
convertible = ((Math.floor(((convertible - currentTime()))/3600000) + "h" + (Math.floor(((convertible - currentTime()))/60000) % 60) + "m"));
}
return convertible;
}
function ChangeTheme(themecolour) {
window.theme = themecolour;
console.log ("Changed theme to " + window.theme);
if(themecolour == "light") {
NormalText = "#000000";
document.getElementById('settings-theme-dark').style.color = "#888888";
document.getElementById('settings-theme-light').style.color = NormalText;
document.body.style.background = "#FFFFFF";
document.querySelectorAll('p').forEach(e => e.style.color = "black");
document.getElementById('settings').style.color = "#888888";
document.getElementById('settings-theme-dark').classList.add("hand_cursor");
document.getElementById('settings-theme-light').classList.remove("hand_cursor");
} else if (window.theme == "dark") {
NormalText = "#FFFFFF";
document.getElementById('settings-theme-light').style.color = "#888888";
document.getElementById('settings-theme-dark').style.color = NormalText;
document.getElementById('settings').style.color = "#888888";
document.body.style.background = "#222222";
document.querySelectorAll('p').forEach(e => e.style.color = "white");
document.getElementById('settings-theme-dark').classList.remove("hand_cursor");
document.getElementById('settings-theme-light').classList.add("hand_cursor");
}
}
ChangeTheme(theme); //called again later (to make sure)
function ToggleTimestamps(timestamps) {
if (timestamps == "tod") {
if(window.showEventToD == true) {
document.getElementById('settings-ts-tod').style.color = "#888888";
window.showEventToD = false;
} else {
document.getElementById('settings-ts-tod').style.color = NormalText;
window.showEventToD = true;
}
}
if (timestamps == "tue") {
if(window.showEventTuE == true) {
document.getElementById('settings-ts-tue').style.color = "#888888";
window.showEventTuE = false;
} else {
document.getElementById('settings-ts-tue').style.color = NormalText;
window.showEventTuE = true;
}
}
}
function TimeOfDay(s) {
var offset = (new Date().getTimezoneOffset())*-60000;
return new Date(s + offset).toISOString().slice(-13, -8);
}
const events = ["Quick Maths","Dragon Egg","2x Rewards","Care Package","KOTL","KOTH","Auction","Giant Cake","All bounty","Squads","Beast","Pizza","Rage Pit","Spire","Robbery","Blockhead","Raffle","Team Deathmatch"]
const lightColours = ["#D9D2E9","#E9D2E1","#D2E9DD","#E9E2D2","#D2E9D2","#D2E9E8","#E9DDD2","#E9D2D2","#E9E3D2","#8EBAEC","#8EEC94","#ECB38E","#EC8E8E","#EC8EEC","#ECE98E","#9191EC","#ECBD8E","#BA8EEC"]
const darkColours = ["#321433","#33142b","#143321","#332314","#1e3314","#143333","#332a14","#261433","#2f3314","#206dc5","#20c541","#c59f20","#c52320","#c520c3","#c5c320","#2323c5","#c0c020","#7320c5"]
function test_zero(conversion) { //adds cute colours
for(var i = window.HiddenEventCount; i < EventsToLoad; i++) {
if (window.theme == "light") {
document.getElementById('event_' + String(i)).style.backgroundColor =lightColours[events.indexOf(conversion[i]['event'])];
}
if (window.theme == "dark") {
document.getElementById('event_' + String(i)).style.backgroundColor =darkColours[events.indexOf(conversion[i]['event'])];
}
if(conversion[i]['type'] == "major") {
document.getElementById('event_' + String(i)).style.fontFamily = "minecraftbold";
}
document.getElementById('event_' + String(i)).style.color = NormalText;
let currentTime = (Date.now);
if ((conversion[i]['timestamp'] - currentTime() <= 60000 && (conversion[i]['timestamp'] - currentTime()) % 1000 > 900) && (theme == "light")) {
document.getElementById('event_'+ String(i)).classList.add("blinktext-light");
document.getElementById('event_'+ String(i)).classList.remove("blinktext-dark");
}
if ((conversion[i]['timestamp'] - currentTime() <= 60000 && (conversion[i]['timestamp'] - currentTime()) % 1000 > 900) && (theme == "dark")) {
document.getElementById('event_'+ String(i)).classList.add("blinktext-dark");
document.getElementById('event_'+ String(i)).classList.remove("blinktext-light");
}
}
}
const pp_url = 'https://raw.githubusercontent.com/BrookeAFK/brookeafk-api/main/events.js'
data_backup = MakeAPIAndHTML();
console.log("The data's been called!")
setInterval(getPitPanda,80);
async function MakeAPIAndHTML() { //Calls the API exactly once (thanks McPqndq for pointing out that i do not have to call apis more than once)
const response = await fetch(pp_url);
window.data = await response.json();
window.data_backup = window.data;
window.EventsToLoad = Object.keys(window.data).length
console.log("Loading events: " + window.EventsToLoad);
console.log("API Called.")
for(var i = 0; i < window.EventsToLoad; i += 1) { //Make HTML elements
var div = document.createElement("div");
console.log("I made an element.")
div.id = ("event_" + i);
div.innerHTML = ("[loading event]");
div.style.padding = "15px";
div.style.backgroundColor = "#222222";
div.style.textAlign = "left";
div.style.fontSize = "1.5em"
div.style.lineHeight = "100%"
document.body.appendChild(div);
}
var p = document.createElement("p");
console.log("Added footer.")
//p.style.marginTop = (String(50*i) + "px")
p.id = ("version")
p.innerHTML = ("v" + window.version_number);
document.body.appendChild(p);
var q = document.createElement("p");
q.id = ("special_thanks")
// q.style.marginTop = (String(50) + "px")
q.innerHTML = (`<span style="font-size: 0.8em;">Special thanks to <a href="http://deviantart.com/hextant" target="_blank">Andrew ♡</a>, <a href="https://twitter.com/ellwixd" target="_blank">Ellie</a>, <a href="https://twitter.com/oSnapLLL" target="_blank">oSnapL</a>, <a href="https://youtu.be/dQw4w9WgXcQ" target="_blank">1Mad</a>, <a href="https://twitter.com/cutekitty271" target="_blank">Emma</a>, <a href="https://namemc.com/profile/354aa68a43694ba29ff23c705dfc11e6" target="_blank">catweapon</a>, <a href="https://twitter.com/KinderFissa" target="_blank">Twen</a>, <a href="https://twitter.com/c4pshypixel" target="_blank">C4PS</a>, <a href="https://vnmm.dev/"" target="_blank">vnmm</a>, and <a href="https://namemc.com/profile/9f65cdd1-81d7-49f3-8d41-fef76a7a8768" target="_blank">Vermasium</a> for kind words!</span>`)
document.body.appendChild(q);
ChangeTheme(theme); //just again to make sure
}
function RapidFirst(transformation) { //Makes the first event update much quicker (useful for the <60s countdown.)
for(var i = window.HiddenEventCount; i <= window.HiddenEventCount; i++) {
document.getElementById('event_' + String(i)).innerHTML = (`<span style="font-family: minecraftregular">` + MakeFunTimestamps(transformation[i].timestamp) + `: </span><span> ` + transformation[i].event + `</span><span style="font-family: minecraftregular"> (` + TimeOfDay(transformation[i].timestamp) + ") </span>");
if(MakeFunTimestamps(transformation[i].timestamp) == "Passed!" && !!document.getElementById('event_' + String(i)) == true) {
//document.getElementById('event_' + String(i)).remove();
document.getElementById('event_' + String(i)).style.display = "none";
window.HiddenEventCount = window.HiddenEventCount + 1;
console.log(config1);
}
}
}
function UpdateEverything(transformation) { //this plops the stuff in the actual html page
for(var i = window.HiddenEventCount + 1; i < EventsToLoad; i++) {
document.getElementById('event_' + String(i)).innerHTML = (`<span style="font-family: minecraftregular">` + MakeFunTimestamps(transformation[i].timestamp) + `: </span><span> ` + transformation[i].event + `</span><span style="font-family: minecraftregular"> (` + TimeOfDay(transformation[i].timestamp) + ") </span>");
if(MakeFunTimestamps(transformation[i].timestamp) == "Passed!" && !!document.getElementById('event_' + String(i)) == true) {
//document.getElementById('event_' + String(i)).remove();
document.getElementById('event_' + String(i)).style.display = "none";
window.HiddenEventCount = window.HiddenEventCount + 1;
}
}
}
function SettingsMenu() {
if(settingsOpened == false) {
document.getElementById('settings').style.color = "#888888";
settingsOpened = true;
document.getElementById('settings-section').style.display = "block";
console.log("set to true");
} else if(settingsOpened == true) {
document.getElementById('settings').style.color = NormalText;
settingsOpened = false;
console.log("set to false");
document.getElementById('settings-section').style.display = "none";
}
}
function getPitPanda() {
window.data = window.data_backup;
test_zero(window.data);
counter = counter + 1;
if (counter == 5) {
counter = 0;
UpdateEverything(window.data);
console.log("Updated 2nd-n values.")
}
RapidFirst(window.data);
console.log("Updated 1st value.");
}
</script>
<style>
a:link {
color: #B15AC2;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: #725279;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: #E7C2EE;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: #EDDDF0;
background-color: transparent;
text-decoration: underline;
}
p {
font-size: 1.5em
}
.blinktext-light {
-webkit-animation: blink-text-light 1000ms linear infinite;
-moz-animation: blink-text-light 1000ms linear infinite;
-ms-animation: blink-text-light 1000ms linear infinite;
-o-animation: blink-text-light 1000ms linear infinite;
animation: blink-text-light 1000ms linear infinite;
}
.blinktext-dark {
-webkit-animation: blink-text-dark 1000ms linear infinite;
-moz-animation: blink-text-dark 1000ms linear infinite;
-ms-animation: blink-text-dark 1000ms linear infinite;
-o-animation: blink-text-dark 1000ms linear infinite;
animation: blink-text-dark 1000ms linear infinite;
}
@keyframes blink-text-light {
0% { color: #FF0000; opacity: 1; }
10% { color: #e80000;opacity: 1; }
15% { color: #d10000;opacity: 1; }
20% { color: #b80000;opacity: 1; }
25% { color: #a30000;opacity: 1; }
30% { color: #8c0000;opacity: 1; }
35% { color: #750000;opacity: 1; }
40% { color: #5e0000;opacity: 1; }
45% { color: #470000;opacity: 1; }
49% { color: #300000;opacity: 1; }
50% { color: #190000;opacity: 1; }
}
@keyframes blink-text-dark {
0% { color: #c00000; opacity: 1; }
10% { color: #c51a1a;opacity: 1; }
15% { color: #ca3333;opacity: 1; }
20% { color: #cf4d4d;opacity: 1; }
25% { color: #d56666;opacity: 1; }
30% { color: #da8080;opacity: 1; }
35% { color: #e59999;opacity: 1; }
40% { color: #eab3b3;opacity: 1; }
45% { color: #f5cccc;opacity: 1; }
49% { color: #fae6e6;opacity: 1; }
50% { color: #ffffff;opacity: 1; }
}
.hand_cursor {
cursor: pointer;
}
#settings-section {
display: none;
margin-left: 60px;
}
</style>
</body>
</html>