Skip to content

Commit 8e59aa6

Browse files
committed
jeopardy buzzer fix
1 parent 7151f8c commit 8e59aa6

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

examples/jeopardy-buzzer/pages/host/[room].sh

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,32 @@
22
ROOM_CODE="${REQUEST_PATH##*/}"
33

44
htmx_page << EOF
5+
<div hx-sse="connect:/sse/host/${ROOM_CODE}">
6+
<div hx-trigger="sse:kick, sse:leave, sse:join, sse:unlock, sse:buzz, load" hx-get="/room/players/${ROOM_CODE}" class="players"></div>
7+
<form>
8+
<input type="hidden" name="room_code" value="${ROOM_CODE}" />
9+
<div class="button-container">
10+
<button hx-post="/reset" hx-sse="swap:buzz">Reset</button>
11+
</div>
12+
</form>
13+
</div>
14+
<form class="footer-link copy">
15+
<input type="text" value="http://${HTTP_HEADERS["host"]}/player/${ROOM_CODE}">
16+
<button type="button">Copy</button>
17+
</form>
18+
<script type="text/javascript">
19+
(function() {
20+
var copyButton = document.querySelector('.copy button');
21+
var copyInput = document.querySelector('.copy input');
22+
copyButton.addEventListener('click', function(e) {
23+
e.preventDefault();
24+
var text = copyInput.select();
25+
document.execCommand('copy');
26+
});
527
6-
<div hx-sse="connect:/sse/host/${ROOM_CODE}">
7-
<div hx-trigger="sse:kick, sse:leave, sse:join, sse:unlock, sse:buzz, load" hx-get="/room/players/${ROOM_CODE}" class="players"></div>
8-
<form>
9-
<input type="hidden" name="room_code" value="${ROOM_CODE}" />
10-
<div class="button-container">
11-
<button hx-post="/reset" hx-sse="swap:buzz">Reset</button>
12-
</div>
13-
</form>
14-
</div>
15-
<form class="footer-link copy">
16-
<input type="text" value="http://${HTTP_HEADERS["Host"]}/player/${ROOM_CODE}">
17-
<button type="button">Copy</button>
18-
</form>
19-
<script type="text/javascript">
20-
(function() {
21-
var copyButton = document.querySelector('.copy button');
22-
var copyInput = document.querySelector('.copy input');
23-
copyButton.addEventListener('click', function(e) {
24-
e.preventDefault();
25-
var text = copyInput.select();
26-
document.execCommand('copy');
27-
});
28-
29-
copyInput.addEventListener('click', function() {
30-
this.select();
31-
});
32-
})();
33-
</script>
28+
copyInput.addEventListener('click', function() {
29+
this.select();
30+
});
31+
})();
32+
</script>
3433
EOF

0 commit comments

Comments
 (0)