summaryrefslogtreecommitdiff
path: root/static/pichat.js
diff options
context:
space:
mode:
authorsostler <sbostler@gmail.com>2010-01-12 00:09:25 -0500
committersostler <sbostler@gmail.com>2010-01-12 00:09:25 -0500
commit948d38e971712ddffeb29e794d436a3202fb54e2 (patch)
tree5b3f26113461f8ecb50df09156ef3018f17c9ffc /static/pichat.js
parent16dce906d7f4bd4bbe4b4b00b9375d42d5d85beb (diff)
Added error handling to refresh
Diffstat (limited to 'static/pichat.js')
-rwxr-xr-xstatic/pichat.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/static/pichat.js b/static/pichat.js
index 4384ed0..8f61c9b 100755
--- a/static/pichat.js
+++ b/static/pichat.js
@@ -47,12 +47,12 @@ function buildUserDiv(user) {
function handleMsgError(resp) {
var respText = resp.responseText ? resp.responseText.trim() : false;
- if (respText == 'UNKNOWN_USER') {
+ if (respText == 'MUST_LOGIN') {
alert("Can't send message! Please login.");
} else if (respText) {
- alert("Cannot send message! (" + respText + ")");
+ alert("Can't send message! (" + respText + ")");
} else {
- alert("Cannot send message!");
+ alert("Can't send message!");
}
}
@@ -124,20 +124,29 @@ function isDuplicateMessage(m) {
return false;
}
var now = new Date().getTime();
- console.log(now, m.created_on);
return m.created_on - now < 5000;
}
function refresh() {
var onSuccess = function(json) {
- Timestamp = json.timestamp;
- var messages = $.grep(
- json.messages,
- function(m) { return !isDuplicateMessage(m) });
- updateUI(messages, json.users);
+ try {
+ Timestamp = json.timestamp;
+ var messages = $.grep(
+ json.messages,
+ function(m) { return !isDuplicateMessage(m) });
+ updateUI(messages, json.users);
+ } catch(e) {
+ if (IsAdmin) {
+ alert("Exception in refresh");
+ console.log(e);
+ }
+ }
setTimeout(refresh, 1000);
};
var onError = function(resp, textStatus, errorThrown) {
+ if (IsAdmin) {
+ console.log(resp, textStatus, errorThrown);
+ }
setTimeout(refresh, 1000);
};