162 lines
4.8 KiB
HTML
162 lines
4.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Now with more buzzers per buzzer!</title>
|
|
<link rel="stylesheet" href="styleMain.css">
|
|
<script src="browserFunctions.js"></script>
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
|
<script src="http:/socket.io/socket.io.js"></script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
var socket = io();
|
|
let buzzInTime;//for ping check
|
|
let queryString = new URL(location.href);
|
|
let userName = queryString.searchParams.get("user");
|
|
$("#message").html("hi "+userName+" :]")
|
|
let teamName = queryString.searchParams.get("team");
|
|
let buzzerOptions = [["Kirbeep","KirbyMic2","KirbyMic3","KirbySquishy","KirbyBugzzy","KirbyKracko"],["MarioBoing","MarioPenguin","MarioCoin","MPYosh","MPDog","MPCat"],["EBWow","EBAttack1","SaturnHonk"],["Ooh"],["Jiggluigibat"],["AAHoldIt","AATakeThat"],["EmergencyMeeting"],["TheNumberEight"],["PikminThrow","PikminDeath"],["MGSAlert"],["FF9Moogle"],["P3Summon"],["HKAdido","HKShaw","HKGrub"],["DKOK"],["SonicOhNo"],["PdPSeren","TAFroggy"],["PKMNLvlUp"],["Mystery"]];
|
|
buzzerOptions.forEach((buzzerGroup) => {
|
|
const groupFaceId = buzzerGroup[0];
|
|
const buzzerGroupHTML = $("<div class=buzzerGroup><small>"+buzzerGroup.length+"</small><img id='"+groupFaceId+"' src='"+groupFaceId+".png'> <div class=buzzerGroupItems hidden> </div>");
|
|
buzzerGroup.forEach((buzzerId) => {
|
|
buzzerGroupHTML.find(".buzzerGroupItems").append("<img id='"+buzzerId+"' src='"+buzzerId+".png'>");
|
|
});
|
|
$("#buzzerOptions").append(buzzerGroupHTML);
|
|
});
|
|
$("#buzzer").attr("src", buzzerOptions[0]+".png" );
|
|
$("#buzzer").css("opacity", "0.2");
|
|
let buzzable = false;
|
|
|
|
socket.emit("updateUserInfo", userName, teamName, "Kirbeep");//initial user registration
|
|
$("#buzzer").attr("src", "Kirbeep.png" );
|
|
|
|
socket.on("userInfoToClient", (userInfo) => {
|
|
userInfoToClient(userInfo);
|
|
});
|
|
|
|
socket.on("gameStateToClient", (currentTeam, currentScore) => {
|
|
gameStateToClient(currentTeam, currentScore);
|
|
});
|
|
|
|
socket.on("clearBuzzers", (currentTeam) => {
|
|
if (currentTeam == teamName) {
|
|
buzzable = true;
|
|
$("#buzzer").css("opacity", "1");
|
|
|
|
} else {
|
|
buzzable = false;
|
|
$("#buzzer").css("opacity", "0.2");
|
|
}
|
|
$("#firstBuzz").html("");
|
|
});
|
|
|
|
socket.on("buzzInfoToClient", (buzzInfo) => {
|
|
buzzInfoToClient(buzzInfo);
|
|
});
|
|
|
|
socket.on("pingClient", (timeStamp) => {
|
|
const ping = new Date().getTime() - timeStamp;
|
|
console.log("ping: "+ping);
|
|
});
|
|
|
|
$(document).keydown(function(e) {
|
|
if(e.which == 32) {
|
|
buzzIn();
|
|
}
|
|
});
|
|
|
|
$("#buzzer").mousedown(function() {
|
|
buzzIn();
|
|
});
|
|
|
|
function buzzIn() {
|
|
if (buzzable) {
|
|
buzzable = false;
|
|
$("#buzzer").css("opacity", "0.2");
|
|
buzzInTime = new Date().getTime();
|
|
socket.emit("buzzerPressed", userName, buzzInTime);
|
|
socket.emit("pingServer", new Date().getTime());
|
|
}
|
|
}
|
|
|
|
$(".buzzerGroup").mousedown(function() {
|
|
$(".buzzerGroupItems").hide();
|
|
$(this).find(".buzzerGroupItems").show();
|
|
});
|
|
|
|
$("#buzzerOptions img").mousedown(function() {
|
|
buzzerId = $(this).attr("id");
|
|
if (buzzerId == "Mystery") {
|
|
buzzerOptionsFlat = buzzerOptions.flat();
|
|
buzzerId = buzzerOptionsFlat[Math.floor(Math.random()*(buzzerOptionsFlat.length-1))];
|
|
}
|
|
socket.emit("updateUserInfo", userName, teamName, buzzerId);
|
|
let buzzerSound = new Audio(buzzerId+".wav");
|
|
$("#buzzer").attr("src", buzzerId+".png" );
|
|
buzzerSound.play();
|
|
});
|
|
|
|
$("#contestAnswer").find("img").mousedown(function() {
|
|
socket.emit("objectionToServer", userName);
|
|
});
|
|
|
|
$("#contestAnswer").find("img").hover(
|
|
function() {
|
|
$(this).attr("src", "AAEvidence.gif");
|
|
}, function() {
|
|
$(this).attr("src", "AAEvidence.png");
|
|
}
|
|
);
|
|
|
|
socket.on("objectionToClient", (userName) => {
|
|
objectionToClient(userName);
|
|
});
|
|
|
|
socket.on("clearObjectionToClient", () => {
|
|
clearObjectionToClient();
|
|
});
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<p id="message"></p>
|
|
<div id="interface">
|
|
<p id="currentTeam"></p>
|
|
Progress:
|
|
<p id="currentScore"></p>
|
|
<br>
|
|
<img id="buzzer" alt="The buzzer">
|
|
<br>
|
|
<p id="firstBuzz"></p>
|
|
<p id="instructions">
|
|
Click the buzzer above or press spacebar to buzz in.
|
|
<br>
|
|
You can only buzz in on your team's turn.
|
|
</p>
|
|
<div id="objection">
|
|
</div>
|
|
</div>
|
|
<div id="userListPanel">
|
|
<div id="PlayersList">
|
|
Players:
|
|
<ul></ul>
|
|
</div>
|
|
<div id="ChasersList">
|
|
Chasers:
|
|
<ul></ul>
|
|
</div>
|
|
</div>
|
|
<div id="buzzerOptions">
|
|
</div>
|
|
<div id="contestAnswer">
|
|
<img src="AAEvidence.png" >
|
|
<p>
|
|
Click to contest an answer marked incorrectly.
|
|
<br>
|
|
(please use sparingly)
|
|
</p>
|
|
<div>
|
|
</body>
|
|
</html>
|