_kiwi.model.Member = Backbone.Model.extend({\r
sortModes: function (modes) {\r
+ var that = this;\r
+\r
return modes.sort(function (a, b) {\r
var a_idx, b_idx, i;\r
- var user_prefixes = _kiwi.gateway.get('user_prefixes');\r
+ var user_prefixes = that.get('user_prefixes');\r
\r
for (i = 0; i < user_prefixes.length; i++) {\r
if (user_prefixes[i].mode === a) {\r
},\r
getPrefix: function (modes) {\r
var prefix = '';\r
- var user_prefixes = _kiwi.gateway.get('user_prefixes');\r
+ var user_prefixes = this.get('user_prefixes');\r
\r
if (typeof modes[0] !== 'undefined') {\r
prefix = _.detect(user_prefixes, function (prefix) {\r
},\r
stripPrefix: function (nick) {\r
var tmp = nick, i, j, k, nick_char;\r
- var user_prefixes = _kiwi.gateway.get('user_prefixes');\r
+ var user_prefixes = this.get('user_prefixes');\r
i = 0;\r
\r
nick_character_loop:\r
return display;\r
},\r
isOp: function () {\r
- var user_prefixes = _kiwi.gateway.get('user_prefixes'),\r
+ var user_prefixes = this.get('user_prefixes'),\r
modes = this.get('modes'),\r
o, max_mode;\r
if (modes.length > 0) {\r
members = c.get('members');
if (!members) return;
- user = new _kiwi.model.Member({nick: event.nick, ident: event.ident, hostname: event.hostname});
+ user = new _kiwi.model.Member({
+ nick: event.nick,
+ ident: event.ident,
+ hostname: event.hostname,
+ user_prefixes: this.get('user_prefixes')
+ });
members.add(user, {kiwi: event});
}
function onUserlist(event) {
- var channel;
- channel = this.panels.getByName(event.channel);
+ var that = this,
+ channel = this.panels.getByName(event.channel);
// If we didn't find a channel for this, may aswell leave
if (!channel) return;
channel.temp_userlist = channel.temp_userlist || [];
_.each(event.users, function (item) {
- var user = new _kiwi.model.Member({nick: item.nick, modes: item.modes});
+ var user = new _kiwi.model.Member({
+ nick: item.nick,
+ modes: item.modes,
+ user_prefixes: that.get('user_prefixes')
+ });
channel.temp_userlist.push(user);
});
}