Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Schedule

Schedule handles the storage, access, mutation and render of courses and events.

requires

window.catalog

Hierarchy

Index

Constructors

constructor

Properties

All

Private _preview

_preview: Section | null = null

the currently previewed (hovered) section

colorSlots

colorSlots: Set<string>[] = Array.from({ length: Schedule.colors.length }, () => new Set<string>())

keep track of used colors to avoid color collision

dateSelector

dateSelector: number = -1

the index of the currently selected separator (in dateSeparators)

dateSeparators

dateSeparators: number[] = []

The separator of sections in different time periods, representing different end times of sections. Elements are dates in milliseconds Example:

[1567457860885, 1567458860885]

days

days: ScheduleDays = [[], [], [], [], [], [], []]

computed based on this.All by computeSchedule

events

events: Event[]

Private pendingCompute

pendingCompute: number = 0

the computeSchedule handle returned by setTimeout

totalCredit

totalCredit: number = 0

total credits stored in this schedule, computed based on this.All

Static colors

colors: readonly string[] = colorSchemes[0].colors

Static combineSections

combineSections: boolean = true

Static multiSelect

multiSelect: boolean = true

Static savedColors

savedColors: {}

Type declaration

  • [key: string]: string

Methods

Private _computeSchedule

  • _computeSchedule(): void

Protected _copy

allEquals

cancelCompute

  • cancelCompute(): void

checkDate

clean

  • clean(): void

cleanSchedule

  • cleanSchedule(cleanDays?: boolean): void
  • clean the computed properties of the schedule. They can be recovered by calling the computeSchedule method

    Parameters

    • Default value cleanDays: boolean = true

    Returns void

computeSchedule

  • computeSchedule(sync?: boolean, time?: number): void
  • Compute the schedule view based on this.All and this.preview. If there is a pending compute task, remove that pending task.

    remarks

    this method has a very high time complexity. However, because we're running on small input sets (usually contain no more than 20 sections), it usually completes within 50ms.

    note

    it is the caller's responsibility to call constructDateSeparators, which is necessary if new classes are added

    Parameters

    • Default value sync: boolean = true

      if true, synchronously execute this function, otherwise use setTimeout

    • Default value time: number = 100

      the delay of setTimeout, in milliseconds

    Returns void

constructDateSeparator

  • constructDateSeparator(): void

constructDateSeparatorFromDateList

  • constructDateSeparatorFromDateList(dates: MeetingDate[]): void

Abstract copy

empty

  • empty(): boolean

equals

Private getColor

  • Get the background color of a hashable object Usually the object is either a Course, a Section, or an Event

    remarks

    color collision is handled by separate chaining

    Parameters

    Returns string

getSectionGroup

  • getSectionGroup(key: string, section: number): number
  • Parameters

    • key: string
    • section: number

    Returns number

    the group index corresponding to the given section

has

  • has(key: string, rendered?: boolean): boolean
  • Check whether the given key exists in the Schedule.

    Parameters

    • key: string
    • Default value rendered: boolean = true

      (default to true) if true, only returns true if the course/event with the given key is rendered

    Returns boolean

hasSection

  • hasSection(key: string, section: number): boolean
  • returns whether a given section exists in this schedule (All)

    Parameters

    • key: string
    • section: number

    Returns boolean

hover

  • hover(key: string, strong?: boolean): void
  • highlight a course, if it exists on the schedule no re-render is needed.

    Parameters

    • key: string
    • Default value strong: boolean = true

    Returns void

isAnySection

  • isAnySection(key: string): boolean

isCourseEmpty

  • isCourseEmpty(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

    true if none of the sections of this course is selected

isGroup

  • isGroup(key: string): boolean

isSomeTBD

  • isSomeTBD(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

    whether some of the sections selected corresponding to the given course key have invalid meeting time

Private place

  • place a Section/Course/Event/ into one of the days array according to its days property

    remarks

    we can place a Course instance if all of its sections occur at the same time

    Parameters

    Returns void

Private placeHelper

  • placeHelper<T>(color: string, days: ScheduleDays, events: T, meeting: T extends Event ? undefined : Meeting, dateArray?: MeetingDate): void

preview

Abstract remove

  • remove(key: string): void

removePreview

  • removePreview(): void

toJSON

ungroup

  • ungroup(key: string): void

unhover

  • unhover(key: string): void

Abstract update

  • update(key: string, section: number, group?: undefined | number, remove?: undefined | false | true): void
  • Parameters

    • key: string
    • section: number
    • Optional group: undefined | number
    • Optional remove: undefined | false | true

    Returns void

Static compressJSON

Static decompressJSON

Object literals

current

current: object

a computed object that's updated by the computeSchedule method, used by ClassList for rendering purposes

  • courses contain all sections (not just those selected by user)
  • ids are the list of ids selected for a given course

courses

courses: never[] = []

ids

ids: never[] = []

Generated using TypeDoc