line_msg = '<div class="msg <%= type %>"><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
+ kiwi.app.view.alertWindow('* People are talking!');\r
this.alert('highlight');\r
} else {\r
+ // If this is the active panel, send an alert out\r
+ if (this.model.isActive()) {\r
+ kiwi.app.view.alertWindow('* People are talking!');\r
+ }\r
this.alert('activity');\r
}\r
\r
},\r
\r
\r
+ alertWindow: function (title) {\r
+ if (!this.alertWindowTimer) {\r
+ this.alertWindowTimer = new (function () {\r
+ var that = this;\r
+ var tmr;\r
+ var has_focus = true;\r
+ var state = 0;\r
+ var default_title = 'Kiwi IRC';\r
+ var title = 'Kiwi IRC';\r
+\r
+ this.setTitle = function (new_title) {\r
+ new_title = new_title || default_title;\r
+ window.document.title = new_title;\r
+ return new_title;\r
+ };\r
+\r
+ this.start = function (new_title) {\r
+ // Don't alert if we already have focus\r
+ if (has_focus) return;\r
+\r
+ title = new_title;\r
+ if (tmr) return;\r
+ tmr = setInterval(this.update, 1000);\r
+ };\r
+\r
+ this.stop = function () {\r
+ // Stop the timer and clear the title\r
+ if (tmr) clearInterval(tmr);\r
+ tmr = null;\r
+ this.setTitle();\r
+\r
+ // Some browsers don't always update the last title correctly\r
+ // Wait a few seconds and then reset\r
+ setTimeout(this.reset, 2000);\r
+ };\r
+\r
+ this.reset = function () {\r
+ if (tmr) return;\r
+ that.setTitle();\r
+ };\r
+\r
+\r
+ this.update = function () {\r
+ if (state === 0) {\r
+ that.setTitle(title);\r
+ state = 1;\r
+ } else {\r
+ that.setTitle();\r
+ state = 0;\r
+ }\r
+ };\r
+\r
+ $(window).focus(function (event) {\r
+ has_focus = true;\r
+ that.stop();\r
+\r
+ // Some browsers don't always update the last title correctly\r
+ // Wait a few seconds and then reset\r
+ setTimeout(this.reset, 2000);\r
+ });\r
+\r
+ $(window).blur(function (event) {\r
+ has_focus = false;\r
+ });\r
+ })();\r
+ }\r
+\r
+ this.alertWindowTimer.start(title);\r
+ },\r
+\r
+\r
barsHide: function (instant) {\r
var that = this;\r
\r