-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperiods.js
More file actions
246 lines (228 loc) · 9.93 KB
/
periods.js
File metadata and controls
246 lines (228 loc) · 9.93 KB
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
fetch('https://api.github.com/repos/Ryanforce08/ryanforce08.github.io/commits?per_page=1')
.then(res => res.json())
.then(res => {
document.getElementById('message').innerHTML = res[0].commit.message
})
if (typeof navigator.serviceWorker !== 'undefined') {
navigator.serviceWorker.register('sw.js')
}
// Retrieve lunch period from local storage
const lunchPeriod = localStorage.getItem("lunchPeriod");
const daytype = localStorage.getItem("daytype");
// Define the schedule based on lunch period
let schedule;
if (daytype === "Halfday"){
document.getElementById("lunch").textContent = "Halfday";
schedule = [
{ period: "School Starts in", start: "00:00", end: "07:34" },
{ period: "Homeroom", start: "07:35", end: "07:40" },
{ period: "Period 1", start: "07:44", end: "08:12" },
{ period: "Period 2", start: "08:16", end: "08:44" },
{ period: "Period 3", start: "08:48", end: "09:16" },
{ period: "Period 4", start: "09:20", end: "09:48" },
{ period: "Period 6/7", start: "09:52", end: "10:20" },
{ period: "Period 8/9", start: "10:24", end: "10:52" },
{ period: "Period 10/11", start: "10:56", end: "11:24" },
{ period: "Period 12", start: "11:28", end: "11:56" }
];
}
else if (daytype === "vet") {
document.getElementById("lunch").textContent = "Veteran's Day";
schedule = [
{ period: "Homeroom", start: "07:35", end: "07:45" },
{ period: "Period 1", start: "07:49", end: "08:20" },
{ period: "Period 2", start: "08:24", end: "08:55" },
{ period: "Assembly", start: "09:00", end: "10:00" },
{ period: "Period 3", start: "10:03", end: "10:34" },
{ period: "Period 4/5", start: "10:38", end: "11:09" },
{ period: "Period 6 - B Lunch", start: "11:13", end: "11:36" },
{ period: "Period 7", start: "11:39", end: "11:45" },
{ period: "Period 8 - C Lunch", start: "11:48", end: "12:11" },
{ period: "Period 9", start: "12:14", end: "12:20" },
{ period: "Period 10 - D Lunch", start: "12:23", end: "12:46" },
{ period: "Period 11", start: "12:49", end: "12:55" },
{ period: "Period 11 - E Lunch", start: "12:58", end: "13:21" },
{ period: "Period 12", start: "13:24", end: "13:55" }
];
}
else if (daytype === "2hour"){
document.getElementById("lunch").textContent = "2 Hour Delay";
schedule = [
{ period: "Homeroom", start: "09:35", end: "09:40" },
{ period: "Period 1", start: "09:44", end: "10:09" },
{ period: "Period 2", start: "10:13", end: "10:38" },
{ period: "Period 3", start: "10:42", end: "11:07" },
{ period: "Period 4/5", start: "11:11", end: "11:36" },
{ period: "Period 6 - B Lunch", start: "11:39", end: "12:04" },
{ period: "Period 8 - C Lunch", start: "12:07", end: "12:32" },
{ period: "Period 10 - D Lunch", start: "12:35", end: "13:00" },
{ period: "Period 11/E - Lunch", start: "13:03", end: "13:28" },
{ period: "Period 12", start: "13:32", end: "13:57" },
{ period: "Period 14", start: "14:00", end: "14:40" }
];
}
else if (daytype === "hr"){
document.getElementById("lunch").textContent = "Extended Homeroom";
schedule = [
{ period: "Homeroom", start: "07:35", end: "08:45" },
{ period: "Period 1", start: "08:39", end: "09:12" },
{ period: "Period 2", start: "09:16", end: "09:49" },
{ period: "Period 3", start: "09:53", end: "10:26" },
{ period: "Period 4/5", start: "10:30", end: "11:03" },
{ period: "Period 6 - B Lunch", start: "11:06", end: "11:29" },
{ period: "Period 8 - C Lunch", start: "11:42", end: "12:05" },
{ period: "Period 10 - D Lunch", start: "12:18", end: "12:41" },
{ period: "Period 11 - E Lunch", start: "12:54", end: "13:17" },
{ period: "Period 12", start: "13:21", end: "13:55" },
{ period: "Period 14", start: "14:00", end: "14:40" }
];
}
else if (lunchPeriod === "Period B") {
document.getElementById("lunch").textContent = "Lunch 6";
schedule = [
{ period: "School Starts in", start: "00:00", end: "07:34" },
{ period: "Homeroom", start: "07:35", end: "07:40" },
{ period: "Period 1", start: "07:44", end: "08:24" },
{ period: "Period 1/2", start: "8:24", end: "08:27" },
{ period: "Period 2", start: "08:28", end: "09:08" },
{ period: "Period 2/3", start: "08:08", end: "09:12" },
{ period: "Period 3", start: "09:12", end: "09:52" },
{ period: "Period 3/4", start: "09:52", end: "09:51" },
{ period: "Period 4", start: "09:52", end: "10:36" },
{ period: "Lunch", start: "10:39", end: "11:02" },
{ period: "Period 7", start: "11:05", end: "11:45" },
{ period: "Period 9/10", start: "11:48", end: "12:28" },
{ period: "Period 11", start: "12:31", end: "13:11" },
{ period: "Period 12", start: "13:16", end: "13:55" },
{ period: "Period 14", start: "14:00", end: "14:39" }
];
} else if (lunchPeriod === "Period C") {
document.getElementById("lunch").textContent = "Lunch 8";
schedule = [
{ period: "School Starts in", start: "00:00", end: "07:34" },
{ period: "Homeroom", start: "07:35", end: "07:40" },
{ period: "Period 1", start: "07:44", end: "08:24" },
{ period: "Period 2", start: "08:28", end: "09:08" },
{ period: "Period 3", start: "09:12", end: "09:52" },
{ period: "Period 4", start: "09:56", end: "10:36" },
{ period: "Period 6", start: "10:36", end: "11:19" },
{ period: "Lunch", start: "11:22", end: "11:45" },
{ period: "Period 9/10", start: "11:48", end: "12:28" },
{ period: "Period 11", start: "12:31", end: "13:11" },
{ period: "Period 12", start: "13:16", end: "13:55" },
{ period: "Period 14", start: "14:00", end: "14:39" }
];
} else if (lunchPeriod === "Period D") {
document.getElementById("lunch").textContent = "Lunch 10";
schedule = [
{ period: "School Starts in", start: "00:00", end: "07:34" },
{ period: "Homeroom", start: "07:35", end: "07:40" },
{ period: "Period 1", start: "07:44", end: "08:24" },
{ period: "Period 2", start: "08:28", end: "09:08" },
{ period: "Period 3", start: "09:12", end: "09:52" },
{ period: "Period 4", start: "09:56", end: "10:36" },
{ period: "Period 6", start: "10:39", end: "11:19" },
{ period: "Period 8", start: "11:22", end: "12:02" },
{ period: "Lunch", start: "12:05", end: "12:28" },
{ period: "Period 11", start: "12:31", end: "13:11" },
{ period: "Period 12", start: "13:16", end: "13:55" },
{ period: "Period 14", start: "14:00", end: "14:39" }
];
} else if (lunchPeriod === "Period E") {
document.getElementById("lunch").textContent = "Lunch 11";
schedule = [
{ period: "School Starts in", start: "00:00", end: "07:34" },
{ period: "Homeroom", start: "07:35", end: "07:40" },
{ period: "Period 1", start: "07:44", end: "08:24" },
{ period: "Period 2", start: "08:28", end: "09:08" },
{ period: "Period 3", start: "09:12", end: "09:52" },
{ period: "Period 4", start: "09:56", end: "10:36" },
{ period: "Period 6", start: "10:39", end: "11:19" },
{ period: "Period 8", start: "11:22", end: "12:02" },
{ period: "Period 9/10", start: "12:05", end: "12:45" },
{ period: "Lunch", start: "12:48", end: "13:11" },
{ period: "Period 12", start: "13:16", end: "13:55" },
{ period: "Period 14", start: "14:00", end: "14:39" }
];
} else {
// Default schedule if lunch period is not set
document.getElementById("lunch").textContent = "No Lunch Set";
schedule = [
{ period: "School Starts in", start: "00:00", end: "07:34" },
{ period: "Homeroom", start: "07:35", end: "07:40" },
{ period: "Period 1", start: "07:44", end: "08:24" },
{ period: "Period 2", start: "08:28", end: "09:08" },
{ period: "Period 3", start: "09:12", end: "09:52" },
{ period: "Period 4/5", start: "09:56", end: "10:36" },
{ period: "Period 6/7", start: "10:39", end: "11:19" },
{ period: "Period 8", start: "11:22", end: "11:45" },
{ period: "Period 9/10", start: "11:48", end: "12:28" },
{ period: "Period 11", start: "12:31", end: "13:11" },
{ period: "Period 12", start: "13:16", end: "13:55" },
{ period: "Period 14", start: "14:00", end: "14:39" }
];
}
// Function to calculate time remaining in seconds
function getTimeRemaining(endTime) {
const total = Date.parse(endTime) - Date.parse(new Date());
const seconds = Math.floor((total / 1000) % 60);
const minutes = Math.floor((total / 1000 / 60) % 60);
const hours = Math.floor((total / (1000 * 60 * 60)) % 24);
return {
total,
hours,
minutes,
seconds
};
}
// Function to update countdown every second
function updateCountdown(endTime, period) {
const timeRemaining = getTimeRemaining(endTime);
// If the current period is over
if (timeRemaining.total <= 0) {
// Refresh the page
location.reload();
document.getElementById("period").textContent = `${period.period}:`;
document.getElementById("countdown").textContent = "Current period is over!";
return;
}
// Display countdown for the current period
document.getElementById("period").textContent = `${period.period}:`;
document.getElementById("countdown").textContent = `${timeRemaining.hours}h ${timeRemaining.minutes}m ${timeRemaining.seconds}s`;
// Update countdown every second
setTimeout(() => {
updateCountdown(endTime, period);
}, 1000);
}
// Function to initialize countdown
function initializeCountdown() {
const now = new Date();
let currentPeriod = null;
let nextPeriod = null;
// Find the current period
for (let i = 0; i < schedule.length; i++) {
const start = new Date(now.toDateString() + " " + schedule[i].start);
const end = new Date(now.toDateString() + " " + schedule[i].end);
if (self.i=0 ){
location.reload();
}
if (now >= start && now <= end) {
currentPeriod = schedule[i];
nextPeriod = schedule[i + 1];
self.i=1
break;
}
}
// If there's no current period (after school hours)
if (!currentPeriod) {
document.getElementById("countdown").textContent = "School is over for today!";
self.i = 0
return;
}
// Calculate time remaining for the current period
const endTime = new Date(now.toDateString() + " " + currentPeriod.end);
// Start updating countdown
updateCountdown(endTime, currentPeriod);
}
// Start the countdown
initializeCountdown();