Working application
This commit is contained in:
BIN
reaction_systems_gui/docs/favicon.ico
Executable file
BIN
reaction_systems_gui/docs/favicon.ico
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
reaction_systems_gui/docs/icon-256.png
Normal file
BIN
reaction_systems_gui/docs/icon-256.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
209
reaction_systems_gui/docs/index.html
Normal file
209
reaction_systems_gui/docs/index.html
Normal file
@ -0,0 +1,209 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<!-- Disable zooming: -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||
|
||||
<head>
|
||||
<title>eframe template</title>
|
||||
<style>
|
||||
html {
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
/* dark mode preference support */
|
||||
body {
|
||||
background: #909090;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
background: #404040;
|
||||
}
|
||||
}
|
||||
|
||||
html, body {
|
||||
overflow: hidden;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#rscanvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0%);
|
||||
}
|
||||
|
||||
.loading {
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: white;
|
||||
font-size: 24px;
|
||||
font-family: Ubuntu-Light, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
/* Loading animation from https://loading.io/css/ */
|
||||
.lds-dual-ring {
|
||||
display: inline-block;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.lds-dual-ring:after {
|
||||
content: " ";
|
||||
display: block;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin: 0px;
|
||||
border-radius: 50%;
|
||||
border: 3px solid #fff;
|
||||
border-color: #fff transparent #fff transparent;
|
||||
animation: lds-dual-ring 1.2s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes lds-dual-ring {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="manifest" href="./manifest.json">
|
||||
<script>
|
||||
// register ServiceWorker
|
||||
window.onload = () => {
|
||||
'use strict';
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register('./sw.js');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- The WASM code will resize this canvas to cover the entire screen -->
|
||||
<canvas id="rscanvas"></canvas>
|
||||
<div class="loading" id="loading">
|
||||
Loading…
|
||||
<div class="lds-dual-ring"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// The `--no-modules`-generated JS from `wasm-bindgen` attempts to use
|
||||
// `WebAssembly.instantiateStreaming` to instantiate the wasm module,
|
||||
// but this doesn't work with `file://` urls. This example is frequently
|
||||
// viewed by simply opening `index.html` in a browser (with a `file://`
|
||||
// url), so it would fail if we were to call this function!
|
||||
//
|
||||
// Work around this for now by deleting the function to ensure that the
|
||||
// `no_modules.js` script doesn't have access to it. You won't need this
|
||||
// hack when deploying over HTTP.
|
||||
delete WebAssembly.instantiateStreaming;
|
||||
</script>
|
||||
|
||||
<!-- This is the JS generated by the `wasm-bindgen` CLI tool -->
|
||||
<script src="reaction_systems_gui.js"></script>
|
||||
|
||||
<script>
|
||||
console.debug("Loading wasm…");
|
||||
// We'll defer our execution until the wasm is ready to go.
|
||||
// Here we tell bindgen the path to the wasm file so it can start
|
||||
// initialization and return to us a promise when it's done.
|
||||
wasm_bindgen("./reaction_systems_gui_bg.wasm")
|
||||
.then(on_wasm_loaded)
|
||||
.catch(console.error);
|
||||
|
||||
function on_wasm_loaded() {
|
||||
console.log("loaded wasm, starting egui app…");
|
||||
// // This call installs a bunch of callbacks and then returns:
|
||||
// wasm_bindgen.start("the_canvas_id");
|
||||
|
||||
let rscanvas = document.getElementById("rscanvas");
|
||||
|
||||
let handle = new wasm_bindgen.WebHandle();
|
||||
|
||||
function check_for_panic() {
|
||||
if (handle.has_panicked()) {
|
||||
console.error("The egui app has crashed");
|
||||
|
||||
// The demo app already logs the panic message and callstack, but you
|
||||
// can access them like this if you want to show them in the html:
|
||||
// console.error(`${handle.panic_message()}`);
|
||||
// console.error(`${handle.panic_callstack()}`);
|
||||
|
||||
// document.getElementById("the_canvas_id").remove();
|
||||
// document.getElementById("center_text").innerHTML = `
|
||||
// <p>
|
||||
// The egui app has crashed.
|
||||
// </p>
|
||||
// <p style="font-size:10px" align="left">
|
||||
// ${handle.panic_message()}
|
||||
// </p>
|
||||
// <p style="font-size:14px">
|
||||
// See the console for details.
|
||||
// </p>
|
||||
// <p style="font-size:14px">
|
||||
// Reload the page to try again.
|
||||
// </p>`;
|
||||
} else {
|
||||
let delay_ms = 1000;
|
||||
setTimeout(check_for_panic, delay_ms);
|
||||
}
|
||||
}
|
||||
|
||||
check_for_panic();
|
||||
|
||||
handle.start(rscanvas).then(on_app_started).catch(on_error);
|
||||
|
||||
console.log("egui app started.");
|
||||
document.getElementById("loading").remove();
|
||||
}
|
||||
|
||||
function on_app_started(handle) {
|
||||
// Call `handle.destroy()` to stop. Uncomment to quick result:
|
||||
// setTimeout(() => { handle.destroy(); handle.free()) }, 2000)
|
||||
|
||||
console.debug("App started.");
|
||||
// document.getElementById("center_text").innerHTML = '';
|
||||
|
||||
// Make sure the canvas is focused so it can receive keyboard events right away:
|
||||
rscanvas.focus();
|
||||
}
|
||||
|
||||
function on_error(error) {
|
||||
console.error("Failed to start: " + error);
|
||||
rscanvas.remove();
|
||||
// document.getElementById("center_text").innerHTML = `
|
||||
// <p>
|
||||
// An error occurred during loading:
|
||||
// </p>
|
||||
// <p style="font-family:Courier New">
|
||||
// ${error}
|
||||
// </p>
|
||||
// <p style="font-size:14px">
|
||||
// Make sure you use a modern browser with WebGL and WASM enabled.
|
||||
// </p>`;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
14
reaction_systems_gui/docs/manifest.json
Normal file
14
reaction_systems_gui/docs/manifest.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Egui Template PWA",
|
||||
"short_name": "egui-template-pwa",
|
||||
"icons": [{
|
||||
"src": "./icon-256.png",
|
||||
"sizes": "256x256",
|
||||
"type": "image/png"
|
||||
}],
|
||||
"lang": "en-US",
|
||||
"start_url": "./index.html",
|
||||
"display": "standalone",
|
||||
"background_color": "white",
|
||||
"theme_color": "white"
|
||||
}
|
||||
1814
reaction_systems_gui/docs/reaction_systems_gui.js
Normal file
1814
reaction_systems_gui/docs/reaction_systems_gui.js
Normal file
File diff suppressed because it is too large
Load Diff
BIN
reaction_systems_gui/docs/reaction_systems_gui_bg.wasm
Normal file
BIN
reaction_systems_gui/docs/reaction_systems_gui_bg.wasm
Normal file
Binary file not shown.
25
reaction_systems_gui/docs/sw.js
Normal file
25
reaction_systems_gui/docs/sw.js
Normal file
@ -0,0 +1,25 @@
|
||||
var cacheName = 'egui-template-pwa';
|
||||
var filesToCache = [
|
||||
'./',
|
||||
'./index.html',
|
||||
'./reaction_systems_gui.js',
|
||||
'./reaction_systems_gui_bg.wasm',
|
||||
];
|
||||
|
||||
/* Start the service worker and cache all of the app's content */
|
||||
self.addEventListener('install', function (e) {
|
||||
e.waitUntil(
|
||||
caches.open(cacheName).then(function (cache) {
|
||||
return cache.addAll(filesToCache);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
/* Serve cached content when offline */
|
||||
self.addEventListener('fetch', function (e) {
|
||||
e.respondWith(
|
||||
caches.match(e.request).then(function (response) {
|
||||
return response || fetch(e.request);
|
||||
})
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user