Better cancellation, better text... Papa John's!
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 12 Dec 2008 16:15:20 -0500
changeset 9 c7f0ffcfb541
parent 8 177f4022f463
child 10 2842d1ea59aa
push id1
push userbsmedberg@mozilla.com
push dateFri, 12 Dec 2008 21:25:26 +0000
Better cancellation, better text... Papa John's!
wordmap.html
wordmap.js
--- a/wordmap.html
+++ b/wordmap.html
@@ -9,26 +9,27 @@
 <body>
   <h1>Word Maps</h1>
 
   <p>The word maps generated by <a href="http://www.wordle.net/">wordle.net</a> have been going around the
   Mozilla community. They are really pretty, but I wanted to hack out
   the output and algorithm, and avoid the unholy Java monster. So I
   recreated it using the HTML &lt;canvas&gt; element and JavaScript.
 
-  <p>Note: currently requires Firefox 3.1. The codebase can be found
-  at http://hg.mozilla.org/users/bsmedberg_mozilla.com/wordmap if
-  you'd like to test/help!
+  <p>Note: currently requires Firefox 3.1. If you'd like to host it
+  yourself, or hack it, <a
+  href="http://hg.mozilla.org/users/bsmedberg_mozilla.com/wordmap">get
+  the code here</a>.
 
   <div>
   <input type="button" value="Wordmap of BSBlog" onclick="drawasync()">
   Choose a font:
   <input type="text" value="Papyrus, URW Palladio L" id="font" onchange="setFont()">
   Status: <span id="status"></span>
-  <input type="button" value="Stop" onclick="gCurDraw = null">
+  <input type="button" value="Stop" onclick="cancel()">
   </div>
 
   <canvas width="800" height="800" id="cc"
     style="border: 1px solid black; display: block"></canvas>
 
   <canvas width="800" height="800" id="chidden" style="display: none"></canvas>
   <iframe src="about:blank" id="i" style="display: none"></iframe>
 
--- a/wordmap.js
+++ b/wordmap.js
@@ -419,16 +419,18 @@ function draw()
       }
       else {
 	yield;
       }
     }
 
     usercx.putImageData(imgdata, 0, 0);
   }
+
+  setStatus('Done!');
 }
 
 function placeWord(imgdata, wdata)
 {
   let x = normalInt(0, kWidth - wdata.width, 1);
   let y = normalInt(0, kHeight - wdata.height, 1);
   for (let t = 1; t < 20; ++t) {
     let x2 = normalInt(0, kWidth - wdata.width, t);
@@ -461,9 +463,15 @@ function drawasync()
       gCurDraw.next();
       setTimeout(doSomeWork, 1);
     }
     catch (e if e instanceof StopIteration) { }
   }
 
   gCurDraw = draw();
   setTimeout(doSomeWork, 1);
+}
+
+function cancel()
+{
+  gCurDraw = null;
+  setStatus('cancelled');
 }
\ No newline at end of file