Reading data from network objects rather than gateway, etc
authorDarren <darren@Darrens-MacBook-Pro.local>
Tue, 23 Apr 2013 22:55:55 +0000 (23:55 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Tue, 23 Apr 2013 22:55:55 +0000 (23:55 +0100)
client/assets/dev/model_application.js
client/assets/dev/model_panellist.js
client/assets/dev/view.js

index cd7cd959796d0427c2c682f753630254a168549e..dcae63ff7a0ffb6f6ebc385073ea2c31fe03c541 100644 (file)
@@ -296,6 +296,14 @@ _kiwi.model.Application = function () {
         };\r
 \r
 \r
+        // Clicking a tab\r
+        this.onPanelActive = function (panel, connection) {\r
+            this.panels = connection.panels;\r
+            this.active_connection = connection;\r
+            console.log('Active connection:', connection.get('connection_id'), 'Active panel:', panel.get('name'));\r
+        };\r
+\r
+\r
         this.bindGatewayCommands = function (gw) {\r
             gw.on('onconnect', function (event) {\r
                 that.view.barsShow();\r
@@ -600,7 +608,7 @@ _kiwi.model.Application = function () {
 \r
             ev.params.shift();\r
 \r
-            panel.addMsg(_kiwi.gateway.get('nick'), ev.params.join(' '));\r
+            panel.addMsg(_kiwi.app.connections.active_connection.get('nick'), ev.params.join(' '));\r
             _kiwi.gateway.privmsg(destination, ev.params.join(' '));\r
         }\r
 \r
@@ -610,7 +618,7 @@ _kiwi.model.Application = function () {
             }\r
 \r
             var panel = _kiwi.app.panels.active;\r
-            panel.addMsg('', '* ' + _kiwi.gateway.get('nick') + ' ' + ev.params.join(' '), 'action');\r
+            panel.addMsg('', '* ' + _kiwi.app.connections.active_connection.get('nick') + ' ' + ev.params.join(' '), 'action');\r
             _kiwi.gateway.action(panel.get('name'), ev.params.join(' '));\r
         }\r
 \r
index 01cc1e3ea9b9f6a8bd12260935b2a111f3722eb1..46cdaebf1ea825353b5d3ee772887cd5ce66f87f 100644 (file)
@@ -53,19 +53,18 @@ _kiwi.model.NetworkPanelList = Backbone.Collection.extend({
 \r
 \r
     onNetworkAdd: function(network) {\r
-        network.panels.on('active', this.onActive, this);\r
+        network.panels.on('active', this.onPanelActive, this);\r
     },\r
 \r
     onNetworkRemove: function(network) {\r
-        network.panels.off('active', this.onActive, this);\r
+        network.panels.off('active', this.onPanelActive, this);\r
     },\r
 \r
-    onActive: function(panel) {\r
+    onPanelActive: function(panel) {\r
         var connection = this.getByConnectionId(panel.tab.data('connection_id'));\r
         this.trigger('active', panel, connection);\r
 \r
         this.active_connection = connection;\r
         this.active = panel;\r
-        console.log('Active connection:', connection.get('connection_id'), 'Active panel:', panel.get('name'));\r
     }\r
 });
\ No newline at end of file
index ca56aa51a01bc6e39de2210fcadee8e3e54b862f..fdb958488f5cc860cdf913157ab034c8669bcd83 100644 (file)
@@ -37,7 +37,7 @@ _kiwi.view.MemberList = Backbone.View.extend({
         userbox.member = member;\r
         userbox.channel = this.model.channel;\r
 \r
-        if (!this.model.getByNick(_kiwi.gateway.get('nick')).get('is_op')) {\r
+        if (!this.model.getByNick(_kiwi.app.connections.active_connection.get('nick')).get('is_op')) {\r
             userbox.$el.children('.if_op').remove();\r
         }\r
 \r
@@ -387,7 +387,7 @@ _kiwi.view.Panel = Backbone.View.extend({
             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
+        if ((new RegExp('\\b' + _kiwi.app.connections.active_connection.get('nick') + '\\b', 'i')).test(msg.msg)) {\r
             is_highlight = true;\r
             msg_css_classes += ' highlight';\r
         }\r
@@ -482,7 +482,7 @@ _kiwi.view.Panel = Backbone.View.extend({
         (function () {\r
             // Only inrement the counters if we're not the active panel\r
             if (this.model.isActive()) return;\r
-\r
+console.log('Updating activity');\r
             var $act = this.model.tab.find('.activity');\r
             $act.text((parseInt($act.text(), 10) || 0) + 1);\r
             if ($act.text() === '0') {\r
@@ -1042,7 +1042,7 @@ _kiwi.view.ControlBox = Backbone.View.extend({
         }\r
 \r
         // Process the raw command for any aliases\r
-        this.preprocessor.vars.server = _kiwi.gateway.get('name');\r
+        this.preprocessor.vars.server = _kiwi.app.connections.active_connection.get('name');\r
         this.preprocessor.vars.channel = _kiwi.app.panels.active.get('name');\r
         this.preprocessor.vars.destination = this.preprocessor.vars.channel;\r
         command_raw = this.preprocessor.process(command_raw);\r