-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathv1.html
124 lines (104 loc) · 4.78 KB
/
v1.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
<!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">
</head>
<body style="font-family: minecraftregular">
<p>brooke's pit event website</p>
<script>
for(var i = 0; i < 100; i += 1) { //Make HTML elements
var div = document.createElement("div");
console.log("I made an element.")
div.id = ("event_" + i);
div.innerHTML = ("test");
div.style.padding = "10px";
div.style.backgroundColor = "#FFFFFF";
div.style.textAlign = "center";
document.body.appendChild(div);
}
function MakeFunTimestamps(convertible) {
let currentTime = (Date.now);
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 test_zero(conversion) { //adds cute colours
for(var i = 0; i < 100; i++) {
if(conversion[i]['event'] == "Blockhead") {
document.getElementById('event_' + String(i)).style.backgroundColor = "#aaffaa";
}
}
}
const pp_url = 'https://raw.githubusercontent.com/BrookeAFK/brookeafk-api/main/events.js'
data_backup = SaveMyGloriousAPI();
console.log("The data's been called!")
setInterval(getPitPanda,80);
async function SaveMyGloriousAPI() { //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;
console.log("API Called.")
}
function UpdateEverything(transformation) { //this plops the stuff in the actual html page
for(var i = 0; i < 100; i++) {
document.getElementById('event_' + String(i)).textContent = (transformation[i].event + " " + MakeFunTimestamps(transformation[i].timestamp) + " " + transformation[i].type);
}
console.log("Just updated " + (i + 1) + " variables.")
}
function getPitPanda() {
window.data = window.data_backup;
console.log("Found backup.");
test_zero(window.data);
UpdateEverything(window.data);
console.log("Updated values!");
}
/* Old code
$.getJSON('https://events.mcpqndq.dev/?key=a2cca262-f36c-4b6a-a666-d99a7a8ff440', function(data) {
PitPandaBackup = data;
jsonPitPandaEvents = PitPandaBackup;
});
function ConvertAPIToTable() {
document.body.innerHTML = '';
jsonPitPandaEvents = PitPandaBackup;
console.log("BEFORE: ");
console.log(jsonPitPandaEvents);
let currentTime = (Date.now);
for (var i = 0; i < jsonPitPandaEvents.length; ++i) {
if ((jsonPitPandaEvents[i]['timestamp'] - currentTime) <= 60000) {
jsonPitPandaEvents[i]['timestamp'] = (((Math.floor((jsonPitPandaEvents[i]['timestamp'] - currentTime)))/1000)+ "s");
console.log("Converted an object (<1m) at t=" + currentTime);
console.log(jsonPitPandaEvents[i]['timestamp'])
}
else if ((jsonPitPandaEvents[i]['timestamp'] - currentTime) <= 3600000) {
jsonPitPandaEvents[i]['timestamp'] = (Math.floor(((jsonPitPandaEvents[i]['timestamp'] - currentTime)/60000))+ "m" + (Math.floor(((jsonPitPandaEvents[i]['timestamp'] - currentTime)/1000) % 60)) + "s"); //creates mm:ss format. this is awful code. please do not judge
console.log("Converted an object (<1h) at t=" + currentTime);
console.log(jsonPitPandaEvents[i]['timestamp'])
}
else {
jsonPitPandaEvents[i]['timestamp'] = (Math.floor(((jsonPitPandaEvents[i]['timestamp'] - currentTime)/3600000))+ "h" + (Math.floor(((jsonPitPandaEvents[i]['timestamp'] - currentTime)/60000) % 60)) + "m"); //creates hh:mm format. this is awful code. please do not judge
console.log("Converted an object (<1d) at t=" + currentTime);
console.log(jsonPitPandaEvents[i]['timestamp'])
}
}
console.log("AFTER: ");
console.log(jsonPitPandaEvents);
document.body.appendChild(buildHtmlTable(jsonPitPandaEvents));
}
ConvertAPIToTable();
*/
</script>
<p>v0.1</p>
<p>0.1.5 • 0.6 • 1.0</p>
</body>
</html>