Methods
buildSchedulesModal()
Builds the viewSchedules modal. Should be called whenever any top-level schedule information is updated.
calculateInterval()
Calculates the integer intervals for displaying the events based on the current events in the schedule.
This should be called before draw when data relating to the times of the current schedule changes, or when the schedule is changed.
checkMobileWarning()
Checks whether or not to display the mobileWarningModal based on the size of the screen.
If the screen size is under a certain threshold, it dislays the mobileWarningModal.
convertToBool(boolString) → (nullable) {boolean}
Converts a boolean represented as a string into a boolean, since javascript is unreliable.
Parameters:
Name | Type | Description |
---|---|---|
boolString |
string | a string that represents a boolean, either 'true' or 'false' |
Returns:
- returns true or false based on the boolString parameter, or null if boolString was not 'true' or 'false'
- Type
- boolean
draw()
The draw function is run to recalculate elements such as class-boxes, timeboxes, and all the elements that make up the visuals.
This should be run anytime data changes that relates to the current schedule or settings.
editClass(classID)
Loads the edit class modal with the proper values when a class is clicked.
Parameters:
Name | Type | Description |
---|---|---|
classID |
string |
getDefault(value, defaultValue) → {*}
Detects whether value is null. If value is not null, then value is returned, otherwise, defaultValue is returned.
Parameters:
Name | Type | Description |
---|---|---|
value |
* | |
defaultValue |
* |
Returns:
- value is value is not null, otherwise defaultValue
- Type
- *
hideHiddenDayOptions(prefix)
Uses settings to determine whether to hide or show day options in the editClass or addClass modals.
Parameters:
Name | Type | Description |
---|---|---|
prefix |
string | Either editClass or addClass depending on which modal it is. |
loadClassInfo()
Loads schedules information from localStorage into local variables.
This function should probably be called loadScheduleInfo, as that is more accurate, but it was originally used for loading individual schedules before multi-schedule support. A refactor is probably in order for the future.
loadSettings()
Loads settings information from localStorage into local variables.
parseClassInfo(prefix, editingMode, classInfo) → {ParseClassInfoReturn}
Parses modal information into a classInfo object. Also performs validation for inputted values.
Parameters:
Name | Type | Description |
---|---|---|
prefix |
string | either editClass or addClass, depending on which modal it is. |
editingMode |
boolean | Controls whether to check for duplicates as part of the validation process. If set to true, the duplication check will be skipped. |
classInfo |
ClassInfo | The ClassInfo object, parsed from the inputs in the modals. |
Returns:
- Type
- ParseClassInfoReturn
parseDecimalTimeToString(time, useSpacesopt) → {string}
Parses a decimal time number into a human-readable time string.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
time |
number | A decimal number from 0-24. | ||
useSpaces |
boolean |
<optional> |
true | Whether or not put spaces between the time and the AM/PM. |
Returns:
- A human readable time string in HH:MM AM/PM format.
- Type
- string
parseNewScheduleName(newName) → {string}
Parses a new schedule name to avoid duplicates.
Parameters:
Name | Type | Description |
---|---|---|
newName |
string | The unverified new name. |
Returns:
- If the name did not conflict with any other schedule name, then the returned value is the same. Otherwise, it is slightly modified to avoid conflicts.
- Type
- string
parseTimeStringToDecimal(timeString) → {number}
Parses a time string into a decimal time.
Parameters:
Name | Type | Description |
---|---|---|
timeString |
string | A string representing the time in HH:MM AM/PM format. |
Returns:
- A decimal number from between 0-24 representing the given time string.
- Type
- number
saveClassInfo()
Saves all schedule information from local variables into localStorage.
saveSettings()
Saves settings from local variables into localStorage.
schedulesLength() → {int}
Reliably gets the length of the schedules list. This is necessary because Object.keys() will occasionally returns keys whose values are null or undefined, and as such, Object.keys().length is unreliable for determining the amount of schedules.
Returns:
- The number of schedules.
- Type
- int
setCurrentSchedule(newScheduleName)
Sets the current schedule by updating currentSchedule, updating classes, saving class info, rebuilding the schedules modal, and redrawing.
Parameters:
Name | Type | Description |
---|---|---|
newScheduleName |
string | the schedule id of the schedule to switch to. |
setPreviewBoxColor(prefix)
Sets the preview box color in either the editClass or addClass modal.
Should be run when the color select is changed.
Parameters:
Name | Type | Description |
---|---|---|
prefix |
string | either editClass or addClass depending on which modal |
setRowVisibility(bool, id) → {int}
Sets the visibility of a dayrow based on the bool parameter. Also adds classes to visible rows.
Parameters:
Name | Type | Description |
---|---|---|
bool |
boolean | Controls whether the row should be shown or hidden. A true value will show the row, while a false value will hide it. |
id |
string | The id of the row element to operate on. |
Returns:
- Returns 1 if the row was shown, and 0 if the row was hidden.
- Type
- int
timeLabelFromInt(timeInt) → {string}
Generates a string time label from an integer
Parameters:
Name | Type | Description |
---|---|---|
timeInt |
int | An integer from 0-24. |
Returns:
- A string representing the given time in HH:00 AM/PM format.
- Type
- string
verifyScheduleFile(fileContents) → {VerifyScheduleFileReturn}
Verifies schedule file contents.
Parameters:
Name | Type | Description |
---|---|---|
fileContents |
string | The contents of the actual file, as a string of text |
Returns:
- An object consisting of success and contents
Type Definitions
ClassInfo
The object that contains information for a given class.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
displayName |
string | The display name of the class |
startTime |
number | The start time of the class, stored as a decimal number from 0-24 |
endTime |
number | The end time of the class, stored as a decimal number from 0-24 |
days |
Array.<boolean> | An array with 7 booleans denoting what days the class is on. The first value in the array is Sunday, and the last is Saturday. Each value should be either true (class is enabled on that day), or false (class is not enabled on that day) |
color |
string | The display color of the class |
ParseClassInfoReturn
The object returned by parseClassInfo.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
invalid |
boolean | Whether the inputted values were invalid. If this value returns true, the returned information should not be saved. |
classID |
string | The class ID of the returned class object. |
ScheduleFile
An object representing the contens of a schedule file.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
name |
string | The name of the schedule |
classes |
Array.<ClassInfo> | A list of classes in the form of ClassInfo objects |
VerifyScheduleFileReturn
An object that represents the return value of verifyScheduleFile
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
success |
boolean | Whether or not the schedule is valid. |
contents |
ScheduleFile | The contents of the schedule file, in object form. |