|
2 | 2 | ROOM_CODE="${REQUEST_PATH##*/}"
|
3 | 3 |
|
4 | 4 | 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 | + }); |
5 | 27 |
|
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> |
34 | 33 | EOF
|
0 commit comments