diff --git a/dist/chatterbox.js b/dist/chatterbox.js
index 588a286..a1c11d9 100644
--- a/dist/chatterbox.js
+++ b/dist/chatterbox.js
@@ -344,6 +344,13 @@ Chatterbox.UI.prototype.build = function( control, navigation, chatbook ) {
}
);
+ this.client.bind(
+ 'ns.set.privclasses',
+ function( event, client ) {
+ ui.channel( event.ns ).build_user_list( event.names, event.orders );
+ }
+ );
+
};
/**
diff --git a/dist/chatterbox.min.js b/dist/chatterbox.min.js
index f75668e..b638f23 100644
--- a/dist/chatterbox.min.js
+++ b/dist/chatterbox.min.js
@@ -2,13 +2,13 @@ var Chatterbox={};Chatterbox.VERSION="0.19.88";Chatterbox.STATE="beta";Chatterbo
scrollbarWidth=j.width()-h.width();j.add(h).remove()}else{var g=$("
").css({width:100,height:100,overflow:"auto",position:"absolute",top:-1000,left:-1000}).prependTo("body").append("").find("div").css({width:"100%",height:200});scrollbarWidth=100-g.width();g.parent().remove()}return scrollbarWidth})();this.LIB="Chatterbox";this.VERSION=Chatterbox.VERSION;this.STATE=Chatterbox.STATE};wsc.defaults.UI=Chatterbox.UI;Chatterbox.UI.prototype.trigger=function(a,b){this.events.emit(a,b,this)};Chatterbox.UI.prototype.on=function(b,a){this.events.addListener(b,a)};Chatterbox.UI.prototype.middle=function(a,b){return this.mw.add(a,b)};Chatterbox.UI.prototype.cascade=function(a,c,b){this.mw.run(a,c,b)};Chatterbox.UI.prototype.remove_listeners=function(){this.events.removeListeners()};Chatterbox.UI.prototype.deform_ns=function(a){if(a.indexOf("chat:")==0){return"#"+a.slice(5)}if(a.indexOf("server:")==0){return"~"+a.slice(7)}if(a.indexOf("pchat:")==0){var b=a.split(":");b.shift();for(i in b){name=b[i];
if(name.toLowerCase()!=this.lun){return"@"+name}}}if(a.indexOf("login:")==0){return"@"+a.slice(6)}if(a[0]!="#"&&a[0]!="@"&&a[0]!="~"){return"#"+a}return a};Chatterbox.UI.prototype.format_ns=function(a){if(a.indexOf("#")==0){return"chat:"+a.slice(1)}if(a.indexOf("@")==0){var b=[a.slice(1),this.lun];b.sort(caseInsensitiveSort);b.unshift("pchat");return b.join(":")}if(a.indexOf("~")==0){return"server:"+a.slice(1)}if(a.indexOf("chat:")!=0&&a.indexOf("server:")!=0&&a.indexOf("pchat:")!=0){return"chat:"+a}return a};Chatterbox.UI.prototype.set_events=function(a){this.events=a||this.events};Chatterbox.UI.prototype.clock=function(a){if(a===undefined||a==this.settings.clock){return this.settings.clock}this.settings.clock=a;this.chatbook.retime();return this.settings.clock};Chatterbox.UI.prototype.build=function(g,a,b){this.view.append(Chatterbox.render("ui",this.settings));this.control=new (g||Chatterbox.Control)(this);this.nav=new (a||Chatterbox.Navigation)(this);this.chatbook=new (b||Chatterbox.Chatbook)(this);
this.pager=new Chatterbox.Pager(this);this.monitoro=this.chatbook.create_channel(this.mns,this.settings.monitor[1],true);this.monitoro.show();this.control.focus();this.sound.bank.m=this.view.find("div.soundbank");this.sound.bank.c=this.sound.bank.m.find("audio.click")[0];this.sound.bank.c.load();var f=this.sound;this.sound.click=function(){f.play(f.bank.c)};var d=false;var c=this.nav.add_button({label:"",icon:"volume",href:"#mute",title:"Mute the client",handler:function(){if(!d){f.mute();c.removeClass("volume");c.addClass("volume_mute");c.prop("title","Unmute the client");d=true;return false}f.unmute();c.removeClass("volume_mute");c.addClass("volume");c.prop("title","Mute the client");d=false;return false}});var e=this;$(window).focus(function(){e.viewing=true});$(window).blur(function(){e.viewing=false});this.client.bind("pkt",function(j,h){e.packet(j,h)});this.client.middle("ns.remove",function(j,h){e.remove_channel(j.ns);h(j)});this.client.bind("ns.create",function(j,h){e.create_channel(j.chan.raw,j.chan.hidden);
-j.chan.ui=e.channel(j.ns)})};Chatterbox.UI.prototype.resize=function(){this.control.resize();this.view.height(this.view.parent().height());this.nav.resize();this.chatbook.resize(((this.view.parent().height()-this.nav.height())-this.control.height())-5)};Chatterbox.UI.prototype.loop=function(){this.chatbook.loop()};Chatterbox.UI.prototype.packet=function(b,a){var c=this;var d=a.protocol.log(b);if(d){if(this.settings.developer){console.log(">>>",b.sns,"|",d.text())}b.html=d.html();this.cascade("log_message",function(f,e){c.chatbook.log_message(f.message,f.event)},{message:d,event:b})}this.chatbook.handle(b,a)};Chatterbox.UI.prototype.create_channel=function(b,a){this.chatbook.create_channel(b,a)};Chatterbox.UI.prototype.remove_channel=function(a){this.chatbook.remove_channel(a)};Chatterbox.UI.prototype.toggle_channel=function(a){return this.chatbook.toggle_channel(a)};Chatterbox.UI.prototype.channel=function(a,b){return this.chatbook.channel(a,b)};Chatterbox.UI.prototype.channels=function(){return this.chatbook.channels()
-};Chatterbox.UI.prototype.channel_left=function(){this.chatbook.channel_left()};Chatterbox.UI.prototype.channel_right=function(){this.chatbook.channel_right()};Chatterbox.UI.prototype.monitor=function(b,a){this.monitoro.server_message(b,a)};Chatterbox.UI.prototype.server_message=function(b,a){this.chatbook.server_message(b,a)};Chatterbox.UI.prototype.log_item=function(a){this.chatbook.log_item(a)};Chatterbox.UI.prototype.log=function(a){this.chatbook.log(a)};Chatterbox.UI.prototype.mute_user=function(a){if(!a){return false}a=a.toLowerCase();if(this.umuted.indexOf(a)!=-1){return false}this.umuted.push(a);this.chatbook.each(function(b,c){c.mute_user(a)});return true};Chatterbox.UI.prototype.unmute_user=function(a){if(!a){return false}a=a.toLowerCase();var b=this.umuted.indexOf(a);if(b==-1){return false}this.umuted.splice(b,1);this.chatbook.each(function(c,d){d.unmute_user(a)});return true};Chatterbox.UI.prototype.clear_user=function(a){this.chatbook.each(function(b,c){c.clear_user(a)})};Chatterbox.UI.prototype.theme=function(a){if(this.settings.theme==a){return this.settings.theme
-}if(this.settings.themes.indexOf(a)==-1){a="wsct_"+a;if(this.settings.themes.indexOf(a)==-1){return this.settings.theme}}this.view.removeClass(this.settings.theme).addClass(a);this.settings.theme=a;this.trigger("theme.set",{name:"theme.set",theme:a});return this.settings.theme};Chatterbox.UI.prototype.add_theme=function(a){if(this.settings.themes.indexOf(a)>-1){return}this.settings.themes.push(a)};Chatterbox.UI.prototype.developer=function(a){this.settings.developer=a;this.chatbook.developer()};Chatterbox.Channel=function(d,b,c,a){this.manager=d;this.hidden=c;this.monitor=(a==undefined?false:a);this.built=false;this.raw=d.format_ns(b);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+d.deform_ns(b).slice(1).toLowerCase();this.namespace=d.deform_ns(b);this.visible=false;this.st=0;this.el={t:{o:null,l:null,c:null,},m:null,l:{p:null,w:null,},u:null,h:{title:null,topic:null}};this.mulw=0;this.d={u:[0,0],h:{title:[0,0],topic:[0,0]}}};Chatterbox.Channel.prototype.build=function(){if(this.built){return
-}var a=this.selector;var c=this.namespace;var b=this.raw;this.el.t.o=this.manager.nav.add_tab(a,c);this.el.t.l=this.el.t.o.find(".tab");this.el.t.c=this.el.t.o.find(".close");this.manager.chatbook.view.append(Chatterbox.render("channel",{selector:a,ns:c}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");this.el.l.p=this.el.m.find("#"+a+"-log");this.el.l.w=this.el.l.p.find("ul.logwrap");this.el.u=this.el.m.find("#"+a+"-users");this.mulw=parseInt(this.el.u.css("max-width").slice(0,-2));var d=this;var e=false;this.el.l.w.click(function(){if(!e){return}d.manager.control.focus()});this.el.l.w.mousedown(function(){e=true});this.el.l.w.mousemove(function(){e=false});this.el.t.l.click(function(){d.manager.toggle_channel(b);return false});this.el.t.c.click(function(f){d.manager.trigger("tab.close.clicked",{ns:d.raw,chan:d,e:f});return false});this.setup_header("title");this.setup_header("topic");if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")
-}this.manager.client.bind(this.namespace+".user.list",function(f){d.set_user_list(f.users)});this.manager.client.middle(this.namespace+".user.privchg",function(g,f){d.privchg(g,f)});this.manager.client.middle(this.namespace+".user.remove",function(g,f){d.remove_one_user(g,f)});this.manager.client.bind(this.namespace+".user.registered",function(f){d.register_user(f.user)});this.built=true};Chatterbox.Channel.prototype.setup_header=function(a){var c=this;var b={};b.m=this.el.m.find("header."+a+" div");b.e=this.el.m.find("header."+a+" a[href=#edit]");b.t=this.el.m.find("header."+a+" textarea");b.s=this.el.m.find("header."+a+" a[href=#save]");b.c=this.el.m.find("header."+a+" a[href=#cancel]");this.el.h[a]=b.m;b.m.parent().mouseover(function(f){if(!b.editing){b.e.css("display","block");return}b.s.css("display","block");b.c.css("display","block")});b.m.parent().mouseout(function(f){if(!b.editing){b.e.css("display","none");return}b.s.css("display","none");b.c.css("display","none")});b.e.click(function(f){b.t.text(c.manager.client.channel(c.namespace).info[a].content);
-b.t.css({display:"block",width:c.el.h[a].innerWidth()-10,});c.el.h[a].css("display","none");b.e.css("display","none");b.editing=true;c.resize();return false});var d=function(){var e=b.t.val();b.t.text("");b.t.css("display","none");c.el.h[a].css("display","block");b.s.css("display","none");b.c.css("display","none");b.editing=false;c.resize();return e};b.s.click(function(f){var g=d();c.manager.trigger(a+".save",{ns:c.raw,value:g});b.t.text("");return false});b.c.click(function(f){d();return false})};Chatterbox.Channel.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.Channel.prototype.show=function(){this.visible=true;this.el.m.css({display:"block"});this.el.t.o.addClass("active");this.el.t.o.removeClass("noise chatting tabbed fill");var a=this;setTimeout(function(){a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight());a.resize();a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight())
-},100)};Chatterbox.Channel.prototype.developer=function(){if(this.manager.settings.developer){this.el.t.o.removeClass("hidden");return}if(this.hidden){this.el.t.o.addClass("hidden")}};Chatterbox.Channel.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.Channel.prototype.scroll=function(){this.pad();var a=this.el.l.w.prop("scrollWidth")-this.el.l.w.innerWidth();var b=this.el.l.w.prop("scrollHeight")-this.el.l.w.innerHeight();if(a>0){b+=a}if(b<0||(b-this.el.l.w.scrollTop())>100){return}this.el.l.w.scrollTop(b)};Chatterbox.Channel.prototype.pad=function(){this.el.l.w.css({"padding-top":0,height:"auto"});var b=this.el.l.w.innerHeight();var a=this.el.l.p.innerHeight()-this.el.h.topic.parent().outerHeight();var c=a-b;if(c>0){this.el.l.w.css({"padding-top":c})}else{this.el.l.w.css({"padding-top":0,height:a})}this.el.l.w.scrollTop(this.st)};Chatterbox.Channel.prototype.resize=function(f,a){var g={title:{m:this.el.m.find("header div.title"),e:this.el.m.find("header.title a[href=#edit]")},topic:{m:this.el.m.find("header div.topic"),e:this.el.m.find("header.topic a[href=#edit]")}};
+j.chan.ui=e.channel(j.ns)});this.client.bind("ns.set.privclasses",function(j,h){e.channel(j.ns).build_user_list(j.names,j.orders)})};Chatterbox.UI.prototype.resize=function(){this.control.resize();this.view.height(this.view.parent().height());this.nav.resize();this.chatbook.resize(((this.view.parent().height()-this.nav.height())-this.control.height())-5)};Chatterbox.UI.prototype.loop=function(){this.chatbook.loop()};Chatterbox.UI.prototype.packet=function(b,a){var c=this;var d=a.protocol.log(b);if(d){if(this.settings.developer){console.log(">>>",b.sns,"|",d.text())}b.html=d.html();this.cascade("log_message",function(f,e){c.chatbook.log_message(f.message,f.event)},{message:d,event:b})}this.chatbook.handle(b,a)};Chatterbox.UI.prototype.create_channel=function(b,a){this.chatbook.create_channel(b,a)};Chatterbox.UI.prototype.remove_channel=function(a){this.chatbook.remove_channel(a)};Chatterbox.UI.prototype.toggle_channel=function(a){return this.chatbook.toggle_channel(a)};Chatterbox.UI.prototype.channel=function(a,b){return this.chatbook.channel(a,b)
+};Chatterbox.UI.prototype.channels=function(){return this.chatbook.channels()};Chatterbox.UI.prototype.channel_left=function(){this.chatbook.channel_left()};Chatterbox.UI.prototype.channel_right=function(){this.chatbook.channel_right()};Chatterbox.UI.prototype.monitor=function(b,a){this.monitoro.server_message(b,a)};Chatterbox.UI.prototype.server_message=function(b,a){this.chatbook.server_message(b,a)};Chatterbox.UI.prototype.log_item=function(a){this.chatbook.log_item(a)};Chatterbox.UI.prototype.log=function(a){this.chatbook.log(a)};Chatterbox.UI.prototype.mute_user=function(a){if(!a){return false}a=a.toLowerCase();if(this.umuted.indexOf(a)!=-1){return false}this.umuted.push(a);this.chatbook.each(function(b,c){c.mute_user(a)});return true};Chatterbox.UI.prototype.unmute_user=function(a){if(!a){return false}a=a.toLowerCase();var b=this.umuted.indexOf(a);if(b==-1){return false}this.umuted.splice(b,1);this.chatbook.each(function(c,d){d.unmute_user(a)});return true};Chatterbox.UI.prototype.clear_user=function(a){this.chatbook.each(function(b,c){c.clear_user(a)
+})};Chatterbox.UI.prototype.theme=function(a){if(this.settings.theme==a){return this.settings.theme}if(this.settings.themes.indexOf(a)==-1){a="wsct_"+a;if(this.settings.themes.indexOf(a)==-1){return this.settings.theme}}this.view.removeClass(this.settings.theme).addClass(a);this.settings.theme=a;this.trigger("theme.set",{name:"theme.set",theme:a});return this.settings.theme};Chatterbox.UI.prototype.add_theme=function(a){if(this.settings.themes.indexOf(a)>-1){return}this.settings.themes.push(a)};Chatterbox.UI.prototype.developer=function(a){this.settings.developer=a;this.chatbook.developer()};Chatterbox.Channel=function(d,b,c,a){this.manager=d;this.hidden=c;this.monitor=(a==undefined?false:a);this.built=false;this.raw=d.format_ns(b);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+d.deform_ns(b).slice(1).toLowerCase();this.namespace=d.deform_ns(b);this.visible=false;this.st=0;this.el={t:{o:null,l:null,c:null,},m:null,l:{p:null,w:null,},u:null,h:{title:null,topic:null}};this.mulw=0;
+this.d={u:[0,0],h:{title:[0,0],topic:[0,0]}}};Chatterbox.Channel.prototype.build=function(){if(this.built){return}var a=this.selector;var c=this.namespace;var b=this.raw;this.el.t.o=this.manager.nav.add_tab(a,c);this.el.t.l=this.el.t.o.find(".tab");this.el.t.c=this.el.t.o.find(".close");this.manager.chatbook.view.append(Chatterbox.render("channel",{selector:a,ns:c}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");this.el.l.p=this.el.m.find("#"+a+"-log");this.el.l.w=this.el.l.p.find("ul.logwrap");this.el.u=this.el.m.find("#"+a+"-users");this.mulw=parseInt(this.el.u.css("max-width").slice(0,-2));var d=this;var e=false;this.el.l.w.click(function(){if(!e){return}d.manager.control.focus()});this.el.l.w.mousedown(function(){e=true});this.el.l.w.mousemove(function(){e=false});this.el.t.l.click(function(){d.manager.toggle_channel(b);return false});this.el.t.c.click(function(f){d.manager.trigger("tab.close.clicked",{ns:d.raw,chan:d,e:f});return false});this.setup_header("title");
+this.setup_header("topic");if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")}this.manager.client.bind(this.namespace+".user.list",function(f){d.set_user_list(f.users)});this.manager.client.middle(this.namespace+".user.privchg",function(g,f){d.privchg(g,f)});this.manager.client.middle(this.namespace+".user.remove",function(g,f){d.remove_one_user(g,f)});this.manager.client.bind(this.namespace+".user.registered",function(f){d.register_user(f.user)});this.built=true};Chatterbox.Channel.prototype.setup_header=function(a){var c=this;var b={};b.m=this.el.m.find("header."+a+" div");b.e=this.el.m.find("header."+a+" a[href=#edit]");b.t=this.el.m.find("header."+a+" textarea");b.s=this.el.m.find("header."+a+" a[href=#save]");b.c=this.el.m.find("header."+a+" a[href=#cancel]");this.el.h[a]=b.m;b.m.parent().mouseover(function(f){if(!b.editing){b.e.css("display","block");return}b.s.css("display","block");b.c.css("display","block")});b.m.parent().mouseout(function(f){if(!b.editing){b.e.css("display","none");
+return}b.s.css("display","none");b.c.css("display","none")});b.e.click(function(f){b.t.text(c.manager.client.channel(c.namespace).info[a].content);b.t.css({display:"block",width:c.el.h[a].innerWidth()-10,});c.el.h[a].css("display","none");b.e.css("display","none");b.editing=true;c.resize();return false});var d=function(){var e=b.t.val();b.t.text("");b.t.css("display","none");c.el.h[a].css("display","block");b.s.css("display","none");b.c.css("display","none");b.editing=false;c.resize();return e};b.s.click(function(f){var g=d();c.manager.trigger(a+".save",{ns:c.raw,value:g});b.t.text("");return false});b.c.click(function(f){d();return false})};Chatterbox.Channel.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.Channel.prototype.show=function(){this.visible=true;this.el.m.css({display:"block"});this.el.t.o.addClass("active");this.el.t.o.removeClass("noise chatting tabbed fill");var a=this;setTimeout(function(){a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight());
+a.resize();a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight())},100)};Chatterbox.Channel.prototype.developer=function(){if(this.manager.settings.developer){this.el.t.o.removeClass("hidden");return}if(this.hidden){this.el.t.o.addClass("hidden")}};Chatterbox.Channel.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.Channel.prototype.scroll=function(){this.pad();var a=this.el.l.w.prop("scrollWidth")-this.el.l.w.innerWidth();var b=this.el.l.w.prop("scrollHeight")-this.el.l.w.innerHeight();if(a>0){b+=a}if(b<0||(b-this.el.l.w.scrollTop())>100){return}this.el.l.w.scrollTop(b)};Chatterbox.Channel.prototype.pad=function(){this.el.l.w.css({"padding-top":0,height:"auto"});var b=this.el.l.w.innerHeight();var a=this.el.l.p.innerHeight()-this.el.h.topic.parent().outerHeight();var c=a-b;if(c>0){this.el.l.w.css({"padding-top":c})}else{this.el.l.w.css({"padding-top":0,height:a})}this.el.l.w.scrollTop(this.st)};Chatterbox.Channel.prototype.resize=function(f,a){var g={title:{m:this.el.m.find("header div.title"),e:this.el.m.find("header.title a[href=#edit]")},topic:{m:this.el.m.find("header div.topic"),e:this.el.m.find("header.topic a[href=#edit]")}};
this.el.l.w.css({"padding-top":0});a=a||this.manager.chatbook.height();f=f||this.manager.chatbook.width();var c=a;this.el.m.height(c);this.el.m.css("width",f-10);var b=this.el.m.width();this.el.u.width(1);this.d.u[0]=this.el.u[0].scrollWidth+this.manager.swidth+5;if(this.d.u[0]>this.mulw){this.d.u[0]=this.mulw}this.el.u.width(this.d.u[0]);b=b-this.d.u[0];c=c-g.title.m.parent().outerHeight();this.el.l.p.css({height:c-3,width:b-10});this.scroll();this.d.u[1]=this.el.l.p.innerHeight();this.el.u.css({height:this.d.u[1]});for(var e in g){if(!g.hasOwnProperty(e)){continue}if(g[e].m.html().length==0){continue}var d=(g[e].m.outerHeight(true)-5)*(-1);g[e].e.css("top",d)}};Chatterbox.Channel.prototype.loop=function(){var a=this.el.l.p.find(".logmsg");if(a.length<200){return}a.slice(0,a.length-200).remove();this.resize()};Chatterbox.Channel.prototype.log=function(b){var a=this;this.manager.cascade("log",function(c){a.log_item({html:Chatterbox.render("logmsg",{message:c.message})})},{ns:this.raw,sns:this.namespace,message:b})
};Chatterbox.Channel.prototype.log_item=function(c){var a=new Date();var b="";if(this.manager.settings.clock){b=formatTime("{HH}:{mm}:{ss}",a)}else{b=formatTime("{hh}:{mm}:{ss} {mr}",a)}var d=this;this.manager.cascade("log_item",function(e){if(d.visible){d.st=d.el.l.w.scrollTop()}d.el.l.w.append(Chatterbox.render("logitem",e));d.manager.trigger("log_item.after",{item:d.el.l.w.find("li").last(),chan:d});if(d.visible){d.st+=d.el.l.w.find("li.logmsg").last().height();d.el.l.w.scrollTop(d.st)}d.scroll();d.noise()},{ns:this.namespace,ts:b,ms:a.getTime(),message:c.html,user:(c.user||"system").toLowerCase()})};Chatterbox.Channel.prototype.retime=function(){var a="";var b=this.el.l.w;if(this.manager.settings.clock){a="{HH}:{mm}:{ss}"}else{a="{hh}:{mm}:{ss} {mr}"}b.find("span.ts").each(function(c,d){el=b.find(d);time=new Date(parseInt(el.prop("id")));el.text(formatTime(a,time))})};Chatterbox.Channel.prototype.server_message=function(c,b){var a=this;this.manager.cascade("server_message",function(d){a.log_item({html:Chatterbox.render("servermsg",{message:d.message,info:d.info})})
},{ns:this.namespace,message:c,info:b})};Chatterbox.Channel.prototype.clear=function(){this.el.l.p.find("li.logmsg").remove();this.el.l.p.find("li.loginfo").remove();this.el.l.w.height(0);this.resize()};Chatterbox.Channel.prototype.log_info=function(e,d){var g={ns:this.namespace,ref:e,content:d};this.manager.trigger("log_info.before",g);delete g.ns;var a=this.el.l.w.append(Chatterbox.render("loginfobox",g));this.scroll();var f=this;var c=this.el.l.w.find("li."+g.ref);c.find("a.close").click(function(b){f.el.l.w.find(this).parent().remove();f.resize();return false});this.scroll();return c};Chatterbox.Channel.prototype.log_whois=function(j){var e={avatar:'',username:""+j.symbol+j.username+"",info:[],conns:[],raw:j,};for(var k in j.connections){var h=j.connections[k];var m=[];if(h.online){var a=(new Date-(h.online*1000));m.push(["online",DateStamp(a/1000)+formatTime(" [{HH}:{mm}:{ss}]",new Date(a))])}if(h.idle){m.push(["idle",timeLengthString(h.idle)])
diff --git a/dist/wsc.dAmn.js b/dist/wsc.dAmn.js
index d3725e4..c7db0f7 100644
--- a/dist/wsc.dAmn.js
+++ b/dist/wsc.dAmn.js
@@ -1026,8 +1026,12 @@ wsc.Channel = function( client, ns, hidden, monitor ) {
* @method build
*/
wsc.Channel.prototype.build = function( ) {
+
this.info.members = {};
- this.set_privclasses( { pkt: { body: '' } } );
+
+ if( this.namespace[0] == '@' )
+ this.set_privclasses( { pkt: { body: '' } } );
+
};
/**
@@ -1149,7 +1153,15 @@ wsc.Channel.prototype.set_privclasses = function( e ) {
var names = this.info.pc;
var orders = this.info.pc_order.slice(0);
- this.ui.build_user_list( names, orders );
+ this.client.trigger(
+ 'ns.set.privclasses',
+ {
+ name: 'ns.set.privclasses',
+ ns: this.namespace,
+ names: names,
+ orders: orders
+ }
+ );
};
/**
@@ -1212,7 +1224,7 @@ wsc.Channel.prototype.set_user_list = function( ) {
this.client.trigger(this.namespace + '.user.list', {
'name': 'set.userlist',
- 'ns': this.info['namespace'],
+ 'ns': this.namespace,
'users': users
});
};
@@ -4707,6 +4719,13 @@ Chatterbox.UI.prototype.build = function( control, navigation, chatbook ) {
}
);
+ this.client.bind(
+ 'ns.set.privclasses',
+ function( event, client ) {
+ ui.channel( event.ns ).build_user_list( event.names, event.orders );
+ }
+ );
+
};
/**
diff --git a/dist/wsc.dAmn.min.js b/dist/wsc.dAmn.min.js
index b65f07c..aaa8665 100644
--- a/dist/wsc.dAmn.min.js
+++ b/dist/wsc.dAmn.min.js
@@ -11,12 +11,12 @@ return((g>f)?1:(g11){mr="pm";if(hh>12){hh=hh-12}}else{if(hh==0){hh="12"}}b=replaceAll(b,"{hh}",zeroPad(hh,2));b=replaceAll(b,"{HH}",zeroPad(HH,2));b=replaceAll(b,"{mr}",mr);return b}function oxlist(a){last=a.pop();ret=a.join(", ");return ret+(ret.length>0?", and ":"")+last}function pluralise(b,a){return b+(a==1?"":"s")}function timeLengthString(f){if(f<=0){return"0 seconds."}var a=f;var g=[];g.unshift(["second",Math.round(a%60)]);a/=Math.round(60);g.unshift(["minute",Math.round(a%60)]);a/=Math.round(60);g.unshift(["hour",Math.round(a%24)]);a/=Math.round(24);g.unshift(["day",a]);var b=[];for(i in g){lapse=g[i];if(lapse[1]<1){continue}b.push(lapse[1].toString()+" "+pluralise(lapse[0],lapse[1]))}return oxlist(b)}function StringSet(a){this.items=a||[]}StringSet.prototype.add=function(b,a){if(!b){return false}b=b.toLowerCase();
if(this.contains(b)){return true}if(a){this.items.unshift(b)}else{this.items.push(b)}return true};StringSet.prototype.remove=function(a){if(!a){return false}a=a.toLowerCase();if(!this.contains(a)){return true}this.items.splice(this.items.indexOf(a),1);return true};StringSet.prototype.contains=function(a){if(!a){return false}return this.items.indexOf(a.toLowerCase())!=-1};wsc.Middleware=function(){this.callbacks={}};wsc.Middleware.prototype.add=function(b,f){var a=this.callbacks[b]||false;if(a===false){this.callbacks[b]=[]}this.callbacks[b].push(f);return this.callbacks[b].length};wsc.Middleware.prototype.run=function(b,h,f){var g=(this.callbacks[b]||[]).slice();g.push(h);var a=function(j){g.shift()(j,a)};a(f)};wsc.Storage=function(b,a){this.ns=b||null;this.parent=a||null};wsc.Storage.prototype.folder=function(a){if(this.ns!=null){a=this.ns+"."+a}return new wsc.Storage(a,this)};wsc.Storage.prototype.get=function(a,f){if(this.ns!=null){a=this.ns+"."+a}try{if(!localStorage.hasOwnProperty(a)){return f
}return localStorage[a]}catch(b){return f}};wsc.Storage.prototype.set=function(a,f){if(this.ns!=null){a=this.ns+"."+a}try{localStorage[a]=f}catch(b){}};wsc.Storage.prototype.remove=function(a){if(this.ns!=null){a=this.ns+"."+a}try{if(!localStorage.hasOwnProperty(a)){return false}return delete localStorage[a]}catch(b){}return false};var chains=[["recv","admin"]];wsc.Packet=function(g,j,a){if(!(g)){return null}if(a===undefined){a=true}j=j||"=";var b={cmd:null,param:null,arg:{},body:null,sub:[],raw:g};var l=null;var m=-1;try{m=g.indexOf("\n\n");if(m>-1){b.body=g.substr(m+2);g=g.substr(0,m)}l=g.split("\n");if(l[0].indexOf(j)==-1){cline=l.shift().split(" ");b.cmd=cline.shift()||null;b.param=cline.join(" ")||null}for(var f in l){arg=l[f];m=arg.search(j);if(m==-1){continue}b.arg[arg.substr(0,m)]=arg.substr(m+j.length)||""}if(b.body!=null&&a){subs=b.body.split("\n\n");for(var h in subs){sub=wsc.Packet(subs[h],j,false);if(sub==null){break}sub.body=subs.slice(h+1).join("\n\n");b.sub.push(sub)}}}catch(k){return null
-}b.toString=function(){return packetToString(b)};b.name=packetEvtName(b);return b};function wsc_packetstr(h,j,f,a){var b="";if(h){b=h;if(j){b=b+" "+j}}if(f){for(var g in f){b=b+"\n"+g+"="+f[g]}}b=b+"\n";if(a){b=b+"\n"+a}return b}function packetToString(a){return wsc_packetstr(a.cmd,a.param,a.arg,a.body)}function packetEvtName(b){var g=b.cmd;var a=null;for(var f in chains){a=chains[f];if(a[0]!=g){continue}var h=b.sub[0];g=g+"_"+h.cmd;if(a.length>1&&h.param!=undefined){if(a[1]==h.cmd){return g+"_"+h.param}}}return g}wsc.Channel=function(b,f,g,a){this.info={members:{},pc:{},pc_order:[],title:{content:"",by:"",ts:""},topic:{content:"",by:"",ts:""},};this.client=b;this.hidden=g;this.monitor=(a==undefined?false:a);this.ui=null;this.raw=b.format_ns(f);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+b.deform_ns(f).slice(1).toLowerCase();this.namespace=b.deform_ns(f);this.monitor=Object.size(this.client.channelo)==0};wsc.Channel.prototype.build=function(){this.info.members={};this.set_privclasses({pkt:{body:""}})
-};wsc.Channel.prototype.log_whois=function(a){if(this.ui==null){return}this.ui.log_whois(a)};wsc.Channel.prototype.log_pc=function(a,b){if(this.ui==null){return}this.ui.log_pc(a,b)};wsc.Channel.prototype.property=function(a){var b=a.pkt.arg["p"];switch(b){case"title":case"topic":if(this.info[b].content.length!=0){if((a.pkt.arg.ts-this.info[b].ts)!=0){this.server_message(b+" set by "+a.pkt.arg["by"])}}this.set_header(b,a);break;case"privclasses":this.set_privclasses(a);break;case"members":this.set_members(a);break;default:this.server_message("Received unknown property "+b+" received in "+this.info.namespace+".");break}};wsc.Channel.prototype.set_header=function(a,b){this.info[a]["content"]=b.value.text()||"";this.info[a]["by"]=b.by;this.info[a]["ts"]=b.ts;if(this.ui==null){return}this.ui.set_header(a,b.value||(new wsc.MessageString))};wsc.Channel.prototype.set_privclasses=function(j){if(this.namespace[0]=="@"){this.info.pc={100:"Room Members"};this.info.pc_order=[100]}else{this.info.pc={};
-this.info.pc_order=[];var a=j.pkt.body.split("\n");var g=[];for(var b in a){if(!a.hasOwnProperty(b)){continue}g=a[b].split(":");if(g.length==1){continue}this.info.pc_order.push(parseInt(g[0]));this.info.pc[parseInt(g[0])]=g[1]}}this.info.pc_order.sort(function(l,k){return k-l});var h=this.info.pc;var f=this.info.pc_order.slice(0);this.ui.build_user_list(h,f)};wsc.Channel.prototype.get_privclass_order=function(a){a=a.toLowerCase();for(var b in this.info.pc){if(!this.info.pc.hasOwnProperty(b)){continue}if(this.info.pc[b].toLowerCase()==a){return b}}};wsc.Channel.prototype.set_members=function(b){this.info.members={};for(var a in b.pkt.sub){if(!b.pkt.sub.hasOwnProperty(a)){continue}this.register_user(b.pkt.sub[a],true)}this.set_user_list()};wsc.Channel.prototype.set_user_list=function(){if(Object.size(this.info.members)==0){return}var f=this.get_usernames();var g=[];var b=null;for(var a in f){if(!f.hasOwnProperty(a)){continue}g.push(this.info.members[f[a]])}this.client.trigger(this.namespace+".user.list",{name:"set.userlist",ns:this.info.namespace,users:g})
-};wsc.Channel.prototype.user_info=function(a){var f=this.info.members[a];var b=f.symbol;return{name:a,pc:f.pc||"Room Members",symbol:b,conn:f.conn,hover:{member:f,name:a,avatar:'',link:b+''+a+"",info:[]}}};wsc.Channel.prototype.register_user=function(a,f){var b=a.param;if(this.info.members[b]==undefined){this.info.members[b]=a.arg;this.info.members[b]["username"]=b;this.info.members[b]["conn"]=1;this.info.members[b]=this.user_info(b)}else{for(i in a.arg){this.info.members[b][i]=a.arg[i]}this.info.members[b]["conn"]++}if(!("pc" in this.info.members[b])){this.info.members[b]["pc"]="Room Members"}f=f||false;if(f){return}this.client.trigger(this.namespace+".user.registered",{name:this.namespace+".user.registered",user:b})};wsc.Channel.prototype.get_usernames=function(){var b=[];for(var a in this.info.members){b.push(a)}b.sort(caseInsensitiveSort);return b};wsc.Channel.prototype.remove_user=function(a,b){b=b||false;
-var f=this.info.members[a];if(f==undefined){return}f.conn--;if(f.conn==0||b){delete this.info.members[a]}this.client.cascade(this.namespace+".user.remove",function(g){},f.name)};wsc.Channel.prototype.recv_join=function(b){var a=new wsc.Packet("user "+b.user+"\n"+b.info);this.register_user(a)};wsc.Channel.prototype.recv_part=function(a){this.remove_user(a.user)};wsc.Channel.prototype.recv_privchg=function(a){var b=this;this.client.cascade(this.namespace+".user.privchg",function(f){var g=b.info.members[f.user];if(!g){return}g.pc=f.pc},a)};wsc.Channel.prototype.recv_kicked=function(a){this.remove_user(a.user,true);this.set_user_list()};wsc.MessageString=function(a,b){this._parser=b||new wsc.MessageParser();this.raw=a};with(wsc.MessageString.prototype=new String){constructor=wsc.MessageParser;toString=valueOf=function(){return this.raw}}wsc.MessageString.prototype.html=function(){return this.raw};wsc.MessageString.prototype.text=function(){return this.raw};wsc.MessageString.prototype.ansi=function(){return this.raw
-};wsc.MessageParser=function(){};wsc.MessageParser.prototype.parse=function(a){return new wsc.MessageString(a,this)};wsc.MessageParser.prototype.render=function(b,a){return a.raw};wsc.Protocol=function(b){this.mparser=b||new wsc.MessageParser;this.chains=[["recv","admin"]];this.maps={chatserver:["version"],login:["username",["e"],"data"],join:["ns",["e"]],part:["ns",["e","*r"]],property:["ns",["p","by","ts"],"*value"],recv_msg:[null,[["from","user"]],"*message"],recv_npmsg:[null,[["from","user"]],"message"],recv_action:[null,["s",["from","user"]],"*message"],recv_join:["user",["s"],"*info"],recv_part:["user",["s","r"]],recv_privchg:["user",["s","by","pc"]],recv_kicked:["user",[["i","s"],"by"],"*r"],recv_admin_create:[null,["p",["by","user"],["name","pc"],"privs"]],recv_admin_update:[null,["p",["by","user"],["name","pc"],"privs"]],recv_admin_rename:[null,["p",["by","user"],"prev",["name","pc"]]],recv_admin_move:[null,["p",["by","user"],"prev",["name","pc"],["n","affected"]]],recv_admin_remove:[null,["p",["by","user"],["name","pc"],["n","affected"]]],recv_admin_show:[null,["p"],"info"],recv_admin_showverbose:[null,["p"],"info"],recv_admin_privclass:[null,["p","e"],"command"],kicked:["ns",[["by","user"]],"*r"],ping:[],disconnect:[null,["e"]],send:["ns",["e"]],kick:["ns",[["u","user"],"e"]],get:["ns",["p","e"]],set:["ns",["p","e"]],kill:["ns",["e"]],unknown:[null,null,null,"packet"],};
+}b.toString=function(){return packetToString(b)};b.name=packetEvtName(b);return b};function wsc_packetstr(h,j,f,a){var b="";if(h){b=h;if(j){b=b+" "+j}}if(f){for(var g in f){b=b+"\n"+g+"="+f[g]}}b=b+"\n";if(a){b=b+"\n"+a}return b}function packetToString(a){return wsc_packetstr(a.cmd,a.param,a.arg,a.body)}function packetEvtName(b){var g=b.cmd;var a=null;for(var f in chains){a=chains[f];if(a[0]!=g){continue}var h=b.sub[0];g=g+"_"+h.cmd;if(a.length>1&&h.param!=undefined){if(a[1]==h.cmd){return g+"_"+h.param}}}return g}wsc.Channel=function(b,f,g,a){this.info={members:{},pc:{},pc_order:[],title:{content:"",by:"",ts:""},topic:{content:"",by:"",ts:""},};this.client=b;this.hidden=g;this.monitor=(a==undefined?false:a);this.ui=null;this.raw=b.format_ns(f);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+b.deform_ns(f).slice(1).toLowerCase();this.namespace=b.deform_ns(f);this.monitor=Object.size(this.client.channelo)==0};wsc.Channel.prototype.build=function(){this.info.members={};if(this.namespace[0]=="@"){this.set_privclasses({pkt:{body:""}})
+}};wsc.Channel.prototype.log_whois=function(a){if(this.ui==null){return}this.ui.log_whois(a)};wsc.Channel.prototype.log_pc=function(a,b){if(this.ui==null){return}this.ui.log_pc(a,b)};wsc.Channel.prototype.property=function(a){var b=a.pkt.arg["p"];switch(b){case"title":case"topic":if(this.info[b].content.length!=0){if((a.pkt.arg.ts-this.info[b].ts)!=0){this.server_message(b+" set by "+a.pkt.arg["by"])}}this.set_header(b,a);break;case"privclasses":this.set_privclasses(a);break;case"members":this.set_members(a);break;default:this.server_message("Received unknown property "+b+" received in "+this.info.namespace+".");break}};wsc.Channel.prototype.set_header=function(a,b){this.info[a]["content"]=b.value.text()||"";this.info[a]["by"]=b.by;this.info[a]["ts"]=b.ts;if(this.ui==null){return}this.ui.set_header(a,b.value||(new wsc.MessageString))};wsc.Channel.prototype.set_privclasses=function(j){if(this.namespace[0]=="@"){this.info.pc={100:"Room Members"};this.info.pc_order=[100]}else{this.info.pc={};
+this.info.pc_order=[];var a=j.pkt.body.split("\n");var g=[];for(var b in a){if(!a.hasOwnProperty(b)){continue}g=a[b].split(":");if(g.length==1){continue}this.info.pc_order.push(parseInt(g[0]));this.info.pc[parseInt(g[0])]=g[1]}}this.info.pc_order.sort(function(l,k){return k-l});var h=this.info.pc;var f=this.info.pc_order.slice(0);this.client.trigger("ns.set.privclasses",{name:"ns.set.privclasses",ns:this.namespace,names:h,orders:f})};wsc.Channel.prototype.get_privclass_order=function(a){a=a.toLowerCase();for(var b in this.info.pc){if(!this.info.pc.hasOwnProperty(b)){continue}if(this.info.pc[b].toLowerCase()==a){return b}}};wsc.Channel.prototype.set_members=function(b){this.info.members={};for(var a in b.pkt.sub){if(!b.pkt.sub.hasOwnProperty(a)){continue}this.register_user(b.pkt.sub[a],true)}this.set_user_list()};wsc.Channel.prototype.set_user_list=function(){if(Object.size(this.info.members)==0){return}var f=this.get_usernames();var g=[];var b=null;for(var a in f){if(!f.hasOwnProperty(a)){continue
+}g.push(this.info.members[f[a]])}this.client.trigger(this.namespace+".user.list",{name:"set.userlist",ns:this.namespace,users:g})};wsc.Channel.prototype.user_info=function(a){var f=this.info.members[a];var b=f.symbol;return{name:a,pc:f.pc||"Room Members",symbol:b,conn:f.conn,hover:{member:f,name:a,avatar:'',link:b+''+a+"",info:[]}}};wsc.Channel.prototype.register_user=function(a,f){var b=a.param;if(this.info.members[b]==undefined){this.info.members[b]=a.arg;this.info.members[b]["username"]=b;this.info.members[b]["conn"]=1;this.info.members[b]=this.user_info(b)}else{for(i in a.arg){this.info.members[b][i]=a.arg[i]}this.info.members[b]["conn"]++}if(!("pc" in this.info.members[b])){this.info.members[b]["pc"]="Room Members"}f=f||false;if(f){return}this.client.trigger(this.namespace+".user.registered",{name:this.namespace+".user.registered",user:b})};wsc.Channel.prototype.get_usernames=function(){var b=[];
+for(var a in this.info.members){b.push(a)}b.sort(caseInsensitiveSort);return b};wsc.Channel.prototype.remove_user=function(a,b){b=b||false;var f=this.info.members[a];if(f==undefined){return}f.conn--;if(f.conn==0||b){delete this.info.members[a]}this.client.cascade(this.namespace+".user.remove",function(g){},f.name)};wsc.Channel.prototype.recv_join=function(b){var a=new wsc.Packet("user "+b.user+"\n"+b.info);this.register_user(a)};wsc.Channel.prototype.recv_part=function(a){this.remove_user(a.user)};wsc.Channel.prototype.recv_privchg=function(a){var b=this;this.client.cascade(this.namespace+".user.privchg",function(f){var g=b.info.members[f.user];if(!g){return}g.pc=f.pc},a)};wsc.Channel.prototype.recv_kicked=function(a){this.remove_user(a.user,true);this.set_user_list()};wsc.MessageString=function(a,b){this._parser=b||new wsc.MessageParser();this.raw=a};with(wsc.MessageString.prototype=new String){constructor=wsc.MessageParser;toString=valueOf=function(){return this.raw}}wsc.MessageString.prototype.html=function(){return this.raw
+};wsc.MessageString.prototype.text=function(){return this.raw};wsc.MessageString.prototype.ansi=function(){return this.raw};wsc.MessageParser=function(){};wsc.MessageParser.prototype.parse=function(a){return new wsc.MessageString(a,this)};wsc.MessageParser.prototype.render=function(b,a){return a.raw};wsc.Protocol=function(b){this.mparser=b||new wsc.MessageParser;this.chains=[["recv","admin"]];this.maps={chatserver:["version"],login:["username",["e"],"data"],join:["ns",["e"]],part:["ns",["e","*r"]],property:["ns",["p","by","ts"],"*value"],recv_msg:[null,[["from","user"]],"*message"],recv_npmsg:[null,[["from","user"]],"message"],recv_action:[null,["s",["from","user"]],"*message"],recv_join:["user",["s"],"*info"],recv_part:["user",["s","r"]],recv_privchg:["user",["s","by","pc"]],recv_kicked:["user",[["i","s"],"by"],"*r"],recv_admin_create:[null,["p",["by","user"],["name","pc"],"privs"]],recv_admin_update:[null,["p",["by","user"],["name","pc"],"privs"]],recv_admin_rename:[null,["p",["by","user"],"prev",["name","pc"]]],recv_admin_move:[null,["p",["by","user"],"prev",["name","pc"],["n","affected"]]],recv_admin_remove:[null,["p",["by","user"],["name","pc"],["n","affected"]]],recv_admin_show:[null,["p"],"info"],recv_admin_showverbose:[null,["p"],"info"],recv_admin_privclass:[null,["p","e"],"command"],kicked:["ns",[["by","user"]],"*r"],ping:[],disconnect:[null,["e"]],send:["ns",["e"]],kick:["ns",[["u","user"],"e"]],get:["ns",["p","e"]],set:["ns",["p","e"]],kill:["ns",["e"]],unknown:[null,null,null,"packet"],};
var a=this;this.mapper={recv:function(h,g,f){g.ns=h.param;return a.map(h.sub[0],g,f)}};this.messages={chatserver:['** Connected to llama {version} *',false,true],login:['** Login as {username}: "{e}" *',false,true],join:['** Join {ns}: "{e}" *',true],part:['** Part {ns}: "{e}" * {r}',true],property:['** Got {p} for {ns} *',true],recv_msg:['<{user}>{message}'],recv_npmsg:['<{user}>{message}'],recv_action:['* {user}{message}'],recv_join:['** {user} has joined *'],recv_part:['** {user} has left * {r}'],recv_privchg:['** {user} has been made a member of {pc} by {by} *'],recv_kicked:['** {user} has been kicked by {by} * {r}'],recv_admin_create:['** Privilege class {pc} has been created by {user} * {privs}'],recv_admin_update:['** Privilege class {pc} has been updated by {user} * {privs}'],recv_admin_rename:['** Privilege class {prev} has been renamed to {pc} by {user} *'],recv_admin_move:['** All members of {prev} have been moved to {pc} by {user} * {affected} affected user(s)'],recv_admin_remove:['** Privilege class {pc} has been removed by {user} * {affected} affected user(s)'],recv_admin_show:null,recv_admin_showverbose:null,recv_admin_privclass:['** Admin command "{command}" failed * {e}'],kicked:['** You have been kicked by {user} * {r}'],ping:null,disconnect:['** You have been disconnected * {e}',false,true],send:['** Send error: {e}'],kick:['** Could not kick {user} * {e}'],get:['** Could not get {p} info for {ns} * {e}'],set:['** Could not set {p} * {e}'],kill:['** Kill error * {e}'],unknown:['** Received unknown packet in {ns} * {packet}',true],}
};wsc.Protocol.prototype.extend_maps=function(a){for(key in a){this.maps[key]=a[key]}};wsc.Protocol.prototype.extend_messages=function(a){for(key in a){this.messages[key]=a[key]}};wsc.Protocol.prototype.parse=function(b){name=this.event(b);if(!(name in this.maps)){console.log("unknown: ",name);console.log(this.maps);mapping=this.maps.unknown;name="unknown"}else{mapping=this.maps[name]}var a={name:name,pkt:b,ns:null};cmd=b.cmd;if(this.mapper[cmd]){this.mapper[cmd](b,a,mapping)}else{this.map(b,a,mapping)}return a};wsc.Protocol.prototype.event=function(b){var g=b.cmd;var a=null;for(var f in this.chains){a=this.chains[f];if(a[0]!=g){continue}var h=b.sub[0];g=g+"_"+h.cmd;if(a.length>1&&h.param!=undefined){if(a[1]==h.cmd){return g+"_"+h.param}}}return g};wsc.Protocol.prototype.map=function(f,b,a){for(var l in a){if(a[l]==null){continue}var m=a[l];var o=m;var j="",h="";switch(parseInt(l)){case 0:b[m]=f.param;break;case 1:if(a[1] instanceof Array){for(var g in a[1]){m=a[1][g];if(m instanceof Array){b[m[1]]=f.arg[m[0]];
o=m[1]}else{var j=m[0]=="*"?m.slice(1):m;b[m]=f.arg[j]||"";o=m}}}if(typeof a[1]=="string"){b[m]=f.arg.slice(0)}break;case 2:if(m instanceof Array){f.sub[0].sub=f.sub.slice(1);this.map(f.sub[0],b,m)}else{b[m]=f.body}break;case 3:b[m]=f.raw;break}if(o[0]!="*"){continue}j=o.slice(1);h=this.mparser.parse(b[o]);b[j]=h}};wsc.Protocol.prototype.render=function(b,f){var a=this.messages[b.name];if(!a){return""}var h=a[0];var g="";for(key in b){if(!b.hasOwnProperty(key)||key=="pkt"){continue}g=b[key];if(key=="ns"||key=="sns"){key="ns";g=b.sns}if(g.hasOwnProperty("_parser")){switch(f){case"text":g=g.text();break;case"html":g=g.html();break;case"ansi":g=g.ansi();break;default:g=g.text();break}}h=replaceAll(h,"{"+key+"}",g)}return h};wsc.Protocol.prototype.log=function(b){var a=this.messages[b.name];if(!a){return null}return new wsc.Protocol.LogMessage(b,a)};wsc.Protocol.LogMessage=function(b,a){this.event=b;this.template=a[0]||"";this.monitor=a[1]||false;this.global=a[2]||false;this._html=false;this._text=false;
@@ -53,13 +53,13 @@ this.conn.open(function(f,g){a.flow.open(a,f,g)});this.conn.disconnect(function(
scrollbarWidth=m.width()-l.width();m.add(l).remove()}else{var k=$("").css({width:100,height:100,overflow:"auto",position:"absolute",top:-1000,left:-1000}).prependTo("body").append("").find("div").css({width:"100%",height:200});scrollbarWidth=100-k.width();k.parent().remove()}return scrollbarWidth})();this.LIB="Chatterbox";this.VERSION=Chatterbox.VERSION;this.STATE=Chatterbox.STATE};wsc.defaults.UI=Chatterbox.UI;Chatterbox.UI.prototype.trigger=function(a,b){this.events.emit(a,b,this)};Chatterbox.UI.prototype.on=function(b,a){this.events.addListener(b,a)};Chatterbox.UI.prototype.middle=function(a,b){return this.mw.add(a,b)};Chatterbox.UI.prototype.cascade=function(a,f,b){this.mw.run(a,f,b)};Chatterbox.UI.prototype.remove_listeners=function(){this.events.removeListeners()};Chatterbox.UI.prototype.deform_ns=function(a){if(a.indexOf("chat:")==0){return"#"+a.slice(5)}if(a.indexOf("server:")==0){return"~"+a.slice(7)}if(a.indexOf("pchat:")==0){var b=a.split(":");b.shift();for(i in b){name=b[i];
if(name.toLowerCase()!=this.lun){return"@"+name}}}if(a.indexOf("login:")==0){return"@"+a.slice(6)}if(a[0]!="#"&&a[0]!="@"&&a[0]!="~"){return"#"+a}return a};Chatterbox.UI.prototype.format_ns=function(a){if(a.indexOf("#")==0){return"chat:"+a.slice(1)}if(a.indexOf("@")==0){var b=[a.slice(1),this.lun];b.sort(caseInsensitiveSort);b.unshift("pchat");return b.join(":")}if(a.indexOf("~")==0){return"server:"+a.slice(1)}if(a.indexOf("chat:")!=0&&a.indexOf("server:")!=0&&a.indexOf("pchat:")!=0){return"chat:"+a}return a};Chatterbox.UI.prototype.set_events=function(a){this.events=a||this.events};Chatterbox.UI.prototype.clock=function(a){if(a===undefined||a==this.settings.clock){return this.settings.clock}this.settings.clock=a;this.chatbook.retime();return this.settings.clock};Chatterbox.UI.prototype.build=function(k,a,b){this.view.append(Chatterbox.render("ui",this.settings));this.control=new (k||Chatterbox.Control)(this);this.nav=new (a||Chatterbox.Navigation)(this);this.chatbook=new (b||Chatterbox.Chatbook)(this);
this.pager=new Chatterbox.Pager(this);this.monitoro=this.chatbook.create_channel(this.mns,this.settings.monitor[1],true);this.monitoro.show();this.control.focus();this.sound.bank.m=this.view.find("div.soundbank");this.sound.bank.c=this.sound.bank.m.find("audio.click")[0];this.sound.bank.c.load();var j=this.sound;this.sound.click=function(){j.play(j.bank.c)};var g=false;var f=this.nav.add_button({label:"",icon:"volume",href:"#mute",title:"Mute the client",handler:function(){if(!g){j.mute();f.removeClass("volume");f.addClass("volume_mute");f.prop("title","Unmute the client");g=true;return false}j.unmute();f.removeClass("volume_mute");f.addClass("volume");f.prop("title","Mute the client");g=false;return false}});var h=this;$(window).focus(function(){h.viewing=true});$(window).blur(function(){h.viewing=false});this.client.bind("pkt",function(m,l){h.packet(m,l)});this.client.middle("ns.remove",function(m,l){h.remove_channel(m.ns);l(m)});this.client.bind("ns.create",function(m,l){h.create_channel(m.chan.raw,m.chan.hidden);
-m.chan.ui=h.channel(m.ns)})};Chatterbox.UI.prototype.resize=function(){this.control.resize();this.view.height(this.view.parent().height());this.nav.resize();this.chatbook.resize(((this.view.parent().height()-this.nav.height())-this.control.height())-5)};Chatterbox.UI.prototype.loop=function(){this.chatbook.loop()};Chatterbox.UI.prototype.packet=function(b,a){var f=this;var g=a.protocol.log(b);if(g){if(this.settings.developer){console.log(">>>",b.sns,"|",g.text())}b.html=g.html();this.cascade("log_message",function(j,h){f.chatbook.log_message(j.message,j.event)},{message:g,event:b})}this.chatbook.handle(b,a)};Chatterbox.UI.prototype.create_channel=function(b,a){this.chatbook.create_channel(b,a)};Chatterbox.UI.prototype.remove_channel=function(a){this.chatbook.remove_channel(a)};Chatterbox.UI.prototype.toggle_channel=function(a){return this.chatbook.toggle_channel(a)};Chatterbox.UI.prototype.channel=function(a,b){return this.chatbook.channel(a,b)};Chatterbox.UI.prototype.channels=function(){return this.chatbook.channels()
-};Chatterbox.UI.prototype.channel_left=function(){this.chatbook.channel_left()};Chatterbox.UI.prototype.channel_right=function(){this.chatbook.channel_right()};Chatterbox.UI.prototype.monitor=function(b,a){this.monitoro.server_message(b,a)};Chatterbox.UI.prototype.server_message=function(b,a){this.chatbook.server_message(b,a)};Chatterbox.UI.prototype.log_item=function(a){this.chatbook.log_item(a)};Chatterbox.UI.prototype.log=function(a){this.chatbook.log(a)};Chatterbox.UI.prototype.mute_user=function(a){if(!a){return false}a=a.toLowerCase();if(this.umuted.indexOf(a)!=-1){return false}this.umuted.push(a);this.chatbook.each(function(b,f){f.mute_user(a)});return true};Chatterbox.UI.prototype.unmute_user=function(a){if(!a){return false}a=a.toLowerCase();var b=this.umuted.indexOf(a);if(b==-1){return false}this.umuted.splice(b,1);this.chatbook.each(function(f,g){g.unmute_user(a)});return true};Chatterbox.UI.prototype.clear_user=function(a){this.chatbook.each(function(b,f){f.clear_user(a)})};Chatterbox.UI.prototype.theme=function(a){if(this.settings.theme==a){return this.settings.theme
-}if(this.settings.themes.indexOf(a)==-1){a="wsct_"+a;if(this.settings.themes.indexOf(a)==-1){return this.settings.theme}}this.view.removeClass(this.settings.theme).addClass(a);this.settings.theme=a;this.trigger("theme.set",{name:"theme.set",theme:a});return this.settings.theme};Chatterbox.UI.prototype.add_theme=function(a){if(this.settings.themes.indexOf(a)>-1){return}this.settings.themes.push(a)};Chatterbox.UI.prototype.developer=function(a){this.settings.developer=a;this.chatbook.developer()};Chatterbox.Channel=function(g,b,f,a){this.manager=g;this.hidden=f;this.monitor=(a==undefined?false:a);this.built=false;this.raw=g.format_ns(b);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+g.deform_ns(b).slice(1).toLowerCase();this.namespace=g.deform_ns(b);this.visible=false;this.st=0;this.el={t:{o:null,l:null,c:null,},m:null,l:{p:null,w:null,},u:null,h:{title:null,topic:null}};this.mulw=0;this.d={u:[0,0],h:{title:[0,0],topic:[0,0]}}};Chatterbox.Channel.prototype.build=function(){if(this.built){return
-}var a=this.selector;var f=this.namespace;var b=this.raw;this.el.t.o=this.manager.nav.add_tab(a,f);this.el.t.l=this.el.t.o.find(".tab");this.el.t.c=this.el.t.o.find(".close");this.manager.chatbook.view.append(Chatterbox.render("channel",{selector:a,ns:f}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");this.el.l.p=this.el.m.find("#"+a+"-log");this.el.l.w=this.el.l.p.find("ul.logwrap");this.el.u=this.el.m.find("#"+a+"-users");this.mulw=parseInt(this.el.u.css("max-width").slice(0,-2));var g=this;var h=false;this.el.l.w.click(function(){if(!h){return}g.manager.control.focus()});this.el.l.w.mousedown(function(){h=true});this.el.l.w.mousemove(function(){h=false});this.el.t.l.click(function(){g.manager.toggle_channel(b);return false});this.el.t.c.click(function(j){g.manager.trigger("tab.close.clicked",{ns:g.raw,chan:g,e:j});return false});this.setup_header("title");this.setup_header("topic");if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")
-}this.manager.client.bind(this.namespace+".user.list",function(j){g.set_user_list(j.users)});this.manager.client.middle(this.namespace+".user.privchg",function(k,j){g.privchg(k,j)});this.manager.client.middle(this.namespace+".user.remove",function(k,j){g.remove_one_user(k,j)});this.manager.client.bind(this.namespace+".user.registered",function(j){g.register_user(j.user)});this.built=true};Chatterbox.Channel.prototype.setup_header=function(a){var f=this;var b={};b.m=this.el.m.find("header."+a+" div");b.e=this.el.m.find("header."+a+" a[href=#edit]");b.t=this.el.m.find("header."+a+" textarea");b.s=this.el.m.find("header."+a+" a[href=#save]");b.c=this.el.m.find("header."+a+" a[href=#cancel]");this.el.h[a]=b.m;b.m.parent().mouseover(function(h){if(!b.editing){b.e.css("display","block");return}b.s.css("display","block");b.c.css("display","block")});b.m.parent().mouseout(function(h){if(!b.editing){b.e.css("display","none");return}b.s.css("display","none");b.c.css("display","none")});b.e.click(function(h){b.t.text(f.manager.client.channel(f.namespace).info[a].content);
-b.t.css({display:"block",width:f.el.h[a].innerWidth()-10,});f.el.h[a].css("display","none");b.e.css("display","none");b.editing=true;f.resize();return false});var g=function(){var h=b.t.val();b.t.text("");b.t.css("display","none");f.el.h[a].css("display","block");b.s.css("display","none");b.c.css("display","none");b.editing=false;f.resize();return h};b.s.click(function(h){var j=g();f.manager.trigger(a+".save",{ns:f.raw,value:j});b.t.text("");return false});b.c.click(function(h){g();return false})};Chatterbox.Channel.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.Channel.prototype.show=function(){this.visible=true;this.el.m.css({display:"block"});this.el.t.o.addClass("active");this.el.t.o.removeClass("noise chatting tabbed fill");var a=this;setTimeout(function(){a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight());a.resize();a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight())
-},100)};Chatterbox.Channel.prototype.developer=function(){if(this.manager.settings.developer){this.el.t.o.removeClass("hidden");return}if(this.hidden){this.el.t.o.addClass("hidden")}};Chatterbox.Channel.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.Channel.prototype.scroll=function(){this.pad();var a=this.el.l.w.prop("scrollWidth")-this.el.l.w.innerWidth();var b=this.el.l.w.prop("scrollHeight")-this.el.l.w.innerHeight();if(a>0){b+=a}if(b<0||(b-this.el.l.w.scrollTop())>100){return}this.el.l.w.scrollTop(b)};Chatterbox.Channel.prototype.pad=function(){this.el.l.w.css({"padding-top":0,height:"auto"});var b=this.el.l.w.innerHeight();var a=this.el.l.p.innerHeight()-this.el.h.topic.parent().outerHeight();var f=a-b;if(f>0){this.el.l.w.css({"padding-top":f})}else{this.el.l.w.css({"padding-top":0,height:a})}this.el.l.w.scrollTop(this.st)};Chatterbox.Channel.prototype.resize=function(j,a){var k={title:{m:this.el.m.find("header div.title"),e:this.el.m.find("header.title a[href=#edit]")},topic:{m:this.el.m.find("header div.topic"),e:this.el.m.find("header.topic a[href=#edit]")}};
+m.chan.ui=h.channel(m.ns)});this.client.bind("ns.set.privclasses",function(m,l){h.channel(m.ns).build_user_list(m.names,m.orders)})};Chatterbox.UI.prototype.resize=function(){this.control.resize();this.view.height(this.view.parent().height());this.nav.resize();this.chatbook.resize(((this.view.parent().height()-this.nav.height())-this.control.height())-5)};Chatterbox.UI.prototype.loop=function(){this.chatbook.loop()};Chatterbox.UI.prototype.packet=function(b,a){var f=this;var g=a.protocol.log(b);if(g){if(this.settings.developer){console.log(">>>",b.sns,"|",g.text())}b.html=g.html();this.cascade("log_message",function(j,h){f.chatbook.log_message(j.message,j.event)},{message:g,event:b})}this.chatbook.handle(b,a)};Chatterbox.UI.prototype.create_channel=function(b,a){this.chatbook.create_channel(b,a)};Chatterbox.UI.prototype.remove_channel=function(a){this.chatbook.remove_channel(a)};Chatterbox.UI.prototype.toggle_channel=function(a){return this.chatbook.toggle_channel(a)};Chatterbox.UI.prototype.channel=function(a,b){return this.chatbook.channel(a,b)
+};Chatterbox.UI.prototype.channels=function(){return this.chatbook.channels()};Chatterbox.UI.prototype.channel_left=function(){this.chatbook.channel_left()};Chatterbox.UI.prototype.channel_right=function(){this.chatbook.channel_right()};Chatterbox.UI.prototype.monitor=function(b,a){this.monitoro.server_message(b,a)};Chatterbox.UI.prototype.server_message=function(b,a){this.chatbook.server_message(b,a)};Chatterbox.UI.prototype.log_item=function(a){this.chatbook.log_item(a)};Chatterbox.UI.prototype.log=function(a){this.chatbook.log(a)};Chatterbox.UI.prototype.mute_user=function(a){if(!a){return false}a=a.toLowerCase();if(this.umuted.indexOf(a)!=-1){return false}this.umuted.push(a);this.chatbook.each(function(b,f){f.mute_user(a)});return true};Chatterbox.UI.prototype.unmute_user=function(a){if(!a){return false}a=a.toLowerCase();var b=this.umuted.indexOf(a);if(b==-1){return false}this.umuted.splice(b,1);this.chatbook.each(function(f,g){g.unmute_user(a)});return true};Chatterbox.UI.prototype.clear_user=function(a){this.chatbook.each(function(b,f){f.clear_user(a)
+})};Chatterbox.UI.prototype.theme=function(a){if(this.settings.theme==a){return this.settings.theme}if(this.settings.themes.indexOf(a)==-1){a="wsct_"+a;if(this.settings.themes.indexOf(a)==-1){return this.settings.theme}}this.view.removeClass(this.settings.theme).addClass(a);this.settings.theme=a;this.trigger("theme.set",{name:"theme.set",theme:a});return this.settings.theme};Chatterbox.UI.prototype.add_theme=function(a){if(this.settings.themes.indexOf(a)>-1){return}this.settings.themes.push(a)};Chatterbox.UI.prototype.developer=function(a){this.settings.developer=a;this.chatbook.developer()};Chatterbox.Channel=function(g,b,f,a){this.manager=g;this.hidden=f;this.monitor=(a==undefined?false:a);this.built=false;this.raw=g.format_ns(b);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+g.deform_ns(b).slice(1).toLowerCase();this.namespace=g.deform_ns(b);this.visible=false;this.st=0;this.el={t:{o:null,l:null,c:null,},m:null,l:{p:null,w:null,},u:null,h:{title:null,topic:null}};this.mulw=0;
+this.d={u:[0,0],h:{title:[0,0],topic:[0,0]}}};Chatterbox.Channel.prototype.build=function(){if(this.built){return}var a=this.selector;var f=this.namespace;var b=this.raw;this.el.t.o=this.manager.nav.add_tab(a,f);this.el.t.l=this.el.t.o.find(".tab");this.el.t.c=this.el.t.o.find(".close");this.manager.chatbook.view.append(Chatterbox.render("channel",{selector:a,ns:f}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");this.el.l.p=this.el.m.find("#"+a+"-log");this.el.l.w=this.el.l.p.find("ul.logwrap");this.el.u=this.el.m.find("#"+a+"-users");this.mulw=parseInt(this.el.u.css("max-width").slice(0,-2));var g=this;var h=false;this.el.l.w.click(function(){if(!h){return}g.manager.control.focus()});this.el.l.w.mousedown(function(){h=true});this.el.l.w.mousemove(function(){h=false});this.el.t.l.click(function(){g.manager.toggle_channel(b);return false});this.el.t.c.click(function(j){g.manager.trigger("tab.close.clicked",{ns:g.raw,chan:g,e:j});return false});this.setup_header("title");
+this.setup_header("topic");if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")}this.manager.client.bind(this.namespace+".user.list",function(j){g.set_user_list(j.users)});this.manager.client.middle(this.namespace+".user.privchg",function(k,j){g.privchg(k,j)});this.manager.client.middle(this.namespace+".user.remove",function(k,j){g.remove_one_user(k,j)});this.manager.client.bind(this.namespace+".user.registered",function(j){g.register_user(j.user)});this.built=true};Chatterbox.Channel.prototype.setup_header=function(a){var f=this;var b={};b.m=this.el.m.find("header."+a+" div");b.e=this.el.m.find("header."+a+" a[href=#edit]");b.t=this.el.m.find("header."+a+" textarea");b.s=this.el.m.find("header."+a+" a[href=#save]");b.c=this.el.m.find("header."+a+" a[href=#cancel]");this.el.h[a]=b.m;b.m.parent().mouseover(function(h){if(!b.editing){b.e.css("display","block");return}b.s.css("display","block");b.c.css("display","block")});b.m.parent().mouseout(function(h){if(!b.editing){b.e.css("display","none");
+return}b.s.css("display","none");b.c.css("display","none")});b.e.click(function(h){b.t.text(f.manager.client.channel(f.namespace).info[a].content);b.t.css({display:"block",width:f.el.h[a].innerWidth()-10,});f.el.h[a].css("display","none");b.e.css("display","none");b.editing=true;f.resize();return false});var g=function(){var h=b.t.val();b.t.text("");b.t.css("display","none");f.el.h[a].css("display","block");b.s.css("display","none");b.c.css("display","none");b.editing=false;f.resize();return h};b.s.click(function(h){var j=g();f.manager.trigger(a+".save",{ns:f.raw,value:j});b.t.text("");return false});b.c.click(function(h){g();return false})};Chatterbox.Channel.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.Channel.prototype.show=function(){this.visible=true;this.el.m.css({display:"block"});this.el.t.o.addClass("active");this.el.t.o.removeClass("noise chatting tabbed fill");var a=this;setTimeout(function(){a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight());
+a.resize();a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight())},100)};Chatterbox.Channel.prototype.developer=function(){if(this.manager.settings.developer){this.el.t.o.removeClass("hidden");return}if(this.hidden){this.el.t.o.addClass("hidden")}};Chatterbox.Channel.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.Channel.prototype.scroll=function(){this.pad();var a=this.el.l.w.prop("scrollWidth")-this.el.l.w.innerWidth();var b=this.el.l.w.prop("scrollHeight")-this.el.l.w.innerHeight();if(a>0){b+=a}if(b<0||(b-this.el.l.w.scrollTop())>100){return}this.el.l.w.scrollTop(b)};Chatterbox.Channel.prototype.pad=function(){this.el.l.w.css({"padding-top":0,height:"auto"});var b=this.el.l.w.innerHeight();var a=this.el.l.p.innerHeight()-this.el.h.topic.parent().outerHeight();var f=a-b;if(f>0){this.el.l.w.css({"padding-top":f})}else{this.el.l.w.css({"padding-top":0,height:a})}this.el.l.w.scrollTop(this.st)};Chatterbox.Channel.prototype.resize=function(j,a){var k={title:{m:this.el.m.find("header div.title"),e:this.el.m.find("header.title a[href=#edit]")},topic:{m:this.el.m.find("header div.topic"),e:this.el.m.find("header.topic a[href=#edit]")}};
this.el.l.w.css({"padding-top":0});a=a||this.manager.chatbook.height();j=j||this.manager.chatbook.width();var f=a;this.el.m.height(f);this.el.m.css("width",j-10);var b=this.el.m.width();this.el.u.width(1);this.d.u[0]=this.el.u[0].scrollWidth+this.manager.swidth+5;if(this.d.u[0]>this.mulw){this.d.u[0]=this.mulw}this.el.u.width(this.d.u[0]);b=b-this.d.u[0];f=f-k.title.m.parent().outerHeight();this.el.l.p.css({height:f-3,width:b-10});this.scroll();this.d.u[1]=this.el.l.p.innerHeight();this.el.u.css({height:this.d.u[1]});for(var h in k){if(!k.hasOwnProperty(h)){continue}if(k[h].m.html().length==0){continue}var g=(k[h].m.outerHeight(true)-5)*(-1);k[h].e.css("top",g)}};Chatterbox.Channel.prototype.loop=function(){var a=this.el.l.p.find(".logmsg");if(a.length<200){return}a.slice(0,a.length-200).remove();this.resize()};Chatterbox.Channel.prototype.log=function(b){var a=this;this.manager.cascade("log",function(f){a.log_item({html:Chatterbox.render("logmsg",{message:f.message})})},{ns:this.raw,sns:this.namespace,message:b})
};Chatterbox.Channel.prototype.log_item=function(f){var a=new Date();var b="";if(this.manager.settings.clock){b=formatTime("{HH}:{mm}:{ss}",a)}else{b=formatTime("{hh}:{mm}:{ss} {mr}",a)}var g=this;this.manager.cascade("log_item",function(h){if(g.visible){g.st=g.el.l.w.scrollTop()}g.el.l.w.append(Chatterbox.render("logitem",h));g.manager.trigger("log_item.after",{item:g.el.l.w.find("li").last(),chan:g});if(g.visible){g.st+=g.el.l.w.find("li.logmsg").last().height();g.el.l.w.scrollTop(g.st)}g.scroll();g.noise()},{ns:this.namespace,ts:b,ms:a.getTime(),message:f.html,user:(f.user||"system").toLowerCase()})};Chatterbox.Channel.prototype.retime=function(){var a="";var b=this.el.l.w;if(this.manager.settings.clock){a="{HH}:{mm}:{ss}"}else{a="{hh}:{mm}:{ss} {mr}"}b.find("span.ts").each(function(f,g){el=b.find(g);time=new Date(parseInt(el.prop("id")));el.text(formatTime(a,time))})};Chatterbox.Channel.prototype.server_message=function(f,b){var a=this;this.manager.cascade("server_message",function(g){a.log_item({html:Chatterbox.render("servermsg",{message:g.message,info:g.info})})
},{ns:this.namespace,message:f,info:b})};Chatterbox.Channel.prototype.clear=function(){this.el.l.p.find("li.logmsg").remove();this.el.l.p.find("li.loginfo").remove();this.el.l.w.height(0);this.resize()};Chatterbox.Channel.prototype.log_info=function(h,g){var k={ns:this.namespace,ref:h,content:g};this.manager.trigger("log_info.before",k);delete k.ns;var a=this.el.l.w.append(Chatterbox.render("loginfobox",k));this.scroll();var j=this;var f=this.el.l.w.find("li."+k.ref);f.find("a.close").click(function(b){j.el.l.w.find(this).parent().remove();j.resize();return false});this.scroll();return f};Chatterbox.Channel.prototype.log_whois=function(m){var h={avatar:'',username:""+m.symbol+m.username+"",info:[],conns:[],raw:m,};for(var n in m.connections){var l=m.connections[n];var p=[];if(l.online){var a=(new Date-(l.online*1000));p.push(["online",DateStamp(a/1000)+formatTime(" [{HH}:{mm}:{ss}]",new Date(a))])}if(l.idle){p.push(["idle",timeLengthString(l.idle)])
diff --git a/dist/wsc.js b/dist/wsc.js
index 54489eb..33758c6 100644
--- a/dist/wsc.js
+++ b/dist/wsc.js
@@ -1026,8 +1026,12 @@ wsc.Channel = function( client, ns, hidden, monitor ) {
* @method build
*/
wsc.Channel.prototype.build = function( ) {
+
this.info.members = {};
- this.set_privclasses( { pkt: { body: '' } } );
+
+ if( this.namespace[0] == '@' )
+ this.set_privclasses( { pkt: { body: '' } } );
+
};
/**
@@ -1149,7 +1153,15 @@ wsc.Channel.prototype.set_privclasses = function( e ) {
var names = this.info.pc;
var orders = this.info.pc_order.slice(0);
- this.ui.build_user_list( names, orders );
+ this.client.trigger(
+ 'ns.set.privclasses',
+ {
+ name: 'ns.set.privclasses',
+ ns: this.namespace,
+ names: names,
+ orders: orders
+ }
+ );
};
/**
@@ -1212,7 +1224,7 @@ wsc.Channel.prototype.set_user_list = function( ) {
this.client.trigger(this.namespace + '.user.list', {
'name': 'set.userlist',
- 'ns': this.info['namespace'],
+ 'ns': this.namespace,
'users': users
});
};
@@ -4707,6 +4719,13 @@ Chatterbox.UI.prototype.build = function( control, navigation, chatbook ) {
}
);
+ this.client.bind(
+ 'ns.set.privclasses',
+ function( event, client ) {
+ ui.channel( event.ns ).build_user_list( event.names, event.orders );
+ }
+ );
+
};
/**
diff --git a/dist/wsc.min.js b/dist/wsc.min.js
index b23f33d..409e534 100644
--- a/dist/wsc.min.js
+++ b/dist/wsc.min.js
@@ -11,12 +11,12 @@ return((f>d)?1:(f11){mr="pm";if(hh>12){hh=hh-12}}else{if(hh==0){hh="12"}}b=replaceAll(b,"{hh}",zeroPad(hh,2));b=replaceAll(b,"{HH}",zeroPad(HH,2));b=replaceAll(b,"{mr}",mr);return b}function oxlist(a){last=a.pop();ret=a.join(", ");return ret+(ret.length>0?", and ":"")+last}function pluralise(b,a){return b+(a==1?"":"s")}function timeLengthString(d){if(d<=0){return"0 seconds."}var a=d;var f=[];f.unshift(["second",Math.round(a%60)]);a/=Math.round(60);f.unshift(["minute",Math.round(a%60)]);a/=Math.round(60);f.unshift(["hour",Math.round(a%24)]);a/=Math.round(24);f.unshift(["day",a]);var b=[];for(i in f){lapse=f[i];if(lapse[1]<1){continue}b.push(lapse[1].toString()+" "+pluralise(lapse[0],lapse[1]))}return oxlist(b)}function StringSet(a){this.items=a||[]}StringSet.prototype.add=function(b,a){if(!b){return false}b=b.toLowerCase();
if(this.contains(b)){return true}if(a){this.items.unshift(b)}else{this.items.push(b)}return true};StringSet.prototype.remove=function(a){if(!a){return false}a=a.toLowerCase();if(!this.contains(a)){return true}this.items.splice(this.items.indexOf(a),1);return true};StringSet.prototype.contains=function(a){if(!a){return false}return this.items.indexOf(a.toLowerCase())!=-1};wsc.Middleware=function(){this.callbacks={}};wsc.Middleware.prototype.add=function(b,d){var a=this.callbacks[b]||false;if(a===false){this.callbacks[b]=[]}this.callbacks[b].push(d);return this.callbacks[b].length};wsc.Middleware.prototype.run=function(b,g,d){var f=(this.callbacks[b]||[]).slice();f.push(g);var a=function(h){f.shift()(h,a)};a(d)};wsc.Storage=function(b,a){this.ns=b||null;this.parent=a||null};wsc.Storage.prototype.folder=function(a){if(this.ns!=null){a=this.ns+"."+a}return new wsc.Storage(a,this)};wsc.Storage.prototype.get=function(a,d){if(this.ns!=null){a=this.ns+"."+a}try{if(!localStorage.hasOwnProperty(a)){return d
}return localStorage[a]}catch(b){return d}};wsc.Storage.prototype.set=function(a,d){if(this.ns!=null){a=this.ns+"."+a}try{localStorage[a]=d}catch(b){}};wsc.Storage.prototype.remove=function(a){if(this.ns!=null){a=this.ns+"."+a}try{if(!localStorage.hasOwnProperty(a)){return false}return delete localStorage[a]}catch(b){}return false};var chains=[["recv","admin"]];wsc.Packet=function(f,h,a){if(!(f)){return null}if(a===undefined){a=true}h=h||"=";var b={cmd:null,param:null,arg:{},body:null,sub:[],raw:f};var k=null;var l=-1;try{l=f.indexOf("\n\n");if(l>-1){b.body=f.substr(l+2);f=f.substr(0,l)}k=f.split("\n");if(k[0].indexOf(h)==-1){cline=k.shift().split(" ");b.cmd=cline.shift()||null;b.param=cline.join(" ")||null}for(var d in k){arg=k[d];l=arg.search(h);if(l==-1){continue}b.arg[arg.substr(0,l)]=arg.substr(l+h.length)||""}if(b.body!=null&&a){subs=b.body.split("\n\n");for(var g in subs){sub=wsc.Packet(subs[g],h,false);if(sub==null){break}sub.body=subs.slice(g+1).join("\n\n");b.sub.push(sub)}}}catch(j){return null
-}b.toString=function(){return packetToString(b)};b.name=packetEvtName(b);return b};function wsc_packetstr(g,h,d,a){var b="";if(g){b=g;if(h){b=b+" "+h}}if(d){for(var f in d){b=b+"\n"+f+"="+d[f]}}b=b+"\n";if(a){b=b+"\n"+a}return b}function packetToString(a){return wsc_packetstr(a.cmd,a.param,a.arg,a.body)}function packetEvtName(b){var f=b.cmd;var a=null;for(var d in chains){a=chains[d];if(a[0]!=f){continue}var g=b.sub[0];f=f+"_"+g.cmd;if(a.length>1&&g.param!=undefined){if(a[1]==g.cmd){return f+"_"+g.param}}}return f}wsc.Channel=function(b,d,f,a){this.info={members:{},pc:{},pc_order:[],title:{content:"",by:"",ts:""},topic:{content:"",by:"",ts:""},};this.client=b;this.hidden=f;this.monitor=(a==undefined?false:a);this.ui=null;this.raw=b.format_ns(d);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+b.deform_ns(d).slice(1).toLowerCase();this.namespace=b.deform_ns(d);this.monitor=Object.size(this.client.channelo)==0};wsc.Channel.prototype.build=function(){this.info.members={};this.set_privclasses({pkt:{body:""}})
-};wsc.Channel.prototype.log_whois=function(a){if(this.ui==null){return}this.ui.log_whois(a)};wsc.Channel.prototype.log_pc=function(a,b){if(this.ui==null){return}this.ui.log_pc(a,b)};wsc.Channel.prototype.property=function(a){var b=a.pkt.arg["p"];switch(b){case"title":case"topic":if(this.info[b].content.length!=0){if((a.pkt.arg.ts-this.info[b].ts)!=0){this.server_message(b+" set by "+a.pkt.arg["by"])}}this.set_header(b,a);break;case"privclasses":this.set_privclasses(a);break;case"members":this.set_members(a);break;default:this.server_message("Received unknown property "+b+" received in "+this.info.namespace+".");break}};wsc.Channel.prototype.set_header=function(a,b){this.info[a]["content"]=b.value.text()||"";this.info[a]["by"]=b.by;this.info[a]["ts"]=b.ts;if(this.ui==null){return}this.ui.set_header(a,b.value||(new wsc.MessageString))};wsc.Channel.prototype.set_privclasses=function(h){if(this.namespace[0]=="@"){this.info.pc={100:"Room Members"};this.info.pc_order=[100]}else{this.info.pc={};
-this.info.pc_order=[];var a=h.pkt.body.split("\n");var f=[];for(var b in a){if(!a.hasOwnProperty(b)){continue}f=a[b].split(":");if(f.length==1){continue}this.info.pc_order.push(parseInt(f[0]));this.info.pc[parseInt(f[0])]=f[1]}}this.info.pc_order.sort(function(k,j){return j-k});var g=this.info.pc;var d=this.info.pc_order.slice(0);this.ui.build_user_list(g,d)};wsc.Channel.prototype.get_privclass_order=function(a){a=a.toLowerCase();for(var b in this.info.pc){if(!this.info.pc.hasOwnProperty(b)){continue}if(this.info.pc[b].toLowerCase()==a){return b}}};wsc.Channel.prototype.set_members=function(b){this.info.members={};for(var a in b.pkt.sub){if(!b.pkt.sub.hasOwnProperty(a)){continue}this.register_user(b.pkt.sub[a],true)}this.set_user_list()};wsc.Channel.prototype.set_user_list=function(){if(Object.size(this.info.members)==0){return}var d=this.get_usernames();var f=[];var b=null;for(var a in d){if(!d.hasOwnProperty(a)){continue}f.push(this.info.members[d[a]])}this.client.trigger(this.namespace+".user.list",{name:"set.userlist",ns:this.info.namespace,users:f})
-};wsc.Channel.prototype.user_info=function(a){var d=this.info.members[a];var b=d.symbol;return{name:a,pc:d.pc||"Room Members",symbol:b,conn:d.conn,hover:{member:d,name:a,avatar:'',link:b+''+a+"",info:[]}}};wsc.Channel.prototype.register_user=function(a,d){var b=a.param;if(this.info.members[b]==undefined){this.info.members[b]=a.arg;this.info.members[b]["username"]=b;this.info.members[b]["conn"]=1;this.info.members[b]=this.user_info(b)}else{for(i in a.arg){this.info.members[b][i]=a.arg[i]}this.info.members[b]["conn"]++}if(!("pc" in this.info.members[b])){this.info.members[b]["pc"]="Room Members"}d=d||false;if(d){return}this.client.trigger(this.namespace+".user.registered",{name:this.namespace+".user.registered",user:b})};wsc.Channel.prototype.get_usernames=function(){var b=[];for(var a in this.info.members){b.push(a)}b.sort(caseInsensitiveSort);return b};wsc.Channel.prototype.remove_user=function(a,b){b=b||false;
-var d=this.info.members[a];if(d==undefined){return}d.conn--;if(d.conn==0||b){delete this.info.members[a]}this.client.cascade(this.namespace+".user.remove",function(f){},d.name)};wsc.Channel.prototype.recv_join=function(b){var a=new wsc.Packet("user "+b.user+"\n"+b.info);this.register_user(a)};wsc.Channel.prototype.recv_part=function(a){this.remove_user(a.user)};wsc.Channel.prototype.recv_privchg=function(a){var b=this;this.client.cascade(this.namespace+".user.privchg",function(d){var f=b.info.members[d.user];if(!f){return}f.pc=d.pc},a)};wsc.Channel.prototype.recv_kicked=function(a){this.remove_user(a.user,true);this.set_user_list()};wsc.MessageString=function(a,b){this._parser=b||new wsc.MessageParser();this.raw=a};with(wsc.MessageString.prototype=new String){constructor=wsc.MessageParser;toString=valueOf=function(){return this.raw}}wsc.MessageString.prototype.html=function(){return this.raw};wsc.MessageString.prototype.text=function(){return this.raw};wsc.MessageString.prototype.ansi=function(){return this.raw
-};wsc.MessageParser=function(){};wsc.MessageParser.prototype.parse=function(a){return new wsc.MessageString(a,this)};wsc.MessageParser.prototype.render=function(b,a){return a.raw};wsc.Protocol=function(b){this.mparser=b||new wsc.MessageParser;this.chains=[["recv","admin"]];this.maps={chatserver:["version"],login:["username",["e"],"data"],join:["ns",["e"]],part:["ns",["e","*r"]],property:["ns",["p","by","ts"],"*value"],recv_msg:[null,[["from","user"]],"*message"],recv_npmsg:[null,[["from","user"]],"message"],recv_action:[null,["s",["from","user"]],"*message"],recv_join:["user",["s"],"*info"],recv_part:["user",["s","r"]],recv_privchg:["user",["s","by","pc"]],recv_kicked:["user",[["i","s"],"by"],"*r"],recv_admin_create:[null,["p",["by","user"],["name","pc"],"privs"]],recv_admin_update:[null,["p",["by","user"],["name","pc"],"privs"]],recv_admin_rename:[null,["p",["by","user"],"prev",["name","pc"]]],recv_admin_move:[null,["p",["by","user"],"prev",["name","pc"],["n","affected"]]],recv_admin_remove:[null,["p",["by","user"],["name","pc"],["n","affected"]]],recv_admin_show:[null,["p"],"info"],recv_admin_showverbose:[null,["p"],"info"],recv_admin_privclass:[null,["p","e"],"command"],kicked:["ns",[["by","user"]],"*r"],ping:[],disconnect:[null,["e"]],send:["ns",["e"]],kick:["ns",[["u","user"],"e"]],get:["ns",["p","e"]],set:["ns",["p","e"]],kill:["ns",["e"]],unknown:[null,null,null,"packet"],};
+}b.toString=function(){return packetToString(b)};b.name=packetEvtName(b);return b};function wsc_packetstr(g,h,d,a){var b="";if(g){b=g;if(h){b=b+" "+h}}if(d){for(var f in d){b=b+"\n"+f+"="+d[f]}}b=b+"\n";if(a){b=b+"\n"+a}return b}function packetToString(a){return wsc_packetstr(a.cmd,a.param,a.arg,a.body)}function packetEvtName(b){var f=b.cmd;var a=null;for(var d in chains){a=chains[d];if(a[0]!=f){continue}var g=b.sub[0];f=f+"_"+g.cmd;if(a.length>1&&g.param!=undefined){if(a[1]==g.cmd){return f+"_"+g.param}}}return f}wsc.Channel=function(b,d,f,a){this.info={members:{},pc:{},pc_order:[],title:{content:"",by:"",ts:""},topic:{content:"",by:"",ts:""},};this.client=b;this.hidden=f;this.monitor=(a==undefined?false:a);this.ui=null;this.raw=b.format_ns(d);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+b.deform_ns(d).slice(1).toLowerCase();this.namespace=b.deform_ns(d);this.monitor=Object.size(this.client.channelo)==0};wsc.Channel.prototype.build=function(){this.info.members={};if(this.namespace[0]=="@"){this.set_privclasses({pkt:{body:""}})
+}};wsc.Channel.prototype.log_whois=function(a){if(this.ui==null){return}this.ui.log_whois(a)};wsc.Channel.prototype.log_pc=function(a,b){if(this.ui==null){return}this.ui.log_pc(a,b)};wsc.Channel.prototype.property=function(a){var b=a.pkt.arg["p"];switch(b){case"title":case"topic":if(this.info[b].content.length!=0){if((a.pkt.arg.ts-this.info[b].ts)!=0){this.server_message(b+" set by "+a.pkt.arg["by"])}}this.set_header(b,a);break;case"privclasses":this.set_privclasses(a);break;case"members":this.set_members(a);break;default:this.server_message("Received unknown property "+b+" received in "+this.info.namespace+".");break}};wsc.Channel.prototype.set_header=function(a,b){this.info[a]["content"]=b.value.text()||"";this.info[a]["by"]=b.by;this.info[a]["ts"]=b.ts;if(this.ui==null){return}this.ui.set_header(a,b.value||(new wsc.MessageString))};wsc.Channel.prototype.set_privclasses=function(h){if(this.namespace[0]=="@"){this.info.pc={100:"Room Members"};this.info.pc_order=[100]}else{this.info.pc={};
+this.info.pc_order=[];var a=h.pkt.body.split("\n");var f=[];for(var b in a){if(!a.hasOwnProperty(b)){continue}f=a[b].split(":");if(f.length==1){continue}this.info.pc_order.push(parseInt(f[0]));this.info.pc[parseInt(f[0])]=f[1]}}this.info.pc_order.sort(function(k,j){return j-k});var g=this.info.pc;var d=this.info.pc_order.slice(0);this.client.trigger("ns.set.privclasses",{name:"ns.set.privclasses",ns:this.namespace,names:g,orders:d})};wsc.Channel.prototype.get_privclass_order=function(a){a=a.toLowerCase();for(var b in this.info.pc){if(!this.info.pc.hasOwnProperty(b)){continue}if(this.info.pc[b].toLowerCase()==a){return b}}};wsc.Channel.prototype.set_members=function(b){this.info.members={};for(var a in b.pkt.sub){if(!b.pkt.sub.hasOwnProperty(a)){continue}this.register_user(b.pkt.sub[a],true)}this.set_user_list()};wsc.Channel.prototype.set_user_list=function(){if(Object.size(this.info.members)==0){return}var d=this.get_usernames();var f=[];var b=null;for(var a in d){if(!d.hasOwnProperty(a)){continue
+}f.push(this.info.members[d[a]])}this.client.trigger(this.namespace+".user.list",{name:"set.userlist",ns:this.namespace,users:f})};wsc.Channel.prototype.user_info=function(a){var d=this.info.members[a];var b=d.symbol;return{name:a,pc:d.pc||"Room Members",symbol:b,conn:d.conn,hover:{member:d,name:a,avatar:'',link:b+''+a+"",info:[]}}};wsc.Channel.prototype.register_user=function(a,d){var b=a.param;if(this.info.members[b]==undefined){this.info.members[b]=a.arg;this.info.members[b]["username"]=b;this.info.members[b]["conn"]=1;this.info.members[b]=this.user_info(b)}else{for(i in a.arg){this.info.members[b][i]=a.arg[i]}this.info.members[b]["conn"]++}if(!("pc" in this.info.members[b])){this.info.members[b]["pc"]="Room Members"}d=d||false;if(d){return}this.client.trigger(this.namespace+".user.registered",{name:this.namespace+".user.registered",user:b})};wsc.Channel.prototype.get_usernames=function(){var b=[];
+for(var a in this.info.members){b.push(a)}b.sort(caseInsensitiveSort);return b};wsc.Channel.prototype.remove_user=function(a,b){b=b||false;var d=this.info.members[a];if(d==undefined){return}d.conn--;if(d.conn==0||b){delete this.info.members[a]}this.client.cascade(this.namespace+".user.remove",function(f){},d.name)};wsc.Channel.prototype.recv_join=function(b){var a=new wsc.Packet("user "+b.user+"\n"+b.info);this.register_user(a)};wsc.Channel.prototype.recv_part=function(a){this.remove_user(a.user)};wsc.Channel.prototype.recv_privchg=function(a){var b=this;this.client.cascade(this.namespace+".user.privchg",function(d){var f=b.info.members[d.user];if(!f){return}f.pc=d.pc},a)};wsc.Channel.prototype.recv_kicked=function(a){this.remove_user(a.user,true);this.set_user_list()};wsc.MessageString=function(a,b){this._parser=b||new wsc.MessageParser();this.raw=a};with(wsc.MessageString.prototype=new String){constructor=wsc.MessageParser;toString=valueOf=function(){return this.raw}}wsc.MessageString.prototype.html=function(){return this.raw
+};wsc.MessageString.prototype.text=function(){return this.raw};wsc.MessageString.prototype.ansi=function(){return this.raw};wsc.MessageParser=function(){};wsc.MessageParser.prototype.parse=function(a){return new wsc.MessageString(a,this)};wsc.MessageParser.prototype.render=function(b,a){return a.raw};wsc.Protocol=function(b){this.mparser=b||new wsc.MessageParser;this.chains=[["recv","admin"]];this.maps={chatserver:["version"],login:["username",["e"],"data"],join:["ns",["e"]],part:["ns",["e","*r"]],property:["ns",["p","by","ts"],"*value"],recv_msg:[null,[["from","user"]],"*message"],recv_npmsg:[null,[["from","user"]],"message"],recv_action:[null,["s",["from","user"]],"*message"],recv_join:["user",["s"],"*info"],recv_part:["user",["s","r"]],recv_privchg:["user",["s","by","pc"]],recv_kicked:["user",[["i","s"],"by"],"*r"],recv_admin_create:[null,["p",["by","user"],["name","pc"],"privs"]],recv_admin_update:[null,["p",["by","user"],["name","pc"],"privs"]],recv_admin_rename:[null,["p",["by","user"],"prev",["name","pc"]]],recv_admin_move:[null,["p",["by","user"],"prev",["name","pc"],["n","affected"]]],recv_admin_remove:[null,["p",["by","user"],["name","pc"],["n","affected"]]],recv_admin_show:[null,["p"],"info"],recv_admin_showverbose:[null,["p"],"info"],recv_admin_privclass:[null,["p","e"],"command"],kicked:["ns",[["by","user"]],"*r"],ping:[],disconnect:[null,["e"]],send:["ns",["e"]],kick:["ns",[["u","user"],"e"]],get:["ns",["p","e"]],set:["ns",["p","e"]],kill:["ns",["e"]],unknown:[null,null,null,"packet"],};
var a=this;this.mapper={recv:function(g,f,d){f.ns=g.param;return a.map(g.sub[0],f,d)}};this.messages={chatserver:['** Connected to llama {version} *',false,true],login:['** Login as {username}: "{e}" *',false,true],join:['** Join {ns}: "{e}" *',true],part:['** Part {ns}: "{e}" * {r}',true],property:['** Got {p} for {ns} *',true],recv_msg:['<{user}>{message}'],recv_npmsg:['<{user}>{message}'],recv_action:['* {user}{message}'],recv_join:['** {user} has joined *'],recv_part:['** {user} has left * {r}'],recv_privchg:['** {user} has been made a member of {pc} by {by} *'],recv_kicked:['** {user} has been kicked by {by} * {r}'],recv_admin_create:['** Privilege class {pc} has been created by {user} * {privs}'],recv_admin_update:['** Privilege class {pc} has been updated by {user} * {privs}'],recv_admin_rename:['** Privilege class {prev} has been renamed to {pc} by {user} *'],recv_admin_move:['** All members of {prev} have been moved to {pc} by {user} * {affected} affected user(s)'],recv_admin_remove:['** Privilege class {pc} has been removed by {user} * {affected} affected user(s)'],recv_admin_show:null,recv_admin_showverbose:null,recv_admin_privclass:['** Admin command "{command}" failed * {e}'],kicked:['** You have been kicked by {user} * {r}'],ping:null,disconnect:['** You have been disconnected * {e}',false,true],send:['** Send error: {e}'],kick:['** Could not kick {user} * {e}'],get:['** Could not get {p} info for {ns} * {e}'],set:['** Could not set {p} * {e}'],kill:['** Kill error * {e}'],unknown:['** Received unknown packet in {ns} * {packet}',true],}
};wsc.Protocol.prototype.extend_maps=function(a){for(key in a){this.maps[key]=a[key]}};wsc.Protocol.prototype.extend_messages=function(a){for(key in a){this.messages[key]=a[key]}};wsc.Protocol.prototype.parse=function(b){name=this.event(b);if(!(name in this.maps)){console.log("unknown: ",name);console.log(this.maps);mapping=this.maps.unknown;name="unknown"}else{mapping=this.maps[name]}var a={name:name,pkt:b,ns:null};cmd=b.cmd;if(this.mapper[cmd]){this.mapper[cmd](b,a,mapping)}else{this.map(b,a,mapping)}return a};wsc.Protocol.prototype.event=function(b){var f=b.cmd;var a=null;for(var d in this.chains){a=this.chains[d];if(a[0]!=f){continue}var g=b.sub[0];f=f+"_"+g.cmd;if(a.length>1&&g.param!=undefined){if(a[1]==g.cmd){return f+"_"+g.param}}}return f};wsc.Protocol.prototype.map=function(d,b,a){for(var j in a){if(a[j]==null){continue}var l=a[j];var m=l;var h="",g="";switch(parseInt(j)){case 0:b[l]=d.param;break;case 1:if(a[1] instanceof Array){for(var f in a[1]){l=a[1][f];if(l instanceof Array){b[l[1]]=d.arg[l[0]];
m=l[1]}else{var h=l[0]=="*"?l.slice(1):l;b[l]=d.arg[h]||"";m=l}}}if(typeof a[1]=="string"){b[l]=d.arg.slice(0)}break;case 2:if(l instanceof Array){d.sub[0].sub=d.sub.slice(1);this.map(d.sub[0],b,l)}else{b[l]=d.body}break;case 3:b[l]=d.raw;break}if(m[0]!="*"){continue}h=m.slice(1);g=this.mparser.parse(b[m]);b[h]=g}};wsc.Protocol.prototype.render=function(b,f){var a=this.messages[b.name];if(!a){return""}var h=a[0];var g="";for(key in b){if(!b.hasOwnProperty(key)||key=="pkt"){continue}g=b[key];if(key=="ns"||key=="sns"){key="ns";g=b.sns}if(g.hasOwnProperty("_parser")){switch(f){case"text":g=g.text();break;case"html":g=g.html();break;case"ansi":g=g.ansi();break;default:g=g.text();break}}h=replaceAll(h,"{"+key+"}",g)}return h};wsc.Protocol.prototype.log=function(b){var a=this.messages[b.name];if(!a){return null}return new wsc.Protocol.LogMessage(b,a)};wsc.Protocol.LogMessage=function(b,a){this.event=b;this.template=a[0]||"";this.monitor=a[1]||false;this.global=a[2]||false;this._html=false;this._text=false;
@@ -53,13 +53,13 @@ this.conn.open(function(d,f){a.flow.open(a,d,f)});this.conn.disconnect(function(
scrollbarWidth=l.width()-k.width();l.add(k).remove()}else{var j=$("").css({width:100,height:100,overflow:"auto",position:"absolute",top:-1000,left:-1000}).prependTo("body").append("").find("div").css({width:"100%",height:200});scrollbarWidth=100-j.width();j.parent().remove()}return scrollbarWidth})();this.LIB="Chatterbox";this.VERSION=Chatterbox.VERSION;this.STATE=Chatterbox.STATE};wsc.defaults.UI=Chatterbox.UI;Chatterbox.UI.prototype.trigger=function(a,b){this.events.emit(a,b,this)};Chatterbox.UI.prototype.on=function(b,a){this.events.addListener(b,a)};Chatterbox.UI.prototype.middle=function(a,b){return this.mw.add(a,b)};Chatterbox.UI.prototype.cascade=function(a,d,b){this.mw.run(a,d,b)};Chatterbox.UI.prototype.remove_listeners=function(){this.events.removeListeners()};Chatterbox.UI.prototype.deform_ns=function(a){if(a.indexOf("chat:")==0){return"#"+a.slice(5)}if(a.indexOf("server:")==0){return"~"+a.slice(7)}if(a.indexOf("pchat:")==0){var b=a.split(":");b.shift();for(i in b){name=b[i];
if(name.toLowerCase()!=this.lun){return"@"+name}}}if(a.indexOf("login:")==0){return"@"+a.slice(6)}if(a[0]!="#"&&a[0]!="@"&&a[0]!="~"){return"#"+a}return a};Chatterbox.UI.prototype.format_ns=function(a){if(a.indexOf("#")==0){return"chat:"+a.slice(1)}if(a.indexOf("@")==0){var b=[a.slice(1),this.lun];b.sort(caseInsensitiveSort);b.unshift("pchat");return b.join(":")}if(a.indexOf("~")==0){return"server:"+a.slice(1)}if(a.indexOf("chat:")!=0&&a.indexOf("server:")!=0&&a.indexOf("pchat:")!=0){return"chat:"+a}return a};Chatterbox.UI.prototype.set_events=function(a){this.events=a||this.events};Chatterbox.UI.prototype.clock=function(a){if(a===undefined||a==this.settings.clock){return this.settings.clock}this.settings.clock=a;this.chatbook.retime();return this.settings.clock};Chatterbox.UI.prototype.build=function(j,a,b){this.view.append(Chatterbox.render("ui",this.settings));this.control=new (j||Chatterbox.Control)(this);this.nav=new (a||Chatterbox.Navigation)(this);this.chatbook=new (b||Chatterbox.Chatbook)(this);
this.pager=new Chatterbox.Pager(this);this.monitoro=this.chatbook.create_channel(this.mns,this.settings.monitor[1],true);this.monitoro.show();this.control.focus();this.sound.bank.m=this.view.find("div.soundbank");this.sound.bank.c=this.sound.bank.m.find("audio.click")[0];this.sound.bank.c.load();var h=this.sound;this.sound.click=function(){h.play(h.bank.c)};var f=false;var d=this.nav.add_button({label:"",icon:"volume",href:"#mute",title:"Mute the client",handler:function(){if(!f){h.mute();d.removeClass("volume");d.addClass("volume_mute");d.prop("title","Unmute the client");f=true;return false}h.unmute();d.removeClass("volume_mute");d.addClass("volume");d.prop("title","Mute the client");f=false;return false}});var g=this;$(window).focus(function(){g.viewing=true});$(window).blur(function(){g.viewing=false});this.client.bind("pkt",function(l,k){g.packet(l,k)});this.client.middle("ns.remove",function(l,k){g.remove_channel(l.ns);k(l)});this.client.bind("ns.create",function(l,k){g.create_channel(l.chan.raw,l.chan.hidden);
-l.chan.ui=g.channel(l.ns)})};Chatterbox.UI.prototype.resize=function(){this.control.resize();this.view.height(this.view.parent().height());this.nav.resize();this.chatbook.resize(((this.view.parent().height()-this.nav.height())-this.control.height())-5)};Chatterbox.UI.prototype.loop=function(){this.chatbook.loop()};Chatterbox.UI.prototype.packet=function(b,a){var d=this;var f=a.protocol.log(b);if(f){if(this.settings.developer){console.log(">>>",b.sns,"|",f.text())}b.html=f.html();this.cascade("log_message",function(h,g){d.chatbook.log_message(h.message,h.event)},{message:f,event:b})}this.chatbook.handle(b,a)};Chatterbox.UI.prototype.create_channel=function(b,a){this.chatbook.create_channel(b,a)};Chatterbox.UI.prototype.remove_channel=function(a){this.chatbook.remove_channel(a)};Chatterbox.UI.prototype.toggle_channel=function(a){return this.chatbook.toggle_channel(a)};Chatterbox.UI.prototype.channel=function(a,b){return this.chatbook.channel(a,b)};Chatterbox.UI.prototype.channels=function(){return this.chatbook.channels()
-};Chatterbox.UI.prototype.channel_left=function(){this.chatbook.channel_left()};Chatterbox.UI.prototype.channel_right=function(){this.chatbook.channel_right()};Chatterbox.UI.prototype.monitor=function(b,a){this.monitoro.server_message(b,a)};Chatterbox.UI.prototype.server_message=function(b,a){this.chatbook.server_message(b,a)};Chatterbox.UI.prototype.log_item=function(a){this.chatbook.log_item(a)};Chatterbox.UI.prototype.log=function(a){this.chatbook.log(a)};Chatterbox.UI.prototype.mute_user=function(a){if(!a){return false}a=a.toLowerCase();if(this.umuted.indexOf(a)!=-1){return false}this.umuted.push(a);this.chatbook.each(function(b,d){d.mute_user(a)});return true};Chatterbox.UI.prototype.unmute_user=function(a){if(!a){return false}a=a.toLowerCase();var b=this.umuted.indexOf(a);if(b==-1){return false}this.umuted.splice(b,1);this.chatbook.each(function(d,f){f.unmute_user(a)});return true};Chatterbox.UI.prototype.clear_user=function(a){this.chatbook.each(function(b,d){d.clear_user(a)})};Chatterbox.UI.prototype.theme=function(a){if(this.settings.theme==a){return this.settings.theme
-}if(this.settings.themes.indexOf(a)==-1){a="wsct_"+a;if(this.settings.themes.indexOf(a)==-1){return this.settings.theme}}this.view.removeClass(this.settings.theme).addClass(a);this.settings.theme=a;this.trigger("theme.set",{name:"theme.set",theme:a});return this.settings.theme};Chatterbox.UI.prototype.add_theme=function(a){if(this.settings.themes.indexOf(a)>-1){return}this.settings.themes.push(a)};Chatterbox.UI.prototype.developer=function(a){this.settings.developer=a;this.chatbook.developer()};Chatterbox.Channel=function(f,b,d,a){this.manager=f;this.hidden=d;this.monitor=(a==undefined?false:a);this.built=false;this.raw=f.format_ns(b);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+f.deform_ns(b).slice(1).toLowerCase();this.namespace=f.deform_ns(b);this.visible=false;this.st=0;this.el={t:{o:null,l:null,c:null,},m:null,l:{p:null,w:null,},u:null,h:{title:null,topic:null}};this.mulw=0;this.d={u:[0,0],h:{title:[0,0],topic:[0,0]}}};Chatterbox.Channel.prototype.build=function(){if(this.built){return
-}var a=this.selector;var d=this.namespace;var b=this.raw;this.el.t.o=this.manager.nav.add_tab(a,d);this.el.t.l=this.el.t.o.find(".tab");this.el.t.c=this.el.t.o.find(".close");this.manager.chatbook.view.append(Chatterbox.render("channel",{selector:a,ns:d}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");this.el.l.p=this.el.m.find("#"+a+"-log");this.el.l.w=this.el.l.p.find("ul.logwrap");this.el.u=this.el.m.find("#"+a+"-users");this.mulw=parseInt(this.el.u.css("max-width").slice(0,-2));var f=this;var g=false;this.el.l.w.click(function(){if(!g){return}f.manager.control.focus()});this.el.l.w.mousedown(function(){g=true});this.el.l.w.mousemove(function(){g=false});this.el.t.l.click(function(){f.manager.toggle_channel(b);return false});this.el.t.c.click(function(h){f.manager.trigger("tab.close.clicked",{ns:f.raw,chan:f,e:h});return false});this.setup_header("title");this.setup_header("topic");if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")
-}this.manager.client.bind(this.namespace+".user.list",function(h){f.set_user_list(h.users)});this.manager.client.middle(this.namespace+".user.privchg",function(j,h){f.privchg(j,h)});this.manager.client.middle(this.namespace+".user.remove",function(j,h){f.remove_one_user(j,h)});this.manager.client.bind(this.namespace+".user.registered",function(h){f.register_user(h.user)});this.built=true};Chatterbox.Channel.prototype.setup_header=function(a){var d=this;var b={};b.m=this.el.m.find("header."+a+" div");b.e=this.el.m.find("header."+a+" a[href=#edit]");b.t=this.el.m.find("header."+a+" textarea");b.s=this.el.m.find("header."+a+" a[href=#save]");b.c=this.el.m.find("header."+a+" a[href=#cancel]");this.el.h[a]=b.m;b.m.parent().mouseover(function(g){if(!b.editing){b.e.css("display","block");return}b.s.css("display","block");b.c.css("display","block")});b.m.parent().mouseout(function(g){if(!b.editing){b.e.css("display","none");return}b.s.css("display","none");b.c.css("display","none")});b.e.click(function(g){b.t.text(d.manager.client.channel(d.namespace).info[a].content);
-b.t.css({display:"block",width:d.el.h[a].innerWidth()-10,});d.el.h[a].css("display","none");b.e.css("display","none");b.editing=true;d.resize();return false});var f=function(){var g=b.t.val();b.t.text("");b.t.css("display","none");d.el.h[a].css("display","block");b.s.css("display","none");b.c.css("display","none");b.editing=false;d.resize();return g};b.s.click(function(g){var h=f();d.manager.trigger(a+".save",{ns:d.raw,value:h});b.t.text("");return false});b.c.click(function(g){f();return false})};Chatterbox.Channel.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.Channel.prototype.show=function(){this.visible=true;this.el.m.css({display:"block"});this.el.t.o.addClass("active");this.el.t.o.removeClass("noise chatting tabbed fill");var a=this;setTimeout(function(){a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight());a.resize();a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight())
-},100)};Chatterbox.Channel.prototype.developer=function(){if(this.manager.settings.developer){this.el.t.o.removeClass("hidden");return}if(this.hidden){this.el.t.o.addClass("hidden")}};Chatterbox.Channel.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.Channel.prototype.scroll=function(){this.pad();var a=this.el.l.w.prop("scrollWidth")-this.el.l.w.innerWidth();var b=this.el.l.w.prop("scrollHeight")-this.el.l.w.innerHeight();if(a>0){b+=a}if(b<0||(b-this.el.l.w.scrollTop())>100){return}this.el.l.w.scrollTop(b)};Chatterbox.Channel.prototype.pad=function(){this.el.l.w.css({"padding-top":0,height:"auto"});var b=this.el.l.w.innerHeight();var a=this.el.l.p.innerHeight()-this.el.h.topic.parent().outerHeight();var d=a-b;if(d>0){this.el.l.w.css({"padding-top":d})}else{this.el.l.w.css({"padding-top":0,height:a})}this.el.l.w.scrollTop(this.st)};Chatterbox.Channel.prototype.resize=function(h,a){var j={title:{m:this.el.m.find("header div.title"),e:this.el.m.find("header.title a[href=#edit]")},topic:{m:this.el.m.find("header div.topic"),e:this.el.m.find("header.topic a[href=#edit]")}};
+l.chan.ui=g.channel(l.ns)});this.client.bind("ns.set.privclasses",function(l,k){g.channel(l.ns).build_user_list(l.names,l.orders)})};Chatterbox.UI.prototype.resize=function(){this.control.resize();this.view.height(this.view.parent().height());this.nav.resize();this.chatbook.resize(((this.view.parent().height()-this.nav.height())-this.control.height())-5)};Chatterbox.UI.prototype.loop=function(){this.chatbook.loop()};Chatterbox.UI.prototype.packet=function(b,a){var d=this;var f=a.protocol.log(b);if(f){if(this.settings.developer){console.log(">>>",b.sns,"|",f.text())}b.html=f.html();this.cascade("log_message",function(h,g){d.chatbook.log_message(h.message,h.event)},{message:f,event:b})}this.chatbook.handle(b,a)};Chatterbox.UI.prototype.create_channel=function(b,a){this.chatbook.create_channel(b,a)};Chatterbox.UI.prototype.remove_channel=function(a){this.chatbook.remove_channel(a)};Chatterbox.UI.prototype.toggle_channel=function(a){return this.chatbook.toggle_channel(a)};Chatterbox.UI.prototype.channel=function(a,b){return this.chatbook.channel(a,b)
+};Chatterbox.UI.prototype.channels=function(){return this.chatbook.channels()};Chatterbox.UI.prototype.channel_left=function(){this.chatbook.channel_left()};Chatterbox.UI.prototype.channel_right=function(){this.chatbook.channel_right()};Chatterbox.UI.prototype.monitor=function(b,a){this.monitoro.server_message(b,a)};Chatterbox.UI.prototype.server_message=function(b,a){this.chatbook.server_message(b,a)};Chatterbox.UI.prototype.log_item=function(a){this.chatbook.log_item(a)};Chatterbox.UI.prototype.log=function(a){this.chatbook.log(a)};Chatterbox.UI.prototype.mute_user=function(a){if(!a){return false}a=a.toLowerCase();if(this.umuted.indexOf(a)!=-1){return false}this.umuted.push(a);this.chatbook.each(function(b,d){d.mute_user(a)});return true};Chatterbox.UI.prototype.unmute_user=function(a){if(!a){return false}a=a.toLowerCase();var b=this.umuted.indexOf(a);if(b==-1){return false}this.umuted.splice(b,1);this.chatbook.each(function(d,f){f.unmute_user(a)});return true};Chatterbox.UI.prototype.clear_user=function(a){this.chatbook.each(function(b,d){d.clear_user(a)
+})};Chatterbox.UI.prototype.theme=function(a){if(this.settings.theme==a){return this.settings.theme}if(this.settings.themes.indexOf(a)==-1){a="wsct_"+a;if(this.settings.themes.indexOf(a)==-1){return this.settings.theme}}this.view.removeClass(this.settings.theme).addClass(a);this.settings.theme=a;this.trigger("theme.set",{name:"theme.set",theme:a});return this.settings.theme};Chatterbox.UI.prototype.add_theme=function(a){if(this.settings.themes.indexOf(a)>-1){return}this.settings.themes.push(a)};Chatterbox.UI.prototype.developer=function(a){this.settings.developer=a;this.chatbook.developer()};Chatterbox.Channel=function(f,b,d,a){this.manager=f;this.hidden=d;this.monitor=(a==undefined?false:a);this.built=false;this.raw=f.format_ns(b);this.selector=(this.raw.substr(0,2)=="pc"?"pc":"c")+"-"+f.deform_ns(b).slice(1).toLowerCase();this.namespace=f.deform_ns(b);this.visible=false;this.st=0;this.el={t:{o:null,l:null,c:null,},m:null,l:{p:null,w:null,},u:null,h:{title:null,topic:null}};this.mulw=0;
+this.d={u:[0,0],h:{title:[0,0],topic:[0,0]}}};Chatterbox.Channel.prototype.build=function(){if(this.built){return}var a=this.selector;var d=this.namespace;var b=this.raw;this.el.t.o=this.manager.nav.add_tab(a,d);this.el.t.l=this.el.t.o.find(".tab");this.el.t.c=this.el.t.o.find(".close");this.manager.chatbook.view.append(Chatterbox.render("channel",{selector:a,ns:d}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");this.el.l.p=this.el.m.find("#"+a+"-log");this.el.l.w=this.el.l.p.find("ul.logwrap");this.el.u=this.el.m.find("#"+a+"-users");this.mulw=parseInt(this.el.u.css("max-width").slice(0,-2));var f=this;var g=false;this.el.l.w.click(function(){if(!g){return}f.manager.control.focus()});this.el.l.w.mousedown(function(){g=true});this.el.l.w.mousemove(function(){g=false});this.el.t.l.click(function(){f.manager.toggle_channel(b);return false});this.el.t.c.click(function(h){f.manager.trigger("tab.close.clicked",{ns:f.raw,chan:f,e:h});return false});this.setup_header("title");
+this.setup_header("topic");if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")}this.manager.client.bind(this.namespace+".user.list",function(h){f.set_user_list(h.users)});this.manager.client.middle(this.namespace+".user.privchg",function(j,h){f.privchg(j,h)});this.manager.client.middle(this.namespace+".user.remove",function(j,h){f.remove_one_user(j,h)});this.manager.client.bind(this.namespace+".user.registered",function(h){f.register_user(h.user)});this.built=true};Chatterbox.Channel.prototype.setup_header=function(a){var d=this;var b={};b.m=this.el.m.find("header."+a+" div");b.e=this.el.m.find("header."+a+" a[href=#edit]");b.t=this.el.m.find("header."+a+" textarea");b.s=this.el.m.find("header."+a+" a[href=#save]");b.c=this.el.m.find("header."+a+" a[href=#cancel]");this.el.h[a]=b.m;b.m.parent().mouseover(function(g){if(!b.editing){b.e.css("display","block");return}b.s.css("display","block");b.c.css("display","block")});b.m.parent().mouseout(function(g){if(!b.editing){b.e.css("display","none");
+return}b.s.css("display","none");b.c.css("display","none")});b.e.click(function(g){b.t.text(d.manager.client.channel(d.namespace).info[a].content);b.t.css({display:"block",width:d.el.h[a].innerWidth()-10,});d.el.h[a].css("display","none");b.e.css("display","none");b.editing=true;d.resize();return false});var f=function(){var g=b.t.val();b.t.text("");b.t.css("display","none");d.el.h[a].css("display","block");b.s.css("display","none");b.c.css("display","none");b.editing=false;d.resize();return g};b.s.click(function(g){var h=f();d.manager.trigger(a+".save",{ns:d.raw,value:h});b.t.text("");return false});b.c.click(function(g){f();return false})};Chatterbox.Channel.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.Channel.prototype.show=function(){this.visible=true;this.el.m.css({display:"block"});this.el.t.o.addClass("active");this.el.t.o.removeClass("noise chatting tabbed fill");var a=this;setTimeout(function(){a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight());
+a.resize();a.el.l.w.scrollTop(a.el.l.w.prop("scrollHeight")-a.el.l.w.innerHeight())},100)};Chatterbox.Channel.prototype.developer=function(){if(this.manager.settings.developer){this.el.t.o.removeClass("hidden");return}if(this.hidden){this.el.t.o.addClass("hidden")}};Chatterbox.Channel.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.Channel.prototype.scroll=function(){this.pad();var a=this.el.l.w.prop("scrollWidth")-this.el.l.w.innerWidth();var b=this.el.l.w.prop("scrollHeight")-this.el.l.w.innerHeight();if(a>0){b+=a}if(b<0||(b-this.el.l.w.scrollTop())>100){return}this.el.l.w.scrollTop(b)};Chatterbox.Channel.prototype.pad=function(){this.el.l.w.css({"padding-top":0,height:"auto"});var b=this.el.l.w.innerHeight();var a=this.el.l.p.innerHeight()-this.el.h.topic.parent().outerHeight();var d=a-b;if(d>0){this.el.l.w.css({"padding-top":d})}else{this.el.l.w.css({"padding-top":0,height:a})}this.el.l.w.scrollTop(this.st)};Chatterbox.Channel.prototype.resize=function(h,a){var j={title:{m:this.el.m.find("header div.title"),e:this.el.m.find("header.title a[href=#edit]")},topic:{m:this.el.m.find("header div.topic"),e:this.el.m.find("header.topic a[href=#edit]")}};
this.el.l.w.css({"padding-top":0});a=a||this.manager.chatbook.height();h=h||this.manager.chatbook.width();var d=a;this.el.m.height(d);this.el.m.css("width",h-10);var b=this.el.m.width();this.el.u.width(1);this.d.u[0]=this.el.u[0].scrollWidth+this.manager.swidth+5;if(this.d.u[0]>this.mulw){this.d.u[0]=this.mulw}this.el.u.width(this.d.u[0]);b=b-this.d.u[0];d=d-j.title.m.parent().outerHeight();this.el.l.p.css({height:d-3,width:b-10});this.scroll();this.d.u[1]=this.el.l.p.innerHeight();this.el.u.css({height:this.d.u[1]});for(var g in j){if(!j.hasOwnProperty(g)){continue}if(j[g].m.html().length==0){continue}var f=(j[g].m.outerHeight(true)-5)*(-1);j[g].e.css("top",f)}};Chatterbox.Channel.prototype.loop=function(){var a=this.el.l.p.find(".logmsg");if(a.length<200){return}a.slice(0,a.length-200).remove();this.resize()};Chatterbox.Channel.prototype.log=function(b){var a=this;this.manager.cascade("log",function(d){a.log_item({html:Chatterbox.render("logmsg",{message:d.message})})},{ns:this.raw,sns:this.namespace,message:b})
};Chatterbox.Channel.prototype.log_item=function(d){var a=new Date();var b="";if(this.manager.settings.clock){b=formatTime("{HH}:{mm}:{ss}",a)}else{b=formatTime("{hh}:{mm}:{ss} {mr}",a)}var f=this;this.manager.cascade("log_item",function(g){if(f.visible){f.st=f.el.l.w.scrollTop()}f.el.l.w.append(Chatterbox.render("logitem",g));f.manager.trigger("log_item.after",{item:f.el.l.w.find("li").last(),chan:f});if(f.visible){f.st+=f.el.l.w.find("li.logmsg").last().height();f.el.l.w.scrollTop(f.st)}f.scroll();f.noise()},{ns:this.namespace,ts:b,ms:a.getTime(),message:d.html,user:(d.user||"system").toLowerCase()})};Chatterbox.Channel.prototype.retime=function(){var a="";var b=this.el.l.w;if(this.manager.settings.clock){a="{HH}:{mm}:{ss}"}else{a="{hh}:{mm}:{ss} {mr}"}b.find("span.ts").each(function(d,f){el=b.find(f);time=new Date(parseInt(el.prop("id")));el.text(formatTime(a,time))})};Chatterbox.Channel.prototype.server_message=function(d,b){var a=this;this.manager.cascade("server_message",function(f){a.log_item({html:Chatterbox.render("servermsg",{message:f.message,info:f.info})})
},{ns:this.namespace,message:d,info:b})};Chatterbox.Channel.prototype.clear=function(){this.el.l.p.find("li.logmsg").remove();this.el.l.p.find("li.loginfo").remove();this.el.l.w.height(0);this.resize()};Chatterbox.Channel.prototype.log_info=function(g,f){var j={ns:this.namespace,ref:g,content:f};this.manager.trigger("log_info.before",j);delete j.ns;var a=this.el.l.w.append(Chatterbox.render("loginfobox",j));this.scroll();var h=this;var d=this.el.l.w.find("li."+j.ref);d.find("a.close").click(function(b){h.el.l.w.find(this).parent().remove();h.resize();return false});this.scroll();return d};Chatterbox.Channel.prototype.log_whois=function(l){var g={avatar:'',username:""+l.symbol+l.username+"",info:[],conns:[],raw:l,};for(var m in l.connections){var k=l.connections[m];var o=[];if(k.online){var a=(new Date-(k.online*1000));o.push(["online",DateStamp(a/1000)+formatTime(" [{HH}:{mm}:{ss}]",new Date(a))])}if(k.idle){o.push(["idle",timeLengthString(k.idle)])
diff --git a/src/channel.js b/src/channel.js
index f146ce3..731fb4b 100644
--- a/src/channel.js
+++ b/src/channel.js
@@ -44,8 +44,12 @@ wsc.Channel = function( client, ns, hidden, monitor ) {
* @method build
*/
wsc.Channel.prototype.build = function( ) {
+
this.info.members = {};
- this.set_privclasses( { pkt: { body: '' } } );
+
+ if( this.namespace[0] == '@' )
+ this.set_privclasses( { pkt: { body: '' } } );
+
};
/**
@@ -167,7 +171,15 @@ wsc.Channel.prototype.set_privclasses = function( e ) {
var names = this.info.pc;
var orders = this.info.pc_order.slice(0);
- this.ui.build_user_list( names, orders );
+ this.client.trigger(
+ 'ns.set.privclasses',
+ {
+ name: 'ns.set.privclasses',
+ ns: this.namespace,
+ names: names,
+ orders: orders
+ }
+ );
};
/**
@@ -230,7 +242,7 @@ wsc.Channel.prototype.set_user_list = function( ) {
this.client.trigger(this.namespace + '.user.list', {
'name': 'set.userlist',
- 'ns': this.info['namespace'],
+ 'ns': this.namespace,
'users': users
});
};
diff --git a/src/ui/base.js b/src/ui/base.js
index 27a0e90..5f12336 100644
--- a/src/ui/base.js
+++ b/src/ui/base.js
@@ -344,6 +344,13 @@ Chatterbox.UI.prototype.build = function( control, navigation, chatbook ) {
}
);
+ this.client.bind(
+ 'ns.set.privclasses',
+ function( event, client ) {
+ ui.channel( event.ns ).build_user_list( event.names, event.orders );
+ }
+ );
+
};
/**