-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathscrollback.js
35 lines (27 loc) · 83.1 KB
/
scrollback.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(function() {
/* SockJS client, version 0.3.4, http://sockjs.org, MIT License
Copyright (c) 2011-2012 VMware, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// JSON2 by Douglas Crockford (minified).
var JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g;return e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function f(a){return a<10?"0"+a:a}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver=="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")})}()
var SockJS;SockJS=function(){var a=document,b=window,c={},d=function(){};d.prototype.addEventListener=function(a,b){this._listeners||(this._listeners={}),a in this._listeners||(this._listeners[a]=[]);var d=this._listeners[a];c.arrIndexOf(d,b)===-1&&d.push(b);return},d.prototype.removeEventListener=function(a,b){if(!(this._listeners&&a in this._listeners))return;var d=this._listeners[a],e=c.arrIndexOf(d,b);if(e!==-1){d.length>1?this._listeners[a]=d.slice(0,e).concat(d.slice(e+1)):delete this._listeners[a];return}return},d.prototype.dispatchEvent=function(a){var b=a.type,c=Array.prototype.slice.call(arguments,0);this["on"+b]&&this["on"+b].apply(this,c);if(this._listeners&&b in this._listeners)for(var d=0;d<this._listeners[b].length;d++)this._listeners[b][d].apply(this,c)};var e=function(a,b){this.type=a;if(typeof b!="undefined")for(var c in b){if(!b.hasOwnProperty(c))continue;this[c]=b[c]}};e.prototype.toString=function(){var a=[];for(var b in this){if(!this.hasOwnProperty(b))continue;var c=this[b];typeof c=="function"&&(c="[function]"),a.push(b+"="+c)}return"SimpleEvent("+a.join(", ")+")"};var f=function(a){var b=this;b._events=a||[],b._listeners={}};f.prototype.emit=function(a){var b=this;b._verifyType(a);if(b._nuked)return;var c=Array.prototype.slice.call(arguments,1);b["on"+a]&&b["on"+a].apply(b,c);if(a in b._listeners)for(var d=0;d<b._listeners[a].length;d++)b._listeners[a][d].apply(b,c)},f.prototype.on=function(a,b){var c=this;c._verifyType(a);if(c._nuked)return;a in c._listeners||(c._listeners[a]=[]),c._listeners[a].push(b)},f.prototype._verifyType=function(a){var b=this;c.arrIndexOf(b._events,a)===-1&&c.log("Event "+JSON.stringify(a)+" not listed "+JSON.stringify(b._events)+" in "+b)},f.prototype.nuke=function(){var a=this;a._nuked=!0;for(var b=0;b<a._events.length;b++)delete a[a._events[b]];a._listeners={}};var g="abcdefghijklmnopqrstuvwxyz0123456789_";c.random_string=function(a,b){b=b||g.length;var c,d=[];for(c=0;c<a;c++)d.push(g.substr(Math.floor(Math.random()*b),1));return d.join("")},c.random_number=function(a){return Math.floor(Math.random()*a)},c.random_number_string=function(a){var b=(""+(a-1)).length,d=Array(b+1).join("0");return(d+c.random_number(a)).slice(-b)},c.getOrigin=function(a){a+="/";var b=a.split("/").slice(0,3);return b.join("/")},c.isSameOriginUrl=function(a,c){return c||(c=b.location.href),a.split("/").slice(0,3).join("/")===c.split("/").slice(0,3).join("/")},c.getParentDomain=function(a){if(/^[0-9.]*$/.test(a))return a;if(/^\[/.test(a))return a;if(!/[.]/.test(a))return a;var b=a.split(".").slice(1);return b.join(".")},c.objectExtend=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a};var h="_jp";c.polluteGlobalNamespace=function(){h in b||(b[h]={})},c.closeFrame=function(a,b){return"c"+JSON.stringify([a,b])},c.userSetCode=function(a){return a===1e3||a>=3e3&&a<=4999},c.countRTO=function(a){var b;return a>100?b=3*a:b=a+200,b},c.log=function(){b.console&&console.log&&console.log.apply&&console.log.apply(console,arguments)},c.bind=function(a,b){return a.bind?a.bind(b):function(){return a.apply(b,arguments)}},c.flatUrl=function(a){return a.indexOf("?")===-1&&a.indexOf("#")===-1},c.amendUrl=function(b){var d=a.location;if(!b)throw new Error("Wrong url for SockJS");if(!c.flatUrl(b))throw new Error("Only basic urls are supported in SockJS");return b.indexOf("//")===0&&(b=d.protocol+b),b.indexOf("/")===0&&(b=d.protocol+"//"+d.host+b),b=b.replace(/[/]+$/,""),b},c.arrIndexOf=function(a,b){for(var c=0;c<a.length;c++)if(a[c]===b)return c;return-1},c.arrSkip=function(a,b){var d=c.arrIndexOf(a,b);if(d===-1)return a.slice();var e=a.slice(0,d);return e.concat(a.slice(d+1))},c.isArray=Array.isArray||function(a){return{}.toString.call(a).indexOf("Array")>=0},c.delay=function(a,b){return typeof a=="function"&&(b=a,a=0),setTimeout(b,a)};var i=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,j={"\0":"\\u0000","\x01":"\\u0001","\x02":"\\u0002","\x03":"\\u0003","\x04":"\\u0004","\x05":"\\u0005","\x06":"\\u0006","\x07":"\\u0007","\b":"\\b","\t":"\\t","\n":"\\n","\x0b":"\\u000b","\f":"\\f","\r":"\\r","\x0e":"\\u000e","\x0f":"\\u000f","\x10":"\\u0010","\x11":"\\u0011","\x12":"\\u0012","\x13":"\\u0013","\x14":"\\u0014","\x15":"\\u0015","\x16":"\\u0016","\x17":"\\u0017","\x18":"\\u0018","\x19":"\\u0019","\x1a":"\\u001a","\x1b":"\\u001b","\x1c":"\\u001c","\x1d":"\\u001d","\x1e":"\\u001e","\x1f":"\\u001f",'"':'\\"',"\\":"\\\\","\x7f":"\\u007f","\x80":"\\u0080","\x81":"\\u0081","\x82":"\\u0082","\x83":"\\u0083","\x84":"\\u0084","\x85":"\\u0085","\x86":"\\u0086","\x87":"\\u0087","\x88":"\\u0088","\x89":"\\u0089","\x8a":"\\u008a","\x8b":"\\u008b","\x8c":"\\u008c","\x8d":"\\u008d","\x8e":"\\u008e","\x8f":"\\u008f","\x90":"\\u0090","\x91":"\\u0091","\x92":"\\u0092","\x93":"\\u0093","\x94":"\\u0094","\x95":"\\u0095","\x96":"\\u0096","\x97":"\\u0097","\x98":"\\u0098","\x99":"\\u0099","\x9a":"\\u009a","\x9b":"\\u009b","\x9c":"\\u009c","\x9d":"\\u009d","\x9e":"\\u009e","\x9f":"\\u009f","\xad":"\\u00ad","\u0600":"\\u0600","\u0601":"\\u0601","\u0602":"\\u0602","\u0603":"\\u0603","\u0604":"\\u0604","\u070f":"\\u070f","\u17b4":"\\u17b4","\u17b5":"\\u17b5","\u200c":"\\u200c","\u200d":"\\u200d","\u200e":"\\u200e","\u200f":"\\u200f","\u2028":"\\u2028","\u2029":"\\u2029","\u202a":"\\u202a","\u202b":"\\u202b","\u202c":"\\u202c","\u202d":"\\u202d","\u202e":"\\u202e","\u202f":"\\u202f","\u2060":"\\u2060","\u2061":"\\u2061","\u2062":"\\u2062","\u2063":"\\u2063","\u2064":"\\u2064","\u2065":"\\u2065","\u2066":"\\u2066","\u2067":"\\u2067","\u2068":"\\u2068","\u2069":"\\u2069","\u206a":"\\u206a","\u206b":"\\u206b","\u206c":"\\u206c","\u206d":"\\u206d","\u206e":"\\u206e","\u206f":"\\u206f","\ufeff":"\\ufeff","\ufff0":"\\ufff0","\ufff1":"\\ufff1","\ufff2":"\\ufff2","\ufff3":"\\ufff3","\ufff4":"\\ufff4","\ufff5":"\\ufff5","\ufff6":"\\ufff6","\ufff7":"\\ufff7","\ufff8":"\\ufff8","\ufff9":"\\ufff9","\ufffa":"\\ufffa","\ufffb":"\\ufffb","\ufffc":"\\ufffc","\ufffd":"\\ufffd","\ufffe":"\\ufffe","\uffff":"\\uffff"},k=/[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e\ufff0-\uffff]/g,l,m=JSON&&JSON.stringify||function(a){return i.lastIndex=0,i.test(a)&&(a=a.replace(i,function(a){return j[a]})),'"'+a+'"'},n=function(a){var b,c={},d=[];for(b=0;b<65536;b++)d.push(String.fromCharCode(b));return a.lastIndex=0,d.join("").replace(a,function(a){return c[a]="\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4),""}),a.lastIndex=0,c};c.quote=function(a){var b=m(a);return k.lastIndex=0,k.test(b)?(l||(l=n(k)),b.replace(k,function(a){return l[a]})):b};var o=["websocket","xdr-streaming","xhr-streaming","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"];c.probeProtocols=function(){var a={};for(var b=0;b<o.length;b++){var c=o[b];a[c]=y[c]&&y[c].enabled()}return a},c.detectProtocols=function(a,b,c){var d={},e=[];b||(b=o);for(var f=0;f<b.length;f++){var g=b[f];d[g]=a[g]}var h=function(a){var b=a.shift();d[b]?e.push(b):a.length>0&&h(a)};return c.websocket!==!1&&h(["websocket"]),d["xhr-streaming"]&&!c.null_origin?e.push("xhr-streaming"):d["xdr-streaming"]&&!c.cookie_needed&&!c.null_origin?e.push("xdr-streaming"):h(["iframe-eventsource","iframe-htmlfile"]),d["xhr-polling"]&&!c.null_origin?e.push("xhr-polling"):d["xdr-polling"]&&!c.cookie_needed&&!c.null_origin?e.push("xdr-polling"):h(["iframe-xhr-polling","jsonp-polling"]),e};var p="_sockjs_global";c.createHook=function(){var a="a"+c.random_string(8);if(!(p in b)){var d={};b[p]=function(a){return a in d||(d[a]={id:a,del:function(){delete d[a]}}),d[a]}}return b[p](a)},c.attachMessage=function(a){c.attachEvent("message",a)},c.attachEvent=function(c,d){typeof b.addEventListener!="undefined"?b.addEventListener(c,d,!1):(a.attachEvent("on"+c,d),b.attachEvent("on"+c,d))},c.detachMessage=function(a){c.detachEvent("message",a)},c.detachEvent=function(c,d){typeof b.addEventListener!="undefined"?b.removeEventListener(c,d,!1):(a.detachEvent("on"+c,d),b.detachEvent("on"+c,d))};var q={},r=!1,s=function(){for(var a in q)q[a](),delete q[a]},t=function(){if(r)return;r=!0,s()};c.attachEvent("unload",t),c.unload_add=function(a){var b=c.random_string(8);return q[b]=a,r&&c.delay(s),b},c.unload_del=function(a){a in q&&delete q[a]},c.createIframe=function(b,d){var e=a.createElement("iframe"),f,g,h=function(){clearTimeout(f);try{e.onload=null}catch(a){}e.onerror=null},i=function(){e&&(h(),setTimeout(function(){e&&e.parentNode.removeChild(e),e=null},0),c.unload_del(g))},j=function(a){e&&(i(),d(a))},k=function(a,b){try{e&&e.contentWindow&&e.contentWindow.postMessage(a,b)}catch(c){}};return e.src=b,e.style.display="none",e.style.position="absolute",e.onerror=function(){j("onerror")},e.onload=function(){clearTimeout(f),f=setTimeout(function(){j("onload timeout")},2e3)},a.body.appendChild(e),f=setTimeout(function(){j("timeout")},15e3),g=c.unload_add(i),{post:k,cleanup:i,loaded:h}},c.createHtmlfile=function(a,d){var e=new ActiveXObject("htmlfile"),f,g,i,j=function(){clearTimeout(f)},k=function(){e&&(j(),c.unload_del(g),i.parentNode.removeChild(i),i=e=null,CollectGarbage())},l=function(a){e&&(k(),d(a))},m=function(a,b){try{i&&i.contentWindow&&i.contentWindow.postMessage(a,b)}catch(c){}};e.open(),e.write('<html><script>document.domain="'+document.domain+'";'+"</s"+"cript></html>"),e.close(),e.parentWindow[h]=b[h];var n=e.createElement("div");return e.body.appendChild(n),i=e.createElement("iframe"),n.appendChild(i),i.src=a,f=setTimeout(function(){l("timeout")},15e3),g=c.unload_add(k),{post:m,cleanup:k,loaded:j}};var u=function(){};u.prototype=new f(["chunk","finish"]),u.prototype._start=function(a,d,e,f){var g=this;try{g.xhr=new XMLHttpRequest}catch(h){}if(!g.xhr)try{g.xhr=new b.ActiveXObject("Microsoft.XMLHTTP")}catch(h){}if(b.ActiveXObject||b.XDomainRequest)d+=(d.indexOf("?")===-1?"?":"&")+"t="+ +(new Date);g.unload_ref=c.unload_add(function(){g._cleanup(!0)});try{g.xhr.open(a,d,!0)}catch(i){g.emit("finish",0,""),g._cleanup();return}if(!f||!f.no_credentials)g.xhr.withCredentials="true";if(f&&f.headers)for(var j in f.headers)g.xhr.setRequestHeader(j,f.headers[j]);g.xhr.onreadystatechange=function(){if(g.xhr){var a=g.xhr;switch(a.readyState){case 3:try{var b=a.status,c=a.responseText}catch(a){}b===1223&&(b=204),c&&c.length>0&&g.emit("chunk",b,c);break;case 4:var b=a.status;b===1223&&(b=204),g.emit("finish",b,a.responseText),g._cleanup(!1)}}},g.xhr.send(e)},u.prototype._cleanup=function(a){var b=this;if(!b.xhr)return;c.unload_del(b.unload_ref),b.xhr.onreadystatechange=function(){};if(a)try{b.xhr.abort()}catch(d){}b.unload_ref=b.xhr=null},u.prototype.close=function(){var a=this;a.nuke(),a._cleanup(!0)};var v=c.XHRCorsObject=function(){var a=this,b=arguments;c.delay(function(){a._start.apply(a,b)})};v.prototype=new u;var w=c.XHRLocalObject=function(a,b,d){var e=this;c.delay(function(){e._start(a,b,d,{no_credentials:!0})})};w.prototype=new u;var x=c.XDRObject=function(a,b,d){var e=this;c.delay(function(){e._start(a,b,d)})};x.prototype=new f(["chunk","finish"]),x.prototype._start=function(a,b,d){var e=this,f=new XDomainRequest;b+=(b.indexOf("?")===-1?"?":"&")+"t="+ +(new Date);var g=f.ontimeout=f.onerror=function(){e.emit("finish",0,""),e._cleanup(!1)};f.onprogress=function(){e.emit("chunk",200,f.responseText)},f.onload=function(){e.emit("finish",200,f.responseText),e._cleanup(!1)},e.xdr=f,e.unload_ref=c.unload_add(function(){e._cleanup(!0)});try{e.xdr.open(a,b),e.xdr.send(d)}catch(h){g()}},x.prototype._cleanup=function(a){var b=this;if(!b.xdr)return;c.unload_del(b.unload_ref),b.xdr.ontimeout=b.xdr.onerror=b.xdr.onprogress=b.xdr.onload=null;if(a)try{b.xdr.abort()}catch(d){}b.unload_ref=b.xdr=null},x.prototype.close=function(){var a=this;a.nuke(),a._cleanup(!0)},c.isXHRCorsCapable=function(){return b.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?1:b.XDomainRequest&&a.domain?2:L.enabled()?3:4};var y=function(a,d,e){if(this===b)return new y(a,d,e);var f=this,g;f._options={devel:!1,debug:!1,protocols_whitelist:[],info:undefined,rtt:undefined},e&&c.objectExtend(f._options,e),f._base_url=c.amendUrl(a),f._server=f._options.server||c.random_number_string(1e3),f._options.protocols_whitelist&&f._options.protocols_whitelist.length?g=f._options.protocols_whitelist:(typeof d=="string"&&d.length>0?g=[d]:c.isArray(d)?g=d:g=null,g&&f._debug('Deprecated API: Use "protocols_whitelist" option instead of supplying protocol list as a second parameter to SockJS constructor.')),f._protocols=[],f.protocol=null,f.readyState=y.CONNECTING,f._ir=S(f._base_url),f._ir.onfinish=function(a,b){f._ir=null,a?(f._options.info&&(a=c.objectExtend(a,f._options.info)),f._options.rtt&&(b=f._options.rtt),f._applyInfo(a,b,g),f._didClose()):f._didClose(1002,"Can't connect to server",!0)}};y.prototype=new d,y.version="0.3.4",y.CONNECTING=0,y.OPEN=1,y.CLOSING=2,y.CLOSED=3,y.prototype._debug=function(){this._options.debug&&c.log.apply(c,arguments)},y.prototype._dispatchOpen=function(){var a=this;a.readyState===y.CONNECTING?(a._transport_tref&&(clearTimeout(a._transport_tref),a._transport_tref=null),a.readyState=y.OPEN,a.dispatchEvent(new e("open"))):a._didClose(1006,"Server lost session")},y.prototype._dispatchMessage=function(a){var b=this;if(b.readyState!==y.OPEN)return;b.dispatchEvent(new e("message",{data:a}))},y.prototype._dispatchHeartbeat=function(a){var b=this;if(b.readyState!==y.OPEN)return;b.dispatchEvent(new e("heartbeat",{}))},y.prototype._didClose=function(a,b,d){var f=this;if(f.readyState!==y.CONNECTING&&f.readyState!==y.OPEN&&f.readyState!==y.CLOSING)throw new Error("INVALID_STATE_ERR");f._ir&&(f._ir.nuke(),f._ir=null),f._transport&&(f._transport.doCleanup(),f._transport=null);var g=new e("close",{code:a,reason:b,wasClean:c.userSetCode(a)});if(!c.userSetCode(a)&&f.readyState===y.CONNECTING&&!d){if(f._try_next_protocol(g))return;g=new e("close",{code:2e3,reason:"All transports failed",wasClean:!1,last_event:g})}f.readyState=y.CLOSED,c.delay(function(){f.dispatchEvent(g)})},y.prototype._didMessage=function(a){var b=this,c=a.slice(0,1);switch(c){case"o":b._dispatchOpen();break;case"a":var d=JSON.parse(a.slice(1)||"[]");for(var e=0;e<d.length;e++)b._dispatchMessage(d[e]);break;case"m":var d=JSON.parse(a.slice(1)||"null");b._dispatchMessage(d);break;case"c":var d=JSON.parse(a.slice(1)||"[]");b._didClose(d[0],d[1]);break;case"h":b._dispatchHeartbeat()}},y.prototype._try_next_protocol=function(b){var d=this;d.protocol&&(d._debug("Closed transport:",d.protocol,""+b),d.protocol=null),d._transport_tref&&(clearTimeout(d._transport_tref),d._transport_tref=null);for(;;){var e=d.protocol=d._protocols.shift();if(!e)return!1;if(y[e]&&y[e].need_body===!0&&(!a.body||typeof a.readyState!="undefined"&&a.readyState!=="complete"))return d._protocols.unshift(e),d.protocol="waiting-for-load",c.attachEvent("load",function(){d._try_next_protocol()}),!0;if(!!y[e]&&!!y[e].enabled(d._options)){var f=y[e].roundTrips||1,g=(d._options.rto||0)*f||5e3;d._transport_tref=c.delay(g,function(){d.readyState===y.CONNECTING&&d._didClose(2007,"Transport timeouted")});var h=c.random_string(8),i=d._base_url+"/"+d._server+"/"+h;return d._debug("Opening transport:",e," url:"+i," RTO:"+d._options.rto),d._transport=new y[e](d,i,d._base_url),!0}d._debug("Skipping transport:",e)}},y.prototype.close=function(a,b){var d=this;if(a&&!c.userSetCode(a))throw new Error("INVALID_ACCESS_ERR");return d.readyState!==y.CONNECTING&&d.readyState!==y.OPEN?!1:(d.readyState=y.CLOSING,d._didClose(a||1e3,b||"Normal closure"),!0)},y.prototype.send=function(a){var b=this;if(b.readyState===y.CONNECTING)throw new Error("INVALID_STATE_ERR");return b.readyState===y.OPEN&&b._transport.doSend(c.quote(""+a)),!0},y.prototype._applyInfo=function(b,d,e){var f=this;f._options.info=b,f._options.rtt=d,f._options.rto=c.countRTO(d),f._options.info.null_origin=!a.domain;var g=c.probeProtocols();f._protocols=c.detectProtocols(g,e,b)};var z=y.websocket=function(a,d){var e=this,f=d+"/websocket";f.slice(0,5)==="https"?f="wss"+f.slice(5):f="ws"+f.slice(4),e.ri=a,e.url=f;var g=b.WebSocket||b.MozWebSocket;e.ws=new g(e.url),e.ws.onmessage=function(a){e.ri._didMessage(a.data)},e.unload_ref=c.unload_add(function(){e.ws.close()}),e.ws.onclose=function(){e.ri._didMessage(c.closeFrame(1006,"WebSocket connection broken"))}};z.prototype.doSend=function(a){this.ws.send("["+a+"]")},z.prototype.doCleanup=function(){var a=this,b=a.ws;b&&(b.onmessage=b.onclose=null,b.close(),c.unload_del(a.unload_ref),a.unload_ref=a.ri=a.ws=null)},z.enabled=function(){return!!b.WebSocket||!!b.MozWebSocket},z.roundTrips=2;var A=function(){};A.prototype.send_constructor=function(a){var b=this;b.send_buffer=[],b.sender=a},A.prototype.doSend=function(a){var b=this;b.send_buffer.push(a),b.send_stop||b.send_schedule()},A.prototype.send_schedule_wait=function(){var a=this,b;a.send_stop=function(){a.send_stop=null,clearTimeout(b)},b=c.delay(25,function(){a.send_stop=null,a.send_schedule()})},A.prototype.send_schedule=function(){var a=this;if(a.send_buffer.length>0){var b="["+a.send_buffer.join(",")+"]";a.send_stop=a.sender(a.trans_url,b,function(b,c){a.send_stop=null,b===!1?a.ri._didClose(1006,"Sending error "+c):a.send_schedule_wait()}),a.send_buffer=[]}},A.prototype.send_destructor=function(){var a=this;a._send_stop&&a._send_stop(),a._send_stop=null};var B=function(b,d,e){var f=this;if(!("_send_form"in f)){var g=f._send_form=a.createElement("form"),h=f._send_area=a.createElement("textarea");h.name="d",g.style.display="none",g.style.position="absolute",g.method="POST",g.enctype="application/x-www-form-urlencoded",g.acceptCharset="UTF-8",g.appendChild(h),a.body.appendChild(g)}var g=f._send_form,h=f._send_area,i="a"+c.random_string(8);g.target=i,g.action=b+"/jsonp_send?i="+i;var j;try{j=a.createElement('<iframe name="'+i+'">')}catch(k){j=a.createElement("iframe"),j.name=i}j.id=i,g.appendChild(j),j.style.display="none";try{h.value=d}catch(l){c.log("Your browser is seriously broken. Go home! "+l.message)}g.submit();var m=function(a){if(!j.onerror)return;j.onreadystatechange=j.onerror=j.onload=null,c.delay(500,function(){j.parentNode.removeChild(j),j=null}),h.value="",e(!0)};return j.onerror=j.onload=m,j.onreadystatechange=function(a){j.readyState=="complete"&&m()},m},C=function(a){return function(b,c,d){var e=new a("POST",b+"/xhr_send",c);return e.onfinish=function(a,b){d(a===200||a===204,"http status "+a)},function(a){d(!1,a)}}},D=function(b,d){var e,f=a.createElement("script"),g,h=function(a){g&&(g.parentNode.removeChild(g),g=null),f&&(clearTimeout(e),f.parentNode.removeChild(f),f.onreadystatechange=f.onerror=f.onload=f.onclick=null,f=null,d(a),d=null)},i=!1,j=null;f.id="a"+c.random_string(8),f.src=b,f.type="text/javascript",f.charset="UTF-8",f.onerror=function(a){j||(j=setTimeout(function(){i||h(c.closeFrame(1006,"JSONP script loaded abnormally (onerror)"))},1e3))},f.onload=function(a){h(c.closeFrame(1006,"JSONP script loaded abnormally (onload)"))},f.onreadystatechange=function(a){if(/loaded|closed/.test(f.readyState)){if(f&&f.htmlFor&&f.onclick){i=!0;try{f.onclick()}catch(b){}}f&&h(c.closeFrame(1006,"JSONP script loaded abnormally (onreadystatechange)"))}};if(typeof f.async=="undefined"&&a.attachEvent)if(!/opera/i.test(navigator.userAgent)){try{f.htmlFor=f.id,f.event="onclick"}catch(k){}f.async=!0}else g=a.createElement("script"),g.text="try{var a = document.getElementById('"+f.id+"'); if(a)a.onerror();}catch(x){};",f.async=g.async=!1;typeof f.async!="undefined"&&(f.async=!0),e=setTimeout(function(){h(c.closeFrame(1006,"JSONP script loaded abnormally (timeout)"))},35e3);var l=a.getElementsByTagName("head")[0];return l.insertBefore(f,l.firstChild),g&&l.insertBefore(g,l.firstChild),h},E=y["jsonp-polling"]=function(a,b){c.polluteGlobalNamespace();var d=this;d.ri=a,d.trans_url=b,d.send_constructor(B),d._schedule_recv()};E.prototype=new A,E.prototype._schedule_recv=function(){var a=this,b=function(b){a._recv_stop=null,b&&(a._is_closing||a.ri._didMessage(b)),a._is_closing||a._schedule_recv()};a._recv_stop=F(a.trans_url+"/jsonp",D,b)},E.enabled=function(){return!0},E.need_body=!0,E.prototype.doCleanup=function(){var a=this;a._is_closing=!0,a._recv_stop&&a._recv_stop(),a.ri=a._recv_stop=null,a.send_destructor()};var F=function(a,d,e){var f="a"+c.random_string(6),g=a+"?c="+escape(h+"."+f),i=0,j=function(a){switch(i){case 0:delete b[h][f],e(a);break;case 1:e(a),i=2;break;case 2:delete b[h][f]}},k=d(g,j);b[h][f]=k;var l=function(){b[h][f]&&(i=1,b[h][f](c.closeFrame(1e3,"JSONP user aborted read")))};return l},G=function(){};G.prototype=new A,G.prototype.run=function(a,b,c,d,e){var f=this;f.ri=a,f.trans_url=b,f.send_constructor(C(e)),f.poll=new $(a,d,b+c,e)},G.prototype.doCleanup=function(){var a=this;a.poll&&(a.poll.abort(),a.poll=null)};var H=y["xhr-streaming"]=function(a,b){this.run(a,b,"/xhr_streaming",bd,c.XHRCorsObject)};H.prototype=new G,H.enabled=function(){return b.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest&&!/opera/i.test(navigator.userAgent)},H.roundTrips=2,H.need_body=!0;var I=y["xdr-streaming"]=function(a,b){this.run(a,b,"/xhr_streaming",bd,c.XDRObject)};I.prototype=new G,I.enabled=function(){return!!b.XDomainRequest},I.roundTrips=2;var J=y["xhr-polling"]=function(a,b){this.run(a,b,"/xhr",bd,c.XHRCorsObject)};J.prototype=new G,J.enabled=H.enabled,J.roundTrips=2;var K=y["xdr-polling"]=function(a,b){this.run(a,b,"/xhr",bd,c.XDRObject)};K.prototype=new G,K.enabled=I.enabled,K.roundTrips=2;var L=function(){};L.prototype.i_constructor=function(a,b,d){var e=this;e.ri=a,e.origin=c.getOrigin(d),e.base_url=d,e.trans_url=b;var f=d+"/iframe.html";e.ri._options.devel&&(f+="?t="+ +(new Date)),e.window_id=c.random_string(8),f+="#"+e.window_id,e.iframeObj=c.createIframe(f,function(a){e.ri._didClose(1006,"Unable to load an iframe ("+a+")")}),e.onmessage_cb=c.bind(e.onmessage,e),c.attachMessage(e.onmessage_cb)},L.prototype.doCleanup=function(){var a=this;if(a.iframeObj){c.detachMessage(a.onmessage_cb);try{a.iframeObj.iframe.contentWindow&&a.postMessage("c")}catch(b){}a.iframeObj.cleanup(),a.iframeObj=null,a.onmessage_cb=a.iframeObj=null}},L.prototype.onmessage=function(a){var b=this;if(a.origin!==b.origin)return;var c=a.data.slice(0,8),d=a.data.slice(8,9),e=a.data.slice(9);if(c!==b.window_id)return;switch(d){case"s":b.iframeObj.loaded(),b.postMessage("s",JSON.stringify([y.version,b.protocol,b.trans_url,b.base_url]));break;case"t":b.ri._didMessage(e)}},L.prototype.postMessage=function(a,b){var c=this;c.iframeObj.post(c.window_id+a+(b||""),c.origin)},L.prototype.doSend=function(a){this.postMessage("m",a)},L.enabled=function(){var a=navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Konqueror")!==-1;return(typeof b.postMessage=="function"||typeof b.postMessage=="object")&&!a};var M,N=function(a,d){parent!==b?parent.postMessage(M+a+(d||""),"*"):c.log("Can't postMessage, no parent window.",a,d)},O=function(){};O.prototype._didClose=function(a,b){N("t",c.closeFrame(a,b))},O.prototype._didMessage=function(a){N("t",a)},O.prototype._doSend=function(a){this._transport.doSend(a)},O.prototype._doCleanup=function(){this._transport.doCleanup()},c.parent_origin=undefined,y.bootstrap_iframe=function(){var d;M=a.location.hash.slice(1);var e=function(a){if(a.source!==parent)return;typeof c.parent_origin=="undefined"&&(c.parent_origin=a.origin);if(a.origin!==c.parent_origin)return;var e=a.data.slice(0,8),f=a.data.slice(8,9),g=a.data.slice(9);if(e!==M)return;switch(f){case"s":var h=JSON.parse(g),i=h[0],j=h[1],k=h[2],l=h[3];i!==y.version&&c.log('Incompatibile SockJS! Main site uses: "'+i+'", the iframe:'+' "'+y.version+'".');if(!c.flatUrl(k)||!c.flatUrl(l)){c.log("Only basic urls are supported in SockJS");return}if(!c.isSameOriginUrl(k)||!c.isSameOriginUrl(l)){c.log("Can't connect to different domain from within an iframe. ("+JSON.stringify([b.location.href,k,l])+")");return}d=new O,d._transport=new O[j](d,k,l);break;case"m":d._doSend(g);break;case"c":d&&d._doCleanup(),d=null}};c.attachMessage(e),N("s")};var P=function(a,b){var d=this;c.delay(function(){d.doXhr(a,b)})};P.prototype=new f(["finish"]),P.prototype.doXhr=function(a,b){var d=this,e=(new Date).getTime(),f=new b("GET",a+"/info"),g=c.delay(8e3,function(){f.ontimeout()});f.onfinish=function(a,b){clearTimeout(g),g=null;if(a===200){var c=(new Date).getTime()-e,f=JSON.parse(b);typeof f!="object"&&(f={}),d.emit("finish",f,c)}else d.emit("finish")},f.ontimeout=function(){f.close(),d.emit("finish")}};var Q=function(b){var d=this,e=function(){var a=new L;a.protocol="w-iframe-info-receiver";var c=function(b){if(typeof b=="string"&&b.substr(0,1)==="m"){var c=JSON.parse(b.substr(1)),e=c[0],f=c[1];d.emit("finish",e,f)}else d.emit("finish");a.doCleanup(),a=null},e={_options:{},_didClose:c,_didMessage:c};a.i_constructor(e,b,b)};a.body?e():c.attachEvent("load",e)};Q.prototype=new f(["finish"]);var R=function(){var a=this;c.delay(function(){a.emit("finish",{},2e3)})};R.prototype=new f(["finish"]);var S=function(a){if(c.isSameOriginUrl(a))return new P(a,c.XHRLocalObject);switch(c.isXHRCorsCapable()){case 1:return new P(a,c.XHRLocalObject);case 2:return new P(a,c.XDRObject);case 3:return new Q(a);default:return new R}},T=O["w-iframe-info-receiver"]=function(a,b,d){var e=new P(d,c.XHRLocalObject);e.onfinish=function(b,c){a._didMessage("m"+JSON.stringify([b,c])),a._didClose()}};T.prototype.doCleanup=function(){};var U=y["iframe-eventsource"]=function(){var a=this;a.protocol="w-iframe-eventsource",a.i_constructor.apply(a,arguments)};U.prototype=new L,U.enabled=function(){return"EventSource"in b&&L.enabled()},U.need_body=!0,U.roundTrips=3;var V=O["w-iframe-eventsource"]=function(a,b){this.run(a,b,"/eventsource",_,c.XHRLocalObject)};V.prototype=new G;var W=y["iframe-xhr-polling"]=function(){var a=this;a.protocol="w-iframe-xhr-polling",a.i_constructor.apply(a,arguments)};W.prototype=new L,W.enabled=function(){return b.XMLHttpRequest&&L.enabled()},W.need_body=!0,W.roundTrips=3;var X=O["w-iframe-xhr-polling"]=function(a,b){this.run(a,b,"/xhr",bd,c.XHRLocalObject)};X.prototype=new G;var Y=y["iframe-htmlfile"]=function(){var a=this;a.protocol="w-iframe-htmlfile",a.i_constructor.apply(a,arguments)};Y.prototype=new L,Y.enabled=function(){return L.enabled()},Y.need_body=!0,Y.roundTrips=3;var Z=O["w-iframe-htmlfile"]=function(a,b){this.run(a,b,"/htmlfile",bc,c.XHRLocalObject)};Z.prototype=new G;var $=function(a,b,c,d){var e=this;e.ri=a,e.Receiver=b,e.recv_url=c,e.AjaxObject=d,e._scheduleRecv()};$.prototype._scheduleRecv=function(){var a=this,b=a.poll=new a.Receiver(a.recv_url,a.AjaxObject),c=0;b.onmessage=function(b){c+=1,a.ri._didMessage(b.data)},b.onclose=function(c){a.poll=b=b.onmessage=b.onclose=null,a.poll_is_closing||(c.reason==="permanent"?a.ri._didClose(1006,"Polling error ("+c.reason+")"):a._scheduleRecv())}},$.prototype.abort=function(){var a=this;a.poll_is_closing=!0,a.poll&&a.poll.abort()};var _=function(a){var b=this,d=new EventSource(a);d.onmessage=function(a){b.dispatchEvent(new e("message",{data:unescape(a.data)}))},b.es_close=d.onerror=function(a,f){var g=f?"user":d.readyState!==2?"network":"permanent";b.es_close=d.onmessage=d.onerror=null,d.close(),d=null,c.delay(200,function(){b.dispatchEvent(new e("close",{reason:g}))})}};_.prototype=new d,_.prototype.abort=function(){var a=this;a.es_close&&a.es_close({},!0)};var ba,bb=function(){if(ba===undefined)if("ActiveXObject"in b)try{ba=!!(new ActiveXObject("htmlfile"))}catch(a){}else ba=!1;return ba},bc=function(a){var d=this;c.polluteGlobalNamespace(),d.id="a"+c.random_string(6,26),a+=(a.indexOf("?")===-1?"?":"&")+"c="+escape(h+"."+d.id);var f=bb()?c.createHtmlfile:c.createIframe,g;b[h][d.id]={start:function(){g.loaded()},message:function(a){d.dispatchEvent(new e("message",{data:a}))},stop:function(){d.iframe_close({},"network")}},d.iframe_close=function(a,c){g.cleanup(),d.iframe_close=g=null,delete b[h][d.id],d.dispatchEvent(new e("close",{reason:c}))},g=f(a,function(a){d.iframe_close({},"permanent")})};bc.prototype=new d,bc.prototype.abort=function(){var a=this;a.iframe_close&&a.iframe_close({},"user")};var bd=function(a,b){var c=this,d=0;c.xo=new b("POST",a,null),c.xo.onchunk=function(a,b){if(a!==200)return;for(;;){var f=b.slice(d),g=f.indexOf("\n");if(g===-1)break;d+=g+1;var h=f.slice(0,g);c.dispatchEvent(new e("message",{data:h}))}},c.xo.onfinish=function(a,b){c.xo.onchunk(a,b),c.xo=null;var d=a===200?"network":"permanent";c.dispatchEvent(new e("close",{reason:d}))}};return bd.prototype=new d,bd.prototype.abort=function(){var a=this;a.xo&&(a.xo.close(),a.dispatchEvent(new e("close",{reason:"user"})),a.xo=null)},y.getUtils=function(){return c},y.getIframeTransport=function(){return L},y}(),"_sockjs_onload"in window&&setTimeout(_sockjs_onload,1),typeof define=="function"&&define.amd&&define("sockjs",[],function(){return SockJS})
;
"use strict";function guid(a){var b,c="";for(a=a||32,b=0;a>b;b++)c+=(36*Math.random()|0).toString(36);return c}function offset(a){for(var b=0,c=0;a;)b+=a.offsetLeft,c+=a.offsetTop,a=a.offsetParent;return[b,c]}function regex(a){try{return new RegExp("(\\s+|^)"+a.replace(/\W/g,function(a){return"\\"+a})+"(\\s+|$)","g")}catch(b){return null}}function hasClass(a,b){return regex(b).test(a.className)}function removeClass(a,b){a.className=a.className.replace(regex(b)," ")}function addClass(a,b){removeClass(a,b),a.className=a.className+" "+b}function prettyDate(a,b){var c=new Date(parseInt(a,10)),d=new Date(b),e=(d.getTime()-c.getTime())/864e5,f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],g=["January","February","March","April","May","June","July","August","September","October","November","December"],h="";return e>6?(h+=g[c.getMonth()]+" "+c.getDate(),h=(c.getFullYear()!==d.getFullYear()?c.getFullYear()+" ":"")+h):h=h||e>1?f[c.getDay()]:c.getDay()!=d.getDay()?"yesterday":"",h+" at "+c.getHours()+":"+(c.getMinutes()<10?"0":"")+c.getMinutes()}function addEvent(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&(a["e"+b+c]=c,a[b+c]=function(){return a["e"+b+c](addEvent.fixEvent(window.event))},a.attachEvent("on"+b,a[b+c]))}function removeEvent(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&(a.detachEvent("on"+b,a[b+c]),a[b+c]=null,a["e"+b+c]=null)}function get(a,b){request("GET",a,b)}function post(a,b,c){request("POST",a,c,b)}function getx(a,b){var c,d=document.createElement("script"),e="c";for(c=0;6>c;c++)e+=Math.floor(256*Math.random()).toString(16);window[e]=function(a){try{delete window[e]}catch(c){window[e]=null}try{a=JSON.parse(a),b(null,a)}catch(c){b(null,a)}},a=a+(-1==a.indexOf("?")?"?":"&")+"callback="+e,document.body.appendChild(d),d.src=a,addEvent(d,"load",function(){document.body.removeChild(d)})}function request(a,b,c,d){var e=createXMLHTTPObject();return e?(e.open(a,b,!0),d&&(e.setRequestHeader("Content-type","application/json"),"object"==typeof d&&(d=JSON.stringify(d))),e.onreadystatechange=function(){var a;if(4==e.readyState){if(200!=e.status&&304!=e.status)return void c("http-"+e.status);try{a=JSON.parse(e.responseText)}catch(b){return void(a=e.responseText)}c(null,a)}},void(4!=e.readyState&&e.send(d))):void setTimeout(function(){c("no-xmlhttp-object")},0)}function createXMLHTTPObject(){for(var a=!1,b=0;b<XMLHttpFactories.length;b++){try{a=XMLHttpFactories[b]()}catch(c){continue}break}return a}function messageArray(a){function b(a,c,d){var f;return"undefined"==typeof c?b(a,0,e.length):a?c>=d?c:(f=(c+d)/2|0,e[f]&&e[f].time<a?b(a,f+1,d):e[f-1]&&e[f-1].time>=a?b(a,c,f-1):f):d}function c(a){if(a.length){for(var c=a[0].time,d=a[a.length-1].time,f=b(c),g=b(d);e[f-1]&&e[f-1].time==c;)f--;for(;e[g]&&e[g].time==d;)g++;e[f-1]&&"result-end"!=e[f-1].type&&"result-start"==a[0].type&&a.shift(),e[g]&&"result-start"!=e[g].type&&"result-end"==a[a.length-1].type&&a.pop(),[].splice.apply(e,[f,g-f].concat(a))}}function d(a,c,d,f){var g,h,i,j,k=[],l=e.length,m=null;for(!a&&f&&(k.push(f(null,null)),a=1e13),g=b(a),h=g,i=0;h>0&&c>i;h--)e[h]&&"text"==e[h].type&&i++;for(i=0;l>h&&c+d+1>i;h++)switch(j=e[h],j.type){case"result-start":f&&k.push(f(m,j.time));break;case"result-end":m=j.time;break;case"text":k.push(j),i++}return j&&"result-end"==j.type&&f&&k.push(f(j.time,null)),k}var e=a||[];return e.merge=c,e.find=b,e.extract=d,e}function sanitizeRoomName(a){return a=a.trim(),a=a.replace(/[^a-zA-Z0-9]/g,"-").replace(/^-+|-+$/,""),a.length<3&&(a+=Array(3-a.length+1).join("-")),a}function onInit(a){nick=a.user.id,core.membership=a.user.membership,core.emit("membership",a.user.membership),core.emit("nick",nick),a.serverTime&&a.clientTime&&(core.emit("connected"),timeAdjustment=a.serverTime-a.clientTime,scrollback.debug&&console.log(a),scrollback.streams&&scrollback.streams.length&&scrollback.streams.forEach(function(a){a&&core.enter(a)}))}function send(a,b,c,d,e){var f,g={id:guid(),type:a,from:nick,to:b,text:c||"",time:core.time()};if(g.origin={gateway:"web",location:window.location.toString()},d)for(f in d)d.hasOwnProperty(f)&&(g[f]=d[f]);return"result-start"!=g.type&&"result-end"!=g.type&&1==socket.readyState&&socket.emit("message",g),"undefined"!=typeof messageArray&&rooms[b]&&(rooms[b].messages.push(g),f=rooms[b].messages.length-1,requests[b+"//"]&&requests[b+"//"](!0)),pendingCallbacks[g.id]=function(a){a.message&&"undefined"!=typeof messageArray&&rooms[b]&&(rooms[b].messages.splice(f,1),requests[b+"//"]&&requests[b+"//"](!0)),e&&e(a)},setTimeout(function(){pendingCallbacks[g.id]&&delete pendingCallbacks[g.id]},1e4),g}function onMessages(a){var b=a.query.to,c=a.query.to+"/"+(a.query.since||"")+"/"+(a.query.until||"");rooms[b].messages.merge(a.messages),requests[c]&&(requests[c](!0),c!=a.query.to+"//"&&delete requests[c])}function onMessage(a){var b,c,d=!1;if(scrollback.debug&&console.log("Received:",a),core.emit("message",a),"nick"==a.type&&a.from==core.nick()&&core.nick(a.ref),pendingCallbacks[a.id]&&(pendingCallbacks[a.id](a),delete pendingCallbacks[a.id]),c=rooms[a.to]&&rooms[a.to].messages){for(b=c.length-1;b>=0&&a.time-c[b].time<12e4;b--)if(c[b].id==a.id){scrollback.debug&&console.log("Time adjustment is now "+timeAdjustment),c[b]=a,d=!0;break}d||c.push(a),requests[a.to+"//"]&&requests[a.to+"//"](!0)}}function onError(a){a.id&&pendingCallbacks[a.id]&&(pendingCallbacks[a.id](a),delete pendingCallbacks[a.id]),core.emit("error",a.message)}Object.keys||(Object.keys=function(a){if("object"!=typeof a&&"function"!=typeof a||null===a)throw new TypeError("Object.keys called on non-object");var b,c=[];for(b in a)a.hasOwnProperty(b)&&c.push(b);return c}),"function"!=typeof Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b}),Array.prototype.remove||(Array.prototype.remove=function(a){var b=this.indexOf(a);return-1!==b?this.splice(b,1):void 0}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=this.length,c=Number(arguments[1])||0;for(c=0>c?Math.ceil(c):Math.floor(c),0>c&&(c+=b);b>c;c++)if(c in this&&this[c]===a)return c;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){for(var c=0,d=this.length;d>c;++c)a.call(b,this[c],c,this)}),Array.prototype.map||(Array.prototype.map=function(a,b){for(var c=[],d=0,e=this.length;e>d;++d)c.push(a.call(b,this[d],d,this));return c}),window.console||(window.console={log:function(){}}),addEvent.fixEvent=function(a){return a.preventDefault=addEvent.preventDefault,a.stopPropagation=addEvent.stopPropagation,a},addEvent.preventDefault=function(){this.returnValue=!1},addEvent.stopPropagation=function(){this.cancelBubble=!0};var emitter={handlers:{},emit:function(a,b){this.handlers.hasOwnProperty(a)&&this.handlers[a].forEach(function(a){setTimeout(function(){a(b)},0)})},on:function(a,b){this.handlers.hasOwnProperty(a)?this.handlers[a].push(b):this.handlers[a]=[b]},off:function(a,b){this.handlers.hasOwnProperty(a)&&this.handlers.remove(b)}},XMLHttpFactories=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],socket=new SockJS(scrollback.host+"/socket"),timeAdjustment=0,rooms={},requests={},lastPos,core=Object.create(emitter),nick="",user,pendingCallbacks={};window.scrollback.streams&&(window.scrollback.streams=window.scrollback.streams.map(function(a){return sanitizeRoomName(a)})),window.scrollback.nick&&(window.scrollback.nick=sanitizeRoomName(window.scrollback.nick)),socket.emit=function(a,b){scrollback.debug&&console.log("Socket sending ",a,b),socket.send(JSON.stringify({type:a,data:b}))},socket.onopen=function(){function a(a){var b={sid:a,clientTime:(new Date).getTime()};scrollback.nick&&(b.nick=scrollback.nick),socket.emit("init",b)}getx(scrollback.host+"/dlg/cookie",function(b,c){b||a(c)})},socket.onerror=function(a){scrollback.debug&&console.log(a)},socket.onclose=function(){var a;for(a in rooms)rooms.hasOwnProperty(a)&&core.leave(a);core.emit("disconnected")},socket.onmessage=function(a){var b;try{b=JSON.parse(a.data)}catch(c){return void(scrollback.debug&&console.log("ERROR: Non-JSON data",a.data))}switch(scrollback.debug&&console.log("Socket received",b),b.type){case"init":onInit(b.data);break;case"message":onMessage(b.data);break;case"messages":onMessages(b.data);break;case"error":onError(b.data)}},core.cache=function(a){return rooms[a].messages},core.time=function(){return(new Date).getTime()+timeAdjustment},core.enter=function(a){rooms[a]||(rooms[a]={messages:messageArray()}),send("result-start",a),send("back",a),core.emit("enter",a)},core.leave=function(a){send("away",a),send("result-end",a),core.emit("leave",a)},core.get=function(a,b,c,d){var e,f={to:a,type:"text"};b&&(f.since=b),c&&(f.until=c),e=a+"/"+(f.since||"")+"/"+(f.until||""),scrollback.debug&&console.log("Request:",e),requests[e]=d,socket.emit("messages",f)},core.say=function(a,b,c){send("text",a,b,{},c)},core.join=function(a,b){send(a,b)},core.nick=function(a,b){return a?("string"==typeof a&&(a={ref:a}),b?void send("nick","","",a,function(a){return a.ref&&(nick=a.ref,core.emit("nick",nick)),b?b(a):void 0}):(nick=a.ref,core.emit("nick",nick),a)):nick},core.watch=function(a,b,c,d,e){function f(b,c){return core.get(a,b,c,g),{type:"missing",text:"Loading messages...",time:b}}function g(g){var h=rooms[a].messages.extract(b,c||32,d||0,g?null:f);e(h)}b||(requests[a+"//"]=g),g(!1)},core.unwatch=function(a){delete requests[a+"//"]},core.update=function(a,b){scrollback.debug&&console.log("sending update"),socket.emit("update",{type:a,params:b})};;
"use strict";function domReady(){if(!isReady&&(isReady=!0,readyList)){for(var a=0;a<readyList.length;a++)readyList[a].call(window,[]);readyList=[]}}function addLoadEvent(a){var b=window.onload;window.onload="function"!=typeof window.onload?a:function(){b&&b(),a()}}function bindReady(){if(!readyBound){if(readyBound=!0,document.addEventListener&&!browser.opera&&document.addEventListener("DOMContentLoaded",domReady,!1),browser.msie&&window==top&&function(){if(!isReady){try{document.documentElement.doScroll("left")}catch(a){return void setTimeout(arguments.callee,0)}domReady()}}(),browser.opera&&document.addEventListener("DOMContentLoaded",function(){if(!isReady){for(var a=0;a<document.styleSheets.length;a++)if(document.styleSheets[a].disabled)return void setTimeout(arguments.callee,0);domReady()}},!1),browser.safari){var a;!function(){if(!isReady){if("loaded"!=document.readyState&&"complete"!=document.readyState)return void setTimeout(arguments.callee,0);if(void 0===a){for(var b=document.getElementsByTagName("link"),c=0;c<b.length;c++)"stylesheet"==b[c].getAttribute("rel")&&a++;var d=document.getElementsByTagName("style");a+=d.length}return document.styleSheets.length!=a?void setTimeout(arguments.callee,0):void domReady()}}()}addLoadEvent(domReady)}}function getByClass(a,b){var c,d,e,f,g=[];if(a.getElementsByClassName)return[].slice.apply(a.getElementsByClassName(b));if(a.querySelectorAll)for(c=a.querySelectorAll("."+b),e=0,f=c.length;f>e;e++)g.push(c[e]);else if(a.evaluate)for(d=".//*[contains(concat(' ', @class, ' '), ' "+b+" ')]",c=a.evaluate(d,a,null,0,null);e=c.iterateNext();)g.push(e);else for(c=a.getElementsByTagName("*"),d=new RegExp("(^|\\s)"+b+"(\\s|$)"),e=0;e<c.length;e++)d.test(c[e].className)&&g.push(c[e]);return g}function init(){addStyles(css),addStyles(scrollback.theme&&themes[scrollback.theme]?themes[scrollback.theme]:themes.light),addEvent(window,"resize",Stream.position),scrollback&&scrollback.streams&&scrollback.streams.forEach(function(a){var b=Stream.get(a);b.initialized||(scrollback.minimized===!1?b.show():b.hide())})}function partMembership(a,b){b.membershipHidden||(b.membershipHidden=a),-1==core.membership.indexOf(b.id)&&(addClass(a,"scrollback-hidden"),b.membershipHidden=a),addEvent(a,"click",function(a){a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),core.join("part",b.id)}),core.on("message",function(c){"part"===c.type&&c.to===b.id&&a!=b.membershipHidden&&core.nick()==c.from&&(addHiddenClass(a,b),core.membership.splice(core.membership.indexOf(b.id),1))}),core.on("membership",function(){-1==core.membership.indexOf(b.id)&&a!=b.membershipHidden&&addHiddenClass(a,b)})}function joinMembership(a,b){-1!=core.membership.indexOf(b.id)&&addHiddenClass(a,b),addEvent(a,"click",function(a){return a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),0==core.nick().indexOf("guest-")?void login():void core.join("join",b.id)}),core.on("message",function(c){"join"==c.type&&c.to==b.id&&a!=b.membershipHidden&&core.nick()==c.from&&(addHiddenClass(a,b),core.membership.push(b.id))}),core.on("membership",function(){-1!=core.membership.indexOf(b.id)&&a!=b.membershipHidden&&addHiddenClass(a,b)})}function addHiddenClass(a,b){addClass(a,"scrollback-hidden"),removeClass(b.membershipHidden,"scrollback-hidden"),b.membershipHidden=a}function Stream(a){var b=this;b.id=a,b.stream=JsonML.parse(dom.stream,function(c){switch(!0){case hasClass(c,"scrollback-log"):b.log=c,addEvent(c,"scroll",function(){b.scroll()});break;case hasClass(c,"scrollback-nick-guest")||hasClass(c,"scrollback-nick"):b.nick=c,0!==core.nick().indexOf("guest-")?(removeClass(c,"scrollback-nick-guest"),addClass(c,"scrollback-nick"),c.innerHTML=core.nick()):c.innerHTML=core.nick().substr(6),addEvent(c,"click",function(){0===core.nick().indexOf("guest-")?login():profile()});break;case hasClass(c,"scrollback-text"):b.text=c,addEvent(c,"focus",function(){this.select()}),addEvent(c,"keydown",function(a){return 13==a.keyCode?(b.send(),!1):!0});break;case hasClass(c,"scrollback-send"):b.sendfrm=c,addEvent(c,"submit",function(a){return a.preventDefault&&a.preventDefault(),b.send(),!1});break;case hasClass(c,"scrollback-tread"):b.tread=c;break;case hasClass(c,"scrollback-thumb"):b.thumb=c;break;case hasClass(c,"scrollback-title"):b.title=c,addEvent(c,"click",function(){b.toggle()});break;case hasClass(c,"scrollback-title-id"):c.innerHTML=scrollback.title||a;break;case hasClass(c,"scrollback-title-text"):b.titleText=c;break;case hasClass(c,"scrollback-title-close"):addEvent(c,"click",function(){b.close()});break;case hasClass(c,"scrollback-icon-pop"):addEvent(c,"click",function(){b.pop()});break;case hasClass(c,"scrollback-alert"):b.alert=c;break;case hasClass(c,"scrollback-icon-login"):addEvent(c,"click",function(a){return login(),a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),!1});break;case hasClass(c,"scrollback-icon-part"):partMembership(c,b);break;case hasClass(c,"scrollback-icon-join"):joinMembership(c,b)}return c}),b.requested={},addEvent(b.stream,"click",function(){b.select()}),document.body.appendChild(b.stream)}function login(a){a=a||{},a.requireAuth&&Stream.text&&Stream.prevText&&(Stream.text.value=Stream.prevText,delete Stream.text,delete Stream.prevText),dialog.show("/dlg/login"+(a.requireAuth?"?requireAuth=1":"")+"#"+core.nick(),function(a){var b;a&&(a.assertion?b={browserid:a.assertion}:a.guestname&&(b="guest-"+a.guestname),b&&core.nick(b,function(a){scrollback.debug&&console.log(a.message),a.message?("AUTH_UNREGISTERED"==a.message&&(scrollback.debug&&console.log("calling profile...."),profile()),dialog.send("error",a.message)):dialog.hide()}))})}function profile(){dialog.show("/dlg/profile",function(a){return a?a.guestname?void core.nick(a.guestname,function(){dialog.hide()}):void core.nick({user:a},function(a){a.message?dialog.send("error",a.message):dialog.hide()}):void dialog.hide()})}function hashColor(a){function b(a){var b,c,d=7;for(a=a.toLowerCase().replace(/[^a-z0-9]+/g," ").replace(/^\s+/g,"").replace(/\s+$/g,""),b=0,c=a.length;c>b;b++)d=(31*d+479*a.charCodeAt(b))%1531;return d%1530}function c(a){function b(a){var b=a.toString(16);return b=1==b.length?"0"+b:b}function c(a,c,d){return"#"+b(a)+b(c)+b(d)}return 255>a?c(255,a,0):510>a?c(255-(a-255),255,0):765>a?c(0,255,a-510):1020>a?c(0,255-(a-765),255):1275>a?c(a-1020,0,255):c(255,0,255-(a-1275))}return a?(a=a.toLowerCase().replace(/[^a-z0-9]+/g," ").replace(/^\s+/g,"").replace(/\s+$/g,""),c(b(a))):"#999"}var setStyle=function(a,b){if("object"==typeof b){for(var c in b)if(b.hasOwnProperty(c))try{a.style[c]=b[c]}catch(d){}}else"undefined"!=typeof a.style.cssText?a.style.cssText=b:a.style=b},addStyles=function(a){function b(a,b){var c,d,e="";if(a=a.replace(/([A-Z]?)([a-z]*)/g,function(a,b,c){if(b)return"-"+b.toLowerCase()+c;switch(c){case"webkit":case"moz":case"ms":case"o":return"-"+c;default:return c}}),"object"==typeof b&&(d=b.length))for(c=0;d>c;c++)e+=a+":"+b[c]+"; ";else e+=a+":"+b+"; ";return e}var c,d,e="";if("object"==typeof a){for(d in a)if(a.hasOwnProperty(d)){e+=d+" { ";for(c in a[d])a[d].hasOwnProperty(c)&&(e+=b(c,a[d][c]));e+=" } "}}else e=a;var f=document.createElement("style");return document.getElementsByTagName("head")[0].appendChild(f),f.styleSheet?f.styleSheet.cssText=e:f.appendChild(document.createTextNode(e)),f},themes={},css={".scrollback-hidden":{position:"absolute",visibility:"hidden"},".scrollback-stream":{position:"fixed",width:"480px",height:"480px",bottom:"0px",boxShadow:"0px 0px 8px 0 rgba(0,0,0,0.5)",boxSizing:"border-box",webkitBoxSizing:"border-box",mozBoxSizing:"border-box",msBoxSizing:"border-box",oBoxSizing:"border-box",fontSize:"13px",lineHeight:"14px",transition:"height 0.2s ease-out",webkitTransition:"height 0.2s ease-out",mozTransition:"height 0.2s ease-out",oTransition:"height 0.2s ease-out",msTransition:"height 0.2s ease-out",overflow:"hidden"},".scrollback-stream-hidden":{height:"44px !important"},".scrollback-alert":{backgroundColor:"#3CA",color:"#fff",width:"100%",position:"absolute",top:"44px",zIndex:"9998",transition:"all 0.2s ease-out",webkitTransition:"all 0.2s ease-out",mozTransition:"all 0.2s ease-out",oTransition:"all 0.2s ease-out",msTransition:"all 0.2s ease-out",fontSize:"13px",lineHeight:"24px",padding:"0px 16px",height:"24px"},".scrollback-alert-hidden":{height:"0px",top:"0px",zIndex:9996},".scrollback-stream-hidden .scrollback-title-text":{display:"inline"},".scrollback-stream-hidden .scrollback-title-id, .scrollback-stream-hidden .scrollback-icon-login, .scrollback-stream-hidden .scrollback-icon-logout":{display:"none"},".scrollback-stream-right .scrollback-title":{"text-align":"right"},".scrollback-stream-right.scrollback-stream-hidden .scrollback-title-text":{display:"none"},".scrollback-icon":{top:"0",margin:"0 0px",width:"40px",height:"40px",cursor:"pointer",zIndex:2,fontWeight:"bold",lineHeight:"40px",textIndent:"-9999px",backgroundRepeat:"no-repeat",backgroundPosition:"center center","float":"right"},".scrollback-icon.scrollback-icon-menu":{"float":"left"},".scrollback-title":{height:"40px",lineHeight:"40px",boxSizing:"content-box",webkitBoxSizing:"content-box",mozBoxSizing:"content-box",msBoxSizing:"content-box",oBoxSizing:"content-box",left:"0px",right:"0px",position:"absolute",fontWeight:"bold",borderBottom:"4px solid transparent",zIndex:9997,top:"0",cursor:"default"},".scrollback-title-content":{padding:"0 2px",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"},".scrollback-title-text":{paddingLeft:"8px",fontWeight:"normal",display:"none"},".scrollback-log":{boxSizing:"border-box",webkitBoxSizing:"border-box",mozBoxSizing:"border-box",msBoxSizing:"border-box",oBoxSizing:"border-box",position:"absolute",top:"44px",bottom:"41px",left:"0",right:"0",overflowY:"auto",overflowX:"hidden"},".scrollback-message":{overflow:"hidden",padding:"2px 24px 2px 48px",textIndent:"-32px",borderLeft:"4px solid transparent",opacity:1,height:"auto",cursor:"default"},".scrollback-message.scrollback-message-mentioned .scrollback-message-content":{color:"#c00"},".scrollback-message-hidden":{opacity:0,height:0,transition:"all 1s ease-out",webkitTransition:"all 1s ease-out",mozTransition:"all 1s ease-out",oTransition:"all 1s ease-out",msTransition:"all 1s ease-out"},".scrollback-timestamp-hidden .scrollback-message-timestamp":{display:"none"},".scrollback-message-timestamp":{display:"block",textAlign:"right",marginRight:"-16px"},".scrollback-timeline":{position:"absolute",top:"44px",right:"0",width:"18px",bottom:"41px",zIndex:9996},".scrollback-tread":{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1},".scrollback-tread-row":{position:"absolute",height:"2px",right:"0",transition:"all .2s linear",webkitTransition:"all 0.2s linear",mozTransition:"all 0.2s linear",oTransition:"all 0.2s linear",msTransition:"all 0.2s linear"},".scrollback-thumb":{position:"absolute",left:"0px",width:"18px",zIndex:2},".scrollback-send":{position:"absolute",padding:"0",margin:"0",bottom:"0px",left:"0px",right:"0px",height:"40px",background:"#fff"},".scrollback-nick, .scrollback-text, .scrollback-nick-guest":{display:"block",border:"none",boxSizing:"border-box",webkitBoxSizing:"border-box",mozBoxSizing:"border-box",msBoxSizing:"border-box",oBoxSizing:"border-box",padding:"0 4px",height:"40px",fontSize:"1em",borderRadius:"0"},".scrollback-nick, .scrollback-text-wrap, .scrollback-nick-guest":{position:"absolute",top:"0",margin:"0"},".scrollback-text:focus":{outline:"none"},".scrollback-nick, .scrollback-nick-guest":{lineHeight:"40px",cursor:"pointer",width:"80px",borderTop:"1px solid #ccc",background:"#ccc",backgroundRepeat:"no-repeat",backgroundPosition:"left center"},".scrollback-text-wrap":{right:"0px",left:"80px"},".scrollback-text":{width:"100%"},".scrollback-icon-popup":{position:"fixed",background:"#f70"},".scrollback-dialog-layer":{position:"fixed",display:"none",top:0,left:0,width:"100%",height:"100%",background:"rgba(255,255,255,0.9)",overflow:"auto",zIndex:999998},".scrollback-dialog":{position:"absolute",top:0,left:0,bottom:0,right:0,width:"360px",height:"400px",margin:"auto",background:"#fff",boxShadow:"0 4px 8px 0 rgba(0,0,0,0.25)"},".scrollback-dialog-close":{display:"block",position:"absolute",top:"0",right:"0",textDecoration:"none",color:"#000",lineHeight:"40px",width:"40px",textAlign:"center",cursor:"pointer",padding:"0px",backgroundColor:"#000 !important"},".scrollback-dialog-close:hover":{backgroundColor:"#555 !important"},".scrollback-dialog-frame":{display:"block",width:"100%",height:"100%",background:"transparent"}};themes.light={".scrollback-stream":{background:"#eee",color:"#000"},".scrollback-icon":{color:"#fff",backgroundColor:"#555"},".scrollback-icon:hover":{backgroundColor:"#000"},".scrollback-icon-menu":{backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoAgMAAADxkFD+AAAACVBMVEUnCBAzzKr///9dqy57AAAAAXRSTlMAQObYZgAAAE9JREFUGNNjYKA7YHSAM1kD4EzREDgzNBSuNETUAa4UrljUgTEErw1aq1atwMvEoa2BCaaAawHXAiiTaYVWA0zFqlUIxQiz4EqBihvoFIgAj/ARaE+bLvMAAAAASUVORK5CYII=')"},".scrollback-icon-hide":{backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABpSURBVFiF7dcxDoAgDEBRMR6Mm3m13qwuOCP9g8b8l3Sj4SdMtMzcvmx/O2DGQMpAykDKQMpAykDKQMpA6ijs9DEVMeaxauBZ2LvFyuFfPnGA+5Z3m786yEDKQMpAykDKQMpAykDKQOoC4wMLTudjPd8AAAAASUVORK5CYII=')"},".scrollback-icon-close":{backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAADYSURBVFiF7dZBCsIwFIThSfQAHsUDeE4FkZ5Gtz2Ma3VcNIs0aEsyT8zi/VDUYM2HksRAEj0X/w1Yy4FqDlRzoJoD1Ryo5kC1bcM9OwD77PULwDU95kUAB8y/hBHAvWo2krVXJDlw3pDGl95zJBlq52sBriHNcApwCWmGU4HfkGY4kgjU//J/WgwA8ABwAyBN0P020/1PbI07pcsMaYk7J0hIz02QVrhLAQhpTEa2rOLyqHtiOurKDwqYVvcmG6s+6iy2mZ/W/TbjQDUHqjlQzYFqDlRzoNobBUUWkfO1saUAAAAASUVORK5CYII=')"},".scrollback-icon.scrollback-icon-pop":{width:"80px",backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAoCAYAAABpYH0BAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAN6SURBVGiB7dhbiFV1FMfxzzRpjpljTkQXoWKKyFCiwCaMyjIiuln40IPV9NCVoDuVD0F0kSKihx6sl4p6KKiXCoKk14KCJpACK5ugki4jlY0Zik0Pa+nsczzp3mcfSJn9hc1e/7P/a/3X/u313///2X1TU1Mauuew/zuBQ51GwJo0AtakEbAmjYA1aQSsSSNgTRoBa9IIWJOZJuAS/IKpEkcpZpqAG3EJfu1VwJkmID0Wsa/5mNBCUYy+Mg4zsQJ7SiNgTRoBa9II2ErlhaURsJXKq3MjYCuVtzgHs4Aj+C6PEdxTaMOzPRyrGGuPiKU4vIdJ9Jo5OKlgLyi04ZgejtUea2NZx24rcC4uwjIMtF07Hiuw2PRm9CycmfYCXIojsn1kxhnB7Ao5VN70ttGNzz50U4EvYRSzsj2JpdiCF3FjIbmtOBVj4oavx8viAQziqox3dPb/G7fitRJ57MRdYrrtynxuwQSG8WDGG8AGvJV+9+JKfJF+97fFXZk5ry+RQ2UBl2SSsE5U8DDG8Shuymuf4ffCQYj6Zto7MB+viArcJG58uRB4U4lcTsHnuDbby3AbnsS3uL3Qd70QcE3mvFLnLy5n57WHS4yP6lN4smDfjD9FNcLqPI/hHFEZq7WyWdzocbhMiAercLGoiH5cUSKXWXiv0P4Ep6fdPr0nxKtlVDy0dvH+EYUwirUlxt5LVQHHxZPdJkR4Qgg2iEXZp/gCbk/0bXya/icUfv9eTMmfs724RC5b069If55PxuN4Gk/hfPHO3Z5+7Qxlv5+EmKWpKuAgXhVPa13+dhouNH0zy7PffFFZRXYU7G8K9lIsxInZHi+Ry5B9V8+deV4rtiYP4ZFCvKMwr0OshWJ6z8EFJcbeS1UBV4hN5ju4On/7Cx/h9WwP4wcxbd7YT6x38WPaH+BLMd12iWlWNp89nIGv0p6HP9IewDWFMa/rEGdzjvsY7lBhi1R1EZkQK9t5YnqOiZV3As+LLcqded6C9/cTaxKXp/+54qa/xn1CzGMPkMuHYmu0KnNahBvy2obMh1jxn0n7hTzW4OPM8+5CzN14AM+JBfGAH0u7+aDaJ7Ydu00/5XaGdH7X/BcDYlHYVjUZUQRzO/j2iym5vYPPbLGA/dbFeC00X6RrcjD/Fz4kaASsSSNgTRoBa9IIWJNGwJo0AtakEbAm/wJb7LLbQAfwGAAAAABJRU5ErkJggg==')"},".scrollback-icon-login":{backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFiSURBVFiF7ZZBToQwFIY/Jh5jErtg7jGeQxccw6VLL2EyCz2HeA5cQOQezwVV6kyhdPrQSeyXEJo++PvzXltaiAiXzOavDYTIBlPJBlPJBlPJBlO5WkFzC9x5+p+BPlpNRDSvrYg04qex8SjN3zJ3tslC8bDQAKVt98CLE7tlKD3AO7BbKqpp0BXaWSNflAwf8D3uUtG1DPoMhOJe/sU2c7+wzxd/DIlrlDhFIFhqjRJ3ChqTxGbQAJVtH4D2qM9HBVxPjR8cMWLTNCLSOptua/ti33NR3ahbTyY6hkxOcWDMcu15P5jBGIPnLIY3YG/be+D1ePyQQMw20zGfwcrG3UVT2bthPtPTKM5BIyIP9m6c2NQc/FjjsGA4XcWh52tOM98DN/z8X3vR/BdX1hCM5axJMAeongfdUrYzZS1jdDUzCOMUKJxr47SfFmfOom1QnYs/bmWDqWSDqWSDqWSDqXwChnTRHUZCC4gAAAAASUVORK5CYII=')"},".scrollback-icon-logout":{backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAADzSURBVFiF7ZaxDcIwFEQvCCVz0DMEY6REtCyRkhEoWQGEmIOCjk0ocjRGCpYJji+EKPpPuib2t5+UL9sZSYyZ2b8FvmGCKiaoYoIqJqgy72GNAsAewML7fgewBfCQVieppCB54WeOJHNlD0UuJ3luketFUhE8eSI7kiuXXUBycMEmVWC88uYk7ZMx/bnVLMyEOa1M8phZujQpI+pKADeXeBL6wu+tLoR6tTWj/8UmqGKCKpMUvOL9hoiFrrZjVdoduSFZdzj/alcz6GMhVjJZThWMkZTkKL5mXqxdQhxckulD8KdM8pgZFBNUMUEVE1QZveATwcwl121kDn4AAAAASUVORK5CYII=')"},".scrollback-icon-join, .scrollback-icon-part":{width:"auto",textIndent:"0",padding:"0 8px"},".scrollback-title":{backgroundColor:"#555",color:"#fff",borderBottomColor:"#3ca"},".scrollback-title-text":{color:"#ccc"},".scrollback-log":{color:"#000"},".scrollback-message":{color:"#999"},".scrollback-message-nick":{color:"#999"},".scrollback-message-separator":{color:"#ccc"},".scrollback-message-timestamp":{color:"#999"},".scrollback-message-content":{color:"#000"},".scrollback-timeline":{background:"#eee"},".scrollback-thumb":{background:"transparent",borderLeft:"2px solid #555",borderRight:"none"},".scrollback-nick, .scrollback-text":{borderTop:"1px solid #ccc"},".scrollback-nick":{color:"#555",background:"#eee"},".scrollback-text":{background:"#fff",color:"#000"}},themes.dark={".scrollback-stream":{background:"#555",color:"#fff"},".scrollback-icon":{color:"#fff",backgroundColor:"#555"},".scrollback-icon:hover":{backgroundColor:"#555"},".scrollback-icon-menu":{backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFVSURBVFiF7dZBToNAFAbgf4oLb9E5gkQPQGLKsmxYeBuvw8KNW5MmHEArR6CHELqhvwsfaWMmUWaelej8yQsJMw++QGbAkMScs/htwFeJwNBEYGgiMDT/C5g2lU2bympeUw2YNpVNhqROhqTWRKoARxyAJYClJjIY+Ak3Rg0ZBHTgOilACekNdOD6w8KsDwuzBtBrIb2ADtzeEMU2LTfbtNwYogCw10Caqf+DLhxgiufr8ul03s3LQw7wEcClnNoNyZC9Xt21Pwo8dy48ejIpn9RS344v8N6jb0w9ZfLsv8U+T7AOuN/k3tkvEp9XbAG0ACjVA8gd83IZG+e10jstJH3Kkmx5TE9ydTK+knNjWumZfC9foAvZkbyV6jRwoUAX8k1KBacBdCHVcFpAF1IFR1J1m7E47nMZPlZtcLT3QSvHVuuCf3KjPmsiMDQRGJoIDM3sge8GnOys45umtwAAAABJRU5ErkJggg==')"},".scrollback-icon-hide":{backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABpSURBVFiF7dcxDoAgDEBRMR6Mm3m13qwuOCP9g8b8l3Sj4SdMtMzcvmx/O2DGQMpAykDKQMpAykDKQMpA6ijs9DEVMeaxauBZ2LvFyuFfPnGA+5Z3m786yEDKQMpAykDKQMpAykDKQOoC4wMLTudjPd8AAAAASUVORK5CYII=')"},".scrollback-icon-close":{backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAADYSURBVFiF7dZBCsIwFIThSfQAHsUDeE4FkZ5Gtz2Ma3VcNIs0aEsyT8zi/VDUYM2HksRAEj0X/w1Yy4FqDlRzoJoD1Ryo5kC1bcM9OwD77PULwDU95kUAB8y/hBHAvWo2krVXJDlw3pDGl95zJBlq52sBriHNcApwCWmGU4HfkGY4kgjU//J/WgwA8ABwAyBN0P020/1PbI07pcsMaYk7J0hIz02QVrhLAQhpTEa2rOLyqHtiOurKDwqYVvcmG6s+6iy2mZ/W/TbjQDUHqjlQzYFqDlRzoNobBUUWkfO1saUAAAAASUVORK5CYII=')"},".scrollback-icon-pop":{backgroundImage:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAERSURBVFiF7ZgxTsNAEEWfDcpBwg2ouQE9DQVE4lhRoHGFKLkBx6DgBBwAkXwKbyTjIDnsH4SLedJordV65ml2V7LcSGLOtP8tMEUKuqSgSwq6pKBLCrrMXvDUfH8BXB2Z5wV4/W0BV/ADELAGTibWrqgQjNjiDrgBtgG5DnA7uKej7+blaP4COHMSRwkCPAJP5XlXxgdMwchb3NKfxXVk3qgO7uVWg7m7qMQROcZyYbiCP8nd03dvBzzj3m5JtdFK2ug7mzI/XHct6VPSbU2d2jM41bkhXRmbqkqV3VtKep/o3DgWNbWcLT4vksfIVUcj78/CEnjjcFvDcAX/nNl/D6agSwq6pKBLCrqkoMvsBb8A4W6WiJ7YEGsAAAAASUVORK5CYII=')"},".scrollback-title":{backgroundColor:"#555",color:"#fff",borderBottomColor:"#3ca"},".scrollback-title-text":{color:"#ccc"},".scrollback-log":{color:"#fff"},".scrollback-message-nick":{color:"#999"},".scrollback-message-separator":{color:"#999"},".scrollback-message-join, .scrollback-message-part":{color:"#999"},".scrollback-message-timestamp":{color:"#999"},".scrollback-timeline":{background:"#555"},".scrollback-tread-row":{background:"#fff"},".scrollback-thumb":{background:"#000"},".scrollback-nick, .scrollback-text":{borderTop:"1px solid #ccc"},".scrollback-nick":{color:"#555",background:"#eee"},".scrollback-text":{background:"#ccc",color:"#000"}};var dom={stream:["div",{"class":"scrollback-stream"},["div",{"class":"scrollback-alert scrollback-alert-hidden"}],["div",{"class":"scrollback-title"},["span",{"class":"scrollback-icon scrollback-icon-menu"},"menu"],scrollback.close?["div",{"class":"scrollback-icon scrollback-icon-close"}]:"",["div",{"class":"scrollback-icon scrollback-icon-pop"},"on scrollback"],["span",{"class":"scrollback-icon scrollback-icon-part scrollback-hidden"},"Unfollow"],["span",{"class":"scrollback-icon scrollback-icon-join"},"Follow"],["div",{"class":"scrollback-title-content"},["span",{"class":"scrollback-title-id"}],["a",{href:"//scrollback.io","class":"scrollback-poweredby",target:"_blank"}],["span",{"class":"scrollback-title-text"}]]],["div",{"class":"scrollback-timeline"},["div",{"class":"scrollback-tread"}],["div",{"class":"scrollback-thumb"}]],["div",{"class":"scrollback-log"}],["form",{"class":"scrollback-send"},["div",{"class":"scrollback-nick-guest"}],["div",{"class":"scrollback-text-wrap"},["input",{"class":"scrollback-text"}]],["button",{type:"submit","class":"scrollback-hidden"},"Send"]]]},DomReady={},userAgent=navigator.userAgent.toLowerCase(),browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)},readyBound=!1,isReady="interactive"==document.readyState||"loaded"==document.readyState||"complete"==document.readyState,readyList=[];DomReady.ready=function(a){bindReady(),isReady?a.call(window,[]):readyList.push(function(){return a.call(window,[])})},bindReady();var JsonML=JsonML||{};!function(a){function b(a,b,c){"string"==typeof c&&(c=new Function("event",c)),"function"==typeof c&&addEvent(a,m[b],c)}function c(a,c){if(c.name&&document.attachEvent)try{var d=document.createElement("<"+a.tagName+' name="'+c.name+'">');a.tagName===d.tagName&&(a=d)}catch(e){}for(var f in c)if(c.hasOwnProperty(f)){var g=c[f];f&&null!==g&&"undefined"!=typeof g&&(f=k[f.toLowerCase()]||f,"style"===f?setStyle(a,g):"class"===f?a.className=g:m[f]?(b(a,f,g),l[f]&&b(a,l[f],g)):"string"==typeof g||"number"==typeof g||"boolean"==typeof g?(a.setAttribute(f,g),l[f]&&a.setAttribute(l[f],g)):(a[f]=g,l[f]&&(a[l[f]]=g)))}return a}function d(a,b){if(b)if(a.tagName&&"table"===a.tagName.toLowerCase()&&a.tBodies){if(!b.tagName){if(11===b.nodeType)for(;b.firstChild;)d(a,b.removeChild(b.firstChild));return}var c=b.tagName.toLowerCase();if(c&&"tbody"!==c&&"thead"!==c){var e=a.tBodies.length>0?a.tBodies[a.tBodies.length-1]:null;e||(e=document.createElement("th"===c?"thead":"tbody"),a.appendChild(e)),e.appendChild(b)}else a.canHaveChildren!==!1&&a.appendChild(b)}else if(a.tagName&&"style"===a.tagName.toLowerCase()&&document.createStyleSheet)a.cssText=b;else if(a.canHaveChildren!==!1)a.appendChild(b);else if(a.tagName&&"object"===a.tagName.toLowerCase()&&b.tagName&&"param"===b.tagName.toLowerCase()){try{a.appendChild(b)}catch(f){}try{a.object&&(a.object[b.name]=b.value)}catch(g){}}}function e(a){return a&&3===a.nodeType&&(!a.nodeValue||!/\S/.exec(a.nodeValue))}function f(a){if(a){for(;e(a.firstChild);)a.removeChild(a.firstChild);for(;e(a.lastChild);)a.removeChild(a.lastChild)}}function g(a){var b=document.createElement("div");if(b.innerHTML=a,f(b),1===b.childNodes.length)return b.firstChild;for(var c=document.createDocumentFragment?document.createDocumentFragment():document.createElement("");b.firstChild;)c.appendChild(b.firstChild);return c}function h(a){this.value=a}function i(a){return document.createTextNode("["+a+"]")}function j(b,e,f){for(var i=1;i<e.length;i++)e[i]instanceof Array||"string"==typeof e[i]?d(b,a.parse(e[i],f)):e[i]instanceof h?d(b,g(e[i].value)):"object"==typeof e[i]&&null!==e[i]&&1===b.nodeType&&(b=c(b,e[i]));return b}var k={rowspan:"rowSpan",colspan:"colSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",tabindex:"tabIndex",accesskey:"accessKey",hidefocus:"hideFocus",usemap:"useMap",maxlength:"maxLength",readonly:"readOnly",contenteditable:"contentEditable"},l={enctype:"encoding",onscroll:"DOMMouseScroll"},m=function(a){for(var b={};a.length;){var c=a.shift();b["on"+c.toLowerCase()]=c}return b}("blur,change,click,dblclick,error,focus,keydown,keypress,keyup,load,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,resize,scroll,select,submit,unload".split(","));a.raw=function(a){return new h(a)},a.onerror=null,a.parse=function(b,c){try{if(!b)return null;if("string"==typeof b)return document.createTextNode(b);if(b instanceof h)return g(b.value);if(!a.isElement(b))throw new SyntaxError("invalid JsonML");var e=b[0];if(!e){for(var k=document.createDocumentFragment?document.createDocumentFragment():document.createElement(""),l=1;l<b.length;l++)d(k,a.parse(b[l],c));return f(k),1===k.childNodes.length?k.firstChild:k}if("style"===e.toLowerCase()&&document.createStyleSheet)return a.patch(document.createStyleSheet(),b,c),null;var m=j(document.createElement(e),b,c);return f(m),m&&"function"==typeof c?c(m):m}catch(n){try{var o="function"==typeof a.onerror?a.onerror:i;return o(n,b,c)}catch(p){return document.createTextNode("["+p+"]")}}},a.patch=function(a,b,c){return j(a,b,c)},a.isElement=function(a){return a instanceof Array&&"string"==typeof a[0]},a.isFragment=function(a){return a instanceof Array&&""===a[0]},a.getTagName=function(a){return a[0]||""},a.isAttributes=function(a){return!(!a||"object"!=typeof a||a instanceof Array)},a.hasAttributes=function(b){if(!a.isElement(b))throw new SyntaxError("invalid JsonML");return a.isAttributes(b[1])},a.getAttributes=function(b,c){if(a.hasAttributes(b))return b[1];if(!c)return void 0;var d=b.shift(),e={};return b.unshift(e),b.unshift(d||""),e},a.addAttributes=function(b,c){if(!a.isElement(b)||!a.isAttributes(c))throw new SyntaxError("invalid JsonML");if(!a.isAttributes(b[1])){var d=b.shift();return b.unshift(c),void b.unshift(d||"")}var e=b[1];for(var f in c)c.hasOwnProperty(f)&&(e[f]=c[f])},a.getAttribute=function(b,c){return a.hasAttributes(b)?b[1][c]:void 0},a.setAttribute=function(b,c,d){a.getAttributes(b,!0)[c]=d},a.appendChild=function(b,c){if(c instanceof Array&&""===c[0])for(c.shift();c.length;)a.appendChild(b,c.shift(),arguments[2]);else if(c&&"object"==typeof c)if(c instanceof Array){if(!a.isElement(b)||!a.isElement(c))throw new SyntaxError("invalid JsonML");"function"==typeof arguments[2]&&arguments[2](b,c),b.push(c)}else if(c instanceof h){if(!a.isElement(b))throw new SyntaxError("invalid JsonML");b.push(c)}else a.addAttributes(b,c);else if("undefined"!=typeof c&&null!==c){if(!(b instanceof Array))throw new SyntaxError("invalid JsonML");c=String(c),c&&b.length>1&&"string"==typeof b[b.length-1]?b[b.length-1]+=c:(c||!b.length)&&b.push(c)}},a.getChildren=function(b){a.hasAttributes(b)&&b.slice(2),b.slice(1)}}(JsonML);var streams={},$$=getByClass,unconfirmed=[],initialized=!1;core.on("connected",function(){initialized||(init(),initialized=!0),getByClass(document,"scrollback-text").forEach(function(a){a.disabled=!1,a.value=""}),getByClass(document,"scrollback-nick").forEach(function(a){a.disabled=!1}),scrollback&&scrollback.streams&&scrollback.streams.forEach(function(a){streams[a]&&streams[a].notify("And... we're back.")})}),core.on("disconnected",function(){getByClass(document,"scrollback-text").forEach(function(a){a.disabled=!0,a.value="Disconnected"}),getByClass(document,"scrollback-nick").forEach(function(a){a.disabled=!0}),scrollback.streams.forEach(function(a){streams[a].notify("Disconnected. Refresh page to reconnect.",!0)})}),core.on("enter",function(){}),core.on("leave",function(){}),core.on("nick",function(a){var b,c,d=a.replace(/^guest-/,"");for(b in streams)streams.hasOwnProperty(b)&&(c=streams[b],c.nick.innerHTML=d,0!==a.indexOf("guest-")&&(removeClass(c.nick,"scrollback-nick-guest"),addClass(c.nick,"scrollback-nick")))}),core.on("message",function(a){a.to&&streams[a.to]&&streams[a.to].onmessage(a)}),Stream.prototype.close=function(){delete streams[this.id],core.leave(this.id),document.body.removeChild(this.stream),Stream.position()},Stream.prototype.pop=function(){window.open(scrollback.host+"/"+this.id+"/","_blank")},Stream.prototype.toggle=function(){this.hidden?this.show():this.hide(),Stream.position()},Stream.prototype.hide=function(){removeClass(this.stream,"scrollback-stream-selected"),addClass(this.stream,"scrollback-stream-hidden"),this.hidden=!0},core.on("error",function(a){"AUTH_UNREGISTERED"===a&&profile(),"AUTH_REQ_TO_POST"===a&&login({requireAuth:1})}),Stream.prototype.show=function(){var a=this;removeClass(this.stream,"scrollback-stream-hidden"),setTimeout(function(){a.initialized||(a.bottom=!0,core.watch(a.id,null,32,0,function(b){a.update(b)}),a.initialized=!0)},250),this.hidden=!1},Stream.prototype.send=function(){var a,b,c,d=this.text.value;if(d){if(Stream.text=this.text,Stream.prevText=this.text.value,this.text.value="","/"==d[0])switch(a=d.substr(1).split(" "),a[0]){case"nick":return b=core.nick(),void(0!=b.indexOf("guest-")?this.notify("You can't change your nick while you're signed in."):(c=this,core.nick("guest-"+a[1],function(){c.nick.innerHTML=a[1],c.rename()})));case"leave":return void(scrollback.close&&this.close())}this.log.scrollTop=this.log.scrollHeight,core.say(this.id,d)}},Stream.prototype.notify=function(a,b){var c=this;this.hidden||(this.alert.innerHTML="<span>"+a+"</span>",removeClass(this.alert,"scrollback-alert-hidden"),clearTimeout(this.alertTimer),b||(this.alertTimer=setTimeout(function(){addClass(c.alert,"scrollback-alert-hidden")},2e3)))},Stream.prototype.onmessage=function(a){var b=this.renderMessage(a);"join"!==a.type&&"part"!==a.type&&("text"==a.type?(a.from!=core.nick()&&browserNotify(a.from.replace(/^guest-/g,"")+" : "+a.text,hasClass(b,"scrollback-message-mentioned")),this.titleText.innerText?this.titleText.innerText=b.innerText:this.titleText.textContent=b.textContent):core.nick()!==a.ref&&a.ref!=a.from&&this.notify(b.innerText||b.textContent))},Stream.prototype.rename=function(){var a=this.nick.innerText||this.nick.textContent;core.nick(a)},Stream.prototype.select=function(){var a,b=$$(document,"scrollback-stream"),c=b.length;for(a=0;c>a;a+=1)removeClass(b[a],"scrollback-stream-selected");addClass(this.stream,"scrollback-stream-selected"),Stream.position()},Stream.get=function(a){if(!a)throw"Can't get a stream with no ID!";return streams[a]?streams[a]:(streams[a]=new Stream(a),Stream.position(),streams[a])},Stream.stack=function(){var a,b,c=$$(document,"scrollback-stream"),d=c.length,e=0,f=1;for(a=0;d>a;a+=1)b=c[a],hasClass(b,"scrollback-stream-selected")&&(f=-1),b.style.zIndex=d+e,e+=f},Stream.position=function(){var a,b,c,d,e,f,g=scrollback.maxWidth||400,h=scrollback.maxHeight||400,i=scrollback.minWidth||250,j=scrollback.minHeight||44,k=scrollback.maxGap||20,l=scrollback.minPitch||120,m=scrollback.margin||40,n=$$(document,"scrollback-stream"),o=n.length,p=1,q=0,r=!1,s=document.documentElement.clientWidth||document.getElementsByTagName("body")[0].clientWidth,t=window.innerHeight||document.documentElement.clientHeight||document.getElementsByTagName("body")[0].clientHeight;for(i+2*m+l*(o-1)>s?(r=!0,f=0,b=s,m=0,c=Math.min(h,t-j*(o-1))):g+2*m+l*(o-1)>s?(r=!1,f=l,b=s-2*m-(o-1)*l,c=Math.min(h,t)):(r=!1,b=g,f=Math.min((s-b-2*m)/(o-1),g+k),c=Math.min(h,t)),a=0;o>a;a+=1)d=n[a],window.scrollback.position&&"left"===window.scrollback.position?(console.log("pushing to left"),d.style.left=m+a*f+"px"):d.style.right=m+a*f+"px",d.style.width=b+"px",hasClass(d,"scrollback-stream-selected")&&(p=-1),r?(e=hasClass(d,"scrollback-stream-selected")?c:j,d.style.height=e+"px",d.style.bottom=q+"px",q+=e,removeClass(d,"scrollback-stream-right")):(e=hasClass(d,"scrollback-stream-hidden")?j:c,d.style.height=Math.round(e)+"px",d.style.bottom="0px",0>p||f>=b||a===o-1?removeClass(d,"scrollback-stream-right"):addClass(d,"scrollback-stream-right"));
Stream.stack()},Stream.prototype.scroll=function(){var a,b,c,d=this.log,e=d.firstChild,f=0,g=99999,h=0,i=this,j=offset(d)[1]+d.scrollTop,k=j+d.clientHeight;if(!this.updating){for(;e;)a=offset(e)[1],a>=j&&k>=a&&(g>f&&(g=f),f>h&&(h=f)),e=e.nextSibling,f++;if("undefined"==typeof this.lastScrollTop)return void(this.lastScrollTop=d.scrollTop);b=d.scrollTop<this.lastScrollTop,this.lastScrollTop=d.scrollTop,this.scrollId=this.messages[g].id,this.scrollPx=offset(this.log.children[g])[1]-offset(this.log)[1]-this.log.scrollTop,this.requested[b?"dn":"up"]=!1,g>=10&&(i.requested.up=!1),i.messages.length-h>=10&&(i.requested.dn=!1),this.renderThumb(g,h),h>=i.messages.length-1&&!b?(scrollback.debug&&console.log("bottomed out"),this.bottom=!0):this.bottom=!1,c=function(a){i.update(a)},this.bottom?core.watch(i.id,null,3*(h-g)+10,0,c):(core.unwatch(i.id),!this.requested[b?"up":"dn"]&&(b&&10>g||!b&&i.messages.length-h<10)&&(this.requested[b?"up":"dn"]=!0,core.watch(i.id,i.messages[g].time,h-g+10,2*(h-g)+10,c)))}},Stream.prototype.update=function(a){var b,c,d=this;if(this.messages=a,this.updating=!0,this.renderLog(),this.renderTimeline(),this.bottom)this.log.scrollTop=this.log.scrollHeight;else{for(b=0,c=this.messages.length;c>b&&this.messages[b].id!=d.scrollId;b++);this.log.scrollTop=offset(this.log.children[b])[1]-offset(this.log)[1]-this.scrollPx}this.lastScrollTop=this.log.scrollTop,setTimeout(function(){d.updating=!1},100)},Stream.prototype.renderLog=function(){var a,b,c=this;this.hidden||(this.log.innerHTML="",this.messages.forEach(function(d){a&&(b=c.renderMessage(a,d.time-a.time>6e4),b&&c.log.appendChild(b)),a=d}),a&&c.log.appendChild(c.renderMessage(a,!0)))},Stream.prototype.renderThumb=function(a,b){var c,d,e=core.cache(this.id),f=(this.log,this.messages[a].time),g=this.messages[b].time,h=e[0].time,i=e[e.length-1].time-h;this.hidden||(c=Math.round((f-h)*this.tread.clientHeight/i),d=Math.round((g-f)*this.tread.clientHeight/i),this.thumb.style.top=c+"px",this.thumb.style.height=Math.max(2,d)+"px")},Stream.prototype.renderTimeline=function(){if(!this.hidden){var a,b,c,d,e,f,g=[],h=4,i=Math.floor(this.tread.clientHeight/h),j=0,k=18,l=["div"],m=0,n=core.cache(this.id);if(this.tread.innerHTML="",n.length){for(c=n[0],b=n.length,d=c.time||0,e=n[b-1].time-d,j=0;b>j;j++){c=n[j];var o=c.labels&&c.labels[0]?c.labels[0].split(":")[0]:"";"text"===c.type&&(a=Math.floor((c.time-d)*i/e),g[a]||(g[a]={nicks:{},n:0,dominant:{nick:o,count:1}}),g[a].nicks[o]=(g[a].nicks[o]||0)+(c.text||"").length,g[a].dominant.count<=g[a].nicks[o]&&(g[a].dominant={nick:c.labels&&c.labels[0]?c.labels[0].split(":")[0]:"",count:g[a].nicks[c.labels&&c.labels[0]?c.labels[0].split(":")[0]:""]}),g[a].n+=c.text.length,g[a].n>m&&(m=g[a].n))}for(a=0;i>a;a+=1)g[a]&&(f=["div",{"class":"scrollback-tread-row scrollback-user-"+Object.keys(g[a].nicks).join(" scrollback-user-"),style:{top:Math.round(a*h)+"px",width:Math.round(h+g[a].n*(k-h)/m)+"px",background:hashColor(g[a].dominant.nick)}}],l.push(f));this.tread.appendChild(JsonML.parse(l))}}},Stream.prototype.renderMessage=function(a,b){function c(a){if(!a)return"";for(var b,c,d,e,f,g=/\b(https?\:\/\/)?([\w.\-]*@)?((?:[a-z0-9\-]+)(?:\.[a-z0-9\-]+)*(?:\.[a-z]{2,4}))((?:\/|\?)\S*)?\b/g,h=["span"],i=0;null!==(b=g.exec(a));)h.push(a.substring(i,b.index)),c=b[1],d=b[2],e=b[3],f=b[4]||"",c=c||(d?"mailto:":"http://"),d=d||"",i=g.lastIndex,h.push(["a",{href:c+d+e+f,target:"_blank"},b[0]]);return h.push(a.substring(i)),h}function d(b){return b?["span",{"class":"scrollback-message-nick",onmouseout:function(){f.userStyle&&f.userStyle.parentNode.removeChild(f.userStyle)},onmouseover:function(){var c={".scrollback-tread-row":{width:"0 !important"}};c[".scrollback-user-"+b]={background:hashColor(a.from)+" !important",width:"100% !important"},f.userStyle=addStyles(c)}},0===b.indexOf("guest-")?b.replace("guest-",""):b]:""}var e,f=this,g=new RegExp("\\b"+core.nick().replace(/^guest-/,"")+"\\b"),h=g.test(a.text)&&a.from!=core.nick()?" scrollback-message-mentioned ":"";switch(a.type){case"text":e=[["span",{"class":"scrollback-message-separator"},"["],d(a.from)],0===a.text.indexOf("/me ")?(e.push(["span",c(a.text.substr(3))]),e.push(["span",{"class":"scrollback-message-separator"},"] "])):(e.push(["span",{"class":"scrollback-message-separator"},"] "]),e.push(["span",{"class":"scrollback-message-content"},c(a.text)]));break;case"back":e=[["span",d(a.from)," entered."]];break;case"away":e=["span",d(a.from)," left"],a.text?e.push(" (",c(a.text),")"):e.push("."),e=[e];break;case"nick":e=[["span",d(a.from)," is now known as ",d(a.ref)]];break;default:e=[["span",a.text]]}return b&&a.time&&e.push(["span",{"class":"scrollback-message-timestamp"},"Sent "+prettyDate(a.time,core.time())]),e?(console.log(),e=JsonML.parse(["div",{"class":"scrollback-message scrollback-message-"+a.type+h,style:{borderLeftColor:hashColor(a.labels&&a.labels[0]?a.labels[0].split(":")[0]:"")},"data-time":a.time,"data-from":d(a.from)}].concat(e))):null};var browserNotify=function(){var a,b,c,d=!1,e=function(){var a,b="data:audio/wav;base64,UklGRnQGAABXQVZFZm10IBAAAAABAAEAESsAABErAAABAAgAZGF0YU8GAACBgIF/gn2Cf4B+gn5+fYJ/gIF/gH+BfX6AfXt5fXx7e3x9fH1+f4CAfnx9f3t9gIB9en2Dfn58fYKDgIJ9hnh7hIZ8gYR6fHyCe4GCioF+gH93foWCgoJ5gHx5gniAeYJ0dneCgXN1jn1+fI1zfHp8dYiCe3qIhHpmfXqMeZJ0ACb/AAD//wAAQ/8A3pYANv/qYek5OGp3tICeexjYUkWgYMzzAB//hDyVcX2Yi5ppXLNsXYKEZ3l7aHGTn1pnlZlwVpuUgqOKgIOMYIpsoXVydJKdc296kZl3h3OAcoV6ao6Be298ipCFhIFxk3yIeXNuh4eHiYh/c3h1eJCUenCCfH9yeZSKcHR7eH9ugYl+eImFfWxuhX1uiIx+gYZmg355hHlzgXl1dIeWdGmciXpteYWMc3GOfntye5Khh1+beoaFgmJ5k4KUe3CXim2GdJaFYXmec1GomG97b4mZcnCIbX6EbX6LbWd1e4B0d4x6cXuKcoKMdoB5eZt9doh0e32Ag5CSgnOEkIWBgX6AeYqRenJ9hoKDhIR6gIBte42DeHuFhm18g35we4x9dnmBgHp+bniBfIF2eYB3fYV3dX+FdIOCf3Z7foF8e4mAfHuCdn+Lc3WKhXyEhnt7goF4foSDhH17f4uFfnp/io90c4OBfHuCg4JyhIxycH2JgnuDiHl8hH98dIODdIKBeIZ8fHeCiXx+f3SIf3V7eYSCdHuCgnh6hIFzioV3gYuAeXl9e4V7e3+JgnV6gIJ7hIiCe3yIinx9hYGAhX17h4OBfICFfIiFfHh9hn93gnp2hYR6foF4dn9/dX1/eX9/dHN+goB3eoF8fHt6f316fIF6gIF8eH2Cgnt/goV6iHx3iIR6f4CDg3uGg3yAiIN9g4B/gn+CgX59hn96fn+FfX59f4SCgIR7foJ7fYGAfoF6f4F5fHyDfXmFfnt5hIB5fn1/fX1+gHl9foN8fYGCfoCGen6AgoB/gH9/g3p8fYWGfXqDhH17gIOCfn+CeoCDg3p6fIGFfXp/gYR9dYN/gX57e359foJ9foGAf357gICAfIJ7fn16hoV6fXyAgX+Bfn5+gnl5gYSBfH19e4h7fISEeIB+gH+Ed3+Cf3p6hX2Af3qAfX5/fn98f4GBgHt3gYZ/fX99gHx8gH97hoR3gX5/g3l+g31/g315f4N8fX+AgX6Af35+gH6AgX97foCCfX99gn1+gYF7gIR9en+DgH59f319gYB8fn1/f32Be3uCgXx+fYR/fH2Cf31+foKEfHyBg31/fn5/goJ7gIaAfX9/gn+Bgn56g4J/goF/foB/gIB/fn+Bf3uAgn96f398gIB/fnyAgHx9fn5+f3p+gnx9f3x/f398f399gH9/fn6Df3yBf39/gIB9f4F/gYF+f4CCfoF/f4KCgICAf4KAg4B+f4KCfX59goN9fYB/gIB6gH99fICAfX1/gnx7fYB/gXx9fn5/fn99fX5+fX5+fn5/f39/gX5/gnx+gIF/foCCfn2Af4J+foGBgX9/f4CCfIGAgYF/f36AgYB+gIGAgH2AgX99gH9/gH2Af3+AfXx9gHx+fHyAfX5+fH2Agnt7f35/fX9/f39/fXp+gH5+goB9f39/gn59gX+Af31/gIB/f39/gH6AgICBfoCEf4B+f4KBf4B/gYGDfn+Af4B/fn59foF+foKBfn9+fHyAfn5+fn+BeX+Fg3N7hX58gH+Afn6FdHuIgnh+g4B6e4iGeHqFhXh7g3+Af36Ag4SAeX+Een1+g4V7en6Ef3+AgX9/f4B+fHx+foJ/fH6ChHx9foGBg3t5foJ/f3x+fYF+f31+gICBgX5/f4F+fn5/fX59fn9+gIOAf3+Af4B9fn9+gX9+gX+BfoGBgIB/f31/gn+CfIB/fYF+f36Bf35/foB/f398gX+Af31/f4CBf358gIKAfn9+gn2Af35+gn99f36Bf31+f3+Af399f4CBfoCAfX+BfX+AgH6AgH9+gIZ9fYJ/iIB3fIt/dISBgHx/f4OFf32AgX53fIOCe4KBfn2Ben57f3t4f4N9gH6BgYKAgHl/gn1/f4N/f36DgoCBfoJ+eX17gH18e4F/fYB+hX6Dg4OBgIB8fHt+f39+fX9/foKBgIGEf31/gX6AgoGDfoCEf32BAA==";return function(){a||(a=document.createElement("div"),a.style.display="none",document.body.appendChild(a)),a.innerHTML='<audio autoplay="autoplay"><source src="'+b+'" type="audio/wav" /><embed hidden="true" autostart="true" loop="false" src="'+b+'" /></audio>'}}();return DomReady.ready(function(){addEvent(window,"focus",function(){a&&(document.title=a,a=null),d=!0}),addEvent(window,"blur",function(){d=!1}),d=document.hasFocus()}),function(f,g){d||(a||(a=document.title),document.title=f,b&&clearTimeout(b),b=setTimeout(function(){document.title=a,a=null,b=null},2e3),scrollback.sounds&&(g&&c&&(clearTimeout(c),c=null),c||(e(),c=setTimeout(function(){c=null},6e4))))}}(),dialog=function(){function a(){b.style.display="none"}var b,c,d,e;return e=0==scrollback.host.indexOf("//")?scrollback.host.replace(/^\/\//,"https://"):scrollback.host.replace(/^http:/,"https:"),addEvent(window,"message",function(a){var b;if(a.origin==e){if("string"==typeof a.data)try{b=JSON.parse(a.data)}catch(c){return void(scrollback.debug&&console.log("Error parsing incoming message: ",a.data,c))}else b=a.data;d(b)}}),{show:function(f,g){d=g,b||(b=JsonML.parse(["div",{"class":"scrollback-dialog-layer",onclick:a},["div",{"class":"scrollback-dialog"},["div",{"class":"scrollback-dialog-close scrollback-icon scrollback-icon-close",onclick:a},"×"],["iframe",{"class":"scrollback-dialog-frame",allowtransparency:!0,id:"scrollback-dialog-frame",frameborder:"0"}]]]),document.body.appendChild(b),c=document.getElementById("scrollback-dialog-frame")),c.src=e+f,b.style.display="block"},hide:a,send:function(a,b){c.contentWindow.postMessage({type:a,data:b},e)}}}();
}())