diff lib/js/urweb.js @ 667:a93d5324f400

Dummy message delivery to clients
author Adam Chlipala <adamc@hcoop.net>
date Thu, 19 Mar 2009 16:34:13 -0400
parents 96ebc6bdb5a0
children b0c1a46b1f15
line wrap: on
line diff
--- a/lib/js/urweb.js	Thu Mar 19 13:47:02 2009 -0400
+++ b/lib/js/urweb.js	Thu Mar 19 16:34:13 2009 -0400
@@ -174,3 +174,40 @@
   xhr.open("GET", uri, true);
   xhr.send(null);
 }
+
+
+var client_id = 0;
+var client_pass = 0;
+var url_prefix = "/";
+
+function path_join(s1, s2) {
+  if (s1.length > 0 && s1[s1.length-1] == '/')
+    return s1 + s2;
+  else
+    return s1 + "/" + s2;
+}
+
+function listener() {
+  var xhr = getXHR();
+
+  xhr.onreadystatechange = function() {
+    if (xhr.readyState == 4) {
+      var isok = false;
+
+      try {
+        if (xhr.status == 200)
+          isok = true;
+      } catch (e) { }
+
+      if (isok)
+        alert("Messages: " + xhr.responseText);
+      else {
+        alert("Error querying remote server for messages!");
+        throw "Error querying remote server for messages!";
+      }
+    }
+  };
+
+  xhr.open("GET", path_join(url_prefix, ".msgs/" + client_id + "/" + client_pass), true);
+  xhr.send(null);
+}