93b4bbe4ed
./public/style.css:530995/411 ./views/room.handlebars:530995/42 ./server.js:530995/182 ./views/index.handlebars:530995/1364
55 lines
1.4 KiB
Handlebars
55 lines
1.4 KiB
Handlebars
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Buzzer</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>Oh hi, {{name}}</h2>
|
|
|
|
<button id="buzzer">
|
|
BUZZ
|
|
</button>
|
|
</main>
|
|
|
|
<script>
|
|
let socket = new WebSocket(`wss://${window.location.hostname}`);
|
|
|
|
socket.onopen = function(e) {
|
|
socket.send(JSON.stringify({
|
|
type: "join",
|
|
data: {
|
|
participantId: '{{participantId}}',
|
|
participantName: '{{participantName}}',
|
|
}
|
|
}));
|
|
};
|
|
|
|
socket.onmessage = function(event) {
|
|
console.log(event);
|
|
};
|
|
|
|
socket.onerror = function(error) {
|
|
alert(`[error] ${error.message}`);
|
|
};
|
|
|
|
document.getElementById('buzzer').addEventListener('click', function() {
|
|
socket.send(JSON.stringify({
|
|
type: "buzz"
|
|
}));
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|