From: Darren Date: Sat, 25 Aug 2012 21:10:14 +0000 (+0100) Subject: Improved nick [ident@host] display X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3caebe4899beddc81eef32dca20b1019d67918e1;p=KiwiIRC.git Improved nick [ident@host] display --- diff --git a/client_backbone/model.js b/client_backbone/model.js index 4009cd0..55f23ac 100644 --- a/client_backbone/model.js +++ b/client_backbone/model.js @@ -115,7 +115,7 @@ kiwi.model.Member = Backbone.Model.extend({ modes = _.reject(modes, function (m) { return (modes_to_remove.indexOf(m) !== -1); }); - + this.set({"prefix": this.getPrefix(modes), "modes": modes}); }, getPrefix: function (modes) { @@ -145,6 +145,17 @@ kiwi.model.Member = Backbone.Model.extend({ } return tmp.substr(i); + }, + displayNick: function (full) { + var display = this.get('nick'); + + if (full) { + if (this.get("ident")) { + display += ' [' + this.get("ident") + '@' + this.get("hostname") + ']'; + } + } + + return display; } }); @@ -290,22 +301,17 @@ kiwi.model.Channel = kiwi.model.Panel.extend({ "topic": "" }, {"silent": true}); - //this.addMsg(' ', '--> You have joined ' + name, 'action join', {style: 'color:#009900;'}); - members = this.get("members"); members.bind("add", function (member) { - var disp = member.get("nick") + ' [' + member.get("ident") + '@' + member.get("hostname") + ']'; - this.addMsg(' ', '--> ' + disp + ' has joined', 'action join'); + this.addMsg(' ', '--> ' + member.displayNick(true) + ' has joined', 'action join'); }, this); members.bind("remove", function (member, options) { - var disp = member.get("nick") + ' [' + member.get("ident") + '@' + member.get("hostname") + ']'; - this.addMsg(' ', '<-- ' + disp + ' has left ' + ((options.message) ? '(' + options.message + ')' : ''), 'action part'); + this.addMsg(' ', '<-- ' + member.displayNick(true) + ' has left ' + ((options.message) ? '(' + options.message + ')' : ''), 'action part'); }, this); members.bind("quit", function (args) { - var disp = member.get("nick") + ' [' + member.get("ident") + '@' + member.get("hostname") + ']'; - this.addMsg(' ', '<-- ' + disp + ' has quit ' + ((args.message) ? '(' + args.message + ')' : ''), 'action quit'); + this.addMsg(' ', '<-- ' + member.displayNick(true) + ' has quit ' + ((args.message) ? '(' + args.message + ')' : ''), 'action quit'); }, this); } });