🎙🏛 Checkpoint
./characters.json:530995/537876 ./views/index.handlebars:530995/61 ./views/audience.handlebars:530995/1 ./views/join.handlebars:530995/3 ./views/room.handlebars:530995/529 ./room.js:530995/100
This commit is contained in:
parent
a3d92bc8f9
commit
932d0e41a7
File diff suppressed because one or more lines are too long
3
room.js
3
room.js
@ -54,7 +54,8 @@ function buzz(roomId, participant) {
|
||||
if (p.ws && p.participantId !== participant.participantId) {
|
||||
p.ws.send(JSON.stringify({
|
||||
type: "buzz",
|
||||
participant: participant.participantName
|
||||
participant: participant.participantName,
|
||||
msg: `<img src="${participant.character}"> ${participant.participantName} buzzed!`
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Buzzer</title>
|
||||
<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">
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Buzzer</title>
|
||||
<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">
|
||||
@ -16,7 +16,11 @@
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<h2>Oh hi,</h2>
|
||||
<h2>Oh hi!</h2>
|
||||
|
||||
<p>
|
||||
Create or join a room
|
||||
</p>
|
||||
|
||||
<form>
|
||||
<label>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Buzzer</title>
|
||||
<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">
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Buzzer</title>
|
||||
<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">
|
||||
@ -23,6 +23,10 @@
|
||||
</button>
|
||||
</main>
|
||||
|
||||
<div id="messageBox">
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let socket = new WebSocket(`wss://${window.location.hostname}/{{room}}`);
|
||||
|
||||
@ -39,19 +43,24 @@
|
||||
socket.onmessage = function(event) {
|
||||
let msg = JSON.parse(event.data);
|
||||
if (msg.type === "buzz") {
|
||||
alert(`${msg.participant} buzzed`);
|
||||
showMessage(msg.msg);
|
||||
}
|
||||
};
|
||||
|
||||
socket.onerror = function(error) {
|
||||
alert(`[error] ${error.message}`);
|
||||
};
|
||||
|
||||
document.getElementById('buzzer').addEventListener('touchstart', function() {
|
||||
socket.send(JSON.stringify({
|
||||
type: "buzz"
|
||||
}));
|
||||
});
|
||||
|
||||
showMessage(msg) {
|
||||
let mb = document.getElementById('messageBox');
|
||||
mb.innerHTML = msg;
|
||||
mb.classList.remove('hide');
|
||||
setTimeout(() => {
|
||||
mb.classList.add('hide');
|
||||
}, 5000)
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user