Now shows buzz in order instead of lateTime

This commit is contained in:
Samuel Kent
2023-01-01 17:19:30 +11:00
parent 355a2c8bf4
commit 3bcc2710c9
5 changed files with 7 additions and 15 deletions
+2 -1
View File
@@ -47,7 +47,8 @@ io.on("connection", (socket) => {
buzzInfo.push({ buzzInfo.push({
userName: newUserName, userName: newUserName,
timeStamp: newTimeStamp, timeStamp: newTimeStamp,
lateTime: newTimeStamp-firstBuzzTimeStamp lateTime: newTimeStamp-firstBuzzTimeStamp,
buzzOrder: buzzInfo.length+1
}); });
io.emit("buzzInfoToClient", buzzInfo); io.emit("buzzInfoToClient", buzzInfo);
// function buzzInfoToclient() { // function buzzInfoToclient() {
+4 -12
View File
@@ -1,12 +1,3 @@
// function setupBuzzerOptions() {
// buzzerOptions.forEach((buzzerName) => {
// $("#buzzerOptions").append("<img id='"+buzzerName+"' src='"+buzzerName+".png'>");
// });
// return buzzerOptions;
// }
function userInfoToClient(userInfo) { function userInfoToClient(userInfo) {
$("#PlayersList").find("ul").html(""); $("#PlayersList").find("ul").html("");
$("#ChasersList").find("ul").html(""); $("#ChasersList").find("ul").html("");
@@ -31,15 +22,16 @@ function buzzInfoToClient(buzzInfo) {
$("#firstBuzz").html(buzzInfo[0].userName); $("#firstBuzz").html(buzzInfo[0].userName);
const userId = buzzInfo[0].userName.replaceAll(" ","_"); const userId = buzzInfo[0].userName.replaceAll(" ","_");
// $("#userListPanel").find("#"+userId).css("font-weight", 900); // $("#userListPanel").find("#"+userId).css("font-weight", 900);
$("#userListPanel").find("#"+userId).find("var").html(" (BUZZ)"); // $("#userListPanel").find("#"+userId).find("var").html(" (BUZZ)");
let buzzerId = $("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId") let buzzerId = $("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId")
let buzzerSound = new Audio(buzzerId+".wav"); let buzzerSound = new Audio(buzzerId+".wav");
buzzerSound.play(); buzzerSound.play();
} }
for (let i=1; i < buzzInfo.length; i++) { for (let i=0; i < buzzInfo.length; i++) {
const userId = buzzInfo[i].userName.replaceAll(" ","_"); const userId = buzzInfo[i].userName.replaceAll(" ","_");
$("#userListPanel").find("#"+userId).find("var").html(" ("+buzzInfo[i].lateTime/1000+")"); // $("#userListPanel").find("#"+userId).find("var").html(" ("+buzzInfo[i].lateTime/1000+")");
$("#userListPanel").find("#"+userId).find("var").html(" ["+buzzInfo[i].buzzOrder+"]");
} }
} }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 KiB

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 155 KiB

+1 -2
View File
@@ -21,7 +21,6 @@
buzzerOptions.forEach((buzzerId) => { buzzerOptions.forEach((buzzerId) => {
$("#buzzerOptions").append("<img id='"+buzzerId+"' src='"+buzzerId+".png'>"); $("#buzzerOptions").append("<img id='"+buzzerId+"' src='"+buzzerId+".png'>");
}); });
// let buzzerSound = new Audio(buzzerOptions[0]+".wav");
$("#buzzer").attr("src", buzzerOptions[0]+".png" ); $("#buzzer").attr("src", buzzerOptions[0]+".png" );
$("#buzzer").css("opacity", "0.2"); $("#buzzer").css("opacity", "0.2");
let buzzable = false; let buzzable = false;
@@ -83,7 +82,7 @@
buzzerId = buzzerOptions[Math.floor(Math.random()*(buzzerOptions.length-1))]; buzzerId = buzzerOptions[Math.floor(Math.random()*(buzzerOptions.length-1))];
} }
socket.emit("updateUserInfo", userName, teamName, buzzerId); socket.emit("updateUserInfo", userName, teamName, buzzerId);
buzzerSound = new Audio(buzzerId+".wav"); let buzzerSound = new Audio(buzzerId+".wav");
$("#buzzer").attr("src", buzzerId+".png" ); $("#buzzer").attr("src", buzzerId+".png" );
buzzerSound.play(); buzzerSound.play();
}); });