51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
// Session-scoped "terminal boot" intro overlay.
|
|
const overlay = document.getElementById('boot-overlay');
|
|
const textEl = document.getElementById('boot-text');
|
|
|
|
if (overlay && textEl) {
|
|
const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
const alreadyBooted = sessionStorage.getItem('briTunes.booted') === '1';
|
|
|
|
if (reduced || alreadyBooted) {
|
|
overlay.classList.add('hidden', 'gone');
|
|
overlay.setAttribute('aria-hidden', 'true');
|
|
} else {
|
|
const siteName = (overlay.dataset.siteName || 'BRI-TUNES').toUpperCase();
|
|
const lines = [
|
|
`${siteName} OS v1.0`,
|
|
'',
|
|
'> boot loader ........................ OK',
|
|
'> initializing audio subsystem ....... OK',
|
|
'> mounting /media .................... OK',
|
|
'> loading neon grid shader ........... OK',
|
|
'> linking synthwave subroutines ...... OK',
|
|
'> ready.',
|
|
];
|
|
const full = lines.join('\n');
|
|
let i = 0;
|
|
const cursor = '<span class="boot-cursor"> </span>';
|
|
const charMs = 14;
|
|
let interval = null;
|
|
|
|
function finish() {
|
|
if (interval) { clearInterval(interval); interval = null; }
|
|
textEl.innerHTML = full + '\n' + cursor;
|
|
sessionStorage.setItem('briTunes.booted', '1');
|
|
setTimeout(() => {
|
|
overlay.classList.add('hidden');
|
|
setTimeout(() => overlay.classList.add('gone'), 350);
|
|
}, 220);
|
|
}
|
|
|
|
interval = setInterval(() => {
|
|
i += 1;
|
|
textEl.innerHTML = full.slice(0, i) + cursor;
|
|
if (i >= full.length) finish();
|
|
}, charMs);
|
|
|
|
const skip = () => finish();
|
|
overlay.addEventListener('click', skip, { once: true });
|
|
window.addEventListener('keydown', skip, { once: true });
|
|
}
|
|
}
|