
 Je tento Random generator number od AI ok?
				Je tento Random generator number od AI ok?			
							
					Ahoj, kouknul by mi někdo pls na tento "program" jestli ten RNG funguje tak aby to bylo co nejvic nahodny a nedelalo to nejake kraviny, je to od AI. Díky moc
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Random 1–100 (auto + klik)</title>
<style>
:root {
--bg: #0f172a;
--card: #111827;
--text: #e5e7eb;
--accent: #60a5fa;
}
html, body {
height: 100%;
margin: 0;
background: #0f172a;
color: var(--text);
font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
}
.wrap {
min-height: 100%;
display: grid;
place-items: center;
user-select: none;
cursor: pointer;
}
.card {
width: min(500px, 92vw);
background: var(--card);
border: 1px solid rgba(255,255,255,0.08);
border-radius: 12px;
padding: 24px;
box-shadow: 0 4px 20px rgba(0,0,0,0.2);
text-align: center;
}
h1 {
margin: 0 0 8px;
font-weight: 700;
font-size: 20px;
color: #cbd5e1;
}
.number {
font-weight: 800;
font-size: clamp(60px, 12vw, 140px);
line-height: 1;
margin: 10px 0;
color: #ffffff;
transition: transform 150ms ease;
}
.hint {
opacity: .7;
font-size: 14px;
color: #9ca3af;
margin-bottom: 8px;
}
.pulse {
transform: scale(1.05);
}
.badge {
display: inline-block;
margin-left: 6px;
padding: 2px 8px;
border-radius: 999px;
font-size: 12px;
color: #0b1220;
background: var(--accent);
}
.controls {
margin-top: 10px;
display: flex;
gap: 8px;
justify-content: center;
flex-wrap: wrap;
}
button {
background: transparent;
border: 1px solid rgba(255,255,255,0.14);
color: var(--text);
padding: 8px 12px;
border-radius: 8px;
font-weight: 600;
letter-spacing: .2px;
cursor: pointer;
}
button:hover { border-color: rgba(255,255,255,0.28); }
</style>
</head>
<body>
<div class="wrap" id="app" title="Kliknutím vygenerujete nové číslo (1–100)">
<div class="card">
<h1>Generátor <span class="badge">1–100</span></h1>
<div id="number" class="number">–</div>
<div class="hint">Mění se každé <strong>3 sekundy</strong> nebo kliknutím kamkoli.</div>
<div class="controls">
<button id="reroll">Změnit teď</button>
<button id="toggle">⏸︎ Pozastavit auto</button>
</div>
</div>
</div>
<script>
function randomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
if (window.crypto && window.crypto.getRandomValues) {
const range = max - min + 1;
const maxUint = 0xFFFFFFFF;
const bucketSize = Math.floor((maxUint + 1) / range) * range;
let r;
do {
const buf = new Uint32Array(1);
window.crypto.getRandomValues(buf);
r = buf[0];
} while (r >= bucketSize);
return min + (r % range);
}
return Math.floor(Math.random() * (max - min + 1)) + min;
}
const MIN = 1;
const MAX = 100;
const numberEl = document.getElementById('number');
const rerollBtn = document.getElementById('reroll');
const toggleBtn = document.getElementById('toggle');
let intervalMs = 3000;
let timerId = null;
let autoRunning = true;
function animateOnce(el) {
el.classList.add('pulse');
setTimeout(() => el.classList.remove('pulse'), 150);
}
function updateNumber() {
const n = randomIntInclusive(MIN, MAX);
numberEl.textContent = n;
animateOnce(numberEl);
}
function startAuto() {
if (timerId !== null) return;
timerId = setInterval(updateNumber, intervalMs);
autoRunning = true;
toggleBtn.textContent = '⏸︎ Pozastavit auto';
}
function stopAuto() {
if (timerId === null) return;
clearInterval(timerId);
timerId = null;
autoRunning = false;
toggleBtn.textContent = '▶ Spustit auto';
}
updateNumber();
startAuto();
window.addEventListener('click', () => {
updateNumber();
});
window.addEventListener('keydown', (e) => {
if (e.code === 'Space') {
e.preventDefault();
updateNumber();
}
});
rerollBtn.addEventListener('click', (e) => {
e.stopPropagation();
updateNumber();
});
toggleBtn.addEventListener('click', (e) => {
e.stopPropagation();
if (autoRunning) stopAuto(); else startAuto();
});
</script>
</body>
</html>
 
 
Bez zadání a očekávání a specifikace vstup vystup těžko zhodnotit, podle mě to je kočkopes HTML, animací a nadbytku JavaScriptu. A to ani neřeším podstatu: bezpečnost a kvalitu generaátoru.
Bohaté stací Math.random() , násobeni 100 modulo, plus, minus , a toInt() . A klidně to může běžet v javascriptovým okénku bez frontentu natož nějakých addeventlistener zhuvěrilosti... Ale neznám zadání faceliftu