Buzzers now play the selection of each user, buzzers also displayed on user lists. Also added some new buzzers
@@ -1,14 +1,11 @@
|
|||||||
|
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
// const https = require('https');
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const app = express();
|
const app = express();
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const { Server } = require("socket.io");
|
const { Server } = require("socket.io");
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
// key: fs.readFileSync('key.pem'),
|
|
||||||
// cert: fs.readFileSync('cert.pem')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = http.createServer(options, app);
|
const server = http.createServer(options, app);
|
||||||
@@ -77,9 +74,10 @@ io.on("connection", (socket) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
socket.on("registerUser", (newUserName, newTeamName) => {
|
socket.on("updateUserInfo", (userName, teamName, buzzerId) => {
|
||||||
userInfo[newUserName] = {
|
userInfo[userName] = {
|
||||||
teamName: newTeamName
|
teamName: teamName,
|
||||||
|
buzzerId: buzzerId
|
||||||
}
|
}
|
||||||
io.emit("userInfoToClient", userInfo);
|
io.emit("userInfoToClient", userInfo);
|
||||||
});
|
});
|
||||||
@@ -112,7 +110,7 @@ app.get("/browserFunctions.js", (request, response) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//all files in these folders can be accessed with a GET request of the filename
|
//all files in these folders can be accessed with a GET request of the filename
|
||||||
let assetFolders = ["styles","pages","images","audio","fonts"];
|
let assetFolders = ["styles","pages","images","images/buzzers","audio","fonts"];
|
||||||
assetFolders.forEach((folderName) => {
|
assetFolders.forEach((folderName) => {
|
||||||
let folderContents = fs.readdirSync(folderName);
|
let folderContents = fs.readdirSync(folderName);
|
||||||
folderContents.forEach((fileName) => {
|
folderContents.forEach((fileName) => {
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
let buzzerOptions = ["Kirbeep","MPYosh","MPDog","MPCat","Wow","Ooh","MarioBoing","TheNumberEight","Mystery"];
|
|
||||||
function setupBuzzerOptions() {
|
// function setupBuzzerOptions() {
|
||||||
|
|
||||||
buzzerOptions.forEach((buzzerName) => {
|
// buzzerOptions.forEach((buzzerName) => {
|
||||||
$("#buzzerOptions").append("<img id='"+buzzerName+"' src='"+buzzerName+".png'>");
|
// $("#buzzerOptions").append("<img id='"+buzzerName+"' src='"+buzzerName+".png'>");
|
||||||
});
|
// });
|
||||||
return buzzerOptions;
|
// return buzzerOptions;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function userInfoToClient(userInfo) {
|
function userInfoToClient(userInfo) {
|
||||||
$("#PlayersList").find("ul").html("");
|
$("#PlayersList").find("ul").html("");
|
||||||
$("#ChasersList").find("ul").html("");
|
$("#ChasersList").find("ul").html("");
|
||||||
for (const user in userInfo) {
|
for (const user in userInfo) {
|
||||||
const userId = user.replaceAll(" ","_");
|
const userId = user.replaceAll(" ","_");
|
||||||
$("#"+userInfo[user].teamName+"List").find("ul").append("<li id="+userId+">"+user+"<var></var></li>");
|
$("#"+userInfo[user].teamName+"List").find("ul").append("<li id="+userId+">"+"<img src="+userInfo[user].buzzerId+".png data-buzzerId="+userInfo[user].buzzerId+" class=userListBuzzerSelections>"+user+"<var></var></li>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,14 +25,16 @@ function gameStateToClient(currentTeam, currentScore) {
|
|||||||
$("#currentScore").html(currentScore);
|
$("#currentScore").html(currentScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buzzInfoToClient(buzzInfo, buzzerSound) {
|
function buzzInfoToClient(buzzInfo) {
|
||||||
//play sound for first buzz in
|
//play sound for first buzz in
|
||||||
if ($("#firstBuzz").html() == "") {
|
if ($("#firstBuzz").html() == "") {
|
||||||
buzzerSound.play();
|
|
||||||
$("#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 buzzerSound = new Audio(buzzerId+".wav");
|
||||||
|
buzzerSound.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i=1; i < buzzInfo.length; i++) {
|
for (let i=1; i < buzzInfo.length; i++) {
|
||||||
@@ -43,9 +45,9 @@ function buzzInfoToClient(buzzInfo, buzzerSound) {
|
|||||||
|
|
||||||
function selectBuzzer(buzzerId) {
|
function selectBuzzer(buzzerId) {
|
||||||
if (buzzerId == "Mystery") {
|
if (buzzerId == "Mystery") {
|
||||||
buzzerId = buzzerOptions[Math.floor(Math.random()*8)];
|
buzzerId = buzzerOptions[Math.floor(Math.random()*(buzzerOptions.length-1))];
|
||||||
}
|
}
|
||||||
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();
|
||||||
return buzzerSound;
|
return buzzerSound;
|
||||||
|
|||||||
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 224 KiB After Width: | Height: | Size: 224 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 306 KiB After Width: | Height: | Size: 306 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 178 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
@@ -10,9 +10,6 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var socket = io();
|
var socket = io();
|
||||||
|
|
||||||
let buzzerOptions = setupBuzzerOptions();
|
|
||||||
let buzzerSound = new Audio(buzzerOptions[0]+".wav");
|
|
||||||
|
|
||||||
socket.on("userInfoToClient", (userInfo) => {
|
socket.on("userInfoToClient", (userInfo) => {
|
||||||
userInfoToClient(userInfo);
|
userInfoToClient(userInfo);
|
||||||
@@ -27,7 +24,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("buzzInfoToClient", (buzzInfo) => {
|
socket.on("buzzInfoToClient", (buzzInfo) => {
|
||||||
buzzInfoToClient(buzzInfo, buzzerSound);
|
buzzInfoToClient(buzzInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#plus0").click(function() {
|
$("#plus0").click(function() {
|
||||||
@@ -43,10 +40,6 @@
|
|||||||
$("#unregisterUsers").click(function() {
|
$("#unregisterUsers").click(function() {
|
||||||
socket.emit("unregisterUsers", 2);
|
socket.emit("unregisterUsers", 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#buzzerOptions").contents().mousedown(function() {
|
|
||||||
buzzerSound = selectBuzzer($(this).attr("id"));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
@@ -77,7 +70,5 @@
|
|||||||
<ul></ul>
|
<ul></ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="buzzerOptions">
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -11,22 +11,22 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var socket = io();
|
var socket = io();
|
||||||
|
|
||||||
|
|
||||||
let buzzInTime;//for ping check
|
let buzzInTime;//for ping check
|
||||||
let queryString = new URL(location.href);
|
let queryString = new URL(location.href);
|
||||||
let userName = queryString.searchParams.get("user");
|
let userName = queryString.searchParams.get("user");
|
||||||
$("#message").html("hi "+userName+" :]")
|
$("#message").html("hi "+userName+" :]")
|
||||||
let teamName = queryString.searchParams.get("team");
|
let teamName = queryString.searchParams.get("team");
|
||||||
|
|
||||||
|
let buzzerOptions = ["Kirbeep","MPYosh","MPDog","MPCat","EBWow","Ooh","MarioBoing","TheNumberEight","EBAttack1","SaturnHonk","PuffRest","AAHoldIt","EmergencyMeeting","Mystery"];
|
||||||
let buzzerOptions = setupBuzzerOptions();
|
buzzerOptions.forEach((buzzerId) => {
|
||||||
let buzzerSound = new Audio(buzzerOptions[0]+".wav");
|
$("#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;
|
||||||
|
|
||||||
socket.emit("registerUser", userName, teamName);
|
socket.emit("updateUserInfo", userName, teamName, "Kirbeep");//initial user registration
|
||||||
|
|
||||||
socket.on("userInfoToClient", (userInfo) => {
|
socket.on("userInfoToClient", (userInfo) => {
|
||||||
userInfoToClient(userInfo);
|
userInfoToClient(userInfo);
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("buzzInfoToClient", (buzzInfo) => {
|
socket.on("buzzInfoToClient", (buzzInfo) => {
|
||||||
buzzInfoToClient(buzzInfo, buzzerSound);
|
buzzInfoToClient(buzzInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("pingClient", (timeStamp) => {
|
socket.on("pingClient", (timeStamp) => {
|
||||||
@@ -78,7 +78,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$("#buzzerOptions").contents().mousedown(function() {
|
$("#buzzerOptions").contents().mousedown(function() {
|
||||||
buzzerSound = selectBuzzer($(this).attr("id"));
|
buzzerId = $(this).attr("id")
|
||||||
|
if (buzzerId == "Mystery") {
|
||||||
|
buzzerId = buzzerOptions[Math.floor(Math.random()*(buzzerOptions.length-1))];
|
||||||
|
}
|
||||||
|
socket.emit("updateUserInfo", userName, teamName, buzzerId);
|
||||||
|
buzzerSound = new Audio(buzzerId+".wav");
|
||||||
|
$("#buzzer").attr("src", buzzerId+".png" );
|
||||||
|
buzzerSound.play();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -90,7 +97,7 @@
|
|||||||
Progress:
|
Progress:
|
||||||
<p id="currentScore"></p>
|
<p id="currentScore"></p>
|
||||||
<br>
|
<br>
|
||||||
<img id="buzzer" alt="The buzzer" style="width: 200px">
|
<img id="buzzer" alt="The buzzer">
|
||||||
<br>
|
<br>
|
||||||
<p id="firstBuzz"></p>
|
<p id="firstBuzz"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ a, a:visited {
|
|||||||
left: 60px;
|
left: 60px;
|
||||||
border: dashed;
|
border: dashed;
|
||||||
width: 400px;
|
width: 400px;
|
||||||
min-height: 130px;
|
min-height: 170px;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,17 +47,18 @@ a, a:visited {
|
|||||||
left: 724px;
|
left: 724px;
|
||||||
border: dashed;
|
border: dashed;
|
||||||
width: 400px;
|
width: 400px;
|
||||||
min-height: 130px;
|
min-height: 170px;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
list-style-type: square;
|
list-style-type: none;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding-left: 30px;
|
padding-left: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#buzzer {
|
#buzzer {
|
||||||
|
width: 200px;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
}
|
}
|
||||||
@@ -86,6 +87,13 @@ ul {
|
|||||||
width: 14px;
|
width: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.userListBuzzerSelections {
|
||||||
|
width: 30px;
|
||||||
|
position: relative;
|
||||||
|
top: 5px;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
#userListPanel {
|
#userListPanel {
|
||||||
top: 80px;
|
top: 80px;
|
||||||
|
|||||||