changeset 25:58ef69894c96

Results now display on big test, and more status/config info.
author Atul Varma <varmaa@toolness.com>
date Mon, 13 Apr 2009 15:14:57 -0700
parents 9414e2a40ed3
children fd8f4c369dc4
files big.html big.js
diffstat 2 files changed, 54 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/big.html	Mon Apr 13 14:56:57 2009 -0700
+++ b/big.html	Mon Apr 13 15:14:57 2009 -0700
@@ -11,8 +11,12 @@
 </head>
 <body>
 <h1>Browser Big Couch Test</h1>
+<div id="config">
+</div>
 <div id="status">
 </div>
+<div id="result" style="font-family: monospace;">
+</div>
 </body>
 <script src="browser-couch.js"></script>
 <script src="big.js"></script>
--- a/big.js	Mon Apr 13 14:56:57 2009 -0700
+++ b/big.js	Mon Apr 13 15:14:57 2009 -0700
@@ -56,39 +56,54 @@
   db.put(docs, cb);
 }
 
-BrowserCouch.get(
-  "big",
-  function(db) {
-    var status = document.getElementById("status");
-    if (db.getLength() == 0) {
-      status.textContent = "Building new corpus.";
-      db.wipe(function() { makeCorpus(db, run); });
-    } else
-      run();
+var config = document.getElementById("config");
+var status = document.getElementById("status");
+var result = document.getElementById("result");
+
+status.textContent = "Please wait...";
+config.textContent = ("Counting word occurrences in a lexicon of " +
+                      LEXICON_SIZE + " words, using a corpus of " +
+                      CORPUS_SIZE + " documents, each of which is " +
+                      MIN_DOCUMENT_LENGTH + " to " + MAX_DOCUMENT_LENGTH +
+                      " words long.");
+
+function start() {
+  BrowserCouch.get(
+    "big",
+    function(db) {
+      if (db.getLength() == 0) {
+        status.textContent = "Building new corpus.";
+        db.wipe(function() { makeCorpus(db, run); });
+      } else
+        run();
 
-    function run() {
-      db.view(
-        {map: function(doc, emit) {
-                 var words = doc.content.split(" ");
-                 for (var i = 0; i < words.length; i++)
-                   emit(words[i], 1);
-         },
-         reduce: function(keys, values) {
-           var sum = 0;
-           for (var i = 0; i < values.length; i++)
-             sum += values[i];
-           return sum;
-         },
-         chunkSize: 5,
-         progress: function(phase, percent, resume) {
-           percent = Math.floor(percent * 100);
-           var msg = phase + " (" + percent + "%)";
-           status.textContent = msg;
-           window.setTimeout(resume, 5);
-         },
-         finished: function(result) {
-           status.textContent = "Done.";
-         }}
-      );
-    }
-  });
+      function run() {
+        db.view(
+          {map: function(doc, emit) {
+             var words = doc.content.split(" ");
+             for (var i = 0; i < words.length; i++)
+               emit(words[i], 1);
+           },
+           reduce: function(keys, values) {
+             var sum = 0;
+             for (var i = 0; i < values.length; i++)
+               sum += values[i];
+             return sum;
+           },
+           chunkSize: 5,
+           progress: function(phase, percent, resume) {
+             percent = Math.floor(percent * 100);
+             var msg = phase + " (" + percent + "%)";
+             status.textContent = msg;
+             window.setTimeout(resume, 5);
+           },
+           finished: function(aResult) {
+             status.textContent = "Done.";
+             result.textContent = JSON.stringify(aResult);
+           }}
+        );
+      }
+    });
+}
+
+window.addEventListener("load", start, false);