Files
catch-phase/shell.html

99 lines
3.2 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, user-scalable=no, viewport-fit=cover">
<title>Catch Phase</title>
<style>
html, body {
margin: 0;
height: 100%;
background: #05070d;
color: #7c8798;
font: 14px/1.5 system-ui, sans-serif;
overscroll-behavior: none;
}
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
}
canvas {
display: block;
aspect-ratio: 8 / 5;
width: 100vw;
max-width: min(1440px, calc(100vh * 8 / 5));
max-height: min(900px, 100vh);
background: #05070d;
touch-action: none;
-webkit-user-select: none;
user-select: none;
outline: none;
}
p {
margin: 0;
padding: 0 16px;
text-align: center;
}
@media (pointer: coarse) {
p { display: none; }
}
</style>
</head>
<body>
<canvas id="canvas" tabindex="-1" oncontextmenu="event.preventDefault()"></canvas>
<p>Instructions go here.</p>
<script>
// Browsers suspend audio until the first user gesture. miniaudio only
// installs click/touchend handlers, so make keyboard/pointer input
// unlock the audio context too.
const unlockEvents = ['keydown', 'pointerdown'];
const unlockAudio = () => {
if (!window.miniaudio || typeof window.miniaudio.unlock !== 'function') return;
window.miniaudio.unlock();
unlockEvents.forEach((type) => removeEventListener(type, unlockAudio, true));
};
unlockEvents.forEach((type) => addEventListener(type, unlockAudio, true));
var Module = {
canvas: document.getElementById('canvas'),
print: console.log.bind(console),
printErr: console.error.bind(console),
// Delay main() until IndexedDB-backed storage has been restored.
noInitialRun: true,
preRun: [function () {
try {
Module.FS.mkdirTree('/persist');
Module.FS.mount(Module.IDBFS, {}, '/persist');
Module.__cpStorageMounted = true;
} catch (e) {
console.error('Catch-Phase: persistent storage unavailable', e);
}
}],
onRuntimeInitialized: function () {
const start = () => Module.callMain();
if (!Module.__cpStorageMounted) {
start();
return;
}
try {
Module.FS.syncfs(true, function (err) {
if (err) console.error('Catch-Phase: failed to load persistent storage', err);
start();
});
} catch (e) {
console.error('Catch-Phase: failed to sync persistent storage', e);
start();
}
},
};
addEventListener('load', () => Module.canvas.focus());
</script>
{{{ SCRIPT }}}
</body>
</html>