Add shell
This commit is contained in:
82
data/shell.html
Normal file
82
data/shell.html
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, user-scalable=no">
|
||||||
|
<title>text_editor</title>
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
outline: none;
|
||||||
|
border: 0;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
|
||||||
|
<div id="error-box" style="display:none; position:fixed; left:12px; right:12px; bottom:12px; z-index:9999; box-sizing:border-box; max-height:35vh; overflow:auto; padding:10px 12px; border:1px solid #7f1d1d; border-radius:6px; background:rgba(127,29,29,0.94); color:#fff; font:13px/1.35 monospace; white-space:pre-wrap;"></div>
|
||||||
|
<script>
|
||||||
|
const errorBox = document.getElementById('error-box');
|
||||||
|
|
||||||
|
function showError(message) {
|
||||||
|
const text = String(message || 'Unknown error');
|
||||||
|
console.error(text);
|
||||||
|
errorBox.style.display = 'block';
|
||||||
|
errorBox.textContent = text + '\n\n(click to dismiss)';
|
||||||
|
}
|
||||||
|
|
||||||
|
errorBox.addEventListener('click', () => {
|
||||||
|
errorBox.style.display = 'none';
|
||||||
|
errorBox.textContent = '';
|
||||||
|
Module.canvas.focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('error', (event) => {
|
||||||
|
showError(event.error && event.error.stack ? event.error.stack : event.message);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('unhandledrejection', (event) => {
|
||||||
|
const reason = event.reason;
|
||||||
|
showError(reason && reason.stack ? reason.stack : reason);
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
var Module = {
|
||||||
|
canvas: document.getElementById('canvas'),
|
||||||
|
print: (text) => console.log(text),
|
||||||
|
printErr: (text) => showError(text),
|
||||||
|
onAbort: (what) => showError('Aborted: ' + what),
|
||||||
|
setStatus: (text) => { if (text) console.log(text); }
|
||||||
|
};
|
||||||
|
|
||||||
|
function resizeCanvasToDisplaySize() {
|
||||||
|
const canvas = Module.canvas;
|
||||||
|
const dpr = window.devicePixelRatio || 1;
|
||||||
|
const w = Math.max(1, Math.floor(window.innerWidth * dpr));
|
||||||
|
const h = Math.max(1, Math.floor(window.innerHeight * dpr));
|
||||||
|
if (canvas.width !== w || canvas.height !== h) {
|
||||||
|
canvas.width = w;
|
||||||
|
canvas.height = h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', resizeCanvasToDisplaySize);
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
resizeCanvasToDisplaySize();
|
||||||
|
Module.canvas.focus();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{{{ SCRIPT }}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user