-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
73 lines (68 loc) · 2.23 KB
/
Copy pathindex.html
File metadata and controls
73 lines (68 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<head>
<title>URLchess</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<link rel="preload" href="assets/URLchess.css?v0.10" as="style" onload="this.rel='stylesheet'">
</head>
<body>
<noscript>
<p>You need to enable JavaScript to run URLchess.</p>
</noscript>
<script type="text/javascript">
//<![CDATA[
window.addEventListener("load", function() {
// Backwards compatibility with URLchess links when version was 0.6 and lower.
var hash = window.location.hash;
var search = window.location.search;
if (search.startsWith("?")) {
search = search.slice(1);
}
if (
(search.length > 0 && hash.length == 0)
||
(search.length == 0 && hash.length == 0 && window.location.href.indexOf("?") != -1)
){
//window.alert("URL is in format for URLchess version <=0.6, transforming...");
window.location.href = window.location.href.replace("?", "#");
}
function fallBackToJsVersion() {
console.warn("Fall back to js version.");
// Load and execute js version of the URLchess app.
var script = document.createElement('script');
script.src = "assets/URLchess.js?v0.10";
document.body.appendChild(script);
}
// If browser supports wasm, try running the wasm version, if something fails use the js version.
if (typeof WebAssembly === "object") {
// Load and execute go wasm runtime.
var script = document.createElement('script');
script.src = "assets/wasm_exec.js?v0.10";
script.onload = function() {
// After wasm runtime is loaded, continue to run the URLchess wasm app.
// Check if go is present.
if (typeof Go === "undefined") {
console.warn("Go runtime is not loaded.");
fallBackToJsVersion();
return;
}
// Start the Go WebAssembly runtime and run URLchess wasm app.
const go = new Go();
WebAssembly.instantiateStreaming(fetch("assets/URLchess.wasm?v0.10"), go.importObject).then((result) => {
go.run(result.instance);
}).catch((err) => {
console.warn("Failed to load WebAssembly:", err);
fallBackToJsVersion();
});
};
// Append the script with wasm to body.
document.body.appendChild(script);
} else {
console.warn("No wasm in browser!");
fallBackToJsVersion();
}
});
//]]>
</script>
</body>
</html>