From 1c5cf83c7bd4bc8a13103224572fffc41fdfc900 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 2 Jun 2009 13:26:42 +0200 Subject: [PATCH] Add error message for downed server --- client.js | 23 +++++++++++++---------- index.html | 2 +- style.css | 2 ++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/client.js b/client.js index a613bfa..5eeabdc 100644 --- a/client.js +++ b/client.js @@ -154,7 +154,6 @@ function handleKeyPress (e) { if (e.keyCode != 13 /* Return */) return; if (!util.isBlank(msg)) { - //addMessage(CONFIG.nick, msg); send(msg); } @@ -162,7 +161,14 @@ function handleKeyPress (e) { clearEntry(); }; +var longPollErrors = 0; function longPoll (data) { + + if (longPollErrors > 2) { + showConnect(); + return; + } + if (data) { if (data.messages) { for (var i = 0; i < data.messages.length; i++) { @@ -194,16 +200,13 @@ function longPoll (data) { , dataType: "json" , data: { since: CONFIG.last_message_time, id: CONFIG.id } , error: function () { - console.log("long poll error! waiting 5 seconds"); - setTimeout(longPoll, 5000); + addMessage("", "long poll error. trying again...", new Date(), "error"); + longPollErrors += 1; + setTimeout(longPoll, 10*1000); } - , success: function (data, textStatus) { - if (textStatus == "success") { - longPoll(data); - } else { - console.log("long poll error: " + textStatus); - setTimeout(longPoll, 5000); - } + , success: function (data) { + longPollErrors = 0; + longPoll(data); } }); } diff --git a/index.html b/index.html index 2bb8d74..6201e01 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@
- +
diff --git a/style.css b/style.css index fb70d4a..9eeb790 100644 --- a/style.css +++ b/style.css @@ -98,6 +98,8 @@ form.horizontal .field label {display: inline; float: left; width: 140px; margin /* not very important info */ .notice td, .join td, .part td, .message .date { color: #555; } +.notice .nick { color: #cd5; } +.error td { color: #933; } .message { margin: 0.1em 0;