updates style & introduces results overlay
All checks were successful
CI / deploy (push) Successful in 6m11s
CI / deploy (pull_request) Successful in 5m57s

This commit is contained in:
Arindy
2025-02-09 22:51:31 +01:00
parent ca538e7980
commit 9d72d51013
7 changed files with 136 additions and 68 deletions

View File

@@ -36,8 +36,11 @@
<body>
<div id="dice-box"></div>
<script type="module">
function url() {
return window.location.protocol + '//' + window.location.hostname + (window.location.port?.length > 0 ? ':' + window.location.port : '');
}
import DiceBox from "/vendor/dice-box/dice-box.es.js";
const evtSource = new EventSource(window.location.protocol + "//" + window.location.hostname + ':' + window.location.port + "/dice/{diceid??}/stream");
const evtSource = new EventSource(url() + "/dice/{diceid??}/stream");
const diceBox = new DiceBox("#dice-box", {
assetPath: "/vendor/assets/",
@@ -62,9 +65,8 @@
evtSource.addEventListener("message", function (event) {
let data = JSON.parse(event.data);
diceBox.onRollComplete = (rollResult) => {
console.log(rollResult)
let httpRequest = new XMLHttpRequest();
httpRequest.open('POST',window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/dice/' + data.room + '/results')
httpRequest.open('POST',url() + '/dice/' + data.room + '/results')
httpRequest.setRequestHeader('Content-Type', 'application/json')
httpRequest.send(JSON.stringify({
name: data.name,