@@ -144,13 +144,16 @@ jobs:
144144 <meta charset="UTF-8">
145145 <meta name="viewport" content="width=device-width, initial-scale=1.0">
146146 <title>Wolfenstein 3D — build ${SHORT_SHA}</title>
147+ <link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
147148 <link rel="stylesheet" href="https://js-dos.com/v8/js-dos.css">
148149 <script src="https://js-dos.com/v8/js-dos.js"></script>
149150 <style>
150151 * { box-sizing: border-box; margin: 0; padding: 0; }
151152 body { background: #111; color: #eee; font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; min-height: 100vh; padding: 20px; }
152153 h1 { margin-bottom: 12px; font-size: 1.4rem; }
153154 #dos { width: 800px; height: 600px; max-width: 100%; }
155+ #status { margin-top: 10px; min-height: 1.2em; font-size: 0.95rem; color: #b7c4d6; }
156+ #status.error { color: #ff9b9b; }
154157 .meta { margin-top: 10px; font-size: 0.8rem; color: #888; }
155158 button { margin-top: 10px; padding: 6px 16px; background: #333; color: #eee; border: 1px solid #555; cursor: pointer; border-radius: 4px; }
156159 button:hover { background: #444; }
@@ -159,16 +162,51 @@ jobs:
159162 <body>
160163 <h1>Wolfenstein 3D</h1>
161164 <div id="dos"></div>
165+ <p id="status" role="status" aria-live="polite">Loading emulator…</p>
162166 <button onclick="document.getElementById('dos').requestFullscreen && document.getElementById('dos').requestFullscreen()">Full screen</button>
163167 <p class="meta">build ${SHORT_SHA} — <a href="https://github.com/luke-b/DosTest/commit/${GITHUB_SHA}" style="color:#888">view commit</a></p>
164168 <script>
165- Dos(document.getElementById("dos"), {
166- url: "./hra.jsdos",
167- onprogress: (stage, total, loaded) => {
168- if (stage === "Resolving DosBox") return;
169- console.log(stage, loaded, "/", total);
169+ const dosRoot = document.getElementById("dos");
170+ const status = document.getElementById("status");
171+
172+ function updateStatus(message, isError = false) {
173+ status.textContent = message;
174+ status.classList.toggle("error", isError);
175+ }
176+
177+ async function startDemo() {
178+ if (typeof Dos !== "function") {
179+ console.error("js-dos failed to load before initialization.");
180+ updateStatus("The js-dos runtime could not be loaded. Check your connection and try again.", true);
181+ return;
170182 }
171- });
183+
184+ try {
185+ const dos = Dos(dosRoot, {
186+ url: "./hra.jsdos",
187+ onprogress: (stage, total, loaded) => {
188+ if (stage === "Resolving DosBox") {
189+ return;
190+ }
191+
192+ const suffix = total ? ` (${loaded}/${total})` : "";
193+ console.log(stage, loaded, "/", total);
194+ updateStatus(`${stage}${suffix}`);
195+ }
196+ });
197+
198+ if (dos && typeof dos.then === "function") {
199+ await dos;
200+ }
201+
202+ updateStatus("Ready. Click inside the emulator window to start playing.");
203+ } catch (error) {
204+ console.error("Error initializing DOSBox:", error);
205+ updateStatus("The emulator failed to start. Check the browser console for details.", true);
206+ }
207+ }
208+
209+ startDemo();
172210 </script>
173211 </body>
174212 </html>
@@ -199,19 +237,24 @@ jobs:
199237 cp index.html "staging/demo/build/${SHORT_SHA}/index.html"
200238 cp hra.jsdos "staging/demo/build/${SHORT_SHA}/hra.jsdos"
201239 cp latest-redirect/index.html "staging/demo/build/latest/index.html"
240+ cp ./index.html staging/index.html
241+ cp ./js-dos-test.html staging/js-dos-test.html
242+ cp ./jsdos-demo1.html staging/jsdos-demo1.html
243+ cp ./favicon.svg staging/favicon.svg
244+ touch staging/.nojekyll
202245
203246 - name : Deploy demo to gh-pages
204247 uses : peaceiris/actions-gh-pages@v4
205248 with :
206249 github_token : ${{ secrets.GITHUB_TOKEN }}
207- publish_dir : ./staging/demo/build
208- destination_dir : demo/build
250+ publish_dir : ./staging
209251 keep_files : true
210252
211253 - name : Smoke test deployed demo
212254 run : |
213255 SHORT_SHA="${{ steps.sha.outputs.short }}"
214256 for url in \
257+ "https://luke-b.github.io/DosTest/" \
215258 "https://luke-b.github.io/DosTest/demo/build/${SHORT_SHA}/" \
216259 "https://luke-b.github.io/DosTest/demo/build/latest/"
217260 do
@@ -296,7 +339,7 @@ jobs:
296339
297340 - name : Update demo link in README.md
298341 run : |
299- DEMO_URL="https://luke-b.github.io/DosTest/demo/build/latest/ "
342+ DEMO_URL="https://luke-b.github.io/DosTest/"
300343 BADGE_LINE="[](${DEMO_URL})"
301344 BLOCK="<!-- DEMO_LINK -->\n${BADGE_LINE}\n<!-- /DEMO_LINK -->"
302345
0 commit comments