-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschool.js
141 lines (137 loc) · 7.62 KB
/
school.js
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
var progress = document.getElementById("progress");
var specific = document.getElementById("specific");
var graduation = document.getElementById("graduation");
var year = document.getElementById("year-text");
var quar = document.getElementById("quarter-text");
var lunch = document.getElementById("lunch");
var sdiv = document.getElementById("specific-div");
var ldiv = document.getElementById("lunch-div");
var obar = document.getElementById("overall-bar");
var sbar = document.getElementById("specific-bar");
var lbar = document.getElementById("lunch-bar");
var ybar = document.getElementById("year-bar");
var gbar = document.getElementById("grad-bar");
var gsel = document.getElementById("grad-sel");
var qbar = document.getElementById("quar-bar");
const start = 1693920000;
const end = 1717704000;
const quarters = [1693920000, 1699563600, 1706216400, 1711656000, 1717704000];
const gpoints = {"2023": [1567516800, 1686254400], "2024": [1599744000, 1717876800], "2025": [1631193600, 1749412800], "2026": [1662470400, 1780948800]};
function minutes(date) {
return (date.getUTCHours() * 60 + date.getUTCMinutes()) - 60;
}
function acc(date) {
return minutes(date) + date.getUTCSeconds() / 60 + date.getUTCMilliseconds() / 60000;
}
function update() {
let tpercent = (Date.now() / 1000 - start) / (end - start) * 100;
year.innerHTML = `The School Year is ${tpercent.toFixed(7)}% done!`;
ybar.setAttribute("width", (tpercent * 0.998) + "%");
let ypercent = (Date.now() / 1000 - gpoints[gsel.value][0]) / (gpoints[gsel.value][1] - gpoints[gsel.value][0]) * 100;
graduation.innerHTML = `${ypercent.toFixed(7)}% done!`;
gbar.setAttribute("width", (ypercent * 0.998) + "%");
for (let i = 0; i < 5; i++) {
if (Date.now() > quarters[i] * 1000) {
continue;
}
let qpercent = (Date.now() / 1000 - quarters[i - 1]) / (quarters[i] - quarters[i - 1]) * 100;
quar.innerHTML = `Quarter ${i} is ${qpercent.toFixed(6)}% done!`;
qbar.setAttribute("width", (qpercent * 0.998) + "%");
break;
}
let now = new Date();
if (now.getUTCDay() % 6 == 0 || minutes(now) < 800 || minutes(now) >= 1200) {
if (now.getUTCDay() % 6 != 0 && minutes(now) < 800) {
if (minutes(now) >= 790 && minutes(now) < 795) {
let percent = (acc(now) - 790) / .05;
mins = 5 - (minutes(now) - 790);
progress.innerHTML = `Warning Bell #2 is ${percent.toFixed(3)}% of the way to being rung! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
obar.setAttribute("width", (percent * 0.998) + "%");
} else if (minutes(now) >= 795) {
let percent = (acc(now) - 795) / .05;
mins = 5 - (minutes(now) - 795);
progress.innerHTML = `School is ${percent.toFixed(3)}% of the way to starting! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
obar.setAttribute("width", (percent * 0.998) + "%");
} else {
progress.innerHTML = "School is not in session at this time!";
obar.setAttribute("width", "99.8%")
}
} else {
progress.innerHTML = "School is not in session at this time!";
obar.setAttribute("width", "99.8%")
}
sdiv.style.display = "none";
ldiv.style.display = "none";
} else {
sdiv.style.display = "block";
let percent = (acc(now) - 800) / 4;
let amins = minutes(now) - 800
let mins = 400 - amins;
progress.innerHTML = `School is ${percent.toFixed(4)}% done! Only ${Math.floor(mins/60) > 0 ? Math.floor(mins/60) + (Math.floor(mins/60) == 1 ? " hour" : " hours") : ""}${Math.floor(mins/60) > 0 && mins % 60 > 0 ? " and " : ""}${mins % 60 > 0 ? mins % 60 + (mins % 60 == 1 ? " minute left" : " minutes left") : ""}!`;
obar.setAttribute("width", (percent * 0.998) + "%");
if (amins < 86) {
percent = (acc(now) - 800) / .86;
mins = 86 - amins;
specific.innerHTML = `Block 1 is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
sbar.setAttribute("width", (percent * 0.998) + "%");
} else if (amins >= 86 && amins < 94) {
percent = (acc(now) - 886) / .08;
mins = 94 - amins;
specific.innerHTML = `Passing Time is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
sbar.setAttribute("width", (percent * 0.998) + "%");
} else if (amins >= 94 && amins < 180) {
percent = (acc(now) - 894) / .86;
mins = 180 - amins;
specific.innerHTML = `Block 2 is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
sbar.setAttribute("width", (percent * 0.998) + "%");
} else if (amins >= 180 && amins < 188) {
percent = (acc(now) - 980) / .08;
mins = 188 - amins;
specific.innerHTML = `Passing Time is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
sbar.setAttribute("width", (percent * 0.998) + "%");
} else if (amins >= 188 && amins < 306) {
percent = (acc(now) - 988) / 1.18;
mins = 306 - amins;
specific.innerHTML = `Block 3 is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
sbar.setAttribute("width", (percent * 0.998) + "%");
} else if (amins >= 306 && amins < 314) {
percent = (acc(now) - 1106) / .08;
mins = 314 - amins;
specific.innerHTML = `Passing Time is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
sbar.setAttribute("width", (percent * 0.998) + "%");
} else if (amins >= 314) {
percent = (acc(now) - 1114) / .86;
mins = 400 - amins;
specific.innerHTML = `Block 4 is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
sbar.setAttribute("width", (percent * 0.998) + "%");
}
if (amins >= 180 && amins < 212) {
ldiv.style.display = "block";
percent = (acc(now) - 980) / .32;
mins = 212 - amins;
lunch.innerHTML = `Lunch A is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
lbar.setAttribute("width", (percent * 0.998) + "%");
} else if (amins >= 212 && amins < 239) {
ldiv.style.display = "block";
percent = (acc(now) - 1012) / .27;
mins = 239 - amins;
lunch.innerHTML = `Lunch B is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
lbar.setAttribute("width", (percent * 0.998) + "%");
} else if (amins >= 250 && amins < 277) {
ldiv.style.display = "block";
percent = (acc(now) - 1050) / .27;
mins = 277 - amins;
lunch.innerHTML = `Lunch C is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
lbar.setAttribute("width", (percent * 0.998) + "%");
} else if (amins >= 277 && amins < 306) {
ldiv.style.display = "block";
percent = (acc(now) - 1077) / .29;
mins = 306 - amins;
lunch.innerHTML = `Lunch D is ${percent.toFixed(4)}% done! Only ${mins + (mins == 1 ? " minute" : " minutes")} left!`;
lbar.setAttribute("width", (percent * 0.998) + "%");
} else {
ldiv.style.display = "none";
}
}
}
setInterval(update, 50);