add paranoiaOffset

This commit is contained in:
2023-12-02 14:08:54 +01:00
parent 754893252e
commit f575301a6d
3 changed files with 35 additions and 2 deletions
+22 -2
View File
@@ -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`
}