diff --git a/js/championship.js b/js/championship.js index cae7cc2..bde7938 100644 --- a/js/championship.js +++ b/js/championship.js @@ -5,7 +5,13 @@ import Transform from './transform.js' export default class Championship { 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() { let remainingOffset = 0 let day = Day.today @@ -17,12 +23,12 @@ export default class Championship { time = Championship.firstTimeNextDay } - return { + return new Championship({ day: day, time: time, location: Data.championships[day][time], remaining: (remainingOffset + time) - Day.minutesPassedSinceMidnight, - } + }) } static get nextChanged() { diff --git a/js/sso-timer.js b/js/sso-timer.js index 5329f09..ed32b2e 100644 --- a/js/sso-timer.js +++ b/js/sso-timer.js @@ -1,6 +1,3 @@ import UI from './ui.js' -import Championship from './championship.js' - -window.Championship = Championship window.addEventListener('load', UI.init) diff --git a/js/ui.js b/js/ui.js index 53e454e..3521cf6 100644 --- a/js/ui.js +++ b/js/ui.js @@ -8,7 +8,7 @@ export default class UI { static updateFrequency = 500 // in ms constructor(rootObject) { - this.next = null + this.next = new Championship() this.rootObject = rootObject this.savedParanoiaOffset = localStorage.getItem('paranoiaOffset') || 1 this.#setParanoiaOffset(this.savedParanoiaOffset) @@ -42,7 +42,7 @@ export default class UI { Day.update() - this.next = Championship.next // TODO: make "next" a standard format + this.next = Championship.next if (Championship.nextChanged) { this.#updateChampionshipDetails()