Sending notices; Improved notice handling
authorDarren <darren@darrenwhitlen.com>
Sat, 25 Aug 2012 21:35:41 +0000 (22:35 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 25 Aug 2012 21:35:41 +0000 (22:35 +0100)
client_backbone/model_application.js

index 9732d158a812914a9e506ffdd8f4b01beae0a9c3..a6beac06187fcab4f8d30fca80939b4be328a6ca 100644 (file)
@@ -124,7 +124,16 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
 \r
 \r
         gw.on('onnotice', function (event) {\r
-            kiwi.app.panels.server.addMsg('', event.msg, 'notice');\r
+            var panel;\r
+\r
+            // If a panel isn't found for this channel, reroute to the\r
+            // server panel\r
+            panel = that.panels.getByName(event.target);\r
+            if (!panel) {\r
+                panel = that.panels.server;\r
+            }\r
+\r
+            panel.addMsg('[' + (event.nick||'') + ']', event.msg);\r
         });\r
 \r
 \r
@@ -242,6 +251,8 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
 \r
         controlbox.on('command_topic', this.topicCommand);\r
 \r
+        controlbox.on('command_notice', this.noticeCommand);\r
+\r
         controlbox.on('command_css', function (ev) {\r
             var queryString = '?reload=' + new Date().getTime();\r
             $('link[rel="stylesheet"]').each(function () {\r
@@ -312,6 +323,18 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
         kiwi.gateway.topic(channel_name, ev.params.join(' '));\r
     };\r
 \r
+    this.noticeCommand = function (ev) {\r
+        var destination;\r
+\r
+        // Make sure we have a destination and some sort of message\r
+        if (ev.params.length <= 1) return;\r
+\r
+        destination = ev.params[0];\r
+        ev.params.shift();\r
+\r
+        kiwi.gateway.notice(destination, ev.params.join(' '));\r
+    };\r
+\r
 \r
 \r
 \r