chiark / gitweb /
Try to give a more friendly message if anything goes wrong during
authorSimon Tatham <anakin@pobox.com>
Wed, 3 Apr 2013 19:04:00 +0000 (19:04 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 3 Apr 2013 19:04:00 +0000 (19:04 +0000)
puzzle startup. The puzzle web pages now enclose the whole puzzle
(buttons, canvas, permalinks) in a div set to display:none, and
instead display an apologetic message saying 'sorry, it didn't work';
then, if we get through the whole init function without crashing, we
show the puzzle and hide the apology.

[originally from svn r9802]

emccpre.js
html/jspage.pl

index ea2077174cb43ea3c8f5a0f3616b4e41bb2ac50e..e2986da0fb4ccdac128f2aa13f29a3f8404790f0 100644 (file)
@@ -257,9 +257,16 @@ function initPuzzle() {
     // Default to giving keyboard focus to the puzzle.
     onscreen_canvas.focus();
 
-    // And run the C setup function, passing argv[1] as the fragment
+    // Run the C setup function, passing argv[1] as the fragment
     // identifier (so that permalinks of the form puzzle.html#game-id
     // can launch the specified id).
     Module.arguments = [location.hash];
     Module.run();
+
+    // And if we get here with everything having gone smoothly, i.e.
+    // we haven't crashed for one reason or another during setup, then
+    // it's probably safe to hide the 'sorry, no puzzle here' div and
+    // show the div containing the actual puzzle.
+    document.getElementById("apology").style.display = "none";
+    document.getElementById("puzzle").style.display = "inline";
 }
index 71728002b998a30957766d48108f36988b3ae94c..376d39a652d22c761c0720ee1577d0edacdcd4de 100755 (executable)
@@ -71,6 +71,7 @@ ${unfinishedheading}
 ${unfinishedpara}
 
 <hr>
+<div id="puzzle" style="display: none">
 <p align=center>
   <input type="button" id="new" value="New game">
   <input type="button" id="restart" value="Restart game">
@@ -98,6 +99,13 @@ ${unfinishedpara}
   <a id="permalink-desc">by game ID</a>
   <a id="permalink-seed">by random seed</a>
 </p>
+</div>
+<div id="apology">
+Sorry, this Javascript puzzle doesn't seem to work on your web
+browser. Perhaps you have Javascript disabled, or perhaps your browser
+doesn't provide a feature they depend on. These puzzles have been
+successfully run in Firefox 19 and Chrome 25.
+</div>
 <hr>
 
 ${instructions}