67 lines
3.1 KiB
HTML
67 lines
3.1 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="icon" href="data:,">
|
|
<title>{{{ PRODUCT_NAME }}}</title>
|
|
<style>
|
|
* { box-sizing: border-box; }
|
|
html, body { margin: 0; height: 100%; background: #101d26; color: #e9ede7; }
|
|
body { display: grid; place-items: center; font: 16px system-ui, sans-serif; }
|
|
#viewport { width: min(100vw, 177.7778vh); height: min(100vh, 56.25vw); position: relative; }
|
|
canvas { width: 100%; height: 100%; display: block; outline: none; }
|
|
#status { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
|
|
#status[hidden] { display: none; }
|
|
#status strong { font: 36px Georgia, serif; color: #e4bd85; margin-bottom: 12px; }
|
|
#fullscreen { position: absolute; right: 7px; bottom: 5px; border: 1px solid #45636a; border-radius: 4px; background: #11242b; color: #d9ebe5; padding: 4px 8px; }
|
|
#viewport:fullscreen { width: 100vw; height: 100vh; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<main id="viewport">
|
|
<canvas id="game" tabindex="0" aria-label="Soundings cruise line simulator"></canvas>
|
|
<section id="status" role="status"><strong>Soundings</strong><span id="message">Loading simulator…</span></section>
|
|
<button id="fullscreen" type="button" hidden>Full screen</button>
|
|
</main>
|
|
<script>
|
|
const viewport = document.querySelector("#viewport");
|
|
const canvas = document.querySelector("#game");
|
|
const status = document.querySelector("#status");
|
|
const message = document.querySelector("#message");
|
|
const fullscreen = document.querySelector("#fullscreen");
|
|
fullscreen.addEventListener("click", () => {
|
|
const request = document.fullscreenElement ? document.exitFullscreen() : viewport.requestFullscreen();
|
|
request.then(() => canvas.focus()).catch(() => canvas.focus());
|
|
});
|
|
document.addEventListener("fullscreenchange", () => {
|
|
fullscreen.textContent = document.fullscreenElement ? "Exit full screen" : "Full screen";
|
|
});
|
|
const build = "Build/";
|
|
const loader = document.createElement("script");
|
|
loader.src = build + "{{{ LOADER_FILENAME }}}";
|
|
loader.onerror = () => { message.textContent = "The simulator loader could not be downloaded."; };
|
|
loader.onload = () => {
|
|
createUnityInstance(canvas, {
|
|
dataUrl: build + "{{{ DATA_FILENAME }}}",
|
|
frameworkUrl: build + "{{{ FRAMEWORK_FILENAME }}}",
|
|
codeUrl: build + "{{{ CODE_FILENAME }}}",
|
|
streamingAssetsUrl: "StreamingAssets",
|
|
companyName: "{{{ COMPANY_NAME }}}",
|
|
productName: "{{{ PRODUCT_NAME }}}",
|
|
productVersion: "{{{ PRODUCT_VERSION }}}"
|
|
}, value => {
|
|
message.textContent = "Loading simulator… " + Math.round(100 * value) + "%";
|
|
}).then(() => {
|
|
status.hidden = true;
|
|
fullscreen.hidden = !document.fullscreenEnabled;
|
|
canvas.focus();
|
|
}).catch(error => {
|
|
message.textContent = String(error);
|
|
});
|
|
};
|
|
document.body.appendChild(loader);
|
|
</script>
|
|
</body>
|
|
</html>
|