mirror of
https://github.com/Mibew/tray.git
synced 2025-01-23 18:40:33 +03:00
59fd9f1fa8
git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@415 c66351dc-e62f-0410-b875-e3a5c0b9693f
1 line
7.7 KiB
JavaScript
1 line
7.7 KiB
JavaScript
var nt={qt:function(rt){if(rt.contentDocument){return rt.contentDocument;} else if(rt.contentWindow){return rt.contentWindow.document;} else if(rt.document){return rt.document;} else{return null;} } ,st:function(rt){var tt=this.qt(rt);tt.open();tt.write("<html><head>");tt.write("<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\""+ut.ht+"/chat.css\" />");tt.write("</head><body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400' marginwidth='0' marginheight='0' leftmargin='0' rightmargin='0' topmargin='0' bottommargin='0'>");tt.write("<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message' id='content'></td></tr></table><a id='bottom'/>");tt.write("</body></html>");tt.close();rt.onload=function(){if(rt.it){nt.qt(rt).getElementById('content').innerHTML+=rt.it;nt.jt(rt);} } ;} ,kt:function(rt,lt){var ot=this.qt(rt).getElementById('content');if(ot==null){if(!rt.it)rt.it="";rt.it+=lt;} else{ot.innerHTML+=lt;} } ,jt:function(rt){var pt=this.qt(rt).getElementById('bottom');if(myAgent=='opera'){rt.contentWindow.scrollTo(0,this.qt(rt).getElementById('content').clientHeight);} else if(pt)pt.scrollIntoView(false);} } ;sq.dt=mn.nn();mn.sn(sq.dt,sq.lq,{qn:function(pq){this.oq(pq);this.pq.onComplete=this.et.on(this);this.pq.jr=this.ft.on(this);this.pq.hr=this._q.on(this);this.pq.timeout=(3100+1900);this.gt={} ;this.frequency=(this.pq.frequency||2);this.at=0;this.bt=true;this.ct=true;this.vt=true;this.wt=this.pq.xt!=null;nt.st(this.pq.yt);if(this.pq.xt){this.pq.xt.onkeydown=this.zt.on(this);this.pq.xt.onfocus=(function(){this.vt=true;} ).on(this);this.pq.xt.onblur=(function(){this.vt=false;} ).on(this)} this.$t();} ,ft:function(_t,mu){this.nu("offline, reconnecting");this.qu();this.ru=setTimeout(this.$t.on(this),01750);} ,_q:function(_t){this.nu("timeout, reconnecting");this.qu();this.ru=setTimeout(this.$t.on(this),(642+358));} ,su:function(tu){this.pq.fq='act='+tu+'&thread='+(this.pq.threadid||0)+'&token='+(this.pq.token||0)+'&lastid='+(this.pq.uu||0);if(this.pq.user)this.pq.fq+="&user=true";if(tu=='refresh'&&this.pq.xt&&this.pq.xt.value!='')this.pq.fq+="&typed=1";} ,hu:function(iu){if(this.pq.xt)this.pq.xt.disabled=!iu;} ,qu:function(){this.hu(true);if(this.gt.pq)this.gt.pq.onComplete=undefined;clearTimeout(this.ru);} ,$t:function(){this.su("refresh");this.gt=new sq.vq(this.pq.servl,this.pq);} ,et:function(hq){try{this.hu(true);this.bt=true;var ju=sq.uq(hq);if(ju&&ju.tagName=='thread'){this.ku(ju);} else{this.lu(hq,ju,'refresh messages failed');} } catch(e){} this.ct=false;this.ru=setTimeout(this.$t.on(this),this.frequency*01750);} ,ou:function(pu){if(pu==""||!this.bt){return;} this.bt=false;this.qu();this.ct=true;this.su("post");var du={} .un(this.pq);du.fq+="&message="+encodeURIComponent(pu);du.onComplete=(function(eu){this.et(eu);if(this.pq.xt){this.pq.xt.value='';this.pq.xt.focus();} } ).on(this);if(myRealAgent!='opera')this.hu(false);this.gt=new sq.vq(this.pq.servl,du);} ,fu:function(gu){this.ct=true;new sq.vq(this.pq.servl,{fq:'act=rename&thread='+(this.pq.threadid||0)+'&token='+(this.pq.token||0)+'&name='+encodeURIComponent(gu)} );} ,au:function(hq){var ju=sq.uq(hq);if(ju&&ju.tagName=='closed'){setTimeout('window.close()',03720);} else{this.lu(hq,ju,'cannot close');} } ,bu:function(){var cu='act=close&thread='+(this.pq.threadid||0)+'&token='+(this.pq.token||0);if(this.pq.user)cu+="&user=true";new sq.vq(this.pq.servl,{fq:cu,onComplete:this.au.on(this)} );} ,vu:function(wu,xt){var xu=qs.us(xt);nt.kt(wu,xu);} ,yu:function(zu){if($("typingdiv")){$("typingdiv").style.display=zu?'inline':'none';} } ,$u:function(_u){var mh=qs.us(_u);if(this.pq._u&&this.pq.user){this.pq._u.innerHTML=mh!=""?"<img src=\""+ut.ht+"/images/free.gif\" width=\"7\" height=\"1\" border=\"0\" alt=\"\" /><img src=\""+mh+"\" border=\"0\" alt=\"\"/>":"";} } ,ku:function(ju){var nh=false;var qh=this.pq.yt;var rh=qs.ks(ju,"lastid");if(rh){this.pq.uu=rh;} var sh=qs.ks(ju,"typing");if(sh){this.yu(sh=='1');} var th=qs.ks(ju,"canpost");if(th){if(th=='1'&&!this.wt||this.wt&&th!='1'){window.location.href=window.location.href;} } for(var i=0;i<ju.childNodes.length;i++){var uh=ju.childNodes[i];if(uh.tagName=='message'){nh=true;this.vu(qh,uh);} else if(uh.tagName=='avatar'){this.$u(uh);} } if(window.location.search.indexOf('trace=on')>=0){var iu="updated";if(this.at>0){var hh=((new Date()).getTime()-this.at)/(691+309);iu=iu+", "+hh+" secs";if(hh>012){alert(iu);} } this.at=(new Date()).getTime();this.nu(iu);} else{this.ih();} if(nh){nt.jt(this.pq.yt);if(!this.ct){var jh=$('soundimg');if(jh==null||jh.className.match(new RegExp("\\bisound\\b"))){$s(ut.ht+'/sounds/new_message.wav');} } if(!this.vt){window.focus();} } } ,zt:function(k){if(k){kh=k.ctrlKey;k=k.which;} else{k=event.keyCode;kh=event.ctrlKey;} if(this.pq.xt&&((k==015&&(kh||myRealAgent=='opera'))||(k==012))){var lh=this.pq.xt.value;if(myRealAgent=='opera'){lh=lh.replace(/[\r\n]+$/,'');} this.ou(lh);return false;} return true;} ,lu:function(hq,ju,oh){if(ju&&ju.tagName=='error'){this.nu(qs.rs(ju,"descr"));} else{this.nu("reconnecting");} } ,ph:function(k){if($("engineinfo")){$("engineinfo").style.display='inline';$("engineinfo").innerHTML=k;} } ,nu:function(k){if(this.dh)clearTimeout(this.dh);this.ph(k);this.dh=setTimeout(this.ih.on(this),07640);} ,ih:function(){$("engineinfo").style.display='none';} } );eh=mn.nn();eh.prototype={qn:function(pq){this.pq=pq;this.fh=0;if(this.pq.gh&&this.pq.ah&&this.pq.bh){this.pq.bh.onmousedown=this.ch.on(this);this.pq.bh.onmouseup=this.vh.on(this);this.pq.bh.onmousemove=this.wh.on(this);} } ,ch:function(e){var or=e||event;if(this.pq.bh.setCapture)this.pq.bh.setCapture();this.xh=this.pq.gh.style.pixelHeight||this.pq.gh.clientHeight;this.yh=or.screenY;this.pq.zh=this.pq.gh.style.pixelHeight+this.pq.ah.clientHeight-this.pq.$h;this.fh=1;} ,vh:function(){if(this.fh){if(this.pq.bh.releaseCapture)this.pq.bh.releaseCapture();this.fh=0;} } ,wh:function(e){var or=e||event;if(this.fh){var _h=this.xh-(or.screenY-this.yh);if(_h>this.pq.zh)_h=this.pq.zh;else if(_h<this.pq.mi)_h=this.pq.mi;if(myAgent=='moz')this.pq.gh.style.height=_h+'px';else this.pq.gh.style.pixelHeight=_h;} } } ;var ut={ni:{} ,qi:{} ,ri:function(){ut.ni.fu($('uname').value);$('changename1').style.display='none';$('changename2').style.display='inline';$('unamelink').innerHTML=$('uname').value;} ,si:function(){$('changename1').style.display='inline';$('changename2').style.display='none';} } ;er.lr({'#postmessage a':function(ti){ti.onclick=function(){var xt=$('msgwnd');if(xt)ut.ni.ou(xt.value);} ;} ,'a#sndmessagelnk':function(ti){if(myRealAgent=='opera'){ti.innerHTML=ti.innerHTML.replace('Ctrl-','');} } ,'select#predefined':function(ti){ti.onchange=function(){var xt=$('msgwnd');if(this.selectedIndex!=0){xt.value=this.options[this.selectedIndex].innerText||this.options[this.selectedIndex].innerHTML;} this.selectedIndex=0;xt.focus();} ;} ,'div#changename2 a':function(ti){ti.onclick=function(){ut.si();return false;} ;} ,'div#changename1 a':function(ti){ti.onclick=function(){ut.ri();return false;} ;} ,'div#changename1 input#uname':function(ti){ti.onkeydown=function(e){var or=e||event;if(or.keyCode==(11+2)){ut.ri();} } ;} ,'a#refresh':function(ti){ti.onclick=function(){ut.ni.qu();ut.ni.$t();} ;} ,'a#togglesound':function(ti){ti.onclick=function(){var jh=$('soundimg');if(!jh){return;} if(jh.className.match(new RegExp("\\bisound\\b"))){jh.className="tplimage inosound";} else{jh.className="tplimage isound";} var ui=$('msgwnd');if(ui)ui.focus();} ;} ,'a.closethread':function(ti){ti.onclick=function(){ut.ni.bu();} ;} } );kr.lr(window,'onload',function(){ut.ht=threadParams.wroot;ut.qi=new eh({bh:$("spl1"),gh:$("msgwndtd"),ah:$("chatwndtd"),mi:(21+9),$h:(29+1)} );ut.ni=new sq.dt(({yt:myRealAgent=='safari'?self.frames[0]:$("chatwnd"),_u:$("avatarwnd"),xt:$("msgwnd")} ).un(threadParams||{} ));} ); |