// Best guess at where the kiwi server is\r
this.detectKiwiServer();\r
\r
- // Holds instances of model_network\r
+ // Takes instances of model_network\r
this.connections = new _kiwi.model.NetworkPanelList();\r
+ this.connections.on('active', this.onPanelActive, this);\r
\r
// The active network (reference to a this.connections element)\r
this.active_connection = null;\r
};\r
\r
+\r
this.start = function () {\r
// Only debug if set in the querystring\r
if (!getQueryVariable('debug')) {\r
* @param {Function} callback A callback function\r
*/\r
this.sendData = function (data, callback) {\r
- this.socket.emit('irc', {server: _kiwi.app.connections.active.get('connection_id'), data: JSON.stringify(data)}, callback);\r
+ var data_buffer = {\r
+ server: _kiwi.app.connections.active_connection.get('connection_id'),\r
+ data: JSON.stringify(data)\r
+ };\r
+ \r
+ this.socket.emit('irc', data_buffer, callback);\r
};\r
\r
/**\r
}, this);
this.gateway.on('nick', function(event) {
- if (event.nick === event.get('nick')) {
+ if (event.nick === this.get('nick')) {
this.set('nick', event.newnick);
}
}, this);
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
- this.active = connection;\r
- connection.panels.active = panel;\r
- \r
- _kiwi.app.panels = connection.panels;\r
}\r
});
\ No newline at end of file
// Hold tab autocomplete data\r
this.tabcomplete = {active: false, data: [], prefix: ''};\r
\r
- _kiwi.gateway.bind('change:nick', function () {\r
- $('.nick', that.$el).text(this.get('nick'));\r
+ // When we get any nick change event for any connection, update our view just incase it's us\r
+ _kiwi.gateway.bind('onnick', function (event) {\r
+ $('.nick', that.$el).text(_kiwi.app.connections.active_connection.get('nick'));\r
+ });\r
+ _kiwi.gateway.bind('onconnect', function (event) {\r
+ $('.nick', that.$el).text(event.nick);\r
});\r
\r
+ // Update our nick view as we flick between connections\r
_kiwi.app.connections.on('active', function(panel, connection) {\r
$('.nick', that.$el).text(connection.get('nick'));\r
});\r