diff options
Diffstat (limited to 'static/pichat.js')
| -rwxr-xr-x | static/pichat.js | 27 |
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); }; |
