220 lines
9.6 KiB
HTML
220 lines
9.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Dice-Tower</title>
|
|
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
<script src="/vendor/color-picker.js"></script>
|
|
<style>
|
|
.w3-theme-l6 { color:#000 !important; background-color:#999999 !important}
|
|
.w3-theme-l4 { color:#fff !important; background-color:#666666 !important}
|
|
.w3-theme-l1 { color:#fff !important; background-color:#333333 !important}
|
|
.collapsible {
|
|
background-color: #333333;
|
|
color: black;
|
|
cursor: pointer;
|
|
margin-top: 10px;
|
|
padding: 18px;
|
|
width: 100%;
|
|
border: none;
|
|
text-align: left;
|
|
outline: none;
|
|
font-size: 15px;
|
|
}
|
|
|
|
.content {
|
|
padding: 0 18px;
|
|
display: none;
|
|
overflow: hidden;
|
|
background-color: #999999;
|
|
color: #000
|
|
}
|
|
|
|
button {
|
|
padding: 10px;
|
|
}
|
|
input {
|
|
margin: 10px;
|
|
}
|
|
|
|
/* The switch - the box around the slider */
|
|
.switch {
|
|
position: relative;
|
|
display: inline-block;
|
|
width: 60px;
|
|
height: 25px;
|
|
}
|
|
|
|
/* Hide default HTML checkbox */
|
|
.switch input {
|
|
opacity: 0;
|
|
width: 0;
|
|
height: 0;
|
|
}
|
|
|
|
/* The slider */
|
|
.slider {
|
|
position: absolute;
|
|
cursor: pointer;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: #ccc;
|
|
-webkit-transition: .4s;
|
|
transition: .4s;
|
|
}
|
|
|
|
.slider:before {
|
|
position: absolute;
|
|
content: "";
|
|
height: 18px;
|
|
width: 26px;
|
|
left: 4px;
|
|
bottom: 4px;
|
|
background-color: white;
|
|
-webkit-transition: .4s;
|
|
transition: .4s;
|
|
}
|
|
|
|
input:checked + .slider {
|
|
background-color: #333333;
|
|
}
|
|
|
|
input:focus + .slider {
|
|
box-shadow: 0 0 1px #333333;
|
|
}
|
|
|
|
input:checked + .slider:before {
|
|
-webkit-transform: translateX(26px);
|
|
-ms-transform: translateX(26px);
|
|
transform: translateX(26px);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="w3-theme-l1">
|
|
<div class="w3-container w3-content" style="height: 100vh">
|
|
<h1>Dice-Tower</h1>
|
|
<p>Welcome to Dice-Tower</p>
|
|
<div class="w3-panel w3-theme-l4 w3-card w3-display-container" style="padding: 25px">
|
|
<label for="name" id="nameLabel">Name </label><input type="text" id="name" style="width: 75%" required onkeyup="start(event)"/><br/>
|
|
<label for="room" id="roomLabel">Room </label><input type="text" id="room" style="width: 75%" required onkeyup="start(event)"/><br/>
|
|
</div>
|
|
<div id="dice-tower" hidden class="w3-panel w3-theme-l4 w3-card w3-display-container" style="padding: 25px">
|
|
<button type="button" class="collapsible" style="color: white; font-weight: bold">Overlay URLs</button>
|
|
<div class="content">
|
|
<label for="overlayId">Dice-Overlay (Only open once) </label><input type="text" readonly id="overlayId" style="width: 70%"/><br/>
|
|
<label for="resultsId">All-Results-Overlay </label><input type="text" readonly id="resultsId" style="width: 75%"/><br/>
|
|
<label for="myResultsId">My-Results-Overlay </label><input type="text" readonly id="myResultsId" style="width: 75%"/><br/>
|
|
</div>
|
|
<button type="button" class="collapsible" style="color: white; font-weight: bold">Customize Dice</button>
|
|
<div class="content">
|
|
<label for="theme">Theme </label>
|
|
<select name="theme" id="theme" style="margin: 25px">
|
|
<option value="default">Default</option>
|
|
<option value="blueGreenMetal">Blue-Green Metal</option>
|
|
<option value="diceOfRolling">Dice of Rolling</option>
|
|
<option value="gemstone">Gemstone</option>
|
|
<option value="gemstoneMarble">Marble Gemstone</option>
|
|
<option value="rock">Rock</option>
|
|
<option value="rust">Rust</option>
|
|
<option value="smooth">Smooth</option>
|
|
<option value="wooden">Wooden</option>
|
|
</select>
|
|
<br/>
|
|
<color-picker value="#cd72fe" id="themeColor"></color-picker><br/>
|
|
</div><br/>
|
|
<p>Example Commands: "1d6", "2d8 1d100", "1d4 and 1d6", "2d20 & 1d2, "5d6+10"</p>
|
|
<label for="command">Command </label><input type="text" id="command" onkeyup="roll(event)"/>
|
|
<button hidden id="roll" onclick="roll()">Roll</button><br/><br/>
|
|
<label for="resultSwitch">Show all results </label>
|
|
<label class="switch">
|
|
<input type="checkbox" id="resultSwitch">
|
|
<span class="slider"></span>
|
|
</label>
|
|
</div>
|
|
|
|
<button id="start" onclick="start()">Start</button>
|
|
|
|
<div id="results" hidden class="w3-panel w3-theme-l6 w3-card w3-display-container" style="padding: 25px; overflow: hidden; height: 50vh;">
|
|
<h2>Results</h2>
|
|
<iframe id="resultFrame" title="results" style="width: 100%; height: 85%; overflow: hidden; border: 0" onload="this.height=this.contentWindow.document.body.scrollHeight;" ></iframe>
|
|
</div>
|
|
|
|
</div>
|
|
<script>
|
|
function url() {
|
|
return window.location.protocol + '//' + window.location.hostname + (window.location.port?.length > 0 ? ':' + window.location.port : '');
|
|
}
|
|
function start(event) {
|
|
if((!event || event.keyCode === 13) && document.getElementById('name').value.length > 0 && document.getElementById('room').value.length > 0) {
|
|
document.getElementById('overlayId').value = url() + '/overlay/' + document.getElementById('room').value + ':' + localStorage.getItem('userId') + '?scale=7';
|
|
document.getElementById('resultsId').value = url() + '/overlay/' + document.getElementById('room').value + '/results';
|
|
document.getElementById('myResultsId').value = document.getElementById('resultsId').value + '?name=' + encodeURIComponent(document.getElementById('name').value) + '&user=' + localStorage.getItem('userId');
|
|
document.getElementById('resultFrame').src = document.getElementById('myResultsId').value;
|
|
document.getElementById('roll').hidden = false;
|
|
document.getElementById('start').hidden = true;
|
|
document.getElementById('dice-tower').hidden = false;
|
|
document.getElementById('name').hidden = true;
|
|
document.getElementById('room').hidden = true;
|
|
document.getElementById('results').hidden = false;
|
|
document.getElementById('nameLabel').innerHTML = '<strong style="font-size:x-large;">' + document.getElementById('name').value + '</strong>';
|
|
document.getElementById('roomLabel').innerHTML = '<strong style="font-size:large;">' + document.getElementById('room').value + '</strong>';
|
|
document.title = document.getElementById('name').value + ' - Dice-Tower';
|
|
|
|
if (localStorage.getItem(document.getElementById('name').value + "-theme")) {
|
|
document.getElementById('theme').value = localStorage.getItem(document.getElementById('name').value + "-theme")
|
|
}
|
|
if (localStorage.getItem(document.getElementById('name').value + "-themeColor")) {
|
|
document.getElementById('themeColor').setColor(localStorage.getItem(document.getElementById('name').value + "-themeColor"));
|
|
}
|
|
}
|
|
}
|
|
|
|
function roll(event) {
|
|
if((!event || event.keyCode === 13) && document.getElementById('command').value?.length > 0) {
|
|
let httpRequest = new XMLHttpRequest();
|
|
httpRequest.open('POST', url() + '/dice/' + document.getElementById('room').value + ':' + localStorage.getItem(`userId`))
|
|
httpRequest.setRequestHeader('Content-Type', 'application/json')
|
|
httpRequest.send(JSON.stringify({
|
|
name: document.getElementById('name').value,
|
|
command: document.getElementById('command').value,
|
|
themeColor: document.getElementById('themeColor').value,
|
|
theme: document.getElementById('theme').value
|
|
} ))
|
|
}
|
|
}
|
|
|
|
let coll = document.getElementsByClassName("collapsible");
|
|
|
|
for (let i = 0; i < coll.length; i++) {
|
|
coll[i].addEventListener("click", function () {
|
|
localStorage.setItem(document.getElementById('name').value + "-theme", document.getElementById('theme').value)
|
|
localStorage.setItem(document.getElementById('name').value + "-themeColor", document.getElementById('themeColor').value)
|
|
const content = this.nextElementSibling;
|
|
if (content.style.display === "block") {
|
|
content.style.display = "none";
|
|
} else {
|
|
content.style.display = "block";
|
|
}
|
|
});
|
|
}
|
|
|
|
document.getElementById('resultSwitch').addEventListener('change', function() {
|
|
if (!this.checked) {
|
|
document.getElementById('resultFrame').src = document.getElementById('myResultsId').value;
|
|
} else {
|
|
document.getElementById('resultFrame').src = document.getElementById('resultsId').value;
|
|
}
|
|
})
|
|
|
|
document.addEventListener("DOMContentLoaded", async() => {
|
|
if (!localStorage.getItem("userId")) {
|
|
localStorage.setItem("userId", self.crypto.randomUUID());
|
|
}
|
|
})
|
|
</script>
|
|
</body>
|
|
</html>
|