From b21a5969e38054c15c82a79748ba9cb08e9457c1 Mon Sep 17 00:00:00 2001 From: Interitio Date: Mon, 22 Sep 2025 23:05:25 +1000 Subject: [PATCH] Remove extra timer modes. --- timer.js | 72 ++++---------------------------------------------------- 1 file changed, 5 insertions(+), 67 deletions(-) diff --git a/timer.js b/timer.js index 31ca2da..b3b0dbd 100644 --- a/timer.js +++ b/timer.js @@ -1,5 +1,5 @@ window.addEventListener("DOMContentLoaded", () => { - const websocket = new WebSocket("ws://adamwalsh.name:9533"); + const websocket = new WebSocket("wss://izashi.thewisewolf.dev/tracker/timer/ws"); websocket.addEventListener("open", () => { communicate(websocket); @@ -20,12 +20,12 @@ class Timer { render_time() { // Render timer status to the document var timestr; + // How many seconds to the end of time + var dur_seconds = Math.floor( (this.end_time - new Date()) / 1000); - if (this.counter < 0) { - timestr = "--:--"; + if (dur_seconds < 0) { + timestr = "00:00"; } else { - // How many seconds have passed in this block - var dur_seconds = Math.floor( (this.end_time - new Date()) / 1000); var seconds = dur_seconds % 60; dur_seconds = dur_seconds - seconds; var minutes = Math.floor(dur_seconds / 60); @@ -86,68 +86,6 @@ class TimerRenderer { } -function rectBounds(prop, rectHeight, rectWidth) { - var totalCircum = 2 * rectHeight + 2 * rectWidth; - var propCircum = prop * totalCircum; - let bounds; - - if (propCircum < rectWidth / 2) { - var xprop = Math.floor(( - (rectWidth/2 + propCircum) / rectWidth - ) * 1000)/10; - bounds = [ - "50% -5%", - `${xprop}% -5%`, - `${xprop}% 4%`, - "50% 4%" - ]; - } else if (propCircum < rectWidth / 2 + rectHeight) { - var yprop = ( - (propCircum - rectWidth / 2) / rectHeight - ) * 100; - bounds = [ - "50% -5%", "110% -5%", - `110% ${yprop}%`, `96% ${yprop}%`, - "95% 4%", "50% 4%" - ]; - } else if (propCircum < 3 * rectWidth / 2 + rectHeight) { - var xprop = ( - ((3 * rectWidth/2 + rectHeight) - propCircum) / rectWidth - ) * 100; - bounds = [ - "50% -5%", "110% -5%", - "110% 110%", - `${xprop}% 110%`, `${xprop}% 96%`, - "95% 96%", - "95% 4%", "50% 4%" - ]; - } else if (propCircum < 3 * rectWidth / 2 + 2 * rectHeight) { - var yprop = ( - ((3 * rectWidth/2 + 2 * rectHeight) - propCircum) / rectHeight - ) * 100; - bounds = [ - "50% -5%", "110% -5%", - "110% 110%", "-5% 110%", - `-5% ${yprop}%`, `4% ${yprop}%`, - "5% 96%", "95% 96%", - "95% 4%", "50% 4%" - ]; - } else { - var xprop = ( - (propCircum - (3 * rectWidth/2 + 2 * rectHeight)) / rectWidth - ) * 100; - bounds = [ - "50% -5%", "110% -5%", - "110% 110%", "-5% 110%", - "-5% -5%", - `${xprop}% -5%`, `${xprop}% 4%`, - "4% 4%", - "5% 96%", "95% 96%", - "95% 4%", "50% 4%" - ]; - } - return bounds; -} function communicate(websocket) { console.log("Communicating");