<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Panic example</title>
<script>
let wasmModule;
</script>
<script type="module">
import wasm_bindgen from './api/wasm.js';
async function run() {
wasmModule = await wasm_bindgen("/api/wasm.wasm");
}
run();
</script>
</head>
<body>
With web_panic_report, an HTML container with an id is replaced with the report form: <br />
<div id="test-container" style="background-color: black; width: 400px; height: 400px;">
<div
style="position: absolute; width: 400px; height: 400px;color: white;text-align: center;display:grid;align-content: center;justify-content: center;">
Canvas (or DOOM) goes here
<br />
<button onclick="triggerPanic()" style="width: auto;">Trigger Panic</button>
</div>
<canvas id="my_canvas" width="400px" height="400px" style="background: black" />
</div>
<script>
function triggerPanic() {
if (wasmModule) {
wasmModule.trigger_panic();
} else {
console.error("WebAssembly module not loaded yet.");
}
}
</script>
</body>
</html>