aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/js
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-03-22 15:05:07 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-03-22 15:05:07 -0400
commit2627ab6f5cfd96df06016a88b7e5a245e3ab9d8f (patch)
tree5a3c064007e7481a452bc60d9dfaeabebb515a53 /lib/js
parent9e730b9a1aa4db311088a355e7e8601c6a998467 (diff)
First message send delivered, but not interpreted
Diffstat (limited to 'lib/js')
-rw-r--r--lib/js/urweb.js32
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 9f93120f..d5147369 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -133,7 +133,11 @@ function cr(n) {
}
-function getXHR()
+var client_id = 0;
+var client_pass = 0;
+var url_prefix = "/";
+
+function getXHR(uri)
{
try {
return new XMLHttpRequest();
@@ -150,6 +154,17 @@ function getXHR()
}
}
+function requestUri(xhr, uri) {
+ xhr.open("GET", uri, true);
+
+ if (client_id != 0) {
+ xhr.setRequestHeader("UrWeb-Client", client_id.toString());
+ xhr.setRequestHeader("UrWeb-Pass", client_pass.toString());
+ }
+
+ xhr.send(null);
+}
+
function rc(uri, parse, k) {
var xhr = getXHR();
@@ -171,15 +186,10 @@ function rc(uri, parse, k) {
}
};
- xhr.open("GET", uri, true);
- xhr.send(null);
+ requestUri(xhr, uri);
}
-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;
@@ -188,6 +198,7 @@ function path_join(s1, s2) {
}
function listener() {
+ var uri = path_join(url_prefix, ".msgs");
var xhr = getXHR();
xhr.onreadystatechange = function() {
@@ -199,8 +210,10 @@ function listener() {
isok = true;
} catch (e) { }
- if (isok)
+ if (isok) {
alert("Messages: " + xhr.responseText);
+ requestUri(xhr, uri);
+ }
else {
alert("Error querying remote server for messages!");
throw "Error querying remote server for messages!";
@@ -208,6 +221,5 @@ function listener() {
}
};
- xhr.open("GET", path_join(url_prefix, ".msgs/" + client_id + "/" + client_pass), true);
- xhr.send(null);
+ requestUri(xhr, uri);
}