Permalink
Browse files

A few stylistic changes

  • Loading branch information...
ry committed Jun 5, 2009
1 parent 7ea18c7 commit e8380ecd450785c820558df553342720f2362fd7
Showing with 29 additions and 25 deletions.
  1. +26 −23 client.js
  2. +3 −2 style.css
View
@@ -166,37 +166,40 @@ function handleKeyPress (e) {
clearEntry();
};
-var longPollErrors = 0;
-function longPoll (data) {
+var transmission_errors = 0;
+var first_poll = true;
- if (longPollErrors > 2) {
+function longPoll (data) {
+ if (transmission_errors > 2) {
showConnect();
return;
}
- if (data) {
- if (data.messages) {
- for (var i = 0; i < data.messages.length; i++) {
- var message = data.messages[i];
+ if (data && data.messages) {
+ for (var i = 0; i < data.messages.length; i++) {
+ var message = data.messages[i];
- if (message.timestamp > CONFIG.last_message_time)
- CONFIG.last_message_time = message.timestamp;
+ if (message.timestamp > CONFIG.last_message_time)
+ CONFIG.last_message_time = message.timestamp;
- switch (message.type) {
- case "msg":
- addMessage(message.nick, message.text, message.timestamp);
- break;
+ switch (message.type) {
+ case "msg":
+ addMessage(message.nick, message.text, message.timestamp);
+ break;
- case "join":
- userJoin(message.nick, message.timestamp);
- break;
+ case "join":
+ userJoin(message.nick, message.timestamp);
+ break;
- case "part":
- userPart(message.nick, message.timestamp);
- break;
- }
+ case "part":
+ userPart(message.nick, message.timestamp);
+ break;
}
}
+ if (first_poll) {
+ first_poll = false;
+ who();
+ }
}
$.ajax({ cache: false
@@ -206,11 +209,11 @@ function longPoll (data) {
, data: { since: CONFIG.last_message_time, id: CONFIG.id }
, error: function () {
addMessage("", "long poll error. trying again...", new Date(), "error");
- longPollErrors += 1;
+ transmission_errors += 1;
setTimeout(longPoll, 10*1000);
}
, success: function (data) {
- longPollErrors = 0;
+ transmission_errors = 0;
longPoll(data);
}
});
@@ -321,7 +324,7 @@ $(document).ready(function() {
// remove fixtures
$("#log table").remove();
- who(longPoll);
+ longPoll();
showConnect();
});
View
@@ -45,7 +45,6 @@ a:hover { text-decoration: underline; color: #aaa; }
border: 0;
}
-
#toolbar {
position: fixed;
color: #fff;
@@ -60,6 +59,7 @@ a:hover { text-decoration: underline; color: #aaa; }
padding: 1em;
margin: 0;
border-width: 0;
+ outline-width: 0;
clear: both;
}
@@ -73,6 +73,7 @@ a:hover { text-decoration: underline; color: #aaa; }
/* not very important info */
.notice td, .join td, .part td, .message .date { color: #555; }
+.date { font-size: 80%; }
.error td { color: #933; }
.personal .nick, .notice .nick { color: #cd5; }
@@ -102,5 +103,5 @@ a:hover { text-decoration: underline; color: #aaa; }
#toolbar li {
display: block;
float: left;
- margin: 0 0.5em;
+ margin: 0 0.5em 0 0;
}

0 comments on commit e8380ec

Please sign in to comment.