diff --git a/app.js b/app.js index 536ee64..36f74cc 100644 --- a/app.js +++ b/app.js @@ -34,6 +34,10 @@ io.on("connection", (socket) => { //initial info on connection socket.emit("gameStateToClient", teamsList[currentTeamNumber], teamsScore[currentTeamNumber]); + socket.on("pingServer", (timeStamp) => { + socket.emit("pingClient", timeStamp); + }); + socket.on("buzzerPressed", (newUserName, newTimeStamp) => { let firstBuzzTimeStamp = (function() { if (buzzInfo.length == 0) { @@ -48,8 +52,13 @@ io.on("connection", (socket) => { timeStamp: newTimeStamp, lateTime: newTimeStamp-firstBuzzTimeStamp }); - io.emit("buzzInfoToClient", buzzInfo); + // function buzzInfoToclient() { + // io.emit("buzzInfoToClient", buzzInfo); + // console.log(buzzInfo); + // } + // setTimeout(buzzInfoToclient, 1000); + // console.log(buzzInfo); }); socket.on("scoresToServer", score => { @@ -74,6 +83,12 @@ io.on("connection", (socket) => { } io.emit("userInfoToClient", userInfo); }); + + socket.on("unregisterUsers", () => { + userInfo = new Object(); + io.emit("userInfoToClient", userInfo); + }); + }); // const io = new Server(server); diff --git a/audio/OkSsuka.wav b/audio/OkSsuka.wav new file mode 100644 index 0000000..12779ac Binary files /dev/null and b/audio/OkSsuka.wav differ diff --git a/audio/Okdesuka.wav b/audio/Okdesuka.wav deleted file mode 100644 index 1e0b307..0000000 Binary files a/audio/Okdesuka.wav and /dev/null differ diff --git a/browserFunctions.js b/browserFunctions.js index ca26fe1..d263ce9 100644 --- a/browserFunctions.js +++ b/browserFunctions.js @@ -7,28 +7,37 @@ function setupBuzzerOptions() { } function userInfoToClient(userInfo) { - $("#PlayersList").html(""); - $("#ChasersList").html(""); + $("#PlayersList").find("ul").html(""); + $("#ChasersList").find("ul").html(""); + console.log(userInfo); + for (const user in userInfo) { - $("#"+userInfo[user].teamName+"List").append("
  • "+user+"
  • "); + const userId = user.replaceAll(" ","_"); + $("#"+userInfo[user].teamName+"List").find("ul").append("
  • "+user+"
  • "); } } function gameStateToClient(currentTeam, currentScore) { + $("#PlayersList").css("opacity", 0.5); + $("#ChasersList").css("opacity", 0.5); + $("#"+currentTeam+"List").css("opacity", 1); + $("#currentTeam").html(currentTeam+" turn"); $("#currentScore").html(currentScore); } function buzzInfoToClient(buzzInfo, buzzerSound) { //play sound for first buzz in - if (buzzInfo.length == 1) { + if ($("#firstBuzz").html() == "") { buzzerSound.play(); $("#firstBuzz").html(buzzInfo[0].userName); - $("#userListPanel").find("#"+buzzInfo[0].userName).css("font-weight", 900); - $("#userListPanel").find("#"+buzzInfo[0].userName).find("var").html(" (BUZZ)") + const userId = buzzInfo[0].userName.replaceAll(" ","_"); + $("#userListPanel").find("#"+userId).css("font-weight", 900); + $("#userListPanel").find("#"+userId).find("var").html(" (BUZZ)") } for (let i=1; i < buzzInfo.length; i++) { - $("#userListPanel").find("#"+buzzInfo[i].userName).find("var").html(" ("+buzzInfo[i].lateTime/1000+")"); + const userId = buzzInfo[i].userName.replaceAll(" ","_"); + $("#userListPanel").find("#"+userId).find("var").html(" ("+buzzInfo[i].lateTime/1000+")"); } } \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..84a4bb0 Binary files /dev/null and b/favicon.ico differ diff --git a/pages/home.html b/pages/home.html index 5a69ec6..a6654b5 100644 --- a/pages/home.html +++ b/pages/home.html @@ -7,9 +7,9 @@