diff --git a/public/buzzer.html b/public/buzzer.html
index 150fca2..952a3e8 100644
--- a/public/buzzer.html
+++ b/public/buzzer.html
@@ -94,6 +94,17 @@
>
add tokens
+
diff --git a/public/buzzer.js b/public/buzzer.js
index 4fb3381..e3f2ab1 100644
--- a/public/buzzer.js
+++ b/public/buzzer.js
@@ -210,24 +210,36 @@ function enable_admin_ui() {
{ target: q("#points-admin") },
)
+ const client_for_target = (target) => {
+ let node = target
+ while (!node.dataset.cid && node.parentElement) {
+ node = node.parentElement
+ }
+ return find_client(node.dataset.cid)
+ }
+
on(
"click",
({ target }) => {
- let node = target
- while (!node.dataset.cid && node.parentElement) {
- node = node.parentElement
- }
- if (!target.dataset.onclick) {
- return
- }
- const client = find_client(node.dataset.cid)
- if (!client) {
+ const client = client_for_target(target)
+ if (!client || !target.dataset.onclick) {
return
}
eval(`;{${target.dataset.onclick}};`)
},
{ target: q("#info .players") },
)
+ on(
+ "change",
+ ({ target }) => {
+ const client = client_for_target(target)
+ if (!client || !target.dataset.onchange) {
+ return
+ }
+ eval(`;{${target.dataset.onchange}};`)
+ },
+ { target: q("#info .players") },
+ )
}
function set_name(name) {
diff --git a/public/monitor.js b/public/monitor.js
index 5c36589..b753665 100644
--- a/public/monitor.js
+++ b/public/monitor.js
@@ -103,12 +103,12 @@ const redraw_clients = debounce(_redraw_clients, 200)
let highlighted = false
function highlight(client_id, until_ns) {
if (highlighted) {
- return
+ return false
}
const timeout_ms = (until_ns - conn.servertime_now_ns()) / ms_ns
if (timeout_ms <= 10) {
console.warn("That highlight timeout was ridiculously low:", client_id, timeout_ms)
- return
+ return false
}
for (const li of player_list.children) {
if (li.dataset.cid === client_id) {
@@ -118,7 +118,7 @@ function highlight(client_id, until_ns) {
highlighted = false
li.classList.remove("buzzing")
}, timeout_ms)
- return
+ return true
}
}
}
@@ -126,7 +126,8 @@ function highlight(client_id, until_ns) {
function setup_ws() {
let clients = {},
me,
- monitored = []
+ monitored = [],
+ sounds = {}
const sid = session_id()
const overlay = q('#text-overlay')
conn = new Connection()
@@ -140,7 +141,10 @@ function setup_ws() {
const { time: buzztime_ns, client: client_id } = value
const duration_ns = 12 * s_ns
const until_ns = buzztime_ns + duration_ns
- highlight(client_id, until_ns)
+ const is_new_buzz = highlight(client_id, until_ns)
+ if (is_new_buzz && sounds[client_id]) {
+ sounds[client_id].play()
+ }
})
conn.on("clients", ({ value }) => {
clients = Object.fromEntries(value.clients.map((c) => [c.id, c]))
@@ -161,6 +165,9 @@ function setup_ws() {
} else {
overlay.classList.add('hidden')
}
+ } else if (action === 'sound' && args.sound) {
+ const { client_id, sound } = args
+ sounds[client_id] = new Audio(`sounds/${sound}.mp3`)
}
})
conn.connect(session_url(sid))
diff --git a/public/sounds/bark.mp3 b/public/sounds/bark.mp3
new file mode 100644
index 0000000..6fd8492
Binary files /dev/null and b/public/sounds/bark.mp3 differ
diff --git a/public/sounds/chirp.mp3 b/public/sounds/chirp.mp3
new file mode 100644
index 0000000..c9d547c
Binary files /dev/null and b/public/sounds/chirp.mp3 differ
diff --git a/public/sounds/meow.mp3 b/public/sounds/meow.mp3
new file mode 100644
index 0000000..a0e3361
Binary files /dev/null and b/public/sounds/meow.mp3 differ
diff --git a/public/sounds/moo.mp3 b/public/sounds/moo.mp3
new file mode 100644
index 0000000..609d173
Binary files /dev/null and b/public/sounds/moo.mp3 differ
diff --git a/public/sounds/quack.mp3 b/public/sounds/quack.mp3
new file mode 100644
index 0000000..e499d7b
Binary files /dev/null and b/public/sounds/quack.mp3 differ
diff --git a/public/sounds/ribbit.mp3 b/public/sounds/ribbit.mp3
new file mode 100644
index 0000000..d1f0d89
Binary files /dev/null and b/public/sounds/ribbit.mp3 differ