From e4de46481786d15ce66fa1bafe99b0bfe89500cd Mon Sep 17 00:00:00 2001 From: Darren Date: Tue, 23 Apr 2013 23:55:55 +0100 Subject: [PATCH] Reading data from network objects rather than gateway, etc --- client/assets/dev/model_application.js | 12 ++++++++++-- client/assets/dev/model_panellist.js | 7 +++---- client/assets/dev/view.js | 8 ++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/client/assets/dev/model_application.js b/client/assets/dev/model_application.js index cd7cd95..dcae63f 100644 --- a/client/assets/dev/model_application.js +++ b/client/assets/dev/model_application.js @@ -296,6 +296,14 @@ _kiwi.model.Application = function () { }; + // Clicking a tab + this.onPanelActive = function (panel, connection) { + this.panels = connection.panels; + this.active_connection = connection; + console.log('Active connection:', connection.get('connection_id'), 'Active panel:', panel.get('name')); + }; + + this.bindGatewayCommands = function (gw) { gw.on('onconnect', function (event) { that.view.barsShow(); @@ -600,7 +608,7 @@ _kiwi.model.Application = function () { ev.params.shift(); - panel.addMsg(_kiwi.gateway.get('nick'), ev.params.join(' ')); + panel.addMsg(_kiwi.app.connections.active_connection.get('nick'), ev.params.join(' ')); _kiwi.gateway.privmsg(destination, ev.params.join(' ')); } @@ -610,7 +618,7 @@ _kiwi.model.Application = function () { } var panel = _kiwi.app.panels.active; - panel.addMsg('', '* ' + _kiwi.gateway.get('nick') + ' ' + ev.params.join(' '), 'action'); + panel.addMsg('', '* ' + _kiwi.app.connections.active_connection.get('nick') + ' ' + ev.params.join(' '), 'action'); _kiwi.gateway.action(panel.get('name'), ev.params.join(' ')); } diff --git a/client/assets/dev/model_panellist.js b/client/assets/dev/model_panellist.js index 01cc1e3..46cdaeb 100644 --- a/client/assets/dev/model_panellist.js +++ b/client/assets/dev/model_panellist.js @@ -53,19 +53,18 @@ _kiwi.model.NetworkPanelList = Backbone.Collection.extend({ onNetworkAdd: function(network) { - network.panels.on('active', this.onActive, this); + network.panels.on('active', this.onPanelActive, this); }, onNetworkRemove: function(network) { - network.panels.off('active', this.onActive, this); + network.panels.off('active', this.onPanelActive, this); }, - onActive: function(panel) { + onPanelActive: function(panel) { var connection = this.getByConnectionId(panel.tab.data('connection_id')); this.trigger('active', panel, connection); this.active_connection = connection; this.active = panel; - console.log('Active connection:', connection.get('connection_id'), 'Active panel:', panel.get('name')); } }); \ No newline at end of file diff --git a/client/assets/dev/view.js b/client/assets/dev/view.js index ca56aa5..fdb9584 100644 --- a/client/assets/dev/view.js +++ b/client/assets/dev/view.js @@ -37,7 +37,7 @@ _kiwi.view.MemberList = Backbone.View.extend({ userbox.member = member; userbox.channel = this.model.channel; - if (!this.model.getByNick(_kiwi.gateway.get('nick')).get('is_op')) { + if (!this.model.getByNick(_kiwi.app.connections.active_connection.get('nick')).get('is_op')) { userbox.$el.children('.if_op').remove(); } @@ -387,7 +387,7 @@ _kiwi.view.Panel = Backbone.View.extend({ nick_colour_hex, nick_hex, is_highlight, msg_css_classes = ''; // Nick highlight detecting - if ((new RegExp('\\b' + _kiwi.gateway.get('nick') + '\\b', 'i')).test(msg.msg)) { + if ((new RegExp('\\b' + _kiwi.app.connections.active_connection.get('nick') + '\\b', 'i')).test(msg.msg)) { is_highlight = true; msg_css_classes += ' highlight'; } @@ -482,7 +482,7 @@ _kiwi.view.Panel = Backbone.View.extend({ (function () { // Only inrement the counters if we're not the active panel if (this.model.isActive()) return; - +console.log('Updating activity'); var $act = this.model.tab.find('.activity'); $act.text((parseInt($act.text(), 10) || 0) + 1); if ($act.text() === '0') { @@ -1042,7 +1042,7 @@ _kiwi.view.ControlBox = Backbone.View.extend({ } // Process the raw command for any aliases - this.preprocessor.vars.server = _kiwi.gateway.get('name'); + this.preprocessor.vars.server = _kiwi.app.connections.active_connection.get('name'); this.preprocessor.vars.channel = _kiwi.app.panels.active.get('name'); this.preprocessor.vars.destination = this.preprocessor.vars.channel; command_raw = this.preprocessor.process(command_raw); -- 2.25.1