cleans up code
This commit is contained in:
@@ -4,35 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Dice-Tower - Overlay</title>
|
||||
<link rel="icon" type="image/png" href="/favicon.png">
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
perspective: 1000px;
|
||||
}
|
||||
|
||||
#dice-box {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: transparent;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#dice-box canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
<link rel="stylesheet" href="/overlay/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="dice-box"></div>
|
||||
@@ -40,7 +12,9 @@
|
||||
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(url() + "/dice/{diceid??}/stream");
|
||||
const diceBox = new DiceBox("#dice-box", {
|
||||
assetPath: "/vendor/assets/",
|
||||
@@ -59,7 +33,7 @@
|
||||
scale: {scale}
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async() => {
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
await diceBox.init()
|
||||
|
||||
let timeout = 0;
|
||||
@@ -68,20 +42,27 @@
|
||||
let data = JSON.parse(event.data);
|
||||
diceBox.onRollComplete = (rollResult) => {
|
||||
let httpRequest = new XMLHttpRequest();
|
||||
httpRequest.open('POST',url() + '/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,
|
||||
user: data.user,
|
||||
themeColor: data.themeColor,
|
||||
results: rollResult,
|
||||
} ))
|
||||
if ({clearAfter} > 0) {
|
||||
timeout = setTimeout(() => diceBox.clear(), {clearAfter} * 1000)
|
||||
}))
|
||||
if ({clearAfter} >
|
||||
0
|
||||
)
|
||||
{
|
||||
timeout = setTimeout(() => diceBox.clear(), {clearAfter} * 1000
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
diceBox.roll(data.roll, { theme: data.theme?.length > 0 ? data.theme : 'default', themeColor: data.themeColor.length > 0 ? data.themeColor : '#4545FF' });
|
||||
diceBox.roll(data.roll, {
|
||||
theme: data.theme?.length > 0 ? data.theme : 'default',
|
||||
themeColor: data.themeColor.length > 0 ? data.themeColor : '#4545FF'
|
||||
});
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user