Skip to content

Commit 6a71f00

Browse files
committed
add countdown to the beginning of the school day
implementation is sketchy. but whatever
1 parent d7f78a0 commit 6a71f00

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

classtime.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,16 @@ function updateText() {
225225
document.getElementById("schedule").innerHTML = getSummaryString();
226226

227227
if (!isNoSchoolDay()) {
228-
document.getElementById('timeToEndOfClass').innerHTML = getTimeToEndOfCurrentClassString()
228+
if(!classIsInSession() && !isNoSchoolDay() && !checkGivenTimeIsBeforeCurrentTime(data.schedules[currentScheduleIndex].classes[0].startTime)) {
229+
230+
document.getElementById("countdownLabel").innerHTML = "School starts in: "
231+
document.getElementById('timeToEndOfClass').innerHTML = getTimeToStartOfSchoolString();
232+
233+
} else {
234+
document.getElementById("countdownLabel").innerHTML = "...which ends in: ";
235+
document.getElementById('timeToEndOfClass').innerHTML = getTimeToEndOfCurrentClassString();
236+
}
237+
229238
document.getElementById("nextClass").innerHTML = getClassName(currentClassPeriodIndex+1)
230239
document.getElementById("currentClass").innerHTML = getClassName(currentClassPeriodIndex)
231240
//document.getElementById('sentence').innerHTML = getSummaryString()
@@ -434,6 +443,18 @@ function getTimeToEndOfCurrentClassString() {
434443
}
435444
}
436445

446+
/**
447+
* This fucntion is used for calculating how long until school starts
448+
* @returns the time to the start of school as a string
449+
*/
450+
function getTimeToStartOfSchoolString() {
451+
if (!classIsInSession() && !isNoSchoolDay() && !checkGivenTimeIsBeforeCurrentTime(data.schedules[currentScheduleIndex].classes[0].startTime)) {
452+
return getTimeStringFromObject(getTimeDelta(data.schedules[currentScheduleIndex].classes[0].startTime));
453+
} else {
454+
return "No Class"
455+
}
456+
}
457+
437458
/**
438459
* this is a an unused method that was written for a feature that never got implemented and, as of this point in time, identical to @function getTimeToEndOfCurrentClassString()
439460
*

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1 class="centered time" id="time"></h1>
1313
<p class="centered label">You are currently in: </p>
1414
<h1 class="centered bottomSpace" id="currentClass"></h1>
1515

16-
<p class="centered label">...which ends in: </p>
16+
<p class="centered label" id="countdownLabel">...which ends in: </p>
1717
<h1 class="centered bottomSpace time bigger" id="timeToEndOfClass"></h1>
1818

1919
<p class="centered label">Your next class period is: </p>

0 commit comments

Comments
 (0)