only check every second for timer updates

This commit is contained in:
bingus_violet 2024-06-29 18:54:27 -05:00
parent a530774d36
commit 7f8fdb6b7c

View file

@ -86,7 +86,7 @@ function timeFormatter(seconds) {
}
}
function loop() {
function spinLoop() {
spinWaiting = true
setTimeout(() => {
spinWaiting = false
@ -125,26 +125,31 @@ function loop() {
spins = lerp(spins, Math.round(spins), 1 / spinSpeed * 3)
}
$(".pfp").css("rotate", (spins * 360) + "deg")
$(".durationBarFormatter").each((_, item) => {
item = $(item)
item.text(`${timeFormatter((Date.now() - item.attr("data-start")))}/${timeFormatter((item.attr("data-end") - item.attr("data-start")))}`)
})
$(".timeEstimate").each((_, item) => {
item = $(item)
item.text(gameTimeFormatter(Date.now() - item.attr("data-start")))
})
$(".endEstimate").each((_, item) => {
item = $(item)
item.text(timeFormatter((item.attr("data-end") - Date.now())))
})
loop()
spinLoop()
}, 1/spinSpeed * 1000);
}
function secondLoop() {
$(".durationBarFormatter").each((_, item) => {
item = $(item)
item.text(`${timeFormatter((Date.now() - item.attr("data-start")))}/${timeFormatter((item.attr("data-end") - item.attr("data-start")))}`)
})
$(".timeEstimate").each((_, item) => {
item = $(item)
item.text(gameTimeFormatter(Date.now() - item.attr("data-start")))
})
$(".endEstimate").each((_, item) => {
item = $(item)
item.text(timeFormatter((item.attr("data-end") - Date.now())))
})
setTimeout(() => {
secondLoop()
}, 1000);
}
window.onbeforeunload = function () {
window.scrollTo(0, 0);
}
@ -154,7 +159,8 @@ window.onload = function () {
pfp = $(".pfp")
loop()
spinLoop()
secondLoop()
pfp.on("mousedown", () => {
// if (!spinWaiting) {