jimgreeno

Untitled

Aug 25th, 2017
1,419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 295.83 KB | None | 0 0
  1. 1.rtmpdump -r "rtmpe://edge1-a.stream.chaturbate.com/live-edge" -a "live-edge" -W "http://ccstatic.chaturbate.com/static/flash/CBV_2p51.swf" -p "http://chaturbate.com/yelle92/" -y "mp4:public-yelle92" -v -o t.flv -T "m9z#$dO0qe34Rxe@sMYxx%"
  2.  
  3.  
  4. 2. '>-SIMPLETEXT->https://chaturbate.com/exotic69dreamz/?-_js./embed_js.php?i=in/?tour=9oGW&campaign=zM6MR&track=embed&room=exotic69dreamz&bgcolor=transparent&embed_sound=0&embed_video_only=1&target=_parent' height=600 width=800 style='border: none;'>-SIMPLETEXT->/ data.replace/new /RegExp( "\r", "g" ), d'');url: /'pastebin.ashx',context: $(this),...load the local file --> window.jQuery || document.write'>-SIMPLETEXT->
  5.  
  6.  
  7. 3.no longer works as of 1/25/12, need to get new token, see javascript:
  8.  
  9.  
  10. 4. '>-SIMPLETEXT->https://chaturbate.com/exotic69dreamz/?-_js./embed_js.php?i=in/?tour=9oGW&campaign=zM6MR&track=embed&room=exotic69dreamz&bgcolor=transparent&embed_sound=0&embed_video_only=1&target=_parent' height=600 width=800 style='border: none;'>-SIMPLETEXT->/ data.replace/new /RegExp( "\r", "g" ), d'');url: /'pastebin.ashx',context: $(this),...load the local file --> window.jQuery || document.write'>-SIMPLETEXT->
  11.  
  12.  
  13. 5.var MEDIA_URL='http://ccstatic.chaturbate.com/static/';var Base64=(function(){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var obj={encode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;do{chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
  14.  
  15.  
  16. 6.output=output+keyStr.charAt(enc1)+keyStr.charAt(enc2)+
  17.  
  18.  
  19. 7.keyStr.charAt(enc3)+keyStr.charAt(enc4);}while(i<input.length);return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
  20.  
  21.  
  22. 8.if(enc4!=64){output=output+String.fromCharCode(chr3);}}while(i<input.length);return output;}};return obj;})();var MD5=(function(){var hexcase=0;var b64pad="";var chrsz=8;var safe_add=function(x,y){var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);};var bit_rol=function(num,cnt){return(num<<cnt)|(num>>>(32-cnt));};var str2binl=function(str){var bin=[];var mask=(1<<chrsz)-1;for(var i=0;i<str.length*chrsz;i+=chrsz)
  23.  
  24.  
  25. 9.{bin[i>>5]|=(str.charCodeAt(i/chrsz)&mask)<<(i%32);}
  26.  
  27.  
  28. 10.return bin;};var binl2str=function(bin){var str="";var mask=(1<<chrsz)-1;for(var i=0;i<bin.length*32;i+=chrsz)
  29.  
  30.  
  31. 11.{str+=String.fromCharCode((bin[i>>5]>>>(i%32))&mask);}
  32.  
  33.  
  34. 12.return str;};var binl2hex=function(binarray){var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i<binarray.length*4;i++)
  35.  
  36.  
  37. 13.{str+=hex_tab.charAt((binarray[i>>2]>>((i%4)*8+4))&0xF)+
  38.  
  39.  
  40. 14.hex_tab.charAt((binarray[i>>2]>>((i%4)*8))&0xF);}
  41.  
  42.  
  43. 15.return str;};var binl2b64=function(binarray){var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";var triplet,j;for(var i=0;i<binarray.length*4;i+=3)
  44.  
  45.  
  46. 16.{triplet=(((binarray[i>>2]>>8*(i%4))&0xFF)<<16)|(((binarray[i+1>>2]>>8*((i+1)%4))&0xFF)<<8)|((binarray[i+2>>2]>>8*((i+2)%4))&0xFF);for(j=0;j<4;j++)
  47.  
  48.  
  49. 17.{if(i*8+j*6>binarray.length*32){str+=b64pad;}
  50.  
  51.  
  52. 18.else{str+=tab.charAt((triplet>>6*(3-j))&0x3F);}}}
  53.  
  54.  
  55. 19.return str;};var md5_cmn=function(q,a,b,x,s,t){return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b);};var md5_ff=function(a,b,c,d,x,s,t){return md5_cmn((b&c)|((~b)&d),a,b,x,s,t);};var md5_gg=function(a,b,c,d,x,s,t){return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t);};var md5_hh=function(a,b,c,d,x,s,t){return md5_cmn(b^c^d,a,b,x,s,t);};var md5_ii=function(a,b,c,d,x,s,t){return md5_cmn(c^(b|(~d)),a,b,x,s,t);};var core_md5=function(x,len){x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;var olda,oldb,oldc,oldd;for(var i=0;i<x.length;i+=16)
  56.  
  57.  
  58. 20.{olda=a;oldb=b;oldc=c;oldd=d;a=md5_ff(a,b,c,d,x[i+0],7,-680876936);d=md5_ff(d,a,b,c,x[i+1],12,-389564586);c=md5_ff(c,d,a,b,x[i+2],17,606105819);b=md5_ff(b,c,d,a,x[i+3],22,-1044525330);a=md5_ff(a,b,c,d,x[i+4],7,-176418897);d=md5_ff(d,a,b,c,x[i+5],12,1200080426);c=md5_ff(c,d,a,b,x[i+6],17,-1473231341);b=md5_ff(b,c,d,a,x[i+7],22,-45705983);a=md5_ff(a,b,c,d,x[i+8],7,1770035416);d=md5_ff(d,a,b,c,x[i+9],12,-1958414417);c=md5_ff(c,d,a,b,x[i+10],17,-42063);b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);a=md5_ff(a,b,c,d,x[i+12],7,1804603682);d=md5_ff(d,a,b,c,x[i+13],12,-40341101);c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);b=md5_ff(b,c,d,a,x[i+15],22,1236535329);a=md5_gg(a,b,c,d,x[i+1],5,-165796510);d=md5_gg(d,a,b,c,x[i+6],9,-1069501632);c=md5_gg(c,d,a,b,x[i+11],14,643717713);b=md5_gg(b,c,d,a,x[i+0],20,-373897302);a=md5_gg(a,b,c,d,x[i+5],5,-701558691);d=md5_gg(d,a,b,c,x[i+10],9,38016083);c=md5_gg(c,d,a,b,x[i+15],14,-660478335);b=md5_gg(b,c,d,a,x[i+4],20,-405537848);a=md5_gg(a,b,c,d,x[i+9],5,568446438);d=md5_gg(d,a,b,c,x[i+14],9,-1019803690);c=md5_gg(c,d,a,b,x[i+3],14,-187363961);b=md5_gg(b,c,d,a,x[i+8],20,1163531501);a=md5_gg(a,b,c,d,x[i+13],5,-1444681467);d=md5_gg(d,a,b,c,x[i+2],9,-51403784);c=md5_gg(c,d,a,b,x[i+7],14,1735328473);b=md5_gg(b,c,d,a,x[i+12],20,-1926607734);a=md5_hh(a,b,c,d,x[i+5],4,-378558);d=md5_hh(d,a,b,c,x[i+8],11,-2022574463);c=md5_hh(c,d,a,b,x[i+11],16,1839030562);b=md5_hh(b,c,d,a,x[i+14],23,-35309556);a=md5_hh(a,b,c,d,x[i+1],4,-1530992060);d=md5_hh(d,a,b,c,x[i+4],11,1272893353);c=md5_hh(c,d,a,b,x[i+7],16,-155497632);b=md5_hh(b,c,d,a,x[i+10],23,-1094730640);a=md5_hh(a,b,c,d,x[i+13],4,681279174);d=md5_hh(d,a,b,c,x[i+0],11,-358537222);c=md5_hh(c,d,a,b,x[i+3],16,-722521979);b=md5_hh(b,c,d,a,x[i+6],23,76029189);a=md5_hh(a,b,c,d,x[i+9],4,-640364487);d=md5_hh(d,a,b,c,x[i+12],11,-421815835);c=md5_hh(c,d,a,b,x[i+15],16,530742520);b=md5_hh(b,c,d,a,x[i+2],23,-995338651);a=md5_ii(a,b,c,d,x[i+0],6,-198630844);d=md5_ii(d,a,b,c,x[i+7],10,1126891415);c=md5_ii(c,d,a,b,x[i+14],15,-1416354905);b=md5_ii(b,c,d,a,x[i+5],21,-57434055);a=md5_ii(a,b,c,d,x[i+12],6,1700485571);d=md5_ii(d,a,b,c,x[i+3],10,-1894986606);c=md5_ii(c,d,a,b,x[i+10],15,-1051523);b=md5_ii(b,c,d,a,x[i+1],21,-2054922799);a=md5_ii(a,b,c,d,x[i+8],6,1873313359);d=md5_ii(d,a,b,c,x[i+15],10,-30611744);c=md5_ii(c,d,a,b,x[i+6],15,-1560198380);b=md5_ii(b,c,d,a,x[i+13],21,1309151649);a=md5_ii(a,b,c,d,x[i+4],6,-145523070);d=md5_ii(d,a,b,c,x[i+11],10,-1120210379);c=md5_ii(c,d,a,b,x[i+2],15,718787259);b=md5_ii(b,c,d,a,x[i+9],21,-343485551);a=safe_add(a,olda);b=safe_add(b,oldb);c=safe_add(c,oldc);d=safe_add(d,oldd);}
  59.  
  60.  
  61. 21.return[a,b,c,d];};var core_hmac_md5=function(key,data){var bkey=str2binl(key);if(bkey.length>16){bkey=core_md5(bkey,key.length*chrsz);}
  62.  
  63.  
  64. 22.var ipad=new Array(16),opad=new Array(16);for(var i=0;i<16;i++)
  65.  
  66.  
  67. 23.{ipad[i]=bkey[i]^0x36363636;opad[i]=bkey[i]^0x5C5C5C5C;}
  68.  
  69.  
  70. 24.var hash=core_md5(ipad.concat(str2binl(data)),512+data.length*chrsz);return core_md5(opad.concat(hash),512+128);};var obj={hexdigest:function(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz));},b64digest:function(s){return binl2b64(core_md5(str2binl(s),s.length*chrsz));},hash:function(s){return binl2str(core_md5(str2binl(s),s.length*chrsz));},hmac_hexdigest:function(key,data){return binl2hex(core_hmac_md5(key,data));},hmac_b64digest:function(key,data){return binl2b64(core_hmac_md5(key,data));},hmac_hash:function(key,data){return binl2str(core_hmac_md5(key,data));},test:function(){return MD5.hexdigest("abc")==="900150983cd24fb0d6963f7d28e17f72";}};return obj;})();if(!Function.prototype.bind){Function.prototype.bind=function(obj)
  71.  
  72.  
  73. 25.{var func=this;return function(){return func.apply(obj,arguments);};};}
  74.  
  75.  
  76. 26.if(!Function.prototype.prependArg){Function.prototype.prependArg=function(arg)
  77.  
  78.  
  79. 27.{var func=this;return function(){var newargs=[arg];for(var i=0;i<arguments.length;i++){newargs.push(arguments[i]);}
  80.  
  81.  
  82. 28.return func.apply(this,newargs);};};}
  83.  
  84.  
  85. 29.if(!Array.prototype.indexOf)
  86.  
  87.  
  88. 30.{Array.prototype.indexOf=function(elt)
  89.  
  90.  
  91. 31.{var len=this.length;var from=Number(arguments[1])||0;from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0){from+=len;}
  92.  
  93.  
  94. 32.for(;from<len;from++){if(from in this&&this[from]===elt){return from;}}
  95.  
  96.  
  97. 33.return-1;};}
  98.  
  99.  
  100. 34.(function(callback){var Strophe;function $build(name,attrs){return new Strophe.Builder(name,attrs);}
  101.  
  102.  
  103. 35.function $msg(attrs){return new Strophe.Builder("message",attrs);}
  104.  
  105.  
  106. 36.function $iq(attrs){return new Strophe.Builder("iq",attrs);}
  107.  
  108.  
  109. 37.function $pres(attrs){return new Strophe.Builder("presence",attrs);}
  110.  
  111.  
  112. 38.Strophe={VERSION:"1.0.1",NS:{HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas"},addNamespace:function(name,value)
  113.  
  114.  
  115. 39.{Strophe.NS[name]=value;},Status:{ERROR:0,CONNECTING:1,CONNFAIL:2,AUTHENTICATING:3,AUTHFAIL:4,CONNECTED:5,DISCONNECTED:6,DISCONNECTING:7,ATTACHED:8},LogLevel:{DEBUG:0,INFO:1,WARN:2,ERROR:3,FATAL:4},ElementType:{NORMAL:1,TEXT:3},TIMEOUT:1.1,SECONDARY_TIMEOUT:0.1,forEachChild:function(elem,elemName,func)
  116.  
  117.  
  118. 40.{var i,childNode;for(i=0;i<elem.childNodes.length;i++){childNode=elem.childNodes[i];if(childNode.nodeType==Strophe.ElementType.NORMAL&&(!elemName||this.isTagEqual(childNode,elemName))){func(childNode);}}},isTagEqual:function(el,name)
  119.  
  120.  
  121. 41.{return el.tagName.toLowerCase()==name.toLowerCase();},_xmlGenerator:null,_makeGenerator:function(){var doc;if(window.ActiveXObject){doc=new ActiveXObject("Microsoft.XMLDOM");doc.appendChild(doc.createElement('strophe'));}else{doc=document.implementation.createDocument('jabber:client','strophe',null);}
  122.  
  123.  
  124. 42.return doc;},xmlElement:function(name)
  125.  
  126.  
  127. 43.{if(!name){return null;}
  128.  
  129.  
  130. 44.var node=null;if(!Strophe._xmlGenerator){Strophe._xmlGenerator=Strophe._makeGenerator();}
  131.  
  132.  
  133. 45.node=Strophe._xmlGenerator.createElement(name);var a,i,k;for(a=1;a<arguments.length;a++){if(!arguments[a]){continue;}
  134.  
  135.  
  136. 46.if(typeof(arguments[a])=="string"||typeof(arguments[a])=="number"){node.appendChild(Strophe.xmlTextNode(arguments[a]));}else if(typeof(arguments[a])=="object"&&typeof(arguments[a].sort)=="function"){for(i=0;i<arguments[a].length;i++){if(typeof(arguments[a][i])=="object"&&typeof(arguments[a][i].sort)=="function"){node.setAttribute(arguments[a][i][0],arguments[a][i][1]);}}}else if(typeof(arguments[a])=="object"){for(k in arguments[a]){if(arguments[a].hasOwnProperty(k)){node.setAttribute(k,arguments[a][k]);}}}}
  137.  
  138.  
  139. 47.return node;},xmlescape:function(text)
  140.  
  141.  
  142. 48.{text=text.replace(/\&/g,"&amp;");text=text.replace(/</g,"&lt;");text=text.replace(/>/g,"&gt;");return text;},xmlTextNode:function(text)
  143.  
  144.  
  145. 49.{text=Strophe.xmlescape(text);if(!Strophe._xmlGenerator){Strophe._xmlGenerator=Strophe._makeGenerator();}
  146.  
  147.  
  148. 50.return Strophe._xmlGenerator.createTextNode(text);},getText:function(elem)
  149.  
  150.  
  151. 51.{if(!elem){return null;}
  152.  
  153.  
  154. 52.var str="";if(elem.childNodes.length===0&&elem.nodeType==Strophe.ElementType.TEXT){str+=elem.nodeValue;}
  155.  
  156.  
  157. 53.for(var i=0;i<elem.childNodes.length;i++){if(elem.childNodes[i].nodeType==Strophe.ElementType.TEXT){str+=elem.childNodes[i].nodeValue;}}
  158.  
  159.  
  160. 54.return str;},copyElement:function(elem)
  161.  
  162.  
  163. 55.{var i,el;if(elem.nodeType==Strophe.ElementType.NORMAL){el=Strophe.xmlElement(elem.tagName);for(i=0;i<elem.attributes.length;i++){el.setAttribute(elem.attributes[i].nodeName.toLowerCase(),elem.attributes[i].value);}
  164.  
  165.  
  166. 56.for(i=0;i<elem.childNodes.length;i++){el.appendChild(Strophe.copyElement(elem.childNodes[i]));}}else if(elem.nodeType==Strophe.ElementType.TEXT){el=Strophe.xmlTextNode(elem.nodeValue);}
  167.  
  168.  
  169. 57.return el;},escapeNode:function(node)
  170.  
  171.  
  172. 58.{return node.replace(/^\s+|\s+$/g,'').replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/\"/g,"\\22").replace(/\&/g,"\\26").replace(/\'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40");},unescapeNode:function(node)
  173.  
  174.  
  175. 59.{return node.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\");},getNodeFromJid:function(jid)
  176.  
  177.  
  178. 60.{if(jid.indexOf("@")<0){return null;}
  179.  
  180.  
  181. 61.return jid.split("@")[0];},getDomainFromJid:function(jid)
  182.  
  183.  
  184. 62.{var bare=Strophe.getBareJidFromJid(jid);if(bare.indexOf("@")<0){return bare;}else{var parts=bare.split("@");parts.splice(0,1);return parts.join('@');}},getResourceFromJid:function(jid)
  185.  
  186.  
  187. 63.{var s=jid.split("/");if(s.length<2){return null;}
  188.  
  189.  
  190. 64.s.splice(0,1);return s.join('/');},getBareJidFromJid:function(jid)
  191.  
  192.  
  193. 65.{return jid.split("/")[0];},log:function(level,msg)
  194.  
  195.  
  196. 66.{return;},debug:function(msg)
  197.  
  198.  
  199. 67.{this.log(this.LogLevel.DEBUG,msg);},info:function(msg)
  200.  
  201.  
  202. 68.{this.log(this.LogLevel.INFO,msg);},warn:function(msg)
  203.  
  204.  
  205. 69.{this.log(this.LogLevel.WARN,msg);},error:function(msg)
  206.  
  207.  
  208. 70.{this.log(this.LogLevel.ERROR,msg);},fatal:function(msg)
  209.  
  210.  
  211. 71.{this.log(this.LogLevel.FATAL,msg);},serialize:function(elem)
  212.  
  213.  
  214. 72.{var result;if(!elem){return null;}
  215.  
  216.  
  217. 73.if(typeof(elem.tree)==="function"){elem=elem.tree();}
  218.  
  219.  
  220. 74.var nodeName=elem.nodeName;var i,child;if(elem.getAttribute("_realname")){nodeName=elem.getAttribute("_realname");}
  221.  
  222.  
  223. 75.result="<"+nodeName;for(i=0;i<elem.attributes.length;i++){if(elem.attributes[i].nodeName!="_realname"){result+=" "+elem.attributes[i].nodeName.toLowerCase()+"='"+elem.attributes[i].value.replace("&","&amp;").replace("'","&apos;").replace("<","&lt;")+"'";}}
  224.  
  225.  
  226. 76.if(elem.childNodes.length>0){result+=">";for(i=0;i<elem.childNodes.length;i++){child=elem.childNodes[i];if(child.nodeType==Strophe.ElementType.NORMAL){result+=Strophe.serialize(child);}else if(child.nodeType==Strophe.ElementType.TEXT){result+=child.nodeValue;}}
  227.  
  228.  
  229. 77.result+="</"+nodeName+">";}else{result+="/>";}
  230.  
  231.  
  232. 78.return result;},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(name,ptype)
  233.  
  234.  
  235. 79.{Strophe._connectionPlugins[name]=ptype;}};Strophe.Builder=function(name,attrs)
  236.  
  237.  
  238. 80.{if(name=="presence"||name=="message"||name=="iq"){if(attrs&&!attrs.xmlns){attrs.xmlns=Strophe.NS.CLIENT;}else if(!attrs){attrs={xmlns:Strophe.NS.CLIENT};}}
  239.  
  240.  
  241. 81.this.nodeTree=Strophe.xmlElement(name,attrs);this.node=this.nodeTree;};Strophe.Builder.prototype={tree:function()
  242.  
  243.  
  244. 82.{return this.nodeTree;},toString:function()
  245.  
  246.  
  247. 83.{return Strophe.serialize(this.nodeTree);},up:function()
  248.  
  249.  
  250. 84.{this.node=this.node.parentNode;return this;},attrs:function(moreattrs)
  251.  
  252.  
  253. 85.{for(var k in moreattrs){if(moreattrs.hasOwnProperty(k)){this.node.setAttribute(k,moreattrs[k]);}}
  254.  
  255.  
  256. 86.return this;},c:function(name,attrs)
  257.  
  258.  
  259. 87.{var child=Strophe.xmlElement(name,attrs);this.node.appendChild(child);this.node=child;return this;},cnode:function(elem)
  260.  
  261.  
  262. 88.{this.node.appendChild(elem);this.node=elem;return this;},t:function(text)
  263.  
  264.  
  265. 89.{var child=Strophe.xmlTextNode(text);this.node.appendChild(child);return this;}};Strophe.Handler=function(handler,ns,name,type,id,from,options)
  266.  
  267.  
  268. 90.{this.handler=handler;this.ns=ns;this.name=name;this.type=type;this.id=id;this.options=options||{matchbare:false};if(!this.options.matchBare){this.options.matchBare=false;}
  269.  
  270.  
  271. 91.if(this.options.matchBare){this.from=Strophe.getBareJidFromJid(from);}else{this.from=from;}
  272.  
  273.  
  274. 92.this.user=true;};Strophe.Handler.prototype={isMatch:function(elem)
  275.  
  276.  
  277. 93.{var nsMatch;var from=null;if(this.options.matchBare){from=Strophe.getBareJidFromJid(elem.getAttribute('from'));}else{from=elem.getAttribute('from');}
  278.  
  279.  
  280. 94.nsMatch=false;if(!this.ns){nsMatch=true;}else{var self=this;Strophe.forEachChild(elem,null,function(elem){if(elem.getAttribute("xmlns")==self.ns){nsMatch=true;}});nsMatch=nsMatch||elem.getAttribute("xmlns")==this.ns;}
  281.  
  282.  
  283. 95.if(nsMatch&&(!this.name||Strophe.isTagEqual(elem,this.name))&&(!this.type||elem.getAttribute("type")===this.type)&&(!this.id||elem.getAttribute("id")===this.id)&&(!this.from||from===this.from)){return true;}
  284.  
  285.  
  286. 96.return false;},run:function(elem)
  287.  
  288.  
  289. 97.{var result=null;try{result=this.handler(elem);}catch(e){if(e.sourceURL){Strophe.fatal("error: "+this.handler+" "+e.sourceURL+":"+
  290.  
  291.  
  292. 98.e.line+" - "+e.name+": "+e.message);}else if(e.fileName){if(typeof(console)!="undefined"){console.trace();console.error(this.handler," - error - ",e,e.message);}
  293.  
  294.  
  295. 99.Strophe.fatal("error: "+this.handler+" "+
  296.  
  297.  
  298. 100.e.fileName+":"+e.lineNumber+" - "+
  299.  
  300.  
  301. 101.e.name+": "+e.message);}else{Strophe.fatal("error: "+this.handler);}
  302.  
  303.  
  304. 102.throw e;}
  305.  
  306.  
  307. 103.return result;},toString:function()
  308.  
  309.  
  310. 104.{return"{Handler: "+this.handler+"("+this.name+","+
  311.  
  312.  
  313. 105.this.id+","+this.ns+")}";}};Strophe.TimedHandler=function(period,handler)
  314.  
  315.  
  316. 106.{this.period=period;this.handler=handler;this.lastCalled=new Date().getTime();this.user=true;};Strophe.TimedHandler.prototype={run:function()
  317.  
  318.  
  319. 107.{this.lastCalled=new Date().getTime();return this.handler();},reset:function()
  320.  
  321.  
  322. 108.{this.lastCalled=new Date().getTime();},toString:function()
  323.  
  324.  
  325. 109.{return"{TimedHandler: "+this.handler+"("+this.period+")}";}};Strophe.Request=function(elem,func,rid,sends)
  326.  
  327.  
  328. 110.{this.id=++Strophe._requestId;this.xmlData=elem;this.data=Strophe.serialize(elem);this.origFunc=func;this.func=func;this.rid=rid;this.date=NaN;this.sends=sends||0;this.abort=false;this.dead=null;this.age=function(){if(!this.date){return 0;}
  329.  
  330.  
  331. 111.var now=new Date();return(now-this.date)/1000;};this.timeDead=function(){if(!this.dead){return 0;}
  332.  
  333.  
  334. 112.var now=new Date();return(now-this.dead)/1000;};this.xhr=this._newXHR();};Strophe.Request.prototype={getResponse:function()
  335.  
  336.  
  337. 113.{var node=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){node=this.xhr.responseXML.documentElement;if(node.tagName=="parsererror"){Strophe.error("invalid response received");Strophe.error("responseText: "+this.xhr.responseText);Strophe.error("responseXML: "+
  338.  
  339.  
  340. 114.Strophe.serialize(this.xhr.responseXML));throw"parsererror";}}else if(this.xhr.responseText){Strophe.error("invalid response received");Strophe.error("responseText: "+this.xhr.responseText);Strophe.error("responseXML: "+
  341.  
  342.  
  343. 115.Strophe.serialize(this.xhr.responseXML));}
  344.  
  345.  
  346. 116.return node;},_newXHR:function()
  347.  
  348.  
  349. 117.{var xhr=null;if(window.XMLHttpRequest){xhr=new XMLHttpRequest();if(xhr.overrideMimeType){xhr.overrideMimeType("text/xml");}}else if(window.ActiveXObject){xhr=new ActiveXObject("Microsoft.XMLHTTP");}
  350.  
  351.  
  352. 118.xhr.onreadystatechange=this.func.prependArg(this);return xhr;}};Strophe.Connection=function(service)
  353.  
  354.  
  355. 119.{this.service=service;this.jid="";this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this._idleTimeout=null;this._disconnectTimeout=null;this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this.paused=false;this.hold=1;this.wait=60;this.window=5;this._data=[];this._requests=[];this._uniqueId=Math.round(Math.random()*10000);this._sasl_success_handler=null;this._sasl_failure_handler=null;this._sasl_challenge_handler=null;this._idleTimeout=setTimeout(this._onIdle.bind(this),100);for(var k in Strophe._connectionPlugins){if(Strophe._connectionPlugins.hasOwnProperty(k)){var ptype=Strophe._connectionPlugins[k];var F=function(){};F.prototype=ptype;this[k]=new F();this[k].init(this);}}};Strophe.Connection.prototype={reset:function()
  356.  
  357.  
  358. 120.{this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this._requests=[];this._uniqueId=Math.round(Math.random()*10000);},pause:function()
  359.  
  360.  
  361. 121.{this.paused=true;},resume:function()
  362.  
  363.  
  364. 122.{this.paused=false;},getUniqueId:function(suffix)
  365.  
  366.  
  367. 123.{if(typeof(suffix)=="string"||typeof(suffix)=="number"){return++this._uniqueId+":"+suffix;}else{return++this._uniqueId+"";}},connect:function(jid,pass,callback,wait,hold)
  368.  
  369.  
  370. 124.{this.jid=jid;this.pass=pass;this.connect_callback=callback;this.disconnecting=false;this.connected=false;this.authenticated=false;this.errors=0;this.wait=wait||this.wait;this.hold=hold||this.hold;this.domain=Strophe.getDomainFromJid(this.jid);var body=this._buildBody().attrs({to:this.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":Strophe.NS.BOSH});this._changeConnectStatus(Strophe.Status.CONNECTING,null);this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._connect_cb.bind(this)),body.tree().getAttribute("rid")));this._throttledRequestHandler();},attach:function(jid,sid,rid,callback,wait,hold,wind)
  371.  
  372.  
  373. 125.{this.jid=jid;this.sid=sid;this.rid=rid;this.connect_callback=callback;this.domain=Strophe.getDomainFromJid(this.jid);this.authenticated=true;this.connected=true;this.wait=wait||this.wait;this.hold=hold||this.hold;this.window=wind||this.window;this._changeConnectStatus(Strophe.Status.ATTACHED,null);},xmlInput:function(elem)
  374.  
  375.  
  376. 126.{return;},xmlOutput:function(elem)
  377.  
  378.  
  379. 127.{return;},rawInput:function(data)
  380.  
  381.  
  382. 128.{return;},rawOutput:function(data)
  383.  
  384.  
  385. 129.{return;},send:function(elem)
  386.  
  387.  
  388. 130.{if(elem===null){return;}
  389.  
  390.  
  391. 131.if(typeof(elem.sort)==="function"){for(var i=0;i<elem.length;i++){this._queueData(elem[i]);}}else if(typeof(elem.tree)==="function"){this._queueData(elem.tree());}else{this._queueData(elem);}
  392.  
  393.  
  394. 132.this._throttledRequestHandler();clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100);},flush:function()
  395.  
  396.  
  397. 133.{clearTimeout(this._idleTimeout);this._onIdle();},sendIQ:function(elem,callback,errback,timeout){var timeoutHandler=null;var that=this;if(typeof(elem.tree)==="function"){elem=elem.tree();}
  398.  
  399.  
  400. 134.var id=elem.getAttribute('id');if(!id){id=this.getUniqueId("sendIQ");elem.setAttribute("id",id);}
  401.  
  402.  
  403. 135.var handler=this.addHandler(function(stanza){if(timeoutHandler){that.deleteTimedHandler(timeoutHandler);}
  404.  
  405.  
  406. 136.var iqtype=stanza.getAttribute('type');if(iqtype==='result'){if(callback){callback(stanza);}}else if(iqtype==='error'){if(errback){errback(stanza);}}else{throw{name:"StropheError",message:"Got bad IQ type of "+iqtype};}},null,'iq',null,id);if(timeout){timeoutHandler=this.addTimedHandler(timeout,function(){that.deleteHandler(handler);if(errback){errback(null);}
  407.  
  408.  
  409. 137.return false;});}
  410.  
  411.  
  412. 138.this.send(elem);return id;},_queueData:function(element){if(element===null||!element.tagName||!element.childNodes){throw{name:"StropheError",message:"Cannot queue non-DOMElement."};}
  413.  
  414.  
  415. 139.this._data.push(element);},_sendRestart:function()
  416.  
  417.  
  418. 140.{this._data.push("restart");this._throttledRequestHandler();clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100);},addTimedHandler:function(period,handler)
  419.  
  420.  
  421. 141.{var thand=new Strophe.TimedHandler(period,handler);this.addTimeds.push(thand);return thand;},deleteTimedHandler:function(handRef)
  422.  
  423.  
  424. 142.{this.removeTimeds.push(handRef);},addHandler:function(handler,ns,name,type,id,from,options)
  425.  
  426.  
  427. 143.{var hand=new Strophe.Handler(handler,ns,name,type,id,from,options);this.addHandlers.push(hand);return hand;},deleteHandler:function(handRef)
  428.  
  429.  
  430. 144.{this.removeHandlers.push(handRef);},disconnect:function(reason)
  431.  
  432.  
  433. 145.{this._changeConnectStatus(Strophe.Status.DISCONNECTING,reason);Strophe.info("Disconnect was called because: "+reason);if(this.connected){this._disconnectTimeout=this._addSysTimedHandler(3000,this._onDisconnectTimeout.bind(this));this._sendTerminate();}},_changeConnectStatus:function(status,condition)
  434.  
  435.  
  436. 146.{for(var k in Strophe._connectionPlugins){if(Strophe._connectionPlugins.hasOwnProperty(k)){var plugin=this[k];if(plugin.statusChanged){try{plugin.statusChanged(status,condition);}catch(err){Strophe.error(""+k+" plugin caused an exception "+"changing status: "+err);}}}}
  437.  
  438.  
  439. 147.if(this.connect_callback){try{this.connect_callback(status,condition);}catch(e){Strophe.error("User connection callback caused an "+"exception: "+e);}}},_buildBody:function()
  440.  
  441.  
  442. 148.{var bodyWrap=$build('body',{rid:this.rid++,xmlns:Strophe.NS.HTTPBIND});if(this.sid!==null){bodyWrap.attrs({sid:this.sid});}
  443.  
  444.  
  445. 149.return bodyWrap;},_removeRequest:function(req)
  446.  
  447.  
  448. 150.{Strophe.debug("removing request");var i;for(i=this._requests.length-1;i>=0;i--){if(req==this._requests[i]){this._requests.splice(i,1);}}
  449.  
  450.  
  451. 151.req.xhr.onreadystatechange=function(){};this._throttledRequestHandler();},_restartRequest:function(i)
  452.  
  453.  
  454. 152.{var req=this._requests[i];if(req.dead===null){req.dead=new Date();}
  455.  
  456.  
  457. 153.this._processRequest(i);},_processRequest:function(i)
  458.  
  459.  
  460. 154.{var req=this._requests[i];var reqStatus=-1;try{if(req.xhr.readyState==4){reqStatus=req.xhr.status;}}catch(e){Strophe.error("caught an error in _requests["+i+"], reqStatus: "+reqStatus);}
  461.  
  462.  
  463. 155.if(typeof(reqStatus)=="undefined"){reqStatus=-1;}
  464.  
  465.  
  466. 156.var time_elapsed=req.age();var primaryTimeout=(!isNaN(time_elapsed)&&time_elapsed>Math.floor(Strophe.TIMEOUT*this.wait));var secondaryTimeout=(req.dead!==null&&req.timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait));var requestCompletedWithServerError=(req.xhr.readyState==4&&(reqStatus<1||reqStatus>=500));if(primaryTimeout||secondaryTimeout||requestCompletedWithServerError){if(secondaryTimeout){Strophe.error("Request "+
  467.  
  468.  
  469. 157.this._requests[i].id+" timed out (secondary), restarting");}
  470.  
  471.  
  472. 158.req.abort=true;req.xhr.abort();req.xhr.onreadystatechange=function(){};this._requests[i]=new Strophe.Request(req.xmlData,req.origFunc,req.rid,req.sends);req=this._requests[i];}
  473.  
  474.  
  475. 159.if(req.xhr.readyState===0){Strophe.debug("request id "+req.id+"."+req.sends+" posting");req.date=new Date();try{var async=!('sync'in this&&this.sync===true);req.xhr.open("POST",this.service,async);}catch(e2){Strophe.error("XHR open failed.");if(!this.connected){this._changeConnectStatus(Strophe.Status.CONNFAIL,"bad-service");}
  476.  
  477.  
  478. 160.this.disconnect();return;}
  479.  
  480.  
  481. 161.var sendFunc=function(){req.xhr.send(req.data);};if(req.sends>1){var backoff=Math.pow(req.sends,3)*1000;setTimeout(sendFunc,backoff);}else{sendFunc();}
  482.  
  483.  
  484. 162.req.sends++;this.xmlOutput(req.xmlData);this.rawOutput(req.data);}else{Strophe.debug("_processRequest: "+
  485.  
  486.  
  487. 163.(i===0?"first":"second")+" request has readyState of "+
  488.  
  489.  
  490. 164.req.xhr.readyState);}},_throttledRequestHandler:function()
  491.  
  492.  
  493. 165.{if(!this._requests){Strophe.debug("_throttledRequestHandler called with "+"undefined requests");}else{Strophe.debug("_throttledRequestHandler called with "+
  494.  
  495.  
  496. 166.this._requests.length+" requests");}
  497.  
  498.  
  499. 167.if(!this._requests||this._requests.length===0){return;}
  500.  
  501.  
  502. 168.if(this._requests.length>0){this._processRequest(0);}
  503.  
  504.  
  505. 169.if(this._requests.length>1&&Math.abs(this._requests[0].rid-
  506.  
  507.  
  508. 170.this._requests[1].rid)<this.window-1){this._processRequest(1);}},_onRequestStateChange:function(func,req)
  509.  
  510.  
  511. 171.{Strophe.debug("request id "+req.id+"."+req.sends+" state changed to "+
  512.  
  513.  
  514. 172.req.xhr.readyState);if(req.abort){req.abort=false;return;}
  515.  
  516.  
  517. 173.var reqStatus;if(req.xhr.readyState==4){reqStatus=0;try{reqStatus=req.xhr.status;}catch(e){}
  518.  
  519.  
  520. 174.if(typeof(reqStatus)=="undefined"){reqStatus=0;}
  521.  
  522.  
  523. 175.if(this.disconnecting){if(reqStatus>=400){this._hitError(reqStatus);return;}}
  524.  
  525.  
  526. 176.var reqIs0=(this._requests[0]==req);var reqIs1=(this._requests[1]==req);if((reqStatus>0&&reqStatus<500)||req.sends>5){this._removeRequest(req);Strophe.debug("request id "+
  527.  
  528.  
  529. 177.req.id+" should now be removed");}
  530.  
  531.  
  532. 178.if(reqStatus==200){if(reqIs1||(reqIs0&&this._requests.length>0&&this._requests[0].age()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait))){this._restartRequest(0);}
  533.  
  534.  
  535. 179.Strophe.debug("request id "+
  536.  
  537.  
  538. 180.req.id+"."+
  539.  
  540.  
  541. 181.req.sends+" got 200");func(req);this.errors=0;}else{Strophe.error("request id "+
  542.  
  543.  
  544. 182.req.id+"."+
  545.  
  546.  
  547. 183.req.sends+" error "+reqStatus+" happened");if(reqStatus===0||(reqStatus>=400&&reqStatus<600)||reqStatus>=12000){this._hitError(reqStatus);if(reqStatus>=400&&reqStatus<500){this._changeConnectStatus(Strophe.Status.DISCONNECTING,null);this._doDisconnect();}}}
  548.  
  549.  
  550. 184.if(!((reqStatus>0&&reqStatus<10000)||req.sends>5)){this._throttledRequestHandler();}}},_hitError:function(reqStatus)
  551.  
  552.  
  553. 185.{this.errors++;Strophe.warn("request errored, status: "+reqStatus+", number of errors: "+this.errors);if(this.errors>4){this._onDisconnectTimeout();}},_doDisconnect:function()
  554.  
  555.  
  556. 186.{Strophe.info("_doDisconnect was called");this.authenticated=false;this.disconnecting=false;this.sid=null;this.streamId=null;this.rid=Math.floor(Math.random()*4294967295);if(this.connected){this._changeConnectStatus(Strophe.Status.DISCONNECTED,null);this.connected=false;}
  557.  
  558.  
  559. 187.this.handlers=[];this.timedHandlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];},_dataRecv:function(req)
  560.  
  561.  
  562. 188.{try{var elem=req.getResponse();}catch(e){if(e!="parsererror"){throw e;}
  563.  
  564.  
  565. 189.this.disconnect("strophe-parsererror");}
  566.  
  567.  
  568. 190.if(elem===null){return;}
  569.  
  570.  
  571. 191.this.xmlInput(elem);this.rawInput(Strophe.serialize(elem));var i,hand;while(this.removeHandlers.length>0){hand=this.removeHandlers.pop();i=this.handlers.indexOf(hand);if(i>=0){this.handlers.splice(i,1);}}
  572.  
  573.  
  574. 192.while(this.addHandlers.length>0){this.handlers.push(this.addHandlers.pop());}
  575.  
  576.  
  577. 193.if(this.disconnecting&&this._requests.length===0){this.deleteTimedHandler(this._disconnectTimeout);this._disconnectTimeout=null;this._doDisconnect();return;}
  578.  
  579.  
  580. 194.var typ=elem.getAttribute("type");var cond,conflict;if(typ!==null&&typ=="terminate"){cond=elem.getAttribute("condition");conflict=elem.getElementsByTagName("conflict");if(cond!==null){if(cond=="remote-stream-error"&&conflict.length>0){cond="conflict";}
  581.  
  582.  
  583. 195.this._changeConnectStatus(Strophe.Status.CONNFAIL,cond);}else{this._changeConnectStatus(Strophe.Status.CONNFAIL,"unknown");}
  584.  
  585.  
  586. 196.this.disconnect();return;}
  587.  
  588.  
  589. 197.var self=this;Strophe.forEachChild(elem,null,function(child){var i,newList;newList=self.handlers;self.handlers=[];for(i=0;i<newList.length;i++){var hand=newList[i];if(hand.isMatch(child)&&(self.authenticated||!hand.user)){if(hand.run(child)){self.handlers.push(hand);}}else{self.handlers.push(hand);}}});},_sendTerminate:function()
  590.  
  591.  
  592. 198.{Strophe.info("_sendTerminate was called");var body=this._buildBody().attrs({type:"terminate"});if(this.authenticated){body.c('presence',{xmlns:Strophe.NS.CLIENT,type:'unavailable'});}
  593.  
  594.  
  595. 199.this.disconnecting=true;var req=new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._dataRecv.bind(this)),body.tree().getAttribute("rid"));this._requests.push(req);this._throttledRequestHandler();},_connect_cb:function(req)
  596.  
  597.  
  598. 200.{Strophe.info("_connect_cb was called");this.connected=true;var bodyWrap=req.getResponse();if(!bodyWrap){return;}
  599.  
  600.  
  601. 201.this.xmlInput(bodyWrap);this.rawInput(Strophe.serialize(bodyWrap));var typ=bodyWrap.getAttribute("type");var cond,conflict;if(typ!==null&&typ=="terminate"){cond=bodyWrap.getAttribute("condition");conflict=bodyWrap.getElementsByTagName("conflict");if(cond!==null){if(cond=="remote-stream-error"&&conflict.length>0){cond="conflict";}
  602.  
  603.  
  604. 202.this._changeConnectStatus(Strophe.Status.CONNFAIL,cond);}else{this._changeConnectStatus(Strophe.Status.CONNFAIL,"unknown");}
  605.  
  606.  
  607. 203.return;}
  608.  
  609.  
  610. 204.if(!this.sid){this.sid=bodyWrap.getAttribute("sid");}
  611.  
  612.  
  613. 205.if(!this.stream_id){this.stream_id=bodyWrap.getAttribute("authid");}
  614.  
  615.  
  616. 206.var wind=bodyWrap.getAttribute('requests');if(wind){this.window=parseInt(wind,10);}
  617.  
  618.  
  619. 207.var hold=bodyWrap.getAttribute('hold');if(hold){this.hold=parseInt(hold,10);}
  620.  
  621.  
  622. 208.var wait=bodyWrap.getAttribute('wait');if(wait){this.wait=parseInt(wait,10);}
  623.  
  624.  
  625. 209.var do_sasl_plain=false;var do_sasl_digest_md5=false;var do_sasl_anonymous=false;var mechanisms=bodyWrap.getElementsByTagName("mechanism");var i,mech,auth_str,hashed_auth_str;if(mechanisms.length>0){for(i=0;i<mechanisms.length;i++){mech=Strophe.getText(mechanisms[i]);if(mech=='DIGEST-MD5'){do_sasl_digest_md5=true;}else if(mech=='PLAIN'){do_sasl_plain=true;}else if(mech=='ANONYMOUS'){do_sasl_anonymous=true;}}}else{var body=this._buildBody();this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._connect_cb.bind(this)),body.tree().getAttribute("rid")));this._throttledRequestHandler();return;}
  626.  
  627.  
  628. 210.if(Strophe.getNodeFromJid(this.jid)===null&&do_sasl_anonymous){this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build("auth",{xmlns:Strophe.NS.SASL,mechanism:"ANONYMOUS"}).tree());}else if(Strophe.getNodeFromJid(this.jid)===null){this._changeConnectStatus(Strophe.Status.CONNFAIL,'x-strophe-bad-non-anon-jid');this.disconnect();}else if(do_sasl_digest_md5){this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge1_cb.bind(this),null,"challenge",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build("auth",{xmlns:Strophe.NS.SASL,mechanism:"DIGEST-MD5"}).tree());}else if(do_sasl_plain){auth_str=Strophe.getBareJidFromJid(this.jid);auth_str=auth_str+"\u0000";auth_str=auth_str+Strophe.getNodeFromJid(this.jid);auth_str=auth_str+"\u0000";auth_str=auth_str+this.pass;this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);hashed_auth_str=Base64.encode(auth_str);this.send($build("auth",{xmlns:Strophe.NS.SASL,mechanism:"PLAIN"}).t(hashed_auth_str).tree());}else{this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._addSysHandler(this._auth1_cb.bind(this),null,null,null,"_auth_1");this.send($iq({type:"get",to:this.domain,id:"_auth_1"}).c("query",{xmlns:Strophe.NS.AUTH}).c("username",{}).t(Strophe.getNodeFromJid(this.jid)).tree());}},_sasl_challenge1_cb:function(elem)
  629.  
  630.  
  631. 211.{var attribMatch=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/;var challenge=Base64.decode(Strophe.getText(elem));var cnonce=MD5.hexdigest(Math.random()*1234567890);var realm="";var host=null;var nonce="";var qop="";var matches;this.deleteHandler(this._sasl_failure_handler);while(challenge.match(attribMatch)){matches=challenge.match(attribMatch);challenge=challenge.replace(matches[0],"");matches[2]=matches[2].replace(/^"(.+)"$/,"$1");switch(matches[1]){case"realm":realm=matches[2];break;case"nonce":nonce=matches[2];break;case"qop":qop=matches[2];break;case"host":host=matches[2];break;}}
  632.  
  633.  
  634. 212.var digest_uri="xmpp/"+this.domain;if(host!==null){digest_uri=digest_uri+"/"+host;}
  635.  
  636.  
  637. 213.var A1=MD5.hash(Strophe.getNodeFromJid(this.jid)+":"+realm+":"+this.pass)+":"+nonce+":"+cnonce;var A2='AUTHENTICATE:'+digest_uri;var responseText="";responseText+='username='+
  638.  
  639.  
  640. 214.this._quote(Strophe.getNodeFromJid(this.jid))+',';responseText+='realm='+this._quote(realm)+',';responseText+='nonce='+this._quote(nonce)+',';responseText+='cnonce='+this._quote(cnonce)+',';responseText+='nc="00000001",';responseText+='qop="auth",';responseText+='digest-uri='+this._quote(digest_uri)+',';responseText+='response='+this._quote(MD5.hexdigest(MD5.hexdigest(A1)+":"+
  641.  
  642.  
  643. 215.nonce+":00000001:"+
  644.  
  645.  
  646. 216.cnonce+":auth:"+
  647.  
  648.  
  649. 217.MD5.hexdigest(A2)))+',';responseText+='charset="utf-8"';this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge2_cb.bind(this),null,"challenge",null,null);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build('response',{xmlns:Strophe.NS.SASL}).t(Base64.encode(responseText)).tree());return false;},_quote:function(str)
  650.  
  651.  
  652. 218.{return'"'+str.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"';},_sasl_challenge2_cb:function(elem)
  653.  
  654.  
  655. 219.{this.deleteHandler(this._sasl_success_handler);this.deleteHandler(this._sasl_failure_handler);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build('response',{xmlns:Strophe.NS.SASL}).tree());return false;},_auth1_cb:function(elem)
  656.  
  657.  
  658. 220.{var iq=$iq({type:"set",id:"_auth_2"}).c('query',{xmlns:Strophe.NS.AUTH}).c('username',{}).t(Strophe.getNodeFromJid(this.jid)).up().c('password').t(this.pass);if(!Strophe.getResourceFromJid(this.jid)){this.jid=Strophe.getBareJidFromJid(this.jid)+'/strophe';}
  659.  
  660.  
  661. 221.iq.up().c('resource',{}).t(Strophe.getResourceFromJid(this.jid));this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2");this.send(iq.tree());return false;},_sasl_success_cb:function(elem)
  662.  
  663.  
  664. 222.{Strophe.info("SASL authentication succeeded.");this.deleteHandler(this._sasl_failure_handler);this._sasl_failure_handler=null;if(this._sasl_challenge_handler){this.deleteHandler(this._sasl_challenge_handler);this._sasl_challenge_handler=null;}
  665.  
  666.  
  667. 223.this._addSysHandler(this._sasl_auth1_cb.bind(this),null,"stream:features",null,null);this._sendRestart();return false;},_sasl_auth1_cb:function(elem)
  668.  
  669.  
  670. 224.{var i,child;for(i=0;i<elem.childNodes.length;i++){child=elem.childNodes[i];if(child.nodeName=='bind'){this.do_bind=true;}
  671.  
  672.  
  673. 225.if(child.nodeName=='session'){this.do_session=true;}}
  674.  
  675.  
  676. 226.if(!this.do_bind){this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}else{this._addSysHandler(this._sasl_bind_cb.bind(this),null,null,null,"_bind_auth_2");var resource=Strophe.getResourceFromJid(this.jid);if(resource){this.send($iq({type:"set",id:"_bind_auth_2"}).c('bind',{xmlns:Strophe.NS.BIND}).c('resource',{}).t(resource).tree());}else{this.send($iq({type:"set",id:"_bind_auth_2"}).c('bind',{xmlns:Strophe.NS.BIND}).tree());}}
  677.  
  678.  
  679. 227.return false;},_sasl_bind_cb:function(elem)
  680.  
  681.  
  682. 228.{if(elem.getAttribute("type")=="error"){Strophe.info("SASL binding failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}
  683.  
  684.  
  685. 229.var bind=elem.getElementsByTagName("bind");var jidNode;if(bind.length>0){jidNode=bind[0].getElementsByTagName("jid");if(jidNode.length>0){this.jid=Strophe.getText(jidNode[0]);if(this.do_session){this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2");this.send($iq({type:"set",id:"_session_auth_2"}).c('session',{xmlns:Strophe.NS.SESSION}).tree());}else{this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null);}}}else{Strophe.info("SASL binding failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}},_sasl_session_cb:function(elem)
  686.  
  687.  
  688. 230.{if(elem.getAttribute("type")=="result"){this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null);}else if(elem.getAttribute("type")=="error"){Strophe.info("Session creation failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}
  689.  
  690.  
  691. 231.return false;},_sasl_failure_cb:function(elem)
  692.  
  693.  
  694. 232.{if(this._sasl_success_handler){this.deleteHandler(this._sasl_success_handler);this._sasl_success_handler=null;}
  695.  
  696.  
  697. 233.if(this._sasl_challenge_handler){this.deleteHandler(this._sasl_challenge_handler);this._sasl_challenge_handler=null;}
  698.  
  699.  
  700. 234.this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;},_auth2_cb:function(elem)
  701.  
  702.  
  703. 235.{if(elem.getAttribute("type")=="result"){this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null);}else if(elem.getAttribute("type")=="error"){this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);this.disconnect();}
  704.  
  705.  
  706. 236.return false;},_addSysTimedHandler:function(period,handler)
  707.  
  708.  
  709. 237.{var thand=new Strophe.TimedHandler(period,handler);thand.user=false;this.addTimeds.push(thand);return thand;},_addSysHandler:function(handler,ns,name,type,id)
  710.  
  711.  
  712. 238.{var hand=new Strophe.Handler(handler,ns,name,type,id);hand.user=false;this.addHandlers.push(hand);return hand;},_onDisconnectTimeout:function()
  713.  
  714.  
  715. 239.{Strophe.info("_onDisconnectTimeout was called");var req;while(this._requests.length>0){req=this._requests.pop();req.abort=true;req.xhr.abort();req.xhr.onreadystatechange=function(){};}
  716.  
  717.  
  718. 240.this._doDisconnect();return false;},_onIdle:function()
  719.  
  720.  
  721. 241.{var i,thand,since,newList;while(this.removeTimeds.length>0){thand=this.removeTimeds.pop();i=this.timedHandlers.indexOf(thand);if(i>=0){this.timedHandlers.splice(i,1);}}
  722.  
  723.  
  724. 242.while(this.addTimeds.length>0){this.timedHandlers.push(this.addTimeds.pop());}
  725.  
  726.  
  727. 243.var now=new Date().getTime();newList=[];for(i=0;i<this.timedHandlers.length;i++){thand=this.timedHandlers[i];if(this.authenticated||!thand.user){since=thand.lastCalled+thand.period;if(since-now<=0){if(thand.run()){newList.push(thand);}}else{newList.push(thand);}}}
  728.  
  729.  
  730. 244.this.timedHandlers=newList;var body,time_elapsed;if(this.authenticated&&this._requests.length===0&&this._data.length===0&&!this.disconnecting){Strophe.info("no requests during idle cycle, sending "+"blank request");this._data.push(null);}
  731.  
  732.  
  733. 245.if(this._requests.length<2&&this._data.length>0&&!this.paused){body=this._buildBody();for(i=0;i<this._data.length;i++){if(this._data[i]!==null){if(this._data[i]==="restart"){body.attrs({to:this.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":Strophe.NS.BOSH});}else{body.cnode(this._data[i]).up();}}}
  734.  
  735.  
  736. 246.delete this._data;this._data=[];this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._dataRecv.bind(this)),body.tree().getAttribute("rid")));this._processRequest(this._requests.length-1);}
  737.  
  738.  
  739. 247.if(this._requests.length>0){time_elapsed=this._requests[0].age();if(this._requests[0].dead!==null){if(this._requests[0].timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait)){this._throttledRequestHandler();}}
  740.  
  741.  
  742. 248.if(time_elapsed>Math.floor(Strophe.TIMEOUT*this.wait)){Strophe.warn("Request "+
  743.  
  744.  
  745. 249.this._requests[0].id+" timed out, over "+Math.floor(Strophe.TIMEOUT*this.wait)+" seconds since last activity");this._throttledRequestHandler();}}
  746.  
  747.  
  748. 250.clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100);}};if(callback){callback(Strophe,$build,$msg,$iq,$pres);}})(function(){window.Strophe=arguments[0];window.$build=arguments[1];window.$msg=arguments[2];window.$iq=arguments[3];window.$pres=arguments[4];});
  749.  
  750.  
  751. 251.(function($){$.fn.jscontext=function(options){var settings={html:'default',bind:'right-click',closeOnMouseLeave:false,fade:false,fadeSpeed:"normal",show:null,open:null,close:null,mouseover:null,mouseleave:null,sticky:false};var methods={initMenu:function(elm,settings){$("html").mousemove(function(e){mouse.x=e.pageX;mouse.y=e.pageY;if(element.current!=undefined&&element.moveit){element.current.css("top",(mouse.y+10)+'px');element.current.css("left",(mouse.x+10)+'px');if(settings.mouseover!=null)
  752.  
  753.  
  754. 252.settings.mouseover.call();}});$("html").click(function(){if(element.close())
  755.  
  756.  
  757. 253.methods.closeMenu(null,null);});$("html").mouseleave(function(){methods.closeMenu(null,null);});switch(settings.bind){case"right-click":$(elm).bind("contextmenu",function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  758.  
  759.  
  760. 254.settings.show.call();element.moveit=false;return false;}});break;case"click":$(elm).click(function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  761.  
  762.  
  763. 255.settings.show.call();element.moveit=false;return false;}});break;case"anyclick":$(elm).bind("contextmenu",function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  764.  
  765.  
  766. 256.settings.show.call();element.moveit=false;return false;}});$(elm).click(function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  767.  
  768.  
  769. 257.settings.show.call();element.moveit=false;return false;}});break;case"hover":$(elm).hover(function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  770.  
  771.  
  772. 258.settings.show.call();if(settings.sticky)
  773.  
  774.  
  775. 259.element.moveit=true;return false;}},function(e){if(settings.sticky){if(element.close())
  776.  
  777.  
  778. 260.methods.closeMenu($(element.current).attr("id"),null);}
  779.  
  780.  
  781. 261.element.moveit=false;});break;}},openMenu:function(elm,settings){methods.createMenu(elm,settings);element.current=$("#"+elm.id+"jscontext");if(settings.html instanceof Function){element.current.html(settings.html(elm));}else{element.current.html(settings.html.clone(true));}
  782.  
  783.  
  784. 262.var jscontextBtn=$(".jscontextBtn");if(settings.open!=null)
  785.  
  786.  
  787. 263.settings.open.call();if(settings.closeOnMouseLeave&&!settings.sticky){element.current.mouseleave(function(){if(element.close())
  788.  
  789.  
  790. 264.methods.closeMenu($(element.current).attr("id"),null);});}
  791.  
  792.  
  793. 265.try{var winWidth=window.innerWidth||document.documentElement.clientWidth||document.body.offsetWidth;if(mouse.x>=winWidth-element.current.width())
  794.  
  795.  
  796. 266.element.current.css("left",mouse.x-(element.current.width()-15)+"px");}
  797.  
  798.  
  799. 267.catch(e){}},createMenu:function(elm,settings){var jscontextID=elm.id+"jscontext";var afterClose=function(){var jscontextElement=document.createElement('div');jscontextElement.id=jscontextID;jscontextElement.style.position='absolute';jscontextElement.style.display='none';if(mouse.y==undefined)
  800.  
  801.  
  802. 268.mouse.y=0;if(mouse.x==undefined)
  803.  
  804.  
  805. 269.mouse.x=0;jscontextElement.style.top=(mouse.y-(settings.sticky==true?0:15))+'px';jscontextElement.style.left=(mouse.x-(settings.sticky==true?0:15))+'px';jscontextElement.style.zIndex='9999';document.body.appendChild(jscontextElement);var jscontext=$("#"+jscontextID);jscontext.addClass("jscontextContainer");if(settings.fade){jscontext.fadeIn(settings.fadeSpeed);element.fade=true;}
  806.  
  807.  
  808. 270.else{jscontext.show();element.fade=false;}}
  809.  
  810.  
  811. 271.methods.closeMenu(null,afterClose);},closeMenu:function(elmID,afterClose){var remove=function(){if(elmID){if($("#"+elmID).length>0)
  812.  
  813.  
  814. 272.document.body.removeChild(document.getElementById(elmID));}
  815.  
  816.  
  817. 273.else{$(".jscontextContainer").remove();}}
  818.  
  819.  
  820. 274.if(element.fade){if(elmID){if($("#"+elmID).length>0)
  821.  
  822.  
  823. 275.$("#"+elmID).fadeOut(settings.fadeSpeed,remove);}
  824.  
  825.  
  826. 276.else{$(".jscontextContainer").fadeOut(settings.fadeSpeed,remove);}}
  827.  
  828.  
  829. 277.else{remove.call();}
  830.  
  831.  
  832. 278.if(settings.close!=null)
  833.  
  834.  
  835. 279.settings.close.call();if(afterClose!=null)
  836.  
  837.  
  838. 280.afterClose.call();}};return this.each(function(){if(options&&typeof options==='object'){$.extend(settings,options);methods.initMenu(this,settings);}
  839.  
  840.  
  841. 281.else if(typeof options==='string'){switch(options){case"":break;}}});};})(jQuery);jscontext=function(option){switch(option){case"close":$(".jscontextContainer").remove();break;}}
  842.  
  843.  
  844. 282.jscontextElm=function(elm){jscontextObj=$(elm);}
  845.  
  846.  
  847. 283.var element={current:null,moveit:false,fade:false,close:function(){if(element.current==null)
  848.  
  849.  
  850. 284.return true;if((mouse.x<element.current.position().left+5)||(mouse.x>(element.current.position().left+element.current.width()-5))||(mouse.y<element.current.position().top+5)||(mouse.y>(element.current.position().top+element.current.height()-5)))
  851.  
  852.  
  853. 285.return true;else
  854.  
  855.  
  856. 286.return false;}};var mouse={x:null,y:null};var jscontextObj=$();(function(jQuery){jQuery.hotkeys={version:"0.8.1",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",91:"command",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":"\"",",":"<",".":">","/":"?","\\":"|"}};function keyHandler(handleObj){if(typeof handleObj.data!=="string"){return;}
  857.  
  858.  
  859. 287.var origHandler=handleObj.handler,keys=handleObj.data.toLowerCase().split(" ");var isCommandPressed=false;handleObj.handler=function(event){var special=event.type!=="keypress"&&jQuery.hotkeys.specialKeys[event.which],character=String.fromCharCode(event.which).toLowerCase(),key,modif="",possible={};if(event.altKey&&special!=="alt"){modif+="alt+";}
  860.  
  861.  
  862. 288.if(event.ctrlKey&&special!=="ctrl"){modif+="ctrl+";}
  863.  
  864.  
  865. 289.if(jQuery.hotkeys.specialKeys[event.which]==="command"){isCommandPressed=true;}
  866.  
  867.  
  868. 290.if(event.metaKey&&!event.ctrlKey&&special!=="meta"&&special!=="command"){if(isCommandPressed){modif+="command+";}else{modif+="meta+";}}
  869.  
  870.  
  871. 291.if(event.shiftKey&&special!=="shift"){modif+="shift+";}
  872.  
  873.  
  874. 292.if(special){possible[modif+special]=true;}else{possible[modif+character]=true;possible[modif+jQuery.hotkeys.shiftNums[character]]=true;if(modif==="shift+"){possible[jQuery.hotkeys.shiftNums[character]]=true;}}
  875.  
  876.  
  877. 293.for(var i=0,l=keys.length;i<l;i++){if(possible[keys[i]]){isCommandPressed=false;return origHandler.apply(this,arguments);}}};}
  878.  
  879.  
  880. 294.jQuery.each(["keydown","keyup","keypress"],function(){jQuery.event.special[this]={add:keyHandler};});})(jQuery);(function($){$.fn.defchat=function(options){var settings={'domain':'localhost','username':null,'password':null,'my_username':'','textinput':this.find('input.text'),'form':this.find('form.chat-form'),'chatlist':this.find('.chat-list'),'userslist':this.find('.users-list'),'buttons':this.find('ul.buttons'),'submitbutton':this.find('.send_message_button'),'usercount':this.find('.usercount'),'subject':'','room':'mymucroom@conference.localhost','private_room':'mymucroom@conference.localhost','throttlechat':false,'throttle_message':null,'translate_message_url':null,'add_moderator_url':null,'media_url':'','ban_url':null,'silence_url':null,'is_broadcasting':false,'allow_tipping':true,'domroot':this,'font_color':'#494949','chat_font':'default','current_subject':'','login_required_callback':null,'submenu_profile_url':null,'emoticon_overlay_url':null,'tipping_current_tokens_url':null,'welcome_message':null,'welcome_warning':null,'first_post_warning':null,'parse_subject':null,'color_choices':['default','Arial, Helvetica','Bookman Old Style','"Comic Sans MS", cursive','"Courier New"','Lucida','Palantino',"Tahoma, Geneva",'"Times New Roman"'],'font_color_cookie_name':'settings_font_color','chat_font_cookie_name':'settings_chat_font','interested_in':[],'group_show_tokens_per_minute_url':null,'group_show_request_url':null,'group_show_decline_url':null,'group_show_cancel_url':null,'return_from_away_url':null,'private_show_tokens_per_minute_url':null,'private_show_request_url':null,'private_show_approve_url':null,'private_show_decline_url':null,'private_show_cancel_url':null,'scroll_on_load':true,'room_goal':{}};if(options){$.extend(settings,options);}
  881.  
  882.  
  883. 295.if(settings.is_broadcasting){settings.font_color_cookie_name='broadcast_settings_font_color';settings.chat_font_cookie_name='broadcast_settings_chat_font';}
  884.  
  885.  
  886. 296.if($.cookie(settings.font_color_cookie_name)){settings.font_color=$.cookie(settings.font_color_cookie_name);}
  887.  
  888.  
  889. 297.if($.cookie(settings.chat_font_cookie_name)){settings.chat_font=$.cookie(settings.chat_font_cookie_name);}
  890.  
  891.  
  892. 298.var default_subject=$.cookie('my_room_subject');if(!default_subject){default_subject=Strophe.getNodeFromJid(settings.room)+"'s room";}
  893.  
  894.  
  895. 299.$.extend(settings,{'user':settings.username+'@'+settings.domain,'muc_nickname':settings.username,'default_subject':default_subject,'bosh_host':'http://'+settings.domain+':5280/http-bind','roomownernick':Strophe.getNodeFromJid(settings.room),'roomowner':Strophe.getNodeFromJid(settings.room)+"@"+settings.domain});if(options){$.extend(settings,options);}
  896.  
  897.  
  898. 300.var conn=new Strophe.Connection(settings.bosh_host);function consolelog(msg){}
  899.  
  900.  
  901. 301.function get_contextual_menu_html(domele){var h=$("<div class='jscontextMenu'></div>");var nick=$(domele).data('nick');var jid=presence_monitor.participants[nick].jid;var account_name=Strophe.getNodeFromJid(jid);function add_link(cls,text,callback){var line=$("<p class='jscontextBtn "+cls+"' data-nick='"+nick+"'>"+text+"</p>");line.click(function(){jscontext('close')});line.click(callback);h.append(line);}
  902.  
  903.  
  904. 302.h.append("<p class=\"jscontextLabel\"><img src=\""+settings.media_url+"images/red-arrow-down.gif\" width=\"9\" height=\"5\" alt=\"\" />"+nick+"</p><hr>");h.append("<div class=\"submenu_profile\"></div><hr>");add_link("pm",gettext("Send private message"),function(){if(!features_unlocked()){unlock_features_required();return;}
  905.  
  906.  
  907. 303.tabs.open_pm(nick);});if(message_receiver.ignored_users.indexOf(jid)!==-1){add_link("ignore",gettext("Un-Ignore This User"),function(event){var ignorenick=$(event.target).data('nick');var ignorejid=presence_monitor.participants[ignorenick].jid;message_receiver.ignored_users=$.grep(message_receiver.ignored_users,function(a){return(a!=ignorejid);});var msg=interpolate(gettext("no longer ignoring %(username)s"),{username:ignorenick},true);add_system_message(msg,tabs.get_current_tab_domele());$('#ignored-list').find("[data-nick='"+ignorenick+"']").parent().remove();tabs._sort_ignored_users_list();ignored_user_methods.store_ignored_users();});}else{add_link("ignore",gettext("Ignore This User"),function(event){var ignorenick=$(event.target).data('nick');message_receiver.ignored_users.push(presence_monitor.participants[ignorenick].jid);var msg=interpolate(gettext("ignoring %(username)s"),{username:ignorenick},true);add_system_message(msg,tabs.get_current_tab_domele());var html="<li>"+ignorenick;html+=" (<a href='#' data-nick='"+presence_monitor.participants[ignorenick].jid;html+="' class='un-ignore'>"+gettext('Un-ignore')+"</a>)</li>";$('#ignored-list').append(html);tabs._sort_ignored_users_list();ignored_user_methods.store_ignored_users();});}
  908.  
  909.  
  910. 304.h.append("<hr>");if(presence_monitor.participants[settings.muc_nickname].role=='moderator'){add_link("",gettext("Silence for 24 hours"),function(event){var bannick=$(event.target).data('nick');var jid=presence_monitor.participants[bannick].jid;var msg=interpolate(gettext("Silence %(username)s?"),{username:bannick},true);if(confirm(msg)){msg=interpolate(gettext("Silencing %(username)s"),{username:bannick},true);add_system_message(msg,tabs.get_current_tab_domele());var account_name=Strophe.getNodeFromJid(jid);var url=settings.silence_url.replace('USERNAMESLUG',account_name);$.post(url,{'foo':'bar'});}});if(presence_monitor.participants[settings.muc_nickname].jid===settings.roomowner){add_link("",gettext("Kick/Ban"),function(event){var bannick=$(event.target).data('nick');var jid=presence_monitor.participants[bannick].jid;var msg=interpolate(gettext("Ban %(username)s?"),{username:bannick},true);if(confirm(msg)){msg=interpolate(gettext("Kicking and banning %(username)s"),{username:bannick},true);add_system_message(msg,tabs.get_current_tab_domele());var iq=$iq({to:settings.room,type:'set'}).c('query',{'xmlns':'http://jabber.org/protocol/muc#admin'}).c('item',{'affiliation':'outcast','jid':jid});consolelog(iq);conn.sendIQ(iq);var account_name=Strophe.getNodeFromJid(jid);var url=settings.ban_url.replace('USERNAMESLUG',account_name);$.post(url,{'foo':'bar'});}});if(presence_monitor.participants[nick].role!='moderator'){add_link("",gettext("Promote to Moderator"),function(event){var nick=$(event.target).data('nick');var msg=interpolate("granting moderator privileges to %(username)s",{username:nick},true);message_sender._send(msg);var iq=$iq({to:settings.room,type:'set'}).c('query',{'xmlns':'http://jabber.org/protocol/muc#admin'}).c('item',{'role':'moderator','nick':nick});consolelog(iq);conn.sendIQ(iq);var url=settings.add_moderator_url.replace('USERNAMESLUG',account_name);$.post(url,{'foo':'bar'});moderators[presence_monitor.participants[nick].jid]=true;});}else{add_link("",gettext("Remove Moderator Status"),function(event){var nick=$(event.target).data('nick');var msg=interpolate(gettext("revoking moderator privileges from %(username)s"),{username:nick},true);add_system_message(msg,tabs.get_current_tab_domele());var iq=$iq({to:settings.room,type:'set'}).c('query',{'xmlns':'http://jabber.org/protocol/muc#admin'}).c('item',{'role':'participant','nick':nick});consolelog(iq);conn.sendIQ(iq);delete moderators[presence_monitor.participants[nick].jid];});}}}
  911.  
  912.  
  913. 305.var url=settings.submenu_profile_url.replace('USERNAMESLUG',account_name);consolelog("Loading menu from "+url);h.find(".submenu_profile").load(url);return h;}
  914.  
  915.  
  916. 306.function add_system_message(message,domele){message_receiver.add_message('<div class="text"><p>'+message+'</p></div>',domele);}
  917.  
  918.  
  919. 307.function insert_user(newhtml,nick,token_balance){var sort_key=$("select[name='sort']").val();if(sort_key==undefined){if($.cookie('room_sort_by')==undefined)
  920.  
  921.  
  922. 308.sort_key='a';else{sort_key=$.cookie('room_sort_by');}}
  923.  
  924.  
  925. 309.if(!settings.is_broadcasting){sort_key='a';}
  926.  
  927.  
  928. 310.var inserted=false;settings.userslist.find("div.text").each(function(index,domEle){var $domEle=$(domEle);var domnick=String($domEle.data('nick'));if(sort_key=='a'){new_val=nick.replace('__anonymous__','zzzz');current_val=domnick.replace('__anonymous__','zzzz');}
  929.  
  930.  
  931. 311.else{new_val=parseInt(token_balance);current_val=parseInt($domEle.data('tokenbalance'));}
  932.  
  933.  
  934. 312.if((sort_key=='a')&&(new_val<current_val)){$domEle.before(newhtml);inserted=true;return false;}
  935.  
  936.  
  937. 313.if((sort_key=='t')&&(new_val>current_val)){$domEle.before(newhtml);inserted=true;return false;}});if(!inserted){settings.userslist.append(newhtml);}}
  938.  
  939.  
  940. 314.function userjoined(event,nick,token_balance){token_balance=parseInt(token_balance);if(isNaN(token_balance)){token_balance=0;}
  941.  
  942.  
  943. 315.if(nick.indexOf('__anonymous__')!=-1){token_balance=-1;}
  944.  
  945.  
  946. 316.var color='color-3';if(settings.is_broadcasting){if(token_balance<1){color='color-3';}else{color='color-4';}}
  947.  
  948.  
  949. 317.var msg=interpolate(gettext("<span class='username "+color+"' data-nick='%(username)s'"+">%(username)s</span> joined"),{username:nick},true);if(initializer.joined&&(new Date()-initializer.joined_at>10*1000)){if(presence_monitor.num_participants<5){add_system_message(msg);}else{if(settings.is_broadcasting&token_balance>=1){add_system_message(msg);}}}
  950.  
  951.  
  952. 318.if(tabs.pm_tab_map[nick]){add_system_message(msg,tabs.pm_tab_map[nick]);}
  953.  
  954.  
  955. 319.var newhtml=$("<div class='text' data-nick='"+nick+"' data-tokenbalance='"+token_balance+"'><strong class='"+
  956.  
  957.  
  958. 320.color+"'>"+nick+"</strong></div>");if(nick!=settings.muc_nickname){newhtml.jscontext({html:get_contextual_menu_html,bind:'anyclick'});}
  959.  
  960.  
  961. 321.return insert_user(newhtml,nick,token_balance);}
  962.  
  963.  
  964. 322.$(document).bind("userjoined.defchat",userjoined);function update_participants_count(){settings.usercount.text(presence_monitor.num_participants);}
  965.  
  966.  
  967. 323.setInterval(update_participants_count,2000);function yield_ownership(event,nick,token_balance){if(nick!=settings.roomownernick){return;}
  968.  
  969.  
  970. 324.if(presence_monitor.participants[settings.muc_nickname]){if(presence_monitor.participants[settings.muc_nickname].role!='moderator'){return;}}
  971.  
  972.  
  973. 325.var iq=$iq({'to':settings.room,'type':'set'}).c('query',{xmlns:'http://jabber.org/protocol/muc#admin'}).c('item',{affiliation:'owner',jid:settings.roomowner});consolelog(iq.toString());conn.sendIQ(iq);}
  974.  
  975.  
  976. 326.$(document).bind("userjoined.defchat",yield_ownership);var public_methods={_set_font_size:function(){if($.cookie('room_font_size')){var size=$.cookie('room_font_size');}
  977.  
  978.  
  979. 327.else{var size='9pt';}
  980.  
  981.  
  982. 328.$("div.chat-list").css("font-size",size);},join_group_show:function(){groups_and_privates.start_group_show_clicked();},change_title:function(title){if(title==settings.current_subject){return;}
  983.  
  984.  
  985. 329.$.cookie('my_room_subject',title,{expires:365});conn.send($msg({to:settings.room,type:'groupchat'}).c('subject').t(title));},select_emoticon:function(emoticon){settings.textinput.val(settings.textinput.val()+" "+emoticon);settings.textinput.focus();},is_goal_set:function(){return settings.room_goal.hasOwnProperty('amount');}};var ignored_user_methods={store_ignored_users:function(){var ignored_str="";for(var i=0;i<message_receiver.ignored_users.length;i++){ignored_str+="#"+message_receiver.ignored_users[i];}
  986.  
  987.  
  988. 330.$.cookie('ignored_users',ignored_str,{expires:30,path:'/'});},load_ignored_users:function(){var ignored_str=$.cookie('ignored_users');if(ignored_str==null)
  989.  
  990.  
  991. 331.return;var ignored_array=ignored_str.split('#');for(var i=0;i<ignored_array.length;i++){if(ignored_array[i]!=''){message_receiver.ignored_users.push(ignored_array[i]);}}}};function reassign_moderator(event,nick,token_balance){if(presence_monitor.participants[settings.muc_nickname]){if(presence_monitor.participants[settings.muc_nickname].role!='moderator'){return;}}
  992.  
  993.  
  994. 332.if(!moderators[presence_monitor.participants[nick].jid]){return;}
  995.  
  996.  
  997. 333.var iq=$iq({to:settings.room,type:'set'}).c('query',{'xmlns':'http://jabber.org/protocol/muc#admin'}).c('item',{'role':'moderator','nick':nick});consolelog(iq.toString());conn.sendIQ(iq);}
  998.  
  999.  
  1000. 334.$(document).bind("userjoined.defchat",reassign_moderator);function remove_user_from_list(nick){settings.userslist.find("[data-nick='"+nick+"']").remove();}
  1001.  
  1002.  
  1003. 335.function userleft(event,nick){var msg=interpolate(gettext("%(username)s has disconnected"),{username:nick},true);if(presence_monitor.num_participants<5){add_system_message(msg);}
  1004.  
  1005.  
  1006. 336.if(tabs.pm_tab_map[nick]){add_system_message(msg,tabs.pm_tab_map[nick]);}
  1007.  
  1008.  
  1009. 337.remove_user_from_list(nick);}
  1010.  
  1011.  
  1012. 338.$(document).bind("userleft.defchat",userleft);$(document).bind("disconnected.defchat",function(){add_system_message(gettext("chat disconnected"));});$(document).bind("connectionfailed.defchat",function(){add_system_message(gettext("unable to connect"));});$(document).bind("connecting.defchat",function(){add_system_message(gettext("connecting"));});function connected(){add_system_message(gettext("connection established"));conn.send($pres().c('priority').t('-1'));initializer.join_room();if(settings.welcome_message){add_system_message(settings.welcome_message);}
  1013.  
  1014.  
  1015. 339.if(settings.welcome_warning){add_system_message(settings.welcome_warning);}
  1016.  
  1017.  
  1018. 340.$(window).unload(function(){conn.sync=true;var msg=$pres({to:settings.room,type:'unavailable'});conn.send(msg);conn.disconnect();conn.flush();});}
  1019.  
  1020.  
  1021. 341.$(document).bind("connected.defchat",connected);var tabs={pm_tab_visible:false,current_tab:'chat',pm_tab:null,pm_tab_map:{},settings_body:null,unread_pm_map:{},total_unread_pms:0,current_pm_nick:null,opened_pms:new Array(),is_blinking:false,open_pm:function(nick){tabs._show_pm_tab();tabs._remove_unread_pms_for_nick(nick);settings.domroot.find('> div').hide();tabs.get_or_create_pm_tab_for_nick(nick,false).show();tabs.current_tab='pm';tabs.current_pm_nick=nick;tabs._enable_form();settings.textinput.focus();tabs._scroll_to_bottom();},close_pm:function(nick){tabs._show_pm_tab();tabs._remove_unread_pms_for_nick(nick);settings.domroot.find('> div').hide();tabs.pm_tab_map[nick].remove();tabs.pm_tab_map[nick]=null;tabs._show_chat_tab();var newopens=new Array();for(var i=0;i<tabs.opened_pms.length;i++){if(tabs.opened_pms[i]!=nick){newopens.push(tabs.opened_pms[i]);}}
  1022.  
  1023.  
  1024. 342.tabs.opened_pms=newopens;},on_tab_click:function(){var tab=$(this).data("tab");settings.domroot.find('> div').hide();if(tab=='users'){tabs._deactivate_tabs();$(this).closest('li').addClass('active');settings.domroot.find('> div.users-list').show();tabs.current_tab='users';tabs._disable_form();}else if(tab=='chat'){tabs._show_chat_tab();}else if(tab=='settings'){tabs._show_settings_tab();tabs._disable_form();}else{consolelog("Unknown tab "+tab);}
  1025.  
  1026.  
  1027. 343.return false;},get_or_create_pm_tab_for_nick:function(nick,show_alert){if(tabs.pm_tab_map[nick]){return tabs.pm_tab_map[nick];}
  1028.  
  1029.  
  1030. 344.if(show_alert){var msg=interpolate(gettext("New private conversation from <span class='username' data-nick='%(username)s'>%(username)s</span> <span class='pmalert'>(click the PM tab)</span>"),{username:nick},true);add_system_message(msg);}
  1031.  
  1032.  
  1033. 345.tabs.opened_pms.push(nick);tabs.opened_pms.sort();tabs._create_pm_tab();if(tabs.opened_pms.length>1){tabs._set_pm_tab_jscontext();}else{tabs._set_pm_tab_direct(nick);}
  1034.  
  1035.  
  1036. 346.tabs.pm_tab_map[nick]=$("<div class='chat-list' style='display: none;'></div>");settings.domroot.find('> div').last().after(tabs.pm_tab_map[nick]);msg=interpolate(gettext("Private conversation with %(username)s"),{username:nick},true);add_system_message(msg,tabs.pm_tab_map[nick]);return tabs.pm_tab_map[nick];},private_message_received:function(nick){if(tabs.current_tab==='pm'&&tabs.current_pm_nick==nick){return;}
  1037.  
  1038.  
  1039. 347.if(tabs.unread_pm_map[nick]){tabs.unread_pm_map[nick]+=1;}else{tabs.unread_pm_map[nick]=1;}
  1040.  
  1041.  
  1042. 348.tabs.total_unread_pms+=1;tabs._refresh_pm_tab_count();if(!tabs.pm_tab.hasClass('active')){if(!tabs.is_blinking){tabs._blink_pm(6,250);}}},_blink_pm:function(numblinks,timeout){if(tabs.current_tab==='pm'){tabs.is_blinking=false;return;}
  1043.  
  1044.  
  1045. 349.if(numblinks==0){tabs.pm_tab.removeClass('active');tabs.is_blinking=false;return;}
  1046.  
  1047.  
  1048. 350.if(!tabs.pm_tab.hasClass('active')){tabs.pm_tab.addClass('active');}else{tabs.pm_tab.removeClass('active');}
  1049.  
  1050.  
  1051. 351.tabs.is_blinking=true;setTimeout(function(){tabs._blink_pm(numblinks-1,timeout);},timeout);},get_current_tab_domele:function(){var r=settings.domroot.find('> div.chat-list:visible');if(r.length===0){return settings.chatlist;}else{return r;}},_show_chat_tab:function(){tabs._deactivate_tabs();settings.buttons.find('li:first').addClass('active');settings.domroot.find('> div').hide();settings.domroot.find('> div.chat-list:first').show();tabs.current_tab='chat';tabs._enable_form();settings.textinput.focus();tabs._scroll_to_bottom();},_scroll_to_bottom:function(){var chat=tabs.get_current_tab_domele().get(0);chat.scrollTop=chat.scrollHeight;},_disable_form:function(){settings.textinput.blur();settings.textinput.focus(function(event){settings.textinput.unbind(event);tabs._show_chat_tab();});},_enable_form:function(){settings.textinput.unbind('focus');},_remove_unread_pms_for_nick:function(nick){if(tabs.unread_pm_map[nick]&&tabs.unread_pm_map[nick]>0){tabs.total_unread_pms=tabs.total_unread_pms-tabs.unread_pm_map[nick];tabs.unread_pm_map[nick]=0;tabs._refresh_pm_tab_count();}},_refresh_pm_tab_count:function(){var str;if(tabs.total_unread_pms==0){str="";}else{str="("+tabs.total_unread_pms+")";}
  1052.  
  1053.  
  1054. 352.tabs.pm_tab.find('.pm_count').text(str);},_create_pm_tab:function(){if(!tabs.pm_tab_visible){tabs.pm_tab_visible=true;tabs.pm_tab=$("<li><a href='#' data-tab='pm'>"+"PM <span class='pm_count'></span></a></li>");settings.buttons.find('li:last').before(tabs.pm_tab);}},_set_pm_tab_direct:function(nick){tabs.pm_tab.unbind('click');tabs.pm_tab.bind('click',function(){tabs.open_pm(nick);return false;});},_set_pm_tab_jscontext:function(){tabs.pm_tab.unbind('click');tabs.pm_tab.jscontext({html:function(){var h=$("<div class='jscontextMenu'></div>");function add_link(nick,text,callback){var line=$("<div class=\"pmline\"><div class=\"user\" data-nick='"+nick+"'>"+text+"</div><div class=\"close\" data-nick='"+nick+"'></div></div>");line.find("div.user").click(callback);line.find("div.user").click(function(){jscontext('close');});line.find("div.close").click(function(event){tabs.close_pm($(event.target).data('nick'));jscontext('close');});h.append(line);}
  1055.  
  1056.  
  1057. 353.h.append("<p class=\"jscontextLabel\"><img src=\""+settings.media_url+"images/orange-arrow-down.gif\" width=\"9\" height=\"5\" alt=\"\" />Private Message with:</p><hr>");for(var i=0;i<tabs.opened_pms.length;i++){var nick=tabs.opened_pms[i];var unread=tabs.unread_pm_map[nick];if(unread&&unread>0){unread=" ("+unread+")";}else{unread="";}
  1058.  
  1059.  
  1060. 354.add_link(nick,nick+unread,function(event){var nick=$(event.target).data('nick');tabs.open_pm(nick);});}
  1061.  
  1062.  
  1063. 355.return h;},bind:"click"});},_deactivate_tabs:function(){settings.buttons.find('li').removeClass('active');},_show_pm_tab:function(){tabs._deactivate_tabs();tabs._create_pm_tab();tabs.pm_tab.addClass('active');},_sort_ignored_users_list:function(){if($("ul#ignored-list li").size()==0){$("ul#ignored-list").hide();$("h3#ignored-title").hide();return;}
  1064.  
  1065.  
  1066. 356.$("ul#ignored-list").show();$("#ignored-title").show();var list=$("ul#ignored-list");var listitems=list.children("li").get();listitems.sort(function(a,b){var compA=$(a).text().toUpperCase();var compB=$(b).text().toUpperCase();return(compA<compB)?-1:(compA>compB)?1:0;});$.each(listitems,function(idx,itm){list.append(itm);});},_sort_users_list:function(){var sort_key=$("select[name='sort']").val();if(sort_key==undefined){if($.cookie('room_sort_by')==undefined)
  1067.  
  1068.  
  1069. 357.sort_key='a';else{sort_key=$.cookie('room_sort_by');}}
  1070.  
  1071.  
  1072. 358.if(!settings.is_broadcasting){sort_key='a';}
  1073.  
  1074.  
  1075. 359.if(sort_key=='a'){var mylist=$('div.users-list');var listitems=mylist.children('div.text').get();listitems.sort(function(a,b){var compA=String($(a).data("nick"));compA=compA.replace('__anonymous__','zzzz');var compB=String($(b).data("nick"));compB=compB.replace('__anonymous__','zzzz');return(compA<compB)?-1:(compA>compB)?1:0;})
  1076.  
  1077.  
  1078. 360.$.each(listitems,function(idx,itm){mylist.append(itm);})}
  1079.  
  1080.  
  1081. 361.else{var mylist=$('div.users-list');var listitems=mylist.children('div.text').get();listitems.sort(function(a,b){var compA=parseInt($(a).data("tokenbalance"));var compB=parseInt($(b).data("tokenbalance"));return(compA<compB)?1:(compA>compB)?-1:0;})
  1082.  
  1083.  
  1084. 362.$.each(listitems,function(idx,itm){mylist.append(itm);})}},_get_font_change:function(){var html="<br/><form>";html+="<label>"+gettext('Change Font Size')+": </label>";html+=" <select id='font-change' name='font-change'>";for(var i=9;i<=20;i++){html+="<option value='"+i+"pt'>"+i+"pt</option>"}
  1085.  
  1086.  
  1087. 363.html+="</select></form>";$("#font-change").live("change",function(){$("div.chat-list").css("font-size",$(this).val());$.cookie('room_font_size',$(this).val(),{expires:365,path:'/'});});return html;},_get_show_emoticons_stored_value:function(){if($.cookie('show_emoticon_icons')=='yes'){return true;}
  1088.  
  1089.  
  1090. 364.if($.cookie('show_emoticon_icons')=='no'){return false;}
  1091.  
  1092.  
  1093. 365.return true;},_store_emoticons_value:function(val){$.cookie('show_emoticon_icons',val,{expires:365,path:'/'});},_get_emoticons_display:function(){var html="<form><label>"+gettext("Show Emoticons")+": </label>";html+="<select id='show-emoticons' name='show-emoticons'>";html+="<option value='yes'";if(tabs._get_show_emoticons_stored_value()){html+=" selected='selected' ";}
  1094.  
  1095.  
  1096. 366.html+=">"+gettext("Yes")+"</option><option value='no'";if(!tabs._get_show_emoticons_stored_value()){html+=" selected='selected' ";}
  1097.  
  1098.  
  1099. 367.html+=">"+gettext("No")+"</option></select></form>"
  1100.  
  1101.  
  1102. 368.$("#show-emoticons").live("change",function(){tabs._store_emoticons_value($(this).val());});return html;},_should_show_emoticon:function(){if($("#show-emoticons").length){return $("#show-emoticons").val()=="yes";}
  1103.  
  1104.  
  1105. 369.return tabs._get_show_emoticons_stored_value();},_set_default_font_change_value:function(){var size='9pt';if($.cookie('room_font_size')){size=$.cookie('room_font_size');}
  1106.  
  1107.  
  1108. 370.$("#font-change option[value='"+size+"']").attr("selected","selected");},_show_settings_tab:function(){tabs.current_tab='settings';settings.domroot.find('> div').hide();if(!tabs.settings_body){var html="<div class='settings-list'><form>"+"<div class='exampletext'>"+gettext("Your chat messages will look like this.")+"</div>"+"<div><br/><label>"+gettext("Chat font")+":</label> <select name='chatfont'></select></div>"+"<div><br/><label>"+gettext("Chat color")+":</label> <input type='color' id='settingscolor' name='color' value='"+settings.font_color+"' data-hex='true' data-text='hidden' style='height:20px;width:20px;'></div>"+"</form><h3 id='ignored-title'>"+gettext('Ignored users')+"</h3><ul id='ignored-list'>";for(var i=0;i<message_receiver.ignored_users.length;i++){var nick=message_receiver.ignored_users[i].split('@')[0];html+="<li>"+nick;html+=" (<a href='#' data-nick='"+message_receiver.ignored_users[i];html+="' class='un-ignore'>"+gettext('Un-ignore')+"</a>)</li>";}
  1109.  
  1110.  
  1111. 371.html+="</ul>";html+=tabs._get_font_change();html+=tabs._get_emoticons_display();if(settings.is_broadcasting){html+='<form><br/><label>'+gettext("Sort users")+":</label> "+'<select name="sort"><option value="a"';if(($.cookie('room_sort_by')=='a')||($.cookie('room_sort_by')==undefined)){html+=' selected="selected" '}
  1112.  
  1113.  
  1114. 372.html+='>'+
  1115.  
  1116.  
  1117. 373.gettext('Alphabetically')+'</option>'+'<option value="t"';if($.cookie('room_sort_by')=='t'){html+=' selected="selected" '}
  1118.  
  1119.  
  1120. 374.html+='>'+gettext('By Tokens')+'</option>'+'</select></form>';$("select[name='sort']").live("change",function(){$.cookie('room_sort_by',$(this).val(),{expires:365,path:'/'});tabs._sort_users_list();});html+="<br/><br/><a href='#' class='clear_all_banned_ips'>"+
  1121.  
  1122.  
  1123. 375.gettext('Clear All Banned IPs')+"</a>"+"<span style='display:none' class='ban_result'>"+
  1124.  
  1125.  
  1126. 376.gettext('Banned IPs cleared...')+"</span>";}
  1127.  
  1128.  
  1129. 377.html+="</div>";tabs.settings_body=$(html);$("#ignored-list li a").live("click",function(){var uname=$(this).data("nick");$(this).parent().remove();message_receiver.ignored_users=$.grep(message_receiver.ignored_users,function(a){return(a!=uname);});uname=uname.split('@')[0];var msg=interpolate(gettext("no longer ignoring %(username)s"),{username:uname},true);add_system_message(msg,tabs.get_current_tab_domele());ignored_user_methods.store_ignored_users();tabs._sort_ignored_users_list();return false;});$.each(settings.color_choices,function(index,value){tabs.settings_body.find('select[name="chatfont"]').append("<option>"+value+"</option>");});tabs.settings_body.find('select[name="chatfont"]').val(settings.chat_font);settings.domroot.find('> div').last().after(tabs.settings_body);consolelog($("#settingscolor"));$('#settingscolor').mColorPicker();$('#settingscolor').bind('colorpicked',function(){if(!features_unlocked()){unlock_features_required();$('#settingscolor').val('#494949');$('#icp_settingscolor').css('background-color','#494949');}
  1130.  
  1131.  
  1132. 378.settings.font_color=$(this).val();tabs.settings_body.find('.exampletext').css('color',settings.font_color);$.cookie(settings.font_color_cookie_name,settings.font_color,{expires:365,path:'/'});});tabs.settings_body.find('select[name="chatfont"]').change(function(){if(!features_unlocked()){tabs.settings_body.find('select[name="chatfont"]').val('default');unlock_features_required();return;}
  1133.  
  1134.  
  1135. 379.settings.chat_font=$(this).val();if(settings.chat_font==='default'){tabs.settings_body.find('.exampletext').css('font-family','');}else{tabs.settings_body.find('.exampletext').css('font-family',settings.chat_font);}
  1136.  
  1137.  
  1138. 380.$.cookie(settings.chat_font_cookie_name,settings.chat_font,{expires:365,path:'/'});});}
  1139.  
  1140.  
  1141. 381.tabs.settings_body.show();tabs._sort_ignored_users_list();tabs._deactivate_tabs();settings.buttons.find('a[data-tab="settings"]').parent().addClass('active');tabs._set_default_font_change_value();}};settings.buttons.find('a').click(tabs.on_tab_click);var initializer={attempts:0,joined:false,joined_at:null,is_on_private_room:false,base_room_name:settings.room,retry_join_room:function(){if(this.attempts>0){settings.muc_nickname+='_';}
  1142.  
  1143.  
  1144. 382.if(this.attempts>=5){consolelog("Too many failed attempts, disconnecting");conn.disconnect();}
  1145.  
  1146.  
  1147. 383.return this.join_room();},join_room:function(){this.attempts+=1;consolelog("Joining "+settings.room+" with "+settings.muc_nickname);var pres=$pres({to:settings.room+"/"+settings.muc_nickname,token_balance:settings.token_balance}).c('x',{xmlns:"http://jabber.org/protocol/muc"});if(initializer.is_on_private_room){pres=pres.c('history',{'maxchars':'0'});}
  1148.  
  1149.  
  1150. 384.conn.send(pres);},change_to_private_room:function(){if(initializer.is_on_private_room){return;}
  1151.  
  1152.  
  1153. 385.message_receiver.ignore_delayed=true;initializer.leave_room();initializer.attempts=4;initializer.is_on_private_room=true;settings.room=settings.private_room;presence_monitor.reset();initializer.join_room();},leave_private_room:function(){if(!initializer.is_on_private_room){return;}
  1154.  
  1155.  
  1156. 386.initializer.leave_room();initializer.attempts=4;initializer.is_on_private_room=false;settings.room=initializer.base_room_name;presence_monitor.reset();initializer.join_room();},leave_room:function(){conn.send($pres({to:settings.room+"/"+settings.muc_nickname,type:'unavailable'}).c('x',{xmlns:"http://jabber.org/protocol/muc"}));},on_disconnect:function(){initializer.joined=false;},on_received_my_presence:function(){initializer.joined=true;initializer.joined_at=new Date();if(!presence_monitor.participants[settings.muc_nickname]){return true;}
  1157.  
  1158.  
  1159. 387.if(presence_monitor.participants[settings.muc_nickname].role!='moderator'){return true;}
  1160.  
  1161.  
  1162. 388.if(settings.current_subject===""&!public_methods.is_goal_set()){conn.send($msg({to:settings.room,type:'groupchat'}).c('subject').t(settings.default_subject))}
  1163.  
  1164.  
  1165. 389.conn.sendIQ($iq({to:settings.room,type:'get'}).c('query',{xmlns:'http://jabber.org/protocol/muc#owner'}),function(response){consolelog("Server configuration form . . .");consolelog(response);var x=$iq({to:settings.room,type:'set'}).c('query',{xmlns:'http://jabber.org/protocol/muc#owner'}).c('x',{xmlns:'jabber:x:data',type:'submit'}).c('field',{'var':'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig​').up().up().c('field',{'var':'muc#roomconfig_whois'}).c('value').t('anyone').up().up().c('field',{'var':'muc#roomconfig_maxusers'}).c('value').t('50000');consolelog("Configuring room "+x.toString());conn.sendIQ(x,function(response){consolelog("Configuration response . . .");consolelog(response);});});}};$(document).bind("disconnected.defchat",initializer.on_disconnect);var presence_monitor={participants:new Array(),num_participants:0,reset:function(){presence_monitor.participants=new Array();presence_monitor.num_participants=0;settings.userslist.html("");},user_is_present:function(nick){var present=presence_monitor.participants[nick];present=(present!==undefined&&present!==false);return present;},remove_participant:function(nick){presence_monitor.num_participants-=1;delete presence_monitor.participants[nick];},on_presence:function(presence){var from=$(presence).attr('from');var room=Strophe.getBareJidFromJid(from);if(room==settings.room){consolelog(presence);var nick=Strophe.getResourceFromJid(from);if(nick.substring(0,6)=='admin-'){return true;}
  1166.  
  1167.  
  1168. 390.consolelog("Nick for "+from+" is "+nick);if($(presence).attr('type')==='error'&&!initializer.joined){if($(presence).find("status[code='409']")){initializer.retry_join_room();return true;}else{consolelog("Disconnecting because of error while connecting");conn.disconnect();return false;}}
  1169.  
  1170.  
  1171. 391.if($(presence).attr('type')!=='unavailable'){var present=presence_monitor.user_is_present(nick);var extradata=$(presence).find('item');if(extradata.attr('jid')){presence_monitor.participants[nick]={'jid':Strophe.getBareJidFromJid(extradata.attr('jid')),'role':extradata.attr('role')};if(!present){presence_monitor.num_participants+=1;$(document).trigger('userjoined.defchat',[nick,$(presence).attr('token_balance')]);}}}else if(presence_monitor.user_is_present(nick)&&$(presence).attr('type')==='unavailable'){presence_monitor.remove_participant(nick);$(document).trigger('userleft.defchat',nick);}
  1172.  
  1173.  
  1174. 392.if($(presence).attr('type')!=='error'&&!initializer.joined&&nick===settings.muc_nickname){initializer.on_received_my_presence();}}
  1175.  
  1176.  
  1177. 393.return true;}};conn.addHandler(presence_monitor.on_presence,null,"presence");var message_receiver={ignored_users:new Array(),ignore_delayed:false,on_goalset:function($message){settings.room_goal.amount=$message.attr('amount');settings.room_goal.current=$message.attr('current');settings.room_goal.hightipper=$message.attr('hightipper');settings.room_goal.hightipper_amount=$message.attr('hightipper_amount');settings.room_goal.lasttipper=$message.attr('lasttipper');settings.room_goal.lasttipper_amount=$message.attr('lasttipper_amount');if(settings.room_goal.lasttipper==""){settings.room_goal.lasttipper="--";settings.room_goal.hightipper="--";}
  1178.  
  1179.  
  1180. 394.tipping_goal.enable_goal();},on_message:function(message){consolelog(message);var $message=$(message);var subtype=$message.attr('subtype');var delayed=false;if($message.children('delay').length!=0){delayed=true;}
  1181.  
  1182.  
  1183. 395.if(message_receiver.ignore_delayed&delayed){return true;}
  1184.  
  1185.  
  1186. 396.if(subtype=='roomalert'){if(!delayed){message_receiver.on_roomalert($message);}
  1187.  
  1188.  
  1189. 397.return true;}else if(subtype=='goalset'){if(!delayed){message_receiver.on_goalset($message);}
  1190.  
  1191.  
  1192. 398.return true;}else if(subtype=='goalcancel'){if(!delayed){tipping_goal.disable_goal();}
  1193.  
  1194.  
  1195. 399.return true;}else if(subtype=='goalreached'){if(!delayed){message_receiver.on_goalreached();}}else if(subtype=='tipalert'){message_receiver.on_tipalert($message);return true;}else if(subtype=='messagechangerequest'){if(!delayed){message_receiver.on_messagechangerequest($message);}
  1196.  
  1197.  
  1198. 400.return true;}else if(subtype=='settingsupdate'){if(!delayed){message_receiver.on_settingsupdate($message);}
  1199.  
  1200.  
  1201. 401.return true;}else if(subtype=='groupshowrequest'){if(!delayed){groups_and_privates.on_groupshowrequest_message($message);}
  1202.  
  1203.  
  1204. 402.return true;}else if(subtype=='privateshowrequest'){if(!delayed){groups_and_privates.on_privateshowrequest_message($message);}
  1205.  
  1206.  
  1207. 403.return true;}else if(subtype=='groupshowapprove'){if(!delayed){groups_and_privates.on_groupshowrequest_approvemessage($message);}
  1208.  
  1209.  
  1210. 404.return true;}else if(subtype=='leaveprivateroom'){if(!delayed){groups_and_privates.on_leaveprivateroom_message($message);}
  1211.  
  1212.  
  1213. 405.return true;}else if(subtype=='privateshowapprove'){if(!delayed){groups_and_privates.on_privateshowrequest_approvemessage($message);}
  1214.  
  1215.  
  1216. 406.return true;}else if(subtype=='token_balance_update'){if(!delayed){tipping.current_balance=parseInt($(message).attr("tokenbalance_"+settings.my_username));$('.tokencount').html(tipping.current_balance);}
  1217.  
  1218.  
  1219. 407.return true;}else if(subtype=='groupshowcancel'){if(!delayed){groups_and_privates.on_groupshowrequest_cancelmessage();}
  1220.  
  1221.  
  1222. 408.return true;}else if(subtype=='privateshowcancel'){if(!delayed){groups_and_privates.on_privateshowrequest_cancelmessage();}
  1223.  
  1224.  
  1225. 409.return true;}else if(subtype=='awaycancel'){if(!delayed){groups_and_privates.on_awaystatus_cancelmessage();}
  1226.  
  1227.  
  1228. 410.return true;}
  1229.  
  1230.  
  1231. 411.var subject=$message.children('subject').text();if(subject){var msg=interpolate(gettext("room subject changed to \"%(subject)s\""),{subject:subject},true);add_system_message("<span class='roommessagelabel'>"+msg+"</span>");$(document).trigger("subjectchanged.defchat",subject);display_subject=settings.parse_subject(subject);settings.subject.text(display_subject);settings.current_subject=subject;return true;}
  1232.  
  1233.  
  1234. 412.var from=$message.attr('from');var nick=Strophe.getResourceFromJid(from);if(nick==null){return true;}
  1235.  
  1236.  
  1237. 413.if(presence_monitor.participants[nick]){if(message_receiver.ignored_users.indexOf(presence_monitor.participants[nick].jid)!==-1){return true;}}
  1238.  
  1239.  
  1240. 414.if($('.broadcaster_panel_away').is(':visible')){return true;}
  1241.  
  1242.  
  1243. 415.message_receiver.add_message(message_receiver._format_message(message));return true;},on_goalreached:function(){if(!settings.is_broadcasting){return;}
  1244.  
  1245.  
  1246. 416.var html="<span class='roommessagelabel'>";html+=gettext("Your goal is completed, to set a new one click Cancel goal and start over")+"</span>";add_system_message(html);},on_settingsupdate:function($message){if($message.attr('allow_privates')==='True'){$('.private_settings .value').html(gettext("Allowed"));groups_and_privates.show_private_show_controls(true);}else{$('.private_settings .value').html(gettext("Disabled"));groups_and_privates.hide_private_show_controls(true);}
  1247.  
  1248.  
  1249. 417.if($message.attr('allow_group')==='True'){$('.group_show_disabled').hide();$('.group_show_active').show();groups_and_privates.show_group_show_controls(true);}else{$('.group_show_active').hide();$('.group_show_disabled').show();groups_and_privates.hide_group_show_controls(true);}
  1250.  
  1251.  
  1252. 418.$('.num_users_required_for_group').html($message.attr('minimum_users_for_group_show'));return true;},on_messagechangerequest:function($message){var subject=$message.children('subject').text();if(settings.is_broadcasting){conn.send($msg({to:settings.room,type:'groupchat'}).c('subject').t(subject));}
  1253.  
  1254.  
  1255. 419.return true;},on_roomalert:function($message){var slug=$message.attr('slug');var url=$message.attr('url');var gendericon=$message.attr('gendericon');var gender=$message.attr('gender');if($.inArray(gender,settings.interested_in)<0){return;}
  1256.  
  1257.  
  1258. 420.if(!(initializer.joined&&(new Date()-initializer.joined_at>2*1000))){return true;}
  1259.  
  1260.  
  1261. 421.var msg=interpolate(gettext("%(roomname)s turned on their cam -- click here to visit."),{roomname:slug},true);msg=message_receiver._add_emoticons(msg);add_system_message("<span class='roomalert'><a href='"+
  1262.  
  1263.  
  1264. 422.url+"'>&lt;&lt;&lt; <img src='"+settings.media_url+"images/"+gendericon+"' height=15 width=14 border=0> "+msg+" &gt;&gt;&gt;</a></span>",tabs.get_current_tab_domele());},on_tipalert:function($message){var from_username=$message.attr('from_username');var to_username=$message.attr('to_username');var amount=$message.attr("amount");var body=$message.find('body').text();var msg=interpolate(gettext("%(from_username)s tipped %(amount)s tokens"),{from_username:from_username,amount:amount},true);if(settings.is_broadcasting){if(!$message.find('delay').length!=0){PlayBeep();if($.trim(body)!=""){msg=msg+" -- "+body;}}}
  1265.  
  1266.  
  1267. 423.add_system_message("<span class='tipalert'>"+msg+"</span>",tabs.get_current_tab_domele());},on_private_message:function(message,nick){if(!nick){var from=$(message).attr('from');nick=Strophe.getResourceFromJid(from);}
  1268.  
  1269.  
  1270. 424.if(presence_monitor.participants[nick]&&presence_monitor.participants[nick].jid){if(message_receiver.ignored_users.indexOf(presence_monitor.participants[nick].jid)!==-1){return true;}}
  1271.  
  1272.  
  1273. 425.message_receiver.add_message(message_receiver._format_message(message),tabs.get_or_create_pm_tab_for_nick(nick,true));tabs.private_message_received(nick);return true;},add_message:function(message,domele){if(!domele){domele=settings.chatlist}
  1274.  
  1275.  
  1276. 426.var chat=domele.get(0);var at_bottom=chat.scrollTop>=chat.scrollHeight-
  1277.  
  1278.  
  1279. 427.chat.clientHeight;domele.append(message);domele.find('div:last').find('a[rel*=facebox]').facebox();domele.find('div:last span.username').not('span[data-nick="'+settings.muc_nickname+'"]').jscontext({html:get_contextual_menu_html,bind:'anyclick'});if(at_bottom){chat.scrollTop=chat.scrollHeight;}
  1280.  
  1281.  
  1282. 428.while(domele.find('div.text').length>200){domele.find('div.text:first').empty().remove();}},_format_message:function(message){var $message=$(message);var from=$message.attr('from');var chat_font=$message.attr('chat_font');var font_color=$message.attr('font_color');var is_mod=$message.attr('is_mod');var has_tokens=$message.attr('has_tokens');var room=Strophe.getBareJidFromJid(from);var nick=Strophe.getResourceFromJid(from);var body=$message.children('body').text();if(!body){body=$message.text();}
  1283.  
  1284.  
  1285. 429.if(room==settings.room){body=message_receiver._add_emoticons(body);var r=$('<div class="text"><span class="username messagelabel" '+'data-nick="'+nick+'">'+nick+':</span><p>'+body+'</p></div>');if(chat_font!=='default'){r.css('font-family',chat_font);}
  1286.  
  1287.  
  1288. 430.r.css('color',font_color);if(presence_monitor.participants[nick]){if(presence_monitor.participants[nick].jid===settings.roomowner){r.find('.messagelabel').addClass('hostmessagelabel');}else if(is_mod=='1'){r.find('.messagelabel').addClass('moderatormessagelabel');}else if(has_tokens=='1'){r.find('.messagelabel').addClass('hastokensmessagelabel');}}
  1289.  
  1290.  
  1291. 431.return r;}},_add_emoticons:function(in_body){var body=$("<div/>").text(in_body).html();while(true){var match=body.match(/%%%\[emoticon ([^\s]+)\]%%%/);if(!match){break;}
  1292.  
  1293.  
  1294. 432.var urlparts=match[1].split(/\|/);var str="";var show_icon=tabs._should_show_emoticon();if(!show_icon){str=":"+urlparts[0];}
  1295.  
  1296.  
  1297. 433.else{var str="<img src='"+urlparts[1]+"' title=':"+urlparts[0]+"' height='"+urlparts[3]+"' width='"+urlparts[2]+"'>";}
  1298.  
  1299.  
  1300. 434.if(urlparts.length==5){str="<a href='"+urlparts[4]+"' rel='facebox'>"+str+"</a>";}
  1301.  
  1302.  
  1303. 435.else if(!show_icon){str="<a href='"+urlparts[1]+"' rel='facebox'>"+str+"</a>";}
  1304.  
  1305.  
  1306. 436.body=body.replace(match[0],str);}
  1307.  
  1308.  
  1309. 437.return body;}};conn.addHandler(message_receiver.on_message,null,"message","groupchat");conn.addHandler(message_receiver.on_private_message,null,"message","chat");var moderators=new Array();var message_sender={message_to_send:'',confirmed_send:false,_recent_message_log:new Array(),on_form_submit:function(){if(settings.textinput.val()==""){message_sender._reset_form();return false;}
  1310.  
  1311.  
  1312. 438.if(settings.first_post_warning!==null){if(!message_sender.confirmed_send){if(!confirm(settings.first_post_warning)){return false;}
  1313.  
  1314.  
  1315. 439.message_sender.confirmed_send=true;}}
  1316.  
  1317.  
  1318. 440.if(presence_monitor.participants[settings.muc_nickname]){if(presence_monitor.participants[settings.muc_nickname].role!='moderator'){if(message_sender.message_to_send==settings.textinput.val()){add_system_message(gettext("duplicate message not sent"),tabs.get_current_tab_domele());message_sender._reset_form();return false;}
  1319.  
  1320.  
  1321. 441.if(message_sender._get_recent_message_log_count()>=3&&tipping.current_balance===0){add_system_message(gettext("message not sent -- try slowing down"),tabs.get_current_tab_domele());return false;}}}
  1322.  
  1323.  
  1324. 442.if(!initializer.joined){add_system_message('not connected');return false;}
  1325.  
  1326.  
  1327. 443.if(settings.password==='anonymous'){if(settings.login_required_callback){settings.login_required_callback();}else{add_system_message(gettext("anonymous users cannot chat - create your free account"),tabs.get_current_tab_domele());}
  1328.  
  1329.  
  1330. 444.return false;}
  1331.  
  1332.  
  1333. 445.message_sender.message_to_send=settings.textinput.val();message_sender._reset_form();message_sender._translate_and_send();message_sender._recent_message_log.push(new Date());return false;},_get_recent_message_log_count:function(){message_sender._remove_old_messages_from_log();return message_sender._recent_message_log.length;},_remove_old_messages_from_log:function(){var now=new Date();message_sender._recent_message_log=$.grep(message_sender._recent_message_log,function(a){return((now-a)<(10*1000));});},_translate_and_send:function(){if(settings.translate_message_url!==null){message_sender._reset_form();$.ajax({url:settings.translate_message_url,aync:false,data:{message:message_sender.message_to_send,room:settings.roomownernick},success:function(data,textStatus,jqXHR){if(!jqXHR.getResponseHeader('X-Successful')){alert("An error occurred");return;}
  1334.  
  1335.  
  1336. 446.if(jqXHR.getResponseHeader('X-Spam')){var m=$msg({to:'',from:settings.room+'/'+settings.username,type:'chat',font_color:settings.font_color,chat_font:settings.chat_font}).c('body').t(data);m=String(m);message_receiver.add_message(message_receiver._format_message(m),tabs.get_current_tab_domele());}else if(jqXHR.getResponseHeader('X-Denied')){m=String(m);message_receiver.add_message("<div class='text'>"+jqXHR.getResponseHeader('X-Denied')+"</div>",tabs.get_current_tab_domele());}else{message_sender._send(data);}}});}else{message_sender._send(message_sender.message_to_send);}},_send:function(message){var ismod='0';if(presence_monitor.participants[settings.muc_nickname]){if(presence_monitor.participants[settings.muc_nickname].role=='moderator'){ismod='1';}}
  1337.  
  1338.  
  1339. 447.var to;var type;if(tabs.current_tab==='pm'){to=settings.room+"/"+tabs.current_pm_nick;type='chat';}else{to=settings.room;type='groupchat';}
  1340.  
  1341.  
  1342. 448.var has_tokens='0';if(tipping.current_balance>0){has_tokens='1';}
  1343.  
  1344.  
  1345. 449.var m=$msg({to:to,type:type,font_color:settings.font_color,chat_font:settings.chat_font,is_mod:ismod,has_tokens:has_tokens}).c('body').t(message);conn.send(m);if(tabs.current_tab==='pm'){var from=settings.room+'/'+settings.muc_nickname;m=$msg({to:to,type:type,from:from,font_color:settings.font_color,chat_font:settings.chat_font,is_mod:ismod}).c('body').t(message);message_receiver.on_private_message(m.toString(),tabs.current_pm_nick);}},_reset_form:function(){settings.textinput.val('');settings.textinput.focus();}};var tipping_goal={init:function(){$("#goalform").submit(tipping_goal.on_configuration_submit);$('.cancel_goal').click(tipping_goal.on_cancel_click);$('.set_goal').click(tipping_goal.on_set_goal_clicked);$('.broadcaster_panel_goal_configuration .cancel a').click(tipping_goal.on_configuration_cancel_click);},on_set_goal_clicked:function(){groups_and_privates.change_broadcaster_panel('goal_configuration');$('#token_goal_description_input').focus();},on_configuration_cancel_click:function(){groups_and_privates.change_broadcaster_panel('default');},disable_goal:function(){settings.room_goal={};if(!settings.is_broadcasting){$(".goal_display_table").hide();}},enable_goal:function(){if(!initializer.is_on_private_room){groups_and_privates.change_broadcaster_panel('goal_display');}
  1346.  
  1347.  
  1348. 450.$(".goal_display_table").show();$('.goal_status_disabled').hide();$('.goal_status_active').show();$('.room_goal_amount').text(settings.room_goal.amount);$('.room_goal_current').text(settings.room_goal.current);$('.room_goal_hightipper').text(settings.room_goal.hightipper);$('.room_goal_hightipper_amount').text(settings.room_goal.hightipper_amount);$('.room_goal_lasttipper').text(settings.room_goal.lasttipper);$('.room_goal_lasttipper_amount').text(settings.room_goal.lasttipper_amount);},on_configuration_submit:function(){var description=$("#goalform input[name='description']").val();var amount=parseInt($("#goalform input[name='amount']").val());if($.trim(description)==""){alert(gettext("Invalid token goal description"));return false;}
  1349.  
  1350.  
  1351. 451.if(isNaN(amount)|amount<=0){alert(gettext("Invalid token goal amount"));return false;}
  1352.  
  1353.  
  1354. 452.$.post($('#goalform').attr('action'),$('#goalform').serialize(),function(data){if(data!='ok'){alert(data);}});return false;},on_cancel_click:function(){if(confirm(gettext("Are you sure you want to remove this goal?"))){groups_and_privates.change_broadcaster_panel('default');$('.goal_status_active').hide();$('.goal_status_disabled').show();$.post($(this).attr('href'),{'foo':'bar'});conn.send($msg({to:settings.room,type:'groupchat'}).c('subject').t(settings.default_subject))}
  1355.  
  1356.  
  1357. 453.return false;}};tipping_goal.init();var emoticons={_emoticons_loaded:false,_popup_window:null,init:function(){settings.domroot.find(".emoticon_button").click(emoticons.on_emoticon_button_clicked);},on_emoticon_button_clicked:function(ev){if(settings.login_required_callback){if(settings.login_required_callback()){return false;}}
  1358.  
  1359.  
  1360. 454.emoticons.toggle_overlay();},on_body_clicked_while_overlay_up:function(ev){if(settings.domroot.find('.emote_popup').has(ev.target).length||settings.domroot.find('.emoticon_button').is(ev.target)){return;}
  1361.  
  1362.  
  1363. 455.emoticons.toggle_overlay();},on_popup_clicked:function(ev){if(!emoticons._popup_window||emoticons._popup_window.closed){emoticons._popup_window=window.open($(this).attr('href'),'_blank','status=0,toolbar=0,menubar=0,directories=0,resizable=1,'+'scrollbars=1,height=615,width=850');emoticons._popup_window.onload=function(){emoticons._popup_window.RunCallbackFunction=emoticons.on_popup_callback;};$(window).unload(emoticons.on_document_closing);}
  1364.  
  1365.  
  1366. 456.emoticons.toggle_overlay();emoticons._popup_window.focus();return false;},on_document_closing:function(){if(emoticons._popup_window){if(!emoticons._popup_window.closed){emoticons._popup_window.close();}}},on_popup_callback:function(){alert("popup callback");},on_emoticon_clicked:function(){emoticons.toggle_overlay();settings.textinput.val(settings.textinput.val()+" "+
  1367.  
  1368.  
  1369. 457.$(this).data('emoticon'));settings.textinput.focus();},toggle_overlay:function(){var ep=settings.domroot.find(".emote_popup");if(ep.is(":visible")){$("body").unbind('click',emoticons.on_body_clicked_while_overlay_up);ep.hide();}else{$("body").click(emoticons.on_body_clicked_while_overlay_up);if(emoticons._emoticons_loaded){ep.show();}else{emoticons._emoticons_loaded=true;ep.load(settings.emoticon_overlay_url,function(){ep.show();ep.find('.more a').click(emoticons.on_popup_clicked);ep.find('img.emoticon').click(emoticons.on_emoticon_clicked);});}}}};emoticons.init();var tipping={current_balance:0,init:function(){$(".tip_button").click(tipping.on_tipping_button_clicked);settings.domroot.find('.tip_popup form').submit(tipping.on_form_submit);tipping.current_balance=settings.token_balance;$(document).bind('keydown','ctrl+s',tipping.on_key_down);$(document).bind('keydown','command+s',tipping.on_key_down);},on_key_down:function(event){tipping.toggle_overlay();return false;},on_form_submit:function(){var amount=parseInt($("#id_tip_amount").val());if(isNaN(amount)|amount<1){alert(gettext("Invalid tip amount"));return false;}
  1370.  
  1371.  
  1372. 458.if(amount>tipping.current_balance){alert(gettext("You do not have enough tokens."));return false;}
  1373.  
  1374.  
  1375. 459.var msg=interpolate(gettext("Send %(tokens)s tokens to %(username)s?"),{username:settings.roomownernick,tokens:$("#id_tip_amount").val()},true);if(!confirm(msg)){return false;}
  1376.  
  1377.  
  1378. 460.var $form=$(this);$.ajax({url:$(this).attr('action'),dataType:'json',data:$(this).serialize(),type:'POST',success:function(response){if(response.error){alert(response.error);}else if(response.success){$form.find("textarea").val("");tipping.toggle_overlay();tipping.current_balance=parseInt(response.token_balance);$('.tokencount').html(response.token_balance);}}});return false;},on_tipping_button_clicked:function(ev){if(settings.login_required_callback){if(settings.login_required_callback()){return false;}}
  1379.  
  1380.  
  1381. 461.if(!(tabs.current_tab=='pm'|tabs.current_tab=='chat')){tabs._show_chat_tab();}
  1382.  
  1383.  
  1384. 462.tipping.toggle_overlay();},on_body_clicked_while_overlay_up:function(ev){if(settings.domroot.find('.tip_popup').has(ev.target).length||$('.tip_button').is(ev.target)){return;}
  1385.  
  1386.  
  1387. 463.tipping.toggle_overlay();},toggle_overlay:function(){if(!settings.allow_tipping){return;}
  1388.  
  1389.  
  1390. 464.if(!(typeof _gaq==='undefined')){_gaq.push(['_trackPageview','/tracking/toggle_tipping_overlay/']);}
  1391.  
  1392.  
  1393. 465.var ep=settings.domroot.find(".tip_popup");if(ep.is(":visible")){$("body").unbind('click',tipping.on_body_clicked_while_overlay_up);ep.hide();settings.textinput.focus();}else{$("body").click(tipping.on_body_clicked_while_overlay_up);$.ajax({url:settings.tipping_current_tokens_url,type:'GET',data:'foo=bar',dataType:'json',cache:false,success:function(response){tipping.current_balance=parseInt(response.token_balance);$('.tokencount').html(response.token_balance);ep.show();ep.find('#id_tip_amount').focus();ep.find('#id_tip_amount').select();}});}}};tipping.init();var keybinder={current_focus:null,init:function(){$(document).keydown(keybinder.handle_keydown);$(":input").live('focus',keybinder.on_focus);$(":input").live('blur',keybinder.on_blur);},handle_keydown:function(e){if(keybinder.current_focus!==null){return;}
  1394.  
  1395.  
  1396. 466.if((e.keyCode>=65&&e.keyCode<=90)|(e.keyCode>=48&&e.keyCode<=57)){settings.textinput.focus().val(settings.textinput.val());}},on_blur:function(){keybinder.current_focus=null;},on_focus:function(){keybinder.current_focus=this.id;}};keybinder.init();var groups_and_privates={init:function(){$('.start_group_show,.start_group_show_link').click(groups_and_privates.start_group_show_clicked);$('.start_group_show_cancel').click(groups_and_privates.cancel_group_chat_request);$('.start_private_show').click(groups_and_privates.start_private_show_clicked);$('.start_private_show_cancel').click(groups_and_privates.cancel_private_chat_request);$('.broadcaster_panel_show_requested .accept').click(groups_and_privates.approve_private_show_clicked);$('.broadcaster_panel_show_requested .decline').click(groups_and_privates.decline_private_show_clicked);$('.broadcaster_panel_private_show .decline').click(groups_and_privates.decline_private_show_clicked);$('.broadcaster_panel_group_show_requested .accept').click(groups_and_privates.approve_group_show_clicked);$('.broadcaster_panel_group_show_requested .decline').click(groups_and_privates.decline_group_show_clicked);$('.broadcaster_panel_group_show .decline').click(groups_and_privates.decline_group_show_clicked);$('.return_from_away_mode').live('click',groups_and_privates.return_from_away_mode_clicked);},approve_private_show_clicked:function(){$.post(settings.private_show_approve_url,{'foo':'bar'});},decline_private_show_clicked:function(){if(!confirm(gettext("Are you sure?"))){return}
  1397.  
  1398.  
  1399. 467.$.post(settings.private_show_decline_url,{'foo':'bar'});},approve_group_show_clicked:function(){$.post(settings.group_show_approve_url,{'foo':'bar'});},return_from_away_mode_clicked:function(){$.post(settings.return_from_away_url,{'foo':'bar'});},decline_group_show_clicked:function(){if(!confirm(gettext("Are you sure?"))){return}
  1400.  
  1401.  
  1402. 468.$.post(settings.group_show_decline_url,{'foo':'bar'});},start_group_show_clicked:function(){if(settings.login_required_callback){if(settings.login_required_callback()){return false;}}
  1403.  
  1404.  
  1405. 469.groups_and_privates.change_group_show_link('processing');$.post(settings.group_show_tokens_per_minute_url,{'foo':'bar'},function(data){var msg=interpolate(gettext("Enter group chat with %(modelname)s? (%(price)s tokens per minute)"),{modelname:settings.roomownernick,price:data},true);if(confirm(msg)){$.post(settings.group_show_request_url,{'chat_username':settings.muc_nickname},function(data){if(data.success){groups_and_privates.change_group_show_link('waiting');add_system_message("<span class='privatealert'>"+
  1406.  
  1407.  
  1408. 470.gettext("Group show request has been sent.")+"</span>");}else{if(data.message){alert(data.message);}
  1409.  
  1410.  
  1411. 471.groups_and_privates.change_group_show_link();}},'json').error(groups_and_privates.error_starting_group_show);}else{groups_and_privates.change_group_show_link();}}).error(groups_and_privates.error_starting_group_show);},on_groupshowrequest_message:function($message){var users_waiting=parseInt($message.attr('users_waiting'));var users_required=parseInt($message.attr('users_required'));if(!initializer.is_on_private_room){add_system_message("<span class='privatealert'>"+users_waiting+" of "+users_required+" users are ready to start a group show.</span>")}
  1412.  
  1413.  
  1414. 472.$('.num_users_waiting_for_group').html($message.attr('users_waiting'));if(settings.is_broadcasting&!initializer.is_on_private_room){if(users_waiting==users_required){$('.broadcaster_panel_group_show_requested .tokens_per_minute').html($message.attr('tokens_per_minute'));groups_and_privates.change_broadcaster_panel('group_show_requested');PlayBeep();}}},start_private_show_clicked:function(){if(settings.login_required_callback){if(settings.login_required_callback()){return false;}}
  1415.  
  1416.  
  1417. 473.groups_and_privates.change_private_show_link('processing');$.post(settings.private_show_tokens_per_minute_url,{'foo':'bar'},function(data){var msg=interpolate(gettext("Enter private chat with %(modelname)s? (%(price)s tokens per minute)"),{modelname:settings.roomownernick,price:data},true);if(confirm(msg)){$.post(settings.private_show_request_url,{'chat_username':settings.muc_nickname},function(data){if(data.success){groups_and_privates.change_private_show_link('waiting');add_system_message("<span class='privatealert'>"+
  1418.  
  1419.  
  1420. 474.gettext("Private show request has been sent. Waiting on broadcaster to approve.")+"</span>");}else{if(data.message){alert(data.message);}
  1421.  
  1422.  
  1423. 475.groups_and_privates.change_private_show_link();}},'json').error(groups_and_privates.error_starting_private_show);}else{groups_and_privates.change_private_show_link();}}).error(groups_and_privates.error_starting_private_show);},is_requesting_group_chat:function(){return $('.start_group_show_waiting').is(':visible')|$('.start_group_show_processing').is(':visible');},is_requesting_private_chat:function(){return $('.start_private_show_waiting').is(':visible');},on_groupshowrequest_approvemessage:function($message){add_system_message("<span class='privatealert'>"+
  1424.  
  1425.  
  1426. 476.gettext("Group show has started.")+"</span>");if(initializer.is_on_private_room){return;}
  1427.  
  1428.  
  1429. 477.$('.tokens_per_minute').html($message.attr('tokens_per_minute'));if(groups_and_privates.is_requesting_group_chat()|settings.is_broadcasting){groups_and_privates.change_group_show_link('active');groups_and_privates.change_broadcaster_panel('group_show');initializer.change_to_private_room();}},on_privateshowrequest_approvemessage:function($message){add_system_message("<span class='privatealert'>"+
  1430.  
  1431.  
  1432. 478.gettext("Private show has started.")+"</span>");if(initializer.is_on_private_room){return;}
  1433.  
  1434.  
  1435. 479.if(groups_and_privates.is_requesting_private_chat()|settings.is_broadcasting){groups_and_privates.change_private_show_link('active');groups_and_privates.change_broadcaster_panel('private_show');$('.tokens_per_minute').html($message.attr('tokens_per_minute'));initializer.change_to_private_room();}},change_broadcaster_panel:function(name){if(public_methods.is_goal_set()&&name=='default'){name='goal_display';}
  1436.  
  1437.  
  1438. 480.$('.broadcaster_panel_default').hide();$('.broadcaster_panel_private_show').hide();$('.broadcaster_panel_group_show').hide();$('.broadcaster_panel_show_requested').hide();$('.broadcaster_panel_group_show_requested').hide();$('.broadcaster_panel_goal_configuration').hide();$('.broadcaster_panel_goal_display').hide();$('.broadcaster_panel_away').hide();$(".broadcaster_panel_"+name).show();},on_groupshowrequest_cancelmessage:function(){$('.num_users_waiting_for_group').html('0');if(initializer.is_on_private_room){if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('away');}
  1439.  
  1440.  
  1441. 481.add_system_message("<span class='privatealert'>"+
  1442.  
  1443.  
  1444. 482.gettext("Group show has finished.")+"</span>");initializer.leave_private_room();groups_and_privates.change_group_show_link();}else{if(groups_and_privates.is_requesting_group_chat()){add_system_message("<span class='privatealert'>"+
  1445.  
  1446.  
  1447. 483.gettext("Group show has been declined.")+"</span>");groups_and_privates.change_group_show_link();}
  1448.  
  1449.  
  1450. 484.if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('default');}}},on_awaystatus_cancelmessage:function(){if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('default');}},on_privateshowrequest_cancelmessage:function(){if(initializer.is_on_private_room){add_system_message("<span class='privatealert'>"+
  1451.  
  1452.  
  1453. 485.gettext("Private show has finished.")+"</span>");initializer.leave_private_room();groups_and_privates.change_private_show_link();if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('away');}}else{if(groups_and_privates.is_requesting_private_chat()){add_system_message("<span class='privatealert'>"+
  1454.  
  1455.  
  1456. 486.gettext("Private show has been declined.")+"</span>");groups_and_privates.change_private_show_link();}
  1457.  
  1458.  
  1459. 487.if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('default');}}},on_leaveprivateroom_message:function($message){if($message.attr('username')==settings.my_username){initializer.leave_private_room();groups_and_privates.change_group_show_link();}},on_privateshowrequest_message:function($message){if(settings.is_broadcasting){var username=$message.attr('requester_username');$('.broadcaster_panel_show_requested .requester_username').html(username);$('.broadcaster_panel_show_requested .tokens_per_minute').html($message.attr('tokens_per_minute'));groups_and_privates.change_broadcaster_panel('show_requested');PlayBeep();add_system_message("<span class='privatealert'>"+username+" wants to start a private show.</span>")}},error_starting_group_show:function(){alert(gettext("There was an error requesting your show. Please try again."));groups_and_privates.change_group_show_link();},error_starting_private_show:function(){alert(gettext("There was an error requesting your show. Please try again."));groups_and_privates.change_private_show_link();},cancel_group_chat_request:function(){if(confirm(gettext("Are you sure?"))){$.post(settings.group_show_cancel_url,{'foo':'bar'});groups_and_privates.change_group_show_link();}},cancel_private_chat_request:function(){if(confirm(gettext("Are you sure?"))){$.post(settings.private_show_cancel_url,{'foo':'bar'});}},change_group_show_link:function(link){$('.start_group_show').hide();$('.start_group_show_waiting').hide();$('.start_group_show_processing').hide();$('.start_group_show_active').hide();var key='.start_group_show';if(link){key=key+"_"+link;groups_and_privates.hide_private_show_controls();}else{groups_and_privates.show_private_show_controls();}
  1460.  
  1461.  
  1462. 488.$(key).show();},change_private_show_link:function(link){$('.start_private_show').hide();$('.start_private_show_processing').hide();$('.start_private_show_waiting').hide();$('.start_private_show_active').hide();var key='.start_private_show';if(link){key=key+"_"+link;groups_and_privates.hide_group_show_controls();}else{groups_and_privates.show_group_show_controls();}
  1463.  
  1464.  
  1465. 489.$(key).show();},hide_private_show_controls:function(force){$('.private_show_controls').hide();if(force){$('.private_show_controls').data('forcehidden','1');}
  1466.  
  1467.  
  1468. 490.groups_and_privates.show_group_show_controls();},show_private_show_controls:function(force){if(force|$('.private_show_controls').data('forcehidden')!='1'){$('.private_show_controls').show();}},hide_group_show_controls:function(force){$('.group_show_controls').hide();if(force){$('.group_show_controls').data('forcehidden','1');}},show_group_show_controls:function(force){if(force|$('.group_show_controls').data('forcehidden')!='1'){$('.group_show_controls').show();}}};groups_and_privates.init();public_methods._set_font_size();ignored_user_methods.load_ignored_users();settings.form.submit(message_sender.on_form_submit);settings.submitbutton.click(message_sender.on_form_submit);if(settings.throttlechat){if(settings.welcome_message){add_system_message(settings.welcome_message);}
  1469.  
  1470.  
  1471. 491.if(settings.welcome_warning){add_system_message(settings.welcome_warning);}
  1472.  
  1473.  
  1474. 492.add_system_message(settings.throttle_message);presence_monitor.num_participants=100;}else{consolelog("Trying to connect to "+settings.bosh_host+" with "+
  1475.  
  1476.  
  1477. 493.settings.user+":"+settings.password);conn.connect(settings.user,settings.password,function(status,data){if(status===Strophe.Status.CONNECTED){$(document).trigger("connected.defchat");}else if(status===Strophe.Status.CONNECTING){$(document).trigger("connecting.defchat");}else if(status===Strophe.Status.DISCONNECTED){$(document).trigger("disconnected.defchat");}else if(status===Strophe.Status.CONNFAIL){$(document).trigger("connectionfailed.defchat");}else{consolelog('Defchat Unhandled status: '+status+"-"+data);}});}
  1478.  
  1479.  
  1480. 494.if(settings.scroll_on_load){settings.textinput.focus();function isScrolledIntoView(elem)
  1481.  
  1482.  
  1483. 495.{var docViewTop=$(window).scrollTop();var docViewBottom=docViewTop+$(window).height();var elemTop=$(elem).offset().top;var elemBottom=elemTop+$(elem).height();return((elemBottom>=docViewTop)&&(elemTop<=docViewBottom));}
  1484.  
  1485.  
  1486. 496.if($('.top-section').length>0){if(!isScrolledIntoView($('.top-section'))){$(document).scrollTop($('.top-section').offset().top);}}}
  1487.  
  1488.  
  1489. 497.var returnhandle=function(method){if(public_methods[method]){return public_methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'||!method){return public_methods.init.apply(this,arguments);}else{$.error('Method '+method+' does not exist in defchat');}};return returnhandle;};})(jQuery);function EmbedViewerSwf(swfname,modelname,fms_address,popout_url,language,mute,pr,sa,express,uid,jg)
  1490.  
  1491.  
  1492. 498.{var params={allowScriptAccess:"always",allowFullScreen:"true",quality:"high",wmode:"opaque",id:"movie",FlashVars:"pid="+modelname+"&address="+fms_address+"&popouturl="+popout_url+"&language="+language+"&mute="+mute+"&pr="+pr+"&sa="+sa+"&uid="+uid+"&jg="+jg};if(!document.getElementById('movie')){return;}
  1493.  
  1494.  
  1495. 499.document.getElementById('movie').innerHTML="<center><br><br><br><br><a border='0' href='http://www.adobe.com/go/getflashplayer' target='_blank'>"+"<img alt='Get Adobe Flash player' src='"+MEDIA_URL+"images/160x41_Get_Flash_Player.jpg'></a><br>"+"We've detected that you are missing the latest version of Flash Player.<br>"+"This version of the Chaturbate Viewer requires Flash Player 10.2.0 or later.<br>"+"<a href='http://www.adobe.com/go/getflashplayer'>"+"Click here to update your Flash Player for free.</a></center>";swfobject.embedSWF(swfname,'movie',"100%","100%","10.2.0",null,"",params);}
  1496.  
  1497.  
  1498. 500.function EmbedBroadcasterSwf(swfname,modelname,fms_address,language,express,pt,captureurl,pk,pe)
  1499.  
  1500.  
  1501. 501.{var params={allowScriptAccess:"always",allowFullScreen:"false",quality:"high",wmode:"opaque",id:"movie",FlashVars:"pid="+modelname+"&address="+fms_address+"&language="+language+"&pt="+pt+"&captureurl="+captureurl+"&pk="+pk+"&pe="+pe};if(!document.getElementById('movie')){return;}
  1502.  
  1503.  
  1504. 502.document.getElementById('movie').innerHTML="<center><br><br><br><br><a border='0' href='http://www.adobe.com/go/getflashplayer' target='_blank'>"+"<img alt='Get Adobe Flash player' src='"+MEDIA_URL+"images/160x41_Get_Flash_Player.jpg'></a><br>"+"We've detected that you are missing the latest version of Flash Player.<br>"+"This version of the Chaturbate Broadcaster requires Flash Player 10.2.0 or later.<br>"+"<a href='http://www.adobe.com/go/getflashplayer'>"+"Click here to update your Flash Player for free.</a></center>";swfobject.embedSWF(swfname,'movie',"100%","100%","10.2.0",null,"",params);}
  1505.  
  1506.  
  1507. 503.function EmbedBroadcasterSwf_11(swfname,modelname,fms_address,language,express,pt,captureurl,pk,pe)
  1508.  
  1509.  
  1510. 504.{var params={allowScriptAccess:"always",allowFullScreen:"false",quality:"high",wmode:"opaque",id:"movie",FlashVars:"pid="+modelname+"&address="+fms_address+"&language="+language+"&pt="+pt+"&captureurl="+captureurl+"&pk="+pk+"&pe="+pe};if(!document.getElementById('movie')){return;}
  1511.  
  1512.  
  1513. 505.document.getElementById('movie').innerHTML="<center><br><br><br><br><a border='0' href='http://www.adobe.com/go/getflashplayer' target='_blank'>"+"<img alt='Get Adobe Flash player' src='"+MEDIA_URL+"images/160x41_Get_Flash_Player.jpg'></a><br>"+"We've detected that you are missing the latest version of Flash Player.<br>"+"This version of the Chaturbate Broadcaster requires Flash Player 11.0.1 or later.<br>"+"<a href='http://www.adobe.com/go/getflashplayer'>"+"Click here to update your Flash Player for free.</a></center>";swfobject.embedSWF(swfname,'movie',"100%","100%","11.0.1",null,"",params);}
  1514.  
  1515.  
  1516. 506.function EmbedDualBroadcasterSwf(swfname,swfname_11,modelname,fms_address,language,express,pt,captureurl,pk,pe)
  1517.  
  1518.  
  1519. 507.{var version=swfobject.getFlashPlayerVersion();if(version.major>=11&&version.minor>=0&&version.release>=1)
  1520.  
  1521.  
  1522. 508.EmbedBroadcasterSwf_11(swfname_11,modelname,fms_address,language,express,pt,captureurl,pk,pe);else
  1523.  
  1524.  
  1525. 509.EmbedBroadcasterSwf(swfname,modelname,fms_address,language,express,pt,captureurl,pk,pe);}
  1526.  
  1527.  
  1528. 510.var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return!a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();function SwfScale(width)
  1529.  
  1530.  
  1531. 511.{var swfwidth=parseInt(width);var swfheight=swfwidth*0.75;document.getElementById("player").style.width=swfwidth+"px";document.getElementById("player").style.height=swfheight+"px";}
  1532.  
  1533.  
  1534. 512.var SwfPopup=null;var PopupUpdater=null;function Popout(broadcaster,url)
  1535.  
  1536.  
  1537. 513.{var windowName="CBVPopup";var windowOptions="width="+(498+16)+",height="+(407+16)+",status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0";document.getElementById('player').style.display='none';SwfPopup=window.open(url,windowName,windowOptions);if(PopupUpdater==null)
  1538.  
  1539.  
  1540. 514.PopupUpdater=setInterval("SwfPopupUpdate()",1000);return SwfPopup;}
  1541.  
  1542.  
  1543. 515.function SwfPopupUpdate()
  1544.  
  1545.  
  1546. 516.{if(SwfPopup&&SwfPopup.closed)
  1547.  
  1548.  
  1549. 517.{clearInterval(PopupUpdater);PopupUpdater=null;SwfPopup=null;document.getElementById('player').style.display='block';}}
  1550.  
  1551.  
  1552. 518.function OnResizePopout()
  1553.  
  1554.  
  1555. 519.{var winW=514,winH=423;if(document.body&&document.body.offsetWidth)
  1556.  
  1557.  
  1558. 520.{winW=document.body.offsetWidth;winH=document.body.offsetHeight;}
  1559.  
  1560.  
  1561. 521.if(document.compatMode=='CSS1Compat'&&document.documentElement&&document.documentElement.offsetWidth)
  1562.  
  1563.  
  1564. 522.{winW=document.documentElement.offsetWidth;winH=document.documentElement.offsetHeight;}
  1565.  
  1566.  
  1567. 523.if(window.innerWidth&&window.innerHeight)
  1568.  
  1569.  
  1570. 524.{winW=window.innerWidth;winH=window.innerHeight;}
  1571.  
  1572.  
  1573. 525.var swfW=winW-16;var swfH=swfW*0.75;if(swfH+16>winH)
  1574.  
  1575.  
  1576. 526.SwfScale((winH-16)*1.33);else
  1577.  
  1578.  
  1579. 527.SwfScale((winW-16));}
  1580.  
  1581.  
  1582. 528.function GetFlashObject(movieName)
  1583.  
  1584.  
  1585. 529.{var isIE=navigator.appName.indexOf("Microsoft")!=-1;return(isIE)?window[movieName]:document[movieName];}
  1586.  
  1587.  
  1588. 530.function PlayBeep()
  1589.  
  1590.  
  1591. 531.{GetFlashObject('movie').PlayBeep();}
  1592.  
  1593.  
  1594. 532.function test_js()
  1595.  
  1596.  
  1597. 533.{alert('test join group link');}
  1598.  
  1599.  
  1600. 534.$(document).ready(function(){function on_key_down(){window.location=nextroomurl;return false;}
  1601.  
  1602.  
  1603. 535.$(document).bind('keydown','ctrl+x',on_key_down);$(document).bind('keydown','command+x',on_key_down);});(function($){$(document).ready(function(){$("a.endless_more").live("click",function(){var container=$(this).closest(".endless_container");var loading=container.find(".endless_loading");$(this).hide();loading.show();var data="querystring_key="+$(this).attr("rel").split(" ")[0];$.get($(this).attr("href"),data,function(data){container.before(data);container.remove();});return false;});$("a.endless_page_link").live("click",function(){var data="querystring_key="+$(this).attr("rel").split(" ")[0];$(this).closest(".endless_page_template").load($(this).attr("href"),data);return false;});});})(jQuery);$(document).ready(function(){$.fn.mColorPicker.init.replace=false;$.fn.mColorPicker.defaults.imageFolder="http://ccstatic.chaturbate.com/static/mColorPicker/images/";$.fn.mColorPicker.init.showLogo=false;$.fn.mColorPicker.init.allowTransparency=false;});(function($){var $o;$.fn.mColorPicker=function(options){$o=$.extend($.fn.mColorPicker.defaults,options);if($o.swatches.length<10)$o.swatches=$.fn.mColorPicker.defaults.swatches
  1604.  
  1605.  
  1606. 536.if($("div#mColorPicker").length<1)$.fn.mColorPicker.drawPicker();if($('#css_disabled_color_picker').length<1)$('head').prepend('<style id="css_disabled_color_picker" type="text/css">.mColorPicker[disabled] + span, .mColorPicker[disabled="disabled"] + span, .mColorPicker[disabled="true"] + span {filter:alpha(opacity=50);-moz-opacity:0.5;-webkit-opacity:0.5;-khtml-opacity: 0.5;opacity: 0.5;}</style>');$('.mColorPicker').live('keyup',function(){try{$(this).css({'background-color':$(this).val()}).css({'color':$.fn.mColorPicker.textColor($(this).css('background-color'))}).trigger('change');}catch(r){}});$('.mColorPickerTrigger').live('click',function(){$.fn.mColorPicker.colorShow($(this).attr('id').replace('icp_',''));});this.each(function(){$.fn.mColorPicker.drawPickerTriggers($(this));});return this;};$.fn.mColorPicker.currentColor=false;$.fn.mColorPicker.currentValue=false;$.fn.mColorPicker.color=false;$.fn.mColorPicker.init={replace:'[type=color]',index:0,enhancedSwatches:true,allowTransparency:true,checkRedraw:'DOMUpdated',liveEvents:false,showLogo:true};$.fn.mColorPicker.defaults={imageFolder:'images/',swatches:["#ffffff","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000","#4c2b11","#3b3b3b","#000000"]};$.fn.mColorPicker.liveEvents=function(){$.fn.mColorPicker.init.liveEvents=true;if($.fn.mColorPicker.init.checkRedraw&&$.fn.mColorPicker.init.replace){$(document).bind($.fn.mColorPicker.init.checkRedraw+'.mColorPicker',function(){$('input[data-mcolorpicker!="true"]').filter(function(){return($.fn.mColorPicker.init.replace=='[type=color]')?this.getAttribute("type")=='color':$(this).is($.fn.mColorPicker.init.replace);}).mColorPicker();});}};$.fn.mColorPicker.drawPickerTriggers=function($t){if($t[0].nodeName.toLowerCase()!='input')return false;var id=$t.attr('id')||'color_'+$.fn.mColorPicker.init.index++,hidden=false;$t.attr('id',id);if($t.attr('text')=='hidden'||$t.attr('data-text')=='hidden')hidden=true;var color=$t.val(),width=($t.width()>0)?$t.width():parseInt($t.css('width'),10),height=($t.height())?$t.height():parseInt($t.css('height'),10),flt=$t.css('float'),image=(color=='transparent')?"url('"+$o.imageFolder+"/grid.gif')":'',colorPicker='';$('body').append('<span id="color_work_area"></span>');$('span#color_work_area').append($t.clone(true));colorPicker=$('span#color_work_area').html().replace(/type="color"/gi,'').replace(/input /gi,(hidden)?'input type="hidden"':'input type="text"');$('span#color_work_area').html('').remove();$t.after((hidden)?'<span style="cursor:pointer;border:1px solid black;float:'+flt+';width:'+width+'px;height:'+height+'px;" id="icp_'+id+'">&nbsp;</span>':'').after(colorPicker).remove();if(hidden){if($('#'+id).prop('class')){$('#icp_'+id).prop('class',$('#'+id).prop('class'));}
  1607.  
  1608.  
  1609. 537.$('#icp_'+id).css({'background-color':color,'background-image':image,'display':'inline-block'}).addClass('mColorPickerTrigger');}else{$('#'+id).css({'background-color':color,'background-image':image}).css({'color':$.fn.mColorPicker.textColor($('#'+id).css('background-color'))}).after('<span style="cursor:pointer;" id="icp_'+id+'" class="mColorPickerTrigger"><img src="'+$o.imageFolder+'color.png" style="border:0;margin:0 0 0 3px" align="absmiddle"></span>').addClass('mColorPickerInput');}
  1610.  
  1611.  
  1612. 538.$('#icp_'+id).attr('data-mcolorpicker','true');$('#'+id).addClass('mColorPicker');return $('#'+id);};$.fn.mColorPicker.drawPicker=function(){$(document.createElement("div")).attr("id","mColorPicker").css('display','none').html('<div id="mColorPickerWrapper"><div id="mColorPickerImg" class="mColor"></div><div id="mColorPickerImgGray" class="mColor"></div><div id="mColorPickerSwatches"><div class="mClear"></div></div><div id="mColorPickerFooter"><input type="text" size="8" id="mColorPickerInput"/></div></div>').appendTo("body");$(document.createElement("div")).attr("id","mColorPickerBg").css({'display':'none'}).appendTo("body");for(n=9;n>-1;n--){$(document.createElement("div")).attr({'id':'cell'+n,'class':"mPastColor"+((n>0)?' mNoLeftBorder':'')}).html('&nbsp;').prependTo("#mColorPickerSwatches");}
  1613.  
  1614.  
  1615. 539.$('#mColorPicker').css({'border':'1px solid #ccc','color':'#fff','z-index':999998,'width':'194px','height':'184px','font-size':'12px','font-family':'times'});$('.mPastColor').css({'height':'18px','width':'18px','border':'1px solid #000','float':'left'});$('#colorPreview').css({'height':'50px'});$('.mNoLeftBorder').css({'border-left':0});$('.mClear').css({'clear':'both'});$('#mColorPickerWrapper').css({'position':'relative','border':'solid 1px gray','z-index':999999});$('#mColorPickerImg').css({'height':'128px','width':'192px','border':0,'cursor':'crosshair','background-image':"url('"+$o.imageFolder+"colorpicker.png')"});$('#mColorPickerImgGray').css({'height':'8px','width':'192px','border':0,'cursor':'crosshair','background-image':"url('"+$o.imageFolder+"graybar.jpg')"});$('#mColorPickerInput').css({'border':'solid 1px gray','font-size':'10pt','margin':'3px','width':'80px'});$('#mColorPickerImgGrid').css({'border':0,'height':'20px','width':'20px','vertical-align':'text-bottom'});$('#mColorPickerSwatches').css({'border-right':'1px solid #000'});$('#mColorPickerFooter').css({'background-image':"url('"+$o.imageFolder+"grid.gif')",'position':'relative','height':'26px'});if($.fn.mColorPicker.init.allowTransparency)$('#mColorPickerFooter').prepend('<span id="mColorPickerTransparent" class="mColor" style="font-size:16px;color:#000;padding-right:30px;padding-top:3px;cursor:pointer;overflow:hidden;float:right;">transparent</span>');if($.fn.mColorPicker.init.showLogo)$('#mColorPickerFooter').prepend('<a href="http://meta100.com/" title="Meta100 - Designing Fun" alt="Meta100 - Designing Fun" style="float:right;" target="_blank"><img src="'+$o.imageFolder+'meta100.png" title="Meta100 - Designing Fun" alt="Meta100 - Designing Fun" style="border:0;border-left:1px solid #aaa;right:0;position:absolute;"/></a>');$("#mColorPickerBg").click($.fn.mColorPicker.closePicker);var swatch=$.fn.mColorPicker.getCookie('swatches'),i=0;if(typeof swatch=='string')swatch=swatch.split('||');if(swatch==null||$.fn.mColorPicker.init.enhancedSwatches||swatch.length<10)swatch=$o.swatches;$(".mPastColor").each(function(){$(this).css('background-color',swatch[i++].toLowerCase());});};$.fn.mColorPicker.closePicker=function(){$(".mColor, .mPastColor, #mColorPickerInput, #mColorPickerWrapper").unbind();$("#mColorPickerBg").hide();$("#mColorPicker").fadeOut()};$.fn.mColorPicker.colorShow=function(id){var $e=$("#icp_"+id);pos=$e.offset(),$i=$("#"+id);hex=$i.attr('data-hex')||$i.attr('hex'),pickerTop=pos.top+$e.outerHeight(),pickerLeft=pos.left,$d=$(document),$m=$("#mColorPicker");if($i.attr('disabled'))return false;if(pickerTop+$m.height()>$d.height())pickerTop=pos.top-$m.height();if(pickerLeft+$m.width()>$d.width())pickerLeft=pos.left-$m.width()+$e.outerWidth();$m.css({'top':(pickerTop)+"px",'left':(pickerLeft)+"px",'position':'absolute'}).fadeIn("fast");$("#mColorPickerBg").css({'z-index':999990,'background':'black','opacity':.01,'position':'absolute','top':0,'left':0,'width':parseInt($d.width(),10)+'px','height':parseInt($d.height(),10)+'px'}).show();var def=$i.val();$('#colorPreview span').text(def);$('#colorPreview').css('background',def);$('#color').val(def);if($('#'+id).attr('data-text'))$.fn.mColorPicker.currentColor=$e.css('background-color');else $.fn.mColorPicker.currentColor=$i.css('background-color');if(hex=='true')$.fn.mColorPicker.currentColor=$.fn.mColorPicker.RGBtoHex($.fn.mColorPicker.currentColor);$("#mColorPickerInput").val($.fn.mColorPicker.currentColor);$('.mColor, .mPastColor').bind('mousemove',function(e){var offset=$(this).offset();$.fn.mColorPicker.color=$(this).css("background-color");if($(this).hasClass('mPastColor')&&hex=='true')$.fn.mColorPicker.color=$.fn.mColorPicker.RGBtoHex($.fn.mColorPicker.color);else if($(this).hasClass('mPastColor')&&hex!='true')$.fn.mColorPicker.color=$.fn.mColorPicker.hexToRGB($.fn.mColorPicker.color);else if($(this).attr('id')=='mColorPickerTransparent')$.fn.mColorPicker.color='transparent';else if(!$(this).hasClass('mPastColor'))$.fn.mColorPicker.color=$.fn.mColorPicker.whichColor(e.pageX-offset.left,e.pageY-offset.top+(($(this).attr('id')=='mColorPickerImgGray')?128:0),hex);$.fn.mColorPicker.setInputColor(id,$.fn.mColorPicker.color);}).click(function(){$.fn.mColorPicker.colorPicked(id);});$('#mColorPickerInput').bind('keyup',function(e){try{$.fn.mColorPicker.color=$('#mColorPickerInput').val();$.fn.mColorPicker.setInputColor(id,$.fn.mColorPicker.color);if(e.which==13)$.fn.mColorPicker.colorPicked(id);}catch(r){}}).bind('blur',function(){$.fn.mColorPicker.setInputColor(id,$.fn.mColorPicker.currentColor);});$('#mColorPickerWrapper').bind('mouseleave',function(){$.fn.mColorPicker.setInputColor(id,$.fn.mColorPicker.currentColor);});};$.fn.mColorPicker.setInputColor=function(id,color){var image=(color=='transparent')?"url('"+$o.imageFolder+"grid.gif')":'',textColor=$.fn.mColorPicker.textColor(color);if($('#'+id).attr('data-text')||$('#'+id).prop('text'))$("#icp_"+id).css({'background-color':color,'background-image':image});$("#"+id).val(color).css({'background-color':color,'background-image':image,'color':textColor}).trigger('change');$("#mColorPickerInput").val(color);};$.fn.mColorPicker.textColor=function(val){if(typeof val=='undefined'||val=='transparent')return"black";val=$.fn.mColorPicker.RGBtoHex(val);return(parseInt(val.substr(1,2),16)+parseInt(val.substr(3,2),16)+parseInt(val.substr(5,2),16)<400)?'white':'black';};$.fn.mColorPicker.setCookie=function(name,value,days){var cookie_string=name+"="+escape(value),expires=new Date();expires.setDate(expires.getDate()+days);cookie_string+="; expires="+expires.toGMTString();document.cookie=cookie_string;};$.fn.mColorPicker.getCookie=function(name){var results=document.cookie.match('(^|;) ?'+name+'=([^;]*)(;|$)');if(results)return(unescape(results[2]));else return null;};$.fn.mColorPicker.colorPicked=function(id){$.fn.mColorPicker.closePicker();if($.fn.mColorPicker.init.enhancedSwatches)$.fn.mColorPicker.addToSwatch();$("#"+id).trigger('colorpicked',[id,$('#mColorPickerInput').val()]);};$.fn.mColorPicker.addToSwatch=function(color){var swatch=[]
  1616.  
  1617.  
  1618. 540.i=0;if(typeof color=='string')$.fn.mColorPicker.color=color.toLowerCase();$.fn.mColorPicker.currentValue=$.fn.mColorPicker.currentColor=$.fn.mColorPicker.color;if($.fn.mColorPicker.color!='transparent')swatch[0]=$.fn.mColorPicker.color.toLowerCase();$('.mPastColor').each(function(){$.fn.mColorPicker.color=$(this).css('background-color').toLowerCase();if($.fn.mColorPicker.color!=swatch[0]&&$.fn.mColorPicker.RGBtoHex($.fn.mColorPicker.color)!=swatch[0]&&$.fn.mColorPicker.hexToRGB($.fn.mColorPicker.color)!=swatch[0]&&swatch.length<10)swatch[swatch.length]=$.fn.mColorPicker.color;$(this).css('background-color',swatch[i++])});if($.fn.mColorPicker.init.enhancedSwatches)$.fn.mColorPicker.setCookie('swatches',swatch.join('||'),365);};$.fn.mColorPicker.whichColor=function(x,y,hex){var colorR=colorG=colorB=255;if(x<32){colorG=x*8;colorB=0;}else if(x<64){colorR=256-(x-32)*8;colorB=0;}else if(x<96){colorR=0;colorB=(x-64)*8;}else if(x<128){colorR=0;colorG=256-(x-96)*8;}else if(x<160){colorR=(x-128)*8;colorG=0;}else{colorG=0;colorB=256-(x-160)*8;}
  1619.  
  1620.  
  1621. 541.if(y<64){colorR+=(256-colorR)*(64-y)/64;colorG+=(256-colorG)*(64-y)/64;colorB+=(256-colorB)*(64-y)/64;}else if(y<=128){colorR-=colorR*(y-64)/64;colorG-=colorG*(y-64)/64;colorB-=colorB*(y-64)/64;}else if(y>128){colorR=colorG=colorB=256-(x/192*256);}
  1622.  
  1623.  
  1624. 542.colorR=Math.round(Math.min(colorR,255));colorG=Math.round(Math.min(colorG,255));colorB=Math.round(Math.min(colorB,255));if(hex=='true'){colorR=colorR.toString(16);colorG=colorG.toString(16);colorB=colorB.toString(16);if(colorR.length<2)colorR=0+colorR;if(colorG.length<2)colorG=0+colorG;if(colorB.length<2)colorB=0+colorB;return"#"+colorR+colorG+colorB;}
  1625.  
  1626.  
  1627. 543.return"rgb("+colorR+', '+colorG+', '+colorB+')';};$.fn.mColorPicker.RGBtoHex=function(color){color=color.toLowerCase();if(typeof color=='undefined')return'';if(color.indexOf('#')>-1&&color.length>6)return color;if(color.indexOf('rgb')<0)return color;if(color.indexOf('#')>-1){return'#'+color.substr(1,1)+color.substr(1,1)+color.substr(2,1)+color.substr(2,1)+color.substr(3,1)+color.substr(3,1);}
  1628.  
  1629.  
  1630. 544.var hexArray=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],decToHex="#",code1=0;color=color.replace(/[^0-9,]/g,'').split(",");for(var n=0;n<color.length;n++){code1=Math.floor(color[n]/16);decToHex+=hexArray[code1]+hexArray[color[n]-code1*16];}
  1631.  
  1632.  
  1633. 545.return decToHex;};$.fn.mColorPicker.hexToRGB=function(color){color=color.toLowerCase();if(typeof color=='undefined')return'';if(color.indexOf('rgb')>-1)return color;if(color.indexOf('#')<0)return color;var c=color.replace('#','');if(c.length<6)c=c.substr(0,1)+c.substr(0,1)+c.substr(1,1)+c.substr(1,1)+c.substr(2,1)+c.substr(2,1);return'rgb('+parseInt(c.substr(0,2),16)+', '+parseInt(c.substr(2,2),16)+', '+parseInt(c.substr(4,2),16)+')';};$(document).ready(function(){if($.fn.mColorPicker.init.replace){$('input[data-mcolorpicker!="true"]').filter(function(){return($.fn.mColorPicker.init.replace=='[type=color]')?this.getAttribute("type")=='color':$(this).is($.fn.mColorPicker.init.replace);}).mColorPicker();$.fn.mColorPicker.liveEvents();}});})(jQuery);$(document).ready(function(){var tabs={photos_url:$('.info-user a[data-tab="photos"]').attr('href'),settings_url:$('.info-user a[data-tab="settings"]').attr('href'),settings_button:$('.info-user a[data-tab="settings"]'),contest_url:$('.info-user a[data-tab="contest"]').attr('href'),tab_handles:{photos:null,settings:null,contest:null,token_stats:$(".info-user div.token_stats"),share_and_earn:$(".info-user div.share_and_earn"),leaderboard:$(".info-user div.leaderboard"),bio:$(".info-user div.bio")},init:function(){$(".info-user .buttons li a").click(tabs.on_tab_button_click);$(".private_settings .value").click(tabs.on_private_settings_clicked);$(".group_show_disabled a").click(tabs.on_groupshow_settings_clicked);},on_groupshow_settings_clicked:function(){tabs._disable_tabs();tabs.settings_button.parent().addClass('active');tabs._show_settings_tab(function(){$('#id_allow_group_shows').focus();});return false;},on_private_settings_clicked:function(){tabs._disable_tabs();tabs.settings_button.parent().addClass('active');tabs._show_settings_tab(function(){$('#id_allow_private_shows').focus();});return false;},on_tab_button_click:function(event){tabs._disable_tabs();$(this).parent().addClass('active');if($(this).data('tab')=='bio'){tabs.tab_handles.bio.show();}else if($(this).data('tab')=='photos'){tabs.refresh_photos();}else if($(this).data('tab')=='settings'){tabs.refresh_settings();}else if($(this).data('tab')=='contest'){tabs.refresh_contest();}else if($(this).data('tab')=='token_stats'){tabs._show_token_stats();}else if($(this).data('tab')=='share_and_earn'){tabs._show_share_and_earn();}else if($(this).data('tab')=='leaderboard'){tabs._show_leaderboard();}
  1634.  
  1635.  
  1636. 546.return false;},refresh_photos:function(){if(tabs.tab_handles.photos){tabs.tab_handles.photos.remove();tabs.tab_handles.photos=null;}
  1637.  
  1638.  
  1639. 547.tabs._show_photos_tab();},refresh_contest:function(){if(tabs.tab_handles.contest){tabs.tab_handles.contest.remove();tabs.tab_handles.contest=null;}
  1640.  
  1641.  
  1642. 548.tabs._show_contest_tab();},refresh_settings:function(callback){if(tabs.tab_handles.settings){tabs.tab_handles.settings.remove();tabs.tab_handles.settings=null;}
  1643.  
  1644.  
  1645. 549.tabs._show_settings_tab(callback);},_show_leaderboard:function(){tabs._load_tab(tabs.tab_handles.leaderboard,$(".info-user .buttons a[data-tab='leaderboard']").attr('href'));},_show_token_stats:function(){tabs._load_tab(tabs.tab_handles.token_stats,$(".info-user .buttons a[data-tab='token_stats']").attr('href'),function(){tabs.tab_handles.token_stats.find('.refreshstats').click(tabs._show_token_stats);tabs.tab_handles.token_stats.find('form').submit(tabs._on_token_transfer);tabs.tab_handles.token_stats.find('.account_activity').scroll(tabs._on_token_stats_scroll);});},_on_token_stats_scroll:function(){var $this=$(this);if($this.scrollTop()+300>=this.scrollHeight-$this.height()){$this.find("a.endless_more").click();}},_on_token_transfer:function(){var num_tokens=parseInt($(this).find("#id_transfer_amount").val());var token_balance=parseInt(tabs.tab_handles.token_stats.find('.token_balance').text());var cash_amount=num_tokens*0.05;if(isNaN(num_tokens)|num_tokens<1){alert("Invalid token amount.");return false;}
  1646.  
  1647.  
  1648. 550.if(num_tokens>token_balance){alert("Insufficient tokens.");return false;}
  1649.  
  1650.  
  1651. 551.var msg=interpolate(gettext("Convert %(num_tokens)s to \$%(cash_amount)s"),{num_tokens:num_tokens,cash_amount:cash_amount},true);return confirm(msg);},_show_share_and_earn:function(){tabs._load_tab(tabs.tab_handles.share_and_earn,$(".info-user .buttons a[data-tab='share_and_earn']").attr('href'));},_load_tab:function(tab,target,func){tab.show();tab.html(gettext("loading . . ."));if(func){tab.load(target,func);}else{tab.load(target);}},_show_photos_tab:function(){if(tabs.tab_handles.photos===null){var html="<div class='bottompanel fixedheightbottompanel photopages'>"+gettext("loading . . .")+"</div>";tabs.tab_handles.photos=$(html);tabs.tab_handles.bio.after(tabs.tab_handles.photos);tabs.tab_handles.photos.load(tabs.photos_url,function(){tabs.tab_handles.photos.scroll(tabs._on_photos_scroll);tabs.tab_handles.photos.find('.refreshphotos').click(tabs.refresh_photos);});}else{tabs.tab_handles.photos.show();}},_show_settings_tab:function(callback){if(tabs.tab_handles.settings===null){var html="<div class='bottompanel accountsettings'>"+gettext("loading . . .")+"</div>";tabs.tab_handles.settings=$(html);tabs.tab_handles.bio.after(tabs.tab_handles.settings);tabs.tab_handles.settings.load(tabs.settings_url,function(){tabs._init_settings_form();if(callback){callback();}});}else{tabs.tab_handles.settings.show();if(callback){callback();}}},_init_settings_form:function(){tabs.tab_handles.settings.find('a').attr('target','_blank');tabs.tab_handles.settings.find('form').submit(tabs._on_settings_submit);tabs.tab_handles.settings.find('#id_block_from_countries').listselect({listTitle:gettext('Able to view'),selectedTitle:gettext('Blocked countries')});tabs.tab_handles.settings.find('#id_block_from_states').listselect({listTitle:gettext('Able to view'),selectedTitle:gettext('Blocked states')});},_on_settings_submit:function(){$.ajax({type:'POST',url:$(this).attr('action'),data:$(this).serialize(),dataType:'json',cache:false,success:function(data){tabs.tab_handles.settings.html(data.html);tabs._init_settings_form();if(data.result=='success'){alert(gettext("Settings saved"));}
  1652.  
  1653.  
  1654. 552.return false;}});return false;},_show_contest_tab:function(){if(tabs.tab_handles.contest===null){var html="<div class='bottompanel conteststats'>"+gettext("loading . . .")+"</div>";tabs.tab_handles.contest=$(html);tabs.tab_handles.bio.after(tabs.tab_handles.contest);tabs.tab_handles.contest.load(tabs.contest_url,function(){tabs.tab_handles.contest.find('.refreshstats').click(tabs.refresh_contest);});}else{tabs.tab_handles.contest.show();}},_on_photos_scroll:function(){var $this=$(this);if($this.scrollTop()+500>=this.scrollHeight-$this.height()){$this.find("a.endless_more").click();}},_disable_tabs:function(){$(".info-user .buttons li.active").removeClass('active');$(".info-user > div").hide();$(".info-user .headline").show();}};tabs.init();var bio={bio_div:$(document).find('div.bio'),init:function(){$('a.editbio').live('click',bio.on_edit_click);},on_edit_click:function(){bio.bio_div.load($(this).attr('href'),bio._init_form);return false;},on_form_submit:function(){var next=$(this).find('input[name="next"]').val();$.ajax({type:'POST',url:$(this).attr('action'),data:$(this).serialize(),dataType:'json',cache:false,success:function(data){if(data.result=='success'){bio.bio_div.load(next);}else{bio.bio_div.html(data.html);bio._init_form();}
  1655.  
  1656.  
  1657. 553.return false;}});return false;},_init_form:function(){bio.bio_div.find('textarea').attr('rows','1');bio.bio_div.find('textarea').elastic();bio.bio_div.find('form').submit(bio.on_form_submit);bio.bio_div.find('.canceleditbio').click(bio._on_cancel_edit_click);},_on_cancel_edit_click:function(){bio.bio_div.load($(this).attr('href'));return false;}};bio.init();var follow={on_follow_click:function(){var link=$(this);if(login_required()){return false;}
  1658.  
  1659.  
  1660. 554.$.ajax({url:link.data('followurl'),cache:false,success:function(){link.parent().removeClass('button_follow');link.parent().addClass('button_unfollow');link.html(link.data('unfollowtext'));}});return false;},on_unfollow_click:function(){var link=$(this);$.ajax({url:link.data('unfollowurl'),cache:false,success:function(){link.parent().removeClass('button_unfollow');link.parent().addClass('button_follow');link.html(link.data('followtext'));}});return false;}};$(".button_follow a").live('click',follow.on_follow_click);$(".button_unfollow a").live('click',follow.on_unfollow_click);var report={_div_overlay:$("#report_popup"),on_cancel:function(){report._clear_and_close();return false;},on_submit:function(){var $this=$(this);if($this.find('select[name="category"]').val()===""){alert(gettext("Please choose a category."));return false;}
  1661.  
  1662.  
  1663. 555.$.ajax({type:'POST',url:$this.attr('action'),data:$this.serialize(),dataType:'json',cache:false,success:function(data){if(data['result']==='success'){report._clear_and_close();alert(gettext("Your abuse report has been submitted."));}else{alert("An error occurred.");}}});return false;},overlay_toggle:function(){if(login_required()){return false;}
  1664.  
  1665.  
  1666. 556.report._div_overlay.toggle();if(report._div_overlay.is(":visible")){report._div_overlay.find('textarea').focus();report._div_overlay.find('textarea').select();}},init:function(){$("#report_popup_link").click(report.overlay_toggle);report._div_overlay.find(".button_abuse_cancel a").click(report.on_cancel);report._div_overlay.find(".button_abuse_report a").click(function(){report._div_overlay.find("form").submit();return false;});report._div_overlay.find("form").submit(report.on_submit);$(".disputerecording").live('click',function(){var msg=gettext("Are the reports that this is a recording false?\n\nPlease only vote if you have confirmed that this cam is live.\n\nAsk something like \"hold up 2 fingers to prove you are live\" first!");if(confirm(msg)){$.ajax({type:'POST',url:$("#report_popup form").attr('action'),data:{'category':'recordingdispute'},dataType:'json',cache:false,success:function(data){if(data['result']==='success'){report._clear_and_close();alert(gettext("Your report has been submitted."));}else{alert("An error occurred.");}}});}});},_clear_and_close:function(){report._div_overlay.hide();report._div_overlay.find('textarea').val("");}};report.init();var dismisscookiename='dsmn4';$('a.dismiss_notice').click(function(){var d=new Date;d.setTime(d.getTime()+1000*60*60*24*60);$.cookie(dismisscookiename,'1',{expires:d,path:'/'});$('.dismissable_notice').hide();return false;});if($.cookie(dismisscookiename)=='1'){$('.dismissable_notice').hide();}
  1667.  
  1668.  
  1669. 557.$("a.deletephotolink").live('click',function(){var deletelink=$(this);if(confirm(gettext("Are you sure you want to delete?"))){$.post(deletelink.attr('href'),function(){deletelink.closest('.image_container').remove()});}
  1670.  
  1671.  
  1672. 558.return false;});$("a.disablephotoslink, a.enablephotoslink").live('click',function(){if(confirm(gettext("Are you sure?"))){$.post($(this).attr('href'),{'foo':'bar'},function(){tabs.refresh_photos();});}
  1673.  
  1674.  
  1675. 559.return false;});$('a[rel*=facebox]').live('mousedown',function(){$(this).facebox();});});
  1676.  
  1677.  
  1678. RAW Paste Data
  1679.  
  1680. rtmpdump -r "rtmpe://edge1-a.stream.chaturbate.com/live-edge" -a "live-edge" -W "http://ccstatic.chaturbate.com/static/flash/CBV_2p51.swf" -p "http://chaturbate.com/yelle92/" -y "mp4:public-yelle92" -v -o t.flv -T "m9z#$dO0qe34Rxe@sMYxx%"
  1681.  
  1682. no longer works as of 1/25/12, need to get new token, see javascript:
  1683.  
  1684. var MEDIA_URL='http://ccstatic.chaturbate.com/static/';var Base64=(function(){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var obj={encode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;do{chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
  1685. output=output+keyStr.charAt(enc1)+keyStr.charAt(enc2)+
  1686. keyStr.charAt(enc3)+keyStr.charAt(enc4);}while(i<input.length);return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
  1687. if(enc4!=64){output=output+String.fromCharCode(chr3);}}while(i<input.length);return output;}};return obj;})();var MD5=(function(){var hexcase=0;var b64pad="";var chrsz=8;var safe_add=function(x,y){var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);};var bit_rol=function(num,cnt){return(num<<cnt)|(num>>>(32-cnt));};var str2binl=function(str){var bin=[];var mask=(1<<chrsz)-1;for(var i=0;i<str.length*chrsz;i+=chrsz)
  1688. {bin[i>>5]|=(str.charCodeAt(i/chrsz)&mask)<<(i%32);}
  1689. return bin;};var binl2str=function(bin){var str="";var mask=(1<<chrsz)-1;for(var i=0;i<bin.length*32;i+=chrsz)
  1690. {str+=String.fromCharCode((bin[i>>5]>>>(i%32))&mask);}
  1691. return str;};var binl2hex=function(binarray){var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i<binarray.length*4;i++)
  1692. {str+=hex_tab.charAt((binarray[i>>2]>>((i%4)*8+4))&0xF)+
  1693. hex_tab.charAt((binarray[i>>2]>>((i%4)*8))&0xF);}
  1694. return str;};var binl2b64=function(binarray){var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";var triplet,j;for(var i=0;i<binarray.length*4;i+=3)
  1695. {triplet=(((binarray[i>>2]>>8*(i%4))&0xFF)<<16)|(((binarray[i+1>>2]>>8*((i+1)%4))&0xFF)<<8)|((binarray[i+2>>2]>>8*((i+2)%4))&0xFF);for(j=0;j<4;j++)
  1696. {if(i*8+j*6>binarray.length*32){str+=b64pad;}
  1697. else{str+=tab.charAt((triplet>>6*(3-j))&0x3F);}}}
  1698. return str;};var md5_cmn=function(q,a,b,x,s,t){return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b);};var md5_ff=function(a,b,c,d,x,s,t){return md5_cmn((b&c)|((~b)&d),a,b,x,s,t);};var md5_gg=function(a,b,c,d,x,s,t){return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t);};var md5_hh=function(a,b,c,d,x,s,t){return md5_cmn(b^c^d,a,b,x,s,t);};var md5_ii=function(a,b,c,d,x,s,t){return md5_cmn(c^(b|(~d)),a,b,x,s,t);};var core_md5=function(x,len){x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;var olda,oldb,oldc,oldd;for(var i=0;i<x.length;i+=16)
  1699. {olda=a;oldb=b;oldc=c;oldd=d;a=md5_ff(a,b,c,d,x[i+0],7,-680876936);d=md5_ff(d,a,b,c,x[i+1],12,-389564586);c=md5_ff(c,d,a,b,x[i+2],17,606105819);b=md5_ff(b,c,d,a,x[i+3],22,-1044525330);a=md5_ff(a,b,c,d,x[i+4],7,-176418897);d=md5_ff(d,a,b,c,x[i+5],12,1200080426);c=md5_ff(c,d,a,b,x[i+6],17,-1473231341);b=md5_ff(b,c,d,a,x[i+7],22,-45705983);a=md5_ff(a,b,c,d,x[i+8],7,1770035416);d=md5_ff(d,a,b,c,x[i+9],12,-1958414417);c=md5_ff(c,d,a,b,x[i+10],17,-42063);b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);a=md5_ff(a,b,c,d,x[i+12],7,1804603682);d=md5_ff(d,a,b,c,x[i+13],12,-40341101);c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);b=md5_ff(b,c,d,a,x[i+15],22,1236535329);a=md5_gg(a,b,c,d,x[i+1],5,-165796510);d=md5_gg(d,a,b,c,x[i+6],9,-1069501632);c=md5_gg(c,d,a,b,x[i+11],14,643717713);b=md5_gg(b,c,d,a,x[i+0],20,-373897302);a=md5_gg(a,b,c,d,x[i+5],5,-701558691);d=md5_gg(d,a,b,c,x[i+10],9,38016083);c=md5_gg(c,d,a,b,x[i+15],14,-660478335);b=md5_gg(b,c,d,a,x[i+4],20,-405537848);a=md5_gg(a,b,c,d,x[i+9],5,568446438);d=md5_gg(d,a,b,c,x[i+14],9,-1019803690);c=md5_gg(c,d,a,b,x[i+3],14,-187363961);b=md5_gg(b,c,d,a,x[i+8],20,1163531501);a=md5_gg(a,b,c,d,x[i+13],5,-1444681467);d=md5_gg(d,a,b,c,x[i+2],9,-51403784);c=md5_gg(c,d,a,b,x[i+7],14,1735328473);b=md5_gg(b,c,d,a,x[i+12],20,-1926607734);a=md5_hh(a,b,c,d,x[i+5],4,-378558);d=md5_hh(d,a,b,c,x[i+8],11,-2022574463);c=md5_hh(c,d,a,b,x[i+11],16,1839030562);b=md5_hh(b,c,d,a,x[i+14],23,-35309556);a=md5_hh(a,b,c,d,x[i+1],4,-1530992060);d=md5_hh(d,a,b,c,x[i+4],11,1272893353);c=md5_hh(c,d,a,b,x[i+7],16,-155497632);b=md5_hh(b,c,d,a,x[i+10],23,-1094730640);a=md5_hh(a,b,c,d,x[i+13],4,681279174);d=md5_hh(d,a,b,c,x[i+0],11,-358537222);c=md5_hh(c,d,a,b,x[i+3],16,-722521979);b=md5_hh(b,c,d,a,x[i+6],23,76029189);a=md5_hh(a,b,c,d,x[i+9],4,-640364487);d=md5_hh(d,a,b,c,x[i+12],11,-421815835);c=md5_hh(c,d,a,b,x[i+15],16,530742520);b=md5_hh(b,c,d,a,x[i+2],23,-995338651);a=md5_ii(a,b,c,d,x[i+0],6,-198630844);d=md5_ii(d,a,b,c,x[i+7],10,1126891415);c=md5_ii(c,d,a,b,x[i+14],15,-1416354905);b=md5_ii(b,c,d,a,x[i+5],21,-57434055);a=md5_ii(a,b,c,d,x[i+12],6,1700485571);d=md5_ii(d,a,b,c,x[i+3],10,-1894986606);c=md5_ii(c,d,a,b,x[i+10],15,-1051523);b=md5_ii(b,c,d,a,x[i+1],21,-2054922799);a=md5_ii(a,b,c,d,x[i+8],6,1873313359);d=md5_ii(d,a,b,c,x[i+15],10,-30611744);c=md5_ii(c,d,a,b,x[i+6],15,-1560198380);b=md5_ii(b,c,d,a,x[i+13],21,1309151649);a=md5_ii(a,b,c,d,x[i+4],6,-145523070);d=md5_ii(d,a,b,c,x[i+11],10,-1120210379);c=md5_ii(c,d,a,b,x[i+2],15,718787259);b=md5_ii(b,c,d,a,x[i+9],21,-343485551);a=safe_add(a,olda);b=safe_add(b,oldb);c=safe_add(c,oldc);d=safe_add(d,oldd);}
  1700. return[a,b,c,d];};var core_hmac_md5=function(key,data){var bkey=str2binl(key);if(bkey.length>16){bkey=core_md5(bkey,key.length*chrsz);}
  1701. var ipad=new Array(16),opad=new Array(16);for(var i=0;i<16;i++)
  1702. {ipad[i]=bkey[i]^0x36363636;opad[i]=bkey[i]^0x5C5C5C5C;}
  1703. var hash=core_md5(ipad.concat(str2binl(data)),512+data.length*chrsz);return core_md5(opad.concat(hash),512+128);};var obj={hexdigest:function(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz));},b64digest:function(s){return binl2b64(core_md5(str2binl(s),s.length*chrsz));},hash:function(s){return binl2str(core_md5(str2binl(s),s.length*chrsz));},hmac_hexdigest:function(key,data){return binl2hex(core_hmac_md5(key,data));},hmac_b64digest:function(key,data){return binl2b64(core_hmac_md5(key,data));},hmac_hash:function(key,data){return binl2str(core_hmac_md5(key,data));},test:function(){return MD5.hexdigest("abc")==="900150983cd24fb0d6963f7d28e17f72";}};return obj;})();if(!Function.prototype.bind){Function.prototype.bind=function(obj)
  1704. {var func=this;return function(){return func.apply(obj,arguments);};};}
  1705. if(!Function.prototype.prependArg){Function.prototype.prependArg=function(arg)
  1706. {var func=this;return function(){var newargs=[arg];for(var i=0;i<arguments.length;i++){newargs.push(arguments[i]);}
  1707. return func.apply(this,newargs);};};}
  1708. if(!Array.prototype.indexOf)
  1709. {Array.prototype.indexOf=function(elt)
  1710. {var len=this.length;var from=Number(arguments[1])||0;from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0){from+=len;}
  1711. for(;from<len;from++){if(from in this&&this[from]===elt){return from;}}
  1712. return-1;};}
  1713. (function(callback){var Strophe;function $build(name,attrs){return new Strophe.Builder(name,attrs);}
  1714. function $msg(attrs){return new Strophe.Builder("message",attrs);}
  1715. function $iq(attrs){return new Strophe.Builder("iq",attrs);}
  1716. function $pres(attrs){return new Strophe.Builder("presence",attrs);}
  1717. Strophe={VERSION:"1.0.1",NS:{HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas"},addNamespace:function(name,value)
  1718. {Strophe.NS[name]=value;},Status:{ERROR:0,CONNECTING:1,CONNFAIL:2,AUTHENTICATING:3,AUTHFAIL:4,CONNECTED:5,DISCONNECTED:6,DISCONNECTING:7,ATTACHED:8},LogLevel:{DEBUG:0,INFO:1,WARN:2,ERROR:3,FATAL:4},ElementType:{NORMAL:1,TEXT:3},TIMEOUT:1.1,SECONDARY_TIMEOUT:0.1,forEachChild:function(elem,elemName,func)
  1719. {var i,childNode;for(i=0;i<elem.childNodes.length;i++){childNode=elem.childNodes[i];if(childNode.nodeType==Strophe.ElementType.NORMAL&&(!elemName||this.isTagEqual(childNode,elemName))){func(childNode);}}},isTagEqual:function(el,name)
  1720. {return el.tagName.toLowerCase()==name.toLowerCase();},_xmlGenerator:null,_makeGenerator:function(){var doc;if(window.ActiveXObject){doc=new ActiveXObject("Microsoft.XMLDOM");doc.appendChild(doc.createElement('strophe'));}else{doc=document.implementation.createDocument('jabber:client','strophe',null);}
  1721. return doc;},xmlElement:function(name)
  1722. {if(!name){return null;}
  1723. var node=null;if(!Strophe._xmlGenerator){Strophe._xmlGenerator=Strophe._makeGenerator();}
  1724. node=Strophe._xmlGenerator.createElement(name);var a,i,k;for(a=1;a<arguments.length;a++){if(!arguments[a]){continue;}
  1725. if(typeof(arguments[a])=="string"||typeof(arguments[a])=="number"){node.appendChild(Strophe.xmlTextNode(arguments[a]));}else if(typeof(arguments[a])=="object"&&typeof(arguments[a].sort)=="function"){for(i=0;i<arguments[a].length;i++){if(typeof(arguments[a][i])=="object"&&typeof(arguments[a][i].sort)=="function"){node.setAttribute(arguments[a][i][0],arguments[a][i][1]);}}}else if(typeof(arguments[a])=="object"){for(k in arguments[a]){if(arguments[a].hasOwnProperty(k)){node.setAttribute(k,arguments[a][k]);}}}}
  1726. return node;},xmlescape:function(text)
  1727. {text=text.replace(/\&/g,"&amp;");text=text.replace(/</g,"&lt;");text=text.replace(/>/g,"&gt;");return text;},xmlTextNode:function(text)
  1728. {text=Strophe.xmlescape(text);if(!Strophe._xmlGenerator){Strophe._xmlGenerator=Strophe._makeGenerator();}
  1729. return Strophe._xmlGenerator.createTextNode(text);},getText:function(elem)
  1730. {if(!elem){return null;}
  1731. var str="";if(elem.childNodes.length===0&&elem.nodeType==Strophe.ElementType.TEXT){str+=elem.nodeValue;}
  1732. for(var i=0;i<elem.childNodes.length;i++){if(elem.childNodes[i].nodeType==Strophe.ElementType.TEXT){str+=elem.childNodes[i].nodeValue;}}
  1733. return str;},copyElement:function(elem)
  1734. {var i,el;if(elem.nodeType==Strophe.ElementType.NORMAL){el=Strophe.xmlElement(elem.tagName);for(i=0;i<elem.attributes.length;i++){el.setAttribute(elem.attributes[i].nodeName.toLowerCase(),elem.attributes[i].value);}
  1735. for(i=0;i<elem.childNodes.length;i++){el.appendChild(Strophe.copyElement(elem.childNodes[i]));}}else if(elem.nodeType==Strophe.ElementType.TEXT){el=Strophe.xmlTextNode(elem.nodeValue);}
  1736. return el;},escapeNode:function(node)
  1737. {return node.replace(/^\s+|\s+$/g,'').replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/\"/g,"\\22").replace(/\&/g,"\\26").replace(/\'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40");},unescapeNode:function(node)
  1738. {return node.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\");},getNodeFromJid:function(jid)
  1739. {if(jid.indexOf("@")<0){return null;}
  1740. return jid.split("@")[0];},getDomainFromJid:function(jid)
  1741. {var bare=Strophe.getBareJidFromJid(jid);if(bare.indexOf("@")<0){return bare;}else{var parts=bare.split("@");parts.splice(0,1);return parts.join('@');}},getResourceFromJid:function(jid)
  1742. {var s=jid.split("/");if(s.length<2){return null;}
  1743. s.splice(0,1);return s.join('/');},getBareJidFromJid:function(jid)
  1744. {return jid.split("/")[0];},log:function(level,msg)
  1745. {return;},debug:function(msg)
  1746. {this.log(this.LogLevel.DEBUG,msg);},info:function(msg)
  1747. {this.log(this.LogLevel.INFO,msg);},warn:function(msg)
  1748. {this.log(this.LogLevel.WARN,msg);},error:function(msg)
  1749. {this.log(this.LogLevel.ERROR,msg);},fatal:function(msg)
  1750. {this.log(this.LogLevel.FATAL,msg);},serialize:function(elem)
  1751. {var result;if(!elem){return null;}
  1752. if(typeof(elem.tree)==="function"){elem=elem.tree();}
  1753. var nodeName=elem.nodeName;var i,child;if(elem.getAttribute("_realname")){nodeName=elem.getAttribute("_realname");}
  1754. result="<"+nodeName;for(i=0;i<elem.attributes.length;i++){if(elem.attributes[i].nodeName!="_realname"){result+=" "+elem.attributes[i].nodeName.toLowerCase()+"='"+elem.attributes[i].value.replace("&","&amp;").replace("'","&apos;").replace("<","&lt;")+"'";}}
  1755. if(elem.childNodes.length>0){result+=">";for(i=0;i<elem.childNodes.length;i++){child=elem.childNodes[i];if(child.nodeType==Strophe.ElementType.NORMAL){result+=Strophe.serialize(child);}else if(child.nodeType==Strophe.ElementType.TEXT){result+=child.nodeValue;}}
  1756. result+="</"+nodeName+">";}else{result+="/>";}
  1757. return result;},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(name,ptype)
  1758. {Strophe._connectionPlugins[name]=ptype;}};Strophe.Builder=function(name,attrs)
  1759. {if(name=="presence"||name=="message"||name=="iq"){if(attrs&&!attrs.xmlns){attrs.xmlns=Strophe.NS.CLIENT;}else if(!attrs){attrs={xmlns:Strophe.NS.CLIENT};}}
  1760. this.nodeTree=Strophe.xmlElement(name,attrs);this.node=this.nodeTree;};Strophe.Builder.prototype={tree:function()
  1761. {return this.nodeTree;},toString:function()
  1762. {return Strophe.serialize(this.nodeTree);},up:function()
  1763. {this.node=this.node.parentNode;return this;},attrs:function(moreattrs)
  1764. {for(var k in moreattrs){if(moreattrs.hasOwnProperty(k)){this.node.setAttribute(k,moreattrs[k]);}}
  1765. return this;},c:function(name,attrs)
  1766. {var child=Strophe.xmlElement(name,attrs);this.node.appendChild(child);this.node=child;return this;},cnode:function(elem)
  1767. {this.node.appendChild(elem);this.node=elem;return this;},t:function(text)
  1768. {var child=Strophe.xmlTextNode(text);this.node.appendChild(child);return this;}};Strophe.Handler=function(handler,ns,name,type,id,from,options)
  1769. {this.handler=handler;this.ns=ns;this.name=name;this.type=type;this.id=id;this.options=options||{matchbare:false};if(!this.options.matchBare){this.options.matchBare=false;}
  1770. if(this.options.matchBare){this.from=Strophe.getBareJidFromJid(from);}else{this.from=from;}
  1771. this.user=true;};Strophe.Handler.prototype={isMatch:function(elem)
  1772. {var nsMatch;var from=null;if(this.options.matchBare){from=Strophe.getBareJidFromJid(elem.getAttribute('from'));}else{from=elem.getAttribute('from');}
  1773. nsMatch=false;if(!this.ns){nsMatch=true;}else{var self=this;Strophe.forEachChild(elem,null,function(elem){if(elem.getAttribute("xmlns")==self.ns){nsMatch=true;}});nsMatch=nsMatch||elem.getAttribute("xmlns")==this.ns;}
  1774. if(nsMatch&&(!this.name||Strophe.isTagEqual(elem,this.name))&&(!this.type||elem.getAttribute("type")===this.type)&&(!this.id||elem.getAttribute("id")===this.id)&&(!this.from||from===this.from)){return true;}
  1775. return false;},run:function(elem)
  1776. {var result=null;try{result=this.handler(elem);}catch(e){if(e.sourceURL){Strophe.fatal("error: "+this.handler+" "+e.sourceURL+":"+
  1777. e.line+" - "+e.name+": "+e.message);}else if(e.fileName){if(typeof(console)!="undefined"){console.trace();console.error(this.handler," - error - ",e,e.message);}
  1778. Strophe.fatal("error: "+this.handler+" "+
  1779. e.fileName+":"+e.lineNumber+" - "+
  1780. e.name+": "+e.message);}else{Strophe.fatal("error: "+this.handler);}
  1781. throw e;}
  1782. return result;},toString:function()
  1783. {return"{Handler: "+this.handler+"("+this.name+","+
  1784. this.id+","+this.ns+")}";}};Strophe.TimedHandler=function(period,handler)
  1785. {this.period=period;this.handler=handler;this.lastCalled=new Date().getTime();this.user=true;};Strophe.TimedHandler.prototype={run:function()
  1786. {this.lastCalled=new Date().getTime();return this.handler();},reset:function()
  1787. {this.lastCalled=new Date().getTime();},toString:function()
  1788. {return"{TimedHandler: "+this.handler+"("+this.period+")}";}};Strophe.Request=function(elem,func,rid,sends)
  1789. {this.id=++Strophe._requestId;this.xmlData=elem;this.data=Strophe.serialize(elem);this.origFunc=func;this.func=func;this.rid=rid;this.date=NaN;this.sends=sends||0;this.abort=false;this.dead=null;this.age=function(){if(!this.date){return 0;}
  1790. var now=new Date();return(now-this.date)/1000;};this.timeDead=function(){if(!this.dead){return 0;}
  1791. var now=new Date();return(now-this.dead)/1000;};this.xhr=this._newXHR();};Strophe.Request.prototype={getResponse:function()
  1792. {var node=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){node=this.xhr.responseXML.documentElement;if(node.tagName=="parsererror"){Strophe.error("invalid response received");Strophe.error("responseText: "+this.xhr.responseText);Strophe.error("responseXML: "+
  1793. Strophe.serialize(this.xhr.responseXML));throw"parsererror";}}else if(this.xhr.responseText){Strophe.error("invalid response received");Strophe.error("responseText: "+this.xhr.responseText);Strophe.error("responseXML: "+
  1794. Strophe.serialize(this.xhr.responseXML));}
  1795. return node;},_newXHR:function()
  1796. {var xhr=null;if(window.XMLHttpRequest){xhr=new XMLHttpRequest();if(xhr.overrideMimeType){xhr.overrideMimeType("text/xml");}}else if(window.ActiveXObject){xhr=new ActiveXObject("Microsoft.XMLHTTP");}
  1797. xhr.onreadystatechange=this.func.prependArg(this);return xhr;}};Strophe.Connection=function(service)
  1798. {this.service=service;this.jid="";this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this._idleTimeout=null;this._disconnectTimeout=null;this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this.paused=false;this.hold=1;this.wait=60;this.window=5;this._data=[];this._requests=[];this._uniqueId=Math.round(Math.random()*10000);this._sasl_success_handler=null;this._sasl_failure_handler=null;this._sasl_challenge_handler=null;this._idleTimeout=setTimeout(this._onIdle.bind(this),100);for(var k in Strophe._connectionPlugins){if(Strophe._connectionPlugins.hasOwnProperty(k)){var ptype=Strophe._connectionPlugins[k];var F=function(){};F.prototype=ptype;this[k]=new F();this[k].init(this);}}};Strophe.Connection.prototype={reset:function()
  1799. {this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this._requests=[];this._uniqueId=Math.round(Math.random()*10000);},pause:function()
  1800. {this.paused=true;},resume:function()
  1801. {this.paused=false;},getUniqueId:function(suffix)
  1802. {if(typeof(suffix)=="string"||typeof(suffix)=="number"){return++this._uniqueId+":"+suffix;}else{return++this._uniqueId+"";}},connect:function(jid,pass,callback,wait,hold)
  1803. {this.jid=jid;this.pass=pass;this.connect_callback=callback;this.disconnecting=false;this.connected=false;this.authenticated=false;this.errors=0;this.wait=wait||this.wait;this.hold=hold||this.hold;this.domain=Strophe.getDomainFromJid(this.jid);var body=this._buildBody().attrs({to:this.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":Strophe.NS.BOSH});this._changeConnectStatus(Strophe.Status.CONNECTING,null);this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._connect_cb.bind(this)),body.tree().getAttribute("rid")));this._throttledRequestHandler();},attach:function(jid,sid,rid,callback,wait,hold,wind)
  1804. {this.jid=jid;this.sid=sid;this.rid=rid;this.connect_callback=callback;this.domain=Strophe.getDomainFromJid(this.jid);this.authenticated=true;this.connected=true;this.wait=wait||this.wait;this.hold=hold||this.hold;this.window=wind||this.window;this._changeConnectStatus(Strophe.Status.ATTACHED,null);},xmlInput:function(elem)
  1805. {return;},xmlOutput:function(elem)
  1806. {return;},rawInput:function(data)
  1807. {return;},rawOutput:function(data)
  1808. {return;},send:function(elem)
  1809. {if(elem===null){return;}
  1810. if(typeof(elem.sort)==="function"){for(var i=0;i<elem.length;i++){this._queueData(elem[i]);}}else if(typeof(elem.tree)==="function"){this._queueData(elem.tree());}else{this._queueData(elem);}
  1811. this._throttledRequestHandler();clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100);},flush:function()
  1812. {clearTimeout(this._idleTimeout);this._onIdle();},sendIQ:function(elem,callback,errback,timeout){var timeoutHandler=null;var that=this;if(typeof(elem.tree)==="function"){elem=elem.tree();}
  1813. var id=elem.getAttribute('id');if(!id){id=this.getUniqueId("sendIQ");elem.setAttribute("id",id);}
  1814. var handler=this.addHandler(function(stanza){if(timeoutHandler){that.deleteTimedHandler(timeoutHandler);}
  1815. var iqtype=stanza.getAttribute('type');if(iqtype==='result'){if(callback){callback(stanza);}}else if(iqtype==='error'){if(errback){errback(stanza);}}else{throw{name:"StropheError",message:"Got bad IQ type of "+iqtype};}},null,'iq',null,id);if(timeout){timeoutHandler=this.addTimedHandler(timeout,function(){that.deleteHandler(handler);if(errback){errback(null);}
  1816. return false;});}
  1817. this.send(elem);return id;},_queueData:function(element){if(element===null||!element.tagName||!element.childNodes){throw{name:"StropheError",message:"Cannot queue non-DOMElement."};}
  1818. this._data.push(element);},_sendRestart:function()
  1819. {this._data.push("restart");this._throttledRequestHandler();clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100);},addTimedHandler:function(period,handler)
  1820. {var thand=new Strophe.TimedHandler(period,handler);this.addTimeds.push(thand);return thand;},deleteTimedHandler:function(handRef)
  1821. {this.removeTimeds.push(handRef);},addHandler:function(handler,ns,name,type,id,from,options)
  1822. {var hand=new Strophe.Handler(handler,ns,name,type,id,from,options);this.addHandlers.push(hand);return hand;},deleteHandler:function(handRef)
  1823. {this.removeHandlers.push(handRef);},disconnect:function(reason)
  1824. {this._changeConnectStatus(Strophe.Status.DISCONNECTING,reason);Strophe.info("Disconnect was called because: "+reason);if(this.connected){this._disconnectTimeout=this._addSysTimedHandler(3000,this._onDisconnectTimeout.bind(this));this._sendTerminate();}},_changeConnectStatus:function(status,condition)
  1825. {for(var k in Strophe._connectionPlugins){if(Strophe._connectionPlugins.hasOwnProperty(k)){var plugin=this[k];if(plugin.statusChanged){try{plugin.statusChanged(status,condition);}catch(err){Strophe.error(""+k+" plugin caused an exception "+"changing status: "+err);}}}}
  1826. if(this.connect_callback){try{this.connect_callback(status,condition);}catch(e){Strophe.error("User connection callback caused an "+"exception: "+e);}}},_buildBody:function()
  1827. {var bodyWrap=$build('body',{rid:this.rid++,xmlns:Strophe.NS.HTTPBIND});if(this.sid!==null){bodyWrap.attrs({sid:this.sid});}
  1828. return bodyWrap;},_removeRequest:function(req)
  1829. {Strophe.debug("removing request");var i;for(i=this._requests.length-1;i>=0;i--){if(req==this._requests[i]){this._requests.splice(i,1);}}
  1830. req.xhr.onreadystatechange=function(){};this._throttledRequestHandler();},_restartRequest:function(i)
  1831. {var req=this._requests[i];if(req.dead===null){req.dead=new Date();}
  1832. this._processRequest(i);},_processRequest:function(i)
  1833. {var req=this._requests[i];var reqStatus=-1;try{if(req.xhr.readyState==4){reqStatus=req.xhr.status;}}catch(e){Strophe.error("caught an error in _requests["+i+"], reqStatus: "+reqStatus);}
  1834. if(typeof(reqStatus)=="undefined"){reqStatus=-1;}
  1835. var time_elapsed=req.age();var primaryTimeout=(!isNaN(time_elapsed)&&time_elapsed>Math.floor(Strophe.TIMEOUT*this.wait));var secondaryTimeout=(req.dead!==null&&req.timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait));var requestCompletedWithServerError=(req.xhr.readyState==4&&(reqStatus<1||reqStatus>=500));if(primaryTimeout||secondaryTimeout||requestCompletedWithServerError){if(secondaryTimeout){Strophe.error("Request "+
  1836. this._requests[i].id+" timed out (secondary), restarting");}
  1837. req.abort=true;req.xhr.abort();req.xhr.onreadystatechange=function(){};this._requests[i]=new Strophe.Request(req.xmlData,req.origFunc,req.rid,req.sends);req=this._requests[i];}
  1838. if(req.xhr.readyState===0){Strophe.debug("request id "+req.id+"."+req.sends+" posting");req.date=new Date();try{var async=!('sync'in this&&this.sync===true);req.xhr.open("POST",this.service,async);}catch(e2){Strophe.error("XHR open failed.");if(!this.connected){this._changeConnectStatus(Strophe.Status.CONNFAIL,"bad-service");}
  1839. this.disconnect();return;}
  1840. var sendFunc=function(){req.xhr.send(req.data);};if(req.sends>1){var backoff=Math.pow(req.sends,3)*1000;setTimeout(sendFunc,backoff);}else{sendFunc();}
  1841. req.sends++;this.xmlOutput(req.xmlData);this.rawOutput(req.data);}else{Strophe.debug("_processRequest: "+
  1842. (i===0?"first":"second")+" request has readyState of "+
  1843. req.xhr.readyState);}},_throttledRequestHandler:function()
  1844. {if(!this._requests){Strophe.debug("_throttledRequestHandler called with "+"undefined requests");}else{Strophe.debug("_throttledRequestHandler called with "+
  1845. this._requests.length+" requests");}
  1846. if(!this._requests||this._requests.length===0){return;}
  1847. if(this._requests.length>0){this._processRequest(0);}
  1848. if(this._requests.length>1&&Math.abs(this._requests[0].rid-
  1849. this._requests[1].rid)<this.window-1){this._processRequest(1);}},_onRequestStateChange:function(func,req)
  1850. {Strophe.debug("request id "+req.id+"."+req.sends+" state changed to "+
  1851. req.xhr.readyState);if(req.abort){req.abort=false;return;}
  1852. var reqStatus;if(req.xhr.readyState==4){reqStatus=0;try{reqStatus=req.xhr.status;}catch(e){}
  1853. if(typeof(reqStatus)=="undefined"){reqStatus=0;}
  1854. if(this.disconnecting){if(reqStatus>=400){this._hitError(reqStatus);return;}}
  1855. var reqIs0=(this._requests[0]==req);var reqIs1=(this._requests[1]==req);if((reqStatus>0&&reqStatus<500)||req.sends>5){this._removeRequest(req);Strophe.debug("request id "+
  1856. req.id+" should now be removed");}
  1857. if(reqStatus==200){if(reqIs1||(reqIs0&&this._requests.length>0&&this._requests[0].age()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait))){this._restartRequest(0);}
  1858. Strophe.debug("request id "+
  1859. req.id+"."+
  1860. req.sends+" got 200");func(req);this.errors=0;}else{Strophe.error("request id "+
  1861. req.id+"."+
  1862. req.sends+" error "+reqStatus+" happened");if(reqStatus===0||(reqStatus>=400&&reqStatus<600)||reqStatus>=12000){this._hitError(reqStatus);if(reqStatus>=400&&reqStatus<500){this._changeConnectStatus(Strophe.Status.DISCONNECTING,null);this._doDisconnect();}}}
  1863. if(!((reqStatus>0&&reqStatus<10000)||req.sends>5)){this._throttledRequestHandler();}}},_hitError:function(reqStatus)
  1864. {this.errors++;Strophe.warn("request errored, status: "+reqStatus+", number of errors: "+this.errors);if(this.errors>4){this._onDisconnectTimeout();}},_doDisconnect:function()
  1865. {Strophe.info("_doDisconnect was called");this.authenticated=false;this.disconnecting=false;this.sid=null;this.streamId=null;this.rid=Math.floor(Math.random()*4294967295);if(this.connected){this._changeConnectStatus(Strophe.Status.DISCONNECTED,null);this.connected=false;}
  1866. this.handlers=[];this.timedHandlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];},_dataRecv:function(req)
  1867. {try{var elem=req.getResponse();}catch(e){if(e!="parsererror"){throw e;}
  1868. this.disconnect("strophe-parsererror");}
  1869. if(elem===null){return;}
  1870. this.xmlInput(elem);this.rawInput(Strophe.serialize(elem));var i,hand;while(this.removeHandlers.length>0){hand=this.removeHandlers.pop();i=this.handlers.indexOf(hand);if(i>=0){this.handlers.splice(i,1);}}
  1871. while(this.addHandlers.length>0){this.handlers.push(this.addHandlers.pop());}
  1872. if(this.disconnecting&&this._requests.length===0){this.deleteTimedHandler(this._disconnectTimeout);this._disconnectTimeout=null;this._doDisconnect();return;}
  1873. var typ=elem.getAttribute("type");var cond,conflict;if(typ!==null&&typ=="terminate"){cond=elem.getAttribute("condition");conflict=elem.getElementsByTagName("conflict");if(cond!==null){if(cond=="remote-stream-error"&&conflict.length>0){cond="conflict";}
  1874. this._changeConnectStatus(Strophe.Status.CONNFAIL,cond);}else{this._changeConnectStatus(Strophe.Status.CONNFAIL,"unknown");}
  1875. this.disconnect();return;}
  1876. var self=this;Strophe.forEachChild(elem,null,function(child){var i,newList;newList=self.handlers;self.handlers=[];for(i=0;i<newList.length;i++){var hand=newList[i];if(hand.isMatch(child)&&(self.authenticated||!hand.user)){if(hand.run(child)){self.handlers.push(hand);}}else{self.handlers.push(hand);}}});},_sendTerminate:function()
  1877. {Strophe.info("_sendTerminate was called");var body=this._buildBody().attrs({type:"terminate"});if(this.authenticated){body.c('presence',{xmlns:Strophe.NS.CLIENT,type:'unavailable'});}
  1878. this.disconnecting=true;var req=new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._dataRecv.bind(this)),body.tree().getAttribute("rid"));this._requests.push(req);this._throttledRequestHandler();},_connect_cb:function(req)
  1879. {Strophe.info("_connect_cb was called");this.connected=true;var bodyWrap=req.getResponse();if(!bodyWrap){return;}
  1880. this.xmlInput(bodyWrap);this.rawInput(Strophe.serialize(bodyWrap));var typ=bodyWrap.getAttribute("type");var cond,conflict;if(typ!==null&&typ=="terminate"){cond=bodyWrap.getAttribute("condition");conflict=bodyWrap.getElementsByTagName("conflict");if(cond!==null){if(cond=="remote-stream-error"&&conflict.length>0){cond="conflict";}
  1881. this._changeConnectStatus(Strophe.Status.CONNFAIL,cond);}else{this._changeConnectStatus(Strophe.Status.CONNFAIL,"unknown");}
  1882. return;}
  1883. if(!this.sid){this.sid=bodyWrap.getAttribute("sid");}
  1884. if(!this.stream_id){this.stream_id=bodyWrap.getAttribute("authid");}
  1885. var wind=bodyWrap.getAttribute('requests');if(wind){this.window=parseInt(wind,10);}
  1886. var hold=bodyWrap.getAttribute('hold');if(hold){this.hold=parseInt(hold,10);}
  1887. var wait=bodyWrap.getAttribute('wait');if(wait){this.wait=parseInt(wait,10);}
  1888. var do_sasl_plain=false;var do_sasl_digest_md5=false;var do_sasl_anonymous=false;var mechanisms=bodyWrap.getElementsByTagName("mechanism");var i,mech,auth_str,hashed_auth_str;if(mechanisms.length>0){for(i=0;i<mechanisms.length;i++){mech=Strophe.getText(mechanisms[i]);if(mech=='DIGEST-MD5'){do_sasl_digest_md5=true;}else if(mech=='PLAIN'){do_sasl_plain=true;}else if(mech=='ANONYMOUS'){do_sasl_anonymous=true;}}}else{var body=this._buildBody();this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._connect_cb.bind(this)),body.tree().getAttribute("rid")));this._throttledRequestHandler();return;}
  1889. if(Strophe.getNodeFromJid(this.jid)===null&&do_sasl_anonymous){this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build("auth",{xmlns:Strophe.NS.SASL,mechanism:"ANONYMOUS"}).tree());}else if(Strophe.getNodeFromJid(this.jid)===null){this._changeConnectStatus(Strophe.Status.CONNFAIL,'x-strophe-bad-non-anon-jid');this.disconnect();}else if(do_sasl_digest_md5){this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge1_cb.bind(this),null,"challenge",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build("auth",{xmlns:Strophe.NS.SASL,mechanism:"DIGEST-MD5"}).tree());}else if(do_sasl_plain){auth_str=Strophe.getBareJidFromJid(this.jid);auth_str=auth_str+"\u0000";auth_str=auth_str+Strophe.getNodeFromJid(this.jid);auth_str=auth_str+"\u0000";auth_str=auth_str+this.pass;this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);hashed_auth_str=Base64.encode(auth_str);this.send($build("auth",{xmlns:Strophe.NS.SASL,mechanism:"PLAIN"}).t(hashed_auth_str).tree());}else{this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._addSysHandler(this._auth1_cb.bind(this),null,null,null,"_auth_1");this.send($iq({type:"get",to:this.domain,id:"_auth_1"}).c("query",{xmlns:Strophe.NS.AUTH}).c("username",{}).t(Strophe.getNodeFromJid(this.jid)).tree());}},_sasl_challenge1_cb:function(elem)
  1890. {var attribMatch=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/;var challenge=Base64.decode(Strophe.getText(elem));var cnonce=MD5.hexdigest(Math.random()*1234567890);var realm="";var host=null;var nonce="";var qop="";var matches;this.deleteHandler(this._sasl_failure_handler);while(challenge.match(attribMatch)){matches=challenge.match(attribMatch);challenge=challenge.replace(matches[0],"");matches[2]=matches[2].replace(/^"(.+)"$/,"$1");switch(matches[1]){case"realm":realm=matches[2];break;case"nonce":nonce=matches[2];break;case"qop":qop=matches[2];break;case"host":host=matches[2];break;}}
  1891. var digest_uri="xmpp/"+this.domain;if(host!==null){digest_uri=digest_uri+"/"+host;}
  1892. var A1=MD5.hash(Strophe.getNodeFromJid(this.jid)+":"+realm+":"+this.pass)+":"+nonce+":"+cnonce;var A2='AUTHENTICATE:'+digest_uri;var responseText="";responseText+='username='+
  1893. this._quote(Strophe.getNodeFromJid(this.jid))+',';responseText+='realm='+this._quote(realm)+',';responseText+='nonce='+this._quote(nonce)+',';responseText+='cnonce='+this._quote(cnonce)+',';responseText+='nc="00000001",';responseText+='qop="auth",';responseText+='digest-uri='+this._quote(digest_uri)+',';responseText+='response='+this._quote(MD5.hexdigest(MD5.hexdigest(A1)+":"+
  1894. nonce+":00000001:"+
  1895. cnonce+":auth:"+
  1896. MD5.hexdigest(A2)))+',';responseText+='charset="utf-8"';this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge2_cb.bind(this),null,"challenge",null,null);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build('response',{xmlns:Strophe.NS.SASL}).t(Base64.encode(responseText)).tree());return false;},_quote:function(str)
  1897. {return'"'+str.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"';},_sasl_challenge2_cb:function(elem)
  1898. {this.deleteHandler(this._sasl_success_handler);this.deleteHandler(this._sasl_failure_handler);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build('response',{xmlns:Strophe.NS.SASL}).tree());return false;},_auth1_cb:function(elem)
  1899. {var iq=$iq({type:"set",id:"_auth_2"}).c('query',{xmlns:Strophe.NS.AUTH}).c('username',{}).t(Strophe.getNodeFromJid(this.jid)).up().c('password').t(this.pass);if(!Strophe.getResourceFromJid(this.jid)){this.jid=Strophe.getBareJidFromJid(this.jid)+'/strophe';}
  1900. iq.up().c('resource',{}).t(Strophe.getResourceFromJid(this.jid));this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2");this.send(iq.tree());return false;},_sasl_success_cb:function(elem)
  1901. {Strophe.info("SASL authentication succeeded.");this.deleteHandler(this._sasl_failure_handler);this._sasl_failure_handler=null;if(this._sasl_challenge_handler){this.deleteHandler(this._sasl_challenge_handler);this._sasl_challenge_handler=null;}
  1902. this._addSysHandler(this._sasl_auth1_cb.bind(this),null,"stream:features",null,null);this._sendRestart();return false;},_sasl_auth1_cb:function(elem)
  1903. {var i,child;for(i=0;i<elem.childNodes.length;i++){child=elem.childNodes[i];if(child.nodeName=='bind'){this.do_bind=true;}
  1904. if(child.nodeName=='session'){this.do_session=true;}}
  1905. if(!this.do_bind){this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}else{this._addSysHandler(this._sasl_bind_cb.bind(this),null,null,null,"_bind_auth_2");var resource=Strophe.getResourceFromJid(this.jid);if(resource){this.send($iq({type:"set",id:"_bind_auth_2"}).c('bind',{xmlns:Strophe.NS.BIND}).c('resource',{}).t(resource).tree());}else{this.send($iq({type:"set",id:"_bind_auth_2"}).c('bind',{xmlns:Strophe.NS.BIND}).tree());}}
  1906. return false;},_sasl_bind_cb:function(elem)
  1907. {if(elem.getAttribute("type")=="error"){Strophe.info("SASL binding failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}
  1908. var bind=elem.getElementsByTagName("bind");var jidNode;if(bind.length>0){jidNode=bind[0].getElementsByTagName("jid");if(jidNode.length>0){this.jid=Strophe.getText(jidNode[0]);if(this.do_session){this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2");this.send($iq({type:"set",id:"_session_auth_2"}).c('session',{xmlns:Strophe.NS.SESSION}).tree());}else{this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null);}}}else{Strophe.info("SASL binding failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}},_sasl_session_cb:function(elem)
  1909. {if(elem.getAttribute("type")=="result"){this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null);}else if(elem.getAttribute("type")=="error"){Strophe.info("Session creation failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}
  1910. return false;},_sasl_failure_cb:function(elem)
  1911. {if(this._sasl_success_handler){this.deleteHandler(this._sasl_success_handler);this._sasl_success_handler=null;}
  1912. if(this._sasl_challenge_handler){this.deleteHandler(this._sasl_challenge_handler);this._sasl_challenge_handler=null;}
  1913. this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;},_auth2_cb:function(elem)
  1914. {if(elem.getAttribute("type")=="result"){this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null);}else if(elem.getAttribute("type")=="error"){this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);this.disconnect();}
  1915. return false;},_addSysTimedHandler:function(period,handler)
  1916. {var thand=new Strophe.TimedHandler(period,handler);thand.user=false;this.addTimeds.push(thand);return thand;},_addSysHandler:function(handler,ns,name,type,id)
  1917. {var hand=new Strophe.Handler(handler,ns,name,type,id);hand.user=false;this.addHandlers.push(hand);return hand;},_onDisconnectTimeout:function()
  1918. {Strophe.info("_onDisconnectTimeout was called");var req;while(this._requests.length>0){req=this._requests.pop();req.abort=true;req.xhr.abort();req.xhr.onreadystatechange=function(){};}
  1919. this._doDisconnect();return false;},_onIdle:function()
  1920. {var i,thand,since,newList;while(this.removeTimeds.length>0){thand=this.removeTimeds.pop();i=this.timedHandlers.indexOf(thand);if(i>=0){this.timedHandlers.splice(i,1);}}
  1921. while(this.addTimeds.length>0){this.timedHandlers.push(this.addTimeds.pop());}
  1922. var now=new Date().getTime();newList=[];for(i=0;i<this.timedHandlers.length;i++){thand=this.timedHandlers[i];if(this.authenticated||!thand.user){since=thand.lastCalled+thand.period;if(since-now<=0){if(thand.run()){newList.push(thand);}}else{newList.push(thand);}}}
  1923. this.timedHandlers=newList;var body,time_elapsed;if(this.authenticated&&this._requests.length===0&&this._data.length===0&&!this.disconnecting){Strophe.info("no requests during idle cycle, sending "+"blank request");this._data.push(null);}
  1924. if(this._requests.length<2&&this._data.length>0&&!this.paused){body=this._buildBody();for(i=0;i<this._data.length;i++){if(this._data[i]!==null){if(this._data[i]==="restart"){body.attrs({to:this.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":Strophe.NS.BOSH});}else{body.cnode(this._data[i]).up();}}}
  1925. delete this._data;this._data=[];this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._dataRecv.bind(this)),body.tree().getAttribute("rid")));this._processRequest(this._requests.length-1);}
  1926. if(this._requests.length>0){time_elapsed=this._requests[0].age();if(this._requests[0].dead!==null){if(this._requests[0].timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait)){this._throttledRequestHandler();}}
  1927. if(time_elapsed>Math.floor(Strophe.TIMEOUT*this.wait)){Strophe.warn("Request "+
  1928. this._requests[0].id+" timed out, over "+Math.floor(Strophe.TIMEOUT*this.wait)+" seconds since last activity");this._throttledRequestHandler();}}
  1929. clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100);}};if(callback){callback(Strophe,$build,$msg,$iq,$pres);}})(function(){window.Strophe=arguments[0];window.$build=arguments[1];window.$msg=arguments[2];window.$iq=arguments[3];window.$pres=arguments[4];});
  1930. (function($){$.fn.jscontext=function(options){var settings={html:'default',bind:'right-click',closeOnMouseLeave:false,fade:false,fadeSpeed:"normal",show:null,open:null,close:null,mouseover:null,mouseleave:null,sticky:false};var methods={initMenu:function(elm,settings){$("html").mousemove(function(e){mouse.x=e.pageX;mouse.y=e.pageY;if(element.current!=undefined&&element.moveit){element.current.css("top",(mouse.y+10)+'px');element.current.css("left",(mouse.x+10)+'px');if(settings.mouseover!=null)
  1931. settings.mouseover.call();}});$("html").click(function(){if(element.close())
  1932. methods.closeMenu(null,null);});$("html").mouseleave(function(){methods.closeMenu(null,null);});switch(settings.bind){case"right-click":$(elm).bind("contextmenu",function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  1933. settings.show.call();element.moveit=false;return false;}});break;case"click":$(elm).click(function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  1934. settings.show.call();element.moveit=false;return false;}});break;case"anyclick":$(elm).bind("contextmenu",function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  1935. settings.show.call();element.moveit=false;return false;}});$(elm).click(function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  1936. settings.show.call();element.moveit=false;return false;}});break;case"hover":$(elm).hover(function(e){var elementcurrent=$("#"+elm.id+"jscontext");if(elementcurrent.length==0){methods.openMenu(elm,settings);jscontextElm(elm);if(settings.show!=null)
  1937. settings.show.call();if(settings.sticky)
  1938. element.moveit=true;return false;}},function(e){if(settings.sticky){if(element.close())
  1939. methods.closeMenu($(element.current).attr("id"),null);}
  1940. element.moveit=false;});break;}},openMenu:function(elm,settings){methods.createMenu(elm,settings);element.current=$("#"+elm.id+"jscontext");if(settings.html instanceof Function){element.current.html(settings.html(elm));}else{element.current.html(settings.html.clone(true));}
  1941. var jscontextBtn=$(".jscontextBtn");if(settings.open!=null)
  1942. settings.open.call();if(settings.closeOnMouseLeave&&!settings.sticky){element.current.mouseleave(function(){if(element.close())
  1943. methods.closeMenu($(element.current).attr("id"),null);});}
  1944. try{var winWidth=window.innerWidth||document.documentElement.clientWidth||document.body.offsetWidth;if(mouse.x>=winWidth-element.current.width())
  1945. element.current.css("left",mouse.x-(element.current.width()-15)+"px");}
  1946. catch(e){}},createMenu:function(elm,settings){var jscontextID=elm.id+"jscontext";var afterClose=function(){var jscontextElement=document.createElement('div');jscontextElement.id=jscontextID;jscontextElement.style.position='absolute';jscontextElement.style.display='none';if(mouse.y==undefined)
  1947. mouse.y=0;if(mouse.x==undefined)
  1948. mouse.x=0;jscontextElement.style.top=(mouse.y-(settings.sticky==true?0:15))+'px';jscontextElement.style.left=(mouse.x-(settings.sticky==true?0:15))+'px';jscontextElement.style.zIndex='9999';document.body.appendChild(jscontextElement);var jscontext=$("#"+jscontextID);jscontext.addClass("jscontextContainer");if(settings.fade){jscontext.fadeIn(settings.fadeSpeed);element.fade=true;}
  1949. else{jscontext.show();element.fade=false;}}
  1950. methods.closeMenu(null,afterClose);},closeMenu:function(elmID,afterClose){var remove=function(){if(elmID){if($("#"+elmID).length>0)
  1951. document.body.removeChild(document.getElementById(elmID));}
  1952. else{$(".jscontextContainer").remove();}}
  1953. if(element.fade){if(elmID){if($("#"+elmID).length>0)
  1954. $("#"+elmID).fadeOut(settings.fadeSpeed,remove);}
  1955. else{$(".jscontextContainer").fadeOut(settings.fadeSpeed,remove);}}
  1956. else{remove.call();}
  1957. if(settings.close!=null)
  1958. settings.close.call();if(afterClose!=null)
  1959. afterClose.call();}};return this.each(function(){if(options&&typeof options==='object'){$.extend(settings,options);methods.initMenu(this,settings);}
  1960. else if(typeof options==='string'){switch(options){case"":break;}}});};})(jQuery);jscontext=function(option){switch(option){case"close":$(".jscontextContainer").remove();break;}}
  1961. jscontextElm=function(elm){jscontextObj=$(elm);}
  1962. var element={current:null,moveit:false,fade:false,close:function(){if(element.current==null)
  1963. return true;if((mouse.x<element.current.position().left+5)||(mouse.x>(element.current.position().left+element.current.width()-5))||(mouse.y<element.current.position().top+5)||(mouse.y>(element.current.position().top+element.current.height()-5)))
  1964. return true;else
  1965. return false;}};var mouse={x:null,y:null};var jscontextObj=$();(function(jQuery){jQuery.hotkeys={version:"0.8.1",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",91:"command",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":"\"",",":"<",".":">","/":"?","\\":"|"}};function keyHandler(handleObj){if(typeof handleObj.data!=="string"){return;}
  1966. var origHandler=handleObj.handler,keys=handleObj.data.toLowerCase().split(" ");var isCommandPressed=false;handleObj.handler=function(event){var special=event.type!=="keypress"&&jQuery.hotkeys.specialKeys[event.which],character=String.fromCharCode(event.which).toLowerCase(),key,modif="",possible={};if(event.altKey&&special!=="alt"){modif+="alt+";}
  1967. if(event.ctrlKey&&special!=="ctrl"){modif+="ctrl+";}
  1968. if(jQuery.hotkeys.specialKeys[event.which]==="command"){isCommandPressed=true;}
  1969. if(event.metaKey&&!event.ctrlKey&&special!=="meta"&&special!=="command"){if(isCommandPressed){modif+="command+";}else{modif+="meta+";}}
  1970. if(event.shiftKey&&special!=="shift"){modif+="shift+";}
  1971. if(special){possible[modif+special]=true;}else{possible[modif+character]=true;possible[modif+jQuery.hotkeys.shiftNums[character]]=true;if(modif==="shift+"){possible[jQuery.hotkeys.shiftNums[character]]=true;}}
  1972. for(var i=0,l=keys.length;i<l;i++){if(possible[keys[i]]){isCommandPressed=false;return origHandler.apply(this,arguments);}}};}
  1973. jQuery.each(["keydown","keyup","keypress"],function(){jQuery.event.special[this]={add:keyHandler};});})(jQuery);(function($){$.fn.defchat=function(options){var settings={'domain':'localhost','username':null,'password':null,'my_username':'','textinput':this.find('input.text'),'form':this.find('form.chat-form'),'chatlist':this.find('.chat-list'),'userslist':this.find('.users-list'),'buttons':this.find('ul.buttons'),'submitbutton':this.find('.send_message_button'),'usercount':this.find('.usercount'),'subject':'','room':'mymucroom@conference.localhost','private_room':'mymucroom@conference.localhost','throttlechat':false,'throttle_message':null,'translate_message_url':null,'add_moderator_url':null,'media_url':'','ban_url':null,'silence_url':null,'is_broadcasting':false,'allow_tipping':true,'domroot':this,'font_color':'#494949','chat_font':'default','current_subject':'','login_required_callback':null,'submenu_profile_url':null,'emoticon_overlay_url':null,'tipping_current_tokens_url':null,'welcome_message':null,'welcome_warning':null,'first_post_warning':null,'parse_subject':null,'color_choices':['default','Arial, Helvetica','Bookman Old Style','"Comic Sans MS", cursive','"Courier New"','Lucida','Palantino',"Tahoma, Geneva",'"Times New Roman"'],'font_color_cookie_name':'settings_font_color','chat_font_cookie_name':'settings_chat_font','interested_in':[],'group_show_tokens_per_minute_url':null,'group_show_request_url':null,'group_show_decline_url':null,'group_show_cancel_url':null,'return_from_away_url':null,'private_show_tokens_per_minute_url':null,'private_show_request_url':null,'private_show_approve_url':null,'private_show_decline_url':null,'private_show_cancel_url':null,'scroll_on_load':true,'room_goal':{}};if(options){$.extend(settings,options);}
  1974. if(settings.is_broadcasting){settings.font_color_cookie_name='broadcast_settings_font_color';settings.chat_font_cookie_name='broadcast_settings_chat_font';}
  1975. if($.cookie(settings.font_color_cookie_name)){settings.font_color=$.cookie(settings.font_color_cookie_name);}
  1976. if($.cookie(settings.chat_font_cookie_name)){settings.chat_font=$.cookie(settings.chat_font_cookie_name);}
  1977. var default_subject=$.cookie('my_room_subject');if(!default_subject){default_subject=Strophe.getNodeFromJid(settings.room)+"'s room";}
  1978. $.extend(settings,{'user':settings.username+'@'+settings.domain,'muc_nickname':settings.username,'default_subject':default_subject,'bosh_host':'http://'+settings.domain+':5280/http-bind','roomownernick':Strophe.getNodeFromJid(settings.room),'roomowner':Strophe.getNodeFromJid(settings.room)+"@"+settings.domain});if(options){$.extend(settings,options);}
  1979. var conn=new Strophe.Connection(settings.bosh_host);function consolelog(msg){}
  1980. function get_contextual_menu_html(domele){var h=$("<div class='jscontextMenu'></div>");var nick=$(domele).data('nick');var jid=presence_monitor.participants[nick].jid;var account_name=Strophe.getNodeFromJid(jid);function add_link(cls,text,callback){var line=$("<p class='jscontextBtn "+cls+"' data-nick='"+nick+"'>"+text+"</p>");line.click(function(){jscontext('close')});line.click(callback);h.append(line);}
  1981. h.append("<p class=\"jscontextLabel\"><img src=\""+settings.media_url+"images/red-arrow-down.gif\" width=\"9\" height=\"5\" alt=\"\" />"+nick+"</p><hr>");h.append("<div class=\"submenu_profile\"></div><hr>");add_link("pm",gettext("Send private message"),function(){if(!features_unlocked()){unlock_features_required();return;}
  1982. tabs.open_pm(nick);});if(message_receiver.ignored_users.indexOf(jid)!==-1){add_link("ignore",gettext("Un-Ignore This User"),function(event){var ignorenick=$(event.target).data('nick');var ignorejid=presence_monitor.participants[ignorenick].jid;message_receiver.ignored_users=$.grep(message_receiver.ignored_users,function(a){return(a!=ignorejid);});var msg=interpolate(gettext("no longer ignoring %(username)s"),{username:ignorenick},true);add_system_message(msg,tabs.get_current_tab_domele());$('#ignored-list').find("[data-nick='"+ignorenick+"']").parent().remove();tabs._sort_ignored_users_list();ignored_user_methods.store_ignored_users();});}else{add_link("ignore",gettext("Ignore This User"),function(event){var ignorenick=$(event.target).data('nick');message_receiver.ignored_users.push(presence_monitor.participants[ignorenick].jid);var msg=interpolate(gettext("ignoring %(username)s"),{username:ignorenick},true);add_system_message(msg,tabs.get_current_tab_domele());var html="<li>"+ignorenick;html+=" (<a href='#' data-nick='"+presence_monitor.participants[ignorenick].jid;html+="' class='un-ignore'>"+gettext('Un-ignore')+"</a>)</li>";$('#ignored-list').append(html);tabs._sort_ignored_users_list();ignored_user_methods.store_ignored_users();});}
  1983. h.append("<hr>");if(presence_monitor.participants[settings.muc_nickname].role=='moderator'){add_link("",gettext("Silence for 24 hours"),function(event){var bannick=$(event.target).data('nick');var jid=presence_monitor.participants[bannick].jid;var msg=interpolate(gettext("Silence %(username)s?"),{username:bannick},true);if(confirm(msg)){msg=interpolate(gettext("Silencing %(username)s"),{username:bannick},true);add_system_message(msg,tabs.get_current_tab_domele());var account_name=Strophe.getNodeFromJid(jid);var url=settings.silence_url.replace('USERNAMESLUG',account_name);$.post(url,{'foo':'bar'});}});if(presence_monitor.participants[settings.muc_nickname].jid===settings.roomowner){add_link("",gettext("Kick/Ban"),function(event){var bannick=$(event.target).data('nick');var jid=presence_monitor.participants[bannick].jid;var msg=interpolate(gettext("Ban %(username)s?"),{username:bannick},true);if(confirm(msg)){msg=interpolate(gettext("Kicking and banning %(username)s"),{username:bannick},true);add_system_message(msg,tabs.get_current_tab_domele());var iq=$iq({to:settings.room,type:'set'}).c('query',{'xmlns':'http://jabber.org/protocol/muc#admin'}).c('item',{'affiliation':'outcast','jid':jid});consolelog(iq);conn.sendIQ(iq);var account_name=Strophe.getNodeFromJid(jid);var url=settings.ban_url.replace('USERNAMESLUG',account_name);$.post(url,{'foo':'bar'});}});if(presence_monitor.participants[nick].role!='moderator'){add_link("",gettext("Promote to Moderator"),function(event){var nick=$(event.target).data('nick');var msg=interpolate("granting moderator privileges to %(username)s",{username:nick},true);message_sender._send(msg);var iq=$iq({to:settings.room,type:'set'}).c('query',{'xmlns':'http://jabber.org/protocol/muc#admin'}).c('item',{'role':'moderator','nick':nick});consolelog(iq);conn.sendIQ(iq);var url=settings.add_moderator_url.replace('USERNAMESLUG',account_name);$.post(url,{'foo':'bar'});moderators[presence_monitor.participants[nick].jid]=true;});}else{add_link("",gettext("Remove Moderator Status"),function(event){var nick=$(event.target).data('nick');var msg=interpolate(gettext("revoking moderator privileges from %(username)s"),{username:nick},true);add_system_message(msg,tabs.get_current_tab_domele());var iq=$iq({to:settings.room,type:'set'}).c('query',{'xmlns':'http://jabber.org/protocol/muc#admin'}).c('item',{'role':'participant','nick':nick});consolelog(iq);conn.sendIQ(iq);delete moderators[presence_monitor.participants[nick].jid];});}}}
  1984. var url=settings.submenu_profile_url.replace('USERNAMESLUG',account_name);consolelog("Loading menu from "+url);h.find(".submenu_profile").load(url);return h;}
  1985. function add_system_message(message,domele){message_receiver.add_message('<div class="text"><p>'+message+'</p></div>',domele);}
  1986. function insert_user(newhtml,nick,token_balance){var sort_key=$("select[name='sort']").val();if(sort_key==undefined){if($.cookie('room_sort_by')==undefined)
  1987. sort_key='a';else{sort_key=$.cookie('room_sort_by');}}
  1988. if(!settings.is_broadcasting){sort_key='a';}
  1989. var inserted=false;settings.userslist.find("div.text").each(function(index,domEle){var $domEle=$(domEle);var domnick=String($domEle.data('nick'));if(sort_key=='a'){new_val=nick.replace('__anonymous__','zzzz');current_val=domnick.replace('__anonymous__','zzzz');}
  1990. else{new_val=parseInt(token_balance);current_val=parseInt($domEle.data('tokenbalance'));}
  1991. if((sort_key=='a')&&(new_val<current_val)){$domEle.before(newhtml);inserted=true;return false;}
  1992. if((sort_key=='t')&&(new_val>current_val)){$domEle.before(newhtml);inserted=true;return false;}});if(!inserted){settings.userslist.append(newhtml);}}
  1993. function userjoined(event,nick,token_balance){token_balance=parseInt(token_balance);if(isNaN(token_balance)){token_balance=0;}
  1994. if(nick.indexOf('__anonymous__')!=-1){token_balance=-1;}
  1995. var color='color-3';if(settings.is_broadcasting){if(token_balance<1){color='color-3';}else{color='color-4';}}
  1996. var msg=interpolate(gettext("<span class='username "+color+"' data-nick='%(username)s'"+">%(username)s</span> joined"),{username:nick},true);if(initializer.joined&&(new Date()-initializer.joined_at>10*1000)){if(presence_monitor.num_participants<5){add_system_message(msg);}else{if(settings.is_broadcasting&token_balance>=1){add_system_message(msg);}}}
  1997. if(tabs.pm_tab_map[nick]){add_system_message(msg,tabs.pm_tab_map[nick]);}
  1998. var newhtml=$("<div class='text' data-nick='"+nick+"' data-tokenbalance='"+token_balance+"'><strong class='"+
  1999. color+"'>"+nick+"</strong></div>");if(nick!=settings.muc_nickname){newhtml.jscontext({html:get_contextual_menu_html,bind:'anyclick'});}
  2000. return insert_user(newhtml,nick,token_balance);}
  2001. $(document).bind("userjoined.defchat",userjoined);function update_participants_count(){settings.usercount.text(presence_monitor.num_participants);}
  2002. setInterval(update_participants_count,2000);function yield_ownership(event,nick,token_balance){if(nick!=settings.roomownernick){return;}
  2003. if(presence_monitor.participants[settings.muc_nickname]){if(presence_monitor.participants[settings.muc_nickname].role!='moderator'){return;}}
  2004. var iq=$iq({'to':settings.room,'type':'set'}).c('query',{xmlns:'http://jabber.org/protocol/muc#admin'}).c('item',{affiliation:'owner',jid:settings.roomowner});consolelog(iq.toString());conn.sendIQ(iq);}
  2005. $(document).bind("userjoined.defchat",yield_ownership);var public_methods={_set_font_size:function(){if($.cookie('room_font_size')){var size=$.cookie('room_font_size');}
  2006. else{var size='9pt';}
  2007. $("div.chat-list").css("font-size",size);},join_group_show:function(){groups_and_privates.start_group_show_clicked();},change_title:function(title){if(title==settings.current_subject){return;}
  2008. $.cookie('my_room_subject',title,{expires:365});conn.send($msg({to:settings.room,type:'groupchat'}).c('subject').t(title));},select_emoticon:function(emoticon){settings.textinput.val(settings.textinput.val()+" "+emoticon);settings.textinput.focus();},is_goal_set:function(){return settings.room_goal.hasOwnProperty('amount');}};var ignored_user_methods={store_ignored_users:function(){var ignored_str="";for(var i=0;i<message_receiver.ignored_users.length;i++){ignored_str+="#"+message_receiver.ignored_users[i];}
  2009. $.cookie('ignored_users',ignored_str,{expires:30,path:'/'});},load_ignored_users:function(){var ignored_str=$.cookie('ignored_users');if(ignored_str==null)
  2010. return;var ignored_array=ignored_str.split('#');for(var i=0;i<ignored_array.length;i++){if(ignored_array[i]!=''){message_receiver.ignored_users.push(ignored_array[i]);}}}};function reassign_moderator(event,nick,token_balance){if(presence_monitor.participants[settings.muc_nickname]){if(presence_monitor.participants[settings.muc_nickname].role!='moderator'){return;}}
  2011. if(!moderators[presence_monitor.participants[nick].jid]){return;}
  2012. var iq=$iq({to:settings.room,type:'set'}).c('query',{'xmlns':'http://jabber.org/protocol/muc#admin'}).c('item',{'role':'moderator','nick':nick});consolelog(iq.toString());conn.sendIQ(iq);}
  2013. $(document).bind("userjoined.defchat",reassign_moderator);function remove_user_from_list(nick){settings.userslist.find("[data-nick='"+nick+"']").remove();}
  2014. function userleft(event,nick){var msg=interpolate(gettext("%(username)s has disconnected"),{username:nick},true);if(presence_monitor.num_participants<5){add_system_message(msg);}
  2015. if(tabs.pm_tab_map[nick]){add_system_message(msg,tabs.pm_tab_map[nick]);}
  2016. remove_user_from_list(nick);}
  2017. $(document).bind("userleft.defchat",userleft);$(document).bind("disconnected.defchat",function(){add_system_message(gettext("chat disconnected"));});$(document).bind("connectionfailed.defchat",function(){add_system_message(gettext("unable to connect"));});$(document).bind("connecting.defchat",function(){add_system_message(gettext("connecting"));});function connected(){add_system_message(gettext("connection established"));conn.send($pres().c('priority').t('-1'));initializer.join_room();if(settings.welcome_message){add_system_message(settings.welcome_message);}
  2018. if(settings.welcome_warning){add_system_message(settings.welcome_warning);}
  2019. $(window).unload(function(){conn.sync=true;var msg=$pres({to:settings.room,type:'unavailable'});conn.send(msg);conn.disconnect();conn.flush();});}
  2020. $(document).bind("connected.defchat",connected);var tabs={pm_tab_visible:false,current_tab:'chat',pm_tab:null,pm_tab_map:{},settings_body:null,unread_pm_map:{},total_unread_pms:0,current_pm_nick:null,opened_pms:new Array(),is_blinking:false,open_pm:function(nick){tabs._show_pm_tab();tabs._remove_unread_pms_for_nick(nick);settings.domroot.find('> div').hide();tabs.get_or_create_pm_tab_for_nick(nick,false).show();tabs.current_tab='pm';tabs.current_pm_nick=nick;tabs._enable_form();settings.textinput.focus();tabs._scroll_to_bottom();},close_pm:function(nick){tabs._show_pm_tab();tabs._remove_unread_pms_for_nick(nick);settings.domroot.find('> div').hide();tabs.pm_tab_map[nick].remove();tabs.pm_tab_map[nick]=null;tabs._show_chat_tab();var newopens=new Array();for(var i=0;i<tabs.opened_pms.length;i++){if(tabs.opened_pms[i]!=nick){newopens.push(tabs.opened_pms[i]);}}
  2021. tabs.opened_pms=newopens;},on_tab_click:function(){var tab=$(this).data("tab");settings.domroot.find('> div').hide();if(tab=='users'){tabs._deactivate_tabs();$(this).closest('li').addClass('active');settings.domroot.find('> div.users-list').show();tabs.current_tab='users';tabs._disable_form();}else if(tab=='chat'){tabs._show_chat_tab();}else if(tab=='settings'){tabs._show_settings_tab();tabs._disable_form();}else{consolelog("Unknown tab "+tab);}
  2022. return false;},get_or_create_pm_tab_for_nick:function(nick,show_alert){if(tabs.pm_tab_map[nick]){return tabs.pm_tab_map[nick];}
  2023. if(show_alert){var msg=interpolate(gettext("New private conversation from <span class='username' data-nick='%(username)s'>%(username)s</span> <span class='pmalert'>(click the PM tab)</span>"),{username:nick},true);add_system_message(msg);}
  2024. tabs.opened_pms.push(nick);tabs.opened_pms.sort();tabs._create_pm_tab();if(tabs.opened_pms.length>1){tabs._set_pm_tab_jscontext();}else{tabs._set_pm_tab_direct(nick);}
  2025. tabs.pm_tab_map[nick]=$("<div class='chat-list' style='display: none;'></div>");settings.domroot.find('> div').last().after(tabs.pm_tab_map[nick]);msg=interpolate(gettext("Private conversation with %(username)s"),{username:nick},true);add_system_message(msg,tabs.pm_tab_map[nick]);return tabs.pm_tab_map[nick];},private_message_received:function(nick){if(tabs.current_tab==='pm'&&tabs.current_pm_nick==nick){return;}
  2026. if(tabs.unread_pm_map[nick]){tabs.unread_pm_map[nick]+=1;}else{tabs.unread_pm_map[nick]=1;}
  2027. tabs.total_unread_pms+=1;tabs._refresh_pm_tab_count();if(!tabs.pm_tab.hasClass('active')){if(!tabs.is_blinking){tabs._blink_pm(6,250);}}},_blink_pm:function(numblinks,timeout){if(tabs.current_tab==='pm'){tabs.is_blinking=false;return;}
  2028. if(numblinks==0){tabs.pm_tab.removeClass('active');tabs.is_blinking=false;return;}
  2029. if(!tabs.pm_tab.hasClass('active')){tabs.pm_tab.addClass('active');}else{tabs.pm_tab.removeClass('active');}
  2030. tabs.is_blinking=true;setTimeout(function(){tabs._blink_pm(numblinks-1,timeout);},timeout);},get_current_tab_domele:function(){var r=settings.domroot.find('> div.chat-list:visible');if(r.length===0){return settings.chatlist;}else{return r;}},_show_chat_tab:function(){tabs._deactivate_tabs();settings.buttons.find('li:first').addClass('active');settings.domroot.find('> div').hide();settings.domroot.find('> div.chat-list:first').show();tabs.current_tab='chat';tabs._enable_form();settings.textinput.focus();tabs._scroll_to_bottom();},_scroll_to_bottom:function(){var chat=tabs.get_current_tab_domele().get(0);chat.scrollTop=chat.scrollHeight;},_disable_form:function(){settings.textinput.blur();settings.textinput.focus(function(event){settings.textinput.unbind(event);tabs._show_chat_tab();});},_enable_form:function(){settings.textinput.unbind('focus');},_remove_unread_pms_for_nick:function(nick){if(tabs.unread_pm_map[nick]&&tabs.unread_pm_map[nick]>0){tabs.total_unread_pms=tabs.total_unread_pms-tabs.unread_pm_map[nick];tabs.unread_pm_map[nick]=0;tabs._refresh_pm_tab_count();}},_refresh_pm_tab_count:function(){var str;if(tabs.total_unread_pms==0){str="";}else{str="("+tabs.total_unread_pms+")";}
  2031. tabs.pm_tab.find('.pm_count').text(str);},_create_pm_tab:function(){if(!tabs.pm_tab_visible){tabs.pm_tab_visible=true;tabs.pm_tab=$("<li><a href='#' data-tab='pm'>"+"PM <span class='pm_count'></span></a></li>");settings.buttons.find('li:last').before(tabs.pm_tab);}},_set_pm_tab_direct:function(nick){tabs.pm_tab.unbind('click');tabs.pm_tab.bind('click',function(){tabs.open_pm(nick);return false;});},_set_pm_tab_jscontext:function(){tabs.pm_tab.unbind('click');tabs.pm_tab.jscontext({html:function(){var h=$("<div class='jscontextMenu'></div>");function add_link(nick,text,callback){var line=$("<div class=\"pmline\"><div class=\"user\" data-nick='"+nick+"'>"+text+"</div><div class=\"close\" data-nick='"+nick+"'></div></div>");line.find("div.user").click(callback);line.find("div.user").click(function(){jscontext('close');});line.find("div.close").click(function(event){tabs.close_pm($(event.target).data('nick'));jscontext('close');});h.append(line);}
  2032. h.append("<p class=\"jscontextLabel\"><img src=\""+settings.media_url+"images/orange-arrow-down.gif\" width=\"9\" height=\"5\" alt=\"\" />Private Message with:</p><hr>");for(var i=0;i<tabs.opened_pms.length;i++){var nick=tabs.opened_pms[i];var unread=tabs.unread_pm_map[nick];if(unread&&unread>0){unread=" ("+unread+")";}else{unread="";}
  2033. add_link(nick,nick+unread,function(event){var nick=$(event.target).data('nick');tabs.open_pm(nick);});}
  2034. return h;},bind:"click"});},_deactivate_tabs:function(){settings.buttons.find('li').removeClass('active');},_show_pm_tab:function(){tabs._deactivate_tabs();tabs._create_pm_tab();tabs.pm_tab.addClass('active');},_sort_ignored_users_list:function(){if($("ul#ignored-list li").size()==0){$("ul#ignored-list").hide();$("h3#ignored-title").hide();return;}
  2035. $("ul#ignored-list").show();$("#ignored-title").show();var list=$("ul#ignored-list");var listitems=list.children("li").get();listitems.sort(function(a,b){var compA=$(a).text().toUpperCase();var compB=$(b).text().toUpperCase();return(compA<compB)?-1:(compA>compB)?1:0;});$.each(listitems,function(idx,itm){list.append(itm);});},_sort_users_list:function(){var sort_key=$("select[name='sort']").val();if(sort_key==undefined){if($.cookie('room_sort_by')==undefined)
  2036. sort_key='a';else{sort_key=$.cookie('room_sort_by');}}
  2037. if(!settings.is_broadcasting){sort_key='a';}
  2038. if(sort_key=='a'){var mylist=$('div.users-list');var listitems=mylist.children('div.text').get();listitems.sort(function(a,b){var compA=String($(a).data("nick"));compA=compA.replace('__anonymous__','zzzz');var compB=String($(b).data("nick"));compB=compB.replace('__anonymous__','zzzz');return(compA<compB)?-1:(compA>compB)?1:0;})
  2039. $.each(listitems,function(idx,itm){mylist.append(itm);})}
  2040. else{var mylist=$('div.users-list');var listitems=mylist.children('div.text').get();listitems.sort(function(a,b){var compA=parseInt($(a).data("tokenbalance"));var compB=parseInt($(b).data("tokenbalance"));return(compA<compB)?1:(compA>compB)?-1:0;})
  2041. $.each(listitems,function(idx,itm){mylist.append(itm);})}},_get_font_change:function(){var html="<br/><form>";html+="<label>"+gettext('Change Font Size')+": </label>";html+=" <select id='font-change' name='font-change'>";for(var i=9;i<=20;i++){html+="<option value='"+i+"pt'>"+i+"pt</option>"}
  2042. html+="</select></form>";$("#font-change").live("change",function(){$("div.chat-list").css("font-size",$(this).val());$.cookie('room_font_size',$(this).val(),{expires:365,path:'/'});});return html;},_get_show_emoticons_stored_value:function(){if($.cookie('show_emoticon_icons')=='yes'){return true;}
  2043. if($.cookie('show_emoticon_icons')=='no'){return false;}
  2044. return true;},_store_emoticons_value:function(val){$.cookie('show_emoticon_icons',val,{expires:365,path:'/'});},_get_emoticons_display:function(){var html="<form><label>"+gettext("Show Emoticons")+": </label>";html+="<select id='show-emoticons' name='show-emoticons'>";html+="<option value='yes'";if(tabs._get_show_emoticons_stored_value()){html+=" selected='selected' ";}
  2045. html+=">"+gettext("Yes")+"</option><option value='no'";if(!tabs._get_show_emoticons_stored_value()){html+=" selected='selected' ";}
  2046. html+=">"+gettext("No")+"</option></select></form>"
  2047. $("#show-emoticons").live("change",function(){tabs._store_emoticons_value($(this).val());});return html;},_should_show_emoticon:function(){if($("#show-emoticons").length){return $("#show-emoticons").val()=="yes";}
  2048. return tabs._get_show_emoticons_stored_value();},_set_default_font_change_value:function(){var size='9pt';if($.cookie('room_font_size')){size=$.cookie('room_font_size');}
  2049. $("#font-change option[value='"+size+"']").attr("selected","selected");},_show_settings_tab:function(){tabs.current_tab='settings';settings.domroot.find('> div').hide();if(!tabs.settings_body){var html="<div class='settings-list'><form>"+"<div class='exampletext'>"+gettext("Your chat messages will look like this.")+"</div>"+"<div><br/><label>"+gettext("Chat font")+":</label> <select name='chatfont'></select></div>"+"<div><br/><label>"+gettext("Chat color")+":</label> <input type='color' id='settingscolor' name='color' value='"+settings.font_color+"' data-hex='true' data-text='hidden' style='height:20px;width:20px;'></div>"+"</form><h3 id='ignored-title'>"+gettext('Ignored users')+"</h3><ul id='ignored-list'>";for(var i=0;i<message_receiver.ignored_users.length;i++){var nick=message_receiver.ignored_users[i].split('@')[0];html+="<li>"+nick;html+=" (<a href='#' data-nick='"+message_receiver.ignored_users[i];html+="' class='un-ignore'>"+gettext('Un-ignore')+"</a>)</li>";}
  2050. html+="</ul>";html+=tabs._get_font_change();html+=tabs._get_emoticons_display();if(settings.is_broadcasting){html+='<form><br/><label>'+gettext("Sort users")+":</label> "+'<select name="sort"><option value="a"';if(($.cookie('room_sort_by')=='a')||($.cookie('room_sort_by')==undefined)){html+=' selected="selected" '}
  2051. html+='>'+
  2052. gettext('Alphabetically')+'</option>'+'<option value="t"';if($.cookie('room_sort_by')=='t'){html+=' selected="selected" '}
  2053. html+='>'+gettext('By Tokens')+'</option>'+'</select></form>';$("select[name='sort']").live("change",function(){$.cookie('room_sort_by',$(this).val(),{expires:365,path:'/'});tabs._sort_users_list();});html+="<br/><br/><a href='#' class='clear_all_banned_ips'>"+
  2054. gettext('Clear All Banned IPs')+"</a>"+"<span style='display:none' class='ban_result'>"+
  2055. gettext('Banned IPs cleared...')+"</span>";}
  2056. html+="</div>";tabs.settings_body=$(html);$("#ignored-list li a").live("click",function(){var uname=$(this).data("nick");$(this).parent().remove();message_receiver.ignored_users=$.grep(message_receiver.ignored_users,function(a){return(a!=uname);});uname=uname.split('@')[0];var msg=interpolate(gettext("no longer ignoring %(username)s"),{username:uname},true);add_system_message(msg,tabs.get_current_tab_domele());ignored_user_methods.store_ignored_users();tabs._sort_ignored_users_list();return false;});$.each(settings.color_choices,function(index,value){tabs.settings_body.find('select[name="chatfont"]').append("<option>"+value+"</option>");});tabs.settings_body.find('select[name="chatfont"]').val(settings.chat_font);settings.domroot.find('> div').last().after(tabs.settings_body);consolelog($("#settingscolor"));$('#settingscolor').mColorPicker();$('#settingscolor').bind('colorpicked',function(){if(!features_unlocked()){unlock_features_required();$('#settingscolor').val('#494949');$('#icp_settingscolor').css('background-color','#494949');}
  2057. settings.font_color=$(this).val();tabs.settings_body.find('.exampletext').css('color',settings.font_color);$.cookie(settings.font_color_cookie_name,settings.font_color,{expires:365,path:'/'});});tabs.settings_body.find('select[name="chatfont"]').change(function(){if(!features_unlocked()){tabs.settings_body.find('select[name="chatfont"]').val('default');unlock_features_required();return;}
  2058. settings.chat_font=$(this).val();if(settings.chat_font==='default'){tabs.settings_body.find('.exampletext').css('font-family','');}else{tabs.settings_body.find('.exampletext').css('font-family',settings.chat_font);}
  2059. $.cookie(settings.chat_font_cookie_name,settings.chat_font,{expires:365,path:'/'});});}
  2060. tabs.settings_body.show();tabs._sort_ignored_users_list();tabs._deactivate_tabs();settings.buttons.find('a[data-tab="settings"]').parent().addClass('active');tabs._set_default_font_change_value();}};settings.buttons.find('a').click(tabs.on_tab_click);var initializer={attempts:0,joined:false,joined_at:null,is_on_private_room:false,base_room_name:settings.room,retry_join_room:function(){if(this.attempts>0){settings.muc_nickname+='_';}
  2061. if(this.attempts>=5){consolelog("Too many failed attempts, disconnecting");conn.disconnect();}
  2062. return this.join_room();},join_room:function(){this.attempts+=1;consolelog("Joining "+settings.room+" with "+settings.muc_nickname);var pres=$pres({to:settings.room+"/"+settings.muc_nickname,token_balance:settings.token_balance}).c('x',{xmlns:"http://jabber.org/protocol/muc"});if(initializer.is_on_private_room){pres=pres.c('history',{'maxchars':'0'});}
  2063. conn.send(pres);},change_to_private_room:function(){if(initializer.is_on_private_room){return;}
  2064. message_receiver.ignore_delayed=true;initializer.leave_room();initializer.attempts=4;initializer.is_on_private_room=true;settings.room=settings.private_room;presence_monitor.reset();initializer.join_room();},leave_private_room:function(){if(!initializer.is_on_private_room){return;}
  2065. initializer.leave_room();initializer.attempts=4;initializer.is_on_private_room=false;settings.room=initializer.base_room_name;presence_monitor.reset();initializer.join_room();},leave_room:function(){conn.send($pres({to:settings.room+"/"+settings.muc_nickname,type:'unavailable'}).c('x',{xmlns:"http://jabber.org/protocol/muc"}));},on_disconnect:function(){initializer.joined=false;},on_received_my_presence:function(){initializer.joined=true;initializer.joined_at=new Date();if(!presence_monitor.participants[settings.muc_nickname]){return true;}
  2066. if(presence_monitor.participants[settings.muc_nickname].role!='moderator'){return true;}
  2067. if(settings.current_subject===""&!public_methods.is_goal_set()){conn.send($msg({to:settings.room,type:'groupchat'}).c('subject').t(settings.default_subject))}
  2068. conn.sendIQ($iq({to:settings.room,type:'get'}).c('query',{xmlns:'http://jabber.org/protocol/muc#owner'}),function(response){consolelog("Server configuration form . . .");consolelog(response);var x=$iq({to:settings.room,type:'set'}).c('query',{xmlns:'http://jabber.org/protocol/muc#owner'}).c('x',{xmlns:'jabber:x:data',type:'submit'}).c('field',{'var':'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig​').up().up().c('field',{'var':'muc#roomconfig_whois'}).c('value').t('anyone').up().up().c('field',{'var':'muc#roomconfig_maxusers'}).c('value').t('50000');consolelog("Configuring room "+x.toString());conn.sendIQ(x,function(response){consolelog("Configuration response . . .");consolelog(response);});});}};$(document).bind("disconnected.defchat",initializer.on_disconnect);var presence_monitor={participants:new Array(),num_participants:0,reset:function(){presence_monitor.participants=new Array();presence_monitor.num_participants=0;settings.userslist.html("");},user_is_present:function(nick){var present=presence_monitor.participants[nick];present=(present!==undefined&&present!==false);return present;},remove_participant:function(nick){presence_monitor.num_participants-=1;delete presence_monitor.participants[nick];},on_presence:function(presence){var from=$(presence).attr('from');var room=Strophe.getBareJidFromJid(from);if(room==settings.room){consolelog(presence);var nick=Strophe.getResourceFromJid(from);if(nick.substring(0,6)=='admin-'){return true;}
  2069. consolelog("Nick for "+from+" is "+nick);if($(presence).attr('type')==='error'&&!initializer.joined){if($(presence).find("status[code='409']")){initializer.retry_join_room();return true;}else{consolelog("Disconnecting because of error while connecting");conn.disconnect();return false;}}
  2070. if($(presence).attr('type')!=='unavailable'){var present=presence_monitor.user_is_present(nick);var extradata=$(presence).find('item');if(extradata.attr('jid')){presence_monitor.participants[nick]={'jid':Strophe.getBareJidFromJid(extradata.attr('jid')),'role':extradata.attr('role')};if(!present){presence_monitor.num_participants+=1;$(document).trigger('userjoined.defchat',[nick,$(presence).attr('token_balance')]);}}}else if(presence_monitor.user_is_present(nick)&&$(presence).attr('type')==='unavailable'){presence_monitor.remove_participant(nick);$(document).trigger('userleft.defchat',nick);}
  2071. if($(presence).attr('type')!=='error'&&!initializer.joined&&nick===settings.muc_nickname){initializer.on_received_my_presence();}}
  2072. return true;}};conn.addHandler(presence_monitor.on_presence,null,"presence");var message_receiver={ignored_users:new Array(),ignore_delayed:false,on_goalset:function($message){settings.room_goal.amount=$message.attr('amount');settings.room_goal.current=$message.attr('current');settings.room_goal.hightipper=$message.attr('hightipper');settings.room_goal.hightipper_amount=$message.attr('hightipper_amount');settings.room_goal.lasttipper=$message.attr('lasttipper');settings.room_goal.lasttipper_amount=$message.attr('lasttipper_amount');if(settings.room_goal.lasttipper==""){settings.room_goal.lasttipper="--";settings.room_goal.hightipper="--";}
  2073. tipping_goal.enable_goal();},on_message:function(message){consolelog(message);var $message=$(message);var subtype=$message.attr('subtype');var delayed=false;if($message.children('delay').length!=0){delayed=true;}
  2074. if(message_receiver.ignore_delayed&delayed){return true;}
  2075. if(subtype=='roomalert'){if(!delayed){message_receiver.on_roomalert($message);}
  2076. return true;}else if(subtype=='goalset'){if(!delayed){message_receiver.on_goalset($message);}
  2077. return true;}else if(subtype=='goalcancel'){if(!delayed){tipping_goal.disable_goal();}
  2078. return true;}else if(subtype=='goalreached'){if(!delayed){message_receiver.on_goalreached();}}else if(subtype=='tipalert'){message_receiver.on_tipalert($message);return true;}else if(subtype=='messagechangerequest'){if(!delayed){message_receiver.on_messagechangerequest($message);}
  2079. return true;}else if(subtype=='settingsupdate'){if(!delayed){message_receiver.on_settingsupdate($message);}
  2080. return true;}else if(subtype=='groupshowrequest'){if(!delayed){groups_and_privates.on_groupshowrequest_message($message);}
  2081. return true;}else if(subtype=='privateshowrequest'){if(!delayed){groups_and_privates.on_privateshowrequest_message($message);}
  2082. return true;}else if(subtype=='groupshowapprove'){if(!delayed){groups_and_privates.on_groupshowrequest_approvemessage($message);}
  2083. return true;}else if(subtype=='leaveprivateroom'){if(!delayed){groups_and_privates.on_leaveprivateroom_message($message);}
  2084. return true;}else if(subtype=='privateshowapprove'){if(!delayed){groups_and_privates.on_privateshowrequest_approvemessage($message);}
  2085. return true;}else if(subtype=='token_balance_update'){if(!delayed){tipping.current_balance=parseInt($(message).attr("tokenbalance_"+settings.my_username));$('.tokencount').html(tipping.current_balance);}
  2086. return true;}else if(subtype=='groupshowcancel'){if(!delayed){groups_and_privates.on_groupshowrequest_cancelmessage();}
  2087. return true;}else if(subtype=='privateshowcancel'){if(!delayed){groups_and_privates.on_privateshowrequest_cancelmessage();}
  2088. return true;}else if(subtype=='awaycancel'){if(!delayed){groups_and_privates.on_awaystatus_cancelmessage();}
  2089. return true;}
  2090. var subject=$message.children('subject').text();if(subject){var msg=interpolate(gettext("room subject changed to \"%(subject)s\""),{subject:subject},true);add_system_message("<span class='roommessagelabel'>"+msg+"</span>");$(document).trigger("subjectchanged.defchat",subject);display_subject=settings.parse_subject(subject);settings.subject.text(display_subject);settings.current_subject=subject;return true;}
  2091. var from=$message.attr('from');var nick=Strophe.getResourceFromJid(from);if(nick==null){return true;}
  2092. if(presence_monitor.participants[nick]){if(message_receiver.ignored_users.indexOf(presence_monitor.participants[nick].jid)!==-1){return true;}}
  2093. if($('.broadcaster_panel_away').is(':visible')){return true;}
  2094. message_receiver.add_message(message_receiver._format_message(message));return true;},on_goalreached:function(){if(!settings.is_broadcasting){return;}
  2095. var html="<span class='roommessagelabel'>";html+=gettext("Your goal is completed, to set a new one click Cancel goal and start over")+"</span>";add_system_message(html);},on_settingsupdate:function($message){if($message.attr('allow_privates')==='True'){$('.private_settings .value').html(gettext("Allowed"));groups_and_privates.show_private_show_controls(true);}else{$('.private_settings .value').html(gettext("Disabled"));groups_and_privates.hide_private_show_controls(true);}
  2096. if($message.attr('allow_group')==='True'){$('.group_show_disabled').hide();$('.group_show_active').show();groups_and_privates.show_group_show_controls(true);}else{$('.group_show_active').hide();$('.group_show_disabled').show();groups_and_privates.hide_group_show_controls(true);}
  2097. $('.num_users_required_for_group').html($message.attr('minimum_users_for_group_show'));return true;},on_messagechangerequest:function($message){var subject=$message.children('subject').text();if(settings.is_broadcasting){conn.send($msg({to:settings.room,type:'groupchat'}).c('subject').t(subject));}
  2098. return true;},on_roomalert:function($message){var slug=$message.attr('slug');var url=$message.attr('url');var gendericon=$message.attr('gendericon');var gender=$message.attr('gender');if($.inArray(gender,settings.interested_in)<0){return;}
  2099. if(!(initializer.joined&&(new Date()-initializer.joined_at>2*1000))){return true;}
  2100. var msg=interpolate(gettext("%(roomname)s turned on their cam -- click here to visit."),{roomname:slug},true);msg=message_receiver._add_emoticons(msg);add_system_message("<span class='roomalert'><a href='"+
  2101. url+"'>&lt;&lt;&lt; <img src='"+settings.media_url+"images/"+gendericon+"' height=15 width=14 border=0> "+msg+" &gt;&gt;&gt;</a></span>",tabs.get_current_tab_domele());},on_tipalert:function($message){var from_username=$message.attr('from_username');var to_username=$message.attr('to_username');var amount=$message.attr("amount");var body=$message.find('body').text();var msg=interpolate(gettext("%(from_username)s tipped %(amount)s tokens"),{from_username:from_username,amount:amount},true);if(settings.is_broadcasting){if(!$message.find('delay').length!=0){PlayBeep();if($.trim(body)!=""){msg=msg+" -- "+body;}}}
  2102. add_system_message("<span class='tipalert'>"+msg+"</span>",tabs.get_current_tab_domele());},on_private_message:function(message,nick){if(!nick){var from=$(message).attr('from');nick=Strophe.getResourceFromJid(from);}
  2103. if(presence_monitor.participants[nick]&&presence_monitor.participants[nick].jid){if(message_receiver.ignored_users.indexOf(presence_monitor.participants[nick].jid)!==-1){return true;}}
  2104. message_receiver.add_message(message_receiver._format_message(message),tabs.get_or_create_pm_tab_for_nick(nick,true));tabs.private_message_received(nick);return true;},add_message:function(message,domele){if(!domele){domele=settings.chatlist}
  2105. var chat=domele.get(0);var at_bottom=chat.scrollTop>=chat.scrollHeight-
  2106. chat.clientHeight;domele.append(message);domele.find('div:last').find('a[rel*=facebox]').facebox();domele.find('div:last span.username').not('span[data-nick="'+settings.muc_nickname+'"]').jscontext({html:get_contextual_menu_html,bind:'anyclick'});if(at_bottom){chat.scrollTop=chat.scrollHeight;}
  2107. while(domele.find('div.text').length>200){domele.find('div.text:first').empty().remove();}},_format_message:function(message){var $message=$(message);var from=$message.attr('from');var chat_font=$message.attr('chat_font');var font_color=$message.attr('font_color');var is_mod=$message.attr('is_mod');var has_tokens=$message.attr('has_tokens');var room=Strophe.getBareJidFromJid(from);var nick=Strophe.getResourceFromJid(from);var body=$message.children('body').text();if(!body){body=$message.text();}
  2108. if(room==settings.room){body=message_receiver._add_emoticons(body);var r=$('<div class="text"><span class="username messagelabel" '+'data-nick="'+nick+'">'+nick+':</span><p>'+body+'</p></div>');if(chat_font!=='default'){r.css('font-family',chat_font);}
  2109. r.css('color',font_color);if(presence_monitor.participants[nick]){if(presence_monitor.participants[nick].jid===settings.roomowner){r.find('.messagelabel').addClass('hostmessagelabel');}else if(is_mod=='1'){r.find('.messagelabel').addClass('moderatormessagelabel');}else if(has_tokens=='1'){r.find('.messagelabel').addClass('hastokensmessagelabel');}}
  2110. return r;}},_add_emoticons:function(in_body){var body=$("<div/>").text(in_body).html();while(true){var match=body.match(/%%%\[emoticon ([^\s]+)\]%%%/);if(!match){break;}
  2111. var urlparts=match[1].split(/\|/);var str="";var show_icon=tabs._should_show_emoticon();if(!show_icon){str=":"+urlparts[0];}
  2112. else{var str="<img src='"+urlparts[1]+"' title=':"+urlparts[0]+"' height='"+urlparts[3]+"' width='"+urlparts[2]+"'>";}
  2113. if(urlparts.length==5){str="<a href='"+urlparts[4]+"' rel='facebox'>"+str+"</a>";}
  2114. else if(!show_icon){str="<a href='"+urlparts[1]+"' rel='facebox'>"+str+"</a>";}
  2115. body=body.replace(match[0],str);}
  2116. return body;}};conn.addHandler(message_receiver.on_message,null,"message","groupchat");conn.addHandler(message_receiver.on_private_message,null,"message","chat");var moderators=new Array();var message_sender={message_to_send:'',confirmed_send:false,_recent_message_log:new Array(),on_form_submit:function(){if(settings.textinput.val()==""){message_sender._reset_form();return false;}
  2117. if(settings.first_post_warning!==null){if(!message_sender.confirmed_send){if(!confirm(settings.first_post_warning)){return false;}
  2118. message_sender.confirmed_send=true;}}
  2119. if(presence_monitor.participants[settings.muc_nickname]){if(presence_monitor.participants[settings.muc_nickname].role!='moderator'){if(message_sender.message_to_send==settings.textinput.val()){add_system_message(gettext("duplicate message not sent"),tabs.get_current_tab_domele());message_sender._reset_form();return false;}
  2120. if(message_sender._get_recent_message_log_count()>=3&&tipping.current_balance===0){add_system_message(gettext("message not sent -- try slowing down"),tabs.get_current_tab_domele());return false;}}}
  2121. if(!initializer.joined){add_system_message('not connected');return false;}
  2122. if(settings.password==='anonymous'){if(settings.login_required_callback){settings.login_required_callback();}else{add_system_message(gettext("anonymous users cannot chat - create your free account"),tabs.get_current_tab_domele());}
  2123. return false;}
  2124. message_sender.message_to_send=settings.textinput.val();message_sender._reset_form();message_sender._translate_and_send();message_sender._recent_message_log.push(new Date());return false;},_get_recent_message_log_count:function(){message_sender._remove_old_messages_from_log();return message_sender._recent_message_log.length;},_remove_old_messages_from_log:function(){var now=new Date();message_sender._recent_message_log=$.grep(message_sender._recent_message_log,function(a){return((now-a)<(10*1000));});},_translate_and_send:function(){if(settings.translate_message_url!==null){message_sender._reset_form();$.ajax({url:settings.translate_message_url,aync:false,data:{message:message_sender.message_to_send,room:settings.roomownernick},success:function(data,textStatus,jqXHR){if(!jqXHR.getResponseHeader('X-Successful')){alert("An error occurred");return;}
  2125. if(jqXHR.getResponseHeader('X-Spam')){var m=$msg({to:'',from:settings.room+'/'+settings.username,type:'chat',font_color:settings.font_color,chat_font:settings.chat_font}).c('body').t(data);m=String(m);message_receiver.add_message(message_receiver._format_message(m),tabs.get_current_tab_domele());}else if(jqXHR.getResponseHeader('X-Denied')){m=String(m);message_receiver.add_message("<div class='text'>"+jqXHR.getResponseHeader('X-Denied')+"</div>",tabs.get_current_tab_domele());}else{message_sender._send(data);}}});}else{message_sender._send(message_sender.message_to_send);}},_send:function(message){var ismod='0';if(presence_monitor.participants[settings.muc_nickname]){if(presence_monitor.participants[settings.muc_nickname].role=='moderator'){ismod='1';}}
  2126. var to;var type;if(tabs.current_tab==='pm'){to=settings.room+"/"+tabs.current_pm_nick;type='chat';}else{to=settings.room;type='groupchat';}
  2127. var has_tokens='0';if(tipping.current_balance>0){has_tokens='1';}
  2128. var m=$msg({to:to,type:type,font_color:settings.font_color,chat_font:settings.chat_font,is_mod:ismod,has_tokens:has_tokens}).c('body').t(message);conn.send(m);if(tabs.current_tab==='pm'){var from=settings.room+'/'+settings.muc_nickname;m=$msg({to:to,type:type,from:from,font_color:settings.font_color,chat_font:settings.chat_font,is_mod:ismod}).c('body').t(message);message_receiver.on_private_message(m.toString(),tabs.current_pm_nick);}},_reset_form:function(){settings.textinput.val('');settings.textinput.focus();}};var tipping_goal={init:function(){$("#goalform").submit(tipping_goal.on_configuration_submit);$('.cancel_goal').click(tipping_goal.on_cancel_click);$('.set_goal').click(tipping_goal.on_set_goal_clicked);$('.broadcaster_panel_goal_configuration .cancel a').click(tipping_goal.on_configuration_cancel_click);},on_set_goal_clicked:function(){groups_and_privates.change_broadcaster_panel('goal_configuration');$('#token_goal_description_input').focus();},on_configuration_cancel_click:function(){groups_and_privates.change_broadcaster_panel('default');},disable_goal:function(){settings.room_goal={};if(!settings.is_broadcasting){$(".goal_display_table").hide();}},enable_goal:function(){if(!initializer.is_on_private_room){groups_and_privates.change_broadcaster_panel('goal_display');}
  2129. $(".goal_display_table").show();$('.goal_status_disabled').hide();$('.goal_status_active').show();$('.room_goal_amount').text(settings.room_goal.amount);$('.room_goal_current').text(settings.room_goal.current);$('.room_goal_hightipper').text(settings.room_goal.hightipper);$('.room_goal_hightipper_amount').text(settings.room_goal.hightipper_amount);$('.room_goal_lasttipper').text(settings.room_goal.lasttipper);$('.room_goal_lasttipper_amount').text(settings.room_goal.lasttipper_amount);},on_configuration_submit:function(){var description=$("#goalform input[name='description']").val();var amount=parseInt($("#goalform input[name='amount']").val());if($.trim(description)==""){alert(gettext("Invalid token goal description"));return false;}
  2130. if(isNaN(amount)|amount<=0){alert(gettext("Invalid token goal amount"));return false;}
  2131. $.post($('#goalform').attr('action'),$('#goalform').serialize(),function(data){if(data!='ok'){alert(data);}});return false;},on_cancel_click:function(){if(confirm(gettext("Are you sure you want to remove this goal?"))){groups_and_privates.change_broadcaster_panel('default');$('.goal_status_active').hide();$('.goal_status_disabled').show();$.post($(this).attr('href'),{'foo':'bar'});conn.send($msg({to:settings.room,type:'groupchat'}).c('subject').t(settings.default_subject))}
  2132. return false;}};tipping_goal.init();var emoticons={_emoticons_loaded:false,_popup_window:null,init:function(){settings.domroot.find(".emoticon_button").click(emoticons.on_emoticon_button_clicked);},on_emoticon_button_clicked:function(ev){if(settings.login_required_callback){if(settings.login_required_callback()){return false;}}
  2133. emoticons.toggle_overlay();},on_body_clicked_while_overlay_up:function(ev){if(settings.domroot.find('.emote_popup').has(ev.target).length||settings.domroot.find('.emoticon_button').is(ev.target)){return;}
  2134. emoticons.toggle_overlay();},on_popup_clicked:function(ev){if(!emoticons._popup_window||emoticons._popup_window.closed){emoticons._popup_window=window.open($(this).attr('href'),'_blank','status=0,toolbar=0,menubar=0,directories=0,resizable=1,'+'scrollbars=1,height=615,width=850');emoticons._popup_window.onload=function(){emoticons._popup_window.RunCallbackFunction=emoticons.on_popup_callback;};$(window).unload(emoticons.on_document_closing);}
  2135. emoticons.toggle_overlay();emoticons._popup_window.focus();return false;},on_document_closing:function(){if(emoticons._popup_window){if(!emoticons._popup_window.closed){emoticons._popup_window.close();}}},on_popup_callback:function(){alert("popup callback");},on_emoticon_clicked:function(){emoticons.toggle_overlay();settings.textinput.val(settings.textinput.val()+" "+
  2136. $(this).data('emoticon'));settings.textinput.focus();},toggle_overlay:function(){var ep=settings.domroot.find(".emote_popup");if(ep.is(":visible")){$("body").unbind('click',emoticons.on_body_clicked_while_overlay_up);ep.hide();}else{$("body").click(emoticons.on_body_clicked_while_overlay_up);if(emoticons._emoticons_loaded){ep.show();}else{emoticons._emoticons_loaded=true;ep.load(settings.emoticon_overlay_url,function(){ep.show();ep.find('.more a').click(emoticons.on_popup_clicked);ep.find('img.emoticon').click(emoticons.on_emoticon_clicked);});}}}};emoticons.init();var tipping={current_balance:0,init:function(){$(".tip_button").click(tipping.on_tipping_button_clicked);settings.domroot.find('.tip_popup form').submit(tipping.on_form_submit);tipping.current_balance=settings.token_balance;$(document).bind('keydown','ctrl+s',tipping.on_key_down);$(document).bind('keydown','command+s',tipping.on_key_down);},on_key_down:function(event){tipping.toggle_overlay();return false;},on_form_submit:function(){var amount=parseInt($("#id_tip_amount").val());if(isNaN(amount)|amount<1){alert(gettext("Invalid tip amount"));return false;}
  2137. if(amount>tipping.current_balance){alert(gettext("You do not have enough tokens."));return false;}
  2138. var msg=interpolate(gettext("Send %(tokens)s tokens to %(username)s?"),{username:settings.roomownernick,tokens:$("#id_tip_amount").val()},true);if(!confirm(msg)){return false;}
  2139. var $form=$(this);$.ajax({url:$(this).attr('action'),dataType:'json',data:$(this).serialize(),type:'POST',success:function(response){if(response.error){alert(response.error);}else if(response.success){$form.find("textarea").val("");tipping.toggle_overlay();tipping.current_balance=parseInt(response.token_balance);$('.tokencount').html(response.token_balance);}}});return false;},on_tipping_button_clicked:function(ev){if(settings.login_required_callback){if(settings.login_required_callback()){return false;}}
  2140. if(!(tabs.current_tab=='pm'|tabs.current_tab=='chat')){tabs._show_chat_tab();}
  2141. tipping.toggle_overlay();},on_body_clicked_while_overlay_up:function(ev){if(settings.domroot.find('.tip_popup').has(ev.target).length||$('.tip_button').is(ev.target)){return;}
  2142. tipping.toggle_overlay();},toggle_overlay:function(){if(!settings.allow_tipping){return;}
  2143. if(!(typeof _gaq==='undefined')){_gaq.push(['_trackPageview','/tracking/toggle_tipping_overlay/']);}
  2144. var ep=settings.domroot.find(".tip_popup");if(ep.is(":visible")){$("body").unbind('click',tipping.on_body_clicked_while_overlay_up);ep.hide();settings.textinput.focus();}else{$("body").click(tipping.on_body_clicked_while_overlay_up);$.ajax({url:settings.tipping_current_tokens_url,type:'GET',data:'foo=bar',dataType:'json',cache:false,success:function(response){tipping.current_balance=parseInt(response.token_balance);$('.tokencount').html(response.token_balance);ep.show();ep.find('#id_tip_amount').focus();ep.find('#id_tip_amount').select();}});}}};tipping.init();var keybinder={current_focus:null,init:function(){$(document).keydown(keybinder.handle_keydown);$(":input").live('focus',keybinder.on_focus);$(":input").live('blur',keybinder.on_blur);},handle_keydown:function(e){if(keybinder.current_focus!==null){return;}
  2145. if((e.keyCode>=65&&e.keyCode<=90)|(e.keyCode>=48&&e.keyCode<=57)){settings.textinput.focus().val(settings.textinput.val());}},on_blur:function(){keybinder.current_focus=null;},on_focus:function(){keybinder.current_focus=this.id;}};keybinder.init();var groups_and_privates={init:function(){$('.start_group_show,.start_group_show_link').click(groups_and_privates.start_group_show_clicked);$('.start_group_show_cancel').click(groups_and_privates.cancel_group_chat_request);$('.start_private_show').click(groups_and_privates.start_private_show_clicked);$('.start_private_show_cancel').click(groups_and_privates.cancel_private_chat_request);$('.broadcaster_panel_show_requested .accept').click(groups_and_privates.approve_private_show_clicked);$('.broadcaster_panel_show_requested .decline').click(groups_and_privates.decline_private_show_clicked);$('.broadcaster_panel_private_show .decline').click(groups_and_privates.decline_private_show_clicked);$('.broadcaster_panel_group_show_requested .accept').click(groups_and_privates.approve_group_show_clicked);$('.broadcaster_panel_group_show_requested .decline').click(groups_and_privates.decline_group_show_clicked);$('.broadcaster_panel_group_show .decline').click(groups_and_privates.decline_group_show_clicked);$('.return_from_away_mode').live('click',groups_and_privates.return_from_away_mode_clicked);},approve_private_show_clicked:function(){$.post(settings.private_show_approve_url,{'foo':'bar'});},decline_private_show_clicked:function(){if(!confirm(gettext("Are you sure?"))){return}
  2146. $.post(settings.private_show_decline_url,{'foo':'bar'});},approve_group_show_clicked:function(){$.post(settings.group_show_approve_url,{'foo':'bar'});},return_from_away_mode_clicked:function(){$.post(settings.return_from_away_url,{'foo':'bar'});},decline_group_show_clicked:function(){if(!confirm(gettext("Are you sure?"))){return}
  2147. $.post(settings.group_show_decline_url,{'foo':'bar'});},start_group_show_clicked:function(){if(settings.login_required_callback){if(settings.login_required_callback()){return false;}}
  2148. groups_and_privates.change_group_show_link('processing');$.post(settings.group_show_tokens_per_minute_url,{'foo':'bar'},function(data){var msg=interpolate(gettext("Enter group chat with %(modelname)s? (%(price)s tokens per minute)"),{modelname:settings.roomownernick,price:data},true);if(confirm(msg)){$.post(settings.group_show_request_url,{'chat_username':settings.muc_nickname},function(data){if(data.success){groups_and_privates.change_group_show_link('waiting');add_system_message("<span class='privatealert'>"+
  2149. gettext("Group show request has been sent.")+"</span>");}else{if(data.message){alert(data.message);}
  2150. groups_and_privates.change_group_show_link();}},'json').error(groups_and_privates.error_starting_group_show);}else{groups_and_privates.change_group_show_link();}}).error(groups_and_privates.error_starting_group_show);},on_groupshowrequest_message:function($message){var users_waiting=parseInt($message.attr('users_waiting'));var users_required=parseInt($message.attr('users_required'));if(!initializer.is_on_private_room){add_system_message("<span class='privatealert'>"+users_waiting+" of "+users_required+" users are ready to start a group show.</span>")}
  2151. $('.num_users_waiting_for_group').html($message.attr('users_waiting'));if(settings.is_broadcasting&!initializer.is_on_private_room){if(users_waiting==users_required){$('.broadcaster_panel_group_show_requested .tokens_per_minute').html($message.attr('tokens_per_minute'));groups_and_privates.change_broadcaster_panel('group_show_requested');PlayBeep();}}},start_private_show_clicked:function(){if(settings.login_required_callback){if(settings.login_required_callback()){return false;}}
  2152. groups_and_privates.change_private_show_link('processing');$.post(settings.private_show_tokens_per_minute_url,{'foo':'bar'},function(data){var msg=interpolate(gettext("Enter private chat with %(modelname)s? (%(price)s tokens per minute)"),{modelname:settings.roomownernick,price:data},true);if(confirm(msg)){$.post(settings.private_show_request_url,{'chat_username':settings.muc_nickname},function(data){if(data.success){groups_and_privates.change_private_show_link('waiting');add_system_message("<span class='privatealert'>"+
  2153. gettext("Private show request has been sent. Waiting on broadcaster to approve.")+"</span>");}else{if(data.message){alert(data.message);}
  2154. groups_and_privates.change_private_show_link();}},'json').error(groups_and_privates.error_starting_private_show);}else{groups_and_privates.change_private_show_link();}}).error(groups_and_privates.error_starting_private_show);},is_requesting_group_chat:function(){return $('.start_group_show_waiting').is(':visible')|$('.start_group_show_processing').is(':visible');},is_requesting_private_chat:function(){return $('.start_private_show_waiting').is(':visible');},on_groupshowrequest_approvemessage:function($message){add_system_message("<span class='privatealert'>"+
  2155. gettext("Group show has started.")+"</span>");if(initializer.is_on_private_room){return;}
  2156. $('.tokens_per_minute').html($message.attr('tokens_per_minute'));if(groups_and_privates.is_requesting_group_chat()|settings.is_broadcasting){groups_and_privates.change_group_show_link('active');groups_and_privates.change_broadcaster_panel('group_show');initializer.change_to_private_room();}},on_privateshowrequest_approvemessage:function($message){add_system_message("<span class='privatealert'>"+
  2157. gettext("Private show has started.")+"</span>");if(initializer.is_on_private_room){return;}
  2158. if(groups_and_privates.is_requesting_private_chat()|settings.is_broadcasting){groups_and_privates.change_private_show_link('active');groups_and_privates.change_broadcaster_panel('private_show');$('.tokens_per_minute').html($message.attr('tokens_per_minute'));initializer.change_to_private_room();}},change_broadcaster_panel:function(name){if(public_methods.is_goal_set()&&name=='default'){name='goal_display';}
  2159. $('.broadcaster_panel_default').hide();$('.broadcaster_panel_private_show').hide();$('.broadcaster_panel_group_show').hide();$('.broadcaster_panel_show_requested').hide();$('.broadcaster_panel_group_show_requested').hide();$('.broadcaster_panel_goal_configuration').hide();$('.broadcaster_panel_goal_display').hide();$('.broadcaster_panel_away').hide();$(".broadcaster_panel_"+name).show();},on_groupshowrequest_cancelmessage:function(){$('.num_users_waiting_for_group').html('0');if(initializer.is_on_private_room){if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('away');}
  2160. add_system_message("<span class='privatealert'>"+
  2161. gettext("Group show has finished.")+"</span>");initializer.leave_private_room();groups_and_privates.change_group_show_link();}else{if(groups_and_privates.is_requesting_group_chat()){add_system_message("<span class='privatealert'>"+
  2162. gettext("Group show has been declined.")+"</span>");groups_and_privates.change_group_show_link();}
  2163. if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('default');}}},on_awaystatus_cancelmessage:function(){if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('default');}},on_privateshowrequest_cancelmessage:function(){if(initializer.is_on_private_room){add_system_message("<span class='privatealert'>"+
  2164. gettext("Private show has finished.")+"</span>");initializer.leave_private_room();groups_and_privates.change_private_show_link();if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('away');}}else{if(groups_and_privates.is_requesting_private_chat()){add_system_message("<span class='privatealert'>"+
  2165. gettext("Private show has been declined.")+"</span>");groups_and_privates.change_private_show_link();}
  2166. if(settings.is_broadcasting){groups_and_privates.change_broadcaster_panel('default');}}},on_leaveprivateroom_message:function($message){if($message.attr('username')==settings.my_username){initializer.leave_private_room();groups_and_privates.change_group_show_link();}},on_privateshowrequest_message:function($message){if(settings.is_broadcasting){var username=$message.attr('requester_username');$('.broadcaster_panel_show_requested .requester_username').html(username);$('.broadcaster_panel_show_requested .tokens_per_minute').html($message.attr('tokens_per_minute'));groups_and_privates.change_broadcaster_panel('show_requested');PlayBeep();add_system_message("<span class='privatealert'>"+username+" wants to start a private show.</span>")}},error_starting_group_show:function(){alert(gettext("There was an error requesting your show. Please try again."));groups_and_privates.change_group_show_link();},error_starting_private_show:function(){alert(gettext("There was an error requesting your show. Please try again."));groups_and_privates.change_private_show_link();},cancel_group_chat_request:function(){if(confirm(gettext("Are you sure?"))){$.post(settings.group_show_cancel_url,{'foo':'bar'});groups_and_privates.change_group_show_link();}},cancel_private_chat_request:function(){if(confirm(gettext("Are you sure?"))){$.post(settings.private_show_cancel_url,{'foo':'bar'});}},change_group_show_link:function(link){$('.start_group_show').hide();$('.start_group_show_waiting').hide();$('.start_group_show_processing').hide();$('.start_group_show_active').hide();var key='.start_group_show';if(link){key=key+"_"+link;groups_and_privates.hide_private_show_controls();}else{groups_and_privates.show_private_show_controls();}
  2167. $(key).show();},change_private_show_link:function(link){$('.start_private_show').hide();$('.start_private_show_processing').hide();$('.start_private_show_waiting').hide();$('.start_private_show_active').hide();var key='.start_private_show';if(link){key=key+"_"+link;groups_and_privates.hide_group_show_controls();}else{groups_and_privates.show_group_show_controls();}
  2168. $(key).show();},hide_private_show_controls:function(force){$('.private_show_controls').hide();if(force){$('.private_show_controls').data('forcehidden','1');}
  2169. groups_and_privates.show_group_show_controls();},show_private_show_controls:function(force){if(force|$('.private_show_controls').data('forcehidden')!='1'){$('.private_show_controls').show();}},hide_group_show_controls:function(force){$('.group_show_controls').hide();if(force){$('.group_show_controls').data('forcehidden','1');}},show_group_show_controls:function(force){if(force|$('.group_show_controls').data('forcehidden')!='1'){$('.group_show_controls').show();}}};groups_and_privates.init();public_methods._set_font_size();ignored_user_methods.load_ignored_users();settings.form.submit(message_sender.on_form_submit);settings.submitbutton.click(message_sender.on_form_submit);if(settings.throttlechat){if(settings.welcome_message){add_system_message(settings.welcome_message);}
  2170. if(settings.welcome_warning){add_system_message(settings.welcome_warning);}
  2171. add_system_message(settings.throttle_message);presence_monitor.num_participants=100;}else{consolelog("Trying to connect to "+settings.bosh_host+" with "+
  2172. settings.user+":"+settings.password);conn.connect(settings.user,settings.password,function(status,data){if(status===Strophe.Status.CONNECTED){$(document).trigger("connected.defchat");}else if(status===Strophe.Status.CONNECTING){$(document).trigger("connecting.defchat");}else if(status===Strophe.Status.DISCONNECTED){$(document).trigger("disconnected.defchat");}else if(status===Strophe.Status.CONNFAIL){$(document).trigger("connectionfailed.defchat");}else{consolelog('Defchat Unhandled status: '+status+"-"+data);}});}
  2173. if(settings.scroll_on_load){settings.textinput.focus();function isScrolledIntoView(elem)
  2174. {var docViewTop=$(window).scrollTop();var docViewBottom=docViewTop+$(window).height();var elemTop=$(elem).offset().top;var elemBottom=elemTop+$(elem).height();return((elemBottom>=docViewTop)&&(elemTop<=docViewBottom));}
  2175. if($('.top-section').length>0){if(!isScrolledIntoView($('.top-section'))){$(document).scrollTop($('.top-section').offset().top);}}}
  2176. var returnhandle=function(method){if(public_methods[method]){return public_methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'||!method){return public_methods.init.apply(this,arguments);}else{$.error('Method '+method+' does not exist in defchat');}};return returnhandle;};})(jQuery);function EmbedViewerSwf(swfname,modelname,fms_address,popout_url,language,mute,pr,sa,express,uid,jg)
  2177. {var params={allowScriptAccess:"always",allowFullScreen:"true",quality:"high",wmode:"opaque",id:"movie",FlashVars:"pid="+modelname+"&address="+fms_address+"&popouturl="+popout_url+"&language="+language+"&mute="+mute+"&pr="+pr+"&sa="+sa+"&uid="+uid+"&jg="+jg};if(!document.getElementById('movie')){return;}
  2178. document.getElementById('movie').innerHTML="<center><br><br><br><br><a border='0' href='http://www.adobe.com/go/getflashplayer' target='_blank'>"+"<img alt='Get Adobe Flash player' src='"+MEDIA_URL+"images/160x41_Get_Flash_Player.jpg'></a><br>"+"We've detected that you are missing the latest version of Flash Player.<br>"+"This version of the Chaturbate Viewer requires Flash Player 10.2.0 or later.<br>"+"<a href='http://www.adobe.com/go/getflashplayer'>"+"Click here to update your Flash Player for free.</a></center>";swfobject.embedSWF(swfname,'movie',"100%","100%","10.2.0",null,"",params);}
  2179. function EmbedBroadcasterSwf(swfname,modelname,fms_address,language,express,pt,captureurl,pk,pe)
  2180. {var params={allowScriptAccess:"always",allowFullScreen:"false",quality:"high",wmode:"opaque",id:"movie",FlashVars:"pid="+modelname+"&address="+fms_address+"&language="+language+"&pt="+pt+"&captureurl="+captureurl+"&pk="+pk+"&pe="+pe};if(!document.getElementById('movie')){return;}
  2181. document.getElementById('movie').innerHTML="<center><br><br><br><br><a border='0' href='http://www.adobe.com/go/getflashplayer' target='_blank'>"+"<img alt='Get Adobe Flash player' src='"+MEDIA_URL+"images/160x41_Get_Flash_Player.jpg'></a><br>"+"We've detected that you are missing the latest version of Flash Player.<br>"+"This version of the Chaturbate Broadcaster requires Flash Player 10.2.0 or later.<br>"+"<a href='http://www.adobe.com/go/getflashplayer'>"+"Click here to update your Flash Player for free.</a></center>";swfobject.embedSWF(swfname,'movie',"100%","100%","10.2.0",null,"",params);}
  2182. function EmbedBroadcasterSwf_11(swfname,modelname,fms_address,language,express,pt,captureurl,pk,pe)
  2183. {var params={allowScriptAccess:"always",allowFullScreen:"false",quality:"high",wmode:"opaque",id:"movie",FlashVars:"pid="+modelname+"&address="+fms_address+"&language="+language+"&pt="+pt+"&captureurl="+captureurl+"&pk="+pk+"&pe="+pe};if(!document.getElementById('movie')){return;}
  2184. document.getElementById('movie').innerHTML="<center><br><br><br><br><a border='0' href='http://www.adobe.com/go/getflashplayer' target='_blank'>"+"<img alt='Get Adobe Flash player' src='"+MEDIA_URL+"images/160x41_Get_Flash_Player.jpg'></a><br>"+"We've detected that you are missing the latest version of Flash Player.<br>"+"This version of the Chaturbate Broadcaster requires Flash Player 11.0.1 or later.<br>"+"<a href='http://www.adobe.com/go/getflashplayer'>"+"Click here to update your Flash Player for free.</a></center>";swfobject.embedSWF(swfname,'movie',"100%","100%","11.0.1",null,"",params);}
  2185. function EmbedDualBroadcasterSwf(swfname,swfname_11,modelname,fms_address,language,express,pt,captureurl,pk,pe)
  2186. {var version=swfobject.getFlashPlayerVersion();if(version.major>=11&&version.minor>=0&&version.release>=1)
  2187. EmbedBroadcasterSwf_11(swfname_11,modelname,fms_address,language,express,pt,captureurl,pk,pe);else
  2188. EmbedBroadcasterSwf(swfname,modelname,fms_address,language,express,pt,captureurl,pk,pe);}
  2189. var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return!a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();function SwfScale(width)
  2190. {var swfwidth=parseInt(width);var swfheight=swfwidth*0.75;document.getElementById("player").style.width=swfwidth+"px";document.getElementById("player").style.height=swfheight+"px";}
  2191. var SwfPopup=null;var PopupUpdater=null;function Popout(broadcaster,url)
  2192. {var windowName="CBVPopup";var windowOptions="width="+(498+16)+",height="+(407+16)+",status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0";document.getElementById('player').style.display='none';SwfPopup=window.open(url,windowName,windowOptions);if(PopupUpdater==null)
  2193. PopupUpdater=setInterval("SwfPopupUpdate()",1000);return SwfPopup;}
  2194. function SwfPopupUpdate()
  2195. {if(SwfPopup&&SwfPopup.closed)
  2196. {clearInterval(PopupUpdater);PopupUpdater=null;SwfPopup=null;document.getElementById('player').style.display='block';}}
  2197. function OnResizePopout()
  2198. {var winW=514,winH=423;if(document.body&&document.body.offsetWidth)
  2199. {winW=document.body.offsetWidth;winH=document.body.offsetHeight;}
  2200. if(document.compatMode=='CSS1Compat'&&document.documentElement&&document.documentElement.offsetWidth)
  2201. {winW=document.documentElement.offsetWidth;winH=document.documentElement.offsetHeight;}
  2202. if(window.innerWidth&&window.innerHeight)
  2203. {winW=window.innerWidth;winH=window.innerHeight;}
  2204. var swfW=winW-16;var swfH=swfW*0.75;if(swfH+16>winH)
  2205. SwfScale((winH-16)*1.33);else
  2206. SwfScale((winW-16));}
  2207. function GetFlashObject(movieName)
  2208. {var isIE=navigator.appName.indexOf("Microsoft")!=-1;return(isIE)?window[movieName]:document[movieName];}
  2209. function PlayBeep()
  2210. {GetFlashObject('movie').PlayBeep();}
  2211. function test_js()
  2212. {alert('test join group link');}
  2213. $(document).ready(function(){function on_key_down(){window.location=nextroomurl;return false;}
  2214. $(document).bind('keydown','ctrl+x',on_key_down);$(document).bind('keydown','command+x',on_key_down);});(function($){$(document).ready(function(){$("a.endless_more").live("click",function(){var container=$(this).closest(".endless_container");var loading=container.find(".endless_loading");$(this).hide();loading.show();var data="querystring_key="+$(this).attr("rel").split(" ")[0];$.get($(this).attr("href"),data,function(data){container.before(data);container.remove();});return false;});$("a.endless_page_link").live("click",function(){var data="querystring_key="+$(this).attr("rel").split(" ")[0];$(this).closest(".endless_page_template").load($(this).attr("href"),data);return false;});});})(jQuery);$(document).ready(function(){$.fn.mColorPicker.init.replace=false;$.fn.mColorPicker.defaults.imageFolder="http://ccstatic.chaturbate.com/static/mColorPicker/images/";$.fn.mColorPicker.init.showLogo=false;$.fn.mColorPicker.init.allowTransparency=false;});(function($){var $o;$.fn.mColorPicker=function(options){$o=$.extend($.fn.mColorPicker.defaults,options);if($o.swatches.length<10)$o.swatches=$.fn.mColorPicker.defaults.swatches
  2215. if($("div#mColorPicker").length<1)$.fn.mColorPicker.drawPicker();if($('#css_disabled_color_picker').length<1)$('head').prepend('<style id="css_disabled_color_picker" type="text/css">.mColorPicker[disabled] + span, .mColorPicker[disabled="disabled"] + span, .mColorPicker[disabled="true"] + span {filter:alpha(opacity=50);-moz-opacity:0.5;-webkit-opacity:0.5;-khtml-opacity: 0.5;opacity: 0.5;}</style>');$('.mColorPicker').live('keyup',function(){try{$(this).css({'background-color':$(this).val()}).css({'color':$.fn.mColorPicker.textColor($(this).css('background-color'))}).trigger('change');}catch(r){}});$('.mColorPickerTrigger').live('click',function(){$.fn.mColorPicker.colorShow($(this).attr('id').replace('icp_',''));});this.each(function(){$.fn.mColorPicker.drawPickerTriggers($(this));});return this;};$.fn.mColorPicker.currentColor=false;$.fn.mColorPicker.currentValue=false;$.fn.mColorPicker.color=false;$.fn.mColorPicker.init={replace:'[type=color]',index:0,enhancedSwatches:true,allowTransparency:true,checkRedraw:'DOMUpdated',liveEvents:false,showLogo:true};$.fn.mColorPicker.defaults={imageFolder:'images/',swatches:["#ffffff","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000","#4c2b11","#3b3b3b","#000000"]};$.fn.mColorPicker.liveEvents=function(){$.fn.mColorPicker.init.liveEvents=true;if($.fn.mColorPicker.init.checkRedraw&&$.fn.mColorPicker.init.replace){$(document).bind($.fn.mColorPicker.init.checkRedraw+'.mColorPicker',function(){$('input[data-mcolorpicker!="true"]').filter(function(){return($.fn.mColorPicker.init.replace=='[type=color]')?this.getAttribute("type")=='color':$(this).is($.fn.mColorPicker.init.replace);}).mColorPicker();});}};$.fn.mColorPicker.drawPickerTriggers=function($t){if($t[0].nodeName.toLowerCase()!='input')return false;var id=$t.attr('id')||'color_'+$.fn.mColorPicker.init.index++,hidden=false;$t.attr('id',id);if($t.attr('text')=='hidden'||$t.attr('data-text')=='hidden')hidden=true;var color=$t.val(),width=($t.width()>0)?$t.width():parseInt($t.css('width'),10),height=($t.height())?$t.height():parseInt($t.css('height'),10),flt=$t.css('float'),image=(color=='transparent')?"url('"+$o.imageFolder+"/grid.gif')":'',colorPicker='';$('body').append('<span id="color_work_area"></span>');$('span#color_work_area').append($t.clone(true));colorPicker=$('span#color_work_area').html().replace(/type="color"/gi,'').replace(/input /gi,(hidden)?'input type="hidden"':'input type="text"');$('span#color_work_area').html('').remove();$t.after((hidden)?'<span style="cursor:pointer;border:1px solid black;float:'+flt+';width:'+width+'px;height:'+height+'px;" id="icp_'+id+'">&nbsp;</span>':'').after(colorPicker).remove();if(hidden){if($('#'+id).prop('class')){$('#icp_'+id).prop('class',$('#'+id).prop('class'));}
  2216. $('#icp_'+id).css({'background-color':color,'background-image':image,'display':'inline-block'}).addClass('mColorPickerTrigger');}else{$('#'+id).css({'background-color':color,'background-image':image}).css({'color':$.fn.mColorPicker.textColor($('#'+id).css('background-color'))}).after('<span style="cursor:pointer;" id="icp_'+id+'" class="mColorPickerTrigger"><img src="'+$o.imageFolder+'color.png" style="border:0;margin:0 0 0 3px" align="absmiddle"></span>').addClass('mColorPickerInput');}
  2217. $('#icp_'+id).attr('data-mcolorpicker','true');$('#'+id).addClass('mColorPicker');return $('#'+id);};$.fn.mColorPicker.drawPicker=function(){$(document.createElement("div")).attr("id","mColorPicker").css('display','none').html('<div id="mColorPickerWrapper"><div id="mColorPickerImg" class="mColor"></div><div id="mColorPickerImgGray" class="mColor"></div><div id="mColorPickerSwatches"><div class="mClear"></div></div><div id="mColorPickerFooter"><input type="text" size="8" id="mColorPickerInput"/></div></div>').appendTo("body");$(document.createElement("div")).attr("id","mColorPickerBg").css({'display':'none'}).appendTo("body");for(n=9;n>-1;n--){$(document.createElement("div")).attr({'id':'cell'+n,'class':"mPastColor"+((n>0)?' mNoLeftBorder':'')}).html('&nbsp;').prependTo("#mColorPickerSwatches");}
  2218. $('#mColorPicker').css({'border':'1px solid #ccc','color':'#fff','z-index':999998,'width':'194px','height':'184px','font-size':'12px','font-family':'times'});$('.mPastColor').css({'height':'18px','width':'18px','border':'1px solid #000','float':'left'});$('#colorPreview').css({'height':'50px'});$('.mNoLeftBorder').css({'border-left':0});$('.mClear').css({'clear':'both'});$('#mColorPickerWrapper').css({'position':'relative','border':'solid 1px gray','z-index':999999});$('#mColorPickerImg').css({'height':'128px','width':'192px','border':0,'cursor':'crosshair','background-image':"url('"+$o.imageFolder+"colorpicker.png')"});$('#mColorPickerImgGray').css({'height':'8px','width':'192px','border':0,'cursor':'crosshair','background-image':"url('"+$o.imageFolder+"graybar.jpg')"});$('#mColorPickerInput').css({'border':'solid 1px gray','font-size':'10pt','margin':'3px','width':'80px'});$('#mColorPickerImgGrid').css({'border':0,'height':'20px','width':'20px','vertical-align':'text-bottom'});$('#mColorPickerSwatches').css({'border-right':'1px solid #000'});$('#mColorPickerFooter').css({'background-image':"url('"+$o.imageFolder+"grid.gif')",'position':'relative','height':'26px'});if($.fn.mColorPicker.init.allowTransparency)$('#mColorPickerFooter').prepend('<span id="mColorPickerTransparent" class="mColor" style="font-size:16px;color:#000;padding-right:30px;padding-top:3px;cursor:pointer;overflow:hidden;float:right;">transparent</span>');if($.fn.mColorPicker.init.showLogo)$('#mColorPickerFooter').prepend('<a href="http://meta100.com/" title="Meta100 - Designing Fun" alt="Meta100 - Designing Fun" style="float:right;" target="_blank"><img src="'+$o.imageFolder+'meta100.png" title="Meta100 - Designing Fun" alt="Meta100 - Designing Fun" style="border:0;border-left:1px solid #aaa;right:0;position:absolute;"/></a>');$("#mColorPickerBg").click($.fn.mColorPicker.closePicker);var swatch=$.fn.mColorPicker.getCookie('swatches'),i=0;if(typeof swatch=='string')swatch=swatch.split('||');if(swatch==null||$.fn.mColorPicker.init.enhancedSwatches||swatch.length<10)swatch=$o.swatches;$(".mPastColor").each(function(){$(this).css('background-color',swatch[i++].toLowerCase());});};$.fn.mColorPicker.closePicker=function(){$(".mColor, .mPastColor, #mColorPickerInput, #mColorPickerWrapper").unbind();$("#mColorPickerBg").hide();$("#mColorPicker").fadeOut()};$.fn.mColorPicker.colorShow=function(id){var $e=$("#icp_"+id);pos=$e.offset(),$i=$("#"+id);hex=$i.attr('data-hex')||$i.attr('hex'),pickerTop=pos.top+$e.outerHeight(),pickerLeft=pos.left,$d=$(document),$m=$("#mColorPicker");if($i.attr('disabled'))return false;if(pickerTop+$m.height()>$d.height())pickerTop=pos.top-$m.height();if(pickerLeft+$m.width()>$d.width())pickerLeft=pos.left-$m.width()+$e.outerWidth();$m.css({'top':(pickerTop)+"px",'left':(pickerLeft)+"px",'position':'absolute'}).fadeIn("fast");$("#mColorPickerBg").css({'z-index':999990,'background':'black','opacity':.01,'position':'absolute','top':0,'left':0,'width':parseInt($d.width(),10)+'px','height':parseInt($d.height(),10)+'px'}).show();var def=$i.val();$('#colorPreview span').text(def);$('#colorPreview').css('background',def);$('#color').val(def);if($('#'+id).attr('data-text'))$.fn.mColorPicker.currentColor=$e.css('background-color');else $.fn.mColorPicker.currentColor=$i.css('background-color');if(hex=='true')$.fn.mColorPicker.currentColor=$.fn.mColorPicker.RGBtoHex($.fn.mColorPicker.currentColor);$("#mColorPickerInput").val($.fn.mColorPicker.currentColor);$('.mColor, .mPastColor').bind('mousemove',function(e){var offset=$(this).offset();$.fn.mColorPicker.color=$(this).css("background-color");if($(this).hasClass('mPastColor')&&hex=='true')$.fn.mColorPicker.color=$.fn.mColorPicker.RGBtoHex($.fn.mColorPicker.color);else if($(this).hasClass('mPastColor')&&hex!='true')$.fn.mColorPicker.color=$.fn.mColorPicker.hexToRGB($.fn.mColorPicker.color);else if($(this).attr('id')=='mColorPickerTransparent')$.fn.mColorPicker.color='transparent';else if(!$(this).hasClass('mPastColor'))$.fn.mColorPicker.color=$.fn.mColorPicker.whichColor(e.pageX-offset.left,e.pageY-offset.top+(($(this).attr('id')=='mColorPickerImgGray')?128:0),hex);$.fn.mColorPicker.setInputColor(id,$.fn.mColorPicker.color);}).click(function(){$.fn.mColorPicker.colorPicked(id);});$('#mColorPickerInput').bind('keyup',function(e){try{$.fn.mColorPicker.color=$('#mColorPickerInput').val();$.fn.mColorPicker.setInputColor(id,$.fn.mColorPicker.color);if(e.which==13)$.fn.mColorPicker.colorPicked(id);}catch(r){}}).bind('blur',function(){$.fn.mColorPicker.setInputColor(id,$.fn.mColorPicker.currentColor);});$('#mColorPickerWrapper').bind('mouseleave',function(){$.fn.mColorPicker.setInputColor(id,$.fn.mColorPicker.currentColor);});};$.fn.mColorPicker.setInputColor=function(id,color){var image=(color=='transparent')?"url('"+$o.imageFolder+"grid.gif')":'',textColor=$.fn.mColorPicker.textColor(color);if($('#'+id).attr('data-text')||$('#'+id).prop('text'))$("#icp_"+id).css({'background-color':color,'background-image':image});$("#"+id).val(color).css({'background-color':color,'background-image':image,'color':textColor}).trigger('change');$("#mColorPickerInput").val(color);};$.fn.mColorPicker.textColor=function(val){if(typeof val=='undefined'||val=='transparent')return"black";val=$.fn.mColorPicker.RGBtoHex(val);return(parseInt(val.substr(1,2),16)+parseInt(val.substr(3,2),16)+parseInt(val.substr(5,2),16)<400)?'white':'black';};$.fn.mColorPicker.setCookie=function(name,value,days){var cookie_string=name+"="+escape(value),expires=new Date();expires.setDate(expires.getDate()+days);cookie_string+="; expires="+expires.toGMTString();document.cookie=cookie_string;};$.fn.mColorPicker.getCookie=function(name){var results=document.cookie.match('(^|;) ?'+name+'=([^;]*)(;|$)');if(results)return(unescape(results[2]));else return null;};$.fn.mColorPicker.colorPicked=function(id){$.fn.mColorPicker.closePicker();if($.fn.mColorPicker.init.enhancedSwatches)$.fn.mColorPicker.addToSwatch();$("#"+id).trigger('colorpicked',[id,$('#mColorPickerInput').val()]);};$.fn.mColorPicker.addToSwatch=function(color){var swatch=[]
  2219. i=0;if(typeof color=='string')$.fn.mColorPicker.color=color.toLowerCase();$.fn.mColorPicker.currentValue=$.fn.mColorPicker.currentColor=$.fn.mColorPicker.color;if($.fn.mColorPicker.color!='transparent')swatch[0]=$.fn.mColorPicker.color.toLowerCase();$('.mPastColor').each(function(){$.fn.mColorPicker.color=$(this).css('background-color').toLowerCase();if($.fn.mColorPicker.color!=swatch[0]&&$.fn.mColorPicker.RGBtoHex($.fn.mColorPicker.color)!=swatch[0]&&$.fn.mColorPicker.hexToRGB($.fn.mColorPicker.color)!=swatch[0]&&swatch.length<10)swatch[swatch.length]=$.fn.mColorPicker.color;$(this).css('background-color',swatch[i++])});if($.fn.mColorPicker.init.enhancedSwatches)$.fn.mColorPicker.setCookie('swatches',swatch.join('||'),365);};$.fn.mColorPicker.whichColor=function(x,y,hex){var colorR=colorG=colorB=255;if(x<32){colorG=x*8;colorB=0;}else if(x<64){colorR=256-(x-32)*8;colorB=0;}else if(x<96){colorR=0;colorB=(x-64)*8;}else if(x<128){colorR=0;colorG=256-(x-96)*8;}else if(x<160){colorR=(x-128)*8;colorG=0;}else{colorG=0;colorB=256-(x-160)*8;}
  2220. if(y<64){colorR+=(256-colorR)*(64-y)/64;colorG+=(256-colorG)*(64-y)/64;colorB+=(256-colorB)*(64-y)/64;}else if(y<=128){colorR-=colorR*(y-64)/64;colorG-=colorG*(y-64)/64;colorB-=colorB*(y-64)/64;}else if(y>128){colorR=colorG=colorB=256-(x/192*256);}
  2221. colorR=Math.round(Math.min(colorR,255));colorG=Math.round(Math.min(colorG,255));colorB=Math.round(Math.min(colorB,255));if(hex=='true'){colorR=colorR.toString(16);colorG=colorG.toString(16);colorB=colorB.toString(16);if(colorR.length<2)colorR=0+colorR;if(colorG.length<2)colorG=0+colorG;if(colorB.length<2)colorB=0+colorB;return"#"+colorR+colorG+colorB;}
  2222. return"rgb("+colorR+', '+colorG+', '+colorB+')';};$.fn.mColorPicker.RGBtoHex=function(color){color=color.toLowerCase();if(typeof color=='undefined')return'';if(color.indexOf('#')>-1&&color.length>6)return color;if(color.indexOf('rgb')<0)return color;if(color.indexOf('#')>-1){return'#'+color.substr(1,1)+color.substr(1,1)+color.substr(2,1)+color.substr(2,1)+color.substr(3,1)+color.substr(3,1);}
  2223. var hexArray=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],decToHex="#",code1=0;color=color.replace(/[^0-9,]/g,'').split(",");for(var n=0;n<color.length;n++){code1=Math.floor(color[n]/16);decToHex+=hexArray[code1]+hexArray[color[n]-code1*16];}
  2224. return decToHex;};$.fn.mColorPicker.hexToRGB=function(color){color=color.toLowerCase();if(typeof color=='undefined')return'';if(color.indexOf('rgb')>-1)return color;if(color.indexOf('#')<0)return color;var c=color.replace('#','');if(c.length<6)c=c.substr(0,1)+c.substr(0,1)+c.substr(1,1)+c.substr(1,1)+c.substr(2,1)+c.substr(2,1);return'rgb('+parseInt(c.substr(0,2),16)+', '+parseInt(c.substr(2,2),16)+', '+parseInt(c.substr(4,2),16)+')';};$(document).ready(function(){if($.fn.mColorPicker.init.replace){$('input[data-mcolorpicker!="true"]').filter(function(){return($.fn.mColorPicker.init.replace=='[type=color]')?this.getAttribute("type")=='color':$(this).is($.fn.mColorPicker.init.replace);}).mColorPicker();$.fn.mColorPicker.liveEvents();}});})(jQuery);$(document).ready(function(){var tabs={photos_url:$('.info-user a[data-tab="photos"]').attr('href'),settings_url:$('.info-user a[data-tab="settings"]').attr('href'),settings_button:$('.info-user a[data-tab="settings"]'),contest_url:$('.info-user a[data-tab="contest"]').attr('href'),tab_handles:{photos:null,settings:null,contest:null,token_stats:$(".info-user div.token_stats"),share_and_earn:$(".info-user div.share_and_earn"),leaderboard:$(".info-user div.leaderboard"),bio:$(".info-user div.bio")},init:function(){$(".info-user .buttons li a").click(tabs.on_tab_button_click);$(".private_settings .value").click(tabs.on_private_settings_clicked);$(".group_show_disabled a").click(tabs.on_groupshow_settings_clicked);},on_groupshow_settings_clicked:function(){tabs._disable_tabs();tabs.settings_button.parent().addClass('active');tabs._show_settings_tab(function(){$('#id_allow_group_shows').focus();});return false;},on_private_settings_clicked:function(){tabs._disable_tabs();tabs.settings_button.parent().addClass('active');tabs._show_settings_tab(function(){$('#id_allow_private_shows').focus();});return false;},on_tab_button_click:function(event){tabs._disable_tabs();$(this).parent().addClass('active');if($(this).data('tab')=='bio'){tabs.tab_handles.bio.show();}else if($(this).data('tab')=='photos'){tabs.refresh_photos();}else if($(this).data('tab')=='settings'){tabs.refresh_settings();}else if($(this).data('tab')=='contest'){tabs.refresh_contest();}else if($(this).data('tab')=='token_stats'){tabs._show_token_stats();}else if($(this).data('tab')=='share_and_earn'){tabs._show_share_and_earn();}else if($(this).data('tab')=='leaderboard'){tabs._show_leaderboard();}
  2225. return false;},refresh_photos:function(){if(tabs.tab_handles.photos){tabs.tab_handles.photos.remove();tabs.tab_handles.photos=null;}
  2226. tabs._show_photos_tab();},refresh_contest:function(){if(tabs.tab_handles.contest){tabs.tab_handles.contest.remove();tabs.tab_handles.contest=null;}
  2227. tabs._show_contest_tab();},refresh_settings:function(callback){if(tabs.tab_handles.settings){tabs.tab_handles.settings.remove();tabs.tab_handles.settings=null;}
  2228. tabs._show_settings_tab(callback);},_show_leaderboard:function(){tabs._load_tab(tabs.tab_handles.leaderboard,$(".info-user .buttons a[data-tab='leaderboard']").attr('href'));},_show_token_stats:function(){tabs._load_tab(tabs.tab_handles.token_stats,$(".info-user .buttons a[data-tab='token_stats']").attr('href'),function(){tabs.tab_handles.token_stats.find('.refreshstats').click(tabs._show_token_stats);tabs.tab_handles.token_stats.find('form').submit(tabs._on_token_transfer);tabs.tab_handles.token_stats.find('.account_activity').scroll(tabs._on_token_stats_scroll);});},_on_token_stats_scroll:function(){var $this=$(this);if($this.scrollTop()+300>=this.scrollHeight-$this.height()){$this.find("a.endless_more").click();}},_on_token_transfer:function(){var num_tokens=parseInt($(this).find("#id_transfer_amount").val());var token_balance=parseInt(tabs.tab_handles.token_stats.find('.token_balance').text());var cash_amount=num_tokens*0.05;if(isNaN(num_tokens)|num_tokens<1){alert("Invalid token amount.");return false;}
  2229. if(num_tokens>token_balance){alert("Insufficient tokens.");return false;}
  2230. var msg=interpolate(gettext("Convert %(num_tokens)s to \$%(cash_amount)s"),{num_tokens:num_tokens,cash_amount:cash_amount},true);return confirm(msg);},_show_share_and_earn:function(){tabs._load_tab(tabs.tab_handles.share_and_earn,$(".info-user .buttons a[data-tab='share_and_earn']").attr('href'));},_load_tab:function(tab,target,func){tab.show();tab.html(gettext("loading . . ."));if(func){tab.load(target,func);}else{tab.load(target);}},_show_photos_tab:function(){if(tabs.tab_handles.photos===null){var html="<div class='bottompanel fixedheightbottompanel photopages'>"+gettext("loading . . .")+"</div>";tabs.tab_handles.photos=$(html);tabs.tab_handles.bio.after(tabs.tab_handles.photos);tabs.tab_handles.photos.load(tabs.photos_url,function(){tabs.tab_handles.photos.scroll(tabs._on_photos_scroll);tabs.tab_handles.photos.find('.refreshphotos').click(tabs.refresh_photos);});}else{tabs.tab_handles.photos.show();}},_show_settings_tab:function(callback){if(tabs.tab_handles.settings===null){var html="<div class='bottompanel accountsettings'>"+gettext("loading . . .")+"</div>";tabs.tab_handles.settings=$(html);tabs.tab_handles.bio.after(tabs.tab_handles.settings);tabs.tab_handles.settings.load(tabs.settings_url,function(){tabs._init_settings_form();if(callback){callback();}});}else{tabs.tab_handles.settings.show();if(callback){callback();}}},_init_settings_form:function(){tabs.tab_handles.settings.find('a').attr('target','_blank');tabs.tab_handles.settings.find('form').submit(tabs._on_settings_submit);tabs.tab_handles.settings.find('#id_block_from_countries').listselect({listTitle:gettext('Able to view'),selectedTitle:gettext('Blocked countries')});tabs.tab_handles.settings.find('#id_block_from_states').listselect({listTitle:gettext('Able to view'),selectedTitle:gettext('Blocked states')});},_on_settings_submit:function(){$.ajax({type:'POST',url:$(this).attr('action'),data:$(this).serialize(),dataType:'json',cache:false,success:function(data){tabs.tab_handles.settings.html(data.html);tabs._init_settings_form();if(data.result=='success'){alert(gettext("Settings saved"));}
  2231. return false;}});return false;},_show_contest_tab:function(){if(tabs.tab_handles.contest===null){var html="<div class='bottompanel conteststats'>"+gettext("loading . . .")+"</div>";tabs.tab_handles.contest=$(html);tabs.tab_handles.bio.after(tabs.tab_handles.contest);tabs.tab_handles.contest.load(tabs.contest_url,function(){tabs.tab_handles.contest.find('.refreshstats').click(tabs.refresh_contest);});}else{tabs.tab_handles.contest.show();}},_on_photos_scroll:function(){var $this=$(this);if($this.scrollTop()+500>=this.scrollHeight-$this.height()){$this.find("a.endless_more").click();}},_disable_tabs:function(){$(".info-user .buttons li.active").removeClass('active');$(".info-user > div").hide();$(".info-user .headline").show();}};tabs.init();var bio={bio_div:$(document).find('div.bio'),init:function(){$('a.editbio').live('click',bio.on_edit_click);},on_edit_click:function(){bio.bio_div.load($(this).attr('href'),bio._init_form);return false;},on_form_submit:function(){var next=$(this).find('input[name="next"]').val();$.ajax({type:'POST',url:$(this).attr('action'),data:$(this).serialize(),dataType:'json',cache:false,success:function(data){if(data.result=='success'){bio.bio_div.load(next);}else{bio.bio_div.html(data.html);bio._init_form();}
  2232. return false;}});return false;},_init_form:function(){bio.bio_div.find('textarea').attr('rows','1');bio.bio_div.find('textarea').elastic();bio.bio_div.find('form').submit(bio.on_form_submit);bio.bio_div.find('.canceleditbio').click(bio._on_cancel_edit_click);},_on_cancel_edit_click:function(){bio.bio_div.load($(this).attr('href'));return false;}};bio.init();var follow={on_follow_click:function(){var link=$(this);if(login_required()){return false;}
  2233. $.ajax({url:link.data('followurl'),cache:false,success:function(){link.parent().removeClass('button_follow');link.parent().addClass('button_unfollow');link.html(link.data('unfollowtext'));}});return false;},on_unfollow_click:function(){var link=$(this);$.ajax({url:link.data('unfollowurl'),cache:false,success:function(){link.parent().removeClass('button_unfollow');link.parent().addClass('button_follow');link.html(link.data('followtext'));}});return false;}};$(".button_follow a").live('click',follow.on_follow_click);$(".button_unfollow a").live('click',follow.on_unfollow_click);var report={_div_overlay:$("#report_popup"),on_cancel:function(){report._clear_and_close();return false;},on_submit:function(){var $this=$(this);if($this.find('select[name="category"]').val()===""){alert(gettext("Please choose a category."));return false;}
  2234. $.ajax({type:'POST',url:$this.attr('action'),data:$this.serialize(),dataType:'json',cache:false,success:function(data){if(data['result']==='success'){report._clear_and_close();alert(gettext("Your abuse report has been submitted."));}else{alert("An error occurred.");}}});return false;},overlay_toggle:function(){if(login_required()){return false;}
  2235. report._div_overlay.toggle();if(report._div_overlay.is(":visible")){report._div_overlay.find('textarea').focus();report._div_overlay.find('textarea').select();}},init:function(){$("#report_popup_link").click(report.overlay_toggle);report._div_overlay.find(".button_abuse_cancel a").click(report.on_cancel);report._div_overlay.find(".button_abuse_report a").click(function(){report._div_overlay.find("form").submit();return false;});report._div_overlay.find("form").submit(report.on_submit);$(".disputerecording").live('click',function(){var msg=gettext("Are the reports that this is a recording false?\n\nPlease only vote if you have confirmed that this cam is live.\n\nAsk something like \"hold up 2 fingers to prove you are live\" first!");if(confirm(msg)){$.ajax({type:'POST',url:$("#report_popup form").attr('action'),data:{'category':'recordingdispute'},dataType:'json',cache:false,success:function(data){if(data['result']==='success'){report._clear_and_close();alert(gettext("Your report has been submitted."));}else{alert("An error occurred.");}}});}});},_clear_and_close:function(){report._div_overlay.hide();report._div_overlay.find('textarea').val("");}};report.init();var dismisscookiename='dsmn4';$('a.dismiss_notice').click(function(){var d=new Date;d.setTime(d.getTime()+1000*60*60*24*60);$.cookie(dismisscookiename,'1',{expires:d,path:'/'});$('.dismissable_notice').hide();return false;});if($.cookie(dismisscookiename)=='1'){$('.dismissable_notice').hide();}
  2236. $("a.deletephotolink").live('click',function(){var deletelink=$(this);if(confirm(gettext("Are you sure you want to delete?"))){$.post(deletelink.attr('href'),function(){deletelink.closest('.image_container').remove()});}
  2237. return false;});$("a.disablephotoslink, a.enablephotoslink").live('click',function(){if(confirm(gettext("Are you sure?"))){$.post($(this).attr('href'),{'foo':'bar'},function(){tabs.refresh_photos();});}
  2238. return false;});$('a[rel*=facebox]').live('mousedown',function(){$(this).facebox();});});
Add Comment
Please, Sign In to add comment