From d3d722b0e3030f9e503ca880480e9aae56d0a791 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Sat, 29 Dec 2018 11:08:44 -0800 Subject: [PATCH 01/45] remove extraneous --- index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.html b/index.html index a7745eb..1a20109 100644 --- a/index.html +++ b/index.html @@ -37,5 +37,4 @@

} } - - \ No newline at end of file + \ No newline at end of file From c21b292fc123f5217530b423d2f76afd934adc3e Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Sat, 29 Dec 2018 12:34:07 -0800 Subject: [PATCH 02/45] add schoolIsInSession() function --- classtime.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/classtime.js b/classtime.js index 3a6458d..4657288 100644 --- a/classtime.js +++ b/classtime.js @@ -277,6 +277,16 @@ function classIsInSession() { //might later want to add a check to make sure that currentClassPeriodIndex is not greater than the number of classes in the schedule for today } +/** + * this function checks to see if the current time is between the start of the first scheduled class and the end of the last scheduled class. This indicates that school is currently in session + * + * @returns a boolean representing if school is in session + */ +function schoolIsInSession() { + + return (checkStartTime(data.schedules[currentScheduleIndex].classes[0]) && checkEndTime(data.schedules[currentScheduleIndex].classes[data.schedules[currentScheduleIndex].classes.length-1])) +} + /** * this function checks to see if the currentScheduleIndex is valid (greater than -1), indicating that there is a schedule for the day * From f168fb68f6f0a2191e25d933dee1efea2502e171 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Sat, 29 Dec 2018 13:36:42 -0800 Subject: [PATCH 03/45] add state flags --- classtime.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/classtime.js b/classtime.js index 4657288..fc74a29 100644 --- a/classtime.js +++ b/classtime.js @@ -1,3 +1,13 @@ +let DAY_OFF_FLAG = "day off" +let OUTSIDE_SCHOOL_HOURS_FLAG = "outside school hours" +let SCHOOL_IN_CLASS_OUT_FLAG = "school is in session, but class is not" +let CLASS_IN_SESSION_FLAG = "class is in session" + + + + + + var currentDay = 0; var currentHours = 0; var currentMinutes = 0; From 426c81b7dff8b9a078eff504f2a6fa868d5e3648 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Sat, 29 Dec 2018 13:37:22 -0800 Subject: [PATCH 04/45] remove passing periods from the schedule they are basically just duplicate info anyways --- classtime.js | 60 ---------------------------------------------------- 1 file changed, 60 deletions(-) diff --git a/classtime.js b/classtime.js index fc74a29..88e003b 100644 --- a/classtime.js +++ b/classtime.js @@ -41,12 +41,6 @@ var data = { startTime: {hours: 9, minutes:55}, endTime: {hours: 10, minutes:10} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 10, minutes:10}, - endTime: {hours: 10, minutes:15} - }, { name: "2nd Period", startTime: {hours: 10, minutes:15}, @@ -57,23 +51,11 @@ var data = { startTime: {hours: 11, minutes:45}, endTime: {hours: 12, minutes:20} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 12, minutes:20}, - endTime: {hours: 12, minutes:25} - }, { name: "3rd Period", startTime: {hours: 12, minutes:25}, endTime: {hours: 13, minutes:55} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 13, minutes:55}, - endTime: {hours: 14, minutes:00} - }, { name: "4th Period", startTime: {hours: 14, minutes:00}, @@ -95,23 +77,11 @@ var data = { startTime: {hours: 9, minutes:47}, endTime: {hours: 9, minutes:57} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 9, minutes:57}, - endTime: {hours: 10, minutes:02} - }, { name: "Support Seminar", startTime: {hours: 10, minutes:02}, endTime: {hours: 10, minutes:34} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 10, minutes:34}, - endTime: {hours: 10, minutes:39} - }, { name: "2nd Period", startTime: {hours: 10, minutes:39}, @@ -122,23 +92,11 @@ var data = { startTime: {hours: 12, minutes:01}, endTime: {hours: 12, minutes:36} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 12, minutes:36}, - endTime: {hours: 12, minutes:41} - }, { name: "3rd Period", startTime: {hours: 12, minutes:41}, endTime: {hours: 14, minutes:03} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 14, minutes:03}, - endTime: {hours: 14, minutes:8} - }, { name: "4th Period", startTime: {hours: 14, minutes:8}, @@ -160,12 +118,6 @@ var data = { startTime: {hours: 9, minutes:50}, endTime: {hours: 10, minutes:00} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 10, minutes:00}, - endTime: {hours: 10, minutes:05} - }, { name: "2nd Period", startTime: {hours: 10, minutes:05}, @@ -176,23 +128,11 @@ var data = { startTime: {hours: 11, minutes:30}, endTime: {hours: 12, minutes:05} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 12, minutes:05}, - endTime: {hours: 12, minutes:10} - }, { name: "3rd Period", startTime: {hours: 12, minutes:10}, endTime: {hours: 13, minutes:35} }, - { - name: "Passing Period", - showInFullSchedule: false, - startTime: {hours: 13, minutes:35}, - endTime: {hours: 13, minutes:40} - }, { name: "4th Period", startTime: {hours: 13, minutes:40}, From 76a8b6832f983203072f376ab1093b6691d94b0c Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Sat, 29 Dec 2018 13:39:08 -0800 Subject: [PATCH 05/45] re-organise updateText using state flags --- classtime.js | 91 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 34 deletions(-) diff --git a/classtime.js b/classtime.js index 88e003b..fea5b60 100644 --- a/classtime.js +++ b/classtime.js @@ -172,40 +172,72 @@ function updateText() { document.getElementById('time').innerHTML = getCurrentTimeString(); document.getElementById('date').innerHTML = getCurrentDateString(); - document.getElementById("schedule").innerHTML = getSummaryString(); - - if (!isNoSchoolDay()) { - if(!classIsInSession() && !isNoSchoolDay() && !checkGivenTimeIsBeforeCurrentTime(data.schedules[currentScheduleIndex].classes[0].startTime)) { - - document.getElementById("countdownLabel").innerHTML = "School starts in: " - document.getElementById('timeToEndOfClass').innerHTML = getTimeToStartOfSchoolString(); + + + + document.getElementById("schedule").innerHTML = "You are viewing the " + getCurrentScheduleName() + " schedule." + + document.getElementById("viewScheduleLink").style.display = "block"; + + + + switch (getCurrentTimeState()) { + case DAY_OFF_FLAG: + document.getElementById("schedule").innerHTML = "There's no class today!" + document.getElementById("viewScheduleLink").style.display = "none"; - } else { + break; + + case OUTSIDE_SCHOOL_HOURS_FLAG: + + if(!checkGivenTimeIsBeforeCurrentTime(data.schedules[currentScheduleIndex].classes[0].startTime)) { + document.getElementById("countdownLabel").innerHTML = "School starts in: " + document.getElementById('timeToEndOfClass').innerHTML = getTimeToStartOfSchoolString(); + } + + document.getElementById("nextClass").innerHTML = getClassName(currentClassPeriodIndex+1) + document.getElementById("currentClass").innerHTML = getClassName(currentClassPeriodIndex) + + break; + + case SCHOOL_IN_CLASS_OUT_FLAG: + + + document.getElementById("nextClass").innerHTML = getClassName(currentClassPeriodIndex+1) + document.getElementById("currentClass").innerHTML = getClassName(currentClassPeriodIndex) + break; + + case CLASS_IN_SESSION_FLAG: document.getElementById("countdownLabel").innerHTML = "...which ends in: "; document.getElementById('timeToEndOfClass').innerHTML = getTimeToEndOfCurrentClassString(); - } - - document.getElementById("nextClass").innerHTML = getClassName(currentClassPeriodIndex+1) - document.getElementById("currentClass").innerHTML = getClassName(currentClassPeriodIndex) - //document.getElementById('sentence').innerHTML = getSummaryString() - labels = document.getElementsByClassName("label") + document.getElementById("nextClass").innerHTML = getClassName(currentClassPeriodIndex+1) + document.getElementById("currentClass").innerHTML = getClassName(currentClassPeriodIndex) + break; - for (var i = 0; i < labels.length; i++) { - labels[i].style.display = "block"; - } + default: + + + } + +} + + +function getCurrentTimeState() { - document.getElementById("viewScheduleLink").style.display = "block"; + //there is no schedule that applies today + if (getCurrentScheduleIndex() <= -1) { return DAY_OFF_FLAG } + + //it is a school day but it is not school hours + else if (!schoolIsInSession()) { return OUTSIDE_SCHOOL_HOURS_FLAG } - } else { - labels = document.getElementsByClassName("label") + //the current time lies between the start of the first schedules class and the end of the last + else if (schoolIsInSession() && !classIsInSession()) { return SCHOOL_IN_CLASS_OUT_FLAG } + + //the current time lies within a scheduled class period + else if (classIsInSession()) { return CLASS_IN_SESSION_FLAG } - for (var i = 0; i < labels.length; i++) { - labels[i].style.display = "none"; - } - document.getElementById("viewScheduleLink").style.display = "none"; - } } /** @@ -256,15 +288,6 @@ function scheduleExists() { return typeof data !== 'undefined' } -function getSummaryString() { - if (isNoSchoolDay()) { - return "There's no class today!" - } else { - return "You are viewing the " + getCurrentScheduleName() + " schedule." - } - //other options - //"it is currently ##:##:##. (period) ends in ##:##" -} From a0af5a639fd901298ff08df5854c65c21270cfd8 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Mon, 31 Dec 2018 16:32:49 -0800 Subject: [PATCH 06/45] continue to update the time even if schedule data is not available --- classtime.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classtime.js b/classtime.js index fea5b60..aeb7085 100644 --- a/classtime.js +++ b/classtime.js @@ -152,8 +152,10 @@ function update() { if (scheduleExists()) { updateVariables() updateText(); - setTimeout(update, 500); + } + + setTimeout(update, 500); } /** From bd0c14699788b2330681cc4bd1c1b822d50ce198 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Wed, 2 Jan 2019 10:44:25 -0800 Subject: [PATCH 07/45] Add flash function --- _layouts/default.html | 1 + classtime.js | 41 +++++++++++++++++++++++++++++++++++++---- style.css | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 4 deletions(-) diff --git a/_layouts/default.html b/_layouts/default.html index 516529b..6b3847b 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -17,6 +17,7 @@ +

{{ content }} diff --git a/classtime.js b/classtime.js index aeb7085..0cd9360 100644 --- a/classtime.js +++ b/classtime.js @@ -3,10 +3,10 @@ let OUTSIDE_SCHOOL_HOURS_FLAG = "outside school hours" let SCHOOL_IN_CLASS_OUT_FLAG = "school is in session, but class is not" let CLASS_IN_SESSION_FLAG = "class is in session" - - - - +let FLASH_SUCCESS = "SUCCESS" +let FLASH_INFO = "INFO" +let FLASH_WARN = "WARNING" +let FLASH_DANGER = "DANGER" var currentDay = 0; var currentHours = 0; @@ -567,6 +567,39 @@ function getLocalStorageBoolean(key, unsetDefault=false) { } } +function flashMessage(message, type = FLASH_INFO, timeout = 5000) { + flash = document.getElementById("flash") + + flash.innerHTML = message; + flash.style.visibility = "visible"; + + + switch (type) { + case FLASH_SUCCESS: + flash.className = "success"; + break; + + case FLASH_WARN: + flash.className = "warning"; + break; + + case FLASH_DANGER: + flash.className = "danger"; + break; + + default: //FLASH_INFO + flash.className = "info"; + } + // maybe animate down or fade in + + if (timeout > 0) { + setTimeout( function remove() { + flash.style.visibility = "hidden"; + }, timeout) + } + +} + var a=document.getElementsByTagName("a"); for(var i=0;i a { margin: 5px; +} + +#flash { + visibility: hidden; + margin: 0 auto; + display: block; + text-align: center; + width: 90vw; + border-bottom-right-radius: .5rem; + border-bottom-left-radius: .5rem; + border: 1px solid rgba(0, 0, 0, 0.5); +} + +#flash.success { + background-color: #d4edda; /* copied from bootstrap */ + color: #155724; +} + +#flash.info { + color: #0c5460; /* copied from bootstrap */ + background-color: #a7d6f5; +} + +#flash.warning { + background-color: #faf0ce; + color: #856404; +} + +#flash.danger { + background-color: #f38c95; + color: #721c24; /* copied from bootstrap */ + } \ No newline at end of file From 53d8eea23a1cddace4651bf7bfb4722ddae680b2 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Thu, 31 Jan 2019 09:54:56 -0800 Subject: [PATCH 08/45] Change data structure to support multiple hardcoded schools --- classtime.js | 281 +++++++++++++++++++++++++------------------------- schedule.html | 4 +- 2 files changed, 145 insertions(+), 140 deletions(-) diff --git a/classtime.js b/classtime.js index 0cd9360..7c13630 100644 --- a/classtime.js +++ b/classtime.js @@ -18,130 +18,135 @@ var currentClassPeriodIndex = -1; //nextClassPeriodIndex var currentScheduleIndex = -1; +var selectedSchoolIndex = 0; var use24HourTime = getLocalStorageBoolean("use24HourTime", false); -var data = { - fullName: "", - shortName: "", - //order is as is on the school website, although it doesnt matter. - schedules: [ - { - name: "Mon/Fri (Regular)", - days: [1, 5], - classes: [ - { - name: "1st Period", - startTime: {hours: 8, minutes:25}, - endTime: {hours: 9, minutes:55} - }, - { - name: "TSCT", - startTime: {hours: 9, minutes:55}, - endTime: {hours: 10, minutes:10} - }, - { - name: "2nd Period", - startTime: {hours: 10, minutes:15}, - endTime: {hours: 11, minutes:45} - }, - { - name: "Lunch", - startTime: {hours: 11, minutes:45}, - endTime: {hours: 12, minutes:20} - }, - { - name: "3rd Period", - startTime: {hours: 12, minutes:25}, - endTime: {hours: 13, minutes:55} - }, - { - name: "4th Period", - startTime: {hours: 14, minutes:00}, - endTime: {hours: 15, minutes:30} - } - ] - }, - { - name: "Tues/Wed (Support Seminar)", - days: [2, 3], - classes: [ - { - name: "1st Period", - startTime: {hours: 8, minutes:25}, - endTime: {hours: 9, minutes:47} - }, - { - name: "TSCT", - startTime: {hours: 9, minutes:47}, - endTime: {hours: 9, minutes:57} - }, - { - name: "Support Seminar", - startTime: {hours: 10, minutes:02}, - endTime: {hours: 10, minutes:34} - }, - { - name: "2nd Period", - startTime: {hours: 10, minutes:39}, - endTime: {hours: 12, minutes:01} - }, - { - name: "Lunch", - startTime: {hours: 12, minutes:01}, - endTime: {hours: 12, minutes:36} - }, - { - name: "3rd Period", - startTime: {hours: 12, minutes:41}, - endTime: {hours: 14, minutes:03} - }, - { - name: "4th Period", - startTime: {hours: 14, minutes:8}, - endTime: {hours: 15, minutes:30} - } - ], - }, + + +var schools = [ { - name: "Thursday (Early Release)", - days: [4], - classes: [ - { - name: "1st Period", - startTime: {hours: 8, minutes:25}, - endTime: {hours: 9, minutes:50} - }, - { - name: "TSCT", - startTime: {hours: 9, minutes:50}, - endTime: {hours: 10, minutes:00} - }, - { - name: "2nd Period", - startTime: {hours: 10, minutes:05}, - endTime: {hours: 11, minutes:30} - }, - { - name: "Lunch", - startTime: {hours: 11, minutes:30}, - endTime: {hours: 12, minutes:05} - }, - { - name: "3rd Period", - startTime: {hours: 12, minutes:10}, - endTime: {hours: 13, minutes:35} - }, - { - name: "4th Period", - startTime: {hours: 13, minutes:40}, - endTime: {hours: 15, minutes:05} - } - ] - } - ] -}; + fullName: "", + shortName: "", + //order is as is on the school website, although it doesnt matter. + schedules: [ + { + name: "Mon/Fri (Regular)", + days: [1, 5], + classes: [ + { + name: "1st Period", + startTime: {hours: 8, minutes:25}, + endTime: {hours: 9, minutes:55} + }, + { + name: "TSCT", + startTime: {hours: 9, minutes:55}, + endTime: {hours: 10, minutes:10} + }, + { + name: "2nd Period", + startTime: {hours: 10, minutes:15}, + endTime: {hours: 11, minutes:45} + }, + { + name: "Lunch", + startTime: {hours: 11, minutes:45}, + endTime: {hours: 12, minutes:20} + }, + { + name: "3rd Period", + startTime: {hours: 12, minutes:25}, + endTime: {hours: 13, minutes:55} + }, + { + name: "4th Period", + startTime: {hours: 14, minutes:00}, + endTime: {hours: 15, minutes:30} + } + ] + }, + { + name: "Tues/Wed (Support Seminar)", + days: [2, 3], + classes: [ + { + name: "1st Period", + startTime: {hours: 8, minutes:25}, + endTime: {hours: 9, minutes:47} + }, + { + name: "TSCT", + startTime: {hours: 9, minutes:47}, + endTime: {hours: 9, minutes:57} + }, + { + name: "Support Seminar", + startTime: {hours: 10, minutes:02}, + endTime: {hours: 10, minutes:34} + }, + { + name: "2nd Period", + startTime: {hours: 10, minutes:39}, + endTime: {hours: 12, minutes:01} + }, + { + name: "Lunch", + startTime: {hours: 12, minutes:01}, + endTime: {hours: 12, minutes:36} + }, + { + name: "3rd Period", + startTime: {hours: 12, minutes:41}, + endTime: {hours: 14, minutes:03} + }, + { + name: "4th Period", + startTime: {hours: 14, minutes:8}, + endTime: {hours: 15, minutes:30} + } + ], + }, + { + name: "Thursday (Early Release)", + days: [4], + classes: [ + { + name: "1st Period", + startTime: {hours: 8, minutes:25}, + endTime: {hours: 9, minutes:50} + }, + { + name: "TSCT", + startTime: {hours: 9, minutes:50}, + endTime: {hours: 10, minutes:00} + }, + { + name: "2nd Period", + startTime: {hours: 10, minutes:05}, + endTime: {hours: 11, minutes:30} + }, + { + name: "Lunch", + startTime: {hours: 11, minutes:30}, + endTime: {hours: 12, minutes:05} + }, + { + name: "3rd Period", + startTime: {hours: 12, minutes:10}, + endTime: {hours: 13, minutes:35} + }, + { + name: "4th Period", + startTime: {hours: 13, minutes:40}, + endTime: {hours: 15, minutes:05} + } + ] + } + ] + } +]; /** * The standard run loop for updating the time and other time-related information on the site. @@ -149,7 +154,7 @@ var data = { */ function update() { updateTime(); - if (scheduleExists()) { + if (typeof selectedSchoolIndex !== 'undefined') { updateVariables() updateText(); @@ -192,7 +197,7 @@ function updateText() { case OUTSIDE_SCHOOL_HOURS_FLAG: - if(!checkGivenTimeIsBeforeCurrentTime(data.schedules[currentScheduleIndex].classes[0].startTime)) { + if(!checkGivenTimeIsBeforeCurrentTime(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[0].startTime)) { document.getElementById("countdownLabel").innerHTML = "School starts in: " document.getElementById('timeToEndOfClass').innerHTML = getTimeToStartOfSchoolString(); } @@ -247,7 +252,7 @@ function getCurrentTimeState() { */ function getCurrentScheduleName() { if (!isNoSchoolDay()) { - return data.schedules[currentScheduleIndex].name + return schools[selectedSchoolIndex].schedules[currentScheduleIndex].name } else { return "No School"} } @@ -268,7 +273,7 @@ function classIsInSession() { */ function schoolIsInSession() { - return (checkStartTime(data.schedules[currentScheduleIndex].classes[0]) && checkEndTime(data.schedules[currentScheduleIndex].classes[data.schedules[currentScheduleIndex].classes.length-1])) + return (checkStartTime(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[0]) && checkEndTime(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes.length-1])) } /** @@ -334,8 +339,8 @@ function getCurrentClassPeriodIndex() { } //using for over forEach() because we are breaking out of the loop early - for (let i = 0; i < data.schedules[currentScheduleIndex].classes.length; i++) { - if (checkStartTime(data.schedules[currentScheduleIndex].classes[i]) && checkEndTime(data.schedules[currentScheduleIndex].classes[i])) { + for (let i = 0; i < schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes.length; i++) { + if (checkStartTime(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[i]) && checkEndTime(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[i])) { return i break;//not sure if this is necessary so I included it anyway } @@ -350,8 +355,8 @@ function getCurrentClassPeriodIndex() { */ function getCurrentScheduleIndex() { //using for over forEach() because we are breaking out of the loop early - for (let i = 0; i < data.schedules.length; i++) { - if (data.schedules[i].days.includes(currentDay)) { + for (let i = 0; i < schools[selectedSchoolIndex].schedules.length; i++) { + if (schools[selectedSchoolIndex].schedules[i].days.includes(currentDay)) { return i } } @@ -430,7 +435,7 @@ function convertMillisecondsToTime(milliseconds) { */ function getTimeToEndOfCurrentClassString() { if (classIsInSession()) { - return getTimeStringFromObject(getTimeDelta(data.schedules[currentScheduleIndex].classes[currentClassPeriodIndex].endTime)); + return getTimeStringFromObject(getTimeDelta(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[currentClassPeriodIndex].endTime)); } else { return "No Class" } @@ -441,8 +446,8 @@ function getTimeToEndOfCurrentClassString() { * @returns the time to the start of school as a string */ function getTimeToStartOfSchoolString() { - if (!classIsInSession() && !isNoSchoolDay() && !checkGivenTimeIsBeforeCurrentTime(data.schedules[currentScheduleIndex].classes[0].startTime)) { - return getTimeStringFromObject(getTimeDelta(data.schedules[currentScheduleIndex].classes[0].startTime)); + if (!classIsInSession() && !isNoSchoolDay() && !checkGivenTimeIsBeforeCurrentTime(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[0].startTime)) { + return getTimeStringFromObject(getTimeDelta(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[0].startTime)); } else { return "No Class" } @@ -454,8 +459,8 @@ function getTimeToStartOfSchoolString() { * @returns the time to the start of the next class as a string */ function getTimeToStartOfNextClassString() { - if (classIsInSession() && currentClassPeriodIndex+1 < data.schedule[selectedSchedule].classes.length ) { - return getTimeStringFromObject(getTimeDelta(data.schedules[currentScheduleIndex].classes[currentClassPeriodIndex+1].startTime)); + if (classIsInSession() && currentClassPeriodIndex+1 < schools[selectedSchoolIndex].schedule[selectedSchedule].classes.length ) { + return getTimeStringFromObject(getTimeDelta(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[currentClassPeriodIndex+1].startTime)); } else { return "No More Classes" } @@ -484,8 +489,8 @@ function getTimeStringFromObject(timeObject, includeSeconds=true) { * @returns returns the class name for the given index or "No Class" if there is no class in session */ function getClassName(index) { - if (!isNoSchoolDay() && index >= 0 && index < data.schedules[currentScheduleIndex].classes.length) { - return data.schedules[currentScheduleIndex].classes[index].name.toString() + if (!isNoSchoolDay() && index >= 0 && index < schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes.length) { + return schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[index].name.toString() } else { return "No Class" } @@ -504,19 +509,19 @@ function populateScheduleTable() { //tbl.setAttribute('border', '1'); var tbdy = document.createElement('tbody'); - for (var i = 0; i < data.schedules[currentScheduleIndex].classes.length; i++) { - if (data.schedules[currentScheduleIndex].classes[i].showInFullSchedule != false) { + for (var i = 0; i < schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes.length; i++) { + if (schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[i].showInFullSchedule != false) { var tr = document.createElement('tr'); //for (var j = 0; j < 3; j++) { var td = document.createElement('td'); - td.innerHTML = data.schedules[currentScheduleIndex].classes[i].name; + td.innerHTML = schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[i].name; td.style.fontWeight = "bold"; //td.appendChild(document.createTextNode(data.schedules[currentScheduleIndex].classes[i].name)) tr.appendChild(td) var td = document.createElement('td'); - td.innerHTML = getFormattedTimeStringFromObject(data.schedules[currentScheduleIndex].classes[i].startTime) + " - " + getFormattedTimeStringFromObject(data.schedules[currentScheduleIndex].classes[i].endTime) + td.innerHTML = getFormattedTimeStringFromObject(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[i].startTime) + " - " + getFormattedTimeStringFromObject(schools[selectedSchoolIndex].schedules[currentScheduleIndex].classes[i].endTime) //td.appendChild(document.createTextNode(data.schedules[currentScheduleIndex].classes[i].name)) tr.appendChild(td); diff --git a/schedule.html b/schedule.html index 6fdb5aa..69e9c3e 100644 --- a/schedule.html +++ b/schedule.html @@ -16,8 +16,8 @@

From 4a608cf45181d5de8f719e04973acdd496dc8709 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Thu, 31 Jan 2019 09:55:40 -0800 Subject: [PATCH 09/45] add function to get an index from localStorage --- classtime.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/classtime.js b/classtime.js index 7c13630..0cfd3b7 100644 --- a/classtime.js +++ b/classtime.js @@ -572,6 +572,14 @@ function getLocalStorageBoolean(key, unsetDefault=false) { } } +function getLocalStorageIndex(key) { + if (localStorage.getItem(key) !== null) { + return (Number(localStorage.getItem(key))) + } else { + return undefined; + } +} + function flashMessage(message, type = FLASH_INFO, timeout = 5000) { flash = document.getElementById("flash") From 437b16d4079be5cb7787004e9a1881a94bc91a13 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Wed, 2 Jan 2019 10:59:22 -0800 Subject: [PATCH 10/45] Add School Name --- classtime.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classtime.js b/classtime.js index 0cfd3b7..7f00453 100644 --- a/classtime.js +++ b/classtime.js @@ -27,8 +27,8 @@ var use24HourTime = getLocalStorageBoolean("use24HourTime", false); var schools = [ { - fullName: "", - shortName: "", + fullName: "Lake Oswego High School", + shortName: "LOHS", //order is as is on the school website, although it doesnt matter. schedules: [ { From d775a8b153516263169ace96ea5ff35de1248354 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Wed, 2 Jan 2019 11:21:26 -0800 Subject: [PATCH 11/45] fix close spacing on settings page --- settings.html | 7 ++++--- style.css | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/settings.html b/settings.html index e7a6eba..b45967b 100644 --- a/settings.html +++ b/settings.html @@ -6,12 +6,13 @@
- - + + Settings are automatically saved
-

Settings are automatically saved

diff --git a/style.css b/style.css index 0266840..28feead 100644 --- a/style.css +++ b/style.css @@ -81,10 +81,19 @@ h1.bigger { font-size: 3em; } +section#credits { + margin-top: 20vh +} + section#credits > a { margin: 5px; } +section#options > * { + display: block; + margin-top: 2vw; +} + #flash { visibility: hidden; margin: 0 auto; From 5fde3c68ebcc6bf0ca9812b5e86e9c68ee986435 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Wed, 2 Jan 2019 11:24:12 -0800 Subject: [PATCH 12/45] continue to update date and time even if a school isn't selected --- classtime.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/classtime.js b/classtime.js index 7f00453..c4827d9 100644 --- a/classtime.js +++ b/classtime.js @@ -154,6 +154,10 @@ var schools = [ */ function update() { updateTime(); + document.getElementById('time').innerHTML = getCurrentTimeString(); + document.getElementById('date').innerHTML = getCurrentDateString(); + + if (typeof selectedSchoolIndex !== 'undefined') { updateVariables() updateText(); @@ -176,12 +180,6 @@ function updateVariables() { * Updates labels on the homepage */ function updateText() { - document.getElementById('time').innerHTML = getCurrentTimeString(); - document.getElementById('date').innerHTML = getCurrentDateString(); - - - - document.getElementById("schedule").innerHTML = "You are viewing the " + getCurrentScheduleName() + " schedule." document.getElementById("viewScheduleLink").style.display = "block"; @@ -309,6 +307,7 @@ function updateTime() { currentHours = currentDate.getHours(); currentMinutes = currentDate.getMinutes(); currentSeconds = currentDate.getSeconds(); + } From 516b99e789a848c1727bf32c6d40da0db5f88216 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Wed, 2 Jan 2019 11:26:47 -0800 Subject: [PATCH 13/45] move nav button HTML to a more sensible place --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 1a20109..a7df214 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ title: ClassClock onload: update() --- +

It is currently:

@@ -23,7 +24,6 @@

View Schedule - + + @@ -22,27 +31,4 @@ {{ content }} - - - - From 6bfbc2b12c7a7b7dd70f4d75c40787fbacce5a9e Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Sun, 10 Feb 2019 09:39:00 -0800 Subject: [PATCH 42/45] hide labels on no school days --- classtime.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/classtime.js b/classtime.js index 648ee90..502635c 100644 --- a/classtime.js +++ b/classtime.js @@ -178,17 +178,25 @@ function updateVariables() { * Updates labels on the homepage */ function updateText() { - document.getElementById("schedule").innerHTML = "You are viewing the " + getCurrentScheduleName() + " schedule" - document.getElementById("selectedSchoolDisplay").innerHTML = "from " + schools[selectedSchoolIndex].fullName + "."; - document.getElementById("viewScheduleLink").style.display = "block"; + if (getCurrentTimeState() !== DAY_OFF_FLAG ) { + document.getElementById("schedule").innerHTML = "You are viewing the " + getCurrentScheduleName() + " schedule" + document.getElementById("selectedSchoolDisplay").innerHTML = "from " + schools[selectedSchoolIndex].fullName + "."; + document.getElementById("viewScheduleLink").style.display = "block"; + } switch (getCurrentTimeState()) { case DAY_OFF_FLAG: document.getElementById("schedule").innerHTML = "There's no class today!" document.getElementById("viewScheduleLink").style.display = "none"; + + let labels = document.getElementsByClassName("label") + for (let i = 0; i < labels.length; i++ ) { + labels[i].style.display = "none"; + } + break; From 6b485dde908ef00fc10ca65bebf1dd5e1bb095ca Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Sun, 10 Feb 2019 09:39:25 -0800 Subject: [PATCH 43/45] add styles for links in flash messages --- style.css | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/style.css b/style.css index 5033588..a8ea495 100644 --- a/style.css +++ b/style.css @@ -117,6 +117,15 @@ section#options > * { border-bottom: 1px solid rgba(0, 0, 0, 0.5); } +#flash a { + font-weight: 700; + text-decoration: none; + +} +#flash a:hover { + text-decoration: underline; +} + #flash.success { background-color: #d4edda; /* copied from bootstrap */ color: #155724; @@ -127,6 +136,10 @@ section#options > * { background-color: #a7d6f5; } +#flash.info a { + color: #002752; +} + #flash.warning { background-color: #faf0ce; color: #856404; @@ -138,6 +151,10 @@ section#options > * { } +.alert-link { + font-weight: 700; +} + .verticalFlex { display: flex; flex-direction: column; From 1f49a7a321da296902efe8146d8d8c80f9f2badc Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Sun, 10 Feb 2019 11:37:18 -0800 Subject: [PATCH 44/45] remove links from readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0fdb47c..09778a3 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ ClassTime is a web-based app that can be saved to your phone's home screen or bo ### iOS -1. Navigate to https://classclock.app in Safari (not tested on other browsers) +1. Navigate to ClassClock in Safari (not tested on other browsers) 2. Click the "Share" or "Action" button (it looks like a square with an arrow pointing up out of the top) 3. Click "Add to Home Screen" on the bottom row (you might have to scroll sideways to see it) 4. Click "Done" in the top corner of the screen to add it to your home screen. @@ -45,7 +45,7 @@ ClassTime is a web-based app that can be saved to your phone's home screen or bo ### Android -1. Navigate to https://classclock.app (instructions for Google Chrome) +1. Navigate to ClassClock (instructions for Google Chrome) 2. Click the "Overflow" button on the top right of your screen (it looks like three vertical dots) 3. Click "Add to Home Screen" button in the menu (it's about 2/3 of the way down) 4. Click "Add" in the dialog box that pops up to add it to your home screen. From f611fc0eab870b16473b320ae63c8dc505011cc7 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Wed, 13 Feb 2019 23:04:25 -0800 Subject: [PATCH 45/45] fix an instance of the old name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09778a3..6cba2da 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Here are some features to look forward to in a future version: ## How to install? -ClassTime is a web-based app that can be saved to your phone's home screen or bookmarked in your browser for easy access. +ClassClock is a web-based app that can be saved to your phone's home screen or bookmarked in your browser for easy access. ### iOS