forked from jamlaubro/week-by-week
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
246 lines (229 loc) · 10.1 KB
/
script.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
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
const options = { timeZone: "Australia/Sydney" };
const sydneyDate = new Intl.DateTimeFormat("en-US", options).format(new Date());
const currentDate = new Date(sydneyDate);
const dayNumber = currentDate.getDay();
// Change semester start dates here
const semester1 = new Date("2025-02-24T00:00:00+11:00");
const semester2 = new Date("2025-08-04T00:00:00+10:00");
// Check which semester it is
if (currentDate < semester2) { // If current date is before start of Semester 2
var semester = "Semester One";
var semesterStartDate = semester1;
var weekStartDates = [
new Date("2025-02-24T00:00:00+11:00"), // S1 Week 1
new Date("2025-03-03T00:00:00+11:00"), // S1 Week 2
new Date("2025-03-10T00:00:00+11:00"), // S1 Week 3
new Date("2025-03-17T00:00:00+11:00"), // S1 Week 4
new Date("2025-03-24T00:00:00+11:00"), // S1 Week 5
new Date("2025-03-31T00:00:00+11:00"), // S1 Week 6
new Date("2025-04-07T00:00:00+11:00"), // S1 Week 7 (and end of AEDT)
new Date("2025-04-14T00:00:00+10:00"), // S1 Week 8
new Date("2025-04-21T00:00:00+10:00"), // Mid-semester break
new Date("2025-04-28T00:00:00+10:00"), // S1 Week 9
new Date("2025-05-05T00:00:00+10:00"), // S1 Week 10
new Date("2025-05-12T00:00:00+10:00"), // S1 Week 11
new Date("2025-05-19T00:00:00+10:00"), // S1 Week 12
new Date("2025-05-26T00:00:00+10:00"), // S1 Week 13
new Date("2025-06-02T00:00:00+10:00"), // S1 STUVAC
new Date("2025-06-09T00:00:00+10:00"), // S1 Exam Period, Week 1
new Date("2025-06-16T00:00:00+10:00"), // S1 Exam Period, Week 2
new Date("2025-06-23T00:00:00+10:00"), // End of Semester 1
];
} else { // Else if current date is after start of Semester 2
var semester = "Semester Two";
var semesterStartDate = semester2;
var weekStartDates = [
new Date("2025-08-04T00:00:00+10:00"), // S2 Week 1
new Date("2025-08-11T00:00:00+10:00"), // S2 Week 2
new Date("2025-08-18T00:00:00+10:00"), // S2 Week 3
new Date("2025-08-25T00:00:00+10:00"), // S2 Week 4
new Date("2025-09-01T00:00:00+10:00"), // S2 Week 5
new Date("2025-09-08T00:00:00+10:00"), // S2 Week 6
new Date("2025-09-15T00:00:00+10:00"), // S2 Week 7
new Date("2025-09-22T00:00:00+10:00"), // S2 Week 8
new Date("2025-09-29T00:00:00+10:00"), // Semester 2 Mid-semester break
new Date("2025-10-06T00:00:00+11:00"), // S2 Week 9 (and start of AEDT)
new Date("2025-10-13T00:00:00+11:00"), // S2 Week 10
new Date("2025-10-20T00:00:00+11:00"), // S2 Week 11
new Date("2025-10-27T00:00:00+11:00"), // S2 Week 12
new Date("2025-11-03T00:00:00+11:00"), // S2 Week 13
new Date("2025-11-10T00:00:00+11:00"), // S2 STUVAC
new Date("2025-11-17T00:00:00+11:00"), // S2 Exam Period, Week 1
new Date("2025-11-24T00:00:00+11:00"), // S2 Exam Period, Week 2
new Date("2025-12-01T00:00:00+11:00"), // End of Semester 2
];
}
const getWeekNumber = (date) => {
let weekNumber;
if (date < weekStartDates[0]) {
weekNumber = -1;
} else if (date >= weekStartDates[17]) {
weekNumber = 18;
} else {
// Iterate through weekStartDates to find the week number
for (let i = 0; i < 17; i++) {
if (date >= weekStartDates[i] && date < weekStartDates[i + 1]) {
weekNumber = i + 1;
break; // Exit the loop once the week is found
}
}
}
return weekNumber;
};
const getDayName = (dayNumber) => { // [N.B: in HTML format, the first day in the array is Sunday, but the counter will still name it correctly]
switch (dayNumber) {
case 0:
return "Sunday";
case 1:
return "Monday";
case 2:
return "Tuesday";
case 3:
return "Wednesday";
case 4:
return "Thursday";
case 5:
return "Friday";
case 6:
return "Saturday";
}
}
// Get week names for Semesters One and Two
const getWeekName = (weekNumber) => {
if (weekNumber < 0) {
return "before " + semester + " has started.";
} else if (weekNumber >= 18) {
return "after " + semester + " has finished.";
} else if (semesterStartDate == semester1) {
switch (weekNumber) {
case 1:
return dayName + " of Week One.";
case 2:
return dayName + " of Week Two.";
case 3:
return dayName + " of Week Three.";
case 4:
return dayName + " of Week Four.";
case 5:
return dayName + " of Week Five.";
case 6:
return dayName + " of Week Six.";
case 7:
return dayName + " of Week Seven.";
case 8:
return dayName + " of Week Eight.";
case 9:
return dayName + " of the Semester Recess.";
case 10:
return dayName + " of Week Nine.";
case 11:
return dayName + " of Week Ten.";
case 12:
return dayName + " of Week Eleven.";
case 13:
return dayName + " of Week Twelve.";
case 14:
return dayName + " of Week Thirteen.";
case 15:
return dayName + " of STUVAC.";
case 16:
return dayName + " of Week One of the Exam Period.";
case 17:
return dayName + " of Week Two of the Exam Period.";
}
} else if (semesterStartDate == semester2) {
switch (weekNumber) {
case 1:
return dayName + " of Week One.";
case 2:
return dayName + " of Week Two.";
case 3:
return dayName + " of Week Three.";
case 4:
return dayName + " of Week Four.";
case 5:
return dayName + " of Week Five.";
case 6:
return dayName + " of Week Six.";
case 7:
return dayName + " of Week Seven.";
case 8:
return dayName + " of Week Eight.";
case 9:
return dayName + " of the Semester Recess.";
case 10:
return dayName + " of Week Nine.";
case 11:
return dayName + " of Week Ten.";
case 12:
return dayName + " of Week Eleven.";
case 13:
return dayName + " of Week Twelve.";
case 14:
return dayName + " of Week Thirteen.";
case 15:
return dayName + " of STUVAC.";
case 16:
return dayName + " of Week One of the Exam Period.";
case 17:
return dayName + " of Week Two of the Exam Period.";
}
}
};
const dayName = getDayName(dayNumber);
const weekNumber = getWeekNumber(currentDate);
const weekName = getWeekName(weekNumber);
document.getElementById("week-display").innerHTML = weekName; // [N.B: if you want to change the text preceding the counter, do so here]
// Optionally display message
let message;
if (weekName.includes("Week One")) {
message = "Every single person you meet knows something you don’t.";
} else if (weekName.includes("Week Two")) {
message = "You're not bad at something, you're just new to it.";
} else if (weekName.includes("Week Three")) {
message = "Read to find new ideas, write to understand them, implement to learn from them.";
} else if (weekName.includes("Week Four")) {
message = "Your brain doesn’t fill up with more information, it expands along with it.";
} else if (weekName.includes("Week Five")) {
message = "Being great is just being consistently good.";
} else if (weekName.includes("Week Six")) {
message = "Consuming information won't make you smart, applying it will.";
} else if (weekName.includes("Week Seven")) {
message = "Motivation more often comes after starting, not before.";
} else if (weekName.includes("Week Eight")) {
message = "A question opens the mind, a statement keeps it closed.";
} else if (weekName.includes("Week Nine")) {
message = "Continuous improvement is better than delayed perfection.";
} else if (weekName.includes("Week Ten")) {
message = "Get comfortable with changing your mind after learning new information.";
} else if (weekName.includes("Week Eleven")) {
message = "Discipline is choosing between what you want now and what you want most.";
} else if (weekName.includes("Week Twelve")) {
message = "If it doesn't feel like work, no one can compete with you.";
} else if (weekName.includes("Week Thirteen")) {
message = "The gap between where you are and where you want to be is closer than you think.";
} else if (weekName.includes("Recess")) {
message = "Luck favours those in motion.";
} else if (weekName.includes("STUVAC")) {
message = "Choose consistency over intensity, because consistency compounds.";
} else if (weekName.includes("Week One of the Exam Period")) {
message = "Your biggest competitor in life is yourself.";
} else if (weekName.includes("Week Two of the Exam Period")) {
message = "The dots only connect in retrospect.";
} else {
message = "If you never get bored of learning, you'll never get tired of living.";
}
document.getElementById("message-display").innerHTML = message;
// Optionally display/update progress bar
const updateProgressBar = () => {
const progressCircle = document.getElementById('progress-circle');
const percentage = document.getElementById('percentage');
// Calculate progress percentage, treating NaN as 100% and negative numbers as 0%
const progressPercentage = isNaN(weekNumber) ? 100 : Math.max((weekNumber / 18) * 100, 0);
const dashArray = Math.PI * 2 * 45;
const dashOffset = dashArray - (dashArray * progressPercentage) / 100;
progressCircle.style.strokeDasharray = dashArray;
progressCircle.style.strokeDashoffset = dashOffset;
percentage.textContent = `${progressPercentage.toFixed(0)}%`;
};
updateProgressBar(); // Update the progress bar on page load