make Championship an instantiated class

This commit is contained in:
2023-12-02 17:10:54 +01:00
parent b98513e6f3
commit 0a14e69f82
3 changed files with 11 additions and 8 deletions
+9 -3
View File
@@ -5,7 +5,13 @@ import Transform from './transform.js'
export default class Championship { export default class Championship {
static last = null static last = null
// TODO: make "next" a standard format constructor(details) {
this.day = details?.day
this.time = details?.time
this.location = details?.location
this.remaining = details?.remaining
}
static get next() { static get next() {
let remainingOffset = 0 let remainingOffset = 0
let day = Day.today let day = Day.today
@@ -17,12 +23,12 @@ export default class Championship {
time = Championship.firstTimeNextDay time = Championship.firstTimeNextDay
} }
return { return new Championship({
day: day, day: day,
time: time, time: time,
location: Data.championships[day][time], location: Data.championships[day][time],
remaining: (remainingOffset + time) - Day.minutesPassedSinceMidnight, remaining: (remainingOffset + time) - Day.minutesPassedSinceMidnight,
} })
} }
static get nextChanged() { static get nextChanged() {
-3
View File
@@ -1,6 +1,3 @@
import UI from './ui.js' import UI from './ui.js'
import Championship from './championship.js'
window.Championship = Championship
window.addEventListener('load', UI.init) window.addEventListener('load', UI.init)
+2 -2
View File
@@ -8,7 +8,7 @@ export default class UI {
static updateFrequency = 500 // in ms static updateFrequency = 500 // in ms
constructor(rootObject) { constructor(rootObject) {
this.next = null this.next = new Championship()
this.rootObject = rootObject this.rootObject = rootObject
this.savedParanoiaOffset = localStorage.getItem('paranoiaOffset') || 1 this.savedParanoiaOffset = localStorage.getItem('paranoiaOffset') || 1
this.#setParanoiaOffset(this.savedParanoiaOffset) this.#setParanoiaOffset(this.savedParanoiaOffset)
@@ -42,7 +42,7 @@ export default class UI {
Day.update() Day.update()
this.next = Championship.next // TODO: make "next" a standard format this.next = Championship.next
if (Championship.nextChanged) { if (Championship.nextChanged) {
this.#updateChampionshipDetails() this.#updateChampionshipDetails()