var channel = function(){ this.name = null; this.TS = null; this.topic = { 'setter': null, 'TS': null, 'text': null }; this.modes = {}; // indexed by mode name this.statusModes = {}; // indexed by UID this.listModes = {}; // indexed by mode name this.users = []; this.metadata = {}; this.events = {}; this.setEvents = function(events){ this.events = events; }; this.setTS = function(TS){ this.TS = TS; }; this.changeModes = function(modes){ for(var mode in modes){ if(mode == 'status'){ for(var i=0; i= 0; j--){ if(this.listModes[listMode.name][j] == listMode.value){ this.listModes[listMode.name].splice(j, 1); } } } this.events.doEvent('channelListMode', this, listMode); } } else { this.modes[mode] = modes[mode]; this.events.doEvent('channelModes', this); } } }; this.joinUser = function(user){ if(this.users.indexOf(user) >= 0) return; this.users.push(user); this.statusModes[user.uid] = {}; user.joinChannel(this); this.events.doEvent('channelJoin', this, user); }; this.removeUser = function(user){ if(user.uid in this.statusModes){ delete this.statusModes[user.uid]; // remove status modes for this user } for(var i=0; i