2020-04-09 10:19:11 +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 10:19:11 +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>
|
2020-04-09 10:30:15 +00:00
|
|
|
<h1>{{room}}</h1>
|
2020-04-09 10:19:11 +00:00
|
|
|
</header>
|
|
|
|
|
|
|
|
<main>
|
2020-04-09 12:16:21 +00:00
|
|
|
<h2>Oh hi, {{name}} <img src="{{character}}"/></h2>
|
2020-04-09 10:30:15 +00:00
|
|
|
|
|
|
|
<button id="buzzer">
|
|
|
|
BUZZ
|
|
|
|
</button>
|
2020-04-09 10:19:11 +00:00
|
|
|
</main>
|
2020-04-09 11:04:28 +00:00
|
|
|
|
2020-04-09 16:37:47 +00:00
|
|
|
<div id="messageBox" class="hide">
|
2020-04-09 16:25:42 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2020-04-09 11:04:28 +00:00
|
|
|
<script>
|
2020-04-09 15:14:45 +00:00
|
|
|
let socket = new WebSocket(`wss://${window.location.hostname}/{{room}}`);
|
2020-04-09 11:04:28 +00:00
|
|
|
|
2020-04-09 11:28:30 +00:00
|
|
|
socket.onopen = function(e) {
|
|
|
|
socket.send(JSON.stringify({
|
|
|
|
type: "join",
|
|
|
|
data: {
|
|
|
|
participantId: '{{participantId}}',
|
|
|
|
participantName: '{{participantName}}',
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
};
|
2020-04-09 11:04:28 +00:00
|
|
|
|
2020-04-09 15:38:44 +00:00
|
|
|
socket.onmessage = function(event) {
|
|
|
|
let msg = JSON.parse(event.data);
|
2020-04-09 15:26:47 +00:00
|
|
|
if (msg.type === "buzz") {
|
2020-04-09 16:25:42 +00:00
|
|
|
showMessage(msg.msg);
|
2020-04-09 15:26:47 +00:00
|
|
|
}
|
2020-04-09 11:28:30 +00:00
|
|
|
};
|
|
|
|
|
2020-04-09 15:49:52 +00:00
|
|
|
document.getElementById('buzzer').addEventListener('touchstart', function() {
|
2020-04-09 17:01:46 +00:00
|
|
|
beep();
|
2020-04-09 11:40:21 +00:00
|
|
|
socket.send(JSON.stringify({
|
|
|
|
type: "buzz"
|
|
|
|
}));
|
2020-04-09 11:28:30 +00:00
|
|
|
});
|
2020-04-09 16:25:42 +00:00
|
|
|
|
2020-04-09 16:49:47 +00:00
|
|
|
document.getElementById('buzzer').addEventListener('mousedown', function() {
|
2020-04-09 17:01:46 +00:00
|
|
|
beep();
|
2020-04-09 16:49:47 +00:00
|
|
|
socket.send(JSON.stringify({
|
|
|
|
type: "buzz"
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
2020-04-09 16:37:47 +00:00
|
|
|
function showMessage(msg) {
|
2020-04-09 16:49:47 +00:00
|
|
|
document.getElementById('buzzer').disabled = true;
|
2020-04-09 16:25:42 +00:00
|
|
|
let mb = document.getElementById('messageBox');
|
|
|
|
mb.innerHTML = msg;
|
|
|
|
mb.classList.remove('hide');
|
|
|
|
setTimeout(() => {
|
2020-04-09 16:49:47 +00:00
|
|
|
document.getElementById('buzzer').disabled = false;
|
2020-04-09 16:25:42 +00:00
|
|
|
mb.classList.add('hide');
|
|
|
|
}, 5000)
|
|
|
|
}
|
2020-04-09 17:01:46 +00:00
|
|
|
|
|
|
|
function beep() {
|
|
|
|
new Audio("https://cdn.glitch.com/81aebabf-079d-4504-b844-d90d643962c4%2FGame-show-buzzer-sound-effect.mp3?v=1586451448374").play();
|
|
|
|
}
|
2020-04-09 11:04:28 +00:00
|
|
|
</script>
|
2020-04-09 10:19:11 +00:00
|
|
|
</body>
|
|
|
|
</html>
|