X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=client%2Fassets%2Fdev%2Fmodel_gateway.js;h=c06b39cc3dd8c83e8792b3bbeb7959ad37235370;hb=f30912776d57471aec36a9ba6ccf66639ee88e95;hp=c9ccf016d33060ae97eb06ba4d6a5ea40b8127b4;hpb=8913f3eacdc639b6cb1648621ad671f09fbbc9ae;p=KiwiIRC.git diff --git a/client/assets/dev/model_gateway.js b/client/assets/dev/model_gateway.js index c9ccf01..c06b39c 100644 --- a/client/assets/dev/model_gateway.js +++ b/client/assets/dev/model_gateway.js @@ -38,7 +38,13 @@ _kiwi.model.Gateway = function () { * The URL to the Kiwi server * @type String */ - kiwi_server: '//kiwi' + kiwi_server: '//kiwi', + + /** + * List of nicks we are ignoring + * @type Array + */ + ignore_list: [] }; @@ -54,9 +60,8 @@ _kiwi.model.Gateway = function () { this.applyEventHandlers = function () { /* - TODO: Impliment event 'groups' to remove a listener group - kiwi.gateway.on('msg:#channel', my_function); - kiwi.gateway.on('msg:somenick', my_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); @@ -112,6 +117,13 @@ _kiwi.model.Gateway = function () { 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); + }); + }; @@ -218,7 +230,8 @@ _kiwi.model.Gateway = function () { this.parseKiwi = function (command, data) { - console.log('kiwi event', command, data); + this.trigger('kiwi:' + command, data); + this.trigger('kiwi', data); }; /* Events: @@ -508,5 +521,23 @@ _kiwi.model.Gateway = function () { }; + // Check a nick alongside our ignore list + this.isNickIgnored = function (nick) { + var idx, list = this.get('ignore_list'); + var pattern, regex; + + for (idx = 0; idx < list.length; idx++) { + pattern = list[idx].replace(/([.+^$[\]\\(){}|-])/g, "\\$1") + .replace('*', '.*') + .replace('?', '.'); + + regex = new RegExp(pattern, 'i'); + if (regex.test(nick)) return true; + } + + return false; + } + + return new (Backbone.Model.extend(this))(arguments); }; \ No newline at end of file