From 9677ce9886ca47912abd66e2545a03980920a259 Mon Sep 17 00:00:00 2001 From: elijahr2411 Date: Fri, 27 Jan 2023 21:09:34 -0500 Subject: [PATCH] - remove duplicate variable - fix error in chatMessage() when processing history - fix turn timer being delayed by one second --- src/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index b0e1eba..b48b7e6 100644 --- a/src/index.js +++ b/src/index.js @@ -26,7 +26,6 @@ const buttons = { } var hasTurn = false; var vm; -var connected = false; var voteinterval; var turninterval; const chatsound = new Audio(config.chatSound); @@ -225,6 +224,7 @@ class CollabVMClient { clearInterval(turninterval); turnstatus.innerText = `Turn expires in ${secs} seconds.`; } + turnUpdate(); turninterval = setInterval(turnUpdate, 1000); display.className = "focused"; } @@ -241,6 +241,7 @@ class CollabVMClient { turnstatus.innerText = `Waiting for turn in ${secs} seconds.`; } turninterval = setInterval(turnUpdate, 1000); + turnUpdate(); display.className = "waiting"; }; var user = users.find(u => u.username === msgArr[i+3]); @@ -486,8 +487,8 @@ function chatMessage(user, msg) { td.innerHTML = msg; else { var u = users.find(u => u.username === user); - var userclass = ""; - switch (u.rank) { + var userclass; + if (u) switch (u.rank) { case 2: userclass = "text-danger"; break; @@ -499,6 +500,7 @@ function chatMessage(user, msg) { userclass = "text-light"; break; } + else userclass = "text-light"; td.innerHTML = `${user}> ${msg}`; } tr.appendChild(td); @@ -548,7 +550,6 @@ async function openVM(url, node) { window.location.href = "#" + node; vm = new CollabVMClient(url); await vm.connect(); - connected = true; await vm.connectToVM(node); vmlist.style.display = "none"; vmview.style.display = "block";