From 7aa199332cbd89c9a65d1b89b137977ce46c15a7 Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 10 May 2014 13:15:03 +0100 Subject: [PATCH] Clients side IRC event names normalised --- client/src/applets/chanlist.js | 4 +- client/src/models/application.js | 4 +- client/src/models/gateway.js | 78 ++------------------------------ client/src/views/serverselect.js | 8 ++-- 4 files changed, 11 insertions(+), 83 deletions(-) diff --git a/client/src/applets/chanlist.js b/client/src/applets/chanlist.js index 8c286fd..bad0bc4 100644 --- a/client/src/applets/chanlist.js +++ b/client/src/applets/chanlist.js @@ -147,8 +147,8 @@ this.view = new View(); this.network = _kiwi.global.components.Network(); - this.network.on('onlist_channel', this.onListChannel, this); - this.network.on('onlist_start', this.onListStart, this); + this.network.on('list_channel', this.onListChannel, this); + this.network.on('list_start', this.onListStart, this); }, diff --git a/client/src/models/application.js b/client/src/models/application.js index 82547fa..74c258d 100644 --- a/client/src/models/application.js +++ b/client/src/models/application.js @@ -167,7 +167,7 @@ bindGatewayCommands: function (gw) { var that = this; - gw.on('onconnect', function (event) { + gw.on('connect', function (event) { that.view.barsShow(); }); @@ -218,7 +218,7 @@ }); - gw.on('onconnect', function (event) { + gw.on('connect', function (event) { that.view.$el.addClass('connected'); if (gw_stat !== 1) return; diff --git a/client/src/models/gateway.js b/client/src/models/gateway.js index f72e940..97edc3e 100644 --- a/client/src/models/gateway.js +++ b/client/src/models/gateway.js @@ -9,84 +9,11 @@ _kiwi.model.Gateway = function () { // For ease of access. The socket.io object this.socket = this.get('socket'); - this.applyEventHandlers(); - // Used to check if a disconnection was unplanned this.disconnect_requested = false; }; - this.applyEventHandlers = function () { - /* - kiwi.gateway.on('message:#channel', my_function); - kiwi.gateway.on('message:somenick', my_function); - - kiwi.gateway.on('notice:#channel', my_function); - kiwi.gateway.on('action:somenick', my_function); - - kiwi.gateway.on('join:#channel', my_function); - kiwi.gateway.on('part:#channel', my_function); - kiwi.gateway.on('quit', my_function); - */ - var that = this; - - // Some easier handler events - this.on('onmsg', function (event) { - var source, - connection = _kiwi.app.connections.getByConnectionId(event.server), - is_pm = (event.target.toLowerCase() == connection.get('nick').toLowerCase()); - - source = is_pm ? event.nick : event.target; - - that.trigger('message:' + source, event); - that.trigger('message', event); - - if (is_pm) { - that.trigger('pm:' + source, event); - that.trigger('pm', event); - } - }, this); - - - this.on('onnotice', function (event) { - // The notice towards a channel or a query window? - var source = event.target || event.nick; - - this.trigger('notice:' + source, event); - this.trigger('notice', event); - }, this); - - - this.on('onaction', function (event) { - var source, - connection = _kiwi.app.connections.getByConnectionId(event.server), - is_pm = (event.target.toLowerCase() == connection.get('nick').toLowerCase()); - - source = is_pm ? event.nick : event.target; - - that.trigger('action:' + source, event); - - if (is_pm) { - that.trigger('action:' + source, event); - that.trigger('action', event); - } - }, this); - - - this.on('ontopic', function (event) { - that.trigger('topic:' + event.channel, event); - that.trigger('topic', event); - }); - - - this.on('onjoin', function (event) { - that.trigger('join:' + event.channel, event); - that.trigger('join', event); - }); - - }; - - this.reconnect = function (callback) { var that = this, @@ -347,6 +274,7 @@ _kiwi.model.Gateway = function () { } + // Trigger the connection specific events (used by Network objects) if (typeof data.server !== 'undefined') { that.trigger('connection:' + data.server.toString(), { event_name: command, @@ -354,8 +282,8 @@ _kiwi.model.Gateway = function () { }); } - // Trigger the global events (Mainly legacy now) - that.trigger('on' + command, data); + // Trigger the global events + that.trigger(command, data); }; /** diff --git a/client/src/views/serverselect.js b/client/src/views/serverselect.js index ded2203..271a372 100644 --- a/client/src/views/serverselect.js +++ b/client/src/views/serverselect.js @@ -42,16 +42,16 @@ _kiwi.view.ServerSelect = Backbone.View.extend({ this.more_shown = false; this.model.bind('new_network', this.newNetwork, this); - _kiwi.gateway.bind('onconnect', this.networkConnected, this); + _kiwi.gateway.bind('connect', this.networkConnected, this); _kiwi.gateway.bind('connecting', this.networkConnecting, this); - _kiwi.gateway.bind('onirc_error', this.onIrcError, this); + _kiwi.gateway.bind('irc_error', this.onIrcError, this); }, dispose: function() { this.model.off('new_network', this.newNetwork, this); - _kiwi.gateway.off('onconnect', this.networkConnected, this); + _kiwi.gateway.off('connect', this.networkConnected, this); _kiwi.gateway.off('connecting', this.networkConnecting, this); - _kiwi.gateway.off('onirc_error', this.onIrcError, this); + _kiwi.gateway.off('irc_error', this.onIrcError, this); this.remove(); }, -- 2.25.1