diff --git a/public/buzzer.html b/public/buzzer.html index 43afeeb..370941e 100644 --- a/public/buzzer.html +++ b/public/buzzer.html @@ -59,6 +59,10 @@ > +
+
diff --git a/public/matrix.js b/public/matrix.js index b4a3e90..91e7099 100644 --- a/public/matrix.js +++ b/public/matrix.js @@ -1,5 +1,7 @@ "use strict" +import { qs } from "./shared.js" + function setup() { let highlighted document.addEventListener("click", (event) => { @@ -18,6 +20,18 @@ function setup() { highlighted = card card.classList.add("highlight") }) + + window.addEventListener("message", ({ data }) => { + if (data !== "double") { + return + } + for (let card of qs(".card")) { + if (card.classList.contains("cat")) { + continue + } + card.textContent = parseInt(card.textContent) * 2 + } + }) } setup() diff --git a/public/monitor.html b/public/monitor.html index 0c10494..d526c78 100644 --- a/public/monitor.html +++ b/public/monitor.html @@ -6,7 +6,7 @@
- + diff --git a/public/monitor.js b/public/monitor.js index 12db086..186ef39 100644 --- a/public/monitor.js +++ b/public/monitor.js @@ -174,6 +174,8 @@ function setup_ws() { } else if (action === "sound" && args.sound) { const { client_id, sound } = args sounds[client_id] = new Audio(`sounds/${sound}.mp3`) + } else if (action === "double") { + q("#board").contentWindow.postMessage("double", "*") } }, ) diff --git a/public/shared.js b/public/shared.js index 882dcc5..cc9cbd7 100644 --- a/public/shared.js +++ b/public/shared.js @@ -15,6 +15,7 @@ export function isEmpty(x) { } export const q = (selector, root = document) => root.querySelector(selector) +export const qs = (selector, root = document) => root.querySelectorAll(selector) const _evlisteners = {}