add paranoiaOffset
This commit is contained in:
@@ -17,6 +17,11 @@
|
||||
<h3 class="location-container">The <span id="location">...</span> Championship</h3>
|
||||
<p class="championship">at <span id="time">00:00</span></p>
|
||||
<p class="remaining">Remaining: <span id="timer">00:00:00</span></p>
|
||||
|
||||
<details>
|
||||
<summary>More</summary>
|
||||
<p class="paranoia-disclaimer">Make my timers shorter by <input id="paranoia" type="number" step="1" value="2"></input></p>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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