6c1a308a03
./views/room.handlebars:530995/80 ./views/audience.handlebars:530995/371 ./server.js:530995/328 ./room.js:530995/345 ./public/style.css:530995/79
54 lines
1.7 KiB
Handlebars
54 lines
1.7 KiB
Handlebars
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Buzzers</title>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="description" content="A cool thing made with Glitch">
|
|
<link id="favicon" rel="icon" href="https://glitch.com/edit/favicon-app.ico" type="image/x-icon">
|
|
<link rel="stylesheet" href="/style.css">
|
|
<script src="/script.js" defer></script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>{{room}}</h1>
|
|
</header>
|
|
|
|
<main>
|
|
<h2>Participants</h2>
|
|
|
|
<div>
|
|
{{#each participants}}
|
|
<figure class="participant" id="p-{{this.participantId}}">
|
|
<img src="{{this.character}}" />
|
|
<figcaption>{{this.participantName}}</figcaption>
|
|
</figure>
|
|
{{/each}}
|
|
</div>
|
|
</main>
|
|
|
|
|
|
<script>
|
|
let socket = new WebSocket(`wss://${window.location.hostname}/{{room}}/audience`);
|
|
|
|
socket.onmessage = function(event) {
|
|
let msg = JSON.parse(event.data);
|
|
if (msg.type === "buzz") {
|
|
beep();
|
|
let buzzed = document.getElementById(`p-${msg.participant.participantId}`);
|
|
buzzed.classList.add('buzzed');
|
|
setTimeout(() => buzzed.classList.remove('buzzed'), 5000)
|
|
} else if (msg.type === "new_participant") {
|
|
window.location = window.location;
|
|
}
|
|
};
|
|
|
|
function beep() {
|
|
window.navigator.vibrate(500);
|
|
new Audio("https://cdn.glitch.com/81aebabf-079d-4504-b844-d90d643962c4%2FGame-show-buzzer-sound-effect.mp3?v=1586451448374").play();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|