<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>mikef.live</title>
<style>
body {
margin: 0;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: system-ui, -apple-system, sans-serif;
background: #0f0f0f;
color: #f5f5f5;
text-align: center;
padding: 2rem;
}
#quote {
font-size: clamp(1.5rem, 4vw, 2.5rem);
max-width: 800px;
line-height: 1.4;
margin-bottom: 1.5rem;
}
#timer {
font-size: 0.9rem;
color: #888;
font-variant-numeric: tabular-nums;
}
</style>
</head>
<body>
<div id="quote">Loading...</div>
<div id="timer">Next in 7s</div>
<script>
const INTERVAL_SECONDS = 7;
let items = [];
let secondsLeft = INTERVAL_SECONDS;
const quoteEl = document.getElementById('quote');
const timerEl = document.getElementById('timer');
function showRandomItem() {
if (!items.length) return;
const randomIndex = Math.floor(Math.random() * items.length);
quoteEl.textContent = items[randomIndex];
secondsLeft = INTERVAL_SECONDS;
timerEl.textContent = `Next in ${secondsLeft}s`;
}
async function init() {
try {
const res = await fetch('./data.json');
items = await res.json();
showRandomItem();
setInterval(() => {
secondsLeft--;
if (secondsLeft <= 0) {
showRandomItem();
} else {
timerEl.textContent = `Next in ${secondsLeft}s`;
}
}, 1000);
} catch (err) {
quoteEl.textContent = 'Failed to load data.';
}
}
init();
</script>
</body>
</html>