add admin ability to double card values
This commit is contained in:
parent
a4b0297c3f
commit
81ee2200fb
5 changed files with 22 additions and 1 deletions
|
|
@ -59,6 +59,10 @@
|
||||||
></textarea>
|
></textarea>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
>double:
|
||||||
|
<button data-onclick="conn.send('control', {action: 'double'})">double</button>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
|
import { qs } from "./shared.js"
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
let highlighted
|
let highlighted
|
||||||
document.addEventListener("click", (event) => {
|
document.addEventListener("click", (event) => {
|
||||||
|
|
@ -18,6 +20,18 @@ function setup() {
|
||||||
highlighted = card
|
highlighted = card
|
||||||
card.classList.add("highlight")
|
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()
|
setup()
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<div id="players">
|
<div id="players">
|
||||||
<!-- players (see template#player) will be inserted here -->
|
<!-- players (see template#player) will be inserted here -->
|
||||||
</div>
|
</div>
|
||||||
<iframe src="matrix.html"></iframe>
|
<iframe id="board" src="matrix.html"></iframe>
|
||||||
<div id="text-overlay" class="hidden"></div>
|
<div id="text-overlay" class="hidden"></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,8 @@ function setup_ws() {
|
||||||
} else if (action === "sound" && args.sound) {
|
} else if (action === "sound" && args.sound) {
|
||||||
const { client_id, sound } = args
|
const { client_id, sound } = args
|
||||||
sounds[client_id] = new Audio(`sounds/${sound}.mp3`)
|
sounds[client_id] = new Audio(`sounds/${sound}.mp3`)
|
||||||
|
} else if (action === "double") {
|
||||||
|
q("#board").contentWindow.postMessage("double", "*")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ export function isEmpty(x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const q = (selector, root = document) => root.querySelector(selector)
|
export const q = (selector, root = document) => root.querySelector(selector)
|
||||||
|
export const qs = (selector, root = document) => root.querySelectorAll(selector)
|
||||||
|
|
||||||
const _evlisteners = {}
|
const _evlisteners = {}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue