2020-04-09 12:16:21 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
2020-04-09 16:25:42 +00:00
|
|
|
<title>Buzzers</title>
|
2020-04-09 12:16:21 +00:00
|
|
|
<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>
|
|
|
|
|
2020-04-09 17:13:46 +00:00
|
|
|
<div>
|
|
|
|
{{#each participants}}
|
|
|
|
<figure class="participant" id="p-{{this.participantId}}">
|
|
|
|
<img src="{{this.character}}" />
|
|
|
|
<figcaption>{{this.participantName}}</figcaption>
|
|
|
|
</figure>
|
|
|
|
{{/each}}
|
|
|
|
</div>
|
2020-04-09 12:16:21 +00:00
|
|
|
</main>
|
2020-04-09 15:38:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
<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") {
|
|
|
|
let buzzed = document.getElementById(`p-${msg.participant.participantId}`);
|
|
|
|
buzzed.classList.add('buzzed');
|
|
|
|
setTimeout(() => buzzed.classList.remove('buzzed'), 5000)
|
2020-04-09 16:01:44 +00:00
|
|
|
} else if (msg.type === "new_participant") {
|
|
|
|
window.location = window.location;
|
2020-04-09 15:38:44 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
socket.onerror = function(error) {
|
|
|
|
alert(`[error] ${error.message}`);
|
|
|
|
};
|
|
|
|
</script>
|
2020-04-09 12:16:21 +00:00
|
|
|
</body>
|
|
|
|
</html>
|