newMsg: function (msg) {\r
// TODO: make sure that the message pane is scrolled to the bottom (Or do we? ~Darren)\r
var re, line_msg, $this = this.$el,\r
- nick_colour_hex, nick_hex;\r
+ nick_colour_hex, nick_hex, is_highlight, msg_css_classes = '';\r
+\r
+ // Nick highlight detecting\r
+ if ((new RegExp('\\b' + _kiwi.gateway.get('nick') + '\\b', 'i')).test(msg.msg)) {\r
+ is_highlight = true;\r
+ msg_css_classes += ' highlight';\r
+ }\r
\r
// Escape any HTML that may be in here\r
msg.msg = $('<div />').text(msg.msg).html();\r
_.map(msg.nick.split(''), function (char) {\r
nick_hex += char.charCodeAt(0).toString(16);\r
});\r
- msg.nick_css_class = 'nick_' + nick_hex;\r
+ msg_css_classes += ' nick_' + nick_hex;\r
}\r
\r
// Build up and add the line\r
- line_msg = '<div class="msg <%= type %> <%= nick_css_class %>"><div class="time"><%- time %></div><div class="nick" style="<%= nick_style %>"><%- nick %></div><div class="text" style="<%= style %>"><%= msg %> </div></div>';\r
+ msg.msg_css_classes = msg_css_classes;\r
+ line_msg = '<div class="msg <%= type %> <%= msg_css_classes %>"><div class="time"><%- time %></div><div class="nick" style="<%= nick_style %>"><%- nick %></div><div class="text" style="<%= style %>"><%= msg %> </div></div>';\r
$this.append(_.template(line_msg, msg));\r
\r
// Activity/alerts based on the type of new message\r
if (msg.type.match(/^action /)) {\r
this.alert('action');\r
- } else if (msg.msg.indexOf(_kiwi.gateway.get('nick')) > -1) {\r
+ } else if (is_highlight) {\r
_kiwi.app.view.alertWindow('* People are talking!');\r
this.alert('highlight');\r
} else {\r