blob: 0bd537b796dcfd9f141283aa3395547f16806ef4 (
plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
body {
color: white;
background-color: black;
}
header {
text-align: center;
}
#loading_bg {
position: absolute;
left: 25%;
top: 50%;
width: 50%;
background-color: grey;
}
#loading_bar {
width: 0%;
padding: 2px;
background-color: red;
}
.game_canvas {
display: none;
margin: auto;
outline-style: double;
outline-color: red;
}
</style>
</head>
<body>
<header>
<h1>This Starless Sky</h1>
<p>we are deserving of no gifts.</p?
</header>
<main>
<div id="loading_bg">
<div id="loading_bar"></div>
</div>
<canvas class="game_canvas" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
</main>
<script>
let progressBar = document.getElementById("loading_bar");
let canvas = document.getElementById("canvas");
function convertStatusToNumeric (status) {
if (status === "Running...") {
return 100;
} else if (status.length === 0) {
return 0;
}
// Ungodly regex from the depths of hell, see
// https://github.com/emscripten-core/emscripten/issues/16278#issuecomment-2178303577
const regExp = RegExp(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
const matches = regExp.exec(status);
if (matches) {
const currentValue = parseInt(matches[2]);
const maxValue = parseInt(matches[4]);
return (currentValue * 100) / maxValue;
} else {
return NaN;
}
}
var Module = {
setStatus (status) {
if (progressBar.style.width !== "100%") {
const percentage = convertStatusToNumeric(status);
progressBar.style.width = percentage + "%";
} else {
progressBar.style.display = "none";
canvas.style.display = "block";
}
},
};
</script>
{{{ SCRIPT }}}
</body>
</html>
|