From a40168ae194c68e7dbf556dd62f39ce9795ec4fb Mon Sep 17 00:00:00 2001 From: Henry Rapley Date: Sat, 28 Sep 2013 16:26:34 +0100 Subject: [PATCH] basic commands hooked in with updated system. lots of refactoring needed. #87 --- dist/chatterbox.js | 2 + dist/chatterbox.min.js | 92 +++++++++++++-------------- dist/wsc.dAmn.js | 17 +++-- dist/wsc.dAmn.min.js | 140 ++++++++++++++++++++--------------------- dist/wsc.js | 17 +++-- dist/wsc.min.js | 140 ++++++++++++++++++++--------------------- src/client.js | 4 +- src/commands.js | 11 ++-- src/ui/base.js | 2 + 9 files changed, 224 insertions(+), 201 deletions(-) diff --git a/dist/chatterbox.js b/dist/chatterbox.js index 4fcb5a8..2e2cfc2 100644 --- a/dist/chatterbox.js +++ b/dist/chatterbox.js @@ -22,6 +22,8 @@ Chatterbox._gum = function( ) {}; if( ui == undefined ) { ui = new Chatterbox.UI( $(this), client, options, ($.browser.mozilla || false) ); $(window).resize(ui.resize); + setInterval(function( ) { ui.loop(); }, 120000); + ui.build(); } $(window).data('chatterbox', ui); } diff --git a/dist/chatterbox.min.js b/dist/chatterbox.min.js index 81b0d22..bb8d88f 100644 --- a/dist/chatterbox.min.js +++ b/dist/chatterbox.min.js @@ -1,49 +1,49 @@ -var Chatterbox={};Chatterbox.VERSION="0.20.104";Chatterbox.STATE="beta";Chatterbox._gum=function(){};(function(a){a.fn.chatterbox=function(e,b,c){var d=a(window).data("chatterbox");if(e=="init"||d===undefined){if(d==undefined){d=new Chatterbox.UI(a(this),b,c,(a.browser.mozilla||false));a(window).resize(d.resize)}a(window).data("chatterbox",d)}if(e!="init"&&e!=undefined){e="jq_"+e;if(e in d){d[e](a(this),c)}}return d}})(jQuery);Chatterbox.UI=function(b,a,c,e,d){this.client=a;this.events=d||new EventEmitter();this.mozilla=e;this.umuted=[];this.viewing=true;this.settings={themes:["wsct_dAmn","wsct_dark"],theme:"wsct_dark",monitor:["~Monitor",true],username:"",domain:"website.com",clock:true,tabclose:true,developer:false,media:"/static/"};var f=this;this.sound={bank:{m:null},add:function(g,h){if(f.sound.hasOwnProperty(g)){return false}f.sound.bank[g]=h;h.load();f.sound[g]=function(){f.sound.play(f.sound.bank[g])};return true},play:function(g){g.pause();g.currentTime=0;g.play()},toggle:function(h){for(var g in f.sound.bank){if(!f.sound.bank.hasOwnProperty(g)){continue -}f.sound.bank[g].muted=h}},mute:function(){f.sound.toggle(true)},unmute:function(){f.sound.toggle(false)},};this.settings=b.extend(this.settings,c);b.append('
');this.protocol=new Chatterbox.Protocol();this.mw=new wsc.Middleware();this.view=b.find(".wsc");this.mns=this.format_ns(this.settings.monitor[0]);this.lun=this.settings.username.toLowerCase();this.monitoro=null;this.swidth=(function(){if($.browser.msie){var j=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body"),h=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body");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})();if(window.mozRTCPeerConnection){Chatterbox._gum=function(h,j,g){return navigator.mozGetUserMedia(h,j,g)}}if(window.webkitRTCPeerConnection){Chatterbox._gum=function(h,j,g){return navigator.webkitGetUserMedia(h,j,g)}}if(window.RTCPeerConnection&&!window.mozRTCPeerConnection){Chatterbox._gum=function(h,j,g){return navigator.getUserMedia(h,j,g)}}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(b){var a=b[0];if(a=="#"||a=="@"||a=="~"||a=="+"){return b}if(b.indexOf("chat:")==0){return"#"+b.slice(5)}if(b.indexOf("server:")==0){return"~"+b.slice(7) -}if(b.indexOf("feed:")==0){return"#"+b.slice(5)}if(b.indexOf("login:")==0){return"@"+b.slice(6)}if(b.indexOf("pchat:")==0){var c=b.split(":");c.shift();for(i in c){name=c[i];if(name.toLowerCase()!=this.lun){return"@"+name}}}return"#"+b};Chatterbox.UI.prototype.format_ns=function(a){var c=a.slice(1);switch(a[0]){case"@":var b=[c,this.lun];b.sort(caseInsensitiveSort);b.unshift("pchat");a=b.join(":");break;case"~":a="server:"+c;break;case"+":a="feed:"+c;break;case"#":a="chat:"+c;break;default:if(a.indexOf("chat:")==0||a.indexOf("pchat:")==0||a.indexOf("server:")==0||a.indexOf("feed:")==0){break}a="chat:"+a;break}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.get_user_media=function(b,c,a){Chatterbox._gum(b,c,a)};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.add("click",this.sound.bank.m.find("audio.click")[0]);var f=this.sound;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)});this.client.bind("ns.user.list",function(h){e.channel(h.ns).set_user_list(h.users)});this.client.middle("ns.user.privchg",function(j,h){e.channel(j.ns).privchg(j,h)});this.client.bind("ns.user.remove",function(j,h){e.channel(j.ns).remove_one_user(j.user)});this.client.bind("ns.user.registered",function(h){e.channel(h.ns).register_user(h.user)})};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=this.protocol.log(b);if(d){if(this.settings.developer){console.log(">>>",b.sns,"|",d.text())}if(b.hasOwnProperty("s")&&b.s=="0"){this.chatbook.handle(b,a);return}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.BaseTab=function(d,b,c,a){this.manager=d;this.hidden=c;this.monitor=(a==undefined?false:a);this.built=false;this.raw=b;this.selector="t-"+(b||"chan").toLowerCase();this.namespace=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]}};if(!d){return}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)};Chatterbox.BaseTab.prototype.build=function(b){if(!this.manager){return}if(this.built){return}var a=this.selector;var d=this.namespace;var c=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(b||Chatterbox.render("basetab",{selector:a,ns:d}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");var e=this;this.el.t.l.click(function(){e.manager.toggle_channel(c); -return false});this.el.t.c.click(function(f){e.manager.trigger("tab.close.clicked",{ns:e.raw,chan:e,e:f});return false});if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")}this.built=true};Chatterbox.BaseTab.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.BaseTab.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.BaseTab.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.BaseTab.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.BaseTab.prototype.resize=function(b,a){this.el.m.css({height:a||this.manager.chatbook.height(),width:(b||this.manager.chatbook.width())-10}) -};Chatterbox.BaseTab.prototype.loop=function(){};Chatterbox.Channel=function(d,b,c,a){Chatterbox.BaseTab.call(this,d,b,c,a);this.resized=function(){};this.ulbuf=0};Chatterbox.Channel.prototype=new Chatterbox.BaseTab;Chatterbox.Channel.prototype.constructor=Chatterbox.Channel;Chatterbox.Channel.prototype.build=function(){if(!this.manager){return}if(this.built){return}var a=this.selector;var c=this.namespace;var b=this.raw;Chatterbox.BaseTab.prototype.build.call(this,Chatterbox.render("channel",{selector:a,ns:c}));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.setup_header("title");this.setup_header("topic"); -if(this.namespace[0]=="@"){this.build_user_list({100:"Room Members"},[100])}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.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){Chatterbox.BaseTab.prototype.resize.call(this,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;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.ulbuf});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)}this.resized()};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:'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)]) -}if(h.agent){m.push(["agent",h.agent])}if(h.debug){m.push(["debug",h.debug])}m.push(["chatrooms",h.channels.join(" ")]);e.conns.push(m)}this.manager.trigger("log_whois.before",e);var b="";for(var k in e.conns){var g=e.conns[k];var o='

connection '+((parseInt(k)+1).toString())+":

";o+="
    ";for(var n in g){o+="
  • "+g[n][0]+": "+g[n][1]+"
  • "}o+="
";b+=o+"
"}var f="";for(var k in e.info){f+="
  • "+e.info[k]+"
  • "}var l=this.log_info("whois-"+j.username,Chatterbox.render("whoiswrap",{avatar:e.avatar,info:Chatterbox.render("whoisinfo",{username:e.username,info:f,connections:b})}));var d=l.find("div.avatar");var c=l.find("div.info");c.width(l.find(".whoiswrap").width()-100);d.height(l.height()-10);this.scroll()};Chatterbox.Channel.prototype.log_pc=function(d,e){contents="";for(var c in e){if(!e.hasOwnProperty(c)){continue}var b=e[c];var a="";if(b[2].length==0){a=""+(d?"default privileges":"no members")+""}else{a=b[2] -}contents+=String.format("
  • {0} {1}:
    • {2}
  • ",[b[1],b[0],a])}var f={title:"Privilege class "+(d?"permissions":"members"),info:"
      "+contents+"
    "};this.log_info("pc-"+(d?"permissions":"members"),Chatterbox.render("pcinfo",f))};Chatterbox.Channel.prototype.set_header=function(a,d,f,c){a=a.toLowerCase();var b=this.el.m.find("header."+a+" a[href=#edit]");if(this.el.h[a].html()!=""){if(d.html().length!=0){this.server_message(a+" set by "+f)}}this.el.h[a].html(d.html());var e=this;setTimeout(function(){if(d.text().length>0){e.el.h[a].css({display:"block"});var g=(e.el.h[a].outerHeight(true)-5)*(-1);b.css("top",g)}else{e.el.h[a].css({display:"none"})}e.resize()},100)};Chatterbox.Channel.prototype.get_header=function(a){return this.el.h[a.toLowerCase()]};Chatterbox.Channel.prototype.build_user_list=function(d,a){var f=this.el.u;var c="";var e=null;f.html("");for(var b in a){var c=d[a[b]];f.append('

    '+c+"

      "); -e=f.find(".pc#"+c);e.css("display","none")}};Chatterbox.Channel.prototype.reveal_user_list=function(){var f=this.el.u;var d=0;var b=0;var a=null;f.find("div.pc").each(function(c,g){a=f.find(this);b=a.find("ul li").length;d+=b;a.css("display",(b==0?"none":"block"))});f.css("display",(d==0?"none":"block"));var e=this;setTimeout(function(){e.resize()},100)};Chatterbox.Channel.prototype.set_user_list=function(d){if(Object.size(d)==0){return}var c=this.el.u;var a=null;for(var b in d){a=d[b];this.set_user(a,true)}this.reveal_user_list()};Chatterbox.Channel.prototype.set_user=function(f,d){var h=this.el.u.find("div.pc#"+replaceAll(f.pc," ","-"));var a=h.find("ul");var b=f.conn==1?"":"["+f.conn+"]";var g='
    • '+f.symbol+""+f.name+""+b+"
    • ";if(a.find("a#"+f.name).length==1){return}if(a.find("li").length==0){a.append(g)}else{var j=f.name.toLowerCase();var l=null;var e=false;a.find("li a").each(function(){if(e){return -}l=a.find(this);if(j"}f.window.append(Chatterbox.render("userinfo",{username:b.name,avatar:b.avatar,link:b.link,info:g}));d=f.window.find(".userinfo#"+b.name);f.window.find("div.userinfo:not('#"+b.name+"')").remove();var j=e.offset();d.css({top:(j.top-e.height())+10,left:(j.left-(d.width()))-6});d.find(".info").height(d.height());d.hover(function(){d.data("hover",1)},function(k){d.data("hover",0);f.unhover_user(d,k)});d.data("hover",0)};var c=function(g){e.data("hover",0);f.unhover_user(d,g)};e.off("mouseenter",a);e.off("mouseleave",c);e.on("mouseenter",a);e.on("mouseleave",c)};Chatterbox.Channel.prototype.unhover_user=function(d,c){var e=d.offset();var b=d.outerHeight(true)+e.top;var g=d.outerWidth(true)+e.left;var a=c.pageX;var f=c.pageY;if(a>e.left&&ae.top&&fe.left&&f>e.top&&f<(e.top+15)){return -}d.remove()};Chatterbox.Channel.prototype.mute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"none"});this.scroll()};Chatterbox.Channel.prototype.unmute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"list-item"});this.scroll()};Chatterbox.Channel.prototype.clear_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).remove();this.scroll()};Chatterbox.Channel.prototype.pkt_join=function(b,a){if(b.e!="ok"){return}this.set_header("title",(new wsc.MessageString("")),"","");this.set_header("topic",(new wsc.MessageString("")),"","")};Chatterbox.Channel.prototype.pkt_recv_msg=function(b,a){var d=this;this.manager.cascade("chan.recv_msg",function(g,c){var f=d.manager.client.settings.username.toLowerCase();if(f==g.user.toLowerCase()){return}var j=g.message.toLowerCase();var h=j.indexOf(f)!=-1;if(!h&&g.sns[0]!="@"){return}if(h){d.highlight()}else{d.highlight(false)}d.manager.trigger("tabbed",g) -},b)};Chatterbox.Channel.prototype.pkt_recv_action=Chatterbox.Channel.prototype.pkt_recv_msg;Chatterbox.Channel.prototype.pkt_property=function(b,a){var e=b.pkt.arg.p;var d=a.channel(this.namespace);switch(e){case"title":case"topic":this.set_header(e,b.value||(new wsc.MessageString("")),b.by,b.ts);break;case"privclasses":this.build_user_list(d.info.pc,d.info.pc_order.slice(0));break;case"members":break;default:break}};Chatterbox.Chatbook=function(a){this.manager=a;this.view=this.manager.view.find("div.chatbook");this.chan={};this.trail=[];this.current=null;this.manager.on("tab.close.clicked",function(b,c){c.chatbook.remove_channel(b.ns)})};Chatterbox.Chatbook.prototype.height=function(){return this.view.height()};Chatterbox.Chatbook.prototype.width=function(){return this.view.width()};Chatterbox.Chatbook.prototype.resize=function(b){b=b||600;var c=this.view.innerWidth();for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}var d=this.chan[a];d.resize(c,b)}};Chatterbox.Chatbook.prototype.loop=function(){for(select in this.chan){this.chan[select].loop() -}};Chatterbox.Chatbook.prototype.channel=function(a,b){a=this.manager.format_ns(a).toLowerCase();if(!this.chan[a]&&b){this.chan[a]=b}return this.chan[a]};Chatterbox.Chatbook.prototype.channels=function(){chans=-1;for(ns in this.chan){if(this.chan[ns].hidden){continue}chans++}return chans};Chatterbox.Chatbook.prototype.create_channel=function(b,c,a){var d=this.channel(b,this.channel_object(b,c,a));d.build();if(this.trail.indexOf(d.namespace)==-1){this.trail.push(d.namespace)}if(!d.visible){this.toggle_channel(b)}this.manager.resize();return d};Chatterbox.Chatbook.prototype.channel_object=function(a,b){return new Chatterbox.Channel(this.manager,a,b)};Chatterbox.Chatbook.prototype.toggle_channel=function(a){var c=this.channel(a);var b=c;if(!c){return}if(c.hidden){if(this.current&&this.current==c){return}if(!this.manager.settings.developer){c.hide();return}}if(this.current){if(this.current==c){return}this.current.hide();b=this.current}else{if(this.manager.monitoro!==null){this.manager.monitoro.hide() -}}c.show();this.manager.control.focus();this.current=c;this.manager.resize();this.manager.control.cache_input(b,c);this.manager.trigger("channel.selected",{ns:c.raw,chan:c,prev:b});this.manager.client.select_ns(c.raw)};Chatterbox.Chatbook.prototype.remove_channel=function(a){var b=this.channel(a);if(!b){return}if(this.channels()==0&&!b.hidden){return}b.remove();delete this.chan[b.raw.toLowerCase()];if(this.current==b){this.channel_left()}var c=this.trail.indexOf(b.namespace);this.trail.splice(c,1)};Chatterbox.Chatbook.prototype.channel_left=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a<0){return}var d=null;while(true){try{d=this.channel(this.trail[--a])}catch(c){a=this.trail.length-1;d=this.channel(this.trail[a])}if(!d.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(d.namespace)};Chatterbox.Chatbook.prototype.channel_right=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a==-1){return}var d=null;while(true){try{d=this.channel(this.trail[++a]) -}catch(c){a=0;d=this.channel(this.trail[0])}if(!d.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(d.namespace)};Chatterbox.Chatbook.prototype.each=function(c){var b=null;for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}b=this.chan[a];if(c(b.namespace,b)===false){break}}};Chatterbox.Chatbook.prototype.server_message=function(b,a){for(ns in this.chan){this.chan[ns].server_message(b,a)}};Chatterbox.Chatbook.prototype.log_item=function(a){for(ns in this.chan){this.chan[ns].log_item(a)}};Chatterbox.Chatbook.prototype.log=function(a){for(ns in this.chan){this.chan[ns].log(a)}};Chatterbox.Chatbook.prototype.log_message=function(c,b){try{if(!c.global){if(!c.monitor){this.channel(b.ns).log_item(b)}else{this.manager.monitoro.log_item(b)}}else{this.log_item(b)}}catch(a){try{this.ui.monitoro.server_message("Failed to log for",b.sns,b.html)}catch(a){console.log(">> Failed to log message for",b.sns,"::");console.log(">>",b.html)}}};Chatterbox.Chatbook.prototype.retime=function(){for(ns in this.chan){this.chan[ns].retime() -}};Chatterbox.Chatbook.prototype.developer=function(){this.each(function(a,b){b.developer()})};Chatterbox.Chatbook.prototype.handle=function(d,b){var e=this.manager;var f=this.channel(d.ns);if(!f){return}var a="pkt_"+d.name;try{f[a](d,b)}catch(c){}};Chatterbox.Control=function(b){this.manager=b;this.manager.view.append(Chatterbox.template.control);this.view=this.manager.view.find("div.chatcontrol");this.ml=false;this.history={};this.tab={hit:false,cache:"",matched:[],index:-1,type:0,prefix:["","/",""],};this.el={form:this.view.find("form.msg"),i:{s:this.view.find("form.msg input.msg"),m:this.view.find("form.msg textarea.msg"),c:null,t:this.view.find("ul.buttons a[href~=#multiline].button")},brow:{m:this.view.find("div.brow"),b:this.view.find("div.brow ul.buttons"),s:this.view.find("div.brow ul.states")}};this.el.i.c=this.el.i.s;var a=this;this.el.i.t.click(function(c){a.multiline(!a.multiline());return false});this.el.i.s.keydown(function(c){return a.keypress(c)});this.el.i.m.keydown(function(c){return a.keypress(c) -});this.el.form.submit(function(c){return a.submit(c)});this.add_button({label:"b",icon:false,href:"#bold",title:"Bold text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"i",icon:false,href:"#italic",title:"Italic text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"u",icon:false,href:"#underline",title:"Underline text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sup",icon:false,href:"#sup",title:"Superscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sub",icon:false,href:"#sub",title:"Subscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}})};Chatterbox.Control.prototype.surroundtext=function(h,g,b){var f=h.scrollTop;var a=h.value,c=h.selectionStart,d=h.selectionEnd;var j=h.value.substring(c,d);h.value=a.substring(0,c)+g+j+b+a.substring(d);h.selectionStart=c+g.length; -h.selectionEnd=c+g.length+j.length;h.scrollTop=f;h.focus()};Chatterbox.Control.prototype.focus=function(){this.el.i.c.focus()};Chatterbox.Control.prototype.resize=function(){w=this.manager.view.width();this.view.css({width:"100%"});this.el.form.css({width:this.manager.view.width()-20});this.el.i.s.css({width:this.manager.view.width()-100});this.el.i.m.css({width:this.manager.view.width()-90})};Chatterbox.Control.prototype.height=function(){var a=this.view.outerHeight();return a};Chatterbox.Control.prototype.multiline=function(a){if(a==undefined||this.ml==a){return this.ml}this.ml=a;var b=(this.ml?"s":"m");a=(this.ml?"m":"s");this.el.i[b].css("display","none");this.el.i[a].css("display","inline-block");this.el.i.c=this.el.i[a];this.manager.resize();return this.ml};Chatterbox.Control.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.brow.b.append(Chatterbox.render("brow_button",a)); -var b=this.el.brow.b.find("a[href="+a.href+"].button");b.click(function(c){a.handler();return false});return b};Chatterbox.Control.prototype.add_state=function(a){a=Object.extend({ref:"state",label:"some state"},(a||{}));var b=this.el.brow.s.find("li#"+a.ref);if(b.length==0){this.el.brow.s.append(Chatterbox.render("brow_state",a));return this.el.brow.s.find("li#"+a.ref)}b.html(a.label);return b};Chatterbox.Control.prototype.rem_state=function(a){return this.el.brow.s.find("li#"+a).remove()};Chatterbox.Control.prototype.chomp=function(){var c=this.el.i.c.val();var b=c.lastIndexOf(" ");if(b==-1){this.el.i.c.val("");return c}var a=c.slice(b+1);this.el.i.c.val(c.slice(0,b));if(a.length==0){return this.chomp()}return a};Chatterbox.Control.prototype.unchomp=function(a){var b=this.el.i.c.val();if(!b){this.el.i.c.val(a)}else{this.el.i.c.val(b+" "+a)}};Chatterbox.Control.prototype.get_text=function(a){if(a==undefined){return this.el.i.c.val()}this.el.i.c.val(a||"");return this.el.i.c.val()};Chatterbox.Control.prototype.set_text=function(a){this.el.i.c.val(a||"") -};Chatterbox.Control.prototype.cache_input=function(b,c){var a=this.get_history(b.namespace);if(a.index>-1){return}a.tmp=this.get_text();this.set_text(this.get_history(c.namespace).tmp)};Chatterbox.Control.prototype.get_history=function(a){if(!a){if(!this.manager.chatbook.current){a="~monitor"}}a=a||this.manager.chatbook.current.namespace;if(!this.history[a]){this.history[a]={index:-1,list:[],tmp:""}}return this.history[a]};Chatterbox.Control.prototype.append_history=function(b){if(!b){return}var a=this.get_history();a.list.unshift(b);a.index=-1;if(a.list.length>100){a.list.pop()}};Chatterbox.Control.prototype.scroll_history=function(a){var c=this.get_history();var b=this.get_text();if(c.index==-1){if(b){c.tmp=b}else{c.list[c.index]=b}}if(a){if(c.list.length>0&&c.index<(c.list.length-1)){c.index++}}else{if(c.index>-1){c.index--}}this.set_text(c.list[c.index]||c.tmp)};Chatterbox.Control.prototype.tab_item=function(b){if(!this.tab.hit){this.start_tab(b)}this.chomp();this.tab.index++;if(this.tab.index>=this.tab.matched.length){this.tab.index=-1 -}if(this.tab.index==-1){this.unchomp(this.tab.prefix[this.tab.type]+this.tab.cache);return}var a=this.get_text()==""?(this.tab.type==0?": ":" "):"";this.unchomp(this.tab.prefix[this.tab.type]+this.tab.matched[this.tab.index]+a)};Chatterbox.Control.prototype.start_tab=function(d){this.tab.hit=true;this.tab.index=-1;this.tab.matched=[];this.tab.type=0;var g=this.chomp();this.unchomp(g);if(g[0]=="/"||g[0]=="#"||g[0]=="@"){this.tab.type=g[0]=="/"?1:2;if(g[0]=="/"){g=g.slice(1)}}else{this.tab.type=0}this.tab.cache=g;g=g.toLowerCase();this.tab.matched=[];if(this.tab.type==0){var h=this.manager.client.channel(this.manager.chatbook.current.namespace);for(var a in h.info.members){if(a.toLowerCase().indexOf(g)==0){this.tab.matched.push(a)}}}else{if(this.tab.type==1){var f="";for(var b in this.manager.client.cmds){f=this.manager.client.cmds[b];if(f.indexOf(g)==0){this.tab.matched.push(f)}}}else{if(this.tab.type==2){var e=this;this.manager.client.each_channel(function(c,j){if(j.namespace.toLowerCase().indexOf(g)==0){e.tab.matched.push(j.namespace) -}})}}}};Chatterbox.Control.prototype.end_tab=function(a){this.tab.hit=false;this.tab.matched=[];this.tab.cache="";this.tab.index=-1};Chatterbox.Control.prototype.submit=function(a){var b=this.get_text();this.append_history(b);this.set_text("");this.handle(a,b);return false};Chatterbox.Control.prototype.keypress=function(c){var b=c.which||c.keyCode;var d=this.tab.hit;var a=false;switch(b){case 13:if(!this.multiline()){this.submit(c)}else{if(c.shiftKey){this.submit(c)}else{a=true}}break;case 38:if(!this.multiline()){this.scroll_history(true);break}a=true;break;case 40:if(!this.multiline()){this.scroll_history(false);break}a=true;break;case 9:if(c.shiftKey){this.manager.channel_right()}else{this.tab_item(c);d=false}break;case 219:if(c.ctrlKey){this.manager.channel_left()}else{a=true}break;case 221:if(c.ctrlKey){this.manager.channel_right()}else{a=true}break;default:a=true;break}if(d){this.end_tab(c)}return a};Chatterbox.Control.prototype.handle=function(b,e){if(e==""){return}if(!this.manager.chatbook.current){return -}var h=false;if(e[0]!="/"){h=true}e=(b.shiftKey?"/npmsg ":(e[0]=="/"?"":"/say "))+e;e=e.slice(1);var j=e.split(" ");var c=j.shift().toLowerCase();var g=this.manager.chatbook.current.namespace;var f=g;if(!h&&j[0]){var d=j[0][0];if((d=="#"||d=="@")&&j[0].length>1){f=this.manager.format_ns(j.shift())}}var k=j.join(" ");var a=this.manager.client.trigger("cmd."+c,{name:"cmd",cmd:c,args:k,target:f,ns:g});if(a==0){this.manager.pager.notice({ref:"cmd-fail",heading:"Command failed",content:'"'+c+'" is not a command.'},false,5000)}};Chatterbox.Navigation=function(a){this.manager=a;this.showclose=this.manager.settings.tabclose;this.settings={};this.settings.open=false;this.el={n:this.manager.view.find("nav.tabs"),tw:this.manager.view.find("nav.tabs div.tabwrap"),t:this.manager.view.find("nav.tabs #chattabs"),b:this.manager.view.find("nav.tabs #tabnav"),l:this.manager.view.find("nav.tabs #tabnav .arrow_left"),r:this.manager.view.find("nav.tabs #tabnav .arrow_right"),s:this.manager.view.find("nav.tabs #tabnav #settings-button"),}; -if(!this.showclose){if(!this.el.t.hasClass("hc")){this.el.t.addClass("hc")}}var b=this;this.el.s.click(function(e){if(b.settings.open){return false}var c={e:e,settings:new Chatterbox.Settings.Config(b.manager)};b.configure_page(c);b.manager.trigger("settings.open",c);b.manager.trigger("settings.open.ran",c);var d=c.settings.page("About");d.item("text",{ref:"about-chatterbox",wclass:"centered faint",text:'Using Chatterbox version '+Chatterbox.VERSION+" "+Chatterbox.STATE+' by ~photofroggy.'});b.settings.window=new Chatterbox.Settings(b.manager,c.settings);b.settings.window.build();b.settings.open=true;return false});this.el.l.click(function(){b.manager.channel_left();return false});this.el.r.click(function(){b.manager.channel_right();return false})};Chatterbox.Navigation.prototype.configure_page=function(b){var d=this.manager;var c=b.settings.page("Main");var e={};e.theme=replaceAll(d.settings.theme,"wsct_",""); -e.clock=d.clock();e.tc=d.nav.closer();var a=[];for(i in d.settings.themes){name=replaceAll(d.settings.themes[i],"wsct_","");a.push({value:name,title:name,selected:e.theme==name})}c.item("Form",{ref:"ui",title:"UI",hint:"Timestamp
      Choose between a 24 hour clock and a 12 hour clock.\n\nTheme
      Change the look of the client.\n\nClose Buttons
      Turn tab close buttons on/off.",fields:[["Dropdown",{ref:"theme",label:"Theme",items:a}],["Dropdown",{ref:"clock",label:"Timestamp Format",items:[{value:"24",title:"24 hour",selected:e.clock},{value:"12",title:"12 hour",selected:!e.clock}]}],["Checkbox",{ref:"tabclose",label:"Close Buttons",items:[{value:"yes",title:"On",selected:e.tc}]}],],event:{change:function(f){d.clock(f.data.clock=="24");d.theme(f.data.theme);d.nav.closer(f.data.tabclose.indexOf("yes")>-1)},save:function(f){e.clock=d.clock();e.theme=replaceAll(d.theme(),"wsct_","");e.tc=d.nav.closer();d.trigger("settings.save.ui",{clock:e.clock,tabclose:e.tc,theme:"wsct_"+e.theme}) -},close:function(f){d.clock(e.clock);d.theme(e.theme);d.nav.closer(e.tc)}}})};Chatterbox.Navigation.prototype.height=function(){var a=this.el.n.outerHeight();return a};Chatterbox.Navigation.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.b.prepend(Chatterbox.render("nav_button",a));var b=this.el.b.find("a[href="+a.href+"].button");b.click(function(c){a.handler();return false});this.resize();return b};Chatterbox.Navigation.prototype.add_tab=function(a,b){this.el.t.append(Chatterbox.render("tab",{selector:a,ns:b}));return this.el.t.find("#"+a+"-tab")};Chatterbox.Navigation.prototype.resize=function(){this.el.tw.width(this.el.n.width()-this.el.b.outerWidth()-20);if(this.settings.open){this.settings.window.resize()}};Chatterbox.Navigation.prototype.closer=function(a){if(a==undefined||a==this.showclose){return this.showclose}this.showclose=a; -if(this.showclose){if(!this.el.t.hasClass("hc")){return}this.el.t.removeClass("hc");return}if(this.el.t.hasClass("hc")){return}this.el.t.addClass("hc")};Chatterbox.Pager=function(a){this.manager=a;this.lifespan=20000;this.halflife=5000;this.el={m:null,click:null};this.sound={click:function(){},};this.notices=[];this.build()};Chatterbox.Pager.prototype.build=function(){this.el.m=this.manager.view.find("div.pager")};Chatterbox.Pager.prototype.notice=function(d,j,h,c){var f={frame:null,close:null,foot:null,b:{},options:Object.extend({ref:"notice",icon:"",heading:"Some notice",content:"Notice content goes here."},(d||{})),onclose:function(){},ondestroy:function(){}};f.options.ref+="-"+(new Date()).valueOf();f.options.content=f.options.content.split("\n").join("

      ");this.notices.push(f);this.el.m.append(Chatterbox.render("pager.notice",f.options));f.frame=this.el.m.find("#"+f.options.ref).last();f.close=f.frame.find("a.close_notice");f.foot=f.frame.find("footer.buttons");var e={};for(var a in f.options.buttons){if(!f.options.buttons.hasOwnProperty(a)){continue -}e=f.options.buttons[a];f.foot.append(Chatterbox.render("pager.button",e));f.b[a]=f.foot.find("a#"+e.ref);f.b[a].click(e.click)}var g=this;f.close.click(function(){f.onclose();g.remove_notice(f);return false});if(!j){if(!h){h=g.lifespan}setTimeout(function(){g.remove_notice(f,true)},h)}if(c!==true){this.manager.sound.click()}return f};Chatterbox.Pager.prototype.remove_notice=function(a,c){var b=this;if(this.notices.indexOf(a)==-1){return false}a.frame.fadeTo((c?this.halflife:300),0).slideUp(function(){a.frame.remove();b.notices.splice(b.notices.indexOf(a),1);a.ondestroy()});if(c){a.frame.mouseenter(function(){if(b.notices.indexOf(a)==-1){return}a.frame.stop(true);a.frame.slideDown(function(){a.frame.fadeTo(300,1);a.frame.mouseleave(function(){setTimeout(function(){b.remove_notice(a,true)},b.lifespan)})})})}};Chatterbox.Pager.prototype.find_notice=function(a){for(var b in this.notices){if(this.notices[b].options.ref==a){return this.notices[b]}}return null};Chatterbox.Popup=function(b,a){this.manager=b; -this.pview=(this.manager||{view:{find:function(){}}}).view;this.window=null;this.closeb=null;this.options=Object.extend({ref:"popup",title:"Popup",close:true,content:""},(a||{}))};Chatterbox.Popup.prototype.build=function(){var b=this.options;if(this.options.close){b.title+=''}this.pview.append(Chatterbox.render("popup",b));this.window=this.pview.find(".floater."+b.ref);if(this.options.close){this.closeb=this.window.find("a.close");var a=this;this.closeb.click(function(c){a.close();return false})}};Chatterbox.Popup.prototype.close=function(){this.window.remove()};Chatterbox.Popup.Prompt=function(b,a){a=a||{};a=Object.extend({position:[0,0],ref:"prompt",title:"Input",close:false,label:"","default":"","submit-button":"Submit",event:{submit:function(){},cancel:function(){}}},a);Chatterbox.Popup.call(this,b,a);this.data=this.options["default"]};Chatterbox.Popup.Prompt.prototype=new Chatterbox.Popup();Chatterbox.Popup.Prompt.prototype.constructor=Chatterbox.Popup.Prompt; -Chatterbox.Popup.Prompt.prototype.build=function(){this.options.content=Chatterbox.template.prompt.main;Chatterbox.Popup.prototype.build.call(this);this.window.css({left:this.options.position[0],top:this.options.position[1]});var a=this;this.window.find(".button.close").click(function(){a.options.event.cancel(a);a.close();return false});this.window.find(".button.submit").click(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false});this.window.find("form").submit(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false})};Chatterbox.Popup.ItemPicker=function(b,a){a=a||{};a=Object.extend({position:[100,60],ref:"item-picker",title:"Items",event:{select:function(c){}}},a);Chatterbox.Popup.call(this,b,a);this.pview=this.pview.find(".chatbook");this.data=this.options["default"];this.pages=[];this.cpage=null};Chatterbox.Popup.ItemPicker.prototype=new Chatterbox.Popup();Chatterbox.Popup.ItemPicker.prototype.constructor=Chatterbox.Popup.ItemPicker; -Chatterbox.Popup.ItemPicker.prototype.build=function(){this.options.content=Chatterbox.render("ip.main",{});Chatterbox.Popup.prototype.build.call(this);this.window.css({right:this.options.position[0],bottom:this.options.position[1]});this.closeb.removeClass("medium");this.pbook=this.window.find("section.pages");this.tabs=this.window.find("section.tabs ul");this.buttons=this.window.find("section.buttons");var c=this;var b=null;for(var a in this.pages){if(!this.pages.hasOwnProperty(a)){continue}b=this.pages[a];b.build();if(a==0){this.select_page(b)}}};Chatterbox.Popup.ItemPicker.prototype.refresh=function(){if(this.cpage==null){return}else{this.cpage.refresh()}};Chatterbox.Popup.ItemPicker.prototype.page=function(b,a){b=b.toLowerCase();for(var c in this.pages){if(!this.pages.hasOwnProperty(c)){continue}if(this.pages[c].name.toLowerCase()==b){return this.pages[c]}}return(a||null)};Chatterbox.Popup.ItemPicker.prototype.add_page=function(a,b){this.pages.push(new (b||Chatterbox.Popup.ItemPicker.Page)(this,a)) -};Chatterbox.Popup.ItemPicker.prototype.add_button=function(a){a=Object.extend({href:"#button",title:"Button",label:"Button"},(a||{}));this.buttons.append(Chatterbox.render("ip.button",a));return this.buttons.find("a[href="+a.href+"]")};Chatterbox.Popup.ItemPicker.prototype.select=function(a){this.options.event.select(a)};Chatterbox.Popup.ItemPicker.prototype.select_page=function(a){if(!a){return}if(this.cpage!=null){this.cpage.hide()}this.cpage=a||null;if(this.cpage!=null){this.cpage.show()}};Chatterbox.Popup.ItemPicker.Page=function(b,a){this.picker=b;this.options=Object.extend({ref:"page",href:"#page",label:"Page",title:"page",items:[],content:"No items on this page.",},(a||{}));this.name=this.options.label;this.nrefresh=true};Chatterbox.Popup.ItemPicker.Page.prototype.build=function(){this.picker.pbook.append(Chatterbox.render("ip.page",this.options));this.picker.tabs.append(Chatterbox.render("ip.tab",this.options));this.view=this.picker.pbook.find("div.page#"+this.options.ref); -this.items=this.view.find("ul");this.tab=this.picker.tabs.find("#"+this.options.ref);this.refresh();var a=this;this.tab.find("a").click(function(){a.picker.select_page(a);return false})};Chatterbox.Popup.ItemPicker.Page.prototype.refresh=function(){var a=this.build_list();if(a.length==0){this.options.content="No items on this page."}else{this.options.content="

        "+a+"
      "}this.view.html(this.options.content);this.items=this.view.find("ul");this.hook_events();this.nrefresh=false};Chatterbox.Popup.ItemPicker.Page.prototype.hook_events=function(){var a=this;this.items.find("li").each(function(b,d){var e=a.view.find(d);var c=e.find(".value").html();e.click(function(){a.picker.select(c)})})};Chatterbox.Popup.ItemPicker.Page.prototype.build_list=function(){var c=[];var d=null;var f,e,b;for(var a in this.options.items){if(!this.options.items.hasOwnProperty(a)){continue}d=this.options.items[a];e=d.value||d;f=d.title||e;b=d.html||false;c.push('
    • '+(b?e:''+e+"")+"
    • ") -}return c.join("")};Chatterbox.Popup.ItemPicker.Page.prototype.show=function(){this.tab.addClass("selected");this.view.css("display","block");this.refresh()};Chatterbox.Popup.ItemPicker.Page.prototype.hide=function(){this.tab.removeClass("selected");this.view.css("display","none")};Chatterbox.Protocol=function(){this.messages={chatserver:{keys:["version"],template:'** Connected to llama {version} *',global:true},dAmnServer:{keys:["version"],template:'** Connected to dAmnServer {version} *',global:true},login:{keys:["username","e","data"],template:'** Login as {username}: "{e}" *',global:true},join:{keys:["ns","e"],template:'** Join {ns}: "{e}" *',monitor:true},part:{keys:["ns","e","r"],template:'** Part {ns}: "{e}" * {r}',monitor:true},property:{keys:["ns","p","by","ts","value"],template:'** Got {p} for {ns} *',monitor:true},recv_msg:{keys:["user","message"],template:'<{user}>{message}'},recv_action:{keys:["s","user","message"],template:'* {user}{message}'},recv_join:{keys:["user","s","info"],template:'** {user} has joined *',},recv_part:{keys:["user","r"],template:'** {user} has left * {r}'},recv_privchg:{keys:["user","s","by","pc"],template:'** {user} has been made a member of {pc} by {by} *'},recv_kicked:{keys:["user","s","by","r"],template:'** {user} has been kicked by {by} * {r}'},recv_admin_create:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been created by {user} * {privs}'},recv_admin_update:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been updated by {user} * {privs}'},recv_admin_rename:{keys:["p","user","prev","pc"],template:'** Privilege class {prev} has been renamed to {pc} by {user} *'},recv_admin_move:{keys:["p","user","prev","pc","affected"],template:'** All members of {prev} have been moved to {pc} by {user} * {affected} affected user(s)'},recv_admin_remove:{keys:["p","user","pc","affected"],template:'** Privilege class {pc} has been removed by {user} * {affected} affected user(s)'},recv_admin_show:null,recv_admin_showverbose:null,recv_admin_privclass:{keys:["p","e","command"],template:'** Admin command "{command}" failed * {e}'},kicked:{keys:["ns","user","r"],template:'** You have been kicked by {user} * {r}'},ping:null,disconnect:{keys:["e"],template:'** You have been disconnected * {e}',global:true},send:{keys:["ns","e"],template:'** Send error: {e}'},kick:{keys:["ns","user","e"],template:'** Could not kick {user} * {e}'},get:{keys:["ns","p","e"],template:'** Could not get {p} info for {ns} * {e}'},set:{keys:["ns","p","e"],template:'** Could not set {p} * {e}'},kill:{keys:["ns","e"],template:'** Kill error * {e}'},unknown:{keys:["ns","packet"],template:'** Received unknown packet in {ns} * {packet}',monitor:true}} +var Chatterbox={};Chatterbox.VERSION="0.20.104";Chatterbox.STATE="beta";Chatterbox._gum=function(){};(function(a){a.fn.chatterbox=function(e,b,c){var d=a(window).data("chatterbox");if(e=="init"||d===undefined){if(d==undefined){d=new Chatterbox.UI(a(this),b,c,(a.browser.mozilla||false));a(window).resize(d.resize);setInterval(function(){d.loop()},120000);d.build()}a(window).data("chatterbox",d)}if(e!="init"&&e!=undefined){e="jq_"+e;if(e in d){d[e](a(this),c)}}return d}})(jQuery);Chatterbox.UI=function(b,a,c,e,d){this.client=a;this.events=d||new EventEmitter();this.mozilla=e;this.umuted=[];this.viewing=true;this.settings={themes:["wsct_dAmn","wsct_dark"],theme:"wsct_dark",monitor:["~Monitor",true],username:"",domain:"website.com",clock:true,tabclose:true,developer:false,media:"/static/"};var f=this;this.sound={bank:{m:null},add:function(g,h){if(f.sound.hasOwnProperty(g)){return false}f.sound.bank[g]=h;h.load();f.sound[g]=function(){f.sound.play(f.sound.bank[g])};return true},play:function(g){g.pause(); +g.currentTime=0;g.play()},toggle:function(h){for(var g in f.sound.bank){if(!f.sound.bank.hasOwnProperty(g)){continue}f.sound.bank[g].muted=h}},mute:function(){f.sound.toggle(true)},unmute:function(){f.sound.toggle(false)},};this.settings=b.extend(this.settings,c);b.append('
      ');this.protocol=new Chatterbox.Protocol();this.mw=new wsc.Middleware();this.view=b.find(".wsc");this.mns=this.format_ns(this.settings.monitor[0]);this.lun=this.settings.username.toLowerCase();this.monitoro=null;this.swidth=(function(){if($.browser.msie){var j=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body"),h=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body");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})();if(window.mozRTCPeerConnection){Chatterbox._gum=function(h,j,g){return navigator.mozGetUserMedia(h,j,g)}}if(window.webkitRTCPeerConnection){Chatterbox._gum=function(h,j,g){return navigator.webkitGetUserMedia(h,j,g)}}if(window.RTCPeerConnection&&!window.mozRTCPeerConnection){Chatterbox._gum=function(h,j,g){return navigator.getUserMedia(h,j,g)}}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(b){var a=b[0];if(a=="#"||a=="@"||a=="~"||a=="+"){return b}if(b.indexOf("chat:")==0){return"#"+b.slice(5) +}if(b.indexOf("server:")==0){return"~"+b.slice(7)}if(b.indexOf("feed:")==0){return"#"+b.slice(5)}if(b.indexOf("login:")==0){return"@"+b.slice(6)}if(b.indexOf("pchat:")==0){var c=b.split(":");c.shift();for(i in c){name=c[i];if(name.toLowerCase()!=this.lun){return"@"+name}}}return"#"+b};Chatterbox.UI.prototype.format_ns=function(a){var c=a.slice(1);switch(a[0]){case"@":var b=[c,this.lun];b.sort(caseInsensitiveSort);b.unshift("pchat");a=b.join(":");break;case"~":a="server:"+c;break;case"+":a="feed:"+c;break;case"#":a="chat:"+c;break;default:if(a.indexOf("chat:")==0||a.indexOf("pchat:")==0||a.indexOf("server:")==0||a.indexOf("feed:")==0){break}a="chat:"+a;break}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.get_user_media=function(b,c,a){Chatterbox._gum(b,c,a) +};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.add("click",this.sound.bank.m.find("audio.click")[0]);var f=this.sound;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)});this.client.bind("ns.user.list",function(h){e.channel(h.ns).set_user_list(h.users)});this.client.middle("ns.user.privchg",function(j,h){e.channel(j.ns).privchg(j,h)});this.client.bind("ns.user.remove",function(j,h){e.channel(j.ns).remove_one_user(j.user)});this.client.bind("ns.user.registered",function(h){e.channel(h.ns).register_user(h.user)})};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=this.protocol.log(b);if(d){if(this.settings.developer){console.log(">>>",b.sns,"|",d.text())}if(b.hasOwnProperty("s")&&b.s=="0"){this.chatbook.handle(b,a); +return}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.BaseTab=function(d,b,c,a){this.manager=d;this.hidden=c;this.monitor=(a==undefined?false:a);this.built=false;this.raw=b;this.selector="t-"+(b||"chan").toLowerCase();this.namespace=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]}};if(!d){return}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)};Chatterbox.BaseTab.prototype.build=function(b){if(!this.manager){return}if(this.built){return}var a=this.selector;var d=this.namespace;var c=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(b||Chatterbox.render("basetab",{selector:a,ns:d})); +this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");var e=this;this.el.t.l.click(function(){e.manager.toggle_channel(c);return false});this.el.t.c.click(function(f){e.manager.trigger("tab.close.clicked",{ns:e.raw,chan:e,e:f});return false});if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")}this.built=true};Chatterbox.BaseTab.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.BaseTab.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.BaseTab.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.BaseTab.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.BaseTab.prototype.resize=function(b,a){this.el.m.css({height:a||this.manager.chatbook.height(),width:(b||this.manager.chatbook.width())-10})};Chatterbox.BaseTab.prototype.loop=function(){};Chatterbox.Channel=function(d,b,c,a){Chatterbox.BaseTab.call(this,d,b,c,a);this.resized=function(){};this.ulbuf=0};Chatterbox.Channel.prototype=new Chatterbox.BaseTab;Chatterbox.Channel.prototype.constructor=Chatterbox.Channel;Chatterbox.Channel.prototype.build=function(){if(!this.manager){return}if(this.built){return}var a=this.selector;var c=this.namespace;var b=this.raw;Chatterbox.BaseTab.prototype.build.call(this,Chatterbox.render("channel",{selector:a,ns:c}));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.setup_header("title");this.setup_header("topic");if(this.namespace[0]=="@"){this.build_user_list({100:"Room Members"},[100])}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.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){Chatterbox.BaseTab.prototype.resize.call(this,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;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.ulbuf});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) +}this.resized()};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:'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)])}if(h.agent){m.push(["agent",h.agent])}if(h.debug){m.push(["debug",h.debug])}m.push(["chatrooms",h.channels.join(" ")]);e.conns.push(m)}this.manager.trigger("log_whois.before",e);var b="";for(var k in e.conns){var g=e.conns[k];var o='

      connection '+((parseInt(k)+1).toString())+":

      ";o+="
        ";for(var n in g){o+="
      • "+g[n][0]+": "+g[n][1]+"
      • "}o+="
      ";b+=o+"
      "}var f="";for(var k in e.info){f+="
    • "+e.info[k]+"
    • "}var l=this.log_info("whois-"+j.username,Chatterbox.render("whoiswrap",{avatar:e.avatar,info:Chatterbox.render("whoisinfo",{username:e.username,info:f,connections:b})})); +var d=l.find("div.avatar");var c=l.find("div.info");c.width(l.find(".whoiswrap").width()-100);d.height(l.height()-10);this.scroll()};Chatterbox.Channel.prototype.log_pc=function(d,e){contents="";for(var c in e){if(!e.hasOwnProperty(c)){continue}var b=e[c];var a="";if(b[2].length==0){a=""+(d?"default privileges":"no members")+""}else{a=b[2]}contents+=String.format("
    • {0} {1}:
      • {2}
    • ",[b[1],b[0],a])}var f={title:"Privilege class "+(d?"permissions":"members"),info:"
        "+contents+"
      "};this.log_info("pc-"+(d?"permissions":"members"),Chatterbox.render("pcinfo",f))};Chatterbox.Channel.prototype.set_header=function(a,d,f,c){a=a.toLowerCase();var b=this.el.m.find("header."+a+" a[href=#edit]");if(this.el.h[a].html()!=""){if(d.html().length!=0){this.server_message(a+" set by "+f)}}this.el.h[a].html(d.html());var e=this;setTimeout(function(){if(d.text().length>0){e.el.h[a].css({display:"block"});var g=(e.el.h[a].outerHeight(true)-5)*(-1); +b.css("top",g)}else{e.el.h[a].css({display:"none"})}e.resize()},100)};Chatterbox.Channel.prototype.get_header=function(a){return this.el.h[a.toLowerCase()]};Chatterbox.Channel.prototype.build_user_list=function(d,a){var f=this.el.u;var c="";var e=null;f.html("");for(var b in a){var c=d[a[b]];f.append('

      '+c+"

        ");e=f.find(".pc#"+c);e.css("display","none")}};Chatterbox.Channel.prototype.reveal_user_list=function(){var f=this.el.u;var d=0;var b=0;var a=null;f.find("div.pc").each(function(c,g){a=f.find(this);b=a.find("ul li").length;d+=b;a.css("display",(b==0?"none":"block"))});f.css("display",(d==0?"none":"block"));var e=this;setTimeout(function(){e.resize()},100)};Chatterbox.Channel.prototype.set_user_list=function(d){if(Object.size(d)==0){return}var c=this.el.u;var a=null;for(var b in d){a=d[b];this.set_user(a,true)}this.reveal_user_list()};Chatterbox.Channel.prototype.set_user=function(f,d){var h=this.el.u.find("div.pc#"+replaceAll(f.pc," ","-")); +var a=h.find("ul");var b=f.conn==1?"":"["+f.conn+"]";var g='
      • '+f.symbol+""+f.name+""+b+"
      • ";if(a.find("a#"+f.name).length==1){return}if(a.find("li").length==0){a.append(g)}else{var j=f.name.toLowerCase();var l=null;var e=false;a.find("li a").each(function(){if(e){return}l=a.find(this);if(j"}f.window.append(Chatterbox.render("userinfo",{username:b.name,avatar:b.avatar,link:b.link,info:g}));d=f.window.find(".userinfo#"+b.name);f.window.find("div.userinfo:not('#"+b.name+"')").remove();var j=e.offset();d.css({top:(j.top-e.height())+10,left:(j.left-(d.width()))-6});d.find(".info").height(d.height());d.hover(function(){d.data("hover",1)},function(k){d.data("hover",0);f.unhover_user(d,k)});d.data("hover",0)};var c=function(g){e.data("hover",0); +f.unhover_user(d,g)};e.off("mouseenter",a);e.off("mouseleave",c);e.on("mouseenter",a);e.on("mouseleave",c)};Chatterbox.Channel.prototype.unhover_user=function(d,c){var e=d.offset();var b=d.outerHeight(true)+e.top;var g=d.outerWidth(true)+e.left;var a=c.pageX;var f=c.pageY;if(a>e.left&&ae.top&&fe.left&&f>e.top&&f<(e.top+15)){return}d.remove()};Chatterbox.Channel.prototype.mute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"none"});this.scroll()};Chatterbox.Channel.prototype.unmute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"list-item"});this.scroll()};Chatterbox.Channel.prototype.clear_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).remove();this.scroll()};Chatterbox.Channel.prototype.pkt_join=function(b,a){if(b.e!="ok"){return}this.set_header("title",(new wsc.MessageString("")),"","");this.set_header("topic",(new wsc.MessageString("")),"","") +};Chatterbox.Channel.prototype.pkt_recv_msg=function(b,a){var d=this;this.manager.cascade("chan.recv_msg",function(g,c){var f=d.manager.client.settings.username.toLowerCase();if(f==g.user.toLowerCase()){return}var j=g.message.toLowerCase();var h=j.indexOf(f)!=-1;if(!h&&g.sns[0]!="@"){return}if(h){d.highlight()}else{d.highlight(false)}d.manager.trigger("tabbed",g)},b)};Chatterbox.Channel.prototype.pkt_recv_action=Chatterbox.Channel.prototype.pkt_recv_msg;Chatterbox.Channel.prototype.pkt_property=function(b,a){var e=b.pkt.arg.p;var d=a.channel(this.namespace);switch(e){case"title":case"topic":this.set_header(e,b.value||(new wsc.MessageString("")),b.by,b.ts);break;case"privclasses":this.build_user_list(d.info.pc,d.info.pc_order.slice(0));break;case"members":break;default:break}};Chatterbox.Chatbook=function(a){this.manager=a;this.view=this.manager.view.find("div.chatbook");this.chan={};this.trail=[];this.current=null;this.manager.on("tab.close.clicked",function(b,c){c.chatbook.remove_channel(b.ns) +})};Chatterbox.Chatbook.prototype.height=function(){return this.view.height()};Chatterbox.Chatbook.prototype.width=function(){return this.view.width()};Chatterbox.Chatbook.prototype.resize=function(b){b=b||600;var c=this.view.innerWidth();for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}var d=this.chan[a];d.resize(c,b)}};Chatterbox.Chatbook.prototype.loop=function(){for(select in this.chan){this.chan[select].loop()}};Chatterbox.Chatbook.prototype.channel=function(a,b){a=this.manager.format_ns(a).toLowerCase();if(!this.chan[a]&&b){this.chan[a]=b}return this.chan[a]};Chatterbox.Chatbook.prototype.channels=function(){chans=-1;for(ns in this.chan){if(this.chan[ns].hidden){continue}chans++}return chans};Chatterbox.Chatbook.prototype.create_channel=function(b,c,a){var d=this.channel(b,this.channel_object(b,c,a));d.build();if(this.trail.indexOf(d.namespace)==-1){this.trail.push(d.namespace)}if(!d.visible){this.toggle_channel(b)}this.manager.resize();return d};Chatterbox.Chatbook.prototype.channel_object=function(a,b){return new Chatterbox.Channel(this.manager,a,b) +};Chatterbox.Chatbook.prototype.toggle_channel=function(a){var c=this.channel(a);var b=c;if(!c){return}if(c.hidden){if(this.current&&this.current==c){return}if(!this.manager.settings.developer){c.hide();return}}if(this.current){if(this.current==c){return}this.current.hide();b=this.current}else{if(this.manager.monitoro!==null){this.manager.monitoro.hide()}}c.show();this.manager.control.focus();this.current=c;this.manager.resize();this.manager.control.cache_input(b,c);this.manager.trigger("channel.selected",{ns:c.raw,chan:c,prev:b});this.manager.client.select_ns(c.raw)};Chatterbox.Chatbook.prototype.remove_channel=function(a){var b=this.channel(a);if(!b){return}if(this.channels()==0&&!b.hidden){return}b.remove();delete this.chan[b.raw.toLowerCase()];if(this.current==b){this.channel_left()}var c=this.trail.indexOf(b.namespace);this.trail.splice(c,1)};Chatterbox.Chatbook.prototype.channel_left=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a<0){return}var d=null;while(true){try{d=this.channel(this.trail[--a]) +}catch(c){a=this.trail.length-1;d=this.channel(this.trail[a])}if(!d.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(d.namespace)};Chatterbox.Chatbook.prototype.channel_right=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a==-1){return}var d=null;while(true){try{d=this.channel(this.trail[++a])}catch(c){a=0;d=this.channel(this.trail[0])}if(!d.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(d.namespace)};Chatterbox.Chatbook.prototype.each=function(c){var b=null;for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}b=this.chan[a];if(c(b.namespace,b)===false){break}}};Chatterbox.Chatbook.prototype.server_message=function(b,a){for(ns in this.chan){this.chan[ns].server_message(b,a)}};Chatterbox.Chatbook.prototype.log_item=function(a){for(ns in this.chan){this.chan[ns].log_item(a)}};Chatterbox.Chatbook.prototype.log=function(a){for(ns in this.chan){this.chan[ns].log(a)}};Chatterbox.Chatbook.prototype.log_message=function(c,b){try{if(!c.global){if(!c.monitor){this.channel(b.ns).log_item(b) +}else{this.manager.monitoro.log_item(b)}}else{this.log_item(b)}}catch(a){try{this.ui.monitoro.server_message("Failed to log for",b.sns,b.html)}catch(a){console.log(">> Failed to log message for",b.sns,"::");console.log(">>",b.html)}}};Chatterbox.Chatbook.prototype.retime=function(){for(ns in this.chan){this.chan[ns].retime()}};Chatterbox.Chatbook.prototype.developer=function(){this.each(function(a,b){b.developer()})};Chatterbox.Chatbook.prototype.handle=function(d,b){var e=this.manager;var f=this.channel(d.ns);if(!f){return}var a="pkt_"+d.name;try{f[a](d,b)}catch(c){}};Chatterbox.Control=function(b){this.manager=b;this.manager.view.append(Chatterbox.template.control);this.view=this.manager.view.find("div.chatcontrol");this.ml=false;this.history={};this.tab={hit:false,cache:"",matched:[],index:-1,type:0,prefix:["","/",""],};this.el={form:this.view.find("form.msg"),i:{s:this.view.find("form.msg input.msg"),m:this.view.find("form.msg textarea.msg"),c:null,t:this.view.find("ul.buttons a[href~=#multiline].button")},brow:{m:this.view.find("div.brow"),b:this.view.find("div.brow ul.buttons"),s:this.view.find("div.brow ul.states")}}; +this.el.i.c=this.el.i.s;var a=this;this.el.i.t.click(function(c){a.multiline(!a.multiline());return false});this.el.i.s.keydown(function(c){return a.keypress(c)});this.el.i.m.keydown(function(c){return a.keypress(c)});this.el.form.submit(function(c){return a.submit(c)});this.add_button({label:"b",icon:false,href:"#bold",title:"Bold text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"i",icon:false,href:"#italic",title:"Italic text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"u",icon:false,href:"#underline",title:"Underline text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sup",icon:false,href:"#sup",title:"Superscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sub",icon:false,href:"#sub",title:"Subscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}})}; +Chatterbox.Control.prototype.surroundtext=function(h,g,b){var f=h.scrollTop;var a=h.value,c=h.selectionStart,d=h.selectionEnd;var j=h.value.substring(c,d);h.value=a.substring(0,c)+g+j+b+a.substring(d);h.selectionStart=c+g.length;h.selectionEnd=c+g.length+j.length;h.scrollTop=f;h.focus()};Chatterbox.Control.prototype.focus=function(){this.el.i.c.focus()};Chatterbox.Control.prototype.resize=function(){w=this.manager.view.width();this.view.css({width:"100%"});this.el.form.css({width:this.manager.view.width()-20});this.el.i.s.css({width:this.manager.view.width()-100});this.el.i.m.css({width:this.manager.view.width()-90})};Chatterbox.Control.prototype.height=function(){var a=this.view.outerHeight();return a};Chatterbox.Control.prototype.multiline=function(a){if(a==undefined||this.ml==a){return this.ml}this.ml=a;var b=(this.ml?"s":"m");a=(this.ml?"m":"s");this.el.i[b].css("display","none");this.el.i[a].css("display","inline-block");this.el.i.c=this.el.i[a];this.manager.resize();return this.ml +};Chatterbox.Control.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.brow.b.append(Chatterbox.render("brow_button",a));var b=this.el.brow.b.find("a[href="+a.href+"].button");b.click(function(c){a.handler();return false});return b};Chatterbox.Control.prototype.add_state=function(a){a=Object.extend({ref:"state",label:"some state"},(a||{}));var b=this.el.brow.s.find("li#"+a.ref);if(b.length==0){this.el.brow.s.append(Chatterbox.render("brow_state",a));return this.el.brow.s.find("li#"+a.ref)}b.html(a.label);return b};Chatterbox.Control.prototype.rem_state=function(a){return this.el.brow.s.find("li#"+a).remove()};Chatterbox.Control.prototype.chomp=function(){var c=this.el.i.c.val();var b=c.lastIndexOf(" ");if(b==-1){this.el.i.c.val("");return c}var a=c.slice(b+1);this.el.i.c.val(c.slice(0,b));if(a.length==0){return this.chomp()}return a +};Chatterbox.Control.prototype.unchomp=function(a){var b=this.el.i.c.val();if(!b){this.el.i.c.val(a)}else{this.el.i.c.val(b+" "+a)}};Chatterbox.Control.prototype.get_text=function(a){if(a==undefined){return this.el.i.c.val()}this.el.i.c.val(a||"");return this.el.i.c.val()};Chatterbox.Control.prototype.set_text=function(a){this.el.i.c.val(a||"")};Chatterbox.Control.prototype.cache_input=function(b,c){var a=this.get_history(b.namespace);if(a.index>-1){return}a.tmp=this.get_text();this.set_text(this.get_history(c.namespace).tmp)};Chatterbox.Control.prototype.get_history=function(a){if(!a){if(!this.manager.chatbook.current){a="~monitor"}}a=a||this.manager.chatbook.current.namespace;if(!this.history[a]){this.history[a]={index:-1,list:[],tmp:""}}return this.history[a]};Chatterbox.Control.prototype.append_history=function(b){if(!b){return}var a=this.get_history();a.list.unshift(b);a.index=-1;if(a.list.length>100){a.list.pop()}};Chatterbox.Control.prototype.scroll_history=function(a){var c=this.get_history(); +var b=this.get_text();if(c.index==-1){if(b){c.tmp=b}else{c.list[c.index]=b}}if(a){if(c.list.length>0&&c.index<(c.list.length-1)){c.index++}}else{if(c.index>-1){c.index--}}this.set_text(c.list[c.index]||c.tmp)};Chatterbox.Control.prototype.tab_item=function(b){if(!this.tab.hit){this.start_tab(b)}this.chomp();this.tab.index++;if(this.tab.index>=this.tab.matched.length){this.tab.index=-1}if(this.tab.index==-1){this.unchomp(this.tab.prefix[this.tab.type]+this.tab.cache);return}var a=this.get_text()==""?(this.tab.type==0?": ":" "):"";this.unchomp(this.tab.prefix[this.tab.type]+this.tab.matched[this.tab.index]+a)};Chatterbox.Control.prototype.start_tab=function(d){this.tab.hit=true;this.tab.index=-1;this.tab.matched=[];this.tab.type=0;var g=this.chomp();this.unchomp(g);if(g[0]=="/"||g[0]=="#"||g[0]=="@"){this.tab.type=g[0]=="/"?1:2;if(g[0]=="/"){g=g.slice(1)}}else{this.tab.type=0}this.tab.cache=g;g=g.toLowerCase();this.tab.matched=[];if(this.tab.type==0){var h=this.manager.client.channel(this.manager.chatbook.current.namespace); +for(var a in h.info.members){if(a.toLowerCase().indexOf(g)==0){this.tab.matched.push(a)}}}else{if(this.tab.type==1){var f="";for(var b in this.manager.client.cmds){f=this.manager.client.cmds[b];if(f.indexOf(g)==0){this.tab.matched.push(f)}}}else{if(this.tab.type==2){var e=this;this.manager.client.each_channel(function(c,j){if(j.namespace.toLowerCase().indexOf(g)==0){e.tab.matched.push(j.namespace)}})}}}};Chatterbox.Control.prototype.end_tab=function(a){this.tab.hit=false;this.tab.matched=[];this.tab.cache="";this.tab.index=-1};Chatterbox.Control.prototype.submit=function(a){var b=this.get_text();this.append_history(b);this.set_text("");this.handle(a,b);return false};Chatterbox.Control.prototype.keypress=function(c){var b=c.which||c.keyCode;var d=this.tab.hit;var a=false;switch(b){case 13:if(!this.multiline()){this.submit(c)}else{if(c.shiftKey){this.submit(c)}else{a=true}}break;case 38:if(!this.multiline()){this.scroll_history(true);break}a=true;break;case 40:if(!this.multiline()){this.scroll_history(false); +break}a=true;break;case 9:if(c.shiftKey){this.manager.channel_right()}else{this.tab_item(c);d=false}break;case 219:if(c.ctrlKey){this.manager.channel_left()}else{a=true}break;case 221:if(c.ctrlKey){this.manager.channel_right()}else{a=true}break;default:a=true;break}if(d){this.end_tab(c)}return a};Chatterbox.Control.prototype.handle=function(b,e){if(e==""){return}if(!this.manager.chatbook.current){return}var h=false;if(e[0]!="/"){h=true}e=(b.shiftKey?"/npmsg ":(e[0]=="/"?"":"/say "))+e;e=e.slice(1);var j=e.split(" ");var c=j.shift().toLowerCase();var g=this.manager.chatbook.current.namespace;var f=g;if(!h&&j[0]){var d=j[0][0];if((d=="#"||d=="@")&&j[0].length>1){f=this.manager.format_ns(j.shift())}}var k=j.join(" ");var a=this.manager.client.trigger("cmd."+c,{name:"cmd",cmd:c,args:k,target:f,ns:g});if(a==0){this.manager.pager.notice({ref:"cmd-fail",heading:"Command failed",content:'"'+c+'" is not a command.'},false,5000)}};Chatterbox.Navigation=function(a){this.manager=a;this.showclose=this.manager.settings.tabclose; +this.settings={};this.settings.open=false;this.el={n:this.manager.view.find("nav.tabs"),tw:this.manager.view.find("nav.tabs div.tabwrap"),t:this.manager.view.find("nav.tabs #chattabs"),b:this.manager.view.find("nav.tabs #tabnav"),l:this.manager.view.find("nav.tabs #tabnav .arrow_left"),r:this.manager.view.find("nav.tabs #tabnav .arrow_right"),s:this.manager.view.find("nav.tabs #tabnav #settings-button"),};if(!this.showclose){if(!this.el.t.hasClass("hc")){this.el.t.addClass("hc")}}var b=this;this.el.s.click(function(e){if(b.settings.open){return false}var c={e:e,settings:new Chatterbox.Settings.Config(b.manager)};b.configure_page(c);b.manager.trigger("settings.open",c);b.manager.trigger("settings.open.ran",c);var d=c.settings.page("About");d.item("text",{ref:"about-chatterbox",wclass:"centered faint",text:'Using Chatterbox version '+Chatterbox.VERSION+" "+Chatterbox.STATE+' by ~photofroggy.'}); +b.settings.window=new Chatterbox.Settings(b.manager,c.settings);b.settings.window.build();b.settings.open=true;return false});this.el.l.click(function(){b.manager.channel_left();return false});this.el.r.click(function(){b.manager.channel_right();return false})};Chatterbox.Navigation.prototype.configure_page=function(b){var d=this.manager;var c=b.settings.page("Main");var e={};e.theme=replaceAll(d.settings.theme,"wsct_","");e.clock=d.clock();e.tc=d.nav.closer();var a=[];for(i in d.settings.themes){name=replaceAll(d.settings.themes[i],"wsct_","");a.push({value:name,title:name,selected:e.theme==name})}c.item("Form",{ref:"ui",title:"UI",hint:"Timestamp
        Choose between a 24 hour clock and a 12 hour clock.\n\nTheme
        Change the look of the client.\n\nClose Buttons
        Turn tab close buttons on/off.",fields:[["Dropdown",{ref:"theme",label:"Theme",items:a}],["Dropdown",{ref:"clock",label:"Timestamp Format",items:[{value:"24",title:"24 hour",selected:e.clock},{value:"12",title:"12 hour",selected:!e.clock}]}],["Checkbox",{ref:"tabclose",label:"Close Buttons",items:[{value:"yes",title:"On",selected:e.tc}]}],],event:{change:function(f){d.clock(f.data.clock=="24"); +d.theme(f.data.theme);d.nav.closer(f.data.tabclose.indexOf("yes")>-1)},save:function(f){e.clock=d.clock();e.theme=replaceAll(d.theme(),"wsct_","");e.tc=d.nav.closer();d.trigger("settings.save.ui",{clock:e.clock,tabclose:e.tc,theme:"wsct_"+e.theme})},close:function(f){d.clock(e.clock);d.theme(e.theme);d.nav.closer(e.tc)}}})};Chatterbox.Navigation.prototype.height=function(){var a=this.el.n.outerHeight();return a};Chatterbox.Navigation.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.b.prepend(Chatterbox.render("nav_button",a));var b=this.el.b.find("a[href="+a.href+"].button");b.click(function(c){a.handler();return false});this.resize();return b};Chatterbox.Navigation.prototype.add_tab=function(a,b){this.el.t.append(Chatterbox.render("tab",{selector:a,ns:b}));return this.el.t.find("#"+a+"-tab")};Chatterbox.Navigation.prototype.resize=function(){this.el.tw.width(this.el.n.width()-this.el.b.outerWidth()-20); +if(this.settings.open){this.settings.window.resize()}};Chatterbox.Navigation.prototype.closer=function(a){if(a==undefined||a==this.showclose){return this.showclose}this.showclose=a;if(this.showclose){if(!this.el.t.hasClass("hc")){return}this.el.t.removeClass("hc");return}if(this.el.t.hasClass("hc")){return}this.el.t.addClass("hc")};Chatterbox.Pager=function(a){this.manager=a;this.lifespan=20000;this.halflife=5000;this.el={m:null,click:null};this.sound={click:function(){},};this.notices=[];this.build()};Chatterbox.Pager.prototype.build=function(){this.el.m=this.manager.view.find("div.pager")};Chatterbox.Pager.prototype.notice=function(d,j,h,c){var f={frame:null,close:null,foot:null,b:{},options:Object.extend({ref:"notice",icon:"",heading:"Some notice",content:"Notice content goes here."},(d||{})),onclose:function(){},ondestroy:function(){}};f.options.ref+="-"+(new Date()).valueOf();f.options.content=f.options.content.split("\n").join("

        ");this.notices.push(f);this.el.m.append(Chatterbox.render("pager.notice",f.options)); +f.frame=this.el.m.find("#"+f.options.ref).last();f.close=f.frame.find("a.close_notice");f.foot=f.frame.find("footer.buttons");var e={};for(var a in f.options.buttons){if(!f.options.buttons.hasOwnProperty(a)){continue}e=f.options.buttons[a];f.foot.append(Chatterbox.render("pager.button",e));f.b[a]=f.foot.find("a#"+e.ref);f.b[a].click(e.click)}var g=this;f.close.click(function(){f.onclose();g.remove_notice(f);return false});if(!j){if(!h){h=g.lifespan}setTimeout(function(){g.remove_notice(f,true)},h)}if(c!==true){this.manager.sound.click()}return f};Chatterbox.Pager.prototype.remove_notice=function(a,c){var b=this;if(this.notices.indexOf(a)==-1){return false}a.frame.fadeTo((c?this.halflife:300),0).slideUp(function(){a.frame.remove();b.notices.splice(b.notices.indexOf(a),1);a.ondestroy()});if(c){a.frame.mouseenter(function(){if(b.notices.indexOf(a)==-1){return}a.frame.stop(true);a.frame.slideDown(function(){a.frame.fadeTo(300,1);a.frame.mouseleave(function(){setTimeout(function(){b.remove_notice(a,true) +},b.lifespan)})})})}};Chatterbox.Pager.prototype.find_notice=function(a){for(var b in this.notices){if(this.notices[b].options.ref==a){return this.notices[b]}}return null};Chatterbox.Popup=function(b,a){this.manager=b;this.pview=(this.manager||{view:{find:function(){}}}).view;this.window=null;this.closeb=null;this.options=Object.extend({ref:"popup",title:"Popup",close:true,content:""},(a||{}))};Chatterbox.Popup.prototype.build=function(){var b=this.options;if(this.options.close){b.title+=''}this.pview.append(Chatterbox.render("popup",b));this.window=this.pview.find(".floater."+b.ref);if(this.options.close){this.closeb=this.window.find("a.close");var a=this;this.closeb.click(function(c){a.close();return false})}};Chatterbox.Popup.prototype.close=function(){this.window.remove()};Chatterbox.Popup.Prompt=function(b,a){a=a||{};a=Object.extend({position:[0,0],ref:"prompt",title:"Input",close:false,label:"","default":"","submit-button":"Submit",event:{submit:function(){},cancel:function(){}}},a); +Chatterbox.Popup.call(this,b,a);this.data=this.options["default"]};Chatterbox.Popup.Prompt.prototype=new Chatterbox.Popup();Chatterbox.Popup.Prompt.prototype.constructor=Chatterbox.Popup.Prompt;Chatterbox.Popup.Prompt.prototype.build=function(){this.options.content=Chatterbox.template.prompt.main;Chatterbox.Popup.prototype.build.call(this);this.window.css({left:this.options.position[0],top:this.options.position[1]});var a=this;this.window.find(".button.close").click(function(){a.options.event.cancel(a);a.close();return false});this.window.find(".button.submit").click(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false});this.window.find("form").submit(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false})};Chatterbox.Popup.ItemPicker=function(b,a){a=a||{};a=Object.extend({position:[100,60],ref:"item-picker",title:"Items",event:{select:function(c){}}},a);Chatterbox.Popup.call(this,b,a);this.pview=this.pview.find(".chatbook"); +this.data=this.options["default"];this.pages=[];this.cpage=null};Chatterbox.Popup.ItemPicker.prototype=new Chatterbox.Popup();Chatterbox.Popup.ItemPicker.prototype.constructor=Chatterbox.Popup.ItemPicker;Chatterbox.Popup.ItemPicker.prototype.build=function(){this.options.content=Chatterbox.render("ip.main",{});Chatterbox.Popup.prototype.build.call(this);this.window.css({right:this.options.position[0],bottom:this.options.position[1]});this.closeb.removeClass("medium");this.pbook=this.window.find("section.pages");this.tabs=this.window.find("section.tabs ul");this.buttons=this.window.find("section.buttons");var c=this;var b=null;for(var a in this.pages){if(!this.pages.hasOwnProperty(a)){continue}b=this.pages[a];b.build();if(a==0){this.select_page(b)}}};Chatterbox.Popup.ItemPicker.prototype.refresh=function(){if(this.cpage==null){return}else{this.cpage.refresh()}};Chatterbox.Popup.ItemPicker.prototype.page=function(b,a){b=b.toLowerCase();for(var c in this.pages){if(!this.pages.hasOwnProperty(c)){continue +}if(this.pages[c].name.toLowerCase()==b){return this.pages[c]}}return(a||null)};Chatterbox.Popup.ItemPicker.prototype.add_page=function(a,b){this.pages.push(new (b||Chatterbox.Popup.ItemPicker.Page)(this,a))};Chatterbox.Popup.ItemPicker.prototype.add_button=function(a){a=Object.extend({href:"#button",title:"Button",label:"Button"},(a||{}));this.buttons.append(Chatterbox.render("ip.button",a));return this.buttons.find("a[href="+a.href+"]")};Chatterbox.Popup.ItemPicker.prototype.select=function(a){this.options.event.select(a)};Chatterbox.Popup.ItemPicker.prototype.select_page=function(a){if(!a){return}if(this.cpage!=null){this.cpage.hide()}this.cpage=a||null;if(this.cpage!=null){this.cpage.show()}};Chatterbox.Popup.ItemPicker.Page=function(b,a){this.picker=b;this.options=Object.extend({ref:"page",href:"#page",label:"Page",title:"page",items:[],content:"No items on this page.",},(a||{}));this.name=this.options.label;this.nrefresh=true};Chatterbox.Popup.ItemPicker.Page.prototype.build=function(){this.picker.pbook.append(Chatterbox.render("ip.page",this.options)); +this.picker.tabs.append(Chatterbox.render("ip.tab",this.options));this.view=this.picker.pbook.find("div.page#"+this.options.ref);this.items=this.view.find("ul");this.tab=this.picker.tabs.find("#"+this.options.ref);this.refresh();var a=this;this.tab.find("a").click(function(){a.picker.select_page(a);return false})};Chatterbox.Popup.ItemPicker.Page.prototype.refresh=function(){var a=this.build_list();if(a.length==0){this.options.content="No items on this page."}else{this.options.content="

          "+a+"
        "}this.view.html(this.options.content);this.items=this.view.find("ul");this.hook_events();this.nrefresh=false};Chatterbox.Popup.ItemPicker.Page.prototype.hook_events=function(){var a=this;this.items.find("li").each(function(b,d){var e=a.view.find(d);var c=e.find(".value").html();e.click(function(){a.picker.select(c)})})};Chatterbox.Popup.ItemPicker.Page.prototype.build_list=function(){var c=[];var d=null;var f,e,b;for(var a in this.options.items){if(!this.options.items.hasOwnProperty(a)){continue +}d=this.options.items[a];e=d.value||d;f=d.title||e;b=d.html||false;c.push('
      • '+(b?e:''+e+"")+"
      • ")}return c.join("")};Chatterbox.Popup.ItemPicker.Page.prototype.show=function(){this.tab.addClass("selected");this.view.css("display","block");this.refresh()};Chatterbox.Popup.ItemPicker.Page.prototype.hide=function(){this.tab.removeClass("selected");this.view.css("display","none")};Chatterbox.Protocol=function(){this.messages={chatserver:{keys:["version"],template:'** Connected to llama {version} *',global:true},dAmnServer:{keys:["version"],template:'** Connected to dAmnServer {version} *',global:true},login:{keys:["username","e","data"],template:'** Login as {username}: "{e}" *',global:true},join:{keys:["ns","e"],template:'** Join {ns}: "{e}" *',monitor:true},part:{keys:["ns","e","r"],template:'** Part {ns}: "{e}" * {r}',monitor:true},property:{keys:["ns","p","by","ts","value"],template:'** Got {p} for {ns} *',monitor:true},recv_msg:{keys:["user","message"],template:'<{user}>{message}'},recv_action:{keys:["s","user","message"],template:'* {user}{message}'},recv_join:{keys:["user","s","info"],template:'** {user} has joined *',},recv_part:{keys:["user","r"],template:'** {user} has left * {r}'},recv_privchg:{keys:["user","s","by","pc"],template:'** {user} has been made a member of {pc} by {by} *'},recv_kicked:{keys:["user","s","by","r"],template:'** {user} has been kicked by {by} * {r}'},recv_admin_create:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been created by {user} * {privs}'},recv_admin_update:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been updated by {user} * {privs}'},recv_admin_rename:{keys:["p","user","prev","pc"],template:'** Privilege class {prev} has been renamed to {pc} by {user} *'},recv_admin_move:{keys:["p","user","prev","pc","affected"],template:'** All members of {prev} have been moved to {pc} by {user} * {affected} affected user(s)'},recv_admin_remove:{keys:["p","user","pc","affected"],template:'** Privilege class {pc} has been removed by {user} * {affected} affected user(s)'},recv_admin_show:null,recv_admin_showverbose:null,recv_admin_privclass:{keys:["p","e","command"],template:'** Admin command "{command}" failed * {e}'},kicked:{keys:["ns","user","r"],template:'** You have been kicked by {user} * {r}'},ping:null,disconnect:{keys:["e"],template:'** You have been disconnected * {e}',global:true},send:{keys:["ns","e"],template:'** Send error: {e}'},kick:{keys:["ns","user","e"],template:'** Could not kick {user} * {e}'},get:{keys:["ns","p","e"],template:'** Could not get {p} info for {ns} * {e}'},set:{keys:["ns","p","e"],template:'** Could not set {p} * {e}'},kill:{keys:["ns","e"],template:'** Kill error * {e}'},unknown:{keys:["ns","packet"],template:'** Received unknown packet in {ns} * {packet}',monitor:true}} };Chatterbox.Protocol.prototype.extend_messages=function(b){for(var a in b){this.messages[a]=b[a]}};Chatterbox.Protocol.prototype.log=function(b){var a=this.messages[b.name];return new Chatterbox.Protocol.LogMessage(b,a)};Chatterbox.Protocol.LogMessage=function(b,a){a=a||{};this.event=b;this.template=a.template||"";this.keys=a.keys||[];this.monitor=a.monitor||false;this.global=a.global||false;this._html=false;this._text=false;this._ansi=false};Chatterbox.Protocol.LogMessage.prototype.text=function(){if(this._text===false){this._text=this.render(0)}return this._text};Chatterbox.Protocol.LogMessage.prototype.html=function(){if(this._html===false){this._html=this.render(1)}return this._html};Chatterbox.Protocol.LogMessage.prototype.ansi=function(){if(this._ansi===false){this._ansi=this.render(2)}return this._ansi};Chatterbox.Protocol.LogMessage.prototype.render=function(c){if(c===undefined){c=0}var b=this.template;var e="";for(var a in this.keys){if(!this.keys.hasOwnProperty(a)){continue}key=this.keys[a]; if(key instanceof Array){key=key[1]}if(!this.event.hasOwnProperty(key)||key=="pkt"){continue}e=this.event[key];if(e==null){continue}if(key=="ns"||key=="sns"){key="ns";e=this.event.sns}if(e.hasOwnProperty("_parser")){switch(c){case 1:e=e.html();break;case 2:e=e.ansi();break;case 0:default:e=e.text();break}}b=replaceAll(b,"{"+key+"}",e)}return b};Chatterbox.Settings=function(b,a){Chatterbox.Popup.call(this,b,{ref:"settings",title:"Settings",close:false,content:""});this.config=a;this.saveb=null;this.scb=null;this.tabs=null;this.book=null;this.changed=false;this.manager=b};Chatterbox.Settings.prototype=new Chatterbox.Popup();Chatterbox.Settings.prototype.constructor=Chatterbox.Settings;Chatterbox.Settings.prototype.build=function(){this.options.content=Chatterbox.template.settings.main;Chatterbox.Popup.prototype.build.call(this);this.saveb=this.window.find("a.button.save");this.closeb=this.window.find("a.close");this.scb=this.window.find("a.button.saveclose");this.tabs=this.window.find("nav.tabs ul.tabs"); this.book=this.window.find("div.book");this.config.build(this.manager,this);this.window.find("ul.tabs li").first().addClass("active");this.window.find("div.book div.page").first().addClass("active");var a=this;this.window.find("form").bind("change",function(){a.changed=true});this.config.each_page(function(b,c){c.each_item(function(d,e){e._onchange=function(f){a.changed=true}})});this.saveb.click(function(b){a.save();return false});this.closeb.click(function(b){if(a.changed){if(!confirm("Are you sure? You will lose any unsaved changes.")){return false}}a.close();return false});this.scb.click(function(b){a.save();a.close();return false});this.resize()};Chatterbox.Settings.prototype.resize=function(){var a=this.window.find(".inner");var c=a.find("h2");var d=a.find(".bookwrap");var b=a.find("footer");d.height(a.height()-b.outerHeight()-c.outerHeight()-15);this.book.height(d.innerHeight()-this.tabs.outerHeight()-25);this.book.width(d.innerWidth()-20);this.config.resize()};Chatterbox.Settings.prototype.switch_page=function(b){var c=this.tabs.find("li.active").first(); diff --git a/dist/wsc.dAmn.js b/dist/wsc.dAmn.js index ca3d887..eaadae6 100644 --- a/dist/wsc.dAmn.js +++ b/dist/wsc.dAmn.js @@ -2185,11 +2185,13 @@ wsc.defaults.Extension = function( client ) { // lol themes client.bind('cmd.theme', cmd.theme); + /* // some ui business. client.ui.on('settings.open', settings_page); client.ui.on('settings.open.ran', about_page); client.ui.on('settings.save.ui', settings_save); client.ui.on('settings.save', function( ) { client.config_save(); } ); + */ }; var settings_save = function( e, ui ) { @@ -2428,7 +2430,8 @@ wsc.defaults.Extension = function( client ) { // Say something. cmd.say = function( e ) { - if( client.channel(e.target).monitor ) return; + if( client.channel(e.target).monitor ) + return; client.say( e.target, e.args ); }; @@ -2572,21 +2575,21 @@ wsc.defaults.Extension = function( client ) { * * @method Ignore */ - wsc.defaults.Extension.Ignore(client); + //wsc.defaults.Extension.Ignore(client); /** * Implements away messages. * * @method Away */ - wsc.defaults.Extension.Away(client); + //wsc.defaults.Extension.Away(client); /** * Implements autojoin channels. * * @method Autojoin */ - wsc.defaults.Extension.Autojoin(client); + //wsc.defaults.Extension.Autojoin(client); }; /** @@ -3361,6 +3364,8 @@ wsc.Client = function( view, options, mozilla ) { } */ + wsc.defaults.Extension( this ); + // Welcome! //this.monitor(this.settings["welcome"]); @@ -3441,7 +3446,7 @@ wsc.Client.prototype.config_save = function( ) { wsc.Client.prototype.build = function( ) { //this.ui.build(); - //this.create_ns( this.settings.monitor[0], true, true ); + this.create_ns( this.settings.monitor[0], true, true ); var client = this; /* this.ui.on('tab.close.clicked', function( event, ui ) { @@ -4208,6 +4213,8 @@ Chatterbox._gum = function( ) {}; if( ui == undefined ) { ui = new Chatterbox.UI( $(this), client, options, ($.browser.mozilla || false) ); $(window).resize(ui.resize); + setInterval(function( ) { ui.loop(); }, 120000); + ui.build(); } $(window).data('chatterbox', ui); } diff --git a/dist/wsc.dAmn.min.js b/dist/wsc.dAmn.min.js index 2746d8c..8c1a140 100644 --- a/dist/wsc.dAmn.min.js +++ b/dist/wsc.dAmn.min.js @@ -21,76 +21,76 @@ var a=this;this.mapper={recv:function(h,g,f){g.ns=h.param;return a.map(h.sub[0], a.connected=true;a.handshake();a.attempts=0};wsc.Flow.prototype.close=function(b,f){var a={name:"closed",pkt:new wsc.Packet("connection closed\n\n"),reason:"",evt:f,connected:b.connected,sio:b.conn instanceof wsc.SocketIO,cause:"",reconnect:true};b.trigger("closed",a);if(b.connected){b.connected=false;if(b.conn instanceof wsc.SocketIO){return}}else{}a.name="quit";if(b.attempts>2){a.reconnect=false;b.attempts=0;b.trigger("quit",a);return}if(f.cause){if(f.cause.hasOwnProperty("name")&&f.cause.name=="login"){b.trigger("quit",a);return}}setTimeout(function(){b.connect()},2000)};wsc.Flow.prototype.message=function(a,g){var b=new wsc.Packet(unescape(replaceAll(g.data,"+"," ")));if(b==null){return}var f=this.protocol.parse(b);if(f.ns==null){f.ns=a.mns}f.sns=a.deform_ns(f.ns);this.handle(a,f);a.trigger("pkt",f);a.trigger("pkt."+f.name,f)};wsc.Flow.prototype.handle=function(a,f){try{this[f.name](f,a)}catch(b){}};wsc.Flow.prototype.ping=function(b,a){a.pong()};wsc.Flow.prototype.chatserver=function(b,a){a.login() };wsc.Flow.prototype.login=function(f,a){if(f.pkt.arg.e=="ok"){var h=f.pkt.sub[0];a.settings.username=f.pkt.param;a.settings.symbol=h.arg.symbol;a.settings.userinfo=h.arg;var b=function(){a.join(a.settings.autojoin);if(a.autojoin.on){for(var j in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(j)){continue}a.join(a.autojoin.channel[j])}}};if(a.fresh){b()}else{var g=false;for(key in a.channelo){if(a.channelo[key].namespace[0]!="~"){a.join(key);g=true}}if(!g){b()}}}else{a.close(f)}if(a.fresh){a.fresh=false}};wsc.Flow.prototype.join=function(f,a){if(f.pkt.arg["e"]=="ok"){var b=a.deform_ns(f.pkt.param);a.create_ns(b,a.hidden.contains(f.pkt.param))}else{}};wsc.Flow.prototype.part=function(f,a){var b=a.deform_ns(f.ns);var g=a.channel(b);if(f.e=="ok"){info="";if(f.r.length>0){info="["+f.r+"]"}else{a.remove_ns(f.ns)}msg="You have left "+b;g.server_message(msg,info);if(a.channels()==0){switch(f.r){case"bad data":case"bad msg":case"msg too big":break;default:if(f.r.indexOf("killed:")<0){return }break}this.message(a,{data:"disconnect\ne="+e.r+"\n"})}}else{}};wsc.Flow.prototype.kicked=function(b,a){if(b.r.toLowerCase().indexOf("autokicked")>-1){return}a.join(b.ns)};wsc.Flow.prototype.property=function(b,a){chan=a.channel(b.pkt.param);if(!chan){return}chan.property(b)};wsc.Flow.prototype.recv_joinpart=function(b,a){c=a.channel(b.ns);if(b.name=="recv_join"){c.recv_join(b)}else{c.recv_part(b)}};wsc.Flow.prototype.recv_join=wsc.Flow.prototype.recv_joinpart;wsc.Flow.prototype.recv_part=wsc.Flow.prototype.recv_joinpart;wsc.Flow.prototype.recv_msg=function(b,a){a.channel(b.ns).recv_msg(b)};wsc.Flow.prototype.recv_action=wsc.Flow.prototype.recv_msg;wsc.Flow.prototype.recv_npmsg=wsc.Flow.prototype.recv_msg;wsc.Flow.prototype.recv_privchg=function(b,a){a.channel(b.ns).recv_privchg(b)};wsc.Flow.prototype.recv_kicked=function(b,a){a.channel(b.ns).recv_kicked(b)};wsc.defaults.Extension=function(f){var a={};a.away={on:false,reason:"",last:{},since:0,store:f.storage.folder("away"),format:{setaway:"/me is away: {reason}",setback:"/me is back",away:"{from}: I am away, reason: {reason}"}}; -var n=function(){f.bind("cmd.connect",b.connection);f.bind("cmd.set",b.setter);f.bind("cmd.join",b.join);f.bind("cmd.chat",b.pjoin);f.bind("cmd.part",b.part);f.bind("cmd.say",b.say);f.bind("cmd.npmsg",b.npmsg);f.bind("cmd.me",b.action);f.bind("cmd.promote",b.chgpriv);f.bind("cmd.demote",b.chgpriv);f.bind("cmd.ban",b.ban);f.bind("cmd.unban",b.ban);f.bind("cmd.kick",b.killk);f.bind("cmd.whois",b.whois);f.bind("cmd.title",b.title);f.bind("cmd.topic",b.title);f.bind("cmd.admin",b.admin);f.bind("cmd.disconnect",b.connection);f.bind("cmd.kill",b.killk);f.bind("cmd.raw",b.raw);f.bind("cmd.clear",b.clear);f.bind("cmd.clearall",b.clearall);f.bind("cmd.close",b.close);f.bind("pkt.property",m);f.bind("pkt.recv_admin_show",g);f.bind("pkt.recv_admin_showverbose",g);f.bind("pkt.get",l);f.bind("cmd.gettitle",b.gett);f.bind("cmd.gettopic",b.gett);f.bind("cmd.theme",b.theme);f.ui.on("settings.open",j);f.ui.on("settings.open.ran",h);f.ui.on("settings.save.ui",k);f.ui.on("settings.save",function(){f.config_save() -})};var k=function(p,o){f.settings.ui.theme=p.theme;f.settings.ui.clock=p.clock;f.settings.ui.tabclose=p.tabclose};var j=function(q,p){var o=q.settings.page("Main");var r={};r.username=f.settings.username;r.pk=f.settings.pk;r.devel=f.settings.developer;o.item("Form",{ref:"login",title:"Login",text:"Here you can change the username and token used to log into the chat server.",fields:[["Textfield",{ref:"username",label:"Username","default":r.username}],["Textfield",{ref:"token",label:"Token","default":r.pk}]],event:{save:function(s){f.settings.username=s.data.username;f.settings.pk=s.data.token}}},true);o.item("Form",{ref:"developer",title:"Developer Mode",text:"Turn developer mode on or off.\n\nDeveloper mode will expose any hidden channel tabs, amongst other things. Keep this turned off unless you're working on implementing something.",fields:[["Checkbox",{ref:"enabled",items:[{value:"on",title:"On",selected:r.devel}]}]],event:{change:function(s){f.settings.developer=(s.data.enabled.indexOf("on")!=-1); -f.ui.developer(f.settings.developer)},save:function(s){r.devel=f.settings.developer},close:function(s){f.settings.developer=r.devel;f.ui.developer(f.settings.developer)}}});o.item("Text",{ref:"intro",title:"Main",text:"Use this window to view and change your settings.\n\nCheck the different pages to see what settings can be changed.",},true);o.item("Text",{ref:"debug",wclass:"faint",title:"Debug Information",text:"Chat Agent: "+f.settings.agent+"\n\nUser Agent: "+navigator.userAgent+""})};var h=function(q,p){var o=q.settings.page("About",true);o.item("Text",{ref:"about-wsc",title:"Wsc",text:'Currently using wsc version '+wsc.VERSION+" "+wsc.STATE+'.\n\nWsc works using HTML5, javascript, and CSS3. WebSocket is used for the connection where possible. The source code for this client is pretty huge.\n\nWsc was created by ~photofroggy'}) -};var b={};b.theme=function(p,o){o.ui.theme(p.args.split(" ").shift())};b.setter=function(q){var p=q.args.split(" ");var o=p.shift().toLowerCase();var p=p.join(" ");if(p.length==0){f.cchannel.serverMessage("Could not set "+o,"No data supplied");return}if(!(o in f.settings)){f.cchannel.serverMessage('Unknown setting "'+o+'"');return}f.settings[o]=p;f.cchannel.serverMessage("Changed "+o+" setting","value: "+p)};b.connection=function(o){f[o.cmd]()};b.join=function(o){var p=o.args.split(" ");var p=p.toString()==""?[]:p;if(o.ns!=o.target){p.unshift(o.target)}if(p.toString()==""){return}for(index in p){f.join(p[index])}};b.pjoin=function(o){var p=o.args.split(" ");var p=p.toString()==""?[]:p;if(o.ns!=o.target){p.unshift(o.target)}if(p.toString()==""){return}for(index in p){f.join("@"+p[index])}};b.part=function(o){var p=o.args.split(" ");if(o.ns!=o.target){p.unshift(o.target)}if(p.toString()==""){f.part(o.ns);return}for(index in p){f.part(p[index])}};b.title=function(o){f.set(o.target,o.cmd,o.args) -};b.chgpriv=function(p){var o=p.args.split(" ");f[p.cmd.toLowerCase()](p.target,o[0],o[1])};b.ban=function(s,o){var q=s.args.split(" ");var p=q.shift();var r=s.cmd;if(r=="ban"&&q.length>0){o.kick(s.target,p,q.join(" "))}o[r](s.target,p)};b.action=function(o){f.action(o.target,o.args)};b.raw=function(o){f.send(o.args.replace(/\\n/gm,"\n"))};b.killk=function(s,o){var v=s.args.split(" ");var p=v.shift();var q=v.length>0?v.join(" "):null;if(s.cmd=="kick"){o.kick(s.target,p,q)}else{o.kill(p,q)}};b.say=function(o){if(f.channel(o.target).monitor){return}f.say(o.target,o.args)};b.npmsg=function(o){f.npmsg(o.target,o.args)};b.clear=function(q,o){if(q.args.length>0){var r=q.args.split(" ");for(var p in r){if(!r.hasOwnProperty(p)){continue}o.ui.channel(q.target).clear_user(r[p])}}else{o.ui.channel(q.target).clear()}};b.clearall=function(p,o){var r=null;if(p.args.length>0){var q=p.args.split(" ");r=function(u,v){for(var s in q){if(!q.hasOwnProperty(s)){continue}v.clear_user(q[s])}}}else{r=function(s,u){u.clear() -}}o.ui.chatbook.each(r,true)};b.close=function(o){f.part(o.target);f.remove_ns(o.target)};b.whois=function(p,o){o.whois(p.args.split(" ")[0])};b.admin=function(p,o){o.admin(p.target,p.args)};b.disconnect=function(p,o){o.disconnect()};b.gett=function(p,o){var q=p.cmd.indexOf("title")>-1?"title":"topic";o.ui.control.set_text("/"+q+" "+o.channel(p.target).info[q].content)};var m=function(r,o){if(r.p!="info"){return}var p=r.pkt.sub;var s=p.shift().arg;s.username=r.sns.substr(1);s.connections=[];var q={};while(p.length>0){q=p.shift().arg;q.channels=[];while(p.length>0){if(p[0].cmd!="ns"){break}q.channels.unshift(o.deform_ns(p.shift().param))}s.connections.push(q)}o.ui.chatbook.current.log_whois(s)};var l=function(p,o){if(p.ns.indexOf("login:")!=0){return}var q=p.sns.substr(1);o.ui.pager.notice({ref:"whois-"+q,heading:"Whois Failed",content:"Whois failed for "+q+".\nNo such user online."},false,5000)};var g=function(s,p){var x=p.channel(s.ns);var o=s.info.split("\n");var v="";var u=[];var q=""; -for(var r in o){if(!o.hasOwnProperty(r)){continue}v=o[r].split(" ");if(s.p=="privclass"){u.push([v.shift(),v.shift().split("=")[1],v.join(" ")])}else{if(s.p=="users"){q=v.shift().split(":",1)[0];u.push([q,x.get_privclass_order(q),v.join(" ")])}}}p.ui.chatbook.current.log_pc(s.p=="privclass",u)};n();wsc.defaults.Extension.Ignore(f);wsc.defaults.Extension.Away(f);wsc.defaults.Extension.Autojoin(f)};wsc.defaults.Extension.Autojoin=function(a){var f=a.autojoin;a.ui.nav.add_button({icon:"chat",label:"",title:"Join your autojoin channels",href:"#autojoin-do",handler:function(){for(var h in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(h)){continue}a.join(a.autojoin.channel[h])}}});var g=function(){a.bind("cmd.autojoin",b);a.ui.on("settings.open",f.page)};f.page=function(l,n){var m=l.settings.page("Autojoin");var k="
          ";var o={};o.ajon=a.autojoin.on;o.chan=a.autojoin.channel;if(a.autojoin.channel.length==0){k+="
        • No autojoin channels set
        "}else{for(var j in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(j)){continue -}k+="
      • "+a.autojoin.channel[j]+"
      • "}k+=""}m.item("Checkbox",{ref:"eaj",title:"Autojoin",text:"Turn on autojoin to automatically join selected channels when you connect to the chat server.",items:[{value:"yes",title:"On",selected:o.ajon}],event:{change:function(p){if(p.target.value=="yes"){a.autojoin.on=p.target.checked}},save:function(p){o.ajon=a.autojoin.on;a.config_save()},close:function(p){a.autojoin.on=o.ajon}}});var h=m.item("Items",{ref:"channelss",title:"Channels",text:"Add any channels you want to join automatically when you connect to the chat server.",items:a.autojoin.channel,prompt:{title:"Add Channel",label:"Channel:",},event:{up:function(p){var q=p.args.swap;a.autojoin.channel[q["this"].index]=q.that.item;a.autojoin.channel[q.that.index]=q["this"].item;h.options.items=a.autojoin.channel},down:function(p){var q=p.args.swap;a.autojoin.channel[q["this"].index]=q.that.item;a.autojoin.channel[q.that.index]=q["this"].item;h.options.items=a.autojoin.channel -},add:function(r){var q=a.deform_ns(r.args.item).toLowerCase();var p=a.autojoin.channel.indexOf(q);if(p!=-1){return}a.autojoin.channel.push(q);h.options.items=a.autojoin.channel},remove:function(p){a.autojoin.channel.splice(p.args.index,1);h.options.items=a.autojoin.channel},save:function(p){o.chan=a.autojoin.channel;a.config_save()},close:function(p){a.config_load()}}})};var b=function(o){var j=o.args.split(" ");if(!j){return}var m=j.shift().toLowerCase();var h=function(q){};var l=false;var p=a.channel(o.ns);switch(m){case"add":h=function(q){if(a.autojoin.channel.indexOf(q)==-1){l=true;a.autojoin.channel.push(q);p.server_message("Added "+q+" to your autojoin.")}else{p.server_message("Already have "+q+" on your autojoin.")}};break;case"rem":case"remove":h=function(r){var q=a.autojoin.channel.indexOf(r);if(q!=-1){l=true;a.autojoin.channel.splice(q,1);p.server_message("Removed "+r+" from your autojoin.")}else{p.server_message(r+" is not on your autojoin list.")}};break;case"on":p.server_message("Autojoin on."); -if(!a.autojoin.on){l=true;a.autojoin.on=true}break;case"off":p.server_message("Autojoin off.");if(a.autojoin.on){l=true;a.autojoin.on=false}break}var n="";for(var k in j){if(!j.hasOwnProperty(k)){continue}n=a.deform_ns(j[k]).toLowerCase();h(n)}if(l){a.config_save()}};g()};wsc.defaults.Extension.Away=function(b){var g=b.storage.folder("away");var f={on:false,reason:"",last:{},since:0,interval:60000,format:{setaway:"/me is away: {reason}",setback:"/me is back",away:"{user}: I've been away for {timesince}. Reason: {reason}"}};b.away=f;var m=function(){k();h();b.bind("cmd.setaway",a);b.bind("cmd.setback",l);b.ui.on("tabbed",j);b.ui.on("settings.open",f.page)};f.page=function(o,q){var n=function(u){u=replaceAll(u,"<","<");u=replaceAll(u,">",">");u=replaceAll(u,'"',""");return u};var r=function(u){u=replaceAll(u,"<","<");u=replaceAll(u,">",">");u=replaceAll(u,""",'"');return u};var p=o.settings.page("Away");var s={};s.away=f.format.away;s.sa=f.format.setaway;s.sb=f.format.setback; -s.intr=f.interval;p.item("Text",{ref:"intro",title:"Away Messages",text:"Use away messages when you are away from the chats.\n\n You can set yourself away using the /setaway [reason] command. When you get back, use /setback. While you are away, the client will automatically respond when people try to talk to you, telling them you're away.",});p.item("Form",{ref:"msgs",title:"Messages",text:"Here you can set the messages displayed when you set yourself away or back. You can also change the away message format.",hint:"{user}
        This is replaced with the username of the person trying to talk to you\n\n{reason}
        This is replaced by your reason for being away.\n\n{timesince}
        Use this to show how long you have been away for.",fields:[["Textfield",{ref:"away",label:"Away","default":n(s.away)}],["Textfield",{ref:"setaway",label:"Setaway","default":n(s.sa)}],["Textfield",{ref:"setback",label:"Setback","default":n(s.sb)}]],event:{save:function(u){f.format.away=r(u.data.away); -f.format.setaway=r(u.data.setaway);f.format.setback=r(u.data.setback);h()}}});p.item("Form",{ref:"interval",title:"Message Interval",text:"Here you can set the amount of time to wait before displaying another away message. The interval is in seconds.",fields:[["Textfield",{ref:"interval",label:"Interval","default":(s.intr/1000).toString()}]],event:{save:function(u){f.interval=parseInt(u.data.interval)*1000;h()}}})};var a=function(p,n){f.on=true;f.last={};f.since=new Date();f.reason=p.args;var q=n.say;var o=replaceAll(f.format.setaway,"{reason}",f.reason||"[silent away]");if(o.indexOf("/me ")==0){o=o.substr(4);q=n.action}n.each_channel(function(r){q.call(n,r,o)});n.ui.control.add_state({ref:"away",label:"Away, reason: "+(f.reason||"[silent away]")+""})};var l=function(p,n){if(!f.on){return}f.on=false;var q=n.say;var o=f.format.setback;if(o.indexOf("/me ")==0){o=o.substr(4);q=n.action}n.each_channel(function(r){q.call(n,r,o)});n.ui.control.rem_state("away")};var j=function(q){if(!f.on){return -}if(f.reason.length==0){return}if(q.user==b.settings.username){return}if(b.exclude.contains(q.ns)){return}var o=new Date();var p=q.sns.toLowerCase();if(p in f.last){if((o-f.last[p])<=f.interval){return}}var n=timeLengthString((o-f.since)/1000);var r=replaceAll(f.format.away,"{user}",q.user);r=replaceAll(r,"{timesince}",n);b.say(q.ns,replaceAll(r,"{reason}",f.reason));f.last[p]=o};var k=function(){f.format.setaway=g.get("setaway","/me is away: {reason}");f.format.setback=g.get("setback","/me is back");f.format.away=g.get("away","{user}: I've been away for {timesince}. Reason: {reason}");f.interval=parseInt(g.get("interval",60000))};var h=function(){g.set("interval",f.interval);g.set("setaway",f.format.setaway);g.set("setback",f.format.setback);g.set("away",f.format.away)};m()};wsc.defaults.Extension.Ignore=function(f){var g={};var h=f.storage.folder("ignore");var a=h.folder("ignored");var m=function(){l();k();f.bind("cmd.ignore",b);f.bind("cmd.unignore",j);f.ui.on("settings.open",g.page) -};g.page=function(o,q){var p=o.settings.page("Ignores");var r={};r.im=g.ignore;r.uim=g.unignore;r.usr=f.ui.umuted;p.item("Text",{ref:"intro",title:"Ignores",text:'Use ignore to ignore people.\n\n You can "ignore" other users of the chat server using the\n /ignore command. Ignoring a user hides their messages from you in the channel log.',});p.item("Form",{ref:"msgs",title:"Messages",text:"Here you can set the messages displayed when you ignore or unignore a user.\n\nThe text {user} is replaced with the name of the user your are ignoring or unignoring.",fields:[["Textfield",{ref:"ignore",label:"Ignore","default":r.im}],["Textfield",{ref:"unignore",label:"Unignore","default":r.uim}]],event:{save:function(s){g.ignore=s.data.ignore;g.unignore=s.data.unignore;k()}}});var n=p.item("Items",{ref:"ignoreds",title:"Users",text:"This is the list of users that you have silenced.\n\nUse the commands /ignore and /unignore to edit the list.",items:r.usr,prompt:{title:"Add User",label:"User:",},event:{up:function(s){var u=s.args.swap; -f.ui.umuted[u["this"].index]=u.that.item;f.ui.umuted[u.that.index]=u["this"].item;n.options.items=f.ui.umuted},down:function(s){var u=s.args.swap;f.ui.umuted[u["this"].index]=u.that.item;f.ui.umuted[u.that.index]=u["this"].item;n.options.items=f.ui.umuted},add:function(s){f.mute_user(s.args.item);n.options.items=f.ui.umuted},remove:function(s){f.unmute_user(s.args.item);n.options.items=f.ui.umuted},save:function(s){r.usr=f.ui.umuted;k()},close:function(s){l()}}})};var b=function(q){var s=q.args.split(" ");var n="";var r="";var p=false;for(var o in s){if(!s.hasOwnProperty(o)){continue}n=s[o];tmod=f.mute_user(n);if(!tmod){continue}p=tmod;r=replaceAll(g.ignore,"{user}",n);if(r.indexOf("/me ")==0){r=r.substr(4);f.action(q.target,r)}else{f.say(q.target,r)}}if(p){k()}};var j=function(r){var v=r.args.split(" ");var o="";var u="";var n=-1;var q=false;var s=false;for(var p in v){if(!v.hasOwnProperty(p)){continue}o=v[p];s=f.unmute_user(o);if(!s){continue}q=s;u=replaceAll(g.unignore,"{user}",o);if(u.indexOf("/me ")==0){u=u.substr(4); -f.action(r.target,u)}else{f.say(r.target,u)}}if(q){k()}};var l=function(){g.ignore=h.get("ignore","/me is ignoring {user} now");g.unignore=h.get("unignore","/me is not ignoring {user} anymore");g.count=parseInt(h.get("count",0));var o=null;for(var n in f.ui.umuted){if(!f.ui.umuted.hasOwnProperty(n)){continue}f.unmute_user(f.ui.umuted[n])}f.ui.umuted=[];if(g.count>0){o=null;for(var n=0;n
        ');this.protocol=new Chatterbox.Protocol();this.mw=new wsc.Middleware();this.view=b.find(".wsc");this.mns=this.format_ns(this.settings.monitor[0]);this.lun=this.settings.username.toLowerCase();this.monitoro=null;this.swidth=(function(){if($.browser.msie){var m=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body"),l=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body");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})();if(window.mozRTCPeerConnection){Chatterbox._gum=function(l,m,k){return navigator.mozGetUserMedia(l,m,k)}}if(window.webkitRTCPeerConnection){Chatterbox._gum=function(l,m,k){return navigator.webkitGetUserMedia(l,m,k)}}if(window.RTCPeerConnection&&!window.mozRTCPeerConnection){Chatterbox._gum=function(l,m,k){return navigator.getUserMedia(l,m,k)}}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(b){var a=b[0];if(a=="#"||a=="@"||a=="~"||a=="+"){return b}if(b.indexOf("chat:")==0){return"#"+b.slice(5)}if(b.indexOf("server:")==0){return"~"+b.slice(7)}if(b.indexOf("feed:")==0){return"#"+b.slice(5)}if(b.indexOf("login:")==0){return"@"+b.slice(6)}if(b.indexOf("pchat:")==0){var f=b.split(":");f.shift();for(i in f){name=f[i];if(name.toLowerCase()!=this.lun){return"@"+name}}}return"#"+b};Chatterbox.UI.prototype.format_ns=function(a){var f=a.slice(1);switch(a[0]){case"@":var b=[f,this.lun];b.sort(caseInsensitiveSort);b.unshift("pchat");a=b.join(":");break;case"~":a="server:"+f;break;case"+":a="feed:"+f;break;case"#":a="chat:"+f;break;default:if(a.indexOf("chat:")==0||a.indexOf("pchat:")==0||a.indexOf("server:")==0||a.indexOf("feed:")==0){break}a="chat:"+a;break}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.get_user_media=function(b,f,a){Chatterbox._gum(b,f,a)};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.add("click",this.sound.bank.m.find("audio.click")[0]);var j=this.sound;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)});this.client.bind("ns.user.list",function(l){h.channel(l.ns).set_user_list(l.users)});this.client.middle("ns.user.privchg",function(m,l){h.channel(m.ns).privchg(m,l)});this.client.bind("ns.user.remove",function(m,l){h.channel(m.ns).remove_one_user(m.user)});this.client.bind("ns.user.registered",function(l){h.channel(l.ns).register_user(l.user)})};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=this.protocol.log(b);if(g){if(this.settings.developer){console.log(">>>",b.sns,"|",g.text())}if(b.hasOwnProperty("s")&&b.s=="0"){this.chatbook.handle(b,a);return}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.BaseTab=function(g,b,f,a){this.manager=g;this.hidden=f;this.monitor=(a==undefined?false:a);this.built=false;this.raw=b;this.selector="t-"+(b||"chan").toLowerCase();this.namespace=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]}};if(!g){return}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)};Chatterbox.BaseTab.prototype.build=function(b){if(!this.manager){return}if(this.built){return}var a=this.selector;var g=this.namespace;var f=this.raw;this.el.t.o=this.manager.nav.add_tab(a,g);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(b||Chatterbox.render("basetab",{selector:a,ns:g}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");var h=this;this.el.t.l.click(function(){h.manager.toggle_channel(f);return false});this.el.t.c.click(function(j){h.manager.trigger("tab.close.clicked",{ns:h.raw,chan:h,e:j});return false});if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")}this.built=true};Chatterbox.BaseTab.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.BaseTab.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.BaseTab.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.BaseTab.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.BaseTab.prototype.resize=function(b,a){this.el.m.css({height:a||this.manager.chatbook.height(),width:(b||this.manager.chatbook.width())-10})};Chatterbox.BaseTab.prototype.loop=function(){};Chatterbox.Channel=function(g,b,f,a){Chatterbox.BaseTab.call(this,g,b,f,a);this.resized=function(){};this.ulbuf=0};Chatterbox.Channel.prototype=new Chatterbox.BaseTab;Chatterbox.Channel.prototype.constructor=Chatterbox.Channel;Chatterbox.Channel.prototype.build=function(){if(!this.manager){return}if(this.built){return}var a=this.selector;var f=this.namespace;var b=this.raw;Chatterbox.BaseTab.prototype.build.call(this,Chatterbox.render("channel",{selector:a,ns:f}));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.setup_header("title");this.setup_header("topic");if(this.namespace[0]=="@"){this.build_user_list({100:"Room Members"},[100])}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.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){Chatterbox.BaseTab.prototype.resize.call(this,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;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.ulbuf});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) -}this.resized()};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:'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)])}if(l.agent){p.push(["agent",l.agent])}if(l.debug){p.push(["debug",l.debug])}p.push(["chatrooms",l.channels.join(" ")]);h.conns.push(p)}this.manager.trigger("log_whois.before",h);var b="";for(var n in h.conns){var k=h.conns[n];var r='

        connection '+((parseInt(n)+1).toString())+":

        ";r+="
          ";for(var q in k){r+="
        • "+k[q][0]+": "+k[q][1]+"
        • "}r+="
        ";b+=r+"
        "}var j="";for(var n in h.info){j+="
      • "+h.info[n]+"
      • "}var o=this.log_info("whois-"+m.username,Chatterbox.render("whoiswrap",{avatar:h.avatar,info:Chatterbox.render("whoisinfo",{username:h.username,info:j,connections:b})})); -var g=o.find("div.avatar");var f=o.find("div.info");f.width(o.find(".whoiswrap").width()-100);g.height(o.height()-10);this.scroll()};Chatterbox.Channel.prototype.log_pc=function(g,h){contents="";for(var f in h){if(!h.hasOwnProperty(f)){continue}var b=h[f];var a="";if(b[2].length==0){a=""+(g?"default privileges":"no members")+""}else{a=b[2]}contents+=String.format("
      • {0} {1}:
        • {2}
      • ",[b[1],b[0],a])}var j={title:"Privilege class "+(g?"permissions":"members"),info:"
          "+contents+"
        "};this.log_info("pc-"+(g?"permissions":"members"),Chatterbox.render("pcinfo",j))};Chatterbox.Channel.prototype.set_header=function(a,g,j,f){a=a.toLowerCase();var b=this.el.m.find("header."+a+" a[href=#edit]");if(this.el.h[a].html()!=""){if(g.html().length!=0){this.server_message(a+" set by "+j)}}this.el.h[a].html(g.html());var h=this;setTimeout(function(){if(g.text().length>0){h.el.h[a].css({display:"block"});var k=(h.el.h[a].outerHeight(true)-5)*(-1); -b.css("top",k)}else{h.el.h[a].css({display:"none"})}h.resize()},100)};Chatterbox.Channel.prototype.get_header=function(a){return this.el.h[a.toLowerCase()]};Chatterbox.Channel.prototype.build_user_list=function(g,a){var j=this.el.u;var f="";var h=null;j.html("");for(var b in a){var f=g[a[b]];j.append('

        '+f+"

          ");h=j.find(".pc#"+f);h.css("display","none")}};Chatterbox.Channel.prototype.reveal_user_list=function(){var h=this.el.u;var f=0;var b=0;var a=null;h.find("div.pc").each(function(j,k){a=h.find(this);b=a.find("ul li").length;f+=b;a.css("display",(b==0?"none":"block"))});h.css("display",(f==0?"none":"block"));var g=this;setTimeout(function(){g.resize()},100)};Chatterbox.Channel.prototype.set_user_list=function(g){if(Object.size(g)==0){return}var f=this.el.u;var a=null;for(var b in g){a=g[b];this.set_user(a,true)}this.reveal_user_list()};Chatterbox.Channel.prototype.set_user=function(h,f){var k=this.el.u.find("div.pc#"+replaceAll(h.pc," ","-")); -var a=k.find("ul");var b=h.conn==1?"":"["+h.conn+"]";var j='
        • '+h.symbol+""+h.name+""+b+"
        • ";if(a.find("a#"+h.name).length==1){return}if(a.find("li").length==0){a.append(j)}else{var l=h.name.toLowerCase();var n=null;var g=false;a.find("li a").each(function(){if(g){return}n=a.find(this);if(l"}j.window.append(Chatterbox.render("userinfo",{username:b.name,avatar:b.avatar,link:b.link,info:k}));g=j.window.find(".userinfo#"+b.name);j.window.find("div.userinfo:not('#"+b.name+"')").remove();var m=h.offset();g.css({top:(m.top-h.height())+10,left:(m.left-(g.width()))-6});g.find(".info").height(g.height());g.hover(function(){g.data("hover",1)},function(n){g.data("hover",0);j.unhover_user(g,n)});g.data("hover",0)};var f=function(k){h.data("hover",0); -j.unhover_user(g,k)};h.off("mouseenter",a);h.off("mouseleave",f);h.on("mouseenter",a);h.on("mouseleave",f)};Chatterbox.Channel.prototype.unhover_user=function(g,f){var h=g.offset();var b=g.outerHeight(true)+h.top;var k=g.outerWidth(true)+h.left;var a=f.pageX;var j=f.pageY;if(a>h.left&&ah.top&&jh.left&&j>h.top&&j<(h.top+15)){return}g.remove()};Chatterbox.Channel.prototype.mute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"none"});this.scroll()};Chatterbox.Channel.prototype.unmute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"list-item"});this.scroll()};Chatterbox.Channel.prototype.clear_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).remove();this.scroll()};Chatterbox.Channel.prototype.pkt_join=function(b,a){if(b.e!="ok"){return}this.set_header("title",(new wsc.MessageString("")),"","");this.set_header("topic",(new wsc.MessageString("")),"","") -};Chatterbox.Channel.prototype.pkt_recv_msg=function(b,a){var f=this;this.manager.cascade("chan.recv_msg",function(j,g){var h=f.manager.client.settings.username.toLowerCase();if(h==j.user.toLowerCase()){return}var l=j.message.toLowerCase();var k=l.indexOf(h)!=-1;if(!k&&j.sns[0]!="@"){return}if(k){f.highlight()}else{f.highlight(false)}f.manager.trigger("tabbed",j)},b)};Chatterbox.Channel.prototype.pkt_recv_action=Chatterbox.Channel.prototype.pkt_recv_msg;Chatterbox.Channel.prototype.pkt_property=function(b,a){var g=b.pkt.arg.p;var f=a.channel(this.namespace);switch(g){case"title":case"topic":this.set_header(g,b.value||(new wsc.MessageString("")),b.by,b.ts);break;case"privclasses":this.build_user_list(f.info.pc,f.info.pc_order.slice(0));break;case"members":break;default:break}};Chatterbox.Chatbook=function(a){this.manager=a;this.view=this.manager.view.find("div.chatbook");this.chan={};this.trail=[];this.current=null;this.manager.on("tab.close.clicked",function(b,f){f.chatbook.remove_channel(b.ns) -})};Chatterbox.Chatbook.prototype.height=function(){return this.view.height()};Chatterbox.Chatbook.prototype.width=function(){return this.view.width()};Chatterbox.Chatbook.prototype.resize=function(b){b=b||600;var f=this.view.innerWidth();for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}var g=this.chan[a];g.resize(f,b)}};Chatterbox.Chatbook.prototype.loop=function(){for(select in this.chan){this.chan[select].loop()}};Chatterbox.Chatbook.prototype.channel=function(a,b){a=this.manager.format_ns(a).toLowerCase();if(!this.chan[a]&&b){this.chan[a]=b}return this.chan[a]};Chatterbox.Chatbook.prototype.channels=function(){chans=-1;for(ns in this.chan){if(this.chan[ns].hidden){continue}chans++}return chans};Chatterbox.Chatbook.prototype.create_channel=function(b,f,a){var g=this.channel(b,this.channel_object(b,f,a));g.build();if(this.trail.indexOf(g.namespace)==-1){this.trail.push(g.namespace)}if(!g.visible){this.toggle_channel(b)}this.manager.resize();return g};Chatterbox.Chatbook.prototype.channel_object=function(a,b){return new Chatterbox.Channel(this.manager,a,b) -};Chatterbox.Chatbook.prototype.toggle_channel=function(a){var f=this.channel(a);var b=f;if(!f){return}if(f.hidden){if(this.current&&this.current==f){return}if(!this.manager.settings.developer){f.hide();return}}if(this.current){if(this.current==f){return}this.current.hide();b=this.current}else{if(this.manager.monitoro!==null){this.manager.monitoro.hide()}}f.show();this.manager.control.focus();this.current=f;this.manager.resize();this.manager.control.cache_input(b,f);this.manager.trigger("channel.selected",{ns:f.raw,chan:f,prev:b});this.manager.client.select_ns(f.raw)};Chatterbox.Chatbook.prototype.remove_channel=function(a){var b=this.channel(a);if(!b){return}if(this.channels()==0&&!b.hidden){return}b.remove();delete this.chan[b.raw.toLowerCase()];if(this.current==b){this.channel_left()}var f=this.trail.indexOf(b.namespace);this.trail.splice(f,1)};Chatterbox.Chatbook.prototype.channel_left=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a<0){return}var g=null;while(true){try{g=this.channel(this.trail[--a]) -}catch(f){a=this.trail.length-1;g=this.channel(this.trail[a])}if(!g.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(g.namespace)};Chatterbox.Chatbook.prototype.channel_right=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a==-1){return}var g=null;while(true){try{g=this.channel(this.trail[++a])}catch(f){a=0;g=this.channel(this.trail[0])}if(!g.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(g.namespace)};Chatterbox.Chatbook.prototype.each=function(f){var b=null;for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}b=this.chan[a];if(f(b.namespace,b)===false){break}}};Chatterbox.Chatbook.prototype.server_message=function(b,a){for(ns in this.chan){this.chan[ns].server_message(b,a)}};Chatterbox.Chatbook.prototype.log_item=function(a){for(ns in this.chan){this.chan[ns].log_item(a)}};Chatterbox.Chatbook.prototype.log=function(a){for(ns in this.chan){this.chan[ns].log(a)}};Chatterbox.Chatbook.prototype.log_message=function(f,b){try{if(!f.global){if(!f.monitor){this.channel(b.ns).log_item(b) -}else{this.manager.monitoro.log_item(b)}}else{this.log_item(b)}}catch(a){try{this.ui.monitoro.server_message("Failed to log for",b.sns,b.html)}catch(a){console.log(">> Failed to log message for",b.sns,"::");console.log(">>",b.html)}}};Chatterbox.Chatbook.prototype.retime=function(){for(ns in this.chan){this.chan[ns].retime()}};Chatterbox.Chatbook.prototype.developer=function(){this.each(function(a,b){b.developer()})};Chatterbox.Chatbook.prototype.handle=function(g,b){var h=this.manager;var j=this.channel(g.ns);if(!j){return}var a="pkt_"+g.name;try{j[a](g,b)}catch(f){}};Chatterbox.Control=function(b){this.manager=b;this.manager.view.append(Chatterbox.template.control);this.view=this.manager.view.find("div.chatcontrol");this.ml=false;this.history={};this.tab={hit:false,cache:"",matched:[],index:-1,type:0,prefix:["","/",""],};this.el={form:this.view.find("form.msg"),i:{s:this.view.find("form.msg input.msg"),m:this.view.find("form.msg textarea.msg"),c:null,t:this.view.find("ul.buttons a[href~=#multiline].button")},brow:{m:this.view.find("div.brow"),b:this.view.find("div.brow ul.buttons"),s:this.view.find("div.brow ul.states")}}; -this.el.i.c=this.el.i.s;var a=this;this.el.i.t.click(function(f){a.multiline(!a.multiline());return false});this.el.i.s.keydown(function(f){return a.keypress(f)});this.el.i.m.keydown(function(f){return a.keypress(f)});this.el.form.submit(function(f){return a.submit(f)});this.add_button({label:"b",icon:false,href:"#bold",title:"Bold text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"i",icon:false,href:"#italic",title:"Italic text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"u",icon:false,href:"#underline",title:"Underline text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sup",icon:false,href:"#sup",title:"Superscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sub",icon:false,href:"#sub",title:"Subscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}})}; -Chatterbox.Control.prototype.surroundtext=function(k,j,b){var h=k.scrollTop;var a=k.value,f=k.selectionStart,g=k.selectionEnd;var l=k.value.substring(f,g);k.value=a.substring(0,f)+j+l+b+a.substring(g);k.selectionStart=f+j.length;k.selectionEnd=f+j.length+l.length;k.scrollTop=h;k.focus()};Chatterbox.Control.prototype.focus=function(){this.el.i.c.focus()};Chatterbox.Control.prototype.resize=function(){w=this.manager.view.width();this.view.css({width:"100%"});this.el.form.css({width:this.manager.view.width()-20});this.el.i.s.css({width:this.manager.view.width()-100});this.el.i.m.css({width:this.manager.view.width()-90})};Chatterbox.Control.prototype.height=function(){var a=this.view.outerHeight();return a};Chatterbox.Control.prototype.multiline=function(a){if(a==undefined||this.ml==a){return this.ml}this.ml=a;var b=(this.ml?"s":"m");a=(this.ml?"m":"s");this.el.i[b].css("display","none");this.el.i[a].css("display","inline-block");this.el.i.c=this.el.i[a];this.manager.resize();return this.ml -};Chatterbox.Control.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.brow.b.append(Chatterbox.render("brow_button",a));var b=this.el.brow.b.find("a[href="+a.href+"].button");b.click(function(f){a.handler();return false});return b};Chatterbox.Control.prototype.add_state=function(a){a=Object.extend({ref:"state",label:"some state"},(a||{}));var b=this.el.brow.s.find("li#"+a.ref);if(b.length==0){this.el.brow.s.append(Chatterbox.render("brow_state",a));return this.el.brow.s.find("li#"+a.ref)}b.html(a.label);return b};Chatterbox.Control.prototype.rem_state=function(a){return this.el.brow.s.find("li#"+a).remove()};Chatterbox.Control.prototype.chomp=function(){var f=this.el.i.c.val();var b=f.lastIndexOf(" ");if(b==-1){this.el.i.c.val("");return f}var a=f.slice(b+1);this.el.i.c.val(f.slice(0,b));if(a.length==0){return this.chomp()}return a -};Chatterbox.Control.prototype.unchomp=function(a){var b=this.el.i.c.val();if(!b){this.el.i.c.val(a)}else{this.el.i.c.val(b+" "+a)}};Chatterbox.Control.prototype.get_text=function(a){if(a==undefined){return this.el.i.c.val()}this.el.i.c.val(a||"");return this.el.i.c.val()};Chatterbox.Control.prototype.set_text=function(a){this.el.i.c.val(a||"")};Chatterbox.Control.prototype.cache_input=function(b,f){var a=this.get_history(b.namespace);if(a.index>-1){return}a.tmp=this.get_text();this.set_text(this.get_history(f.namespace).tmp)};Chatterbox.Control.prototype.get_history=function(a){if(!a){if(!this.manager.chatbook.current){a="~monitor"}}a=a||this.manager.chatbook.current.namespace;if(!this.history[a]){this.history[a]={index:-1,list:[],tmp:""}}return this.history[a]};Chatterbox.Control.prototype.append_history=function(b){if(!b){return}var a=this.get_history();a.list.unshift(b);a.index=-1;if(a.list.length>100){a.list.pop()}};Chatterbox.Control.prototype.scroll_history=function(a){var f=this.get_history(); -var b=this.get_text();if(f.index==-1){if(b){f.tmp=b}else{f.list[f.index]=b}}if(a){if(f.list.length>0&&f.index<(f.list.length-1)){f.index++}}else{if(f.index>-1){f.index--}}this.set_text(f.list[f.index]||f.tmp)};Chatterbox.Control.prototype.tab_item=function(b){if(!this.tab.hit){this.start_tab(b)}this.chomp();this.tab.index++;if(this.tab.index>=this.tab.matched.length){this.tab.index=-1}if(this.tab.index==-1){this.unchomp(this.tab.prefix[this.tab.type]+this.tab.cache);return}var a=this.get_text()==""?(this.tab.type==0?": ":" "):"";this.unchomp(this.tab.prefix[this.tab.type]+this.tab.matched[this.tab.index]+a)};Chatterbox.Control.prototype.start_tab=function(f){this.tab.hit=true;this.tab.index=-1;this.tab.matched=[];this.tab.type=0;var j=this.chomp();this.unchomp(j);if(j[0]=="/"||j[0]=="#"||j[0]=="@"){this.tab.type=j[0]=="/"?1:2;if(j[0]=="/"){j=j.slice(1)}}else{this.tab.type=0}this.tab.cache=j;j=j.toLowerCase();this.tab.matched=[];if(this.tab.type==0){var k=this.manager.client.channel(this.manager.chatbook.current.namespace); -for(var a in k.info.members){if(a.toLowerCase().indexOf(j)==0){this.tab.matched.push(a)}}}else{if(this.tab.type==1){var h="";for(var b in this.manager.client.cmds){h=this.manager.client.cmds[b];if(h.indexOf(j)==0){this.tab.matched.push(h)}}}else{if(this.tab.type==2){var g=this;this.manager.client.each_channel(function(l,m){if(m.namespace.toLowerCase().indexOf(j)==0){g.tab.matched.push(m.namespace)}})}}}};Chatterbox.Control.prototype.end_tab=function(a){this.tab.hit=false;this.tab.matched=[];this.tab.cache="";this.tab.index=-1};Chatterbox.Control.prototype.submit=function(a){var b=this.get_text();this.append_history(b);this.set_text("");this.handle(a,b);return false};Chatterbox.Control.prototype.keypress=function(f){var b=f.which||f.keyCode;var g=this.tab.hit;var a=false;switch(b){case 13:if(!this.multiline()){this.submit(f)}else{if(f.shiftKey){this.submit(f)}else{a=true}}break;case 38:if(!this.multiline()){this.scroll_history(true);break}a=true;break;case 40:if(!this.multiline()){this.scroll_history(false); -break}a=true;break;case 9:if(f.shiftKey){this.manager.channel_right()}else{this.tab_item(f);g=false}break;case 219:if(f.ctrlKey){this.manager.channel_left()}else{a=true}break;case 221:if(f.ctrlKey){this.manager.channel_right()}else{a=true}break;default:a=true;break}if(g){this.end_tab(f)}return a};Chatterbox.Control.prototype.handle=function(b,h){if(h==""){return}if(!this.manager.chatbook.current){return}var l=false;if(h[0]!="/"){l=true}h=(b.shiftKey?"/npmsg ":(h[0]=="/"?"":"/say "))+h;h=h.slice(1);var m=h.split(" ");var f=m.shift().toLowerCase();var k=this.manager.chatbook.current.namespace;var j=k;if(!l&&m[0]){var g=m[0][0];if((g=="#"||g=="@")&&m[0].length>1){j=this.manager.format_ns(m.shift())}}var n=m.join(" ");var a=this.manager.client.trigger("cmd."+f,{name:"cmd",cmd:f,args:n,target:j,ns:k});if(a==0){this.manager.pager.notice({ref:"cmd-fail",heading:"Command failed",content:'"'+f+'" is not a command.'},false,5000)}};Chatterbox.Navigation=function(a){this.manager=a;this.showclose=this.manager.settings.tabclose; -this.settings={};this.settings.open=false;this.el={n:this.manager.view.find("nav.tabs"),tw:this.manager.view.find("nav.tabs div.tabwrap"),t:this.manager.view.find("nav.tabs #chattabs"),b:this.manager.view.find("nav.tabs #tabnav"),l:this.manager.view.find("nav.tabs #tabnav .arrow_left"),r:this.manager.view.find("nav.tabs #tabnav .arrow_right"),s:this.manager.view.find("nav.tabs #tabnav #settings-button"),};if(!this.showclose){if(!this.el.t.hasClass("hc")){this.el.t.addClass("hc")}}var b=this;this.el.s.click(function(h){if(b.settings.open){return false}var f={e:h,settings:new Chatterbox.Settings.Config(b.manager)};b.configure_page(f);b.manager.trigger("settings.open",f);b.manager.trigger("settings.open.ran",f);var g=f.settings.page("About");g.item("text",{ref:"about-chatterbox",wclass:"centered faint",text:'Using Chatterbox version '+Chatterbox.VERSION+" "+Chatterbox.STATE+' by ~photofroggy.'}); -b.settings.window=new Chatterbox.Settings(b.manager,f.settings);b.settings.window.build();b.settings.open=true;return false});this.el.l.click(function(){b.manager.channel_left();return false});this.el.r.click(function(){b.manager.channel_right();return false})};Chatterbox.Navigation.prototype.configure_page=function(b){var g=this.manager;var f=b.settings.page("Main");var h={};h.theme=replaceAll(g.settings.theme,"wsct_","");h.clock=g.clock();h.tc=g.nav.closer();var a=[];for(i in g.settings.themes){name=replaceAll(g.settings.themes[i],"wsct_","");a.push({value:name,title:name,selected:h.theme==name})}f.item("Form",{ref:"ui",title:"UI",hint:"Timestamp
          Choose between a 24 hour clock and a 12 hour clock.\n\nTheme
          Change the look of the client.\n\nClose Buttons
          Turn tab close buttons on/off.",fields:[["Dropdown",{ref:"theme",label:"Theme",items:a}],["Dropdown",{ref:"clock",label:"Timestamp Format",items:[{value:"24",title:"24 hour",selected:h.clock},{value:"12",title:"12 hour",selected:!h.clock}]}],["Checkbox",{ref:"tabclose",label:"Close Buttons",items:[{value:"yes",title:"On",selected:h.tc}]}],],event:{change:function(j){g.clock(j.data.clock=="24"); -g.theme(j.data.theme);g.nav.closer(j.data.tabclose.indexOf("yes")>-1)},save:function(j){h.clock=g.clock();h.theme=replaceAll(g.theme(),"wsct_","");h.tc=g.nav.closer();g.trigger("settings.save.ui",{clock:h.clock,tabclose:h.tc,theme:"wsct_"+h.theme})},close:function(j){g.clock(h.clock);g.theme(h.theme);g.nav.closer(h.tc)}}})};Chatterbox.Navigation.prototype.height=function(){var a=this.el.n.outerHeight();return a};Chatterbox.Navigation.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.b.prepend(Chatterbox.render("nav_button",a));var b=this.el.b.find("a[href="+a.href+"].button");b.click(function(f){a.handler();return false});this.resize();return b};Chatterbox.Navigation.prototype.add_tab=function(a,b){this.el.t.append(Chatterbox.render("tab",{selector:a,ns:b}));return this.el.t.find("#"+a+"-tab")};Chatterbox.Navigation.prototype.resize=function(){this.el.tw.width(this.el.n.width()-this.el.b.outerWidth()-20); -if(this.settings.open){this.settings.window.resize()}};Chatterbox.Navigation.prototype.closer=function(a){if(a==undefined||a==this.showclose){return this.showclose}this.showclose=a;if(this.showclose){if(!this.el.t.hasClass("hc")){return}this.el.t.removeClass("hc");return}if(this.el.t.hasClass("hc")){return}this.el.t.addClass("hc")};Chatterbox.Pager=function(a){this.manager=a;this.lifespan=20000;this.halflife=5000;this.el={m:null,click:null};this.sound={click:function(){},};this.notices=[];this.build()};Chatterbox.Pager.prototype.build=function(){this.el.m=this.manager.view.find("div.pager")};Chatterbox.Pager.prototype.notice=function(g,m,l,f){var j={frame:null,close:null,foot:null,b:{},options:Object.extend({ref:"notice",icon:"",heading:"Some notice",content:"Notice content goes here."},(g||{})),onclose:function(){},ondestroy:function(){}};j.options.ref+="-"+(new Date()).valueOf();j.options.content=j.options.content.split("\n").join("

          ");this.notices.push(j);this.el.m.append(Chatterbox.render("pager.notice",j.options)); -j.frame=this.el.m.find("#"+j.options.ref).last();j.close=j.frame.find("a.close_notice");j.foot=j.frame.find("footer.buttons");var h={};for(var a in j.options.buttons){if(!j.options.buttons.hasOwnProperty(a)){continue}h=j.options.buttons[a];j.foot.append(Chatterbox.render("pager.button",h));j.b[a]=j.foot.find("a#"+h.ref);j.b[a].click(h.click)}var k=this;j.close.click(function(){j.onclose();k.remove_notice(j);return false});if(!m){if(!l){l=k.lifespan}setTimeout(function(){k.remove_notice(j,true)},l)}if(f!==true){this.manager.sound.click()}return j};Chatterbox.Pager.prototype.remove_notice=function(a,f){var b=this;if(this.notices.indexOf(a)==-1){return false}a.frame.fadeTo((f?this.halflife:300),0).slideUp(function(){a.frame.remove();b.notices.splice(b.notices.indexOf(a),1);a.ondestroy()});if(f){a.frame.mouseenter(function(){if(b.notices.indexOf(a)==-1){return}a.frame.stop(true);a.frame.slideDown(function(){a.frame.fadeTo(300,1);a.frame.mouseleave(function(){setTimeout(function(){b.remove_notice(a,true) -},b.lifespan)})})})}};Chatterbox.Pager.prototype.find_notice=function(a){for(var b in this.notices){if(this.notices[b].options.ref==a){return this.notices[b]}}return null};Chatterbox.Popup=function(b,a){this.manager=b;this.pview=(this.manager||{view:{find:function(){}}}).view;this.window=null;this.closeb=null;this.options=Object.extend({ref:"popup",title:"Popup",close:true,content:""},(a||{}))};Chatterbox.Popup.prototype.build=function(){var b=this.options;if(this.options.close){b.title+=''}this.pview.append(Chatterbox.render("popup",b));this.window=this.pview.find(".floater."+b.ref);if(this.options.close){this.closeb=this.window.find("a.close");var a=this;this.closeb.click(function(f){a.close();return false})}};Chatterbox.Popup.prototype.close=function(){this.window.remove()};Chatterbox.Popup.Prompt=function(b,a){a=a||{};a=Object.extend({position:[0,0],ref:"prompt",title:"Input",close:false,label:"","default":"","submit-button":"Submit",event:{submit:function(){},cancel:function(){}}},a); -Chatterbox.Popup.call(this,b,a);this.data=this.options["default"]};Chatterbox.Popup.Prompt.prototype=new Chatterbox.Popup();Chatterbox.Popup.Prompt.prototype.constructor=Chatterbox.Popup.Prompt;Chatterbox.Popup.Prompt.prototype.build=function(){this.options.content=Chatterbox.template.prompt.main;Chatterbox.Popup.prototype.build.call(this);this.window.css({left:this.options.position[0],top:this.options.position[1]});var a=this;this.window.find(".button.close").click(function(){a.options.event.cancel(a);a.close();return false});this.window.find(".button.submit").click(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false});this.window.find("form").submit(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false})};Chatterbox.Popup.ItemPicker=function(b,a){a=a||{};a=Object.extend({position:[100,60],ref:"item-picker",title:"Items",event:{select:function(f){}}},a);Chatterbox.Popup.call(this,b,a);this.pview=this.pview.find(".chatbook"); -this.data=this.options["default"];this.pages=[];this.cpage=null};Chatterbox.Popup.ItemPicker.prototype=new Chatterbox.Popup();Chatterbox.Popup.ItemPicker.prototype.constructor=Chatterbox.Popup.ItemPicker;Chatterbox.Popup.ItemPicker.prototype.build=function(){this.options.content=Chatterbox.render("ip.main",{});Chatterbox.Popup.prototype.build.call(this);this.window.css({right:this.options.position[0],bottom:this.options.position[1]});this.closeb.removeClass("medium");this.pbook=this.window.find("section.pages");this.tabs=this.window.find("section.tabs ul");this.buttons=this.window.find("section.buttons");var f=this;var b=null;for(var a in this.pages){if(!this.pages.hasOwnProperty(a)){continue}b=this.pages[a];b.build();if(a==0){this.select_page(b)}}};Chatterbox.Popup.ItemPicker.prototype.refresh=function(){if(this.cpage==null){return}else{this.cpage.refresh()}};Chatterbox.Popup.ItemPicker.prototype.page=function(b,a){b=b.toLowerCase();for(var f in this.pages){if(!this.pages.hasOwnProperty(f)){continue -}if(this.pages[f].name.toLowerCase()==b){return this.pages[f]}}return(a||null)};Chatterbox.Popup.ItemPicker.prototype.add_page=function(a,b){this.pages.push(new (b||Chatterbox.Popup.ItemPicker.Page)(this,a))};Chatterbox.Popup.ItemPicker.prototype.add_button=function(a){a=Object.extend({href:"#button",title:"Button",label:"Button"},(a||{}));this.buttons.append(Chatterbox.render("ip.button",a));return this.buttons.find("a[href="+a.href+"]")};Chatterbox.Popup.ItemPicker.prototype.select=function(a){this.options.event.select(a)};Chatterbox.Popup.ItemPicker.prototype.select_page=function(a){if(!a){return}if(this.cpage!=null){this.cpage.hide()}this.cpage=a||null;if(this.cpage!=null){this.cpage.show()}};Chatterbox.Popup.ItemPicker.Page=function(b,a){this.picker=b;this.options=Object.extend({ref:"page",href:"#page",label:"Page",title:"page",items:[],content:"No items on this page.",},(a||{}));this.name=this.options.label;this.nrefresh=true};Chatterbox.Popup.ItemPicker.Page.prototype.build=function(){this.picker.pbook.append(Chatterbox.render("ip.page",this.options)); -this.picker.tabs.append(Chatterbox.render("ip.tab",this.options));this.view=this.picker.pbook.find("div.page#"+this.options.ref);this.items=this.view.find("ul");this.tab=this.picker.tabs.find("#"+this.options.ref);this.refresh();var a=this;this.tab.find("a").click(function(){a.picker.select_page(a);return false})};Chatterbox.Popup.ItemPicker.Page.prototype.refresh=function(){var a=this.build_list();if(a.length==0){this.options.content="No items on this page."}else{this.options.content="

            "+a+"
          "}this.view.html(this.options.content);this.items=this.view.find("ul");this.hook_events();this.nrefresh=false};Chatterbox.Popup.ItemPicker.Page.prototype.hook_events=function(){var a=this;this.items.find("li").each(function(b,g){var h=a.view.find(g);var f=h.find(".value").html();h.click(function(){a.picker.select(f)})})};Chatterbox.Popup.ItemPicker.Page.prototype.build_list=function(){var f=[];var g=null;var j,h,b;for(var a in this.options.items){if(!this.options.items.hasOwnProperty(a)){continue -}g=this.options.items[a];h=g.value||g;j=g.title||h;b=g.html||false;f.push('
        • '+(b?h:''+h+"")+"
        • ")}return f.join("")};Chatterbox.Popup.ItemPicker.Page.prototype.show=function(){this.tab.addClass("selected");this.view.css("display","block");this.refresh()};Chatterbox.Popup.ItemPicker.Page.prototype.hide=function(){this.tab.removeClass("selected");this.view.css("display","none")};Chatterbox.Protocol=function(){this.messages={chatserver:{keys:["version"],template:'** Connected to llama {version} *',global:true},dAmnServer:{keys:["version"],template:'** Connected to dAmnServer {version} *',global:true},login:{keys:["username","e","data"],template:'** Login as {username}: "{e}" *',global:true},join:{keys:["ns","e"],template:'** Join {ns}: "{e}" *',monitor:true},part:{keys:["ns","e","r"],template:'** Part {ns}: "{e}" * {r}',monitor:true},property:{keys:["ns","p","by","ts","value"],template:'** Got {p} for {ns} *',monitor:true},recv_msg:{keys:["user","message"],template:'<{user}>{message}'},recv_action:{keys:["s","user","message"],template:'* {user}{message}'},recv_join:{keys:["user","s","info"],template:'** {user} has joined *',},recv_part:{keys:["user","r"],template:'** {user} has left * {r}'},recv_privchg:{keys:["user","s","by","pc"],template:'** {user} has been made a member of {pc} by {by} *'},recv_kicked:{keys:["user","s","by","r"],template:'** {user} has been kicked by {by} * {r}'},recv_admin_create:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been created by {user} * {privs}'},recv_admin_update:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been updated by {user} * {privs}'},recv_admin_rename:{keys:["p","user","prev","pc"],template:'** Privilege class {prev} has been renamed to {pc} by {user} *'},recv_admin_move:{keys:["p","user","prev","pc","affected"],template:'** All members of {prev} have been moved to {pc} by {user} * {affected} affected user(s)'},recv_admin_remove:{keys:["p","user","pc","affected"],template:'** Privilege class {pc} has been removed by {user} * {affected} affected user(s)'},recv_admin_show:null,recv_admin_showverbose:null,recv_admin_privclass:{keys:["p","e","command"],template:'** Admin command "{command}" failed * {e}'},kicked:{keys:["ns","user","r"],template:'** You have been kicked by {user} * {r}'},ping:null,disconnect:{keys:["e"],template:'** You have been disconnected * {e}',global:true},send:{keys:["ns","e"],template:'** Send error: {e}'},kick:{keys:["ns","user","e"],template:'** Could not kick {user} * {e}'},get:{keys:["ns","p","e"],template:'** Could not get {p} info for {ns} * {e}'},set:{keys:["ns","p","e"],template:'** Could not set {p} * {e}'},kill:{keys:["ns","e"],template:'** Kill error * {e}'},unknown:{keys:["ns","packet"],template:'** Received unknown packet in {ns} * {packet}',monitor:true}} +var n=function(){f.bind("cmd.connect",b.connection);f.bind("cmd.set",b.setter);f.bind("cmd.join",b.join);f.bind("cmd.chat",b.pjoin);f.bind("cmd.part",b.part);f.bind("cmd.say",b.say);f.bind("cmd.npmsg",b.npmsg);f.bind("cmd.me",b.action);f.bind("cmd.promote",b.chgpriv);f.bind("cmd.demote",b.chgpriv);f.bind("cmd.ban",b.ban);f.bind("cmd.unban",b.ban);f.bind("cmd.kick",b.killk);f.bind("cmd.whois",b.whois);f.bind("cmd.title",b.title);f.bind("cmd.topic",b.title);f.bind("cmd.admin",b.admin);f.bind("cmd.disconnect",b.connection);f.bind("cmd.kill",b.killk);f.bind("cmd.raw",b.raw);f.bind("cmd.clear",b.clear);f.bind("cmd.clearall",b.clearall);f.bind("cmd.close",b.close);f.bind("pkt.property",m);f.bind("pkt.recv_admin_show",g);f.bind("pkt.recv_admin_showverbose",g);f.bind("pkt.get",l);f.bind("cmd.gettitle",b.gett);f.bind("cmd.gettopic",b.gett);f.bind("cmd.theme",b.theme)};var k=function(p,o){f.settings.ui.theme=p.theme;f.settings.ui.clock=p.clock;f.settings.ui.tabclose=p.tabclose};var j=function(q,p){var o=q.settings.page("Main"); +var r={};r.username=f.settings.username;r.pk=f.settings.pk;r.devel=f.settings.developer;o.item("Form",{ref:"login",title:"Login",text:"Here you can change the username and token used to log into the chat server.",fields:[["Textfield",{ref:"username",label:"Username","default":r.username}],["Textfield",{ref:"token",label:"Token","default":r.pk}]],event:{save:function(s){f.settings.username=s.data.username;f.settings.pk=s.data.token}}},true);o.item("Form",{ref:"developer",title:"Developer Mode",text:"Turn developer mode on or off.\n\nDeveloper mode will expose any hidden channel tabs, amongst other things. Keep this turned off unless you're working on implementing something.",fields:[["Checkbox",{ref:"enabled",items:[{value:"on",title:"On",selected:r.devel}]}]],event:{change:function(s){f.settings.developer=(s.data.enabled.indexOf("on")!=-1);f.ui.developer(f.settings.developer)},save:function(s){r.devel=f.settings.developer},close:function(s){f.settings.developer=r.devel; +f.ui.developer(f.settings.developer)}}});o.item("Text",{ref:"intro",title:"Main",text:"Use this window to view and change your settings.\n\nCheck the different pages to see what settings can be changed.",},true);o.item("Text",{ref:"debug",wclass:"faint",title:"Debug Information",text:"Chat Agent: "+f.settings.agent+"\n\nUser Agent: "+navigator.userAgent+""})};var h=function(q,p){var o=q.settings.page("About",true);o.item("Text",{ref:"about-wsc",title:"Wsc",text:'Currently using wsc version '+wsc.VERSION+" "+wsc.STATE+'.\n\nWsc works using HTML5, javascript, and CSS3. WebSocket is used for the connection where possible. The source code for this client is pretty huge.\n\nWsc was created by ~photofroggy'})};var b={};b.theme=function(p,o){o.ui.theme(p.args.split(" ").shift()) +};b.setter=function(q){var p=q.args.split(" ");var o=p.shift().toLowerCase();var p=p.join(" ");if(p.length==0){f.cchannel.serverMessage("Could not set "+o,"No data supplied");return}if(!(o in f.settings)){f.cchannel.serverMessage('Unknown setting "'+o+'"');return}f.settings[o]=p;f.cchannel.serverMessage("Changed "+o+" setting","value: "+p)};b.connection=function(o){f[o.cmd]()};b.join=function(o){var p=o.args.split(" ");var p=p.toString()==""?[]:p;if(o.ns!=o.target){p.unshift(o.target)}if(p.toString()==""){return}for(index in p){f.join(p[index])}};b.pjoin=function(o){var p=o.args.split(" ");var p=p.toString()==""?[]:p;if(o.ns!=o.target){p.unshift(o.target)}if(p.toString()==""){return}for(index in p){f.join("@"+p[index])}};b.part=function(o){var p=o.args.split(" ");if(o.ns!=o.target){p.unshift(o.target)}if(p.toString()==""){f.part(o.ns);return}for(index in p){f.part(p[index])}};b.title=function(o){f.set(o.target,o.cmd,o.args)};b.chgpriv=function(p){var o=p.args.split(" ");f[p.cmd.toLowerCase()](p.target,o[0],o[1]) +};b.ban=function(s,o){var q=s.args.split(" ");var p=q.shift();var r=s.cmd;if(r=="ban"&&q.length>0){o.kick(s.target,p,q.join(" "))}o[r](s.target,p)};b.action=function(o){f.action(o.target,o.args)};b.raw=function(o){f.send(o.args.replace(/\\n/gm,"\n"))};b.killk=function(s,o){var v=s.args.split(" ");var p=v.shift();var q=v.length>0?v.join(" "):null;if(s.cmd=="kick"){o.kick(s.target,p,q)}else{o.kill(p,q)}};b.say=function(o){if(f.channel(o.target).monitor){return}f.say(o.target,o.args)};b.npmsg=function(o){f.npmsg(o.target,o.args)};b.clear=function(q,o){if(q.args.length>0){var r=q.args.split(" ");for(var p in r){if(!r.hasOwnProperty(p)){continue}o.ui.channel(q.target).clear_user(r[p])}}else{o.ui.channel(q.target).clear()}};b.clearall=function(p,o){var r=null;if(p.args.length>0){var q=p.args.split(" ");r=function(u,v){for(var s in q){if(!q.hasOwnProperty(s)){continue}v.clear_user(q[s])}}}else{r=function(s,u){u.clear()}}o.ui.chatbook.each(r,true)};b.close=function(o){f.part(o.target);f.remove_ns(o.target) +};b.whois=function(p,o){o.whois(p.args.split(" ")[0])};b.admin=function(p,o){o.admin(p.target,p.args)};b.disconnect=function(p,o){o.disconnect()};b.gett=function(p,o){var q=p.cmd.indexOf("title")>-1?"title":"topic";o.ui.control.set_text("/"+q+" "+o.channel(p.target).info[q].content)};var m=function(r,o){if(r.p!="info"){return}var p=r.pkt.sub;var s=p.shift().arg;s.username=r.sns.substr(1);s.connections=[];var q={};while(p.length>0){q=p.shift().arg;q.channels=[];while(p.length>0){if(p[0].cmd!="ns"){break}q.channels.unshift(o.deform_ns(p.shift().param))}s.connections.push(q)}o.ui.chatbook.current.log_whois(s)};var l=function(p,o){if(p.ns.indexOf("login:")!=0){return}var q=p.sns.substr(1);o.ui.pager.notice({ref:"whois-"+q,heading:"Whois Failed",content:"Whois failed for "+q+".\nNo such user online."},false,5000)};var g=function(s,p){var x=p.channel(s.ns);var o=s.info.split("\n");var v="";var u=[];var q="";for(var r in o){if(!o.hasOwnProperty(r)){continue}v=o[r].split(" ");if(s.p=="privclass"){u.push([v.shift(),v.shift().split("=")[1],v.join(" ")]) +}else{if(s.p=="users"){q=v.shift().split(":",1)[0];u.push([q,x.get_privclass_order(q),v.join(" ")])}}}p.ui.chatbook.current.log_pc(s.p=="privclass",u)};n()};wsc.defaults.Extension.Autojoin=function(a){var f=a.autojoin;a.ui.nav.add_button({icon:"chat",label:"",title:"Join your autojoin channels",href:"#autojoin-do",handler:function(){for(var h in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(h)){continue}a.join(a.autojoin.channel[h])}}});var g=function(){a.bind("cmd.autojoin",b);a.ui.on("settings.open",f.page)};f.page=function(l,n){var m=l.settings.page("Autojoin");var k="
            ";var o={};o.ajon=a.autojoin.on;o.chan=a.autojoin.channel;if(a.autojoin.channel.length==0){k+="
          • No autojoin channels set
          "}else{for(var j in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(j)){continue}k+="
        • "+a.autojoin.channel[j]+"
        • "}k+=""}m.item("Checkbox",{ref:"eaj",title:"Autojoin",text:"Turn on autojoin to automatically join selected channels when you connect to the chat server.",items:[{value:"yes",title:"On",selected:o.ajon}],event:{change:function(p){if(p.target.value=="yes"){a.autojoin.on=p.target.checked +}},save:function(p){o.ajon=a.autojoin.on;a.config_save()},close:function(p){a.autojoin.on=o.ajon}}});var h=m.item("Items",{ref:"channelss",title:"Channels",text:"Add any channels you want to join automatically when you connect to the chat server.",items:a.autojoin.channel,prompt:{title:"Add Channel",label:"Channel:",},event:{up:function(p){var q=p.args.swap;a.autojoin.channel[q["this"].index]=q.that.item;a.autojoin.channel[q.that.index]=q["this"].item;h.options.items=a.autojoin.channel},down:function(p){var q=p.args.swap;a.autojoin.channel[q["this"].index]=q.that.item;a.autojoin.channel[q.that.index]=q["this"].item;h.options.items=a.autojoin.channel},add:function(r){var q=a.deform_ns(r.args.item).toLowerCase();var p=a.autojoin.channel.indexOf(q);if(p!=-1){return}a.autojoin.channel.push(q);h.options.items=a.autojoin.channel},remove:function(p){a.autojoin.channel.splice(p.args.index,1);h.options.items=a.autojoin.channel},save:function(p){o.chan=a.autojoin.channel;a.config_save() +},close:function(p){a.config_load()}}})};var b=function(o){var j=o.args.split(" ");if(!j){return}var m=j.shift().toLowerCase();var h=function(q){};var l=false;var p=a.channel(o.ns);switch(m){case"add":h=function(q){if(a.autojoin.channel.indexOf(q)==-1){l=true;a.autojoin.channel.push(q);p.server_message("Added "+q+" to your autojoin.")}else{p.server_message("Already have "+q+" on your autojoin.")}};break;case"rem":case"remove":h=function(r){var q=a.autojoin.channel.indexOf(r);if(q!=-1){l=true;a.autojoin.channel.splice(q,1);p.server_message("Removed "+r+" from your autojoin.")}else{p.server_message(r+" is not on your autojoin list.")}};break;case"on":p.server_message("Autojoin on.");if(!a.autojoin.on){l=true;a.autojoin.on=true}break;case"off":p.server_message("Autojoin off.");if(a.autojoin.on){l=true;a.autojoin.on=false}break}var n="";for(var k in j){if(!j.hasOwnProperty(k)){continue}n=a.deform_ns(j[k]).toLowerCase();h(n)}if(l){a.config_save()}};g()};wsc.defaults.Extension.Away=function(b){var g=b.storage.folder("away"); +var f={on:false,reason:"",last:{},since:0,interval:60000,format:{setaway:"/me is away: {reason}",setback:"/me is back",away:"{user}: I've been away for {timesince}. Reason: {reason}"}};b.away=f;var m=function(){k();h();b.bind("cmd.setaway",a);b.bind("cmd.setback",l);b.ui.on("tabbed",j);b.ui.on("settings.open",f.page)};f.page=function(o,q){var n=function(u){u=replaceAll(u,"<","<");u=replaceAll(u,">",">");u=replaceAll(u,'"',""");return u};var r=function(u){u=replaceAll(u,"<","<");u=replaceAll(u,">",">");u=replaceAll(u,""",'"');return u};var p=o.settings.page("Away");var s={};s.away=f.format.away;s.sa=f.format.setaway;s.sb=f.format.setback;s.intr=f.interval;p.item("Text",{ref:"intro",title:"Away Messages",text:"Use away messages when you are away from the chats.\n\n You can set yourself away using the /setaway [reason] command. When you get back, use /setback. While you are away, the client will automatically respond when people try to talk to you, telling them you're away.",}); +p.item("Form",{ref:"msgs",title:"Messages",text:"Here you can set the messages displayed when you set yourself away or back. You can also change the away message format.",hint:"{user}
          This is replaced with the username of the person trying to talk to you\n\n{reason}
          This is replaced by your reason for being away.\n\n{timesince}
          Use this to show how long you have been away for.",fields:[["Textfield",{ref:"away",label:"Away","default":n(s.away)}],["Textfield",{ref:"setaway",label:"Setaway","default":n(s.sa)}],["Textfield",{ref:"setback",label:"Setback","default":n(s.sb)}]],event:{save:function(u){f.format.away=r(u.data.away);f.format.setaway=r(u.data.setaway);f.format.setback=r(u.data.setback);h()}}});p.item("Form",{ref:"interval",title:"Message Interval",text:"Here you can set the amount of time to wait before displaying another away message. The interval is in seconds.",fields:[["Textfield",{ref:"interval",label:"Interval","default":(s.intr/1000).toString()}]],event:{save:function(u){f.interval=parseInt(u.data.interval)*1000; +h()}}})};var a=function(p,n){f.on=true;f.last={};f.since=new Date();f.reason=p.args;var q=n.say;var o=replaceAll(f.format.setaway,"{reason}",f.reason||"[silent away]");if(o.indexOf("/me ")==0){o=o.substr(4);q=n.action}n.each_channel(function(r){q.call(n,r,o)});n.ui.control.add_state({ref:"away",label:"Away, reason: "+(f.reason||"[silent away]")+""})};var l=function(p,n){if(!f.on){return}f.on=false;var q=n.say;var o=f.format.setback;if(o.indexOf("/me ")==0){o=o.substr(4);q=n.action}n.each_channel(function(r){q.call(n,r,o)});n.ui.control.rem_state("away")};var j=function(q){if(!f.on){return}if(f.reason.length==0){return}if(q.user==b.settings.username){return}if(b.exclude.contains(q.ns)){return}var o=new Date();var p=q.sns.toLowerCase();if(p in f.last){if((o-f.last[p])<=f.interval){return}}var n=timeLengthString((o-f.since)/1000);var r=replaceAll(f.format.away,"{user}",q.user);r=replaceAll(r,"{timesince}",n);b.say(q.ns,replaceAll(r,"{reason}",f.reason));f.last[p]=o};var k=function(){f.format.setaway=g.get("setaway","/me is away: {reason}"); +f.format.setback=g.get("setback","/me is back");f.format.away=g.get("away","{user}: I've been away for {timesince}. Reason: {reason}");f.interval=parseInt(g.get("interval",60000))};var h=function(){g.set("interval",f.interval);g.set("setaway",f.format.setaway);g.set("setback",f.format.setback);g.set("away",f.format.away)};m()};wsc.defaults.Extension.Ignore=function(f){var g={};var h=f.storage.folder("ignore");var a=h.folder("ignored");var m=function(){l();k();f.bind("cmd.ignore",b);f.bind("cmd.unignore",j);f.ui.on("settings.open",g.page)};g.page=function(o,q){var p=o.settings.page("Ignores");var r={};r.im=g.ignore;r.uim=g.unignore;r.usr=f.ui.umuted;p.item("Text",{ref:"intro",title:"Ignores",text:'Use ignore to ignore people.\n\n You can "ignore" other users of the chat server using the\n /ignore command. Ignoring a user hides their messages from you in the channel log.',});p.item("Form",{ref:"msgs",title:"Messages",text:"Here you can set the messages displayed when you ignore or unignore a user.\n\nThe text {user} is replaced with the name of the user your are ignoring or unignoring.",fields:[["Textfield",{ref:"ignore",label:"Ignore","default":r.im}],["Textfield",{ref:"unignore",label:"Unignore","default":r.uim}]],event:{save:function(s){g.ignore=s.data.ignore; +g.unignore=s.data.unignore;k()}}});var n=p.item("Items",{ref:"ignoreds",title:"Users",text:"This is the list of users that you have silenced.\n\nUse the commands /ignore and /unignore to edit the list.",items:r.usr,prompt:{title:"Add User",label:"User:",},event:{up:function(s){var u=s.args.swap;f.ui.umuted[u["this"].index]=u.that.item;f.ui.umuted[u.that.index]=u["this"].item;n.options.items=f.ui.umuted},down:function(s){var u=s.args.swap;f.ui.umuted[u["this"].index]=u.that.item;f.ui.umuted[u.that.index]=u["this"].item;n.options.items=f.ui.umuted},add:function(s){f.mute_user(s.args.item);n.options.items=f.ui.umuted},remove:function(s){f.unmute_user(s.args.item);n.options.items=f.ui.umuted},save:function(s){r.usr=f.ui.umuted;k()},close:function(s){l()}}})};var b=function(q){var s=q.args.split(" ");var n="";var r="";var p=false;for(var o in s){if(!s.hasOwnProperty(o)){continue}n=s[o];tmod=f.mute_user(n);if(!tmod){continue}p=tmod; +r=replaceAll(g.ignore,"{user}",n);if(r.indexOf("/me ")==0){r=r.substr(4);f.action(q.target,r)}else{f.say(q.target,r)}}if(p){k()}};var j=function(r){var v=r.args.split(" ");var o="";var u="";var n=-1;var q=false;var s=false;for(var p in v){if(!v.hasOwnProperty(p)){continue}o=v[p];s=f.unmute_user(o);if(!s){continue}q=s;u=replaceAll(g.unignore,"{user}",o);if(u.indexOf("/me ")==0){u=u.substr(4);f.action(r.target,u)}else{f.say(r.target,u)}}if(q){k()}};var l=function(){g.ignore=h.get("ignore","/me is ignoring {user} now");g.unignore=h.get("unignore","/me is not ignoring {user} anymore");g.count=parseInt(h.get("count",0));var o=null;for(var n in f.ui.umuted){if(!f.ui.umuted.hasOwnProperty(n)){continue}f.unmute_user(f.ui.umuted[n])}f.ui.umuted=[];if(g.count>0){o=null;for(var n=0;n
          '); +this.protocol=new Chatterbox.Protocol();this.mw=new wsc.Middleware();this.view=b.find(".wsc");this.mns=this.format_ns(this.settings.monitor[0]);this.lun=this.settings.username.toLowerCase();this.monitoro=null;this.swidth=(function(){if($.browser.msie){var m=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body"),l=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body");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})();if(window.mozRTCPeerConnection){Chatterbox._gum=function(l,m,k){return navigator.mozGetUserMedia(l,m,k)}}if(window.webkitRTCPeerConnection){Chatterbox._gum=function(l,m,k){return navigator.webkitGetUserMedia(l,m,k) +}}if(window.RTCPeerConnection&&!window.mozRTCPeerConnection){Chatterbox._gum=function(l,m,k){return navigator.getUserMedia(l,m,k)}}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(b){var a=b[0];if(a=="#"||a=="@"||a=="~"||a=="+"){return b}if(b.indexOf("chat:")==0){return"#"+b.slice(5)}if(b.indexOf("server:")==0){return"~"+b.slice(7)}if(b.indexOf("feed:")==0){return"#"+b.slice(5)}if(b.indexOf("login:")==0){return"@"+b.slice(6)}if(b.indexOf("pchat:")==0){var f=b.split(":");f.shift();for(i in f){name=f[i];if(name.toLowerCase()!=this.lun){return"@"+name +}}}return"#"+b};Chatterbox.UI.prototype.format_ns=function(a){var f=a.slice(1);switch(a[0]){case"@":var b=[f,this.lun];b.sort(caseInsensitiveSort);b.unshift("pchat");a=b.join(":");break;case"~":a="server:"+f;break;case"+":a="feed:"+f;break;case"#":a="chat:"+f;break;default:if(a.indexOf("chat:")==0||a.indexOf("pchat:")==0||a.indexOf("server:")==0||a.indexOf("feed:")==0){break}a="chat:"+a;break}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.get_user_media=function(b,f,a){Chatterbox._gum(b,f,a)};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.add("click",this.sound.bank.m.find("audio.click")[0]);var j=this.sound;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)});this.client.bind("ns.user.list",function(l){h.channel(l.ns).set_user_list(l.users) +});this.client.middle("ns.user.privchg",function(m,l){h.channel(m.ns).privchg(m,l)});this.client.bind("ns.user.remove",function(m,l){h.channel(m.ns).remove_one_user(m.user)});this.client.bind("ns.user.registered",function(l){h.channel(l.ns).register_user(l.user)})};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=this.protocol.log(b);if(g){if(this.settings.developer){console.log(">>>",b.sns,"|",g.text())}if(b.hasOwnProperty("s")&&b.s=="0"){this.chatbook.handle(b,a);return}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.BaseTab=function(g,b,f,a){this.manager=g;this.hidden=f;this.monitor=(a==undefined?false:a); +this.built=false;this.raw=b;this.selector="t-"+(b||"chan").toLowerCase();this.namespace=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]}};if(!g){return}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)};Chatterbox.BaseTab.prototype.build=function(b){if(!this.manager){return}if(this.built){return}var a=this.selector;var g=this.namespace;var f=this.raw;this.el.t.o=this.manager.nav.add_tab(a,g);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(b||Chatterbox.render("basetab",{selector:a,ns:g}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");var h=this;this.el.t.l.click(function(){h.manager.toggle_channel(f);return false});this.el.t.c.click(function(j){h.manager.trigger("tab.close.clicked",{ns:h.raw,chan:h,e:j}); +return false});if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")}this.built=true};Chatterbox.BaseTab.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.BaseTab.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.BaseTab.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.BaseTab.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.BaseTab.prototype.resize=function(b,a){this.el.m.css({height:a||this.manager.chatbook.height(),width:(b||this.manager.chatbook.width())-10}) +};Chatterbox.BaseTab.prototype.loop=function(){};Chatterbox.Channel=function(g,b,f,a){Chatterbox.BaseTab.call(this,g,b,f,a);this.resized=function(){};this.ulbuf=0};Chatterbox.Channel.prototype=new Chatterbox.BaseTab;Chatterbox.Channel.prototype.constructor=Chatterbox.Channel;Chatterbox.Channel.prototype.build=function(){if(!this.manager){return}if(this.built){return}var a=this.selector;var f=this.namespace;var b=this.raw;Chatterbox.BaseTab.prototype.build.call(this,Chatterbox.render("channel",{selector:a,ns:f}));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.setup_header("title");this.setup_header("topic"); +if(this.namespace[0]=="@"){this.build_user_list({100:"Room Members"},[100])}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.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){Chatterbox.BaseTab.prototype.resize.call(this,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;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.ulbuf});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)}this.resized()};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:'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)]) +}if(l.agent){p.push(["agent",l.agent])}if(l.debug){p.push(["debug",l.debug])}p.push(["chatrooms",l.channels.join(" ")]);h.conns.push(p)}this.manager.trigger("log_whois.before",h);var b="";for(var n in h.conns){var k=h.conns[n];var r='

          connection '+((parseInt(n)+1).toString())+":

          ";r+="
            ";for(var q in k){r+="
          • "+k[q][0]+": "+k[q][1]+"
          • "}r+="
          ";b+=r+"
          "}var j="";for(var n in h.info){j+="
        • "+h.info[n]+"
        • "}var o=this.log_info("whois-"+m.username,Chatterbox.render("whoiswrap",{avatar:h.avatar,info:Chatterbox.render("whoisinfo",{username:h.username,info:j,connections:b})}));var g=o.find("div.avatar");var f=o.find("div.info");f.width(o.find(".whoiswrap").width()-100);g.height(o.height()-10);this.scroll()};Chatterbox.Channel.prototype.log_pc=function(g,h){contents="";for(var f in h){if(!h.hasOwnProperty(f)){continue}var b=h[f];var a="";if(b[2].length==0){a=""+(g?"default privileges":"no members")+""}else{a=b[2] +}contents+=String.format("
        • {0} {1}:
          • {2}
        • ",[b[1],b[0],a])}var j={title:"Privilege class "+(g?"permissions":"members"),info:"
            "+contents+"
          "};this.log_info("pc-"+(g?"permissions":"members"),Chatterbox.render("pcinfo",j))};Chatterbox.Channel.prototype.set_header=function(a,g,j,f){a=a.toLowerCase();var b=this.el.m.find("header."+a+" a[href=#edit]");if(this.el.h[a].html()!=""){if(g.html().length!=0){this.server_message(a+" set by "+j)}}this.el.h[a].html(g.html());var h=this;setTimeout(function(){if(g.text().length>0){h.el.h[a].css({display:"block"});var k=(h.el.h[a].outerHeight(true)-5)*(-1);b.css("top",k)}else{h.el.h[a].css({display:"none"})}h.resize()},100)};Chatterbox.Channel.prototype.get_header=function(a){return this.el.h[a.toLowerCase()]};Chatterbox.Channel.prototype.build_user_list=function(g,a){var j=this.el.u;var f="";var h=null;j.html("");for(var b in a){var f=g[a[b]];j.append('

          '+f+"

            "); +h=j.find(".pc#"+f);h.css("display","none")}};Chatterbox.Channel.prototype.reveal_user_list=function(){var h=this.el.u;var f=0;var b=0;var a=null;h.find("div.pc").each(function(j,k){a=h.find(this);b=a.find("ul li").length;f+=b;a.css("display",(b==0?"none":"block"))});h.css("display",(f==0?"none":"block"));var g=this;setTimeout(function(){g.resize()},100)};Chatterbox.Channel.prototype.set_user_list=function(g){if(Object.size(g)==0){return}var f=this.el.u;var a=null;for(var b in g){a=g[b];this.set_user(a,true)}this.reveal_user_list()};Chatterbox.Channel.prototype.set_user=function(h,f){var k=this.el.u.find("div.pc#"+replaceAll(h.pc," ","-"));var a=k.find("ul");var b=h.conn==1?"":"["+h.conn+"]";var j='
          • '+h.symbol+""+h.name+""+b+"
          • ";if(a.find("a#"+h.name).length==1){return}if(a.find("li").length==0){a.append(j)}else{var l=h.name.toLowerCase();var n=null;var g=false;a.find("li a").each(function(){if(g){return +}n=a.find(this);if(l"}j.window.append(Chatterbox.render("userinfo",{username:b.name,avatar:b.avatar,link:b.link,info:k}));g=j.window.find(".userinfo#"+b.name);j.window.find("div.userinfo:not('#"+b.name+"')").remove();var m=h.offset();g.css({top:(m.top-h.height())+10,left:(m.left-(g.width()))-6});g.find(".info").height(g.height());g.hover(function(){g.data("hover",1)},function(n){g.data("hover",0);j.unhover_user(g,n)});g.data("hover",0)};var f=function(k){h.data("hover",0);j.unhover_user(g,k)};h.off("mouseenter",a);h.off("mouseleave",f);h.on("mouseenter",a);h.on("mouseleave",f)};Chatterbox.Channel.prototype.unhover_user=function(g,f){var h=g.offset();var b=g.outerHeight(true)+h.top;var k=g.outerWidth(true)+h.left;var a=f.pageX;var j=f.pageY;if(a>h.left&&ah.top&&jh.left&&j>h.top&&j<(h.top+15)){return +}g.remove()};Chatterbox.Channel.prototype.mute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"none"});this.scroll()};Chatterbox.Channel.prototype.unmute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"list-item"});this.scroll()};Chatterbox.Channel.prototype.clear_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).remove();this.scroll()};Chatterbox.Channel.prototype.pkt_join=function(b,a){if(b.e!="ok"){return}this.set_header("title",(new wsc.MessageString("")),"","");this.set_header("topic",(new wsc.MessageString("")),"","")};Chatterbox.Channel.prototype.pkt_recv_msg=function(b,a){var f=this;this.manager.cascade("chan.recv_msg",function(j,g){var h=f.manager.client.settings.username.toLowerCase();if(h==j.user.toLowerCase()){return}var l=j.message.toLowerCase();var k=l.indexOf(h)!=-1;if(!k&&j.sns[0]!="@"){return}if(k){f.highlight()}else{f.highlight(false)}f.manager.trigger("tabbed",j) +},b)};Chatterbox.Channel.prototype.pkt_recv_action=Chatterbox.Channel.prototype.pkt_recv_msg;Chatterbox.Channel.prototype.pkt_property=function(b,a){var g=b.pkt.arg.p;var f=a.channel(this.namespace);switch(g){case"title":case"topic":this.set_header(g,b.value||(new wsc.MessageString("")),b.by,b.ts);break;case"privclasses":this.build_user_list(f.info.pc,f.info.pc_order.slice(0));break;case"members":break;default:break}};Chatterbox.Chatbook=function(a){this.manager=a;this.view=this.manager.view.find("div.chatbook");this.chan={};this.trail=[];this.current=null;this.manager.on("tab.close.clicked",function(b,f){f.chatbook.remove_channel(b.ns)})};Chatterbox.Chatbook.prototype.height=function(){return this.view.height()};Chatterbox.Chatbook.prototype.width=function(){return this.view.width()};Chatterbox.Chatbook.prototype.resize=function(b){b=b||600;var f=this.view.innerWidth();for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}var g=this.chan[a];g.resize(f,b)}};Chatterbox.Chatbook.prototype.loop=function(){for(select in this.chan){this.chan[select].loop() +}};Chatterbox.Chatbook.prototype.channel=function(a,b){a=this.manager.format_ns(a).toLowerCase();if(!this.chan[a]&&b){this.chan[a]=b}return this.chan[a]};Chatterbox.Chatbook.prototype.channels=function(){chans=-1;for(ns in this.chan){if(this.chan[ns].hidden){continue}chans++}return chans};Chatterbox.Chatbook.prototype.create_channel=function(b,f,a){var g=this.channel(b,this.channel_object(b,f,a));g.build();if(this.trail.indexOf(g.namespace)==-1){this.trail.push(g.namespace)}if(!g.visible){this.toggle_channel(b)}this.manager.resize();return g};Chatterbox.Chatbook.prototype.channel_object=function(a,b){return new Chatterbox.Channel(this.manager,a,b)};Chatterbox.Chatbook.prototype.toggle_channel=function(a){var f=this.channel(a);var b=f;if(!f){return}if(f.hidden){if(this.current&&this.current==f){return}if(!this.manager.settings.developer){f.hide();return}}if(this.current){if(this.current==f){return}this.current.hide();b=this.current}else{if(this.manager.monitoro!==null){this.manager.monitoro.hide() +}}f.show();this.manager.control.focus();this.current=f;this.manager.resize();this.manager.control.cache_input(b,f);this.manager.trigger("channel.selected",{ns:f.raw,chan:f,prev:b});this.manager.client.select_ns(f.raw)};Chatterbox.Chatbook.prototype.remove_channel=function(a){var b=this.channel(a);if(!b){return}if(this.channels()==0&&!b.hidden){return}b.remove();delete this.chan[b.raw.toLowerCase()];if(this.current==b){this.channel_left()}var f=this.trail.indexOf(b.namespace);this.trail.splice(f,1)};Chatterbox.Chatbook.prototype.channel_left=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a<0){return}var g=null;while(true){try{g=this.channel(this.trail[--a])}catch(f){a=this.trail.length-1;g=this.channel(this.trail[a])}if(!g.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(g.namespace)};Chatterbox.Chatbook.prototype.channel_right=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a==-1){return}var g=null;while(true){try{g=this.channel(this.trail[++a]) +}catch(f){a=0;g=this.channel(this.trail[0])}if(!g.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(g.namespace)};Chatterbox.Chatbook.prototype.each=function(f){var b=null;for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}b=this.chan[a];if(f(b.namespace,b)===false){break}}};Chatterbox.Chatbook.prototype.server_message=function(b,a){for(ns in this.chan){this.chan[ns].server_message(b,a)}};Chatterbox.Chatbook.prototype.log_item=function(a){for(ns in this.chan){this.chan[ns].log_item(a)}};Chatterbox.Chatbook.prototype.log=function(a){for(ns in this.chan){this.chan[ns].log(a)}};Chatterbox.Chatbook.prototype.log_message=function(f,b){try{if(!f.global){if(!f.monitor){this.channel(b.ns).log_item(b)}else{this.manager.monitoro.log_item(b)}}else{this.log_item(b)}}catch(a){try{this.ui.monitoro.server_message("Failed to log for",b.sns,b.html)}catch(a){console.log(">> Failed to log message for",b.sns,"::");console.log(">>",b.html)}}};Chatterbox.Chatbook.prototype.retime=function(){for(ns in this.chan){this.chan[ns].retime() +}};Chatterbox.Chatbook.prototype.developer=function(){this.each(function(a,b){b.developer()})};Chatterbox.Chatbook.prototype.handle=function(g,b){var h=this.manager;var j=this.channel(g.ns);if(!j){return}var a="pkt_"+g.name;try{j[a](g,b)}catch(f){}};Chatterbox.Control=function(b){this.manager=b;this.manager.view.append(Chatterbox.template.control);this.view=this.manager.view.find("div.chatcontrol");this.ml=false;this.history={};this.tab={hit:false,cache:"",matched:[],index:-1,type:0,prefix:["","/",""],};this.el={form:this.view.find("form.msg"),i:{s:this.view.find("form.msg input.msg"),m:this.view.find("form.msg textarea.msg"),c:null,t:this.view.find("ul.buttons a[href~=#multiline].button")},brow:{m:this.view.find("div.brow"),b:this.view.find("div.brow ul.buttons"),s:this.view.find("div.brow ul.states")}};this.el.i.c=this.el.i.s;var a=this;this.el.i.t.click(function(f){a.multiline(!a.multiline());return false});this.el.i.s.keydown(function(f){return a.keypress(f)});this.el.i.m.keydown(function(f){return a.keypress(f) +});this.el.form.submit(function(f){return a.submit(f)});this.add_button({label:"b",icon:false,href:"#bold",title:"Bold text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"i",icon:false,href:"#italic",title:"Italic text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"u",icon:false,href:"#underline",title:"Underline text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sup",icon:false,href:"#sup",title:"Superscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sub",icon:false,href:"#sub",title:"Subscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}})};Chatterbox.Control.prototype.surroundtext=function(k,j,b){var h=k.scrollTop;var a=k.value,f=k.selectionStart,g=k.selectionEnd;var l=k.value.substring(f,g);k.value=a.substring(0,f)+j+l+b+a.substring(g);k.selectionStart=f+j.length; +k.selectionEnd=f+j.length+l.length;k.scrollTop=h;k.focus()};Chatterbox.Control.prototype.focus=function(){this.el.i.c.focus()};Chatterbox.Control.prototype.resize=function(){w=this.manager.view.width();this.view.css({width:"100%"});this.el.form.css({width:this.manager.view.width()-20});this.el.i.s.css({width:this.manager.view.width()-100});this.el.i.m.css({width:this.manager.view.width()-90})};Chatterbox.Control.prototype.height=function(){var a=this.view.outerHeight();return a};Chatterbox.Control.prototype.multiline=function(a){if(a==undefined||this.ml==a){return this.ml}this.ml=a;var b=(this.ml?"s":"m");a=(this.ml?"m":"s");this.el.i[b].css("display","none");this.el.i[a].css("display","inline-block");this.el.i.c=this.el.i[a];this.manager.resize();return this.ml};Chatterbox.Control.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.brow.b.append(Chatterbox.render("brow_button",a)); +var b=this.el.brow.b.find("a[href="+a.href+"].button");b.click(function(f){a.handler();return false});return b};Chatterbox.Control.prototype.add_state=function(a){a=Object.extend({ref:"state",label:"some state"},(a||{}));var b=this.el.brow.s.find("li#"+a.ref);if(b.length==0){this.el.brow.s.append(Chatterbox.render("brow_state",a));return this.el.brow.s.find("li#"+a.ref)}b.html(a.label);return b};Chatterbox.Control.prototype.rem_state=function(a){return this.el.brow.s.find("li#"+a).remove()};Chatterbox.Control.prototype.chomp=function(){var f=this.el.i.c.val();var b=f.lastIndexOf(" ");if(b==-1){this.el.i.c.val("");return f}var a=f.slice(b+1);this.el.i.c.val(f.slice(0,b));if(a.length==0){return this.chomp()}return a};Chatterbox.Control.prototype.unchomp=function(a){var b=this.el.i.c.val();if(!b){this.el.i.c.val(a)}else{this.el.i.c.val(b+" "+a)}};Chatterbox.Control.prototype.get_text=function(a){if(a==undefined){return this.el.i.c.val()}this.el.i.c.val(a||"");return this.el.i.c.val()};Chatterbox.Control.prototype.set_text=function(a){this.el.i.c.val(a||"") +};Chatterbox.Control.prototype.cache_input=function(b,f){var a=this.get_history(b.namespace);if(a.index>-1){return}a.tmp=this.get_text();this.set_text(this.get_history(f.namespace).tmp)};Chatterbox.Control.prototype.get_history=function(a){if(!a){if(!this.manager.chatbook.current){a="~monitor"}}a=a||this.manager.chatbook.current.namespace;if(!this.history[a]){this.history[a]={index:-1,list:[],tmp:""}}return this.history[a]};Chatterbox.Control.prototype.append_history=function(b){if(!b){return}var a=this.get_history();a.list.unshift(b);a.index=-1;if(a.list.length>100){a.list.pop()}};Chatterbox.Control.prototype.scroll_history=function(a){var f=this.get_history();var b=this.get_text();if(f.index==-1){if(b){f.tmp=b}else{f.list[f.index]=b}}if(a){if(f.list.length>0&&f.index<(f.list.length-1)){f.index++}}else{if(f.index>-1){f.index--}}this.set_text(f.list[f.index]||f.tmp)};Chatterbox.Control.prototype.tab_item=function(b){if(!this.tab.hit){this.start_tab(b)}this.chomp();this.tab.index++;if(this.tab.index>=this.tab.matched.length){this.tab.index=-1 +}if(this.tab.index==-1){this.unchomp(this.tab.prefix[this.tab.type]+this.tab.cache);return}var a=this.get_text()==""?(this.tab.type==0?": ":" "):"";this.unchomp(this.tab.prefix[this.tab.type]+this.tab.matched[this.tab.index]+a)};Chatterbox.Control.prototype.start_tab=function(f){this.tab.hit=true;this.tab.index=-1;this.tab.matched=[];this.tab.type=0;var j=this.chomp();this.unchomp(j);if(j[0]=="/"||j[0]=="#"||j[0]=="@"){this.tab.type=j[0]=="/"?1:2;if(j[0]=="/"){j=j.slice(1)}}else{this.tab.type=0}this.tab.cache=j;j=j.toLowerCase();this.tab.matched=[];if(this.tab.type==0){var k=this.manager.client.channel(this.manager.chatbook.current.namespace);for(var a in k.info.members){if(a.toLowerCase().indexOf(j)==0){this.tab.matched.push(a)}}}else{if(this.tab.type==1){var h="";for(var b in this.manager.client.cmds){h=this.manager.client.cmds[b];if(h.indexOf(j)==0){this.tab.matched.push(h)}}}else{if(this.tab.type==2){var g=this;this.manager.client.each_channel(function(l,m){if(m.namespace.toLowerCase().indexOf(j)==0){g.tab.matched.push(m.namespace) +}})}}}};Chatterbox.Control.prototype.end_tab=function(a){this.tab.hit=false;this.tab.matched=[];this.tab.cache="";this.tab.index=-1};Chatterbox.Control.prototype.submit=function(a){var b=this.get_text();this.append_history(b);this.set_text("");this.handle(a,b);return false};Chatterbox.Control.prototype.keypress=function(f){var b=f.which||f.keyCode;var g=this.tab.hit;var a=false;switch(b){case 13:if(!this.multiline()){this.submit(f)}else{if(f.shiftKey){this.submit(f)}else{a=true}}break;case 38:if(!this.multiline()){this.scroll_history(true);break}a=true;break;case 40:if(!this.multiline()){this.scroll_history(false);break}a=true;break;case 9:if(f.shiftKey){this.manager.channel_right()}else{this.tab_item(f);g=false}break;case 219:if(f.ctrlKey){this.manager.channel_left()}else{a=true}break;case 221:if(f.ctrlKey){this.manager.channel_right()}else{a=true}break;default:a=true;break}if(g){this.end_tab(f)}return a};Chatterbox.Control.prototype.handle=function(b,h){if(h==""){return}if(!this.manager.chatbook.current){return +}var l=false;if(h[0]!="/"){l=true}h=(b.shiftKey?"/npmsg ":(h[0]=="/"?"":"/say "))+h;h=h.slice(1);var m=h.split(" ");var f=m.shift().toLowerCase();var k=this.manager.chatbook.current.namespace;var j=k;if(!l&&m[0]){var g=m[0][0];if((g=="#"||g=="@")&&m[0].length>1){j=this.manager.format_ns(m.shift())}}var n=m.join(" ");var a=this.manager.client.trigger("cmd."+f,{name:"cmd",cmd:f,args:n,target:j,ns:k});if(a==0){this.manager.pager.notice({ref:"cmd-fail",heading:"Command failed",content:'"'+f+'" is not a command.'},false,5000)}};Chatterbox.Navigation=function(a){this.manager=a;this.showclose=this.manager.settings.tabclose;this.settings={};this.settings.open=false;this.el={n:this.manager.view.find("nav.tabs"),tw:this.manager.view.find("nav.tabs div.tabwrap"),t:this.manager.view.find("nav.tabs #chattabs"),b:this.manager.view.find("nav.tabs #tabnav"),l:this.manager.view.find("nav.tabs #tabnav .arrow_left"),r:this.manager.view.find("nav.tabs #tabnav .arrow_right"),s:this.manager.view.find("nav.tabs #tabnav #settings-button"),}; +if(!this.showclose){if(!this.el.t.hasClass("hc")){this.el.t.addClass("hc")}}var b=this;this.el.s.click(function(h){if(b.settings.open){return false}var f={e:h,settings:new Chatterbox.Settings.Config(b.manager)};b.configure_page(f);b.manager.trigger("settings.open",f);b.manager.trigger("settings.open.ran",f);var g=f.settings.page("About");g.item("text",{ref:"about-chatterbox",wclass:"centered faint",text:'Using Chatterbox version '+Chatterbox.VERSION+" "+Chatterbox.STATE+' by ~photofroggy.'});b.settings.window=new Chatterbox.Settings(b.manager,f.settings);b.settings.window.build();b.settings.open=true;return false});this.el.l.click(function(){b.manager.channel_left();return false});this.el.r.click(function(){b.manager.channel_right();return false})};Chatterbox.Navigation.prototype.configure_page=function(b){var g=this.manager;var f=b.settings.page("Main");var h={};h.theme=replaceAll(g.settings.theme,"wsct_",""); +h.clock=g.clock();h.tc=g.nav.closer();var a=[];for(i in g.settings.themes){name=replaceAll(g.settings.themes[i],"wsct_","");a.push({value:name,title:name,selected:h.theme==name})}f.item("Form",{ref:"ui",title:"UI",hint:"Timestamp
            Choose between a 24 hour clock and a 12 hour clock.\n\nTheme
            Change the look of the client.\n\nClose Buttons
            Turn tab close buttons on/off.",fields:[["Dropdown",{ref:"theme",label:"Theme",items:a}],["Dropdown",{ref:"clock",label:"Timestamp Format",items:[{value:"24",title:"24 hour",selected:h.clock},{value:"12",title:"12 hour",selected:!h.clock}]}],["Checkbox",{ref:"tabclose",label:"Close Buttons",items:[{value:"yes",title:"On",selected:h.tc}]}],],event:{change:function(j){g.clock(j.data.clock=="24");g.theme(j.data.theme);g.nav.closer(j.data.tabclose.indexOf("yes")>-1)},save:function(j){h.clock=g.clock();h.theme=replaceAll(g.theme(),"wsct_","");h.tc=g.nav.closer();g.trigger("settings.save.ui",{clock:h.clock,tabclose:h.tc,theme:"wsct_"+h.theme}) +},close:function(j){g.clock(h.clock);g.theme(h.theme);g.nav.closer(h.tc)}}})};Chatterbox.Navigation.prototype.height=function(){var a=this.el.n.outerHeight();return a};Chatterbox.Navigation.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.b.prepend(Chatterbox.render("nav_button",a));var b=this.el.b.find("a[href="+a.href+"].button");b.click(function(f){a.handler();return false});this.resize();return b};Chatterbox.Navigation.prototype.add_tab=function(a,b){this.el.t.append(Chatterbox.render("tab",{selector:a,ns:b}));return this.el.t.find("#"+a+"-tab")};Chatterbox.Navigation.prototype.resize=function(){this.el.tw.width(this.el.n.width()-this.el.b.outerWidth()-20);if(this.settings.open){this.settings.window.resize()}};Chatterbox.Navigation.prototype.closer=function(a){if(a==undefined||a==this.showclose){return this.showclose}this.showclose=a; +if(this.showclose){if(!this.el.t.hasClass("hc")){return}this.el.t.removeClass("hc");return}if(this.el.t.hasClass("hc")){return}this.el.t.addClass("hc")};Chatterbox.Pager=function(a){this.manager=a;this.lifespan=20000;this.halflife=5000;this.el={m:null,click:null};this.sound={click:function(){},};this.notices=[];this.build()};Chatterbox.Pager.prototype.build=function(){this.el.m=this.manager.view.find("div.pager")};Chatterbox.Pager.prototype.notice=function(g,m,l,f){var j={frame:null,close:null,foot:null,b:{},options:Object.extend({ref:"notice",icon:"",heading:"Some notice",content:"Notice content goes here."},(g||{})),onclose:function(){},ondestroy:function(){}};j.options.ref+="-"+(new Date()).valueOf();j.options.content=j.options.content.split("\n").join("

            ");this.notices.push(j);this.el.m.append(Chatterbox.render("pager.notice",j.options));j.frame=this.el.m.find("#"+j.options.ref).last();j.close=j.frame.find("a.close_notice");j.foot=j.frame.find("footer.buttons");var h={};for(var a in j.options.buttons){if(!j.options.buttons.hasOwnProperty(a)){continue +}h=j.options.buttons[a];j.foot.append(Chatterbox.render("pager.button",h));j.b[a]=j.foot.find("a#"+h.ref);j.b[a].click(h.click)}var k=this;j.close.click(function(){j.onclose();k.remove_notice(j);return false});if(!m){if(!l){l=k.lifespan}setTimeout(function(){k.remove_notice(j,true)},l)}if(f!==true){this.manager.sound.click()}return j};Chatterbox.Pager.prototype.remove_notice=function(a,f){var b=this;if(this.notices.indexOf(a)==-1){return false}a.frame.fadeTo((f?this.halflife:300),0).slideUp(function(){a.frame.remove();b.notices.splice(b.notices.indexOf(a),1);a.ondestroy()});if(f){a.frame.mouseenter(function(){if(b.notices.indexOf(a)==-1){return}a.frame.stop(true);a.frame.slideDown(function(){a.frame.fadeTo(300,1);a.frame.mouseleave(function(){setTimeout(function(){b.remove_notice(a,true)},b.lifespan)})})})}};Chatterbox.Pager.prototype.find_notice=function(a){for(var b in this.notices){if(this.notices[b].options.ref==a){return this.notices[b]}}return null};Chatterbox.Popup=function(b,a){this.manager=b; +this.pview=(this.manager||{view:{find:function(){}}}).view;this.window=null;this.closeb=null;this.options=Object.extend({ref:"popup",title:"Popup",close:true,content:""},(a||{}))};Chatterbox.Popup.prototype.build=function(){var b=this.options;if(this.options.close){b.title+=''}this.pview.append(Chatterbox.render("popup",b));this.window=this.pview.find(".floater."+b.ref);if(this.options.close){this.closeb=this.window.find("a.close");var a=this;this.closeb.click(function(f){a.close();return false})}};Chatterbox.Popup.prototype.close=function(){this.window.remove()};Chatterbox.Popup.Prompt=function(b,a){a=a||{};a=Object.extend({position:[0,0],ref:"prompt",title:"Input",close:false,label:"","default":"","submit-button":"Submit",event:{submit:function(){},cancel:function(){}}},a);Chatterbox.Popup.call(this,b,a);this.data=this.options["default"]};Chatterbox.Popup.Prompt.prototype=new Chatterbox.Popup();Chatterbox.Popup.Prompt.prototype.constructor=Chatterbox.Popup.Prompt; +Chatterbox.Popup.Prompt.prototype.build=function(){this.options.content=Chatterbox.template.prompt.main;Chatterbox.Popup.prototype.build.call(this);this.window.css({left:this.options.position[0],top:this.options.position[1]});var a=this;this.window.find(".button.close").click(function(){a.options.event.cancel(a);a.close();return false});this.window.find(".button.submit").click(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false});this.window.find("form").submit(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false})};Chatterbox.Popup.ItemPicker=function(b,a){a=a||{};a=Object.extend({position:[100,60],ref:"item-picker",title:"Items",event:{select:function(f){}}},a);Chatterbox.Popup.call(this,b,a);this.pview=this.pview.find(".chatbook");this.data=this.options["default"];this.pages=[];this.cpage=null};Chatterbox.Popup.ItemPicker.prototype=new Chatterbox.Popup();Chatterbox.Popup.ItemPicker.prototype.constructor=Chatterbox.Popup.ItemPicker; +Chatterbox.Popup.ItemPicker.prototype.build=function(){this.options.content=Chatterbox.render("ip.main",{});Chatterbox.Popup.prototype.build.call(this);this.window.css({right:this.options.position[0],bottom:this.options.position[1]});this.closeb.removeClass("medium");this.pbook=this.window.find("section.pages");this.tabs=this.window.find("section.tabs ul");this.buttons=this.window.find("section.buttons");var f=this;var b=null;for(var a in this.pages){if(!this.pages.hasOwnProperty(a)){continue}b=this.pages[a];b.build();if(a==0){this.select_page(b)}}};Chatterbox.Popup.ItemPicker.prototype.refresh=function(){if(this.cpage==null){return}else{this.cpage.refresh()}};Chatterbox.Popup.ItemPicker.prototype.page=function(b,a){b=b.toLowerCase();for(var f in this.pages){if(!this.pages.hasOwnProperty(f)){continue}if(this.pages[f].name.toLowerCase()==b){return this.pages[f]}}return(a||null)};Chatterbox.Popup.ItemPicker.prototype.add_page=function(a,b){this.pages.push(new (b||Chatterbox.Popup.ItemPicker.Page)(this,a)) +};Chatterbox.Popup.ItemPicker.prototype.add_button=function(a){a=Object.extend({href:"#button",title:"Button",label:"Button"},(a||{}));this.buttons.append(Chatterbox.render("ip.button",a));return this.buttons.find("a[href="+a.href+"]")};Chatterbox.Popup.ItemPicker.prototype.select=function(a){this.options.event.select(a)};Chatterbox.Popup.ItemPicker.prototype.select_page=function(a){if(!a){return}if(this.cpage!=null){this.cpage.hide()}this.cpage=a||null;if(this.cpage!=null){this.cpage.show()}};Chatterbox.Popup.ItemPicker.Page=function(b,a){this.picker=b;this.options=Object.extend({ref:"page",href:"#page",label:"Page",title:"page",items:[],content:"No items on this page.",},(a||{}));this.name=this.options.label;this.nrefresh=true};Chatterbox.Popup.ItemPicker.Page.prototype.build=function(){this.picker.pbook.append(Chatterbox.render("ip.page",this.options));this.picker.tabs.append(Chatterbox.render("ip.tab",this.options));this.view=this.picker.pbook.find("div.page#"+this.options.ref); +this.items=this.view.find("ul");this.tab=this.picker.tabs.find("#"+this.options.ref);this.refresh();var a=this;this.tab.find("a").click(function(){a.picker.select_page(a);return false})};Chatterbox.Popup.ItemPicker.Page.prototype.refresh=function(){var a=this.build_list();if(a.length==0){this.options.content="No items on this page."}else{this.options.content="

              "+a+"
            "}this.view.html(this.options.content);this.items=this.view.find("ul");this.hook_events();this.nrefresh=false};Chatterbox.Popup.ItemPicker.Page.prototype.hook_events=function(){var a=this;this.items.find("li").each(function(b,g){var h=a.view.find(g);var f=h.find(".value").html();h.click(function(){a.picker.select(f)})})};Chatterbox.Popup.ItemPicker.Page.prototype.build_list=function(){var f=[];var g=null;var j,h,b;for(var a in this.options.items){if(!this.options.items.hasOwnProperty(a)){continue}g=this.options.items[a];h=g.value||g;j=g.title||h;b=g.html||false;f.push('
          • '+(b?h:''+h+"")+"
          • ") +}return f.join("")};Chatterbox.Popup.ItemPicker.Page.prototype.show=function(){this.tab.addClass("selected");this.view.css("display","block");this.refresh()};Chatterbox.Popup.ItemPicker.Page.prototype.hide=function(){this.tab.removeClass("selected");this.view.css("display","none")};Chatterbox.Protocol=function(){this.messages={chatserver:{keys:["version"],template:'** Connected to llama {version} *',global:true},dAmnServer:{keys:["version"],template:'** Connected to dAmnServer {version} *',global:true},login:{keys:["username","e","data"],template:'** Login as {username}: "{e}" *',global:true},join:{keys:["ns","e"],template:'** Join {ns}: "{e}" *',monitor:true},part:{keys:["ns","e","r"],template:'** Part {ns}: "{e}" * {r}',monitor:true},property:{keys:["ns","p","by","ts","value"],template:'** Got {p} for {ns} *',monitor:true},recv_msg:{keys:["user","message"],template:'<{user}>{message}'},recv_action:{keys:["s","user","message"],template:'* {user}{message}'},recv_join:{keys:["user","s","info"],template:'** {user} has joined *',},recv_part:{keys:["user","r"],template:'** {user} has left * {r}'},recv_privchg:{keys:["user","s","by","pc"],template:'** {user} has been made a member of {pc} by {by} *'},recv_kicked:{keys:["user","s","by","r"],template:'** {user} has been kicked by {by} * {r}'},recv_admin_create:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been created by {user} * {privs}'},recv_admin_update:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been updated by {user} * {privs}'},recv_admin_rename:{keys:["p","user","prev","pc"],template:'** Privilege class {prev} has been renamed to {pc} by {user} *'},recv_admin_move:{keys:["p","user","prev","pc","affected"],template:'** All members of {prev} have been moved to {pc} by {user} * {affected} affected user(s)'},recv_admin_remove:{keys:["p","user","pc","affected"],template:'** Privilege class {pc} has been removed by {user} * {affected} affected user(s)'},recv_admin_show:null,recv_admin_showverbose:null,recv_admin_privclass:{keys:["p","e","command"],template:'** Admin command "{command}" failed * {e}'},kicked:{keys:["ns","user","r"],template:'** You have been kicked by {user} * {r}'},ping:null,disconnect:{keys:["e"],template:'** You have been disconnected * {e}',global:true},send:{keys:["ns","e"],template:'** Send error: {e}'},kick:{keys:["ns","user","e"],template:'** Could not kick {user} * {e}'},get:{keys:["ns","p","e"],template:'** Could not get {p} info for {ns} * {e}'},set:{keys:["ns","p","e"],template:'** Could not set {p} * {e}'},kill:{keys:["ns","e"],template:'** Kill error * {e}'},unknown:{keys:["ns","packet"],template:'** Received unknown packet in {ns} * {packet}',monitor:true}} };Chatterbox.Protocol.prototype.extend_messages=function(b){for(var a in b){this.messages[a]=b[a]}};Chatterbox.Protocol.prototype.log=function(b){var a=this.messages[b.name];return new Chatterbox.Protocol.LogMessage(b,a)};Chatterbox.Protocol.LogMessage=function(b,a){a=a||{};this.event=b;this.template=a.template||"";this.keys=a.keys||[];this.monitor=a.monitor||false;this.global=a.global||false;this._html=false;this._text=false;this._ansi=false};Chatterbox.Protocol.LogMessage.prototype.text=function(){if(this._text===false){this._text=this.render(0)}return this._text};Chatterbox.Protocol.LogMessage.prototype.html=function(){if(this._html===false){this._html=this.render(1)}return this._html};Chatterbox.Protocol.LogMessage.prototype.ansi=function(){if(this._ansi===false){this._ansi=this.render(2)}return this._ansi};Chatterbox.Protocol.LogMessage.prototype.render=function(f){if(f===undefined){f=0}var b=this.template;var g="";for(var a in this.keys){if(!this.keys.hasOwnProperty(a)){continue}key=this.keys[a]; if(key instanceof Array){key=key[1]}if(!this.event.hasOwnProperty(key)||key=="pkt"){continue}g=this.event[key];if(g==null){continue}if(key=="ns"||key=="sns"){key="ns";g=this.event.sns}if(g.hasOwnProperty("_parser")){switch(f){case 1:g=g.html();break;case 2:g=g.ansi();break;case 0:default:g=g.text();break}}b=replaceAll(b,"{"+key+"}",g)}return b};Chatterbox.Settings=function(b,a){Chatterbox.Popup.call(this,b,{ref:"settings",title:"Settings",close:false,content:""});this.config=a;this.saveb=null;this.scb=null;this.tabs=null;this.book=null;this.changed=false;this.manager=b};Chatterbox.Settings.prototype=new Chatterbox.Popup();Chatterbox.Settings.prototype.constructor=Chatterbox.Settings;Chatterbox.Settings.prototype.build=function(){this.options.content=Chatterbox.template.settings.main;Chatterbox.Popup.prototype.build.call(this);this.saveb=this.window.find("a.button.save");this.closeb=this.window.find("a.close");this.scb=this.window.find("a.button.saveclose");this.tabs=this.window.find("nav.tabs ul.tabs"); this.book=this.window.find("div.book");this.config.build(this.manager,this);this.window.find("ul.tabs li").first().addClass("active");this.window.find("div.book div.page").first().addClass("active");var a=this;this.window.find("form").bind("change",function(){a.changed=true});this.config.each_page(function(b,f){f.each_item(function(g,h){h._onchange=function(j){a.changed=true}})});this.saveb.click(function(b){a.save();return false});this.closeb.click(function(b){if(a.changed){if(!confirm("Are you sure? You will lose any unsaved changes.")){return false}}a.close();return false});this.scb.click(function(b){a.save();a.close();return false});this.resize()};Chatterbox.Settings.prototype.resize=function(){var a=this.window.find(".inner");var f=a.find("h2");var g=a.find(".bookwrap");var b=a.find("footer");g.height(a.height()-b.outerHeight()-f.outerHeight()-15);this.book.height(g.innerHeight()-this.tabs.outerHeight()-25);this.book.width(g.innerWidth()-20);this.config.resize()};Chatterbox.Settings.prototype.switch_page=function(b){var f=this.tabs.find("li.active").first(); diff --git a/dist/wsc.js b/dist/wsc.js index 1c70b9b..07e24b6 100644 --- a/dist/wsc.js +++ b/dist/wsc.js @@ -2185,11 +2185,13 @@ wsc.defaults.Extension = function( client ) { // lol themes client.bind('cmd.theme', cmd.theme); + /* // some ui business. client.ui.on('settings.open', settings_page); client.ui.on('settings.open.ran', about_page); client.ui.on('settings.save.ui', settings_save); client.ui.on('settings.save', function( ) { client.config_save(); } ); + */ }; var settings_save = function( e, ui ) { @@ -2428,7 +2430,8 @@ wsc.defaults.Extension = function( client ) { // Say something. cmd.say = function( e ) { - if( client.channel(e.target).monitor ) return; + if( client.channel(e.target).monitor ) + return; client.say( e.target, e.args ); }; @@ -2572,21 +2575,21 @@ wsc.defaults.Extension = function( client ) { * * @method Ignore */ - wsc.defaults.Extension.Ignore(client); + //wsc.defaults.Extension.Ignore(client); /** * Implements away messages. * * @method Away */ - wsc.defaults.Extension.Away(client); + //wsc.defaults.Extension.Away(client); /** * Implements autojoin channels. * * @method Autojoin */ - wsc.defaults.Extension.Autojoin(client); + //wsc.defaults.Extension.Autojoin(client); }; /** @@ -3361,6 +3364,8 @@ wsc.Client = function( view, options, mozilla ) { } */ + wsc.defaults.Extension( this ); + // Welcome! //this.monitor(this.settings["welcome"]); @@ -3441,7 +3446,7 @@ wsc.Client.prototype.config_save = function( ) { wsc.Client.prototype.build = function( ) { //this.ui.build(); - //this.create_ns( this.settings.monitor[0], true, true ); + this.create_ns( this.settings.monitor[0], true, true ); var client = this; /* this.ui.on('tab.close.clicked', function( event, ui ) { @@ -4208,6 +4213,8 @@ Chatterbox._gum = function( ) {}; if( ui == undefined ) { ui = new Chatterbox.UI( $(this), client, options, ($.browser.mozilla || false) ); $(window).resize(ui.resize); + setInterval(function( ) { ui.loop(); }, 120000); + ui.build(); } $(window).data('chatterbox', ui); } diff --git a/dist/wsc.min.js b/dist/wsc.min.js index a30ee74..06051a1 100644 --- a/dist/wsc.min.js +++ b/dist/wsc.min.js @@ -21,76 +21,76 @@ var a=this;this.mapper={recv:function(g,f,d){f.ns=g.param;return a.map(g.sub[0], a.connected=true;a.handshake();a.attempts=0};wsc.Flow.prototype.close=function(b,d){var a={name:"closed",pkt:new wsc.Packet("connection closed\n\n"),reason:"",evt:d,connected:b.connected,sio:b.conn instanceof wsc.SocketIO,cause:"",reconnect:true};b.trigger("closed",a);if(b.connected){b.connected=false;if(b.conn instanceof wsc.SocketIO){return}}else{}a.name="quit";if(b.attempts>2){a.reconnect=false;b.attempts=0;b.trigger("quit",a);return}if(d.cause){if(d.cause.hasOwnProperty("name")&&d.cause.name=="login"){b.trigger("quit",a);return}}setTimeout(function(){b.connect()},2000)};wsc.Flow.prototype.message=function(a,f){var b=new wsc.Packet(unescape(replaceAll(f.data,"+"," ")));if(b==null){return}var d=this.protocol.parse(b);if(d.ns==null){d.ns=a.mns}d.sns=a.deform_ns(d.ns);this.handle(a,d);a.trigger("pkt",d);a.trigger("pkt."+d.name,d)};wsc.Flow.prototype.handle=function(a,d){try{this[d.name](d,a)}catch(b){}};wsc.Flow.prototype.ping=function(b,a){a.pong()};wsc.Flow.prototype.chatserver=function(b,a){a.login() };wsc.Flow.prototype.login=function(d,a){if(d.pkt.arg.e=="ok"){var g=d.pkt.sub[0];a.settings.username=d.pkt.param;a.settings.symbol=g.arg.symbol;a.settings.userinfo=g.arg;var b=function(){a.join(a.settings.autojoin);if(a.autojoin.on){for(var h in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(h)){continue}a.join(a.autojoin.channel[h])}}};if(a.fresh){b()}else{var f=false;for(key in a.channelo){if(a.channelo[key].namespace[0]!="~"){a.join(key);f=true}}if(!f){b()}}}else{a.close(d)}if(a.fresh){a.fresh=false}};wsc.Flow.prototype.join=function(d,a){if(d.pkt.arg["e"]=="ok"){var b=a.deform_ns(d.pkt.param);a.create_ns(b,a.hidden.contains(d.pkt.param))}else{}};wsc.Flow.prototype.part=function(d,a){var b=a.deform_ns(d.ns);var f=a.channel(b);if(d.e=="ok"){info="";if(d.r.length>0){info="["+d.r+"]"}else{a.remove_ns(d.ns)}msg="You have left "+b;f.server_message(msg,info);if(a.channels()==0){switch(d.r){case"bad data":case"bad msg":case"msg too big":break;default:if(d.r.indexOf("killed:")<0){return }break}this.message(a,{data:"disconnect\ne="+e.r+"\n"})}}else{}};wsc.Flow.prototype.kicked=function(b,a){if(b.r.toLowerCase().indexOf("autokicked")>-1){return}a.join(b.ns)};wsc.Flow.prototype.property=function(b,a){chan=a.channel(b.pkt.param);if(!chan){return}chan.property(b)};wsc.Flow.prototype.recv_joinpart=function(b,a){c=a.channel(b.ns);if(b.name=="recv_join"){c.recv_join(b)}else{c.recv_part(b)}};wsc.Flow.prototype.recv_join=wsc.Flow.prototype.recv_joinpart;wsc.Flow.prototype.recv_part=wsc.Flow.prototype.recv_joinpart;wsc.Flow.prototype.recv_msg=function(b,a){a.channel(b.ns).recv_msg(b)};wsc.Flow.prototype.recv_action=wsc.Flow.prototype.recv_msg;wsc.Flow.prototype.recv_npmsg=wsc.Flow.prototype.recv_msg;wsc.Flow.prototype.recv_privchg=function(b,a){a.channel(b.ns).recv_privchg(b)};wsc.Flow.prototype.recv_kicked=function(b,a){a.channel(b.ns).recv_kicked(b)};wsc.defaults.Extension=function(d){var a={};a.away={on:false,reason:"",last:{},since:0,store:d.storage.folder("away"),format:{setaway:"/me is away: {reason}",setback:"/me is back",away:"{from}: I am away, reason: {reason}"}}; -var m=function(){d.bind("cmd.connect",b.connection);d.bind("cmd.set",b.setter);d.bind("cmd.join",b.join);d.bind("cmd.chat",b.pjoin);d.bind("cmd.part",b.part);d.bind("cmd.say",b.say);d.bind("cmd.npmsg",b.npmsg);d.bind("cmd.me",b.action);d.bind("cmd.promote",b.chgpriv);d.bind("cmd.demote",b.chgpriv);d.bind("cmd.ban",b.ban);d.bind("cmd.unban",b.ban);d.bind("cmd.kick",b.killk);d.bind("cmd.whois",b.whois);d.bind("cmd.title",b.title);d.bind("cmd.topic",b.title);d.bind("cmd.admin",b.admin);d.bind("cmd.disconnect",b.connection);d.bind("cmd.kill",b.killk);d.bind("cmd.raw",b.raw);d.bind("cmd.clear",b.clear);d.bind("cmd.clearall",b.clearall);d.bind("cmd.close",b.close);d.bind("pkt.property",l);d.bind("pkt.recv_admin_show",f);d.bind("pkt.recv_admin_showverbose",f);d.bind("pkt.get",k);d.bind("cmd.gettitle",b.gett);d.bind("cmd.gettopic",b.gett);d.bind("cmd.theme",b.theme);d.ui.on("settings.open",h);d.ui.on("settings.open.ran",g);d.ui.on("settings.save.ui",j);d.ui.on("settings.save",function(){d.config_save() -})};var j=function(o,n){d.settings.ui.theme=o.theme;d.settings.ui.clock=o.clock;d.settings.ui.tabclose=o.tabclose};var h=function(p,o){var n=p.settings.page("Main");var q={};q.username=d.settings.username;q.pk=d.settings.pk;q.devel=d.settings.developer;n.item("Form",{ref:"login",title:"Login",text:"Here you can change the username and token used to log into the chat server.",fields:[["Textfield",{ref:"username",label:"Username","default":q.username}],["Textfield",{ref:"token",label:"Token","default":q.pk}]],event:{save:function(r){d.settings.username=r.data.username;d.settings.pk=r.data.token}}},true);n.item("Form",{ref:"developer",title:"Developer Mode",text:"Turn developer mode on or off.\n\nDeveloper mode will expose any hidden channel tabs, amongst other things. Keep this turned off unless you're working on implementing something.",fields:[["Checkbox",{ref:"enabled",items:[{value:"on",title:"On",selected:q.devel}]}]],event:{change:function(r){d.settings.developer=(r.data.enabled.indexOf("on")!=-1); -d.ui.developer(d.settings.developer)},save:function(r){q.devel=d.settings.developer},close:function(r){d.settings.developer=q.devel;d.ui.developer(d.settings.developer)}}});n.item("Text",{ref:"intro",title:"Main",text:"Use this window to view and change your settings.\n\nCheck the different pages to see what settings can be changed.",},true);n.item("Text",{ref:"debug",wclass:"faint",title:"Debug Information",text:"Chat Agent: "+d.settings.agent+"\n\nUser Agent: "+navigator.userAgent+""})};var g=function(p,o){var n=p.settings.page("About",true);n.item("Text",{ref:"about-wsc",title:"Wsc",text:'Currently using wsc version '+wsc.VERSION+" "+wsc.STATE+'.\n\nWsc works using HTML5, javascript, and CSS3. WebSocket is used for the connection where possible. The source code for this client is pretty huge.\n\nWsc was created by ~photofroggy'}) -};var b={};b.theme=function(o,n){n.ui.theme(o.args.split(" ").shift())};b.setter=function(p){var o=p.args.split(" ");var n=o.shift().toLowerCase();var o=o.join(" ");if(o.length==0){d.cchannel.serverMessage("Could not set "+n,"No data supplied");return}if(!(n in d.settings)){d.cchannel.serverMessage('Unknown setting "'+n+'"');return}d.settings[n]=o;d.cchannel.serverMessage("Changed "+n+" setting","value: "+o)};b.connection=function(n){d[n.cmd]()};b.join=function(n){var o=n.args.split(" ");var o=o.toString()==""?[]:o;if(n.ns!=n.target){o.unshift(n.target)}if(o.toString()==""){return}for(index in o){d.join(o[index])}};b.pjoin=function(n){var o=n.args.split(" ");var o=o.toString()==""?[]:o;if(n.ns!=n.target){o.unshift(n.target)}if(o.toString()==""){return}for(index in o){d.join("@"+o[index])}};b.part=function(n){var o=n.args.split(" ");if(n.ns!=n.target){o.unshift(n.target)}if(o.toString()==""){d.part(n.ns);return}for(index in o){d.part(o[index])}};b.title=function(n){d.set(n.target,n.cmd,n.args) -};b.chgpriv=function(o){var n=o.args.split(" ");d[o.cmd.toLowerCase()](o.target,n[0],n[1])};b.ban=function(r,n){var p=r.args.split(" ");var o=p.shift();var q=r.cmd;if(q=="ban"&&p.length>0){n.kick(r.target,o,p.join(" "))}n[q](r.target,o)};b.action=function(n){d.action(n.target,n.args)};b.raw=function(n){d.send(n.args.replace(/\\n/gm,"\n"))};b.killk=function(q,n){var s=q.args.split(" ");var o=s.shift();var p=s.length>0?s.join(" "):null;if(q.cmd=="kick"){n.kick(q.target,o,p)}else{n.kill(o,p)}};b.say=function(n){if(d.channel(n.target).monitor){return}d.say(n.target,n.args)};b.npmsg=function(n){d.npmsg(n.target,n.args)};b.clear=function(p,n){if(p.args.length>0){var q=p.args.split(" ");for(var o in q){if(!q.hasOwnProperty(o)){continue}n.ui.channel(p.target).clear_user(q[o])}}else{n.ui.channel(p.target).clear()}};b.clearall=function(o,n){var q=null;if(o.args.length>0){var p=o.args.split(" ");q=function(s,t){for(var r in p){if(!p.hasOwnProperty(r)){continue}t.clear_user(p[r])}}}else{q=function(r,s){s.clear() -}}n.ui.chatbook.each(q,true)};b.close=function(n){d.part(n.target);d.remove_ns(n.target)};b.whois=function(o,n){n.whois(o.args.split(" ")[0])};b.admin=function(o,n){n.admin(o.target,o.args)};b.disconnect=function(o,n){n.disconnect()};b.gett=function(o,n){var p=o.cmd.indexOf("title")>-1?"title":"topic";n.ui.control.set_text("/"+p+" "+n.channel(o.target).info[p].content)};var l=function(q,n){if(q.p!="info"){return}var o=q.pkt.sub;var r=o.shift().arg;r.username=q.sns.substr(1);r.connections=[];var p={};while(o.length>0){p=o.shift().arg;p.channels=[];while(o.length>0){if(o[0].cmd!="ns"){break}p.channels.unshift(n.deform_ns(o.shift().param))}r.connections.push(p)}n.ui.chatbook.current.log_whois(r)};var k=function(o,n){if(o.ns.indexOf("login:")!=0){return}var p=o.sns.substr(1);n.ui.pager.notice({ref:"whois-"+p,heading:"Whois Failed",content:"Whois failed for "+p+".\nNo such user online."},false,5000)};var f=function(r,o){var u=o.channel(r.ns);var n=r.info.split("\n");var t="";var s=[];var p=""; -for(var q in n){if(!n.hasOwnProperty(q)){continue}t=n[q].split(" ");if(r.p=="privclass"){s.push([t.shift(),t.shift().split("=")[1],t.join(" ")])}else{if(r.p=="users"){p=t.shift().split(":",1)[0];s.push([p,u.get_privclass_order(p),t.join(" ")])}}}o.ui.chatbook.current.log_pc(r.p=="privclass",s)};m();wsc.defaults.Extension.Ignore(d);wsc.defaults.Extension.Away(d);wsc.defaults.Extension.Autojoin(d)};wsc.defaults.Extension.Autojoin=function(a){var d=a.autojoin;a.ui.nav.add_button({icon:"chat",label:"",title:"Join your autojoin channels",href:"#autojoin-do",handler:function(){for(var g in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(g)){continue}a.join(a.autojoin.channel[g])}}});var f=function(){a.bind("cmd.autojoin",b);a.ui.on("settings.open",d.page)};d.page=function(k,m){var l=k.settings.page("Autojoin");var j="
              ";var n={};n.ajon=a.autojoin.on;n.chan=a.autojoin.channel;if(a.autojoin.channel.length==0){j+="
            • No autojoin channels set
            "}else{for(var h in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(h)){continue -}j+="
          • "+a.autojoin.channel[h]+"
          • "}j+=""}l.item("Checkbox",{ref:"eaj",title:"Autojoin",text:"Turn on autojoin to automatically join selected channels when you connect to the chat server.",items:[{value:"yes",title:"On",selected:n.ajon}],event:{change:function(o){if(o.target.value=="yes"){a.autojoin.on=o.target.checked}},save:function(o){n.ajon=a.autojoin.on;a.config_save()},close:function(o){a.autojoin.on=n.ajon}}});var g=l.item("Items",{ref:"channelss",title:"Channels",text:"Add any channels you want to join automatically when you connect to the chat server.",items:a.autojoin.channel,prompt:{title:"Add Channel",label:"Channel:",},event:{up:function(o){var p=o.args.swap;a.autojoin.channel[p["this"].index]=p.that.item;a.autojoin.channel[p.that.index]=p["this"].item;g.options.items=a.autojoin.channel},down:function(o){var p=o.args.swap;a.autojoin.channel[p["this"].index]=p.that.item;a.autojoin.channel[p.that.index]=p["this"].item;g.options.items=a.autojoin.channel -},add:function(q){var p=a.deform_ns(q.args.item).toLowerCase();var o=a.autojoin.channel.indexOf(p);if(o!=-1){return}a.autojoin.channel.push(p);g.options.items=a.autojoin.channel},remove:function(o){a.autojoin.channel.splice(o.args.index,1);g.options.items=a.autojoin.channel},save:function(o){n.chan=a.autojoin.channel;a.config_save()},close:function(o){a.config_load()}}})};var b=function(n){var h=n.args.split(" ");if(!h){return}var l=h.shift().toLowerCase();var g=function(p){};var k=false;var o=a.channel(n.ns);switch(l){case"add":g=function(p){if(a.autojoin.channel.indexOf(p)==-1){k=true;a.autojoin.channel.push(p);o.server_message("Added "+p+" to your autojoin.")}else{o.server_message("Already have "+p+" on your autojoin.")}};break;case"rem":case"remove":g=function(q){var p=a.autojoin.channel.indexOf(q);if(p!=-1){k=true;a.autojoin.channel.splice(p,1);o.server_message("Removed "+q+" from your autojoin.")}else{o.server_message(q+" is not on your autojoin list.")}};break;case"on":o.server_message("Autojoin on."); -if(!a.autojoin.on){k=true;a.autojoin.on=true}break;case"off":o.server_message("Autojoin off.");if(a.autojoin.on){k=true;a.autojoin.on=false}break}var m="";for(var j in h){if(!h.hasOwnProperty(j)){continue}m=a.deform_ns(h[j]).toLowerCase();g(m)}if(k){a.config_save()}};f()};wsc.defaults.Extension.Away=function(b){var f=b.storage.folder("away");var d={on:false,reason:"",last:{},since:0,interval:60000,format:{setaway:"/me is away: {reason}",setback:"/me is back",away:"{user}: I've been away for {timesince}. Reason: {reason}"}};b.away=d;var l=function(){j();g();b.bind("cmd.setaway",a);b.bind("cmd.setback",k);b.ui.on("tabbed",h);b.ui.on("settings.open",d.page)};d.page=function(n,p){var m=function(s){s=replaceAll(s,"<","<");s=replaceAll(s,">",">");s=replaceAll(s,'"',""");return s};var q=function(s){s=replaceAll(s,"<","<");s=replaceAll(s,">",">");s=replaceAll(s,""",'"');return s};var o=n.settings.page("Away");var r={};r.away=d.format.away;r.sa=d.format.setaway;r.sb=d.format.setback; -r.intr=d.interval;o.item("Text",{ref:"intro",title:"Away Messages",text:"Use away messages when you are away from the chats.\n\n You can set yourself away using the /setaway [reason] command. When you get back, use /setback. While you are away, the client will automatically respond when people try to talk to you, telling them you're away.",});o.item("Form",{ref:"msgs",title:"Messages",text:"Here you can set the messages displayed when you set yourself away or back. You can also change the away message format.",hint:"{user}
            This is replaced with the username of the person trying to talk to you\n\n{reason}
            This is replaced by your reason for being away.\n\n{timesince}
            Use this to show how long you have been away for.",fields:[["Textfield",{ref:"away",label:"Away","default":m(r.away)}],["Textfield",{ref:"setaway",label:"Setaway","default":m(r.sa)}],["Textfield",{ref:"setback",label:"Setback","default":m(r.sb)}]],event:{save:function(s){d.format.away=q(s.data.away); -d.format.setaway=q(s.data.setaway);d.format.setback=q(s.data.setback);g()}}});o.item("Form",{ref:"interval",title:"Message Interval",text:"Here you can set the amount of time to wait before displaying another away message. The interval is in seconds.",fields:[["Textfield",{ref:"interval",label:"Interval","default":(r.intr/1000).toString()}]],event:{save:function(s){d.interval=parseInt(s.data.interval)*1000;g()}}})};var a=function(o,m){d.on=true;d.last={};d.since=new Date();d.reason=o.args;var p=m.say;var n=replaceAll(d.format.setaway,"{reason}",d.reason||"[silent away]");if(n.indexOf("/me ")==0){n=n.substr(4);p=m.action}m.each_channel(function(q){p.call(m,q,n)});m.ui.control.add_state({ref:"away",label:"Away, reason: "+(d.reason||"[silent away]")+""})};var k=function(o,m){if(!d.on){return}d.on=false;var p=m.say;var n=d.format.setback;if(n.indexOf("/me ")==0){n=n.substr(4);p=m.action}m.each_channel(function(q){p.call(m,q,n)});m.ui.control.rem_state("away")};var h=function(p){if(!d.on){return -}if(d.reason.length==0){return}if(p.user==b.settings.username){return}if(b.exclude.contains(p.ns)){return}var n=new Date();var o=p.sns.toLowerCase();if(o in d.last){if((n-d.last[o])<=d.interval){return}}var m=timeLengthString((n-d.since)/1000);var q=replaceAll(d.format.away,"{user}",p.user);q=replaceAll(q,"{timesince}",m);b.say(p.ns,replaceAll(q,"{reason}",d.reason));d.last[o]=n};var j=function(){d.format.setaway=f.get("setaway","/me is away: {reason}");d.format.setback=f.get("setback","/me is back");d.format.away=f.get("away","{user}: I've been away for {timesince}. Reason: {reason}");d.interval=parseInt(f.get("interval",60000))};var g=function(){f.set("interval",d.interval);f.set("setaway",d.format.setaway);f.set("setback",d.format.setback);f.set("away",d.format.away)};l()};wsc.defaults.Extension.Ignore=function(d){var f={};var g=d.storage.folder("ignore");var a=g.folder("ignored");var l=function(){k();j();d.bind("cmd.ignore",b);d.bind("cmd.unignore",h);d.ui.on("settings.open",f.page) -};f.page=function(n,p){var o=n.settings.page("Ignores");var q={};q.im=f.ignore;q.uim=f.unignore;q.usr=d.ui.umuted;o.item("Text",{ref:"intro",title:"Ignores",text:'Use ignore to ignore people.\n\n You can "ignore" other users of the chat server using the\n /ignore command. Ignoring a user hides their messages from you in the channel log.',});o.item("Form",{ref:"msgs",title:"Messages",text:"Here you can set the messages displayed when you ignore or unignore a user.\n\nThe text {user} is replaced with the name of the user your are ignoring or unignoring.",fields:[["Textfield",{ref:"ignore",label:"Ignore","default":q.im}],["Textfield",{ref:"unignore",label:"Unignore","default":q.uim}]],event:{save:function(r){f.ignore=r.data.ignore;f.unignore=r.data.unignore;j()}}});var m=o.item("Items",{ref:"ignoreds",title:"Users",text:"This is the list of users that you have silenced.\n\nUse the commands /ignore and /unignore to edit the list.",items:q.usr,prompt:{title:"Add User",label:"User:",},event:{up:function(r){var s=r.args.swap; -d.ui.umuted[s["this"].index]=s.that.item;d.ui.umuted[s.that.index]=s["this"].item;m.options.items=d.ui.umuted},down:function(r){var s=r.args.swap;d.ui.umuted[s["this"].index]=s.that.item;d.ui.umuted[s.that.index]=s["this"].item;m.options.items=d.ui.umuted},add:function(r){d.mute_user(r.args.item);m.options.items=d.ui.umuted},remove:function(r){d.unmute_user(r.args.item);m.options.items=d.ui.umuted},save:function(r){q.usr=d.ui.umuted;j()},close:function(r){k()}}})};var b=function(p){var r=p.args.split(" ");var m="";var q="";var o=false;for(var n in r){if(!r.hasOwnProperty(n)){continue}m=r[n];tmod=d.mute_user(m);if(!tmod){continue}o=tmod;q=replaceAll(f.ignore,"{user}",m);if(q.indexOf("/me ")==0){q=q.substr(4);d.action(p.target,q)}else{d.say(p.target,q)}}if(o){j()}};var h=function(q){var t=q.args.split(" ");var n="";var s="";var m=-1;var p=false;var r=false;for(var o in t){if(!t.hasOwnProperty(o)){continue}n=t[o];r=d.unmute_user(n);if(!r){continue}p=r;s=replaceAll(f.unignore,"{user}",n);if(s.indexOf("/me ")==0){s=s.substr(4); -d.action(q.target,s)}else{d.say(q.target,s)}}if(p){j()}};var k=function(){f.ignore=g.get("ignore","/me is ignoring {user} now");f.unignore=g.get("unignore","/me is not ignoring {user} anymore");f.count=parseInt(g.get("count",0));var n=null;for(var m in d.ui.umuted){if(!d.ui.umuted.hasOwnProperty(m)){continue}d.unmute_user(d.ui.umuted[m])}d.ui.umuted=[];if(f.count>0){n=null;for(var m=0;m
            ');this.protocol=new Chatterbox.Protocol();this.mw=new wsc.Middleware();this.view=b.find(".wsc");this.mns=this.format_ns(this.settings.monitor[0]);this.lun=this.settings.username.toLowerCase();this.monitoro=null;this.swidth=(function(){if($.browser.msie){var l=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body"),k=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body");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})();if(window.mozRTCPeerConnection){Chatterbox._gum=function(k,l,j){return navigator.mozGetUserMedia(k,l,j)}}if(window.webkitRTCPeerConnection){Chatterbox._gum=function(k,l,j){return navigator.webkitGetUserMedia(k,l,j)}}if(window.RTCPeerConnection&&!window.mozRTCPeerConnection){Chatterbox._gum=function(k,l,j){return navigator.getUserMedia(k,l,j)}}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(b){var a=b[0];if(a=="#"||a=="@"||a=="~"||a=="+"){return b}if(b.indexOf("chat:")==0){return"#"+b.slice(5)}if(b.indexOf("server:")==0){return"~"+b.slice(7)}if(b.indexOf("feed:")==0){return"#"+b.slice(5)}if(b.indexOf("login:")==0){return"@"+b.slice(6)}if(b.indexOf("pchat:")==0){var d=b.split(":");d.shift();for(i in d){name=d[i];if(name.toLowerCase()!=this.lun){return"@"+name}}}return"#"+b};Chatterbox.UI.prototype.format_ns=function(a){var d=a.slice(1);switch(a[0]){case"@":var b=[d,this.lun];b.sort(caseInsensitiveSort);b.unshift("pchat");a=b.join(":");break;case"~":a="server:"+d;break;case"+":a="feed:"+d;break;case"#":a="chat:"+d;break;default:if(a.indexOf("chat:")==0||a.indexOf("pchat:")==0||a.indexOf("server:")==0||a.indexOf("feed:")==0){break}a="chat:"+a;break}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.get_user_media=function(b,d,a){Chatterbox._gum(b,d,a)};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.add("click",this.sound.bank.m.find("audio.click")[0]);var h=this.sound;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)});this.client.bind("ns.user.list",function(k){g.channel(k.ns).set_user_list(k.users)});this.client.middle("ns.user.privchg",function(l,k){g.channel(l.ns).privchg(l,k)});this.client.bind("ns.user.remove",function(l,k){g.channel(l.ns).remove_one_user(l.user)});this.client.bind("ns.user.registered",function(k){g.channel(k.ns).register_user(k.user)})};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=this.protocol.log(b);if(f){if(this.settings.developer){console.log(">>>",b.sns,"|",f.text())}if(b.hasOwnProperty("s")&&b.s=="0"){this.chatbook.handle(b,a);return}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.BaseTab=function(f,b,d,a){this.manager=f;this.hidden=d;this.monitor=(a==undefined?false:a);this.built=false;this.raw=b;this.selector="t-"+(b||"chan").toLowerCase();this.namespace=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]}};if(!f){return}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)};Chatterbox.BaseTab.prototype.build=function(b){if(!this.manager){return}if(this.built){return}var a=this.selector;var f=this.namespace;var d=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(b||Chatterbox.render("basetab",{selector:a,ns:f}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");var g=this;this.el.t.l.click(function(){g.manager.toggle_channel(d);return false});this.el.t.c.click(function(h){g.manager.trigger("tab.close.clicked",{ns:g.raw,chan:g,e:h});return false});if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")}this.built=true};Chatterbox.BaseTab.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.BaseTab.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.BaseTab.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.BaseTab.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.BaseTab.prototype.resize=function(b,a){this.el.m.css({height:a||this.manager.chatbook.height(),width:(b||this.manager.chatbook.width())-10})};Chatterbox.BaseTab.prototype.loop=function(){};Chatterbox.Channel=function(f,b,d,a){Chatterbox.BaseTab.call(this,f,b,d,a);this.resized=function(){};this.ulbuf=0};Chatterbox.Channel.prototype=new Chatterbox.BaseTab;Chatterbox.Channel.prototype.constructor=Chatterbox.Channel;Chatterbox.Channel.prototype.build=function(){if(!this.manager){return}if(this.built){return}var a=this.selector;var d=this.namespace;var b=this.raw;Chatterbox.BaseTab.prototype.build.call(this,Chatterbox.render("channel",{selector:a,ns:d}));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.setup_header("title");this.setup_header("topic");if(this.namespace[0]=="@"){this.build_user_list({100:"Room Members"},[100])}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.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){Chatterbox.BaseTab.prototype.resize.call(this,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;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.ulbuf});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) -}this.resized()};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:'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)])}if(k.agent){o.push(["agent",k.agent])}if(k.debug){o.push(["debug",k.debug])}o.push(["chatrooms",k.channels.join(" ")]);g.conns.push(o)}this.manager.trigger("log_whois.before",g);var b="";for(var m in g.conns){var j=g.conns[m];var q='

            connection '+((parseInt(m)+1).toString())+":

            ";q+="
              ";for(var p in j){q+="
            • "+j[p][0]+": "+j[p][1]+"
            • "}q+="
            ";b+=q+"
            "}var h="";for(var m in g.info){h+="
          • "+g.info[m]+"
          • "}var n=this.log_info("whois-"+l.username,Chatterbox.render("whoiswrap",{avatar:g.avatar,info:Chatterbox.render("whoisinfo",{username:g.username,info:h,connections:b})})); -var f=n.find("div.avatar");var d=n.find("div.info");d.width(n.find(".whoiswrap").width()-100);f.height(n.height()-10);this.scroll()};Chatterbox.Channel.prototype.log_pc=function(f,g){contents="";for(var d in g){if(!g.hasOwnProperty(d)){continue}var b=g[d];var a="";if(b[2].length==0){a=""+(f?"default privileges":"no members")+""}else{a=b[2]}contents+=String.format("
          • {0} {1}:
            • {2}
          • ",[b[1],b[0],a])}var h={title:"Privilege class "+(f?"permissions":"members"),info:"
              "+contents+"
            "};this.log_info("pc-"+(f?"permissions":"members"),Chatterbox.render("pcinfo",h))};Chatterbox.Channel.prototype.set_header=function(a,f,h,d){a=a.toLowerCase();var b=this.el.m.find("header."+a+" a[href=#edit]");if(this.el.h[a].html()!=""){if(f.html().length!=0){this.server_message(a+" set by "+h)}}this.el.h[a].html(f.html());var g=this;setTimeout(function(){if(f.text().length>0){g.el.h[a].css({display:"block"});var j=(g.el.h[a].outerHeight(true)-5)*(-1); -b.css("top",j)}else{g.el.h[a].css({display:"none"})}g.resize()},100)};Chatterbox.Channel.prototype.get_header=function(a){return this.el.h[a.toLowerCase()]};Chatterbox.Channel.prototype.build_user_list=function(f,a){var h=this.el.u;var d="";var g=null;h.html("");for(var b in a){var d=f[a[b]];h.append('

            '+d+"

              ");g=h.find(".pc#"+d);g.css("display","none")}};Chatterbox.Channel.prototype.reveal_user_list=function(){var g=this.el.u;var d=0;var b=0;var a=null;g.find("div.pc").each(function(h,j){a=g.find(this);b=a.find("ul li").length;d+=b;a.css("display",(b==0?"none":"block"))});g.css("display",(d==0?"none":"block"));var f=this;setTimeout(function(){f.resize()},100)};Chatterbox.Channel.prototype.set_user_list=function(f){if(Object.size(f)==0){return}var d=this.el.u;var a=null;for(var b in f){a=f[b];this.set_user(a,true)}this.reveal_user_list()};Chatterbox.Channel.prototype.set_user=function(g,d){var j=this.el.u.find("div.pc#"+replaceAll(g.pc," ","-")); -var a=j.find("ul");var b=g.conn==1?"":"["+g.conn+"]";var h='
            • '+g.symbol+""+g.name+""+b+"
            • ";if(a.find("a#"+g.name).length==1){return}if(a.find("li").length==0){a.append(h)}else{var k=g.name.toLowerCase();var m=null;var f=false;a.find("li a").each(function(){if(f){return}m=a.find(this);if(k"}h.window.append(Chatterbox.render("userinfo",{username:b.name,avatar:b.avatar,link:b.link,info:j}));f=h.window.find(".userinfo#"+b.name);h.window.find("div.userinfo:not('#"+b.name+"')").remove();var l=g.offset();f.css({top:(l.top-g.height())+10,left:(l.left-(f.width()))-6});f.find(".info").height(f.height());f.hover(function(){f.data("hover",1)},function(m){f.data("hover",0);h.unhover_user(f,m)});f.data("hover",0)};var d=function(j){g.data("hover",0); -h.unhover_user(f,j)};g.off("mouseenter",a);g.off("mouseleave",d);g.on("mouseenter",a);g.on("mouseleave",d)};Chatterbox.Channel.prototype.unhover_user=function(f,d){var g=f.offset();var b=f.outerHeight(true)+g.top;var j=f.outerWidth(true)+g.left;var a=d.pageX;var h=d.pageY;if(a>g.left&&ag.top&&hg.left&&h>g.top&&h<(g.top+15)){return}f.remove()};Chatterbox.Channel.prototype.mute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"none"});this.scroll()};Chatterbox.Channel.prototype.unmute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"list-item"});this.scroll()};Chatterbox.Channel.prototype.clear_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).remove();this.scroll()};Chatterbox.Channel.prototype.pkt_join=function(b,a){if(b.e!="ok"){return}this.set_header("title",(new wsc.MessageString("")),"","");this.set_header("topic",(new wsc.MessageString("")),"","") -};Chatterbox.Channel.prototype.pkt_recv_msg=function(b,a){var d=this;this.manager.cascade("chan.recv_msg",function(h,f){var g=d.manager.client.settings.username.toLowerCase();if(g==h.user.toLowerCase()){return}var k=h.message.toLowerCase();var j=k.indexOf(g)!=-1;if(!j&&h.sns[0]!="@"){return}if(j){d.highlight()}else{d.highlight(false)}d.manager.trigger("tabbed",h)},b)};Chatterbox.Channel.prototype.pkt_recv_action=Chatterbox.Channel.prototype.pkt_recv_msg;Chatterbox.Channel.prototype.pkt_property=function(b,a){var f=b.pkt.arg.p;var d=a.channel(this.namespace);switch(f){case"title":case"topic":this.set_header(f,b.value||(new wsc.MessageString("")),b.by,b.ts);break;case"privclasses":this.build_user_list(d.info.pc,d.info.pc_order.slice(0));break;case"members":break;default:break}};Chatterbox.Chatbook=function(a){this.manager=a;this.view=this.manager.view.find("div.chatbook");this.chan={};this.trail=[];this.current=null;this.manager.on("tab.close.clicked",function(b,d){d.chatbook.remove_channel(b.ns) -})};Chatterbox.Chatbook.prototype.height=function(){return this.view.height()};Chatterbox.Chatbook.prototype.width=function(){return this.view.width()};Chatterbox.Chatbook.prototype.resize=function(b){b=b||600;var d=this.view.innerWidth();for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}var f=this.chan[a];f.resize(d,b)}};Chatterbox.Chatbook.prototype.loop=function(){for(select in this.chan){this.chan[select].loop()}};Chatterbox.Chatbook.prototype.channel=function(a,b){a=this.manager.format_ns(a).toLowerCase();if(!this.chan[a]&&b){this.chan[a]=b}return this.chan[a]};Chatterbox.Chatbook.prototype.channels=function(){chans=-1;for(ns in this.chan){if(this.chan[ns].hidden){continue}chans++}return chans};Chatterbox.Chatbook.prototype.create_channel=function(b,d,a){var f=this.channel(b,this.channel_object(b,d,a));f.build();if(this.trail.indexOf(f.namespace)==-1){this.trail.push(f.namespace)}if(!f.visible){this.toggle_channel(b)}this.manager.resize();return f};Chatterbox.Chatbook.prototype.channel_object=function(a,b){return new Chatterbox.Channel(this.manager,a,b) -};Chatterbox.Chatbook.prototype.toggle_channel=function(a){var d=this.channel(a);var b=d;if(!d){return}if(d.hidden){if(this.current&&this.current==d){return}if(!this.manager.settings.developer){d.hide();return}}if(this.current){if(this.current==d){return}this.current.hide();b=this.current}else{if(this.manager.monitoro!==null){this.manager.monitoro.hide()}}d.show();this.manager.control.focus();this.current=d;this.manager.resize();this.manager.control.cache_input(b,d);this.manager.trigger("channel.selected",{ns:d.raw,chan:d,prev:b});this.manager.client.select_ns(d.raw)};Chatterbox.Chatbook.prototype.remove_channel=function(a){var b=this.channel(a);if(!b){return}if(this.channels()==0&&!b.hidden){return}b.remove();delete this.chan[b.raw.toLowerCase()];if(this.current==b){this.channel_left()}var d=this.trail.indexOf(b.namespace);this.trail.splice(d,1)};Chatterbox.Chatbook.prototype.channel_left=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a<0){return}var f=null;while(true){try{f=this.channel(this.trail[--a]) -}catch(d){a=this.trail.length-1;f=this.channel(this.trail[a])}if(!f.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(f.namespace)};Chatterbox.Chatbook.prototype.channel_right=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a==-1){return}var f=null;while(true){try{f=this.channel(this.trail[++a])}catch(d){a=0;f=this.channel(this.trail[0])}if(!f.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(f.namespace)};Chatterbox.Chatbook.prototype.each=function(d){var b=null;for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}b=this.chan[a];if(d(b.namespace,b)===false){break}}};Chatterbox.Chatbook.prototype.server_message=function(b,a){for(ns in this.chan){this.chan[ns].server_message(b,a)}};Chatterbox.Chatbook.prototype.log_item=function(a){for(ns in this.chan){this.chan[ns].log_item(a)}};Chatterbox.Chatbook.prototype.log=function(a){for(ns in this.chan){this.chan[ns].log(a)}};Chatterbox.Chatbook.prototype.log_message=function(d,b){try{if(!d.global){if(!d.monitor){this.channel(b.ns).log_item(b) -}else{this.manager.monitoro.log_item(b)}}else{this.log_item(b)}}catch(a){try{this.ui.monitoro.server_message("Failed to log for",b.sns,b.html)}catch(a){console.log(">> Failed to log message for",b.sns,"::");console.log(">>",b.html)}}};Chatterbox.Chatbook.prototype.retime=function(){for(ns in this.chan){this.chan[ns].retime()}};Chatterbox.Chatbook.prototype.developer=function(){this.each(function(a,b){b.developer()})};Chatterbox.Chatbook.prototype.handle=function(f,b){var g=this.manager;var h=this.channel(f.ns);if(!h){return}var a="pkt_"+f.name;try{h[a](f,b)}catch(d){}};Chatterbox.Control=function(b){this.manager=b;this.manager.view.append(Chatterbox.template.control);this.view=this.manager.view.find("div.chatcontrol");this.ml=false;this.history={};this.tab={hit:false,cache:"",matched:[],index:-1,type:0,prefix:["","/",""],};this.el={form:this.view.find("form.msg"),i:{s:this.view.find("form.msg input.msg"),m:this.view.find("form.msg textarea.msg"),c:null,t:this.view.find("ul.buttons a[href~=#multiline].button")},brow:{m:this.view.find("div.brow"),b:this.view.find("div.brow ul.buttons"),s:this.view.find("div.brow ul.states")}}; -this.el.i.c=this.el.i.s;var a=this;this.el.i.t.click(function(d){a.multiline(!a.multiline());return false});this.el.i.s.keydown(function(d){return a.keypress(d)});this.el.i.m.keydown(function(d){return a.keypress(d)});this.el.form.submit(function(d){return a.submit(d)});this.add_button({label:"b",icon:false,href:"#bold",title:"Bold text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"i",icon:false,href:"#italic",title:"Italic text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"u",icon:false,href:"#underline",title:"Underline text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sup",icon:false,href:"#sup",title:"Superscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sub",icon:false,href:"#sub",title:"Subscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}})}; -Chatterbox.Control.prototype.surroundtext=function(j,h,b){var g=j.scrollTop;var a=j.value,d=j.selectionStart,f=j.selectionEnd;var k=j.value.substring(d,f);j.value=a.substring(0,d)+h+k+b+a.substring(f);j.selectionStart=d+h.length;j.selectionEnd=d+h.length+k.length;j.scrollTop=g;j.focus()};Chatterbox.Control.prototype.focus=function(){this.el.i.c.focus()};Chatterbox.Control.prototype.resize=function(){w=this.manager.view.width();this.view.css({width:"100%"});this.el.form.css({width:this.manager.view.width()-20});this.el.i.s.css({width:this.manager.view.width()-100});this.el.i.m.css({width:this.manager.view.width()-90})};Chatterbox.Control.prototype.height=function(){var a=this.view.outerHeight();return a};Chatterbox.Control.prototype.multiline=function(a){if(a==undefined||this.ml==a){return this.ml}this.ml=a;var b=(this.ml?"s":"m");a=(this.ml?"m":"s");this.el.i[b].css("display","none");this.el.i[a].css("display","inline-block");this.el.i.c=this.el.i[a];this.manager.resize();return this.ml -};Chatterbox.Control.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.brow.b.append(Chatterbox.render("brow_button",a));var b=this.el.brow.b.find("a[href="+a.href+"].button");b.click(function(d){a.handler();return false});return b};Chatterbox.Control.prototype.add_state=function(a){a=Object.extend({ref:"state",label:"some state"},(a||{}));var b=this.el.brow.s.find("li#"+a.ref);if(b.length==0){this.el.brow.s.append(Chatterbox.render("brow_state",a));return this.el.brow.s.find("li#"+a.ref)}b.html(a.label);return b};Chatterbox.Control.prototype.rem_state=function(a){return this.el.brow.s.find("li#"+a).remove()};Chatterbox.Control.prototype.chomp=function(){var f=this.el.i.c.val();var b=f.lastIndexOf(" ");if(b==-1){this.el.i.c.val("");return f}var a=f.slice(b+1);this.el.i.c.val(f.slice(0,b));if(a.length==0){return this.chomp()}return a -};Chatterbox.Control.prototype.unchomp=function(a){var b=this.el.i.c.val();if(!b){this.el.i.c.val(a)}else{this.el.i.c.val(b+" "+a)}};Chatterbox.Control.prototype.get_text=function(a){if(a==undefined){return this.el.i.c.val()}this.el.i.c.val(a||"");return this.el.i.c.val()};Chatterbox.Control.prototype.set_text=function(a){this.el.i.c.val(a||"")};Chatterbox.Control.prototype.cache_input=function(b,d){var a=this.get_history(b.namespace);if(a.index>-1){return}a.tmp=this.get_text();this.set_text(this.get_history(d.namespace).tmp)};Chatterbox.Control.prototype.get_history=function(a){if(!a){if(!this.manager.chatbook.current){a="~monitor"}}a=a||this.manager.chatbook.current.namespace;if(!this.history[a]){this.history[a]={index:-1,list:[],tmp:""}}return this.history[a]};Chatterbox.Control.prototype.append_history=function(b){if(!b){return}var a=this.get_history();a.list.unshift(b);a.index=-1;if(a.list.length>100){a.list.pop()}};Chatterbox.Control.prototype.scroll_history=function(a){var d=this.get_history(); -var b=this.get_text();if(d.index==-1){if(b){d.tmp=b}else{d.list[d.index]=b}}if(a){if(d.list.length>0&&d.index<(d.list.length-1)){d.index++}}else{if(d.index>-1){d.index--}}this.set_text(d.list[d.index]||d.tmp)};Chatterbox.Control.prototype.tab_item=function(b){if(!this.tab.hit){this.start_tab(b)}this.chomp();this.tab.index++;if(this.tab.index>=this.tab.matched.length){this.tab.index=-1}if(this.tab.index==-1){this.unchomp(this.tab.prefix[this.tab.type]+this.tab.cache);return}var a=this.get_text()==""?(this.tab.type==0?": ":" "):"";this.unchomp(this.tab.prefix[this.tab.type]+this.tab.matched[this.tab.index]+a)};Chatterbox.Control.prototype.start_tab=function(d){this.tab.hit=true;this.tab.index=-1;this.tab.matched=[];this.tab.type=0;var h=this.chomp();this.unchomp(h);if(h[0]=="/"||h[0]=="#"||h[0]=="@"){this.tab.type=h[0]=="/"?1:2;if(h[0]=="/"){h=h.slice(1)}}else{this.tab.type=0}this.tab.cache=h;h=h.toLowerCase();this.tab.matched=[];if(this.tab.type==0){var j=this.manager.client.channel(this.manager.chatbook.current.namespace); -for(var a in j.info.members){if(a.toLowerCase().indexOf(h)==0){this.tab.matched.push(a)}}}else{if(this.tab.type==1){var g="";for(var b in this.manager.client.cmds){g=this.manager.client.cmds[b];if(g.indexOf(h)==0){this.tab.matched.push(g)}}}else{if(this.tab.type==2){var f=this;this.manager.client.each_channel(function(k,l){if(l.namespace.toLowerCase().indexOf(h)==0){f.tab.matched.push(l.namespace)}})}}}};Chatterbox.Control.prototype.end_tab=function(a){this.tab.hit=false;this.tab.matched=[];this.tab.cache="";this.tab.index=-1};Chatterbox.Control.prototype.submit=function(a){var b=this.get_text();this.append_history(b);this.set_text("");this.handle(a,b);return false};Chatterbox.Control.prototype.keypress=function(d){var b=d.which||d.keyCode;var f=this.tab.hit;var a=false;switch(b){case 13:if(!this.multiline()){this.submit(d)}else{if(d.shiftKey){this.submit(d)}else{a=true}}break;case 38:if(!this.multiline()){this.scroll_history(true);break}a=true;break;case 40:if(!this.multiline()){this.scroll_history(false); -break}a=true;break;case 9:if(d.shiftKey){this.manager.channel_right()}else{this.tab_item(d);f=false}break;case 219:if(d.ctrlKey){this.manager.channel_left()}else{a=true}break;case 221:if(d.ctrlKey){this.manager.channel_right()}else{a=true}break;default:a=true;break}if(f){this.end_tab(d)}return a};Chatterbox.Control.prototype.handle=function(b,g){if(g==""){return}if(!this.manager.chatbook.current){return}var k=false;if(g[0]!="/"){k=true}g=(b.shiftKey?"/npmsg ":(g[0]=="/"?"":"/say "))+g;g=g.slice(1);var l=g.split(" ");var d=l.shift().toLowerCase();var j=this.manager.chatbook.current.namespace;var h=j;if(!k&&l[0]){var f=l[0][0];if((f=="#"||f=="@")&&l[0].length>1){h=this.manager.format_ns(l.shift())}}var m=l.join(" ");var a=this.manager.client.trigger("cmd."+d,{name:"cmd",cmd:d,args:m,target:h,ns:j});if(a==0){this.manager.pager.notice({ref:"cmd-fail",heading:"Command failed",content:'"'+d+'" is not a command.'},false,5000)}};Chatterbox.Navigation=function(a){this.manager=a;this.showclose=this.manager.settings.tabclose; -this.settings={};this.settings.open=false;this.el={n:this.manager.view.find("nav.tabs"),tw:this.manager.view.find("nav.tabs div.tabwrap"),t:this.manager.view.find("nav.tabs #chattabs"),b:this.manager.view.find("nav.tabs #tabnav"),l:this.manager.view.find("nav.tabs #tabnav .arrow_left"),r:this.manager.view.find("nav.tabs #tabnav .arrow_right"),s:this.manager.view.find("nav.tabs #tabnav #settings-button"),};if(!this.showclose){if(!this.el.t.hasClass("hc")){this.el.t.addClass("hc")}}var b=this;this.el.s.click(function(g){if(b.settings.open){return false}var d={e:g,settings:new Chatterbox.Settings.Config(b.manager)};b.configure_page(d);b.manager.trigger("settings.open",d);b.manager.trigger("settings.open.ran",d);var f=d.settings.page("About");f.item("text",{ref:"about-chatterbox",wclass:"centered faint",text:'Using Chatterbox version '+Chatterbox.VERSION+" "+Chatterbox.STATE+' by ~photofroggy.'}); -b.settings.window=new Chatterbox.Settings(b.manager,d.settings);b.settings.window.build();b.settings.open=true;return false});this.el.l.click(function(){b.manager.channel_left();return false});this.el.r.click(function(){b.manager.channel_right();return false})};Chatterbox.Navigation.prototype.configure_page=function(b){var f=this.manager;var d=b.settings.page("Main");var g={};g.theme=replaceAll(f.settings.theme,"wsct_","");g.clock=f.clock();g.tc=f.nav.closer();var a=[];for(i in f.settings.themes){name=replaceAll(f.settings.themes[i],"wsct_","");a.push({value:name,title:name,selected:g.theme==name})}d.item("Form",{ref:"ui",title:"UI",hint:"Timestamp
              Choose between a 24 hour clock and a 12 hour clock.\n\nTheme
              Change the look of the client.\n\nClose Buttons
              Turn tab close buttons on/off.",fields:[["Dropdown",{ref:"theme",label:"Theme",items:a}],["Dropdown",{ref:"clock",label:"Timestamp Format",items:[{value:"24",title:"24 hour",selected:g.clock},{value:"12",title:"12 hour",selected:!g.clock}]}],["Checkbox",{ref:"tabclose",label:"Close Buttons",items:[{value:"yes",title:"On",selected:g.tc}]}],],event:{change:function(h){f.clock(h.data.clock=="24"); -f.theme(h.data.theme);f.nav.closer(h.data.tabclose.indexOf("yes")>-1)},save:function(h){g.clock=f.clock();g.theme=replaceAll(f.theme(),"wsct_","");g.tc=f.nav.closer();f.trigger("settings.save.ui",{clock:g.clock,tabclose:g.tc,theme:"wsct_"+g.theme})},close:function(h){f.clock(g.clock);f.theme(g.theme);f.nav.closer(g.tc)}}})};Chatterbox.Navigation.prototype.height=function(){var a=this.el.n.outerHeight();return a};Chatterbox.Navigation.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.b.prepend(Chatterbox.render("nav_button",a));var b=this.el.b.find("a[href="+a.href+"].button");b.click(function(d){a.handler();return false});this.resize();return b};Chatterbox.Navigation.prototype.add_tab=function(a,b){this.el.t.append(Chatterbox.render("tab",{selector:a,ns:b}));return this.el.t.find("#"+a+"-tab")};Chatterbox.Navigation.prototype.resize=function(){this.el.tw.width(this.el.n.width()-this.el.b.outerWidth()-20); -if(this.settings.open){this.settings.window.resize()}};Chatterbox.Navigation.prototype.closer=function(a){if(a==undefined||a==this.showclose){return this.showclose}this.showclose=a;if(this.showclose){if(!this.el.t.hasClass("hc")){return}this.el.t.removeClass("hc");return}if(this.el.t.hasClass("hc")){return}this.el.t.addClass("hc")};Chatterbox.Pager=function(a){this.manager=a;this.lifespan=20000;this.halflife=5000;this.el={m:null,click:null};this.sound={click:function(){},};this.notices=[];this.build()};Chatterbox.Pager.prototype.build=function(){this.el.m=this.manager.view.find("div.pager")};Chatterbox.Pager.prototype.notice=function(f,l,k,d){var h={frame:null,close:null,foot:null,b:{},options:Object.extend({ref:"notice",icon:"",heading:"Some notice",content:"Notice content goes here."},(f||{})),onclose:function(){},ondestroy:function(){}};h.options.ref+="-"+(new Date()).valueOf();h.options.content=h.options.content.split("\n").join("

              ");this.notices.push(h);this.el.m.append(Chatterbox.render("pager.notice",h.options)); -h.frame=this.el.m.find("#"+h.options.ref).last();h.close=h.frame.find("a.close_notice");h.foot=h.frame.find("footer.buttons");var g={};for(var a in h.options.buttons){if(!h.options.buttons.hasOwnProperty(a)){continue}g=h.options.buttons[a];h.foot.append(Chatterbox.render("pager.button",g));h.b[a]=h.foot.find("a#"+g.ref);h.b[a].click(g.click)}var j=this;h.close.click(function(){h.onclose();j.remove_notice(h);return false});if(!l){if(!k){k=j.lifespan}setTimeout(function(){j.remove_notice(h,true)},k)}if(d!==true){this.manager.sound.click()}return h};Chatterbox.Pager.prototype.remove_notice=function(a,d){var b=this;if(this.notices.indexOf(a)==-1){return false}a.frame.fadeTo((d?this.halflife:300),0).slideUp(function(){a.frame.remove();b.notices.splice(b.notices.indexOf(a),1);a.ondestroy()});if(d){a.frame.mouseenter(function(){if(b.notices.indexOf(a)==-1){return}a.frame.stop(true);a.frame.slideDown(function(){a.frame.fadeTo(300,1);a.frame.mouseleave(function(){setTimeout(function(){b.remove_notice(a,true) -},b.lifespan)})})})}};Chatterbox.Pager.prototype.find_notice=function(a){for(var b in this.notices){if(this.notices[b].options.ref==a){return this.notices[b]}}return null};Chatterbox.Popup=function(b,a){this.manager=b;this.pview=(this.manager||{view:{find:function(){}}}).view;this.window=null;this.closeb=null;this.options=Object.extend({ref:"popup",title:"Popup",close:true,content:""},(a||{}))};Chatterbox.Popup.prototype.build=function(){var b=this.options;if(this.options.close){b.title+=''}this.pview.append(Chatterbox.render("popup",b));this.window=this.pview.find(".floater."+b.ref);if(this.options.close){this.closeb=this.window.find("a.close");var a=this;this.closeb.click(function(d){a.close();return false})}};Chatterbox.Popup.prototype.close=function(){this.window.remove()};Chatterbox.Popup.Prompt=function(b,a){a=a||{};a=Object.extend({position:[0,0],ref:"prompt",title:"Input",close:false,label:"","default":"","submit-button":"Submit",event:{submit:function(){},cancel:function(){}}},a); -Chatterbox.Popup.call(this,b,a);this.data=this.options["default"]};Chatterbox.Popup.Prompt.prototype=new Chatterbox.Popup();Chatterbox.Popup.Prompt.prototype.constructor=Chatterbox.Popup.Prompt;Chatterbox.Popup.Prompt.prototype.build=function(){this.options.content=Chatterbox.template.prompt.main;Chatterbox.Popup.prototype.build.call(this);this.window.css({left:this.options.position[0],top:this.options.position[1]});var a=this;this.window.find(".button.close").click(function(){a.options.event.cancel(a);a.close();return false});this.window.find(".button.submit").click(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false});this.window.find("form").submit(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false})};Chatterbox.Popup.ItemPicker=function(b,a){a=a||{};a=Object.extend({position:[100,60],ref:"item-picker",title:"Items",event:{select:function(d){}}},a);Chatterbox.Popup.call(this,b,a);this.pview=this.pview.find(".chatbook"); -this.data=this.options["default"];this.pages=[];this.cpage=null};Chatterbox.Popup.ItemPicker.prototype=new Chatterbox.Popup();Chatterbox.Popup.ItemPicker.prototype.constructor=Chatterbox.Popup.ItemPicker;Chatterbox.Popup.ItemPicker.prototype.build=function(){this.options.content=Chatterbox.render("ip.main",{});Chatterbox.Popup.prototype.build.call(this);this.window.css({right:this.options.position[0],bottom:this.options.position[1]});this.closeb.removeClass("medium");this.pbook=this.window.find("section.pages");this.tabs=this.window.find("section.tabs ul");this.buttons=this.window.find("section.buttons");var d=this;var b=null;for(var a in this.pages){if(!this.pages.hasOwnProperty(a)){continue}b=this.pages[a];b.build();if(a==0){this.select_page(b)}}};Chatterbox.Popup.ItemPicker.prototype.refresh=function(){if(this.cpage==null){return}else{this.cpage.refresh()}};Chatterbox.Popup.ItemPicker.prototype.page=function(b,a){b=b.toLowerCase();for(var d in this.pages){if(!this.pages.hasOwnProperty(d)){continue -}if(this.pages[d].name.toLowerCase()==b){return this.pages[d]}}return(a||null)};Chatterbox.Popup.ItemPicker.prototype.add_page=function(a,b){this.pages.push(new (b||Chatterbox.Popup.ItemPicker.Page)(this,a))};Chatterbox.Popup.ItemPicker.prototype.add_button=function(a){a=Object.extend({href:"#button",title:"Button",label:"Button"},(a||{}));this.buttons.append(Chatterbox.render("ip.button",a));return this.buttons.find("a[href="+a.href+"]")};Chatterbox.Popup.ItemPicker.prototype.select=function(a){this.options.event.select(a)};Chatterbox.Popup.ItemPicker.prototype.select_page=function(a){if(!a){return}if(this.cpage!=null){this.cpage.hide()}this.cpage=a||null;if(this.cpage!=null){this.cpage.show()}};Chatterbox.Popup.ItemPicker.Page=function(b,a){this.picker=b;this.options=Object.extend({ref:"page",href:"#page",label:"Page",title:"page",items:[],content:"No items on this page.",},(a||{}));this.name=this.options.label;this.nrefresh=true};Chatterbox.Popup.ItemPicker.Page.prototype.build=function(){this.picker.pbook.append(Chatterbox.render("ip.page",this.options)); -this.picker.tabs.append(Chatterbox.render("ip.tab",this.options));this.view=this.picker.pbook.find("div.page#"+this.options.ref);this.items=this.view.find("ul");this.tab=this.picker.tabs.find("#"+this.options.ref);this.refresh();var a=this;this.tab.find("a").click(function(){a.picker.select_page(a);return false})};Chatterbox.Popup.ItemPicker.Page.prototype.refresh=function(){var a=this.build_list();if(a.length==0){this.options.content="No items on this page."}else{this.options.content="

                "+a+"
              "}this.view.html(this.options.content);this.items=this.view.find("ul");this.hook_events();this.nrefresh=false};Chatterbox.Popup.ItemPicker.Page.prototype.hook_events=function(){var a=this;this.items.find("li").each(function(b,f){var g=a.view.find(f);var d=g.find(".value").html();g.click(function(){a.picker.select(d)})})};Chatterbox.Popup.ItemPicker.Page.prototype.build_list=function(){var d=[];var f=null;var h,g,b;for(var a in this.options.items){if(!this.options.items.hasOwnProperty(a)){continue -}f=this.options.items[a];g=f.value||f;h=f.title||g;b=f.html||false;d.push('
            • '+(b?g:''+g+"")+"
            • ")}return d.join("")};Chatterbox.Popup.ItemPicker.Page.prototype.show=function(){this.tab.addClass("selected");this.view.css("display","block");this.refresh()};Chatterbox.Popup.ItemPicker.Page.prototype.hide=function(){this.tab.removeClass("selected");this.view.css("display","none")};Chatterbox.Protocol=function(){this.messages={chatserver:{keys:["version"],template:'** Connected to llama {version} *',global:true},dAmnServer:{keys:["version"],template:'** Connected to dAmnServer {version} *',global:true},login:{keys:["username","e","data"],template:'** Login as {username}: "{e}" *',global:true},join:{keys:["ns","e"],template:'** Join {ns}: "{e}" *',monitor:true},part:{keys:["ns","e","r"],template:'** Part {ns}: "{e}" * {r}',monitor:true},property:{keys:["ns","p","by","ts","value"],template:'** Got {p} for {ns} *',monitor:true},recv_msg:{keys:["user","message"],template:'<{user}>{message}'},recv_action:{keys:["s","user","message"],template:'* {user}{message}'},recv_join:{keys:["user","s","info"],template:'** {user} has joined *',},recv_part:{keys:["user","r"],template:'** {user} has left * {r}'},recv_privchg:{keys:["user","s","by","pc"],template:'** {user} has been made a member of {pc} by {by} *'},recv_kicked:{keys:["user","s","by","r"],template:'** {user} has been kicked by {by} * {r}'},recv_admin_create:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been created by {user} * {privs}'},recv_admin_update:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been updated by {user} * {privs}'},recv_admin_rename:{keys:["p","user","prev","pc"],template:'** Privilege class {prev} has been renamed to {pc} by {user} *'},recv_admin_move:{keys:["p","user","prev","pc","affected"],template:'** All members of {prev} have been moved to {pc} by {user} * {affected} affected user(s)'},recv_admin_remove:{keys:["p","user","pc","affected"],template:'** Privilege class {pc} has been removed by {user} * {affected} affected user(s)'},recv_admin_show:null,recv_admin_showverbose:null,recv_admin_privclass:{keys:["p","e","command"],template:'** Admin command "{command}" failed * {e}'},kicked:{keys:["ns","user","r"],template:'** You have been kicked by {user} * {r}'},ping:null,disconnect:{keys:["e"],template:'** You have been disconnected * {e}',global:true},send:{keys:["ns","e"],template:'** Send error: {e}'},kick:{keys:["ns","user","e"],template:'** Could not kick {user} * {e}'},get:{keys:["ns","p","e"],template:'** Could not get {p} info for {ns} * {e}'},set:{keys:["ns","p","e"],template:'** Could not set {p} * {e}'},kill:{keys:["ns","e"],template:'** Kill error * {e}'},unknown:{keys:["ns","packet"],template:'** Received unknown packet in {ns} * {packet}',monitor:true}} +var m=function(){d.bind("cmd.connect",b.connection);d.bind("cmd.set",b.setter);d.bind("cmd.join",b.join);d.bind("cmd.chat",b.pjoin);d.bind("cmd.part",b.part);d.bind("cmd.say",b.say);d.bind("cmd.npmsg",b.npmsg);d.bind("cmd.me",b.action);d.bind("cmd.promote",b.chgpriv);d.bind("cmd.demote",b.chgpriv);d.bind("cmd.ban",b.ban);d.bind("cmd.unban",b.ban);d.bind("cmd.kick",b.killk);d.bind("cmd.whois",b.whois);d.bind("cmd.title",b.title);d.bind("cmd.topic",b.title);d.bind("cmd.admin",b.admin);d.bind("cmd.disconnect",b.connection);d.bind("cmd.kill",b.killk);d.bind("cmd.raw",b.raw);d.bind("cmd.clear",b.clear);d.bind("cmd.clearall",b.clearall);d.bind("cmd.close",b.close);d.bind("pkt.property",l);d.bind("pkt.recv_admin_show",f);d.bind("pkt.recv_admin_showverbose",f);d.bind("pkt.get",k);d.bind("cmd.gettitle",b.gett);d.bind("cmd.gettopic",b.gett);d.bind("cmd.theme",b.theme)};var j=function(o,n){d.settings.ui.theme=o.theme;d.settings.ui.clock=o.clock;d.settings.ui.tabclose=o.tabclose};var h=function(p,o){var n=p.settings.page("Main"); +var q={};q.username=d.settings.username;q.pk=d.settings.pk;q.devel=d.settings.developer;n.item("Form",{ref:"login",title:"Login",text:"Here you can change the username and token used to log into the chat server.",fields:[["Textfield",{ref:"username",label:"Username","default":q.username}],["Textfield",{ref:"token",label:"Token","default":q.pk}]],event:{save:function(r){d.settings.username=r.data.username;d.settings.pk=r.data.token}}},true);n.item("Form",{ref:"developer",title:"Developer Mode",text:"Turn developer mode on or off.\n\nDeveloper mode will expose any hidden channel tabs, amongst other things. Keep this turned off unless you're working on implementing something.",fields:[["Checkbox",{ref:"enabled",items:[{value:"on",title:"On",selected:q.devel}]}]],event:{change:function(r){d.settings.developer=(r.data.enabled.indexOf("on")!=-1);d.ui.developer(d.settings.developer)},save:function(r){q.devel=d.settings.developer},close:function(r){d.settings.developer=q.devel; +d.ui.developer(d.settings.developer)}}});n.item("Text",{ref:"intro",title:"Main",text:"Use this window to view and change your settings.\n\nCheck the different pages to see what settings can be changed.",},true);n.item("Text",{ref:"debug",wclass:"faint",title:"Debug Information",text:"Chat Agent: "+d.settings.agent+"\n\nUser Agent: "+navigator.userAgent+""})};var g=function(p,o){var n=p.settings.page("About",true);n.item("Text",{ref:"about-wsc",title:"Wsc",text:'Currently using wsc version '+wsc.VERSION+" "+wsc.STATE+'.\n\nWsc works using HTML5, javascript, and CSS3. WebSocket is used for the connection where possible. The source code for this client is pretty huge.\n\nWsc was created by ~photofroggy'})};var b={};b.theme=function(o,n){n.ui.theme(o.args.split(" ").shift()) +};b.setter=function(p){var o=p.args.split(" ");var n=o.shift().toLowerCase();var o=o.join(" ");if(o.length==0){d.cchannel.serverMessage("Could not set "+n,"No data supplied");return}if(!(n in d.settings)){d.cchannel.serverMessage('Unknown setting "'+n+'"');return}d.settings[n]=o;d.cchannel.serverMessage("Changed "+n+" setting","value: "+o)};b.connection=function(n){d[n.cmd]()};b.join=function(n){var o=n.args.split(" ");var o=o.toString()==""?[]:o;if(n.ns!=n.target){o.unshift(n.target)}if(o.toString()==""){return}for(index in o){d.join(o[index])}};b.pjoin=function(n){var o=n.args.split(" ");var o=o.toString()==""?[]:o;if(n.ns!=n.target){o.unshift(n.target)}if(o.toString()==""){return}for(index in o){d.join("@"+o[index])}};b.part=function(n){var o=n.args.split(" ");if(n.ns!=n.target){o.unshift(n.target)}if(o.toString()==""){d.part(n.ns);return}for(index in o){d.part(o[index])}};b.title=function(n){d.set(n.target,n.cmd,n.args)};b.chgpriv=function(o){var n=o.args.split(" ");d[o.cmd.toLowerCase()](o.target,n[0],n[1]) +};b.ban=function(r,n){var p=r.args.split(" ");var o=p.shift();var q=r.cmd;if(q=="ban"&&p.length>0){n.kick(r.target,o,p.join(" "))}n[q](r.target,o)};b.action=function(n){d.action(n.target,n.args)};b.raw=function(n){d.send(n.args.replace(/\\n/gm,"\n"))};b.killk=function(q,n){var s=q.args.split(" ");var o=s.shift();var p=s.length>0?s.join(" "):null;if(q.cmd=="kick"){n.kick(q.target,o,p)}else{n.kill(o,p)}};b.say=function(n){if(d.channel(n.target).monitor){return}d.say(n.target,n.args)};b.npmsg=function(n){d.npmsg(n.target,n.args)};b.clear=function(p,n){if(p.args.length>0){var q=p.args.split(" ");for(var o in q){if(!q.hasOwnProperty(o)){continue}n.ui.channel(p.target).clear_user(q[o])}}else{n.ui.channel(p.target).clear()}};b.clearall=function(o,n){var q=null;if(o.args.length>0){var p=o.args.split(" ");q=function(s,t){for(var r in p){if(!p.hasOwnProperty(r)){continue}t.clear_user(p[r])}}}else{q=function(r,s){s.clear()}}n.ui.chatbook.each(q,true)};b.close=function(n){d.part(n.target);d.remove_ns(n.target) +};b.whois=function(o,n){n.whois(o.args.split(" ")[0])};b.admin=function(o,n){n.admin(o.target,o.args)};b.disconnect=function(o,n){n.disconnect()};b.gett=function(o,n){var p=o.cmd.indexOf("title")>-1?"title":"topic";n.ui.control.set_text("/"+p+" "+n.channel(o.target).info[p].content)};var l=function(q,n){if(q.p!="info"){return}var o=q.pkt.sub;var r=o.shift().arg;r.username=q.sns.substr(1);r.connections=[];var p={};while(o.length>0){p=o.shift().arg;p.channels=[];while(o.length>0){if(o[0].cmd!="ns"){break}p.channels.unshift(n.deform_ns(o.shift().param))}r.connections.push(p)}n.ui.chatbook.current.log_whois(r)};var k=function(o,n){if(o.ns.indexOf("login:")!=0){return}var p=o.sns.substr(1);n.ui.pager.notice({ref:"whois-"+p,heading:"Whois Failed",content:"Whois failed for "+p+".\nNo such user online."},false,5000)};var f=function(r,o){var u=o.channel(r.ns);var n=r.info.split("\n");var t="";var s=[];var p="";for(var q in n){if(!n.hasOwnProperty(q)){continue}t=n[q].split(" ");if(r.p=="privclass"){s.push([t.shift(),t.shift().split("=")[1],t.join(" ")]) +}else{if(r.p=="users"){p=t.shift().split(":",1)[0];s.push([p,u.get_privclass_order(p),t.join(" ")])}}}o.ui.chatbook.current.log_pc(r.p=="privclass",s)};m()};wsc.defaults.Extension.Autojoin=function(a){var d=a.autojoin;a.ui.nav.add_button({icon:"chat",label:"",title:"Join your autojoin channels",href:"#autojoin-do",handler:function(){for(var g in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(g)){continue}a.join(a.autojoin.channel[g])}}});var f=function(){a.bind("cmd.autojoin",b);a.ui.on("settings.open",d.page)};d.page=function(k,m){var l=k.settings.page("Autojoin");var j="
                ";var n={};n.ajon=a.autojoin.on;n.chan=a.autojoin.channel;if(a.autojoin.channel.length==0){j+="
              • No autojoin channels set
              "}else{for(var h in a.autojoin.channel){if(!a.autojoin.channel.hasOwnProperty(h)){continue}j+="
            • "+a.autojoin.channel[h]+"
            • "}j+=""}l.item("Checkbox",{ref:"eaj",title:"Autojoin",text:"Turn on autojoin to automatically join selected channels when you connect to the chat server.",items:[{value:"yes",title:"On",selected:n.ajon}],event:{change:function(o){if(o.target.value=="yes"){a.autojoin.on=o.target.checked +}},save:function(o){n.ajon=a.autojoin.on;a.config_save()},close:function(o){a.autojoin.on=n.ajon}}});var g=l.item("Items",{ref:"channelss",title:"Channels",text:"Add any channels you want to join automatically when you connect to the chat server.",items:a.autojoin.channel,prompt:{title:"Add Channel",label:"Channel:",},event:{up:function(o){var p=o.args.swap;a.autojoin.channel[p["this"].index]=p.that.item;a.autojoin.channel[p.that.index]=p["this"].item;g.options.items=a.autojoin.channel},down:function(o){var p=o.args.swap;a.autojoin.channel[p["this"].index]=p.that.item;a.autojoin.channel[p.that.index]=p["this"].item;g.options.items=a.autojoin.channel},add:function(q){var p=a.deform_ns(q.args.item).toLowerCase();var o=a.autojoin.channel.indexOf(p);if(o!=-1){return}a.autojoin.channel.push(p);g.options.items=a.autojoin.channel},remove:function(o){a.autojoin.channel.splice(o.args.index,1);g.options.items=a.autojoin.channel},save:function(o){n.chan=a.autojoin.channel;a.config_save() +},close:function(o){a.config_load()}}})};var b=function(n){var h=n.args.split(" ");if(!h){return}var l=h.shift().toLowerCase();var g=function(p){};var k=false;var o=a.channel(n.ns);switch(l){case"add":g=function(p){if(a.autojoin.channel.indexOf(p)==-1){k=true;a.autojoin.channel.push(p);o.server_message("Added "+p+" to your autojoin.")}else{o.server_message("Already have "+p+" on your autojoin.")}};break;case"rem":case"remove":g=function(q){var p=a.autojoin.channel.indexOf(q);if(p!=-1){k=true;a.autojoin.channel.splice(p,1);o.server_message("Removed "+q+" from your autojoin.")}else{o.server_message(q+" is not on your autojoin list.")}};break;case"on":o.server_message("Autojoin on.");if(!a.autojoin.on){k=true;a.autojoin.on=true}break;case"off":o.server_message("Autojoin off.");if(a.autojoin.on){k=true;a.autojoin.on=false}break}var m="";for(var j in h){if(!h.hasOwnProperty(j)){continue}m=a.deform_ns(h[j]).toLowerCase();g(m)}if(k){a.config_save()}};f()};wsc.defaults.Extension.Away=function(b){var f=b.storage.folder("away"); +var d={on:false,reason:"",last:{},since:0,interval:60000,format:{setaway:"/me is away: {reason}",setback:"/me is back",away:"{user}: I've been away for {timesince}. Reason: {reason}"}};b.away=d;var l=function(){j();g();b.bind("cmd.setaway",a);b.bind("cmd.setback",k);b.ui.on("tabbed",h);b.ui.on("settings.open",d.page)};d.page=function(n,p){var m=function(s){s=replaceAll(s,"<","<");s=replaceAll(s,">",">");s=replaceAll(s,'"',""");return s};var q=function(s){s=replaceAll(s,"<","<");s=replaceAll(s,">",">");s=replaceAll(s,""",'"');return s};var o=n.settings.page("Away");var r={};r.away=d.format.away;r.sa=d.format.setaway;r.sb=d.format.setback;r.intr=d.interval;o.item("Text",{ref:"intro",title:"Away Messages",text:"Use away messages when you are away from the chats.\n\n You can set yourself away using the /setaway [reason] command. When you get back, use /setback. While you are away, the client will automatically respond when people try to talk to you, telling them you're away.",}); +o.item("Form",{ref:"msgs",title:"Messages",text:"Here you can set the messages displayed when you set yourself away or back. You can also change the away message format.",hint:"{user}
              This is replaced with the username of the person trying to talk to you\n\n{reason}
              This is replaced by your reason for being away.\n\n{timesince}
              Use this to show how long you have been away for.",fields:[["Textfield",{ref:"away",label:"Away","default":m(r.away)}],["Textfield",{ref:"setaway",label:"Setaway","default":m(r.sa)}],["Textfield",{ref:"setback",label:"Setback","default":m(r.sb)}]],event:{save:function(s){d.format.away=q(s.data.away);d.format.setaway=q(s.data.setaway);d.format.setback=q(s.data.setback);g()}}});o.item("Form",{ref:"interval",title:"Message Interval",text:"Here you can set the amount of time to wait before displaying another away message. The interval is in seconds.",fields:[["Textfield",{ref:"interval",label:"Interval","default":(r.intr/1000).toString()}]],event:{save:function(s){d.interval=parseInt(s.data.interval)*1000; +g()}}})};var a=function(o,m){d.on=true;d.last={};d.since=new Date();d.reason=o.args;var p=m.say;var n=replaceAll(d.format.setaway,"{reason}",d.reason||"[silent away]");if(n.indexOf("/me ")==0){n=n.substr(4);p=m.action}m.each_channel(function(q){p.call(m,q,n)});m.ui.control.add_state({ref:"away",label:"Away, reason: "+(d.reason||"[silent away]")+""})};var k=function(o,m){if(!d.on){return}d.on=false;var p=m.say;var n=d.format.setback;if(n.indexOf("/me ")==0){n=n.substr(4);p=m.action}m.each_channel(function(q){p.call(m,q,n)});m.ui.control.rem_state("away")};var h=function(p){if(!d.on){return}if(d.reason.length==0){return}if(p.user==b.settings.username){return}if(b.exclude.contains(p.ns)){return}var n=new Date();var o=p.sns.toLowerCase();if(o in d.last){if((n-d.last[o])<=d.interval){return}}var m=timeLengthString((n-d.since)/1000);var q=replaceAll(d.format.away,"{user}",p.user);q=replaceAll(q,"{timesince}",m);b.say(p.ns,replaceAll(q,"{reason}",d.reason));d.last[o]=n};var j=function(){d.format.setaway=f.get("setaway","/me is away: {reason}"); +d.format.setback=f.get("setback","/me is back");d.format.away=f.get("away","{user}: I've been away for {timesince}. Reason: {reason}");d.interval=parseInt(f.get("interval",60000))};var g=function(){f.set("interval",d.interval);f.set("setaway",d.format.setaway);f.set("setback",d.format.setback);f.set("away",d.format.away)};l()};wsc.defaults.Extension.Ignore=function(d){var f={};var g=d.storage.folder("ignore");var a=g.folder("ignored");var l=function(){k();j();d.bind("cmd.ignore",b);d.bind("cmd.unignore",h);d.ui.on("settings.open",f.page)};f.page=function(n,p){var o=n.settings.page("Ignores");var q={};q.im=f.ignore;q.uim=f.unignore;q.usr=d.ui.umuted;o.item("Text",{ref:"intro",title:"Ignores",text:'Use ignore to ignore people.\n\n You can "ignore" other users of the chat server using the\n /ignore command. Ignoring a user hides their messages from you in the channel log.',});o.item("Form",{ref:"msgs",title:"Messages",text:"Here you can set the messages displayed when you ignore or unignore a user.\n\nThe text {user} is replaced with the name of the user your are ignoring or unignoring.",fields:[["Textfield",{ref:"ignore",label:"Ignore","default":q.im}],["Textfield",{ref:"unignore",label:"Unignore","default":q.uim}]],event:{save:function(r){f.ignore=r.data.ignore; +f.unignore=r.data.unignore;j()}}});var m=o.item("Items",{ref:"ignoreds",title:"Users",text:"This is the list of users that you have silenced.\n\nUse the commands /ignore and /unignore to edit the list.",items:q.usr,prompt:{title:"Add User",label:"User:",},event:{up:function(r){var s=r.args.swap;d.ui.umuted[s["this"].index]=s.that.item;d.ui.umuted[s.that.index]=s["this"].item;m.options.items=d.ui.umuted},down:function(r){var s=r.args.swap;d.ui.umuted[s["this"].index]=s.that.item;d.ui.umuted[s.that.index]=s["this"].item;m.options.items=d.ui.umuted},add:function(r){d.mute_user(r.args.item);m.options.items=d.ui.umuted},remove:function(r){d.unmute_user(r.args.item);m.options.items=d.ui.umuted},save:function(r){q.usr=d.ui.umuted;j()},close:function(r){k()}}})};var b=function(p){var r=p.args.split(" ");var m="";var q="";var o=false;for(var n in r){if(!r.hasOwnProperty(n)){continue}m=r[n];tmod=d.mute_user(m);if(!tmod){continue}o=tmod; +q=replaceAll(f.ignore,"{user}",m);if(q.indexOf("/me ")==0){q=q.substr(4);d.action(p.target,q)}else{d.say(p.target,q)}}if(o){j()}};var h=function(q){var t=q.args.split(" ");var n="";var s="";var m=-1;var p=false;var r=false;for(var o in t){if(!t.hasOwnProperty(o)){continue}n=t[o];r=d.unmute_user(n);if(!r){continue}p=r;s=replaceAll(f.unignore,"{user}",n);if(s.indexOf("/me ")==0){s=s.substr(4);d.action(q.target,s)}else{d.say(q.target,s)}}if(p){j()}};var k=function(){f.ignore=g.get("ignore","/me is ignoring {user} now");f.unignore=g.get("unignore","/me is not ignoring {user} anymore");f.count=parseInt(g.get("count",0));var n=null;for(var m in d.ui.umuted){if(!d.ui.umuted.hasOwnProperty(m)){continue}d.unmute_user(d.ui.umuted[m])}d.ui.umuted=[];if(f.count>0){n=null;for(var m=0;m
              '); +this.protocol=new Chatterbox.Protocol();this.mw=new wsc.Middleware();this.view=b.find(".wsc");this.mns=this.format_ns(this.settings.monitor[0]);this.lun=this.settings.username.toLowerCase();this.monitoro=null;this.swidth=(function(){if($.browser.msie){var l=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body"),k=$('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body");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})();if(window.mozRTCPeerConnection){Chatterbox._gum=function(k,l,j){return navigator.mozGetUserMedia(k,l,j)}}if(window.webkitRTCPeerConnection){Chatterbox._gum=function(k,l,j){return navigator.webkitGetUserMedia(k,l,j) +}}if(window.RTCPeerConnection&&!window.mozRTCPeerConnection){Chatterbox._gum=function(k,l,j){return navigator.getUserMedia(k,l,j)}}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(b){var a=b[0];if(a=="#"||a=="@"||a=="~"||a=="+"){return b}if(b.indexOf("chat:")==0){return"#"+b.slice(5)}if(b.indexOf("server:")==0){return"~"+b.slice(7)}if(b.indexOf("feed:")==0){return"#"+b.slice(5)}if(b.indexOf("login:")==0){return"@"+b.slice(6)}if(b.indexOf("pchat:")==0){var d=b.split(":");d.shift();for(i in d){name=d[i];if(name.toLowerCase()!=this.lun){return"@"+name +}}}return"#"+b};Chatterbox.UI.prototype.format_ns=function(a){var d=a.slice(1);switch(a[0]){case"@":var b=[d,this.lun];b.sort(caseInsensitiveSort);b.unshift("pchat");a=b.join(":");break;case"~":a="server:"+d;break;case"+":a="feed:"+d;break;case"#":a="chat:"+d;break;default:if(a.indexOf("chat:")==0||a.indexOf("pchat:")==0||a.indexOf("server:")==0||a.indexOf("feed:")==0){break}a="chat:"+a;break}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.get_user_media=function(b,d,a){Chatterbox._gum(b,d,a)};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.add("click",this.sound.bank.m.find("audio.click")[0]);var h=this.sound;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)});this.client.bind("ns.user.list",function(k){g.channel(k.ns).set_user_list(k.users) +});this.client.middle("ns.user.privchg",function(l,k){g.channel(l.ns).privchg(l,k)});this.client.bind("ns.user.remove",function(l,k){g.channel(l.ns).remove_one_user(l.user)});this.client.bind("ns.user.registered",function(k){g.channel(k.ns).register_user(k.user)})};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=this.protocol.log(b);if(f){if(this.settings.developer){console.log(">>>",b.sns,"|",f.text())}if(b.hasOwnProperty("s")&&b.s=="0"){this.chatbook.handle(b,a);return}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.BaseTab=function(f,b,d,a){this.manager=f;this.hidden=d;this.monitor=(a==undefined?false:a); +this.built=false;this.raw=b;this.selector="t-"+(b||"chan").toLowerCase();this.namespace=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]}};if(!f){return}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)};Chatterbox.BaseTab.prototype.build=function(b){if(!this.manager){return}if(this.built){return}var a=this.selector;var f=this.namespace;var d=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(b||Chatterbox.render("basetab",{selector:a,ns:f}));this.el.m=this.window=this.manager.chatbook.view.find("#"+a+"-window");var g=this;this.el.t.l.click(function(){g.manager.toggle_channel(d);return false});this.el.t.c.click(function(h){g.manager.trigger("tab.close.clicked",{ns:g.raw,chan:g,e:h}); +return false});if(this.hidden&&!this.manager.settings.developer){this.el.t.o.toggleClass("hidden")}this.built=true};Chatterbox.BaseTab.prototype.hide=function(){this.el.m.css({display:"none"});this.el.t.o.removeClass("active");this.visible=false};Chatterbox.BaseTab.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.BaseTab.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.BaseTab.prototype.remove=function(){this.el.t.o.remove();this.el.m.remove()};Chatterbox.BaseTab.prototype.resize=function(b,a){this.el.m.css({height:a||this.manager.chatbook.height(),width:(b||this.manager.chatbook.width())-10}) +};Chatterbox.BaseTab.prototype.loop=function(){};Chatterbox.Channel=function(f,b,d,a){Chatterbox.BaseTab.call(this,f,b,d,a);this.resized=function(){};this.ulbuf=0};Chatterbox.Channel.prototype=new Chatterbox.BaseTab;Chatterbox.Channel.prototype.constructor=Chatterbox.Channel;Chatterbox.Channel.prototype.build=function(){if(!this.manager){return}if(this.built){return}var a=this.selector;var d=this.namespace;var b=this.raw;Chatterbox.BaseTab.prototype.build.call(this,Chatterbox.render("channel",{selector:a,ns:d}));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.setup_header("title");this.setup_header("topic"); +if(this.namespace[0]=="@"){this.build_user_list({100:"Room Members"},[100])}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.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){Chatterbox.BaseTab.prototype.resize.call(this,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;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.ulbuf});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)}this.resized()};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:'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)]) +}if(k.agent){o.push(["agent",k.agent])}if(k.debug){o.push(["debug",k.debug])}o.push(["chatrooms",k.channels.join(" ")]);g.conns.push(o)}this.manager.trigger("log_whois.before",g);var b="";for(var m in g.conns){var j=g.conns[m];var q='

              connection '+((parseInt(m)+1).toString())+":

              ";q+="
                ";for(var p in j){q+="
              • "+j[p][0]+": "+j[p][1]+"
              • "}q+="
              ";b+=q+"
              "}var h="";for(var m in g.info){h+="
            • "+g.info[m]+"
            • "}var n=this.log_info("whois-"+l.username,Chatterbox.render("whoiswrap",{avatar:g.avatar,info:Chatterbox.render("whoisinfo",{username:g.username,info:h,connections:b})}));var f=n.find("div.avatar");var d=n.find("div.info");d.width(n.find(".whoiswrap").width()-100);f.height(n.height()-10);this.scroll()};Chatterbox.Channel.prototype.log_pc=function(f,g){contents="";for(var d in g){if(!g.hasOwnProperty(d)){continue}var b=g[d];var a="";if(b[2].length==0){a=""+(f?"default privileges":"no members")+""}else{a=b[2] +}contents+=String.format("
            • {0} {1}:
              • {2}
            • ",[b[1],b[0],a])}var h={title:"Privilege class "+(f?"permissions":"members"),info:"
                "+contents+"
              "};this.log_info("pc-"+(f?"permissions":"members"),Chatterbox.render("pcinfo",h))};Chatterbox.Channel.prototype.set_header=function(a,f,h,d){a=a.toLowerCase();var b=this.el.m.find("header."+a+" a[href=#edit]");if(this.el.h[a].html()!=""){if(f.html().length!=0){this.server_message(a+" set by "+h)}}this.el.h[a].html(f.html());var g=this;setTimeout(function(){if(f.text().length>0){g.el.h[a].css({display:"block"});var j=(g.el.h[a].outerHeight(true)-5)*(-1);b.css("top",j)}else{g.el.h[a].css({display:"none"})}g.resize()},100)};Chatterbox.Channel.prototype.get_header=function(a){return this.el.h[a.toLowerCase()]};Chatterbox.Channel.prototype.build_user_list=function(f,a){var h=this.el.u;var d="";var g=null;h.html("");for(var b in a){var d=f[a[b]];h.append('

              '+d+"

                "); +g=h.find(".pc#"+d);g.css("display","none")}};Chatterbox.Channel.prototype.reveal_user_list=function(){var g=this.el.u;var d=0;var b=0;var a=null;g.find("div.pc").each(function(h,j){a=g.find(this);b=a.find("ul li").length;d+=b;a.css("display",(b==0?"none":"block"))});g.css("display",(d==0?"none":"block"));var f=this;setTimeout(function(){f.resize()},100)};Chatterbox.Channel.prototype.set_user_list=function(f){if(Object.size(f)==0){return}var d=this.el.u;var a=null;for(var b in f){a=f[b];this.set_user(a,true)}this.reveal_user_list()};Chatterbox.Channel.prototype.set_user=function(g,d){var j=this.el.u.find("div.pc#"+replaceAll(g.pc," ","-"));var a=j.find("ul");var b=g.conn==1?"":"["+g.conn+"]";var h='
              • '+g.symbol+""+g.name+""+b+"
              • ";if(a.find("a#"+g.name).length==1){return}if(a.find("li").length==0){a.append(h)}else{var k=g.name.toLowerCase();var m=null;var f=false;a.find("li a").each(function(){if(f){return +}m=a.find(this);if(k"}h.window.append(Chatterbox.render("userinfo",{username:b.name,avatar:b.avatar,link:b.link,info:j}));f=h.window.find(".userinfo#"+b.name);h.window.find("div.userinfo:not('#"+b.name+"')").remove();var l=g.offset();f.css({top:(l.top-g.height())+10,left:(l.left-(f.width()))-6});f.find(".info").height(f.height());f.hover(function(){f.data("hover",1)},function(m){f.data("hover",0);h.unhover_user(f,m)});f.data("hover",0)};var d=function(j){g.data("hover",0);h.unhover_user(f,j)};g.off("mouseenter",a);g.off("mouseleave",d);g.on("mouseenter",a);g.on("mouseleave",d)};Chatterbox.Channel.prototype.unhover_user=function(f,d){var g=f.offset();var b=f.outerHeight(true)+g.top;var j=f.outerWidth(true)+g.left;var a=d.pageX;var h=d.pageY;if(a>g.left&&ag.top&&hg.left&&h>g.top&&h<(g.top+15)){return +}f.remove()};Chatterbox.Channel.prototype.mute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"none"});this.scroll()};Chatterbox.Channel.prototype.unmute_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).css({display:"list-item"});this.scroll()};Chatterbox.Channel.prototype.clear_user=function(a){if(!a){return}this.el.l.w.find("li.logmsg.u-"+a.toLowerCase()).remove();this.scroll()};Chatterbox.Channel.prototype.pkt_join=function(b,a){if(b.e!="ok"){return}this.set_header("title",(new wsc.MessageString("")),"","");this.set_header("topic",(new wsc.MessageString("")),"","")};Chatterbox.Channel.prototype.pkt_recv_msg=function(b,a){var d=this;this.manager.cascade("chan.recv_msg",function(h,f){var g=d.manager.client.settings.username.toLowerCase();if(g==h.user.toLowerCase()){return}var k=h.message.toLowerCase();var j=k.indexOf(g)!=-1;if(!j&&h.sns[0]!="@"){return}if(j){d.highlight()}else{d.highlight(false)}d.manager.trigger("tabbed",h) +},b)};Chatterbox.Channel.prototype.pkt_recv_action=Chatterbox.Channel.prototype.pkt_recv_msg;Chatterbox.Channel.prototype.pkt_property=function(b,a){var f=b.pkt.arg.p;var d=a.channel(this.namespace);switch(f){case"title":case"topic":this.set_header(f,b.value||(new wsc.MessageString("")),b.by,b.ts);break;case"privclasses":this.build_user_list(d.info.pc,d.info.pc_order.slice(0));break;case"members":break;default:break}};Chatterbox.Chatbook=function(a){this.manager=a;this.view=this.manager.view.find("div.chatbook");this.chan={};this.trail=[];this.current=null;this.manager.on("tab.close.clicked",function(b,d){d.chatbook.remove_channel(b.ns)})};Chatterbox.Chatbook.prototype.height=function(){return this.view.height()};Chatterbox.Chatbook.prototype.width=function(){return this.view.width()};Chatterbox.Chatbook.prototype.resize=function(b){b=b||600;var d=this.view.innerWidth();for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}var f=this.chan[a];f.resize(d,b)}};Chatterbox.Chatbook.prototype.loop=function(){for(select in this.chan){this.chan[select].loop() +}};Chatterbox.Chatbook.prototype.channel=function(a,b){a=this.manager.format_ns(a).toLowerCase();if(!this.chan[a]&&b){this.chan[a]=b}return this.chan[a]};Chatterbox.Chatbook.prototype.channels=function(){chans=-1;for(ns in this.chan){if(this.chan[ns].hidden){continue}chans++}return chans};Chatterbox.Chatbook.prototype.create_channel=function(b,d,a){var f=this.channel(b,this.channel_object(b,d,a));f.build();if(this.trail.indexOf(f.namespace)==-1){this.trail.push(f.namespace)}if(!f.visible){this.toggle_channel(b)}this.manager.resize();return f};Chatterbox.Chatbook.prototype.channel_object=function(a,b){return new Chatterbox.Channel(this.manager,a,b)};Chatterbox.Chatbook.prototype.toggle_channel=function(a){var d=this.channel(a);var b=d;if(!d){return}if(d.hidden){if(this.current&&this.current==d){return}if(!this.manager.settings.developer){d.hide();return}}if(this.current){if(this.current==d){return}this.current.hide();b=this.current}else{if(this.manager.monitoro!==null){this.manager.monitoro.hide() +}}d.show();this.manager.control.focus();this.current=d;this.manager.resize();this.manager.control.cache_input(b,d);this.manager.trigger("channel.selected",{ns:d.raw,chan:d,prev:b});this.manager.client.select_ns(d.raw)};Chatterbox.Chatbook.prototype.remove_channel=function(a){var b=this.channel(a);if(!b){return}if(this.channels()==0&&!b.hidden){return}b.remove();delete this.chan[b.raw.toLowerCase()];if(this.current==b){this.channel_left()}var d=this.trail.indexOf(b.namespace);this.trail.splice(d,1)};Chatterbox.Chatbook.prototype.channel_left=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a<0){return}var f=null;while(true){try{f=this.channel(this.trail[--a])}catch(d){a=this.trail.length-1;f=this.channel(this.trail[a])}if(!f.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(f.namespace)};Chatterbox.Chatbook.prototype.channel_right=function(){var b=this.current.namespace;var a=this.trail.indexOf(b);if(a==-1){return}var f=null;while(true){try{f=this.channel(this.trail[++a]) +}catch(d){a=0;f=this.channel(this.trail[0])}if(!f.hidden){break}if(this.manager.settings.developer){break}}this.toggle_channel(f.namespace)};Chatterbox.Chatbook.prototype.each=function(d){var b=null;for(var a in this.chan){if(!this.chan.hasOwnProperty(a)){continue}b=this.chan[a];if(d(b.namespace,b)===false){break}}};Chatterbox.Chatbook.prototype.server_message=function(b,a){for(ns in this.chan){this.chan[ns].server_message(b,a)}};Chatterbox.Chatbook.prototype.log_item=function(a){for(ns in this.chan){this.chan[ns].log_item(a)}};Chatterbox.Chatbook.prototype.log=function(a){for(ns in this.chan){this.chan[ns].log(a)}};Chatterbox.Chatbook.prototype.log_message=function(d,b){try{if(!d.global){if(!d.monitor){this.channel(b.ns).log_item(b)}else{this.manager.monitoro.log_item(b)}}else{this.log_item(b)}}catch(a){try{this.ui.monitoro.server_message("Failed to log for",b.sns,b.html)}catch(a){console.log(">> Failed to log message for",b.sns,"::");console.log(">>",b.html)}}};Chatterbox.Chatbook.prototype.retime=function(){for(ns in this.chan){this.chan[ns].retime() +}};Chatterbox.Chatbook.prototype.developer=function(){this.each(function(a,b){b.developer()})};Chatterbox.Chatbook.prototype.handle=function(f,b){var g=this.manager;var h=this.channel(f.ns);if(!h){return}var a="pkt_"+f.name;try{h[a](f,b)}catch(d){}};Chatterbox.Control=function(b){this.manager=b;this.manager.view.append(Chatterbox.template.control);this.view=this.manager.view.find("div.chatcontrol");this.ml=false;this.history={};this.tab={hit:false,cache:"",matched:[],index:-1,type:0,prefix:["","/",""],};this.el={form:this.view.find("form.msg"),i:{s:this.view.find("form.msg input.msg"),m:this.view.find("form.msg textarea.msg"),c:null,t:this.view.find("ul.buttons a[href~=#multiline].button")},brow:{m:this.view.find("div.brow"),b:this.view.find("div.brow ul.buttons"),s:this.view.find("div.brow ul.states")}};this.el.i.c=this.el.i.s;var a=this;this.el.i.t.click(function(d){a.multiline(!a.multiline());return false});this.el.i.s.keydown(function(d){return a.keypress(d)});this.el.i.m.keydown(function(d){return a.keypress(d) +});this.el.form.submit(function(d){return a.submit(d)});this.add_button({label:"b",icon:false,href:"#bold",title:"Bold text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"i",icon:false,href:"#italic",title:"Italic text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"u",icon:false,href:"#underline",title:"Underline text",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sup",icon:false,href:"#sup",title:"Superscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}});this.add_button({label:"sub",icon:false,href:"#sub",title:"Subscript",handler:function(){a.surroundtext(a.el.i.c[0],"","")}})};Chatterbox.Control.prototype.surroundtext=function(j,h,b){var g=j.scrollTop;var a=j.value,d=j.selectionStart,f=j.selectionEnd;var k=j.value.substring(d,f);j.value=a.substring(0,d)+h+k+b+a.substring(f);j.selectionStart=d+h.length; +j.selectionEnd=d+h.length+k.length;j.scrollTop=g;j.focus()};Chatterbox.Control.prototype.focus=function(){this.el.i.c.focus()};Chatterbox.Control.prototype.resize=function(){w=this.manager.view.width();this.view.css({width:"100%"});this.el.form.css({width:this.manager.view.width()-20});this.el.i.s.css({width:this.manager.view.width()-100});this.el.i.m.css({width:this.manager.view.width()-90})};Chatterbox.Control.prototype.height=function(){var a=this.view.outerHeight();return a};Chatterbox.Control.prototype.multiline=function(a){if(a==undefined||this.ml==a){return this.ml}this.ml=a;var b=(this.ml?"s":"m");a=(this.ml?"m":"s");this.el.i[b].css("display","none");this.el.i[a].css("display","inline-block");this.el.i.c=this.el.i[a];this.manager.resize();return this.ml};Chatterbox.Control.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.brow.b.append(Chatterbox.render("brow_button",a)); +var b=this.el.brow.b.find("a[href="+a.href+"].button");b.click(function(d){a.handler();return false});return b};Chatterbox.Control.prototype.add_state=function(a){a=Object.extend({ref:"state",label:"some state"},(a||{}));var b=this.el.brow.s.find("li#"+a.ref);if(b.length==0){this.el.brow.s.append(Chatterbox.render("brow_state",a));return this.el.brow.s.find("li#"+a.ref)}b.html(a.label);return b};Chatterbox.Control.prototype.rem_state=function(a){return this.el.brow.s.find("li#"+a).remove()};Chatterbox.Control.prototype.chomp=function(){var f=this.el.i.c.val();var b=f.lastIndexOf(" ");if(b==-1){this.el.i.c.val("");return f}var a=f.slice(b+1);this.el.i.c.val(f.slice(0,b));if(a.length==0){return this.chomp()}return a};Chatterbox.Control.prototype.unchomp=function(a){var b=this.el.i.c.val();if(!b){this.el.i.c.val(a)}else{this.el.i.c.val(b+" "+a)}};Chatterbox.Control.prototype.get_text=function(a){if(a==undefined){return this.el.i.c.val()}this.el.i.c.val(a||"");return this.el.i.c.val()};Chatterbox.Control.prototype.set_text=function(a){this.el.i.c.val(a||"") +};Chatterbox.Control.prototype.cache_input=function(b,d){var a=this.get_history(b.namespace);if(a.index>-1){return}a.tmp=this.get_text();this.set_text(this.get_history(d.namespace).tmp)};Chatterbox.Control.prototype.get_history=function(a){if(!a){if(!this.manager.chatbook.current){a="~monitor"}}a=a||this.manager.chatbook.current.namespace;if(!this.history[a]){this.history[a]={index:-1,list:[],tmp:""}}return this.history[a]};Chatterbox.Control.prototype.append_history=function(b){if(!b){return}var a=this.get_history();a.list.unshift(b);a.index=-1;if(a.list.length>100){a.list.pop()}};Chatterbox.Control.prototype.scroll_history=function(a){var d=this.get_history();var b=this.get_text();if(d.index==-1){if(b){d.tmp=b}else{d.list[d.index]=b}}if(a){if(d.list.length>0&&d.index<(d.list.length-1)){d.index++}}else{if(d.index>-1){d.index--}}this.set_text(d.list[d.index]||d.tmp)};Chatterbox.Control.prototype.tab_item=function(b){if(!this.tab.hit){this.start_tab(b)}this.chomp();this.tab.index++;if(this.tab.index>=this.tab.matched.length){this.tab.index=-1 +}if(this.tab.index==-1){this.unchomp(this.tab.prefix[this.tab.type]+this.tab.cache);return}var a=this.get_text()==""?(this.tab.type==0?": ":" "):"";this.unchomp(this.tab.prefix[this.tab.type]+this.tab.matched[this.tab.index]+a)};Chatterbox.Control.prototype.start_tab=function(d){this.tab.hit=true;this.tab.index=-1;this.tab.matched=[];this.tab.type=0;var h=this.chomp();this.unchomp(h);if(h[0]=="/"||h[0]=="#"||h[0]=="@"){this.tab.type=h[0]=="/"?1:2;if(h[0]=="/"){h=h.slice(1)}}else{this.tab.type=0}this.tab.cache=h;h=h.toLowerCase();this.tab.matched=[];if(this.tab.type==0){var j=this.manager.client.channel(this.manager.chatbook.current.namespace);for(var a in j.info.members){if(a.toLowerCase().indexOf(h)==0){this.tab.matched.push(a)}}}else{if(this.tab.type==1){var g="";for(var b in this.manager.client.cmds){g=this.manager.client.cmds[b];if(g.indexOf(h)==0){this.tab.matched.push(g)}}}else{if(this.tab.type==2){var f=this;this.manager.client.each_channel(function(k,l){if(l.namespace.toLowerCase().indexOf(h)==0){f.tab.matched.push(l.namespace) +}})}}}};Chatterbox.Control.prototype.end_tab=function(a){this.tab.hit=false;this.tab.matched=[];this.tab.cache="";this.tab.index=-1};Chatterbox.Control.prototype.submit=function(a){var b=this.get_text();this.append_history(b);this.set_text("");this.handle(a,b);return false};Chatterbox.Control.prototype.keypress=function(d){var b=d.which||d.keyCode;var f=this.tab.hit;var a=false;switch(b){case 13:if(!this.multiline()){this.submit(d)}else{if(d.shiftKey){this.submit(d)}else{a=true}}break;case 38:if(!this.multiline()){this.scroll_history(true);break}a=true;break;case 40:if(!this.multiline()){this.scroll_history(false);break}a=true;break;case 9:if(d.shiftKey){this.manager.channel_right()}else{this.tab_item(d);f=false}break;case 219:if(d.ctrlKey){this.manager.channel_left()}else{a=true}break;case 221:if(d.ctrlKey){this.manager.channel_right()}else{a=true}break;default:a=true;break}if(f){this.end_tab(d)}return a};Chatterbox.Control.prototype.handle=function(b,g){if(g==""){return}if(!this.manager.chatbook.current){return +}var k=false;if(g[0]!="/"){k=true}g=(b.shiftKey?"/npmsg ":(g[0]=="/"?"":"/say "))+g;g=g.slice(1);var l=g.split(" ");var d=l.shift().toLowerCase();var j=this.manager.chatbook.current.namespace;var h=j;if(!k&&l[0]){var f=l[0][0];if((f=="#"||f=="@")&&l[0].length>1){h=this.manager.format_ns(l.shift())}}var m=l.join(" ");var a=this.manager.client.trigger("cmd."+d,{name:"cmd",cmd:d,args:m,target:h,ns:j});if(a==0){this.manager.pager.notice({ref:"cmd-fail",heading:"Command failed",content:'"'+d+'" is not a command.'},false,5000)}};Chatterbox.Navigation=function(a){this.manager=a;this.showclose=this.manager.settings.tabclose;this.settings={};this.settings.open=false;this.el={n:this.manager.view.find("nav.tabs"),tw:this.manager.view.find("nav.tabs div.tabwrap"),t:this.manager.view.find("nav.tabs #chattabs"),b:this.manager.view.find("nav.tabs #tabnav"),l:this.manager.view.find("nav.tabs #tabnav .arrow_left"),r:this.manager.view.find("nav.tabs #tabnav .arrow_right"),s:this.manager.view.find("nav.tabs #tabnav #settings-button"),}; +if(!this.showclose){if(!this.el.t.hasClass("hc")){this.el.t.addClass("hc")}}var b=this;this.el.s.click(function(g){if(b.settings.open){return false}var d={e:g,settings:new Chatterbox.Settings.Config(b.manager)};b.configure_page(d);b.manager.trigger("settings.open",d);b.manager.trigger("settings.open.ran",d);var f=d.settings.page("About");f.item("text",{ref:"about-chatterbox",wclass:"centered faint",text:'Using Chatterbox version '+Chatterbox.VERSION+" "+Chatterbox.STATE+' by ~photofroggy.'});b.settings.window=new Chatterbox.Settings(b.manager,d.settings);b.settings.window.build();b.settings.open=true;return false});this.el.l.click(function(){b.manager.channel_left();return false});this.el.r.click(function(){b.manager.channel_right();return false})};Chatterbox.Navigation.prototype.configure_page=function(b){var f=this.manager;var d=b.settings.page("Main");var g={};g.theme=replaceAll(f.settings.theme,"wsct_",""); +g.clock=f.clock();g.tc=f.nav.closer();var a=[];for(i in f.settings.themes){name=replaceAll(f.settings.themes[i],"wsct_","");a.push({value:name,title:name,selected:g.theme==name})}d.item("Form",{ref:"ui",title:"UI",hint:"Timestamp
                Choose between a 24 hour clock and a 12 hour clock.\n\nTheme
                Change the look of the client.\n\nClose Buttons
                Turn tab close buttons on/off.",fields:[["Dropdown",{ref:"theme",label:"Theme",items:a}],["Dropdown",{ref:"clock",label:"Timestamp Format",items:[{value:"24",title:"24 hour",selected:g.clock},{value:"12",title:"12 hour",selected:!g.clock}]}],["Checkbox",{ref:"tabclose",label:"Close Buttons",items:[{value:"yes",title:"On",selected:g.tc}]}],],event:{change:function(h){f.clock(h.data.clock=="24");f.theme(h.data.theme);f.nav.closer(h.data.tabclose.indexOf("yes")>-1)},save:function(h){g.clock=f.clock();g.theme=replaceAll(f.theme(),"wsct_","");g.tc=f.nav.closer();f.trigger("settings.save.ui",{clock:g.clock,tabclose:g.tc,theme:"wsct_"+g.theme}) +},close:function(h){f.clock(g.clock);f.theme(g.theme);f.nav.closer(g.tc)}}})};Chatterbox.Navigation.prototype.height=function(){var a=this.el.n.outerHeight();return a};Chatterbox.Navigation.prototype.add_button=function(a){a=Object.extend({label:"New",icon:false,href:"#button",title:"Button.",handler:function(){}},(a||{}));if(a.icon!==false){a.icon=" iconic "+a.icon}else{a.icon=" text"}this.el.b.prepend(Chatterbox.render("nav_button",a));var b=this.el.b.find("a[href="+a.href+"].button");b.click(function(d){a.handler();return false});this.resize();return b};Chatterbox.Navigation.prototype.add_tab=function(a,b){this.el.t.append(Chatterbox.render("tab",{selector:a,ns:b}));return this.el.t.find("#"+a+"-tab")};Chatterbox.Navigation.prototype.resize=function(){this.el.tw.width(this.el.n.width()-this.el.b.outerWidth()-20);if(this.settings.open){this.settings.window.resize()}};Chatterbox.Navigation.prototype.closer=function(a){if(a==undefined||a==this.showclose){return this.showclose}this.showclose=a; +if(this.showclose){if(!this.el.t.hasClass("hc")){return}this.el.t.removeClass("hc");return}if(this.el.t.hasClass("hc")){return}this.el.t.addClass("hc")};Chatterbox.Pager=function(a){this.manager=a;this.lifespan=20000;this.halflife=5000;this.el={m:null,click:null};this.sound={click:function(){},};this.notices=[];this.build()};Chatterbox.Pager.prototype.build=function(){this.el.m=this.manager.view.find("div.pager")};Chatterbox.Pager.prototype.notice=function(f,l,k,d){var h={frame:null,close:null,foot:null,b:{},options:Object.extend({ref:"notice",icon:"",heading:"Some notice",content:"Notice content goes here."},(f||{})),onclose:function(){},ondestroy:function(){}};h.options.ref+="-"+(new Date()).valueOf();h.options.content=h.options.content.split("\n").join("

                ");this.notices.push(h);this.el.m.append(Chatterbox.render("pager.notice",h.options));h.frame=this.el.m.find("#"+h.options.ref).last();h.close=h.frame.find("a.close_notice");h.foot=h.frame.find("footer.buttons");var g={};for(var a in h.options.buttons){if(!h.options.buttons.hasOwnProperty(a)){continue +}g=h.options.buttons[a];h.foot.append(Chatterbox.render("pager.button",g));h.b[a]=h.foot.find("a#"+g.ref);h.b[a].click(g.click)}var j=this;h.close.click(function(){h.onclose();j.remove_notice(h);return false});if(!l){if(!k){k=j.lifespan}setTimeout(function(){j.remove_notice(h,true)},k)}if(d!==true){this.manager.sound.click()}return h};Chatterbox.Pager.prototype.remove_notice=function(a,d){var b=this;if(this.notices.indexOf(a)==-1){return false}a.frame.fadeTo((d?this.halflife:300),0).slideUp(function(){a.frame.remove();b.notices.splice(b.notices.indexOf(a),1);a.ondestroy()});if(d){a.frame.mouseenter(function(){if(b.notices.indexOf(a)==-1){return}a.frame.stop(true);a.frame.slideDown(function(){a.frame.fadeTo(300,1);a.frame.mouseleave(function(){setTimeout(function(){b.remove_notice(a,true)},b.lifespan)})})})}};Chatterbox.Pager.prototype.find_notice=function(a){for(var b in this.notices){if(this.notices[b].options.ref==a){return this.notices[b]}}return null};Chatterbox.Popup=function(b,a){this.manager=b; +this.pview=(this.manager||{view:{find:function(){}}}).view;this.window=null;this.closeb=null;this.options=Object.extend({ref:"popup",title:"Popup",close:true,content:""},(a||{}))};Chatterbox.Popup.prototype.build=function(){var b=this.options;if(this.options.close){b.title+=''}this.pview.append(Chatterbox.render("popup",b));this.window=this.pview.find(".floater."+b.ref);if(this.options.close){this.closeb=this.window.find("a.close");var a=this;this.closeb.click(function(d){a.close();return false})}};Chatterbox.Popup.prototype.close=function(){this.window.remove()};Chatterbox.Popup.Prompt=function(b,a){a=a||{};a=Object.extend({position:[0,0],ref:"prompt",title:"Input",close:false,label:"","default":"","submit-button":"Submit",event:{submit:function(){},cancel:function(){}}},a);Chatterbox.Popup.call(this,b,a);this.data=this.options["default"]};Chatterbox.Popup.Prompt.prototype=new Chatterbox.Popup();Chatterbox.Popup.Prompt.prototype.constructor=Chatterbox.Popup.Prompt; +Chatterbox.Popup.Prompt.prototype.build=function(){this.options.content=Chatterbox.template.prompt.main;Chatterbox.Popup.prototype.build.call(this);this.window.css({left:this.options.position[0],top:this.options.position[1]});var a=this;this.window.find(".button.close").click(function(){a.options.event.cancel(a);a.close();return false});this.window.find(".button.submit").click(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false});this.window.find("form").submit(function(){a.data=a.window.find("input").val();a.options.event.submit(a);a.close();return false})};Chatterbox.Popup.ItemPicker=function(b,a){a=a||{};a=Object.extend({position:[100,60],ref:"item-picker",title:"Items",event:{select:function(d){}}},a);Chatterbox.Popup.call(this,b,a);this.pview=this.pview.find(".chatbook");this.data=this.options["default"];this.pages=[];this.cpage=null};Chatterbox.Popup.ItemPicker.prototype=new Chatterbox.Popup();Chatterbox.Popup.ItemPicker.prototype.constructor=Chatterbox.Popup.ItemPicker; +Chatterbox.Popup.ItemPicker.prototype.build=function(){this.options.content=Chatterbox.render("ip.main",{});Chatterbox.Popup.prototype.build.call(this);this.window.css({right:this.options.position[0],bottom:this.options.position[1]});this.closeb.removeClass("medium");this.pbook=this.window.find("section.pages");this.tabs=this.window.find("section.tabs ul");this.buttons=this.window.find("section.buttons");var d=this;var b=null;for(var a in this.pages){if(!this.pages.hasOwnProperty(a)){continue}b=this.pages[a];b.build();if(a==0){this.select_page(b)}}};Chatterbox.Popup.ItemPicker.prototype.refresh=function(){if(this.cpage==null){return}else{this.cpage.refresh()}};Chatterbox.Popup.ItemPicker.prototype.page=function(b,a){b=b.toLowerCase();for(var d in this.pages){if(!this.pages.hasOwnProperty(d)){continue}if(this.pages[d].name.toLowerCase()==b){return this.pages[d]}}return(a||null)};Chatterbox.Popup.ItemPicker.prototype.add_page=function(a,b){this.pages.push(new (b||Chatterbox.Popup.ItemPicker.Page)(this,a)) +};Chatterbox.Popup.ItemPicker.prototype.add_button=function(a){a=Object.extend({href:"#button",title:"Button",label:"Button"},(a||{}));this.buttons.append(Chatterbox.render("ip.button",a));return this.buttons.find("a[href="+a.href+"]")};Chatterbox.Popup.ItemPicker.prototype.select=function(a){this.options.event.select(a)};Chatterbox.Popup.ItemPicker.prototype.select_page=function(a){if(!a){return}if(this.cpage!=null){this.cpage.hide()}this.cpage=a||null;if(this.cpage!=null){this.cpage.show()}};Chatterbox.Popup.ItemPicker.Page=function(b,a){this.picker=b;this.options=Object.extend({ref:"page",href:"#page",label:"Page",title:"page",items:[],content:"No items on this page.",},(a||{}));this.name=this.options.label;this.nrefresh=true};Chatterbox.Popup.ItemPicker.Page.prototype.build=function(){this.picker.pbook.append(Chatterbox.render("ip.page",this.options));this.picker.tabs.append(Chatterbox.render("ip.tab",this.options));this.view=this.picker.pbook.find("div.page#"+this.options.ref); +this.items=this.view.find("ul");this.tab=this.picker.tabs.find("#"+this.options.ref);this.refresh();var a=this;this.tab.find("a").click(function(){a.picker.select_page(a);return false})};Chatterbox.Popup.ItemPicker.Page.prototype.refresh=function(){var a=this.build_list();if(a.length==0){this.options.content="No items on this page."}else{this.options.content="

                  "+a+"
                "}this.view.html(this.options.content);this.items=this.view.find("ul");this.hook_events();this.nrefresh=false};Chatterbox.Popup.ItemPicker.Page.prototype.hook_events=function(){var a=this;this.items.find("li").each(function(b,f){var g=a.view.find(f);var d=g.find(".value").html();g.click(function(){a.picker.select(d)})})};Chatterbox.Popup.ItemPicker.Page.prototype.build_list=function(){var d=[];var f=null;var h,g,b;for(var a in this.options.items){if(!this.options.items.hasOwnProperty(a)){continue}f=this.options.items[a];g=f.value||f;h=f.title||g;b=f.html||false;d.push('
              • '+(b?g:''+g+"")+"
              • ") +}return d.join("")};Chatterbox.Popup.ItemPicker.Page.prototype.show=function(){this.tab.addClass("selected");this.view.css("display","block");this.refresh()};Chatterbox.Popup.ItemPicker.Page.prototype.hide=function(){this.tab.removeClass("selected");this.view.css("display","none")};Chatterbox.Protocol=function(){this.messages={chatserver:{keys:["version"],template:'** Connected to llama {version} *',global:true},dAmnServer:{keys:["version"],template:'** Connected to dAmnServer {version} *',global:true},login:{keys:["username","e","data"],template:'** Login as {username}: "{e}" *',global:true},join:{keys:["ns","e"],template:'** Join {ns}: "{e}" *',monitor:true},part:{keys:["ns","e","r"],template:'** Part {ns}: "{e}" * {r}',monitor:true},property:{keys:["ns","p","by","ts","value"],template:'** Got {p} for {ns} *',monitor:true},recv_msg:{keys:["user","message"],template:'<{user}>{message}'},recv_action:{keys:["s","user","message"],template:'* {user}{message}'},recv_join:{keys:["user","s","info"],template:'** {user} has joined *',},recv_part:{keys:["user","r"],template:'** {user} has left * {r}'},recv_privchg:{keys:["user","s","by","pc"],template:'** {user} has been made a member of {pc} by {by} *'},recv_kicked:{keys:["user","s","by","r"],template:'** {user} has been kicked by {by} * {r}'},recv_admin_create:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been created by {user} * {privs}'},recv_admin_update:{keys:["p","user","pc","privs"],template:'** Privilege class {pc} has been updated by {user} * {privs}'},recv_admin_rename:{keys:["p","user","prev","pc"],template:'** Privilege class {prev} has been renamed to {pc} by {user} *'},recv_admin_move:{keys:["p","user","prev","pc","affected"],template:'** All members of {prev} have been moved to {pc} by {user} * {affected} affected user(s)'},recv_admin_remove:{keys:["p","user","pc","affected"],template:'** Privilege class {pc} has been removed by {user} * {affected} affected user(s)'},recv_admin_show:null,recv_admin_showverbose:null,recv_admin_privclass:{keys:["p","e","command"],template:'** Admin command "{command}" failed * {e}'},kicked:{keys:["ns","user","r"],template:'** You have been kicked by {user} * {r}'},ping:null,disconnect:{keys:["e"],template:'** You have been disconnected * {e}',global:true},send:{keys:["ns","e"],template:'** Send error: {e}'},kick:{keys:["ns","user","e"],template:'** Could not kick {user} * {e}'},get:{keys:["ns","p","e"],template:'** Could not get {p} info for {ns} * {e}'},set:{keys:["ns","p","e"],template:'** Could not set {p} * {e}'},kill:{keys:["ns","e"],template:'** Kill error * {e}'},unknown:{keys:["ns","packet"],template:'** Received unknown packet in {ns} * {packet}',monitor:true}} };Chatterbox.Protocol.prototype.extend_messages=function(b){for(var a in b){this.messages[a]=b[a]}};Chatterbox.Protocol.prototype.log=function(b){var a=this.messages[b.name];return new Chatterbox.Protocol.LogMessage(b,a)};Chatterbox.Protocol.LogMessage=function(b,a){a=a||{};this.event=b;this.template=a.template||"";this.keys=a.keys||[];this.monitor=a.monitor||false;this.global=a.global||false;this._html=false;this._text=false;this._ansi=false};Chatterbox.Protocol.LogMessage.prototype.text=function(){if(this._text===false){this._text=this.render(0)}return this._text};Chatterbox.Protocol.LogMessage.prototype.html=function(){if(this._html===false){this._html=this.render(1)}return this._html};Chatterbox.Protocol.LogMessage.prototype.ansi=function(){if(this._ansi===false){this._ansi=this.render(2)}return this._ansi};Chatterbox.Protocol.LogMessage.prototype.render=function(f){if(f===undefined){f=0}var b=this.template;var g="";for(var a in this.keys){if(!this.keys.hasOwnProperty(a)){continue}key=this.keys[a]; if(key instanceof Array){key=key[1]}if(!this.event.hasOwnProperty(key)||key=="pkt"){continue}g=this.event[key];if(g==null){continue}if(key=="ns"||key=="sns"){key="ns";g=this.event.sns}if(g.hasOwnProperty("_parser")){switch(f){case 1:g=g.html();break;case 2:g=g.ansi();break;case 0:default:g=g.text();break}}b=replaceAll(b,"{"+key+"}",g)}return b};Chatterbox.Settings=function(b,a){Chatterbox.Popup.call(this,b,{ref:"settings",title:"Settings",close:false,content:""});this.config=a;this.saveb=null;this.scb=null;this.tabs=null;this.book=null;this.changed=false;this.manager=b};Chatterbox.Settings.prototype=new Chatterbox.Popup();Chatterbox.Settings.prototype.constructor=Chatterbox.Settings;Chatterbox.Settings.prototype.build=function(){this.options.content=Chatterbox.template.settings.main;Chatterbox.Popup.prototype.build.call(this);this.saveb=this.window.find("a.button.save");this.closeb=this.window.find("a.close");this.scb=this.window.find("a.button.saveclose");this.tabs=this.window.find("nav.tabs ul.tabs"); this.book=this.window.find("div.book");this.config.build(this.manager,this);this.window.find("ul.tabs li").first().addClass("active");this.window.find("div.book div.page").first().addClass("active");var a=this;this.window.find("form").bind("change",function(){a.changed=true});this.config.each_page(function(b,d){d.each_item(function(f,g){g._onchange=function(h){a.changed=true}})});this.saveb.click(function(b){a.save();return false});this.closeb.click(function(b){if(a.changed){if(!confirm("Are you sure? You will lose any unsaved changes.")){return false}}a.close();return false});this.scb.click(function(b){a.save();a.close();return false});this.resize()};Chatterbox.Settings.prototype.resize=function(){var a=this.window.find(".inner");var d=a.find("h2");var f=a.find(".bookwrap");var b=a.find("footer");f.height(a.height()-b.outerHeight()-d.outerHeight()-15);this.book.height(f.innerHeight()-this.tabs.outerHeight()-25);this.book.width(f.innerWidth()-20);this.config.resize()};Chatterbox.Settings.prototype.switch_page=function(b){var d=this.tabs.find("li.active").first(); diff --git a/src/client.js b/src/client.js index 7069a7b..821e621 100644 --- a/src/client.js +++ b/src/client.js @@ -111,6 +111,8 @@ wsc.Client = function( view, options, mozilla ) { } */ + wsc.defaults.Extension( this ); + // Welcome! //this.monitor(this.settings["welcome"]); @@ -191,7 +193,7 @@ wsc.Client.prototype.config_save = function( ) { wsc.Client.prototype.build = function( ) { //this.ui.build(); - //this.create_ns( this.settings.monitor[0], true, true ); + this.create_ns( this.settings.monitor[0], true, true ); var client = this; /* this.ui.on('tab.close.clicked', function( event, ui ) { diff --git a/src/commands.js b/src/commands.js index 59be663..ab19986 100644 --- a/src/commands.js +++ b/src/commands.js @@ -64,11 +64,13 @@ wsc.defaults.Extension = function( client ) { // lol themes client.bind('cmd.theme', cmd.theme); + /* // some ui business. client.ui.on('settings.open', settings_page); client.ui.on('settings.open.ran', about_page); client.ui.on('settings.save.ui', settings_save); client.ui.on('settings.save', function( ) { client.config_save(); } ); + */ }; var settings_save = function( e, ui ) { @@ -307,7 +309,8 @@ wsc.defaults.Extension = function( client ) { // Say something. cmd.say = function( e ) { - if( client.channel(e.target).monitor ) return; + if( client.channel(e.target).monitor ) + return; client.say( e.target, e.args ); }; @@ -451,20 +454,20 @@ wsc.defaults.Extension = function( client ) { * * @method Ignore */ - wsc.defaults.Extension.Ignore(client); + //wsc.defaults.Extension.Ignore(client); /** * Implements away messages. * * @method Away */ - wsc.defaults.Extension.Away(client); + //wsc.defaults.Extension.Away(client); /** * Implements autojoin channels. * * @method Autojoin */ - wsc.defaults.Extension.Autojoin(client); + //wsc.defaults.Extension.Autojoin(client); }; diff --git a/src/ui/base.js b/src/ui/base.js index 86acd55..b61cd58 100644 --- a/src/ui/base.js +++ b/src/ui/base.js @@ -22,6 +22,8 @@ Chatterbox._gum = function( ) {}; if( ui == undefined ) { ui = new Chatterbox.UI( $(this), client, options, ($.browser.mozilla || false) ); $(window).resize(ui.resize); + setInterval(function( ) { ui.loop(); }, 120000); + ui.build(); } $(window).data('chatterbox', ui); }