This repository has been archived by the owner on May 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathjircs.min.js
2 lines (2 loc) · 34.4 KB
/
jircs.min.js
1
2
function jIRCs(a){this.buf="",this.queue=[],this.displays=[],this.channels={},this.chantypes=[],this.statuses={},this.statusOrder=[],this.statusSymbols={},this.chanModes={},this.userModes=[],this.scrollbackSize=500,this.reconnect_delay=0,this.nickname="",this.password="",this.registered=!1,this.connected=!1,this.account=!1,this.conn_generator=a,this.conn=a(),this.conn.parent=this,this.conn.onopen=function(a){this.parent.onconnect(a)},this.conn.onmessage=function(a){this.parent.onmessage(a)},this.conn.onclose=function(a){this.parent.ondisconnect(a)}}var allCookies={getItem:function(a){return a&&this.hasItem(a)?unescape(document.cookie.replace(RegExp("(?:^|.*;\\s*)"+escape(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1")):null},setItem:function(a,b,c,d,e,f){if(a&&!/^(?:expires|max\-age|path|domain|secure)$/i.test(a)){var g="";if(c)switch(c.constructor){case Number:g=c===1/0?"; expires=Tue, 19 Jan 2038 03:14:07 GMT":"; max-age="+c;break;case String:g="; expires="+c;break;case Date:g="; expires="+c.toGMTString()}document.cookie=escape(a)+"="+escape(b)+g+(e?"; domain="+e:"")+(d?"; path="+d:"")+(f?"; secure":"")}},removeItem:function(a,b){a&&this.hasItem(a)&&(document.cookie=escape(a)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"+(b?"; path="+b:""))},hasItem:function(a){return RegExp("(?:^|;\\s*)"+escape(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},keys:function(){for(var a=document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g,"").split(/\s*(?:\=[^;]*)?;\s*/),b=0;a.length>b;b++)a[b]=unescape(a[b]);return a}};jIRCs.prototype.version="jIRCs 0.1",jIRCs.prototype.nick=function(a,b){a=a.replace(" ","_");while(!this.nick_regex.test(a)&&a)a=a.slice(0,-1);a||(a="Guest"+Math.floor(Math.random()*9e6+1e6)),this.nickname=a,this.password=b,allCookies.setItem("jirc-nickname",a),this.send("CAP",["LS"]),b&&this.send("PASS",[b]),this.send("USER",[a,a,a,":"+a]),this.send("NICK",[a])},window.console||(window.console={log:function(){}}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),Function.prototype.bind||(Function.prototype.bind=function(a){if(typeof this!="function")throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){"use strict";if(this==null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(c===0)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:d!=0&&d!=1/0&&d!=-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),jIRCs.prototype.onconnect=function(){this.setConnected("Connected"),this.forEach(this.queue,this.send,this),this.queue=[]},jIRCs.prototype.ondisconnect=function(){this.forEach(this.channels,function(a,b){b!="Status"&&this.destroyChan(b)},this),this.setConnected("Disconnected"),this.reconnect_delay=15,this.reconnect()},jIRCs.prototype.reconnect=function(){this.reconnect_delay>0?(this.setConnected("Reconnecting in "+this.reconnect_delay+"..."),this.reconnect_delay--,setTimeout(this.reconnect.bind(this),1e3)):(this.setConnected("Reconnecting..."),irc=new jIRCs(this.conn_generator),irc.nick(this.nickname,this.password),this.forEach(this.displays,function(a){a.container.innerHTML="",irc.display(a.container)},this))},jIRCs.prototype.onmessage=function(a){this.buf+=a.data;var b=this.buf.split("\n");this.buf=b.pop(),this.forEach(b,this.parseMessage,this)},jIRCs.prototype.send=function(a,b){var c=a;typeof b=="object"&&(c+=" "+b.join(" ")),this.conn.readyState==1?this.conn.send(c+"\r\n"):this.queue.push(c)},jIRCs.prototype.say=function(a,b){b||(b=this.nickname),this.send("PRIVMSG",[b,":"+a]),this.irc_PRIVMSG(this.nickname,[b,a])},jIRCs.prototype.ctcp_VERSION=function(a){var c=":VERSION "+this.version+"";this.send("NOTICE",[a,c])},jIRCs.prototype.ctcp_TIME=function(a){var c=":TIME "+(new Date+"")+"";this.send("NOTICE",[a,c])},jIRCs.prototype.ctcp_PING=function(a,b){var c=":PING "+b[0]+"";this.send("NOTICE",[a,c])},jIRCs.prototype.display=function(a){if(!a){var b=document.getElementsByTagName("script");a=b[b.length-1].parentNode}var c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("div"),f=document.createElement("div"),g=document.createElement("div"),h=document.createElement("div"),i=document.createElement("div"),j=document.createElement("div"),k=document.createElement("div"),l=document.createElement("div"),m=document.createElement("form"),n=document.createElement("label"),o=document.createElement("input"),p=document.createElement("input"),q=document.createElement("div"),r=document.createElement("span"),s=document.createElement("span"),t=document.createElement("div"),u=document.createElement("a"),v=document.createElement("a"),w=document.createElement("a"),x=document.createElement("img"),y=document.createElement("span"),z=document.createElement("span"),A=document.createElement("span"),B=document.createElement("form"),C=document.createElement("input"),D=document.createElement("input"),E={container:a,tabbar:c,topic:d,auction:e,window:f,chat:g,messages:h,notification:i,userlist:j,inputbar:k,status:l,form:m,name:n,input:o,send:p,status_normal:q,status_connected:r,status_account:s,status_special:t,status_gethelp:u,status_hideulist:v,status_hideauction:w,auction_image:x,auction_title:y,auction_bidder:z,auction_bid:A,auction_form:B,auction_input:C,auction_submit:D,viewing:"",tabs:{},lines:{},widths:{},history:[],options:{show_userlist:!0,show_auction:!0},auction_running:!1,note_timer:!1};a.className="jircs_main",c.className="jircs_tabbar",d.className="jircs_topic",e.className="jircs_auction",f.className="jircs_window",g.className="jircs_chat",h.className="jircs_messages",i.className="jircs_notification",j.className="jircs_userlist",k.className="jircs_inputbar",l.className="jircs_status",m.className="jircs_form",n.className="jircs_name",o.className="jircs_input",p.className="jircs_send",q.className="jircs_status_normal",r.className="jircs_status_connected",s.className="jircs_status_account",t.className="jircs_status_special",u.className="jircs_status_gethelp",v.className="jircs_status_hideulist",w.className="jircs_status_hideauction",x.className="jircs_auction_image",y.className="jircs_auction_title",z.className="jircs_auction_bidder",A.className="jircs_auction_bid",B.className="jircs_auction_form",C.className="jircs_auction_input",D.className="jircs_auction_submit",a.style.overflow="hidden",g.style.display="inline-block",j.style.display="inline-block",m.style.display="inline-block",o.style.display="inline-block",h.style.verticalAlign="top",h.style.overflow="auto",j.style.verticalAlign="top",j.style.overflow="auto",o.type="text",p.type="submit",p.value="Send",q.style.display="inline-block",q.style.width="45%",r.innerHTML=this.connected?"Connected":"Disconnected",s.appendChild(document.createTextNode(this.account?"Logged in as "+this.account:"Not Logged In")),t.style.display="inline-block",t.style.width="54%",t.style.textAlign="right",u.href="#",v.href="#",w.href="#",u.innerHTML="Get Help",v.innerHTML=E.options.show_userlist?"Hide Users":"Show Users",w.innerHTML=E.options.show_auction?"Hide Auction Bar":"Show Auction Bar",e.style.display="none",C.type="text",D.type="submit",D.value="Bid",a.appendChild(c),a.appendChild(d),a.appendChild(e),a.appendChild(f),a.appendChild(k),a.appendChild(l),f.appendChild(g),f.appendChild(j),g.appendChild(h),g.appendChild(i),k.appendChild(m),m.appendChild(n),m.appendChild(o),m.appendChild(p),q.appendChild(r),q.appendChild(document.createTextNode(" | ")),q.appendChild(s),t.appendChild(u),t.appendChild(document.createTextNode(" | ")),t.appendChild(v),t.appendChild(document.createTextNode(" | ")),t.appendChild(w),l.appendChild(q),l.appendChild(t),e.appendChild(x),e.appendChild(y),e.appendChild(z),e.appendChild(A),e.appendChild(B),B.appendChild(C),B.appendChild(D),this.listen(a,"click",this.el_container_click,E),this.listen(a,"mousedown",this.el_container_mousedown,E),this.listen(a,"mouseup",this.el_container_mouseup,E),this.listen(e,"mouseup",this.el_auction_mouseup,E),this.listen(m,"submit",this.el_form_submit,E),this.listen(o,"keydown",this.el_input_keydown,E),this.listen(u,"click",this.el_gethelp_click,E),this.listen(v,"click",this.el_hideulist_click,E),this.listen(w,"click",this.el_hideauction_click,E),this.listen(B,"submit",this.el_auction_form_submit,E),this.initChan("Status",E),this.activateChan("Status",E),this.displays.push(E)},jIRCs.prototype.initChan=function(a,b){var c=document.createElement("span");if(c.className="jircs_tab",c.style.position="relative",c.style.overflow="hidden",c.style.cursor="pointer",c.appendChild(document.createTextNode(a)),this.listen(c,"click",this.el_tab_click,b),a!="Status"){var d=document.createElement("span");d.appendChild(document.createTextNode("X")),this.listen(d,"click",this.el_closebtn_click,b),d.className="jircs_tab_closeBtn",c.appendChild(d)}b.tabbar.appendChild(c),b.tabs[a]=c,b.lines[a]=[]},jIRCs.prototype.destroyChan=function(a){a!="Status"&&a in this.channels&&(a.charAt(0)=="#"&&this.send("PART",[a]),this.forEach(this.displays,function(b){if(b.tabbar.removeChild(b.tabs[a]),delete b.tabs[a],a==b.viewing){var c=b.history.pop();while(c&&!b.tabs[c])c=b.history.pop()||!1;c||(c="Status"),this.activateChan(c,b)}},this),delete this.channels[a])},jIRCs.prototype.activateChan=function(a,b){b.tabs[a]&&b.viewing!=a&&(this.forEach(this.displays,function(c){this.forEach(c.tabs,function(d,e){var f="jircs_tab";c!=b&&d.className.indexOf("jircs_tab_active")!=-1&&(f+=" jircs_tab_active"),e!=a&&(d.className.indexOf("jircs_tab_attention")!=-1&&(f+=" jircs_tab_attention"),d.className.indexOf("jircs_tab_hilight")!=-1&&(f+=" jircs_tab_hilight")),d.className=f},this)},this),b.tabs[a].className+=" jircs_tab_active",b.history.push(b.viewing),b.viewing=a,b.messages.innerHTML="",this.forEach(b.lines[a],function(a){b.messages.appendChild(a.container)},this),this.render(b),b.messages.scrollTop=b.messages.scrollHeight-b.messages.clientHeight)},jIRCs.prototype.render=function(a){var b=4;if(a.topic.innerHTML="",a.viewing in this.channels&&this.channels[a.viewing].topic){var c=document.createElement("p");if(c.style.margin="0",c.appendChild(document.createTextNode(this.channels[a.viewing].topic.message)),c.className="jircs_topic_message",c.innerHTML=this.formatLine(c.innerHTML),a.topic.appendChild(c),this.channels[a.viewing].topic.creator){var d=document.createElement("p");d.style.margin="0";var e="Set by "+this.channels[a.viewing].topic.creator;if(this.channels[a.viewing].topic.time){var f=this.channels[a.viewing].topic.time,g=""+f.getHours(),h=""+f.getMinutes(),i=""+f.getSeconds();e+=" on "+(f.getMonth()+1)+"/"+f.getDate()+"/"+f.getFullYear()+" "+(g.length>1?g:"0"+g)+":"+(h.length>1?h:"0"+h)+":"+(i.length>1?i:"0"+i)}d.appendChild(document.createTextNode(e)),d.className="jircs_topic_creator",a.topic.appendChild(d)}}var j=0,k=0;if(a.viewing in this.channels){a.userlist.innerHTML="";var l={},n="";this.forEach(this.channels[a.viewing].names,function(a,b){a.length&&(a=a.charAt(0)),n=a in this.statuses?this.statuses[a]:"",n in l||(l[n]=[]),l[n].push(a+b)},this),this.forEach(this.statusOrder,function(b){if(b in l){var c=l[b];c.sort(function(a,b){return a.toLowerCase()>b.toLowerCase()?1:b.toLowerCase()>a.toLowerCase()?-1:0}),this.forEach(c,function(b){var c=document.createElement("p");c.style.margin="0",c.style.cursor="pointer",this.listen(c,"click",this.el_userentry_click,a),c.appendChild(document.createTextNode(b)),c.className="jircs_userlist_user",a.userlist.appendChild(c);var d=this.measureText(b,"jircs_userlist_user");j=Math.max(d.width,j),k+=d.height},this)}},this)}a.name.innerHTML="",a.name.appendChild(document.createTextNode(this.nickname+"\u00a0")),a.input.style.width="0px",a.input.style.width=a.inputbar.clientWidth-a.form.offsetWidth-b+"px",a.window.style.height="0px",componentHeight=a.tabbar.offsetHeight+a.topic.offsetHeight+a.auction.offsetHeight+a.window.offsetHeight+a.inputbar.offsetHeight+a.status.offsetHeight,a.window.style.height=a.container.clientHeight-componentHeight+"px",a.userlist.style.width=k>a.window.clientHeight?j+b+this.calculateScrollWidth()+"px":j+b+"px",a.userlist.style.height=a.window.clientHeight+"px",a.chat.style.width=a.window.clientWidth-a.userlist.offsetWidth-b+"px",a.messages.style.height=a.window.clientHeight-a.notification.offsetHeight+"px";var o=0,p=0,q=0,r=0;this.forEach(a.lines[a.viewing],function(a){var b;b=this.measureText(a.time.textContent||a.time.innerText,a.time.className),o=Math.max(b.width,o),b=this.measureText(a.name.textContent||a.name.innerText,a.name.className),p=Math.max(b.width,p)},this),r=a.messages.clientWidth-o-p-b-this.calculateScrollWidth()-this.measureText("","jircs_chatText jircs_action jircs_hilight").width,this.forEach(a.lines[a.viewing],function(a){a.time.style.width=o+"px",a.name.style.width=p+"px",a.message.style.width=r+"px",q+=a.container.offsetHeight},this),a.messages.clientHeight>q+b&&(r=a.messages.clientWidth-o-p-b-this.measureText("","jircs_chatText jircs_action jircs_hilight").width,this.forEach(a.lines[a.viewing],function(a){a.message.style.width=r+"px"},this)),a.viewing in a.widths||(a.widths[a.viewing]={}),a.widths[a.viewing].time=o,a.widths[a.viewing].name=p,a.widths[a.viewing].message=r,a.widths[a.viewing].height=q+b},jIRCs.prototype.renderLine=function(a,b,c,d){a||(a="Status");var e=new Date,f=""+e.getHours(),g=""+e.getMinutes(),h=""+e.getSeconds(),i=document.createElement("div"),j=document.createElement("div"),k=document.createElement("div");i.className="jircs_chatDate",j.className="jircs_chatUser",k.className="jircs_chatText",i.style.display="inline-block",j.style.display="inline-block",k.style.display="inline-block",k.style.wordWrap="break-word",b==""&&(k.className+=" jircs_action"),b==a&&(b="",k.className+=" jircs_event"),i.appendChild(document.createTextNode("["+(f.length>1?f:"0"+f)+":"+(g.length>1?g:"0"+g)+":"+(h.length>1?h:"0"+h)+"]")),j.appendChild(document.createTextNode("\u00a0"+b+"\u00a0")),k.appendChild(document.createTextNode(c));var l=RegExp("\\b"+this.cleanRegex(this.nickname)+"\\b","ig");k.innerHTML=this.formatLine(k.innerHTML);var m={time:this.measureText(i.textContent||i.innerText,i.className).width,name:this.measureText(j.textContent||j.innerText,j.className).width,message:this.measureText(k.textContent||k.innerText,k.className).width};a in this.channels||(this.channels[a]={});var n=[];this.forEach(this.displays,function(a){n.push(a.viewing)},this);var o=this.displays;d&&(o=[d]),this.forEach(o,function(b){b.tabs[a]||this.initChan(a,b),b.viewing in b.widths||(b.widths[b.viewing]={});var d=b.messages.clientHeight>b.messages.scrollHeight||b.messages.scrollTop+b.messages.clientHeight+50>=b.messages.scrollHeight,e=document.createElement("div"),f=i.cloneNode(!0),g=j.cloneNode(!0),h=k.cloneNode(!0);f.style.width=b.widths[b.viewing].time+"px",g.style.width=b.widths[b.viewing].name+"px",h.style.width=b.widths[b.viewing].message+"px",e.className="jircs_chatRow",l.test(c)&&(e.className+=" jircs_hilight"),e.appendChild(f),e.appendChild(g),e.appendChild(h),b.lines[a].push({container:e,time:f,name:g,message:h});while(b.lines[a].length>this.scrollbackSize)b.lines[a].shift();if(b.viewing==a){b.messages.appendChild(e);while(b.messages.children.length>this.scrollbackSize)b.messages.removeChild(b.messages.firstChild);(m.time>b.widths[b.viewing].time||m.name>b.widths[b.viewing].name||m.message>b.widths[b.viewing].message||b.messages.clientHeight>b.widths[b.viewing].height-e.offsetHeight&&b.widths[b.viewing].height+e.offsetHeight>=b.messages.clientHeight)&&this.render(b)}b.widths[b.viewing].height+=e.offsetHeight,d&&(b.messages.scrollTop=b.messages.scrollHeight-b.messages.clientHeight),n.indexOf(a)==-1&&(b.tabs[a].className.indexOf("jircs_tab_attention")==-1&&(b.tabs[a].className+=" jircs_tab_attention"),b.tabs[a].className.indexOf("jircs_tab_hilight")==-1&&l.test(c)&&(b.tabs[a].className+=" jircs_tab_hilight"))},this)},jIRCs.prototype.formatLine=function(a){a=a.replace(this.url_regex,this.linkMunger),a=a.replace(/([>\s])(#[^\s\a,:]+?)([<\s])/gi,'$1<a href="$2" class="jircs_channel_link">$2</a>$3');var b=0,c="",d=!1,e=!1,f=!1,g={foreground:!1,background:!1,tmp:"",state:0,set:!1};return this.forEach(a,function(a){var h=!1,i=!1;if(a=="")d?h=!0:(c+='<span class="jircs_bold">',b+=1),d=!d;else if(a==""){g.foreground||(g.foreground="1"),g.background||(g.background="0");var j=g.foreground;g.foreground=g.background,g.background=j,g.set?(c+="<span>",b+=1):(c+="<span><span>",b+=2),g.set=h=!0}else a==""?(e?h=!0:(c+='<span class="jircs_italic">',b+=1),e=!e):a==""?(f?h=!0:(c+='<span class="jircs_underline">',b+=1),f=!f):a==""?g.state=1:g.state==1?isNaN(parseInt(a))?(g.state=0,g.foreground=g.background=g.set=!1,i=h=!0):(g.tmp+=a,g.state=2):g.state==2?isNaN(parseInt(a))?(g.foreground=g.tmp,g.tmp="",a==","?g.state=3:(g.state=0,i=!0,b+=1,g.set?(c+="<span>",h=!0):(g.set=!0,c+='<span class="jircs_color_foreground_'+parseInt(g.foreground)+'">'))):g.tmp+=a:g.state==3?isNaN(parseInt(a))?(g.tmp&&(g.background=g.tmp),g.tmp="",g.state=0,i=!0,b+=1,g.set?(c+="<span>",h=!0):(g.set=!0,c+='<span class="jircs_color_foreground_'+parseInt(g.foreground)+" jircs_color_background_"+parseInt(g.background)+'">')):g.tmp+=a:a==""?(c+=this.repeat("</span>",b),b=0,d=e=f=g.foreground=g.background=g.set=!1):c+=a;h&&(c+=this.repeat("</span>",b),b-=1,d&&(c+='<span class="jircs_bold">'),e&&(c+='<span class="jircs_italic">'),f&&(c+='<span class="jircs_underline">'),g.foreground&&(c+='<span class="jircs_color_foreground_'+parseInt(g.foreground),g.background&&(c+=" jircs_color_background_"+parseInt(g.background)),c+='">')),i&&(c+=a)},this),c+=this.repeat("</span>",b)},jIRCs.prototype.renderNotification=function(a,b){b.note_timer&&clearTimeout(b.note_timer),b.notification.innerHTML="",b.notification.appendChild(document.createTextNode(a)),this.render(b),b.note_timer=setTimeout(function(){b.notification.innerHTML="",this.render(b),b.note_timer=!1},5e3)},jIRCs.prototype.setConnected=function(a){this.connected=a=="Disconnected",this.forEach(this.displays,function(b){b.status_connected.innerHTML=a,this.render(b)},this)},jIRCs.prototype.setAccount=function(a){this.account=a,this.forEach(this.displays,function(b){b.status_account.innerHTML="",b.status_account.appendChild(document.createTextNode(a?"Logged in as "+a:"Not Logged In")),this.render(b)},this)},jIRCs.prototype.auctionStart=function(a,b){this.forEach(this.displays,function(c){c.auction_running=!0,c.options.show_auction&&(c.auction.style.display="block"),c.auction_image.src="http://desertbus.org/images/prizes_irc/"+a+".png",c.auction_title.innerHTML="",c.auction_title.appendChild(document.createTextNode(b)),this.render(c)},this)},jIRCs.prototype.auctionBid=function(a,b){this.forEach(this.displays,function(c){c.auction_bid.innerHTML="",c.auction_bidder.innerHTML="",c.auction_bid.appendChild(document.createTextNode(a)),c.auction_bidder.appendChild(document.createTextNode(b)),this.render(c)},this)},jIRCs.prototype.auctionStop=function(){this.forEach(this.displays,function(a){a.auction_running=!1,a.auction.style.display="none",this.render(a)},this)},jIRCs.prototype.el_container_click=function(a,b){b.target&&b.target.className=="jircs_channel_link"&&(this.send("JOIN",[b.target.innerHTML]),this.cancelEvent(b))},jIRCs.prototype.el_container_mousedown=function(a,b){a.mouse={x:b.screenX,y:b.screenY}},jIRCs.prototype.el_container_mouseup=function(a,b){if(!("mouse"in a&&"x"in a.mouse&&"y"in a.mouse))return a.input.focus(),void 0;var c=a.mouse.x-b.screenX,d=a.mouse.y-b.screenY;0>c&&(c*=-1),0>d&&(d*=-1),5>c&&5>d&&b.button==0&&a.input.focus()},jIRCs.prototype.el_auction_mouseup=function(a,b){if(!("mouse"in a&&"x"in a.mouse&&"y"in a.mouse))return a.auction_input.focus(),this.cancelEvent(b),void 0;var c=a.mouse.x-b.screenX,d=a.mouse.y-b.screenY;0>c&&(c*=-1),0>d&&(d*=-1),5>c&&5>d&&b.button==0&&(a.auction_input.focus(),this.cancelEvent(b))},jIRCs.prototype.el_form_submit=function(a,b){this.cancelEvent(b),a.input.value&&(this.handleLine(a.input.value,a),a.input.value="")},jIRCs.prototype.el_input_keydown=function(a,b){var c=b.keyCode||b.which;if(c==9){var d=0;if(b.target.createTextRange){var e=document.selection.createRange().duplicate();e.moveEnd("character",b.target.value.length),e.text==""&&(d=b.target.value.length),d=b.target.value.lastIndexOf(e.text)}else d=b.target.selectionStart;var f=b.target.value.lastIndexOf(" ",d)+1,g=b.target.value.indexOf(" ",d);g==-1&&(g=b.target.value.length);var h=b.target.value.substring(f,g),i=[];this.forEach(this.channels[a.viewing].names,function(a,b){b.substring(0,h.length).toLowerCase()==h.toLowerCase()&&i.push(b)},this),i.length==1?h=i[0]:i.length==0?this.renderNotification("No Possible Nicknames",a):this.renderNotification("Possible Nicknames: "+i.join(" "),a),b.target.value=b.target.value.substring(0,f)+h+b.target.value.substr(g),this.cancelEvent(b)}},jIRCs.prototype.el_tab_click=function(a,b){this.activateChan(b.target.firstChild.nodeValue,a)},jIRCs.prototype.el_closebtn_click=function(a,b){this.destroyChan(b.target.parentNode.firstChild.nodeValue)},jIRCs.prototype.el_hideulist_click=function(a,b){this.cancelEvent(b),a.options.show_userlist=!a.options.show_userlist,a.userlist.style.display=a.options.show_userlist?"inline-block":"none",a.status_hideulist.innerHTML=a.options.show_userlist?"Hide Users":"Show Users",this.render(a)},jIRCs.prototype.el_gethelp_click=function(a,b){this.cancelEvent(b),this.send("JOIN",["#help"])},jIRCs.prototype.el_hideauction_click=function(a,b){this.cancelEvent(b),a.options.show_auction=!a.options.show_auction,a.auction.style.display=a.options.show_auction&&a.auction_running?"block":"none",a.status_hideauction.innerHTML=a.options.show_auction?"Hide Auction Bar":"Show Auction Bar",this.render(a)},jIRCs.prototype.el_auction_form_submit=function(a,b){this.cancelEvent(b),a.auction_input.value&&(this.command_BID(a.auction_input.value.split(" "),a),a.auction_input.value="")},jIRCs.prototype.el_userentry_click=function(a,b){var c=b.target.firstChild.nodeValue.toLowerCase();c.charAt(0)in this.statusSymbols&&(c=c.substr(1)),c in this.channels||(this.channels[c]={}),this.initChan(c,a),this.activateChan(c,a)},jIRCs.prototype.irc_PING=function(a,b){this.send("PONG",b)},jIRCs.prototype.irc_NICK=function(a,b){var c=this.getNick(a),d=b.pop();c==this.nickname&&(this.nickname=d,allCookies.setItem("jirc-nickname",this.nickname)),this.forEach(this.channels,function(a,b){a.names&&c in a.names&&(this.renderLine(b,b,c+" is now known as "+d),a.names[d]=a.names[c],delete a.names[c])},this),this.forEach(this.displays,function(a){this.render(a)},this)},jIRCs.prototype.irc_JOIN=function(a,b){var c=b.pop().toLowerCase();a!=this.nickname||this.renderLine(c,c,"You have joined "+c),this.channels[c].names||(this.channels[c].names={}),this.channels[c].names[a]="",this.channels[c].modes||(this.channels[c].modes={},this.send("MODE",[c])),this.forEach(this.displays,function(b){c.charAt(0)=="#"&&a==this.nickname&&this.activateChan(c,b),b.viewing==c&&this.render(b)},this)},jIRCs.prototype.irc_PART=function(a,b){var c=b.shift().toLowerCase();b.pop(),this.getNick(a)==this.nickname?this.destroyChan(c):(delete this.channels[c].names[a],this.forEach(this.displays,function(a){a.viewing==c&&this.render(a)},this))},jIRCs.prototype.irc_QUIT=function(a,b){b.pop(),this.forEach(this.channels,function(b,c){c!="Status"&&b.names&&a in b.names&&delete b.names[a]},this),this.getNick(a)==this.nickname||this.forEach(this.displays,function(a){this.render(a)},this)},jIRCs.prototype.irc_PRIVMSG=function(a,b){var c=b.shift().toLowerCase(),d=b.pop();if(c==this.nickname.toLowerCase()&&(c=a.toLowerCase()),c.charAt(0)in this.statusSymbols&&(a+=":"+c,c=c.substr(1)),d.charAt(0)=="")if(d=d.split("")[1],d.substr(0,6).toUpperCase()=="ACTION")d=a+d.substr(6),a="",this.renderLine(c,a,d);else{b=d.split(" ");var e="ctcp_"+b.shift().toUpperCase();e in this&&this[e](c,b)}else this.renderLine(c,"<"+a+">",d);if(a=="BidServ"){var f=d.replace("","").replace("","").replace("4","").replace("","").replace("","").replace("","").replace("",""),g=f.split(" ");if(g.slice(0,2).join(" ")=="Starting Auction"){var h=g[4].slice(1,-1),i=g.slice(5,-4).join(" ").slice(1,-2);this.auctionStart(h,i)}else if(g.slice(0,3).join(" ")=="Beginning bidding at"){var j=g[3];this.auctionBid(j,"Nobody")}else if(~f.indexOf("has the high bid of")){var k=0;while(g.length-5>k){if(g[k+1]=="has"&&g[k+2]=="the"&&g[k+3]=="high"&&g[k+4]=="bid"&&g[k+5]=="of")break;k++}var l=g[k],m=g[k+6];this.auctionBid(m,l)}else if(~f.indexOf("New highest bid is by")){g=f.substr(f.indexOf("New highest bid is by")).split(" ");var l=g[5],m=g[7];this.auctionBid(m,l)}else g.slice(0,2).join(" ")=="Auction for"&&~f.indexOf("cancelled")?this.auctionStop():g[0]=="Sold!"&&this.auctionStop()}},jIRCs.prototype.irc_NOTICE=function(a,b){var c="\u2013 "+this.getNick(a),d=b.pop(),e=b.shift().toLowerCase();this.chantypes.indexOf(e.charAt(0))!==-1||this.chantypes.indexOf(e.charAt(1))!==-1?(c+=":"+e+" \u2013",e.charAt(0)in this.statusSymbols&&(e=e.substr(1)),this.renderLine(e,c,d)):(c+=" \u2013",this.forEach(this.displays,function(a){this.renderLine(a.viewing,c,d,a)},this)),this.getNick(a)=="NickServ"&&(d.slice(0,33)=="You are now identified. Welcome, "?this.setAccount(d.slice(33,-1)):d.slice(0,22)=="You are now logged out"&&this.setAccount(!1))},jIRCs.prototype.irc_KICK=function(a,b){var c=b.shift().toLowerCase(),d=b.pop();this.renderLine(c,"<"+a+">","4You have been kicked from "+c+" (Reason: "+d+")")},jIRCs.prototype.irc_MODE=function(a,b){var c=b.shift().toLowerCase(),d=b.shift().split("");if(c==this.nickname.toLowerCase()){var e=!0;this.forEach(d,function(a){switch(a){case"+":e=!0;break;case"-":e=!1;break;default:if(e)this.userModes.push(a);else{var b=this.userModes.indexOf(a);b!=-1&&this.userModes.splice(b,1)}}},this)}else this.parseModes(c,d,b)},jIRCs.prototype.irc_CAP=function(a,b){if(b[1]=="LS"){var c=b[2].split(" ");c.indexOf("multi-prefix")!=-1?this.send("CAP",["REQ",":multi-prefix"]):this.registered||this.send("CAP",["END"])}else b[1]!="ACK"||this.registered||this.send("CAP",["END"])},jIRCs.prototype.irc_001=function(){this.registered=!0},jIRCs.prototype.irc_005=function(a,b){b.shift(),b.pop(),this.forEach(b,function(a){if(a.substr(0,7).toUpperCase()=="PREFIX="){var b=a.substr(8).split(")"),c=b[1].split(""),d=b[0].split("");this.statuses=this.zip(c.concat(d),d.concat(c)),this.statusOrder=d,this.statusSymbols=this.zip(c,c),this.statuses[""]="",this.statusOrder.push("")}if(a.substr(0,10)=="CHANMODES="){var b=a.substr(10),e=b.split(",");this.forEach(e,function(a,b){this.forEach(a,function(a){this.chanModes[a]=b},this)},this)}a.substr(0,10)=="CHANTYPES="&&(this.chantypes=a.substr(10).split(""))},this)},jIRCs.prototype.irc_324=function(a,b){b.shift();var c=b.shift().toLowerCase(),d=b.shift().split("");this.channels[c].modes={},this.parseModes(c,d,b)},jIRCs.prototype.irc_353=function(a,b){var c=b[2].toLowerCase();this.channels[c].moreNames||(this.channels[c].names={},this.channels[c].moreNames=!0);var d=b[3].split(" ");this.forEach(d,function(a){var b="";while(a.charAt(0)in this.statusSymbols)b+=a.charAt(0),a=a.substr(1);this.channels[c].names[a]=b},this)},jIRCs.prototype.irc_366=function(a,b){var c=b[1].toLowerCase();this.channels[c].moreNames=!1,this.forEach(this.displays,function(a){a.viewing==c&&this.render(a)},this)},jIRCs.prototype.irc_332=function(a,b){var c=b[1].toLowerCase();this.channels[c].topic||(this.channels[c].topic={}),this.channels[c].topic.message=b[2],this.forEach(this.displays,function(a){a.viewing==c&&this.render(a)},this)},jIRCs.prototype.irc_333=function(a,b){var c=b[1].toLowerCase();this.channels[c].topic||(this.channels[c].topic={}),this.channels[c].topic.creator=b[2],this.channels[c].topic.time=new Date(b[3]*1e3),this.forEach(this.displays,function(a){a.viewing==c&&this.render(a)},this)},jIRCs.prototype.irc_TOPIC=function(a,b){var c=b[0].toLowerCase();this.channels[c].topic||(this.channels[c].topic={}),this.channels[c].topic.creator=a,this.channels[c].topic.time=new Date,this.channels[c].topic.message=b[1],this.forEach(this.displays,function(a){a.viewing==c&&this.render(a)},this)},jIRCs.prototype.irc_433=function(){this.nickname+="_",allCookies.setItem("jirc-nickname",this.nickname),this.send("NICK",[this.nickname])},jIRCs.prototype.irc_unknown=function(a,b){b[0]==this.nickname&&b.shift(),this.renderLine("Status",a,b.join(" "))},jIRCs.prototype.command_NICK=function(a,b){a[0]=a[0].replace(" ","_"),this.nick_regex.test(a[0])?this.send("NICK",a):this.renderNotification(a[0]+" is an invalid nickname. Please try another.",b)},jIRCs.prototype.command_ME=function(a,b){var c="ACTION "+a.join(" ")+"";this.say(c,b.viewing)},jIRCs.prototype.command_CTCP=function(a){var b=a.shift(),c=""+a.join(" ")+"";this.say(c,b)},jIRCs.prototype.command_MSG=function(a){var b=a.shift();this.say(a.join(" "),b)},jIRCs.prototype.command_PART=function(a){var b=a.shift().toLowerCase();this.destroyChan(b)},jIRCs.prototype.command_QUIT=function(a){var b=":"+a.join(" ");this.send("QUIT",[b])},jIRCs.prototype.command_BID=function(a){var c=a[0],d=":"+a.slice(1).join(" ");this.send("BID",[c,d])},jIRCs.prototype.tlds=["AC","AD","AE","AERO","AF","AG","AI","AL","AM","AN","AO","AQ","AR","ARPA","AS","ASIA","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BIZ","BJ","BM","BN","BO","BR","BS","BT","BV","BW","BY","BZ","CA","CAT","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","COM","COOP","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EDU","EE","EG","ER","ES","ET","EU","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GOV","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","INFO","INT","IO","IQ","IR","IS","IT","JE","JM","JO","JOBS","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MG","MH","MIL","MK","ML","MM","MN","MO","MOBI","MP","MQ","MR","MS","MT","MU","MUSEUM","MV","MW","MX","MY","MZ","NA","NAME","NC","NE","NET","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","ORG","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PRO","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","ST","SU","SV","SX","SY","SZ","TC","TD","TEL","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TP","TR","TRAVEL","TT","TV","TW","TZ","UA","UG","UK","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XN--0ZWM56D","XN--11B5BS3A9AJ6G","XN--3E0B707E","XN--45BRJ9C","XN--80AKHBYKNJ4F","XN--80AO21A","XN--90A3AC","XN--9T4B11YI5A","XN--CLCHC0EA0B2G2A9GCD","XN--DEBA0AD","XN--FIQS8S","XN--FIQZ9S","XN--FPCRJ9C3D","XN--FZC2C9E2C","XN--G6W251D","XN--GECRJ9C","XN--H2BRJ9C","XN--HGBK6AJ7F53BBA","XN--HLCJ6AYA9ESC7A","XN--J6W193G","XN--JXALPDLP","XN--KGBECHTV","XN--KPRW13D","XN--KPRY57D","XN--LGBBAT1AD8J","XN--MGBAAM7A8H","XN--MGBAYH7GPA","XN--MGBBH1A71E","XN--MGBC0A9AZCG","XN--MGBERP4A5D4AR","XN--O3CW4H","XN--OGBPF8FL","XN--P1AI","XN--PGBS0DH","XN--S9BRJ9C","XN--WGBH1C","XN--WGBL6A","XN--XKC2AL3HYE2A","XN--XKC2DL3A5EE0H","XN--YFRO4I67O","XN--YGBI2AMMX","XN--ZCKZAH","XXX","YE","YT","ZA","ZM","ZW"].sort(function(a,b){return a.length>b.length?-1:b.length>a.length?1:0}),jIRCs.prototype.url_regex=RegExp("(\\b)(?:(https?|ftp|svn|git)://)?((?:[a-z0-9](?:[a-z0-9\\-]*[a-z0-9])?\\.)+(?:"+jIRCs.prototype.tlds.join("|")+"))(/[^\\s]*[^\\s`!()\\[\\]{};:'\".,<>?\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd])?(\\b)","ig"),jIRCs.prototype.nick_regex=/^[a-zA-Z\[\]\\`_^{}\|][a-zA-Z0-9-\[\]\\`_^{}\|]{0,31}$/,jIRCs.prototype.regex_regex=/[\[\]{}\\\|]/g,jIRCs.prototype.linkMunger=function(a,b,c,d,e,f){var i=a;
return c||(i="http://"+i),b+'<a href="'+i+'" target="_blank">'+a+"</a>"+f},jIRCs.prototype.handleLine=function(a,b){if(a.charAt(0)=="/"){var c=a.substr(1).split(" "),d=c.shift().toUpperCase(),e="command_"+d;e in this?this[e](c,b):this.send(d,c)}else this.say(a,b.viewing)},jIRCs.prototype.parseMessage=function(a){var b="",c="",d="",e=[],f="";if(a=a.trim(),a!=""){if(a.charAt(0)==":"&&(e=a.split(" "),c=e.shift().substr(1).split("!",1)[0],a=e.join(" ")),a.indexOf(" :")!=-1){var g=a.split(" :");e=g.shift().split(" "),f=g.join(" :"),e.push(f)}else e=a.split(" ");d=e.shift(),b="irc_"+d.toUpperCase(),b in this?this[b](c,e):this.irc_unknown(c,e)}},jIRCs.prototype.parseModes=function(a,b,c){var d=!0;this.forEach(b,function(b){switch(b){case"+":d=!0;break;case"-":d=!1;break;default:if(this.statusOrder.indexOf(b)!=-1){var e=c.shift();if(d){var f=this.channels[a].names[e]+this.statuses[b],g="";this.forEach(this.statusOrder,function(a){f.indexOf(this.statuses[a])!=-1&&(g+=this.statuses[a])},this),this.channels[a].names[e]=g}else{var h=this.statuses[b],i=this.channels[a].names[e].indexOf(h);if(i!=-1){var j=this.channels[a].names[e].split("");j.splice(i,1),this.channels[a].names[e]=j.join("")}}this.forEach(this.displays,function(b){b.viewing==a&&this.render(b)},this)}else{var k=this.chanModes[b];if(k==1){var l=c.shift();d?this.channels[a].modes[b]=l:delete this.channels[a].modes[b]}else k==2?d?this.channels[a].modes[b]=c.shift():delete this.channels[a].modes[b]:k==3&&(d?this.channels[a].modes[b]="":delete this.channels[a].modes[b])}}},this)},jIRCs.prototype.getNick=function(a){return a.split("!")[0]},jIRCs.prototype.zip=function(a,b){for(var e,f,c={},d=0;(e=a[d])&&(f=b[d]);d++)c[e]=f;return c},jIRCs.prototype.forEach=function(a,b,c){if(a)if(a.forEach)a.forEach(b,c);else if(a.length)for(var d=0,e=a.length;e>d;++d)b.call(c||a,a[d],d,a);else for(var f in a)a.hasOwnProperty(f)&&b.call(c||a,a[f],f,a);else;},jIRCs.prototype.repeat=function(a,b){if(1>b)return"";var c="";while(b>0)b&1&&(c+=a),b>>=1,a+=a;return c},jIRCs.prototype.measureText=function(a,b){var c=document.createElement("div");return b&&(c.className=b),c.style.position="absolute",c.style.visibility="hidden",c.style.height="auto",c.style.width="auto",c.appendChild(document.createTextNode(a)),document.body.appendChild(c),r={height:c.offsetHeight+2,width:c.offsetWidth+2},document.body.removeChild(c),r},jIRCs.prototype.listen=function(a,b,c,d){var e=this.fixEvent.bind(this,c.bind(this,d));a.addEventListener?a.addEventListener(b,e,!1):a.attachEvent?a.attachEvent("on"+b,e):a["on"+b]=e},jIRCs.prototype.fixEvent=function(a,b){b=b||window.event,b.target||(b.target=b.srcElement),a(b)},jIRCs.prototype.cancelEvent=function(a){a.preventDefault?a.preventDefault():(a.returnValue=!1,a.cancelBubble=!0)},jIRCs.prototype.calculateScrollWidth=function(){var a=document.createElement("div");a.style.width="100px",a.style.height="100px",a.style.overflow="scroll",document.body.appendChild(a);var b=a.offsetWidth-a.clientWidth;return document.body.removeChild(a),b},jIRCs.prototype.cleanRegex=function(a){return a.replace(this.regex_regex,"\\$&")}