diff --git a/browserFunctions.js b/browserFunctions.js index d263ce9..006bbec 100644 --- a/browserFunctions.js +++ b/browserFunctions.js @@ -1,5 +1,6 @@ +let buzzerOptions = ["Kirbeep","MPYosh","MPDog","MPCat","Wow","Ooh","MarioBoing","TheNumberEight","Mystery"]; function setupBuzzerOptions() { - let buzzerOptions = ["Kirbeep","MPYosh","MPDog","MPCat","Wow","Ooh","MarioBoing","TheNumberEight"]; + buzzerOptions.forEach((buzzerName) => { $("#buzzerOptions").append(""); }); @@ -9,8 +10,6 @@ function setupBuzzerOptions() { function userInfoToClient(userInfo) { $("#PlayersList").find("ul").html(""); $("#ChasersList").find("ul").html(""); - console.log(userInfo); - for (const user in userInfo) { const userId = user.replaceAll(" ","_"); $("#"+userInfo[user].teamName+"List").find("ul").append("
  • "+user+"
  • "); @@ -40,4 +39,14 @@ function buzzInfoToClient(buzzInfo, buzzerSound) { const userId = buzzInfo[i].userName.replaceAll(" ","_"); $("#userListPanel").find("#"+userId).find("var").html(" ("+buzzInfo[i].lateTime/1000+")"); } +} + +function selectBuzzer(buzzerId) { + if (buzzerId == "Mystery") { + buzzerId = buzzerOptions[Math.floor(Math.random()*8)]; + } + buzzerSound = new Audio(buzzerId+".wav"); + $("#buzzer").attr("src", buzzerId+".png" ); + buzzerSound.play(); + return buzzerSound; } \ No newline at end of file diff --git a/images/Mystery.png b/images/Mystery.png new file mode 100644 index 0000000..d1cc182 Binary files /dev/null and b/images/Mystery.png differ diff --git a/pages/host.html b/pages/host.html index 04957c5..90e8e53 100644 --- a/pages/host.html +++ b/pages/host.html @@ -44,8 +44,7 @@ }); $("#buzzerOptions").contents().mousedown(function() { - buzzerSound = new Audio($(this).attr("id")+".wav"); - buzzerSound.play(); + buzzerSound = selectBuzzer($(this).attr("id")); }); }); diff --git a/pages/play.html b/pages/play.html index 444cb6b..182e7f9 100644 --- a/pages/play.html +++ b/pages/play.html @@ -20,7 +20,6 @@ let buzzerOptions = setupBuzzerOptions(); let buzzerSound = new Audio(buzzerOptions[0]+".wav"); - console.log(buzzerSound); $("#buzzer").attr("src", buzzerOptions[0]+".png" ); $("#buzzer").css("opacity", "0.2"); let buzzable = false; @@ -77,9 +76,7 @@ } $("#buzzerOptions").contents().mousedown(function() { - buzzerSound = new Audio($(this).attr("id")+".wav"); - $("#buzzer").attr("src", $(this).attr("id")+".png" ); - buzzerSound.play(); + buzzerSound = selectBuzzer($(this).attr("id")); }); });