init
This commit is contained in:
commit
8631733274
14 changed files with 1719 additions and 0 deletions
162
dice/index.html
Normal file
162
dice/index.html
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Dice Roller</title>
|
||||
<meta property="og:title" content="Dice" />
|
||||
<meta property="og:image" content="http://shots.wayl.one/shot/?url=https://dice.wayl.one/&height=630&width=1200&scaled_width=1200&scaled_height=630&selectors=" />
|
||||
<meta property="og:description" content="Dice rolls, it just rolls dice, thats it." />
|
||||
<meta property="og:url" content="https://dice.wayl.one/" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:site_name" content="Dice" />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:title" content="Dice" />
|
||||
<meta name="twitter:description" content="A large display dice, it just shows the time." />
|
||||
<meta name="twitter:image" content="http://shots.wayl.one/shot/?url=https://dice.wayl.one/&height=630&width=1200&scaled_width=1200&scaled_height=640&selectors=" />
|
||||
<style>
|
||||
body {
|
||||
background: black;
|
||||
color: lime;
|
||||
font-family: sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
.container {
|
||||
text-align: center;
|
||||
font-size: 4rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
#rolls {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 6rem;
|
||||
margin-top: 1rem;
|
||||
color: lime;
|
||||
}
|
||||
#rolls li {
|
||||
border: 4px solid #005500;
|
||||
background: #00ff0024;
|
||||
box-shadow: 0 0 3rem 1rem #00ff0017;
|
||||
aspect-ratio: 1;
|
||||
border-radius: .5rem;
|
||||
height: 1.5em;
|
||||
width: 1.5em;
|
||||
line-height: 1.5em;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
padding: 0.5rem;
|
||||
margin: 2rem;
|
||||
}
|
||||
.total {
|
||||
margin-top: 0.5rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
/* Modal styles */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.75);
|
||||
display: none;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
.modal {
|
||||
box-shadow: 0 0 3rem 1rem #00ff0017;
|
||||
background: black;
|
||||
border: 2px solid lime;
|
||||
border-radius: 0.5rem;
|
||||
padding: 2rem;
|
||||
max-width: 90%;
|
||||
color: lime;
|
||||
text-align: left;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
.modal h2 {
|
||||
margin-top: 0;
|
||||
color: #008e00;
|
||||
}
|
||||
.modal ul {
|
||||
color: #00ae00;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div id="total" class="total"></div>
|
||||
<div id="detail" class="rolls"></div>
|
||||
<ul id="rolls"></ul>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div id="modal-overlay" class="modal-overlay">
|
||||
<div class="modal">
|
||||
<h2>Help</h2>
|
||||
<p>
|
||||
You can control the roll by passing query parameters in the URL:
|
||||
</p>
|
||||
<ul>
|
||||
<li><code>num</code> – number of dice (default <strong>1</strong>)</li>
|
||||
<li><code>sides</code> – sides per die (default <strong>6</strong>)</li>
|
||||
</ul>
|
||||
<p>Examples:</p>
|
||||
<ul>
|
||||
<li><code>?num=3&sides=20</code> — roll 3 twenty-sided dice</li>
|
||||
<li><code>?num=5&sides=8</code> — roll 5 eight-sided dice</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Parse query params
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const num = Math.max(1, parseInt(params.get('num')) || 1);
|
||||
const sides = Math.max(2, parseInt(params.get('sides')) || 6);
|
||||
|
||||
// Roll the dice
|
||||
const rolls = [];
|
||||
for (let i = 0; i < num; i++) {
|
||||
rolls.push(Math.floor(Math.random() * sides) + 1);
|
||||
}
|
||||
const sum = rolls.reduce((a, b) => a + b, 0);
|
||||
|
||||
// Display
|
||||
document.getElementById('total').textContent = `${sum}`;
|
||||
const rolls_ul = document.getElementById('rolls')
|
||||
rolls.forEach((roll, idx) => {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = `${roll}`;
|
||||
rolls_ul.appendChild(li);
|
||||
});
|
||||
|
||||
// ---- Modal logic ----
|
||||
const overlay = document.getElementById('modal-overlay');
|
||||
|
||||
function toggleModal() {
|
||||
if (overlay.style.display === 'none') {
|
||||
overlay.style.display = 'flex';
|
||||
} else {
|
||||
overlay.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
overlay.addEventListener('click', e => {
|
||||
if (e.target === overlay) hideModal();
|
||||
});
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key === '?') {
|
||||
toggleModal();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue