diff lib/js/urweb.js @ 679:44f23712020d

Chat example working nicely, but without dead channel removal
author Adam Chlipala <adamc@hcoop.net>
date Thu, 26 Mar 2009 18:26:50 -0400
parents a8effb6159c2
children 6c9b8875f347
line wrap: on
line diff
--- a/lib/js/urweb.js	Thu Mar 26 16:22:34 2009 -0400
+++ b/lib/js/urweb.js	Thu Mar 26 18:26:50 2009 -0400
@@ -257,7 +257,7 @@
       if (isok) {
         var lines = xhr.responseText.split("\n");
         if (lines.length < 2) 
-          throw "Empty message from remote server";
+          return; //throw "Empty message from remote server";
 
         for (var i = 0; i+1 < lines.length; i += 2) {
           var chn = lines[i];
@@ -285,9 +285,9 @@
         connect();
       }
       else {
-        try {
+        /*try {
           whine("Error querying remote server for messages! " + xhr.status);
-        } catch (e) { }
+        } catch (e) { }*/
       }
     }
   };
@@ -300,10 +300,17 @@
   connect();
 }
 
+var listener_started = false;
+
 function rv(chn, parse, k) {
   if (chn < 0)
     whine("Out-of-bounds channel receive");
 
+  if (!listener_started) {
+    listener_started = true;
+    listener();
+  }
+
   var ch;
 
   if (chn >= channels.length || channels[chn] == null) {
@@ -320,6 +327,10 @@
   }
 }
 
-function unesc(s) {
-  return unescape(s).replace("+", " ");
+function uf(s) {
+ return escape(s).replace(new RegExp ("/", "g"), "%2F");
 }
+
+function uu(s) {
+  return unescape(s).replace(new RegExp ("\\+", "g"), " ");
+}