added ExtensionRoot for consistent styling across injected components, and added a bunch of comments for all the added types and classes
This commit is contained in:
@@ -10,7 +10,6 @@ export type Instructor = {
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
middleInitial?: string;
|
||||
rateMyProfessorURL?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -18,6 +17,9 @@ export type Instructor = {
|
||||
*/
|
||||
export type InstructionMode = 'Online' | 'In Person' | 'Hybrid';
|
||||
|
||||
/**
|
||||
* The status of a course (e.g. open, closed, waitlisted, cancelled)
|
||||
*/
|
||||
export enum Status {
|
||||
OPEN = 'OPEN',
|
||||
CLOSED = 'CLOSED',
|
||||
@@ -25,20 +27,37 @@ export enum Status {
|
||||
CANCELLED = 'CANCELLED',
|
||||
}
|
||||
|
||||
/**
|
||||
* The internal representation of a course for the extension
|
||||
*/
|
||||
export class Course {
|
||||
/** Every course has a uniqueId within UT's registrar system corresponding to each course section */
|
||||
uniqueId: number;
|
||||
/** This is the course number for a course, i.e CS 314 would be 314, MAL 306H would be 306H */
|
||||
number: string;
|
||||
/** The full name of the course, i.e. CS 314 Data Structures and Algorithms */
|
||||
fullName: string;
|
||||
/** Just the english name for a course, without the number and department */
|
||||
courseName: string;
|
||||
/** The unique identifier for which department that a course belongs to, i.e. CS, MAL, etc. */
|
||||
department: string;
|
||||
/** Is the course open, closed, waitlisted, or cancelled? */
|
||||
status: Status;
|
||||
/** all the people that are teaching this course, and some metadata about their names */
|
||||
instructors: Instructor[];
|
||||
/** Some courses at UT are reserved for certain groups of people or people within a certain major, which makes it difficult for people outside of that group to register for the course. */
|
||||
isReserved: boolean;
|
||||
/** The description of the course as an array of "lines". This will include important information as well as a short summary of the topics covered */
|
||||
description?: string[];
|
||||
/** The schedule for the course, which includes the days of the week that the course is taught, the time that the course is taught, and the location that the course is taught */
|
||||
schedule: CourseSchedule;
|
||||
/** the link to the course details page for this course */
|
||||
url: string;
|
||||
/** the link to the registration page for this course, for easy access when registering */
|
||||
registerURL?: string;
|
||||
/** At UT, some courses have certain "flags" which aid in graduation */
|
||||
flags: string[];
|
||||
/** How is the class being taught (online, hybrid, in person, etc) */
|
||||
instructionMode: InstructionMode;
|
||||
|
||||
constructor(course: Course | Serialized<Course>) {
|
||||
@@ -46,6 +65,9 @@ export class Course {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper type that is used to represent a row in the course schedule table, with the actual element corresponding to the course object
|
||||
*/
|
||||
export type CourseRow = {
|
||||
rowElement: HTMLTableRowElement;
|
||||
course: Course;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Serialized } from 'chrome-extension-toolkit';
|
||||
|
||||
const dayMap = {
|
||||
/**
|
||||
* a map of the days of the week that a class is taught, and the corresponding abbreviation
|
||||
*/
|
||||
const DAY_MAP = {
|
||||
M: 'Monday',
|
||||
T: 'Tuesday',
|
||||
W: 'Wednesday',
|
||||
@@ -10,28 +13,42 @@ const dayMap = {
|
||||
SU: 'Sunday',
|
||||
} as const;
|
||||
|
||||
type Day = typeof dayMap[keyof typeof dayMap];
|
||||
/** A day of the week that a class is taught */
|
||||
type Day = typeof DAY_MAP[keyof typeof DAY_MAP];
|
||||
|
||||
/** A physical room that a class is taught in */
|
||||
type Room = {
|
||||
/** The UT building code for where the class is taught */
|
||||
building: string;
|
||||
/** The room number for where the class is taught */
|
||||
number: string;
|
||||
};
|
||||
|
||||
export type CourseSection = {
|
||||
/**
|
||||
* This represents one "Meeting Time" for a course, which includes the day of the week that the course is taught, the time that the course is taught, and the location that the course is taught
|
||||
*/
|
||||
export type CourseMeeting = {
|
||||
/** The day of the week that the course is taught */
|
||||
day: Day;
|
||||
/** The start time of the course, in minutes since midnight */
|
||||
startTime: number;
|
||||
/** The end time of the course, in minutes since midnight */
|
||||
endTime: number;
|
||||
/** The location that the course is taught */
|
||||
room?: Room;
|
||||
};
|
||||
|
||||
/**
|
||||
* This represents the schedule for a course, which includes all the meeting times for the course, as well as helper functions for parsing, serializing, and deserializing the schedule
|
||||
*/
|
||||
export class CourseSchedule {
|
||||
sections: CourseSection[];
|
||||
meetings: CourseMeeting[];
|
||||
|
||||
constructor(courseSchedule: CourseSchedule | Serialized<CourseSchedule>) {
|
||||
Object.assign(this, courseSchedule);
|
||||
}
|
||||
|
||||
static parse(dayLine: string, timeLine: string, roomLine: string): CourseSection[] {
|
||||
static parse(dayLine: string, timeLine: string, roomLine: string): CourseMeeting[] {
|
||||
try {
|
||||
let days: Day[] = dayLine
|
||||
.split('')
|
||||
@@ -44,7 +61,7 @@ export class CourseSchedule {
|
||||
if (char === 'S' && nextChar === 'U') {
|
||||
day += nextChar;
|
||||
}
|
||||
return dayMap[day];
|
||||
return DAY_MAP[day];
|
||||
})
|
||||
.filter(Boolean) as Day[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user