diff --git a/index.html b/index.html index e7c691c..02acd5e 100755 --- a/index.html +++ b/index.html @@ -17,6 +17,11 @@

The ... Championship

at 00:00

Remaining: 00:00:00

+ +
+ More +

Make my timers shorter by

+
diff --git a/js/transform.js b/js/transform.js index 0d61341..9aba03f 100644 --- a/js/transform.js +++ b/js/transform.js @@ -18,4 +18,12 @@ export default class Transform { static time(time) { return Math.floor(time/60).toString().padStart(2, '0') + ":" + (time % 60).toString().padStart(2, '0') } + + static stopAtZero(number) { + if (number > 0) { + return number + } + + return 0 + } } diff --git a/js/ui.js b/js/ui.js index e378801..7db3080 100644 --- a/js/ui.js +++ b/js/ui.js @@ -9,6 +9,8 @@ export default class UI { constructor(rootObject) { this.rootObject = rootObject + this.savedParanoiaOffset = localStorage.getItem('paranoiaOffset') || 2 + this.setParanoiaOffset(this.savedParanoiaOffset) this.loadChampionships() this.start() // auto-start, might need some more thought } @@ -17,6 +19,19 @@ export default class UI { UI.instance = new UI(window.document) } + get paranoiaOffset() { + let currentParanoiaOffset = this.rootObject.getElementById('paranoia').value + if (this.savedParanoiaOffset != currentParanoiaOffset) { + localStorage.setItem('paranoiaOffset', currentParanoiaOffset) + } + + return currentParanoiaOffset + } + + setParanoiaOffset(value) { + this.rootObject.getElementById('paranoia').value = value + } + loadResponseIntoData(response) { response.json().then(Data.init) } @@ -54,8 +69,13 @@ export default class UI { } updateTimer(next) { - let remaining = Transform.time(next.remaining) + ":" + Day.secondsUntilFullMinute - this.rootObject.getElementById('timer').innerHTML = remaining + let remaining = next.remaining - this.paranoiaOffset + let formattedRemaining = '00:00:00' + if (remaining >= 0) { + formattedRemaining = Transform.time(remaining) + ":" + Day.secondsUntilFullMinute + } + + this.rootObject.getElementById('timer').innerHTML = formattedRemaining this.rootObject.title = `${remaining} - ${next.location} - SSO Timer` }