add paranoiaOffset
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user