Browse files

Add nick highlighting

  • Loading branch information...
1 parent 7859662 commit 0d46ca9ea6ccebfb216e3f647f0b11654aa7842b @ry ry committed Jun 2, 2009
Showing with 17 additions and 8 deletions.
  1. +16 −7 client.js
  2. +1 −1 style.css
View
23 client.js
@@ -40,29 +40,38 @@ function scrollDown () {
$("#entry").focus();
}
-function addMessage (from, message, time, _class) {
- if (message === null)
+function addMessage (from, text, time, _class) {
+ if (text === null)
return;
if (time !== null)
time = new Date();
- message = util.toStaticHTML(message); // first sanitize
- message = message.replace(util.urlRE, '<a target="_blank" href="$&">$&</a>');
-
var messageElement = $(document.createElement("table"));
- messageElement.addClass("message");
+ messageElement.addClass("text");
if (_class)
messageElement.addClass(_class);
+ // sanitize
+ text = util.toStaticHTML(text);
+
+ // See if it matches our nick?
+ var nick_re = new RegExp(CONFIG.nick);
+ if (nick_re.exec(text))
+ messageElement.addClass("personal");
+
+ // replace URLs with links
+ text = text.replace(util.urlRE, '<a target="_blank" href="$&">$&</a>');
+
var content = '<tr>'
+ ' <td class="date">' + util.timeString(time) + '</td>'
+ ' <td class="nick">' + util.toStaticHTML(from) + '</td>'
- + ' <td class="msg-text">' + message + '</td>'
+ + ' <td class="msg-text">' + text + '</td>'
+ '</tr>'
;
messageElement.html(content);
+
$("#log").append(messageElement);
scrollDown();
}
View
2 style.css
@@ -97,7 +97,7 @@ form.horizontal .field label {display: inline; float: left; width: 140px; margin
}
/* not very important info */
-.rename td, .join td, .part td, .message .date { color: #444; }
+.rename td, .join td, .part td, .message .date { color: #555; }
.message {
margin: 0.1em 0;

0 comments on commit 0d46ca9

Please sign in to comment.