updates style & introduces results overlay
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user