127){do{B+=(C=p.charCodeAt(z++))}while(C==255)}while(--B>=0){h(F,A++)}}f(l.spare,H,I)}}}}}}l.hold=function(n){if(l.holding==n){return}l.holding=n;l.canvas.fillStyle="#000000";l.canvas.fillRect(0,0,l.width,l.height);if(l.holding==false){if((l.canvas.canvas.width!=l.width)||(l.canvas.canvas.height!=l.height)){l.canvas.canvas.width=l.width;l.canvas.canvas.height=l.height;if(l.onScreenSizeChange!=null){l.onScreenSizeChange(l,l.ScreenWidth,l.ScreenHeight)}}l.Send(String.fromCharCode(3,0,0,0,0,0)+ShortToStr(l.width)+ShortToStr(l.height))}else{l.UnGrabMouseInput();l.UnGrabKeyInput()}};function f(n,o,p){if(l.holding==true){return}l.canvas.putImageData(n,o,p)}function h(q,n){var o=n*4;if(l.bpp==1){l.spare.data[o++]=q&224;l.spare.data[o++]=(q&28)<<3;l.spare.data[o++]=b((q&3)<<6)}else{l.spare.data[o++]=(q>>8)&248;l.spare.data[o++]=(q>>3)&252;l.spare.data[o++]=(q&31)<<3}l.spare.data[o]=255}function b(n){return(n>127)?(n+32):n}function g(){if(l.holding==true){return}l.send(String.fromCharCode(3,1,0,0,0,0)+ShortToStr(l.rwidth)+ShortToStr(l.rheight))}l.Start=function(){l.state=0;l.acc="";l.ZRLEfirst=1;l.onKvmDataPending=[];l.onKvmDataAck=-1;l.kvmDataSupported=false;for(var n in l.sparecache){delete l.sparecache[n]}};l.Stop=function(){l.UnGrabMouseInput();l.UnGrabKeyInput();l.parent.Stop()};l.send=function(n){l.parent.send(n)};function c(n,o){if(!o){o=window.event}var p=o.keyCode,q=p;if(o.shiftKey==false&&p>=65&&p<=90){q=p+32}if(p>=112&&p<=124){q=p+65358}if(p==8){q=65288}if(p==9){q=65289}if(p==13){q=65293}if(p==16){q=65505}if(p==17){q=65507}if(p==18){q=65513}if(p==27){q=65307}if(p==33){q=65365}if(p==34){q=65366}if(p==35){q=65367}if(p==36){q=65360}if(p==37){q=65361}if(p==38){q=65362}if(p==39){q=65363}if(p==40){q=65364}if(p==45){q=65379}if(p==46){q=65535}if(p>=96&&p<=105){q=p-48}if(p==106){q=42}if(p==107){q=43}if(p==109){q=45}if(p==110){q=46}if(p==111){q=47}if(p==186){q=59}if(p==187){q=61}if(p==188){q=44}if(p==189){q=45}if(p==190){q=46}if(p==191){q=47}if(p==192){q=96}if(p==219){q=91}if(p==220){q=92}if(p==221){q=93}if(p==222){q=39}l.sendkey(q,n);return l.haltEvent(o)}l.sendkey=function(p,n){if(typeof p=="object"){for(var o in p){l.sendkey(p[o][0],p[o][1])}}else{l.send(String.fromCharCode(4,n,0,0)+IntToStr(p))}};function k(n){if(n.length<8){return 0}var p=ReadInt(l.acc,4)+8;if(n.length=16)&&(o.substring(0,15)=="\0KvmDataChannel")){if(l.kvmDataSupported==false){l.kvmDataSupported=true;console.log("KVM Data Channel Supported.")}if(((l.onKvmDataAck==-1)&&(o.length==16))||(o.charCodeAt(15)!=0)){l.onKvmDataAck=true}if(o.length>=16){l.onKvmData(o.substring(16))}if((l.onKvmDataAck==true)&&(l.onKvmDataPending.length>0)){l.sendKvmData(l.onKvmDataPending.shift())}}}return p}l.sendKvmData=function(n){if(l.onKvmDataAck!==true){l.onKvmDataPending.push(n)}else{n="\0KvmDataChannel\0"+n;l.send(String.fromCharCode(6,0,0,0)+IntToStr(n.length)+n);l.onKvmDataAck=false}};l.sendKeepAlive=function(){if(l.lastKeepAlive=1;aL--){if(av[aL]!=0){break}}if(aQ>aL){aQ=aL}if(aL==0){aC={op:64,bits:1,val:0};aS[aU++]=aC;aS[aU++]=aC;if(aV==t){aR.distbits=1}else{aR.lenbits=1}aR.next=aU;return 0}for(aN=1;aN0&&(aV==g||aL!=1)){aR.next=aU;return -1}aP[1]=0;for(aG=1;aG=z)||(aV==t&&aW>=y)){aR.next=aU;return 1}for(;;){aC={op:0,bits:aG-ax,val:0};if(aX[aT]ay){aC.op=az[aA+aX[aT]];aC.val=aq[ar+aX[aT]]}else{aC.op=32+64}}aE=1<<(aG-ax);aB=1<>>ax)+aB]=aC}while(aB!=0);aE=1<<(aG-1);while(aD&aE){aE>>>=1}if(aE!=0){aD&=aE-1;aD+=aE}else{aD=0}aT++;if(--(av[aG])==0){if(aG==aL){break}aG=aH[aI+aX[aT]]}if(aG>aQ&&(aD&aK)!=aJ){if(ax==0){ax=aQ}aO+=aN;aw=aG-ax;aF=(1<=z)||(aV==t&&aW>=y)){aR.next=aU;return 1}aJ=aD&aK;aS[aU+aJ]={op:aw,bits:aQ,val:aO-aU}}}if(aD!=0){aS[aO+aD]={op:64,bits:aG-ax,val:0}}aR.next=aU+aW;if(aV==t){aR.distbits=aQ}else{aR.lenbits=aQ}return 0}function H(aN,aL){var aM;var aC;var aI;var aD;var aK;var aq;var ax;var aR;var aO;var aQ;var aP;var aB;var ar;var at;var aE;var au;var aH;var aw;var aA;var aJ;var aF;var av;var az=-1;var ay=-1;aM=aN.state;aC=aN.input_data;aI=aN.next_in;aD=aI+aN.avail_in-5;aK=aN.next_out;aq=aK-(aL-aN.avail_out);ax=aK+(aN.avail_out-257);aR=aM.wsize;aO=aM.whave;aQ=aM.wnext;aP=aM.window;aB=aM.hold;ar=aM.bits;at=aM.codes;aE=aM.lencode;au=aM.distcode;aH=(1<>>=aJ;ar-=aJ;aJ=aA.op;if(aJ==0){aN.output_data+=String.fromCharCode(aA.val);aK++}else{if(aJ&16){aF=aA.val;aJ&=15;if(aJ){if(ar>>=aJ;ar-=aJ}if(ar<15){aB+=(aC.charCodeAt(aI++)&255)<>>=aJ;ar-=aJ;aJ=aA.op;if(aJ&16){av=aA.val;aJ&=15;if(ar>>=aJ;ar-=aJ;aJ=aK-aq;if(av>aJ){aJ=av-aJ;if(aJ>aO){if(aM.sane){aN.msg="invalid distance too far back";aM.mode=a;break loop}}az=0;ay=-1;if(aQ==0){az+=aR-aJ;if(aJ=0){aN.output_data+=aP.substring(az,az+aF);aK+=aF;az+=aF}else{var aG=aF;if(aG>aK-ay){aG=aK-ay}aN.output_data+=aN.output_data.substring(ay,ay+aG);aK+=aG;aF-=aG;ay+=aG;aK+=aF;while(aF>2){aN.output_data+=aN.output_data.charAt(ay++);aN.output_data+=aN.output_data.charAt(ay++);aN.output_data+=aN.output_data.charAt(ay++);aF-=3}if(aF){aN.output_data+=aN.output_data.charAt(ay++);if(aF>1){aN.output_data+=aN.output_data.charAt(ay++)}}}}else{if((aJ&64)==0){aA=at[au+(aA.val+(aB&((1<>>3;aI-=aF;ar-=aF<<3;aB&=(1<>>4)+1;if(at<48){at&=15}}if(au==1&&(typeof ZLIB.adler32==="function")){ar.checksum_function=ZLIB.adler32}else{if(au==2&&(typeof ZLIB.crc32==="function")){ar.checksum_function=ZLIB.crc32}else{ar.checksum_function=e}}if(at&&(at<8||at>15)){return ZLIB.Z_STREAM_ERROR}if(aq.window&&aq.wbits!=at){aq.window=null}aq.wrap=au;aq.wbits=at;aq.wsize=0;aq.whave=0;aq.wnext=0;return ZLIB.inflateResetKeep(ar)};ZLIB.inflateInit=function(ar){var aq=new ZLIB.z_stream();aq.state=new J();ZLIB.inflateReset(aq,ar);return aq};ZLIB.inflatePrime=function(at,aq,au){var ar;if(!at||!at.state){return ZLIB.Z_STREAM_ERROR}ar=at.state;if(aq<0){ar.hold=0;ar.bits=0;return ZLIB.Z_OK}if(aq>16||ar.bits+aq>32){return ZLIB.Z_STREAM_ERROR}au&=(1<=ar.wsize){ar.window=at.output_data.substring(aq-ar.wsize)}else{if(ar.whave+aq>>8)&255];ar.state.check=ar.checksum_function(ar.state.check,aq,0,2)}function m(ar,at){var aq=[at&255,(at>>>8)&255,(at>>>16)&255,(at>>>24)&255];ar.state.check=ar.checksum_function(ar.state.check,aq,0,4)}function Z(ar,aq){aq.strm=ar;aq.left=ar.avail_out;aq.next=ar.next_in;aq.have=ar.avail_in;aq.hold=ar.state.hold;aq.bits=ar.state.bits;return aq}function ah(aq){var ar=aq.strm;ar.next_in=aq.next;ar.avail_out=aq.left;ar.avail_in=aq.have;ar.state.hold=aq.hold;ar.state.bits=aq.bits}function P(aq){aq.hold=0;aq.bits=0}function ag(aq){if(aq.have==0){return false}aq.have--;aq.hold+=(aq.strm.input_data.charCodeAt(aq.next++)&255)<>>=aq;ar.bits-=aq}function c(aq){aq.hold>>>=aq.bits&7;aq.bits-=aq.bits&7}function ai(aq){return((aq>>>24)&255)+((aq>>>8)&65280)+((aq&65280)<<8)+((aq&255)<<24)}var I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];ZLIB.inflate=function(aD,at){var aC;var aB;var aq,az;var ar;var av=-1;var au=-1;var aw;var ax;var ay;var aA;if(!aD||!aD.state||(!aD.input_data&&aD.avail_in!=0)){return ZLIB.Z_STREAM_ERROR}aC=aD.state;if(aC.mode==an){aC.mode=ao}aB={};Z(aD,aB);aq=aB.have;az=aB.left;aA=ZLIB.Z_OK;inf_leave:for(;;){switch(aC.mode){case G:if(aC.wrap==0){aC.mode=ao;break}if(!ad(aB,16)){break inf_leave}if((aC.wrap&2)&&aB.hold==35615){aC.check=aD.checksum_function(0,null,0,0);l(aD,aB.hold);P(aB);aC.mode=D;break}aC.flags=0;if(aC.head!==null){aC.head.done=-1}if(!(aC.wrap&1)||((b(aB,8)<<8)+(aB.hold>>>8))%31){aD.msg="incorrect header check";aC.mode=a;break}if(b(aB,4)!=ZLIB.Z_DEFLATED){aD.msg="unknown compression method";aC.mode=a;break}v(aB,4);ay=b(aB,4)+8;if(aC.wbits==0){aC.wbits=ay}else{if(ay>aC.wbits){aD.msg="invalid window size";aC.mode=a;break}}aC.dmax=1<>>8)&1}if(aC.flags&512){l(aD,aB.hold)}P(aB);aC.mode=am;case am:if(!ad(aB,32)){break inf_leave}if(aC.head!==null){aC.head.time=aB.hold}if(aC.flags&512){m(aD,aB.hold)}P(aB);aC.mode=af;case af:if(!ad(aB,16)){break inf_leave}if(aC.head!==null){aC.head.xflags=aB.hold&255;aC.head.os=aB.hold>>>8}if(aC.flags&512){l(aD,aB.hold)}P(aB);aC.mode=A;case A:if(aC.flags&1024){if(!ad(aB,16)){break inf_leave}aC.length=aB.hold;if(aC.head!==null){aC.head.extra_len=aB.hold}if(aC.flags&512){l(aD,aB.hold)}P(aB);aC.head.extra=""}else{if(aC.head!==null){aC.head.extra=null}}aC.mode=B;case B:if(aC.flags&1024){ar=aC.length;if(ar>aB.have){ar=aB.have}if(ar){if(aC.head!==null&&aC.head.extra!==null){ay=aC.head.extra_len-aC.length;aC.head.extra+=aD.input_data.substring(aB.next,aB.next+(ay+ar>aC.head.extra_max?aC.head.extra_max-ay:ar))}if(aC.flags&512){aC.check=aD.checksum_function(aC.check,aD.input_data,aB.next,ar)}aB.have-=ar;aB.next+=ar;aC.length-=ar}if(aC.length){break inf_leave}}aC.length=0;aC.mode=ac;case ac:if(aC.flags&2048){if(aB.have==0){break inf_leave}if(aC.head!==null&&aC.head.name===null){aC.head.name=""}ar=0;do{ay=aD.input_data.charAt(aB.next+ar);ar++;if(ay==="\0"){break}if(aC.head!==null&&aC.length>>9)&1;aC.head.done=1}aD.adler=aC.check=aD.checksum_function(0,null,0,0);aC.mode=an;break;case p:if(!ad(aB,32)){break inf_leave}aD.adler=aC.check=ai(aB.hold);P(aB);aC.mode=o;case o:if(aC.havedict==0){ah(aB);return ZLIB.Z_NEED_DICT}aD.adler=aC.check=aD.checksum_function(0,null,0,0);aC.mode=an;case an:if(at==ZLIB.Z_BLOCK||at==ZLIB.Z_TREES){break inf_leave}case ao:if(aC.last){c(aB);aC.mode=d;break}if(!ad(aB,3)){break inf_leave}aC.last=b(aB,1);v(aB,1);switch(b(aB,2)){case 0:aC.mode=aj;break;case 1:C(aC);aC.mode=S;if(at==ZLIB.Z_TREES){v(aB,2);break inf_leave}break;case 2:aC.mode=al;break;case 3:aD.msg="invalid block type";aC.mode=a}v(aB,2);break;case aj:c(aB);if(!ad(aB,32)){break inf_leave}if((aB.hold&65535)!=(((aB.hold>>>16)&65535)^65535)){aD.msg="invalid stored block lengths";aC.mode=a;break}aC.length=aB.hold&65535;P(aB);aC.mode=k;if(at==ZLIB.Z_TREES){break inf_leave}case k:aC.mode=j;case j:ar=aC.length;if(ar){if(ar>aB.have){ar=aB.have}if(ar>aB.left){ar=aB.left}if(ar==0){break inf_leave}aD.output_data+=aD.input_data.substring(aB.next,aB.next+ar);aD.next_out+=ar;aB.have-=ar;aB.next+=ar;aB.left-=ar;aC.length-=ar;break}aC.mode=an;break;case al:if(!ad(aB,14)){break inf_leave}aC.nlen=b(aB,5)+257;v(aB,5);aC.ndist=b(aB,5)+1;v(aB,5);aC.ncode=b(aB,4)+4;v(aB,4);if(aC.nlen>286||aC.ndist>30){aD.msg="too many length or distance symbols";aC.mode=a;break}aC.have=0;aC.mode=W;case W:while(aC.haveaC.nlen+aC.ndist){aD.msg="invalid bit length repeat";aC.mode=a;break}while(ar--){aC.lens[aC.have++]=ay}}}if(aC.mode==a){break}if(aC.lens[256]==0){aD.msg="invalid code -- missing end-of-block";aC.mode=a;break}aC.next=0;aC.lencode=aC.next;aC.lenbits=9;aA=K(aC,X);if(aA){aD.msg="invalid literal/lengths set";aC.mode=a;break}aC.distcode=aC.next;aC.distbits=6;aA=K(aC,t);if(aA){aD.msg="invalid distances set";aC.mode=a;break}aC.mode=S;if(at==ZLIB.Z_TREES){break inf_leave}case S:aC.mode=R;case R:if(aB.have>=6&&aB.left>=258){ah(aB);H(aD,az);Z(aD,aB);if(aC.mode==an){aC.back=-1}break}aC.back=0;for(;;){aw=aC.codes[aC.lencode+b(aB,aC.lenbits)];if(aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}if(aw.op&&(aw.op&240)==0){ax=aw;for(;;){aw=aC.codes[aC.lencode+ax.val+(b(aB,ax.bits+ax.op)>>>ax.bits)];if(ax.bits+aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}v(aB,ax.bits);aC.back+=ax.bits}v(aB,aw.bits);aC.back+=aw.bits;aC.length=aw.val;if(aw.op==0){aC.mode=Y;break}if(aw.op&32){aC.back=-1;aC.mode=an;break}if(aw.op&64){aD.msg="invalid literal/length code";aC.mode=a;break}aC.extra=aw.op&15;aC.mode=T;case T:if(aC.extra){if(!ad(aB,aC.extra)){break inf_leave}aC.length+=b(aB,aC.extra);v(aB,aC.extra);aC.back+=aC.extra}aC.was=aC.length;aC.mode=q;case q:for(;;){aw=aC.codes[aC.distcode+b(aB,aC.distbits)];if(aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}if((aw.op&240)==0){ax=aw;for(;;){aw=aC.codes[aC.distcode+ax.val+(b(aB,ax.bits+ax.op)>>>ax.bits)];if((ax.bits+aw.bits)<=aB.bits){break}if(!ag(aB)){break inf_leave}}v(aB,ax.bits);aC.back+=ax.bits}v(aB,aw.bits);aC.back+=aw.bits;if(aw.op&64){aD.msg="invalid distance code";aC.mode=a;break}aC.offset=aw.val;aC.extra=aw.op&15;aC.mode=r;case r:if(aC.extra){if(!ad(aB,aC.extra)){break inf_leave}aC.offset+=b(aB,aC.extra);v(aB,aC.extra);aC.back+=aC.extra}aC.mode=aa;case aa:if(aB.left==0){break inf_leave}ar=az-aB.left;if(aC.offset>ar){ar=aC.offset-ar;if(ar>aC.whave){if(aC.sane){aD.msg="invalid distance too far back";aC.mode=a;break}}if(ar>aC.wnext){ar-=aC.wnext;av=aC.wsize-ar;au=-1}else{av=aC.wnext-ar;au=-1}if(ar>aC.length){ar=aC.length}}else{av=-1;au=aD.next_out-aC.offset;ar=aC.length}if(ar>aB.left){ar=aB.left}aB.left-=ar;aC.length-=ar;if(av>=0){aD.output_data+=aC.window.substring(av,av+ar);aD.next_out+=ar;ar=0}else{aD.next_out+=ar;do{aD.output_data+=aD.output_data.charAt(au++)}while(--ar)}if(aC.length==0){aC.mode=R}break;case Y:if(aB.left==0){break inf_leave}aD.output_data+=String.fromCharCode(aC.length);aD.next_out++;aB.left--;aC.mode=R;break;case d:if(aC.wrap){if(!ad(aB,32)){break inf_leave}az-=aB.left;aD.total_out+=az;aC.total+=az;if(az){aD.adler=aC.check=aD.checksum_function(aC.check,aD.output_data,aD.output_data.length-az,az)}az=aB.left;if((aC.flags?aB.hold:ai(aB.hold))!=aC.check){aD.msg="incorrect data check";aC.mode=a;break}P(aB)}aC.mode=V;case V:if(aC.wrap&&aC.flags){if(!ad(aB,32)){break inf_leave}if(aB.hold!=(aC.total&4294967295)){aD.msg="incorrect length check";aC.mode=a;break}P(aB)}aC.mode=u;case u:aA=ZLIB.Z_STREAM_END;break inf_leave;case a:aA=ZLIB.Z_DATA_ERROR;break inf_leave;case ab:return ZLIB.Z_MEM_ERROR;case ak:default:return ZLIB.Z_STREAM_ERROR}}inf_leave:ah(aB);if(aC.wsize||(az!=aD.avail_out&&aC.mode=0?aq:ar);this.output_data="";this.next_out=0;this.error=ZLIB.inflate(this,at);if(aq>=0){return this.output_data}aw+=this.output_data;if(this.avail_out>0){break}}while(this.error==ZLIB.Z_OK);return aw};ZLIB.z_stream.prototype.inflateReset=function(aq){return ZLIB.inflateReset(this,aq)}}());if(typeof ZLIB==="undefined"){alert("ZLIB is not defined. SRC zlib.js before zlib-adler32.js")}(function(){var c=65521;var d=5552;function b(e,f,j,g){var k;var h;k=(e>>>16)&65535;e&=65535;if(g==1){e+=f.charCodeAt(j)&255;if(e>=c){e-=c}k+=e;if(k>=c){k-=c}return e|(k<<16)}if(f===null){return 1}if(g<16){while(g--){e+=f.charCodeAt(j++)&255;k+=e}if(e>=c){e-=c}k%=c;return e|(k<<16)}while(g>=d){g-=d;h=d>>4;do{e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e}while(--h);e%=c;k%=c}if(g){while(g>=16){g-=16;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e;e+=f.charCodeAt(j++)&255;k+=e}while(g--){e+=f.charCodeAt(j++)&255;k+=e}e%=c;k%=c}return e|(k<<16)}function a(e,f,j,g){var k;var h;k=(e>>>16)&65535;e&=65535;if(g==1){e+=f[j];if(e>=c){e-=c}k+=e;if(k>=c){k-=c}return e|(k<<16)}if(f===null){return 1}if(g<16){while(g--){e+=f[j++];k+=e}if(e>=c){e-=c}k%=c;return e|(k<<16)}while(g>=d){g-=d;h=d>>4;do{e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e}while(--h);e%=c;k%=c}if(g){while(g>=16){g-=16;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e;e+=f[j++];k+=e}while(g--){e+=f[j++];k+=e}e%=c;k%=c}return e|(k<<16)}ZLIB.adler32=function(e,f,h,g){if(typeof f==="string"){return b(e,f,h,g)}else{return a(e,f,h,g)}};ZLIB.adler32_combine=function(e,f,g){var j;var k;var h;if(g<0){return 4294967295}g%=c;h=g;j=e&65535;k=h*j;k%=c;j+=(f&65535)+c-1;k+=((e>>16)&65535)+((f>>16)&65535)+c-h;if(j>=c){j-=c}if(j>=c){j-=c}if(k>=(c<<1)){k-=(c<<1)}if(k>=c){k-=c}return j|(k<<16)}}());if(typeof ZLIB==="undefined"){alert("ZLIB is not defined. SRC zlib.js before zlib-crc32.js")}(function(){var a=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918000,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];function c(h,g,k,j){if(g==null){return 0}h=h^4294967295;while(j>=8){h=a[(h^g.charCodeAt(k++))&255]^(h>>>8);h=a[(h^g.charCodeAt(k++))&255]^(h>>>8);h=a[(h^g.charCodeAt(k++))&255]^(h>>>8);h=a[(h^g.charCodeAt(k++))&255]^(h>>>8);h=a[(h^g.charCodeAt(k++))&255]^(h>>>8);h=a[(h^g.charCodeAt(k++))&255]^(h>>>8);h=a[(h^g.charCodeAt(k++))&255]^(h>>>8);h=a[(h^g.charCodeAt(k++))&255]^(h>>>8);j-=8}if(j){do{h=a[(h^g.charCodeAt(k++))&255]^(h>>>8)}while(--j)}return h^4294967295}function b(h,g,k,j){if(g==null){return 0}h=h^4294967295;while(j>=8){h=a[(h^g[k++])&255]^(h>>>8);h=a[(h^g[k++])&255]^(h>>>8);h=a[(h^g[k++])&255]^(h>>>8);h=a[(h^g[k++])&255]^(h>>>8);h=a[(h^g[k++])&255]^(h>>>8);h=a[(h^g[k++])&255]^(h>>>8);h=a[(h^g[k++])&255]^(h>>>8);h=a[(h^g[k++])&255]^(h>>>8);j-=8}if(j){do{h=a[(h^g[k++])&255]^(h>>>8)}while(--j)}return h^4294967295}ZLIB.crc32=function(h,g,k,j){if(typeof g==="string"){return c(h,g,k,j)}else{return b(h,g,k,j)}};var d=32;function f(g,k){var j;var h=0;j=0;while(k){if(k&1){j^=g[h]}k>>=1;h++}return j}function e(j,g){var h;for(h=0;h>=1;if(k==0){break}e(m,j);if(k&1){g=f(m,g)}k>>=1}while(k!=0);g^=h;return g}}());"use strict";var debugLevel=parseInt("{{{debuglevel}}}");var features=parseInt("{{{features}}}");var sessionTime=parseInt("{{{sessiontime}}}");var domain="{{{domain}}}";var domainUrl="{{{domainurl}}}";var meshserver=null;var xdr=null;var serverinfo=null;var nodes=[];var meshes={};var filetree={};var userinfo=null;var serverinfo=null;var users=null;var nodeShortIdent=0;var serverPublicNamePort="{{{serverDnsName}}}:{{{serverPublicPort}}}";var debugmode=false;var attemptWebRTC=((features&128)!=0);var StatusStrs=["Disconnected","Connecting...","Setup...","Connected","Intel® AMT Connected"];var files;function startup(){if((features&32)==0){var b=null;try{b=top.location.toString().toLowerCase()}catch(a){}if(top!=self&&(b==null||top.active==false)){top.location=self.location;return}}window.onresize=center;center();QH("p1message","Connecting...");go(1);meshserver=MeshServerCreateControl(domainUrl);meshserver.onStateChanged=onStateChanged;meshserver.onMessage=onMessage;meshserver.Start();var c=localStorage.getItem("desktopsettings");if(c!=null){desktopsettings=JSON.parse(c)}applyDesktopSettings()}function onStateChanged(a,b){if(b==0){setDialogMode(0);go(0);setTimeout(serverPoll,5000)}else{if(b==2){meshserver.send({action:"meshes"});meshserver.send({action:"nodes"});meshserver.send({action:"files"});if(xxcurrentView<2){go(2)}}}}function serverPoll(){xdr=null;try{xdr=new XDomainRequest()}catch(a){}if(!xdr){xdr=new XMLHttpRequest()}xdr.open("HEAD",window.location.href);xdr.timeout=15000;xdr.onload=function(){reload()};xdr.onerror=xdr.ontimeout=function(){setTimeout(serverPoll,10000)};xdr.send()}function onMessage(h,d){switch(d.action){case"serverinfo":serverinfo=d.serverinfo;break;case"userinfo":userinfo=d.userinfo;QH("p3userName",userinfo.name);break;case"users":users={};for(var c in d.users){users[d.users[c]._id]=d.users[c]}updateUsers();break;case"wssessioncount":wssessions=d.wssessions;updateUsers();break;case"meshes":meshes={};for(var c in d.meshes){meshes[d.meshes[c]._id]=d.meshes[c]}updateMeshes();updateDevices();break;case"files":filetree=setupBackPointers(d.filetree);updateFiles();break;case"nodes":nodes=[];for(var c in d.nodes){for(var e in d.nodes[c]){if(!meshes[c]){console.log("Invalid mesh (1): "+c);continue}d.nodes[c][e].namel=d.nodes[c][e].name.toLowerCase();if(d.nodes[c][e].rname){d.nodes[c][e].rnamel=d.nodes[c][e].rname.toLowerCase()}else{d.nodes[c][e].rnamel=d.nodes[c][e].namel}d.nodes[c][e].meshnamel=meshes[c].name.toLowerCase();d.nodes[c][e].meshid=c;d.nodes[c][e].state=(d.nodes[c][e].state)?(d.nodes[c][e].state):0;d.nodes[c][e].desc=d.nodes[c][e].desc;if(!d.nodes[c][e].icon){d.nodes[c][e].icon=1}d.nodes[c][e].ident=++nodeShortIdent;nodes.push(d.nodes[c][e])}}updateDevices();if(xxcurrentView==0){if("{{viewmode}}"!=""){go(parseInt("{{viewmode}}"))}else{setDialogMode(0);go(1)}}if("{{currentNode}}"!=""){gotoDevice("{{currentNode}}",parseInt("{{viewmode}}"))}break;case"powertimeline":if(d.nodeid!=powerTimelineReq){break}powerTimelineNode=d.nodeid;powerTimeline=d.timeline;powerTimelineUpdate=Date.now()+300000;if(currentNode._id==d.nodeid){drawDeviceTimeline()}break;case"event":switch(d.event.action){case"createmesh":if(d.event.links["user/"+domain+"/"+userinfo.name.toLowerCase()]!=null){meshes[d.event.meshid]={_id:d.event.meshid,name:d.event.name,mtype:d.event.mtype,desc:d.event.desc,links:d.event.links};updateMeshes();updateDevices();meshserver.send({action:"files"})}break;case"meshchange":if(meshes[d.event.meshid]==null){meshes[d.event.meshid]={_id:d.event.meshid,name:d.event.name,mtype:d.event.mtype,desc:d.event.desc,links:d.event.links};meshserver.send({action:"nodes"})}else{meshes[d.event.meshid].name=d.event.name;meshes[d.event.meshid].desc=d.event.desc;meshes[d.event.meshid].links=d.event.links;if(meshes[d.event.meshid].links["user/"+domain+"/"+userinfo.name.toLowerCase()]==null){if((xxcurrentView==20)&&(currentMesh==meshes[d.event.meshid])){go(2)}delete meshes[d.event.meshid];var f=[];for(var a in nodes){if(nodes[a].meshid!=d.event.meshid){f.push(nodes[a])}}nodes=f;if(xxcurrentView>=10&&xxcurrentView<20&¤tNode&¤tNode.meshid==d.event.meshid){setDialogMode(0);go(1)}}}updateMeshes();updateDevices();meshserver.send({action:"files"});if(xxcurrentView==20&¤tMesh._id==d.event.meshid){p20updateMesh()}break;case"deletemesh":if(meshes[d.event.meshid]){delete meshes[d.event.meshid];updateMeshes();meshserver.send({action:"files"})}var f=[];for(var a in nodes){if(nodes[a].meshid!=d.event.meshid){f.push(nodes[a])}}nodes=f;updateDevices();if(xxcurrentView>=20&&xxcurrentView<30&¤tMesh._id==d.event.meshid){setDialogMode(0);go(2)}if(xxcurrentView>=10&&xxcurrentView<20&¤tNode&¤tNode.meshid==d.event.meshid){setDialogMode(0);go(1)}break;case"addnode":var g=d.event.node;if(!meshes[g.meshid]){break}g.namel=g.name.toLowerCase();if(g.rname){g.rnamel=g.rname.toLowerCase()}else{g.rnamel=g.namel}g.meshnamel=meshes[g.meshid].name.toLowerCase();g.state=0;if(!g.icon){g.icon=1}g.ident=++nodeShortIdent;nodes.push(g);updateDevices();break;case"removenode":var b=-1;for(var a in nodes){if(nodes[a]._id==d.event.nodeid){b=a;break}}if(b!=-1){var g=nodes[b];if(currentNode==g){if(xxcurrentView>=10&&xxcurrentView<20){setDialogMode(0);go(1)}currentNode=null}nodes.splice(b,1);updateDevices();updateMapMarkers()}break;case"changenode":var b=-1;for(var a in nodes){if(nodes[a]._id==d.event.nodeid){b=a;break}}if(b!=-1){var g=nodes[b];g.name=d.event.node.name;g.rname=d.event.node.rname;g.host=d.event.node.host;g.desc=d.event.node.desc;g.publicip=d.event.node.publicip;g.iploc=d.event.node.iploc;g.wifiloc=d.event.node.wifiloc;g.gpsloc=d.event.node.gpsloc;g.tags=d.event.node.tags;g.userloc=d.event.node.userloc;if(d.event.node.agent!=null){if(g.agent==null){g.agent={}}if(d.event.node.agent.ver!=null){g.agent.ver=d.event.node.agent.ver}if(d.event.node.agent.id!=null){g.agent.id=d.event.node.agent.id}if(d.event.node.agent.caps!=null){g.agent.caps=d.event.node.agent.caps}if(d.event.node.agent.core!=null){g.agent.core=d.event.node.agent.core}else{if(g.agent.core){delete g.agent.core}}g.agent.tag=d.event.node.agent.tag}if(d.event.node.intelamt!=null){if(g.intelamt==null){g.intelamt={}}if(d.event.node.intelamt.host!=null){g.intelamt.user=d.event.node.intelamt.host}if(d.event.node.intelamt.user!=null){g.intelamt.user=d.event.node.intelamt.user}if(d.event.node.intelamt.tls!=null){g.intelamt.tls=d.event.node.intelamt.tls}if(d.event.node.intelamt.ver!=null){g.intelamt.ver=d.event.node.intelamt.ver}if(d.event.node.intelamt.state!=null){g.intelamt.state=d.event.node.intelamt.state}}g.namel=g.name.toLowerCase();if(g.rname){g.rnamel=g.rname.toLowerCase()}else{g.rnamel=g.namel}if(d.event.node.icon){g.icon=d.event.node.icon}refreshDevice(g._id);updateDevices()}break;case"nodeconnect":var b=-1;for(var a in nodes){if(nodes[a]._id==d.event.nodeid){b=a;break}}if(b!=-1){var g=nodes[b];g.conn=d.event.conn;g.pwr=d.event.pwr;updateDevices()}break;case"clearevents":break;case"login":if(users!=null&&users["user/"+domain+"/"+d.event.username.toLowerCase()]){users["user/"+domain+"/"+d.event.username.toLowerCase()].login=d.event.time}break;case"notify":break}break}}function topMenu(a){if((xxdialogMode!=null)&&(xxdialogMode!=0)&&(xxdialogMode!=999)){return}if(a===undefined){var b=(QS("topMenu").display=="none");if(b==true){if((xxdialogMode==0)||(xxdialogMode==null)){QV("topMenu",true);xxdialogMode=999}}else{QV("topMenu",false);xxdialogMode=0}}else{QV("topMenu",false);xxdialogMode=0;if((a==1)&&(xxcurrentView!=3)){goForward("account")}if((a==2)&&(xxcurrentView!=5)){goForward("files")}}}var backStack=[];function goBack(){if(xxdialogMode){return}if(backStack.length>0){backStack.pop()}goStack()}function goForward(a){if(xxdialogMode){return}backStack.push(a);goStack()}function goStack(){if(backStack.length==0){go(2);return}var a=backStack[backStack.length-1],b=a.split("/")[0];if(b=="node"){setupDeviceMenu(0);gotoDevice(a)}if(b=="mesh"){gotoMesh(a)}if(b=="account"){go(3)}if(b=="devices"){go(2)}if(b=="files"){go(5)}}function updateFooterMenu(b){while(b!=null&&b.length<3){b.push({n:""})}var d="",c="";if(b!=null){for(var a in b){d+=''+b[a].n;c=b[a].n}}QH("footerMenu"," "+d)}function account_showVerifyEmail(){if(xxdialogMode||(userinfo.emailVerified==true)||(serverinfo.emailcheck!=true)){return}var a="Click ok to send a verification mail to:"+EscapeHtml(userinfo.email)+"
Please wait a few minute to receive the verification.";setDialogMode(2,"Email Verification",3,account_showVerifyEmailEx,a)}function account_showVerifyEmailEx(){meshserver.send({action:"verifyemail",email:userinfo.email})}function account_showChangeEmail(){if(xxdialogMode){return}var a=addHtmlValue("Email"," ");setDialogMode(2,"Email Address Change",3,account_changeEmail,a);if(userinfo.email!=null){Q("dp3email").value=userinfo.email}account_validateEmail();Q("dp3email").focus()}function account_validateEmail(a,b){QE("idx_dlgOkButton",validateEmail(Q("dp3email").value)&&(Q("dp3email").value!=userinfo.email));if((x==true)&&(a!=null)&&(a.keyCode==13)){dialogclose(1)}}function account_changeEmail(){meshserver.send({action:"changeemail",email:Q("dp3email").value})}function account_showDeleteAccount(){if(xxdialogMode){return}var a="";setDialogMode(2,"Delete Account",0,null,a);account_validateDeleteAccount();Q("apassword1").focus()}function account_showChangePassword(){if(xxdialogMode){return}var a="";setDialogMode(2,"Change Password",0,null,a);account_validateDeleteAccount();Q("apassword1").focus()}function account_createMesh(){if(xxdialogMode){return}var a=addHtmlValue("Name"," ");a+=addHtmlValue("Type","Software Agent Group Intel® AMT only
");a+=addHtmlValue("Description","
");setDialogMode(2,"Create Device Group",3,account_createMeshEx,a);account_validateMeshCreate();Q("dp3meshname").focus()}function account_validateMeshCreate(){QE("idx_dlgOkButton",Q("dp3meshname").value.length>0)}function account_createMeshEx(a,b){meshserver.send({action:"createmesh",meshname:Q("dp3meshname").value,meshtype:Q("dp3meshtype").value,desc:Q("dp3meshdesc").value})}function account_validateDeleteAccount(){QE("account_dlgOkButton",(Q("apassword1").value.length>0)&&(Q("apassword1").value==Q("apassword2").value))}function account_validateNewPassword(){QE("account_dlgOkButton",(Q("apassword1").value.length>0)&&(Q("apassword1").value==Q("apassword2").value));var b="";if(Q("apassword1").value!=""){var a=checkPasswordStrength(Q("apassword1").value);if(a>=80){b="Strong"}else{if(a>=60){b="Good"}else{b="Weak"}}}QH("dxPassWarn",b)}function checkPasswordStrength(e){var f=0,d={},g=0,h={digits:/\d/.test(e),lower:/[a-z]/.test(e),upper:/[A-Z]/.test(e),nonWords:/\W/.test(e)};if(!e){return 0}for(var b=0;b";c+='';c+='';c+="
"+EscapeHtml(meshes[i].name)+"
"+d+"
";c+="
"}QH("p3meshes",c);QV("p3noMeshFound",a==0)}function gotoMesh(a){currentMesh=meshes[a];if(currentMesh==null){goBack()}p20updateMesh();go(20)}function server_showRestoreDlg(){if(xxdialogMode){return}var a="Restore the server using a backup, this will delete the existing server data . Only do this if you know what you are doing. ";a+='";setDialogMode(2,"Restore Server",0,null,a);account_validateServerRestore()}function account_validateServerRestore(){QE("account_dlgOkButton",Q("account_dlgFileInput").files.length==1)}function server_showVersionDlg(){if(xxdialogMode){return}setDialogMode(2,"MeshCentral Version",1,null,"Loading...","MeshCentralServerUpdate");meshserver.send({action:"serverversion"})}function server_showVersionDlgUpdate(){QE("idx_dlgOkButton",Q("d2updateCheck").checked)}function server_showVersionDlgEx(){meshserver.send({action:"serverupdate"})}var filetreelinkpath;var filetreelocation=[];function p5refreshFiles(){meshserver.send({action:"files"})}function updateFiles(){QV("MainMenuMyFiles",((features&8)==0));if((features&8)!=0){return}var o="",p="",c="Root ",m="Root",w,g=filetree,k=1;var e=[],t=filetreelinkpath,b=[],a=document.getElementsByName("fc");for(var q=0;q2){w+="/"+filetreelocation[q]}}}g=g.f[filetreelocation[q]];c+=" / "+(g.n!=null?g.n:filetreelocation[q])+" ";k++}else{break}}filetreelocation=e;var u=m.toLowerCase().startsWith("root / "+userinfo._id+" / public");var j=p5sort_files(g.f);for(var q in j){var d=j[q],s=d.n,z;z=s;if(s.length>40){z=''+EscapeHtml(s.substring(0,40))+"... "}else{z=EscapeHtml(s)}s=EscapeHtml(s);var l="";if(d.s!=null){l=getFileSizeStr(d.s)}var n="";if(d.t<3||d.t==4){var y=(d.t==1||d.t==4)?p5getQuotabar(d):"",B="";n=""}else{var r=z;var v="";if(u){v=' (Link )"}if(d.s>0){r=''+z+" "+v}n=""}if(d.t<3){o+=n}else{p+=n}}QH("p5rightOfButtons",p5getQuotabar(g));QH("p5files",o+p);QH("p5currentpath",c);QE("p5FolderUp",filetreelocation.length!=0);QV("p5PublicShare",u);if(t==filetreelinkpath){a=document.getElementsByName("fc");for(var q=0;q=0)}}p5setActions()}function p5getQuotabar(a){while(a.t>1&&a.t!=4){a=a.parent}if((a.t!=1&&a.t!=4)||(a.maxbytes==null)){return""}var b=Math.floor(a.s/1024),c=Math.floor((a.maxbytes-a.s)/1024);return'1?"s":"")+". "+(Math.floor(a.maxbytes/1024))+'k maxinum">'+((c<0)?("Storage limit exceed"):(c+"k remaining"))+" "}function p5showPublicLink(a){setDialogMode(2,"Public Link",1,null,' ')}var sortorder;function p5sort_filename(c,d){if(c.ln>d.ln){return(1*sortorder)}if(c.lnd.d){return(1*sortorder)}if(c.d3){sortorder=-1;d-=3}if(d==1){c.sort(p5sort_filename)}else{if(d==2){c.sort(p5sort_bysize)}else{if(d==3){c.sort(p5sort_timestamp)}}}return c}function p5setActions(){var a=getFileSelCount(),c=getFileCount(),b=getFileSelCount(false);QE("p5DeleteFileButton",(a>0)&&(filetreelocation.length>0));QE("p5NewFolderButton",filetreelocation.length>0);QE("p5UploadButton",filetreelocation.length>0);QE("p5RenameFileButton",(a==1)&&(filetreelocation.length>0));QE("p5SelectAllButton",c>0);Q("p5SelectAllButton").value=(a>0?"None":"All");QE("p5CutButton",(b>0)&&(a==b));QE("p5CopyButton",(b>0)&&(a==b));QE("p5PasteButton",(p5clipboard!=null)&&(p5clipboard.length>0)&&(filetreelocation.length>0))}function getFileSelCount(d){var a=0;var b=document.getElementsByName("fc");for(var c=0;ca){filetreelocation.pop()}}updateFiles()}function p5folderset(a){filetreelocation.push(decodeURIComponent(a));updateFiles()}function p5createfolder(){setDialogMode(2,"New Folder",3,p5createfolderEx," ");focusTextBox("p5renameinput");p5fileNameCheck()}function p5createfolderEx(){meshserver.send({action:"fileoperation",fileop:"createfolder",path:filetreelocation,newfolder:Q("p5renameinput").value})}function p5deletefile(){var a=getFileSelCount();setDialogMode(2,"Delete",3,p5deletefileEx,(a>1)?("Delete "+a+" selected items?"):("Delete selected item?"))}function p5deletefileEx(){var b=[],a=document.getElementsByName("fc");for(var c=0;c ',{action:"fileoperation",fileop:"rename",path:filetreelocation,oldname:c});focusTextBox("p5renameinput");p5fileNameCheck()}function p5renamefileEx(a,c){c.newname=Q("p5renameinput").value;meshserver.send(c)}function p5fileNameCheck(a){var b=isFilenameValid(Q("p5renameinput").value);QE("idx_dlgOkButton",b);if((b==true)&&(a.keyCode==13)){dialogclose(1)}}var isFilenameValid=(function(){var b=/^[^\\/:\*\?"<>\|]+$/,c=/^\./,d=/^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i;return function a(e){return b.test(e)&&!c.test(e)&&!d.test(e)&&(e[0]!=".")}})();function p5uploadFile(){setDialogMode(2,"Upload File",3,p5uploadFileEx,'');updateUploadDialogOk("p5uploadinput")}function p5uploadFileEx(){Q("p5loginSubmit").click()}function updateUploadDialogOk(a){QE("idx_dlgOkButton",Q(a).value!="")}var p5clipboard=null,p5clipboardFolder=null,p5clipboardCut=0;function p5copyFile(b){var a=document.getElementsByName("fc");p5clipboard=[];p5clipboardCut=b,p5clipboardFolder=Clone(filetreelocation);for(var c=0;c0)){a="Confim "+(p5clipboardCut==0?"copy":"move")+" of "+p5clipboard.length+" entrie"+((p5clipboard.length>1)?"s":"")+" to this location?"}setDialogMode(2,"Paste",3,p5pasteFileEx,a)}function p5pasteFileEx(){meshserver.send({action:"fileoperation",fileop:(p5clipboardCut==0?"copy":"move"),scpath:p5clipboardFolder,path:filetreelocation,names:p5clipboard});p5folderup(999);if(p5clipboardCut==1){p5clipboard=null,p5clipboardFolder=null,p5clipboardCut=0;p5updateClipview()}}function p5updateClipview(){var a="";if((p5clipboard!=null)&&(p5clipboard.length>0)){a="Holding "+p5clipboard.length+" entrie"+((p5clipboard.length>1)?"s":"")+" for "+(p5clipboardCut==0?"copy":"move")+", Clear ."}QH("p5bottomstatus",a);p5setActions()}function p5clearClip(){p5clipboard=null;p5clipboardFolder=null;p5clipboardCut=0;p5updateClipview()}function p5fileDragDrop(b){haltEvent(b);QV("bigfail",false);QV("bigok",false);if(b.dataTransfer==null||b.dataTransfer.files.length==0||filetreelocation.length==0){return}var f=[],j=[],k=[],a=[],h=b.dataTransfer.files.length;for(var d=0;d, Intel® AMT only "}if(d!=null){if(a==2){t+="
"}if(t!=""){t+=" "}}t+="";t+=' '+EscapeHtml(meshes[nodes[j].meshid].name)+" "+f+"
";d=nodes[j].meshid;e[d]=1;a=0}}else{if(sort==1){if(nodes[j].pwr!==d){deviceHeaderSet();if(d!==null){if(a==2){t+="
"}if(t!=""){t+=""}}t+=""+PowerStateStr2(nodes[j].pwr)+"
";d=nodes[j].pwr;a=0}}else{if(sort==2){if(d==null){d="1"}}}}b++;var u=EscapeHtml(nodes[j].name);if(u.length==0){u="None "}if((nodes[j].rname!=null)&&(nodes[j].rname.length>0)){u+=" / "+EscapeHtml(nodes[j].rname)}var q=EscapeHtml(nodes[j].name);if(showRealNames==true&&nodes[j].rname!=null){q=EscapeHtml(nodes[j].rname)}if(q.length==0){q="None "}var k=nodes[j].icon,s=NodeStateStr(nodes[j]);if((!nodes[j].conn)||(nodes[j].conn==0)){k+=" gray"}t+="";deviceHeaderTotal++;if(typeof deviceHeaderCount[nodes[j].state]=="undefined"){deviceHeaderCount[nodes[j].state]=1}else{deviceHeaderCount[nodes[j].state]++}}if(sort==0){for(var j in meshes){var l=meshes[j],n=l.links["user/"+domain+"/"+userinfo.name.toLowerCase()];if(n!=null){var p=n.rights;if(e[l._id]==null){if((d!="")&&(t!="")){t+=""}t+="";t+=' '+EscapeHtml(l.name)+"
";if(l.mtype==1){t+="
No Intel® AMT devices in this mesh"}if(l.mtype==2){t+=" No devices in this mesh"}t+=".
";d=l._id;b++}}}}QH("xdevices",t);deviceHeaderSet();for(var j in deviceHeaders){QH(j,deviceHeaders[j])}for(var j in deviceHeadersTitles){Q(j).title=deviceHeadersTitles[j]}}var powerStatetable=["","Powered","Sleep","Sleep","Sleep","Hibernating","Power off","Present"];var powerStateStrings=["",'
Powered ','
Sleeping ','
Sleeping ','
Deep Sleep ','
Hibernating ','
Soft-Off ','
Present '];var powerStateStrings2=["","Device is powered","Device is in sleep state (S1)","Device is in sleep state (S2)","Device is in deep sleep state (S3)","Device is hibernating (S4)","Device is in soft-off state (S5)","Device is present, but power state cannot be determined"];var powerColorTable=["#00000000","black","blue","blue","lightblue","blueviolet","darkgreen","lightseagreen","lightseagreen"];function NodeStateStr(a){var b=[];if(a.state>0&&a.state
Agent')}if((a.conn&2)!=0){b.push('CIRA ')}if((a.conn&4)!=0){b.push('Intel® AMT ')}if((a.conn&8)!=0){b.push('Relay ')}}if((a.pwr!=null)&&(a.pwr!=0)){b.push(powerStateStrings[a.pwr])}return b.join(", ")}function PowerStateStr(a){if(a0){a+=", "}a+=deviceHeaderCount[b]+" "+PowerStateStr2(b)}deviceHeadersTitles["DevxHeader"+deviceHeaderId]=a;deviceHeaderId++;deviceHeaderCount={};deviceHeaderTotal=0}function meshSort(c,d){if(c.meshnamel>d.meshnamel){return 1}if(c.meshnameld.rnamel){return 1}if(c.rnameld.namel){return 1}if(c.namele.rnamel){return 1}if(c.rnamele.namel){return 1}if(c.namelf){return 1}if(dd.namel){return 1}if(c.nameld.rnamel){return 1}if(c.rnamelNone"}if((h&4)!=0){j=""+j+" "}QH("p10deviceName",j);var s="";s+=addDeviceAttribute('Group ',''+EscapeHtml(meshes[k.meshid].name)+" ");if(k.rname!=null){s+=addDeviceAttribute('Name ',''+EscapeHtml(k.rname)+" ")}if((g.mtype==1)||(k.name!=k.host)){if((h&4)!=0){if(k.host){s+=addDeviceAttribute("Hostname",""+EscapeHtml(k.host)+" ")}else{s+=addDeviceAttribute("Hostname","None ")}}else{s+=addDeviceAttribute("Hostname",EscapeHtml(k.host))}}var d=k.desc?EscapeHtml(k.desc):"None ";if((h&4)!=0){s+=addDeviceAttribute("Description",""+d+" ")}else{s+=addDeviceAttribute("Description",d)}var a=["Unknown","Windows 32bit console","Windows 64bit console","Windows 32bit service","Windows 64bit service","Linux 32bit","Linux 64bit","MIPS","XENx86","Android ARM","Linux ARM","OSX 32bit","Android x86","PogoPlug ARM","Android APK","Linux Poky x86-32bit","OSX 64bit","ChromeOS","Linux Poky x86-64bit","Linux NoKVM x86-32bit","Linux NoKVM x86-64bit","Windows MinCore console","Windows MinCore service","NodeJS","ARM-Linaro","ARMv6l / ARMv7l"];if((k.agent!=null)&&(k.agent.id!=null)&&(k.agent.ver!=null)){var q="";if(k.agent.id<=a.length){q=a[k.agent.id]}else{q=a[0]}if(k.agent.ver!=0){q+=" v"+k.agent.ver}s+=addDeviceAttribute("Agent",q)}if(k.intelamt!=null){var q="";var o={0:"Not Activated (Pre)",1:"Not Activated (In)",2:"Activated"};if(k.intelamt.ver!=null&&k.intelamt.state==null){q+="Unknown State , v"+k.intelamt.ver}else{if((k.intelamt.ver==null)&&(k.intelamt.state==2)){q+="Activated "}else{if((k.intelamt.ver==null)||(k.intelamt.state==null)){q+="Unknown Version & State "}else{q+=o[k.intelamt.state];if(k.intelamt.flags){if(k.intelamt.flags&2){q=' CCM '}else{if(k.intelamt.flags&4){q=' ACM '}}}q+=(", v"+k.intelamt.ver)}}}if(k.intelamt.tls==1){q+=', TLS '}if(k.intelamt.state==2){if(k.intelamt.user==null||k.intelamt.user==""){if((h&4)!=0){q+=', No Credentials '}else{q+=", No Credentials "}}q+=" ";if((h&4)!=0){q+=' '}}s+=addDeviceAttribute("Intel® AMT",q)}if((k.agent!=null)&&(k.agent.tag!=null)&&(k.agent.tag!="mailto:")){var r=EscapeHtml(k.agent.tag);if(r.startsWith("mailto:")){r=''+r.substring(7)+" "}s+=addDeviceAttribute("Agent Tag",r)}var b=k.conn;if(b&&b>1){var c=[];if((k.conn&1)!=0){c.push('Agent ')}if((k.conn&2)!=0){c.push('Intel® AMT CIRA ')}if((k.conn&4)!=0){c.push('Intel® AMT ')}if((k.conn&8)!=0){c.push('Agent Relay ')}s+=addDeviceAttribute("Connectivity",c.join(", "))}var e="None ";if(k.tags!=null){e="";for(var f in k.tags){e+=''+k.tags[f]+" "}}s+=addDeviceAttribute("Tags",""+e+" ");s+="
";if((h&76)!=0){s+=' '}QH("p10html",s);setupFiles();s="";s+="
";QH("p10html3",s);var n=PowerStateStr(k.state);if((b&1)!=0){if(n.length>0){n+=", "}n+='Mesh Agent '}if((b&2)!=0){if(n.length>0){n+=", "}n+='Intel® AMT connected '}else{if((b&4)!=0){if(n.length>0){n+=", "}n+='Intel® AMT detected '}}QH("MainComputerState",n);QH("MainComputerImage",'
');if((powerTimelineNode!=currentNode._id)&&(powerTimelineReq!=currentNode._id)){QH("p10html2","");powerTimelineReq=currentNode._id;meshserver.send({action:"powertimeline",nodeid:currentNode._id})}}setupDesktop();if(!m){m=10}go(m);setupDeviceMenu()}function deviceToastFunction(){if(xxdialogMode){return}setDialogMode(2,"Device Toast",3,deviceToastFunctionEx,"")}function deviceToastFunctionEx(){meshserver.send({action:"toast",nodeids:[currentNode._id],title:"MeshCentral",msg:Q("d2devToast").value})}function setupDeviceMenu(d,c){var b=0;if(currentNode){b=meshes[currentNode.meshid].links["user/"+domain+"/"+userinfo.name.toLowerCase()].rights}if(d!=null){currentDevicePanel=d}QV("p10general",currentDevicePanel==0);QV("p10desktop",currentDevicePanel==1);QV("p10files",currentDevicePanel==2);var a=[];if(currentDevicePanel!=0){a.push({n:"General",f:"setupDeviceMenu(0)"})}if((currentDevicePanel!=1)&&(currentNode!=null)&&((b&8)||(b&256))&&((currentNode.mtype==1)||(currentNode.agent.caps&1))){a.push({n:"Desktop",f:"setupDeviceMenu(1)"})}if((currentDevicePanel!=2)&&(currentNode!=null)&&(b&8)&&((currentNode.mtype==2)&&(currentNode.agent.caps&4))){a.push({n:"Files",f:"setupDeviceMenu(2)"})}updateFooterMenu(a)}function deviceActionFunction(){if(xxdialogMode){return}var a=meshes[currentNode.meshid].links["user/"+domain+"/"+userinfo.name.toLowerCase()].rights;var b="Select an operation to perform on this device. ";var c="";if((a&64)!=0){c+="Wake-up "}if((a&8)!=0){c+="Sleep Reset Power off "}c+=" ";b+=addHtmlValue("Operation",c);setDialogMode(2,"Device Action",3,deviceActionFunctionEx,b)}function deviceActionFunctionEx(){var a=Q("d2deviceop").value;if(a==100){meshserver.send({action:"wakedevices",nodeids:[currentNode._id]})}else{meshserver.send({action:"poweraction",nodeids:[currentNode._id],actiontype:a})}}function updateDeviceTimeline(){if((meshserver.State!=2)||(powerTimelineNode==null)||(powerTimelineUpdate==null)||(currentNode==null)){return}if((powerTimelineNode==powerTimelineReq)&&(currentNode._id==powerTimelineNode)&&(powerTimelineUpdate1){s.push([0,r[1],r[0]]);var c=r[1];for(var l=2;l(l+1)){h=r[l+1]}s.push([c,c+h,o]);c=c+h}}var z="",b=1,g=new Date();var v=Q("masthead").offsetWidth-(90+9+9+14);g.setHours(0,0,0,0);for(var l=0;l<7;l++){var f="",p=g.getTime(),k=p+(1000*60*60*24);for(var m in s){var a=s[m];if(isTimeBlockInside(p,k,a[0],a[1])==true){var w=Math.max(p,a[0]);var q=Math.min(Math.min(k,a[1]),n);var y=Math.round(((q-w)*v)/86400000);if(y>0){var u=powerStateStrings2[a[2]]+" from "+new Date(w).toLocaleTimeString()+" to "+new Date(q).toLocaleTimeString()+".";f+='
"}}}z+=" "+g.toLocaleDateString()+"
"+f+"
";++b;g=new Date(g.getTime()-(1000*60*60*24))}QH("p10html2",'")}function powerColor(a){if(ac)){return true}if((b>d)&&(bd)&&(a"+a+" "+b+" "}function editDeviceAmtSettings(e,b){if(xxdialogMode){return}var f="",d=getNodeFromId(e),a=3,c=getNodeRights(e);if((c&4)==0){return}f+=addHtmlValue("Username",' ');f+=addHtmlValue("Password"," ");f+=addHtmlValue("Security","No TLS security TLS security required ");if((d.intelamt.user!=null)&&(d.intelamt.user!="")){a=7}setDialogMode(2,"Edit Intel® AMT credentials",a,editDeviceAmtSettingsEx,f,{node:d,func:b});if((d.intelamt.user!=null)&&(d.intelamt.user!="")){Q("dp10username").value=d.intelamt.user}else{Q("dp10username").value="admin"}Q("dp10tls").value=d.intelamt.tls;validateDeviceAmtSettings()}function validateDeviceAmtSettings(){QE("idx_dlgOkButton",passwordcheck(Q("dp10password").value))}function editDeviceAmtSettingsEx(c,d){if(c==2){meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:"",pass:""}})}else{var b=Q("dp10username").value;if(b==""){b="admin"}var a=Q("dp10password").value;if(a==""){b=""}meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:b,pass:a,tls:Q("dp10tls").value}});d.node.intelamt.user=b;d.node.intelamt.tls=Q("dp10tls").value;if(d.func){setTimeout(d.func,300)}}}function p10showDeleteNodeDialog(a){if(xxdialogMode){return}setDialogMode(2,"Delete Node",3,p10showDeleteNodeDialogEx,'Delete "'+EscapeHtml(currentNode.name)+'"? Confirm',a);p10validateDeleteNodeDialog()}function p10validateDeleteNodeDialog(){QE("idx_dlgOkButton",Q("p10check").checked)}function p10showDeleteNodeDialogEx(a,b){meshserver.send({action:"removedevices",nodeids:[b]})}function p10showiconselector(){if(xxdialogMode){return}var a=meshes[currentNode.meshid];var b=a.links["user/"+domain+"/"+userinfo.name.toLowerCase()].rights;if((b&4)==0){return}var c="";c+="
";c+="
";c+="
";c+="
";c+="
";c+="
";setDialogMode(2,"Icon Selection",0,null,c);QV("id_dialogclose",true)}function p10setIcon(a){setDialogMode(0);meshserver.send({action:"changedevice",nodeid:currentNode._id,icon:a})}var showEditNodeValueDialog_modes=["Device Name","Hostname","Description","Tags"];var showEditNodeValueDialog_modes2=["name","host","desc","tags"];var showEditNodeValueDialog_modes3=["","","","Group1, Group2, Group3"];function showEditNodeValueDialog(a){if(xxdialogMode){return}var c=addHtmlValue(showEditNodeValueDialog_modes[a],' ");setDialogMode(2,"Edit Device",3,showEditNodeValueDialogEx,c,a);var b=currentNode[showEditNodeValueDialog_modes2[a]];if(b==null){b=""}if(Array.isArray(b)){b=b.join(", ")}Q("dp10devicevalue").value=b;p10editdevicevalueValidate();Q("dp10devicevalue").focus()}function showEditNodeValueDialogEx(a,b){var c={action:"changedevice",nodeid:currentNode._id};c[showEditNodeValueDialog_modes2[b]]=Q("dp10devicevalue").value;meshserver.send(c)}function p10editdevicevalueValidate(b,a){var c=((b>1)||(Q("dp10devicevalue").value.length>0));QE("idx_dlgOkButton",c);if((a!=null)&&(c==true)&&(a.keyCode==13)){dialogclose(1)}}var desktop;var desktopNode;var desktopsettings={encoding:2,showfocus:false,showmouse:true,showcad:true,quality:40,scaling:1024,framerate:50};function setupDesktop(){if((desktopNode!=currentNode)&&(desktop!=null)){desktop.Stop();desktopNode=null;desktop=null}if((desktopNode!=currentNode)||(desktop==null)){QH("DeskParent",' ');desktopNode=currentNode;Q("Desk").addEventListener("DOMMouseScroll",function(a){return dmousewheel(a)});Q("Desk").addEventListener("mousewheel",function(a){return dmousewheel(a)})}desktopNode=currentNode;updateDesktopButtons();if(!Q("Desk")["toBlob"]){QV("deskSaveBtn",false)}}function updateDesktopButtons(){var c=meshes[currentNode.meshid];var a=0;if(desktop!=null){a=desktop.State}var d=c.links["user/"+domain+"/"+userinfo.name.toLowerCase()].rights;QV("disconnectbutton1",(a!=0));QV("connectbutton1",(a==0)&&(c.mtype==2)&&((d&8)||(d&256)));QV("connectbutton1h",(a==0)&&((currentNode.intelamt!=null)&&(d&8)&&(c.mtype==1||currentNode.intelamt.state==2)&&((currentNode.intelamt.ver!=null)||(c.mtype==1))));QV("d7amtkvm",(currentNode.intelamt!=null&&((currentNode.intelamt.ver!=null)||(c.mtype==1)))&&((a==0)||(desktop.contype==2)));QV("d7meshkvm",(c.mtype==2)&&((a==false)||(desktop.contype==1)));var e=((currentNode.conn&1)!=0);QE("connectbutton1",e);var b=((currentNode.conn&6)!=0);QE("connectbutton1h",b);QV("DeskToastButton",(currentNode.agent)&&(currentNode.agent.id<5)&&(d&8));QE("DeskToastButton",e);QV("deskActionsBtn",d&8);Q("DeskControl").checked=((d&8)!=0);if(e==false){QV("DeskTools",false)}}function connectDesktop(b,a){if(desktop==null){desktopNode=currentNode;if(a==2){if((desktopNode.intelamt.user==null)||(desktopNode.intelamt.user=="")){editDeviceAmtSettings(desktopNode._id,connectDesktop);return}desktop=CreateAmtRedirect(CreateAmtRemoteDesktop("Desk"));desktop.debugmode=debugmode;desktop.onStateChanged=onDesktopStateChange;desktop.m.bpp=(desktopsettings.encoding==1||desktopsettings.encoding==3)?1:2;desktop.m.useZRLE=(desktopsettings.encoding<3);desktop.m.showmouse=desktopsettings.showmouse;desktop.m.onScreenSizeChange=deskAdjust;desktop.Start(desktopNode._id,16994,"*","*",0);desktop.contype=2}else{desktop=CreateAgentRedirect(meshserver,CreateAgentRemoteDesktop("Desk"),serverPublicNamePort);desktop.debugmode=debugmode;desktop.m.debugmode=debugmode;desktop.attemptWebRTC=attemptWebRTC;desktop.onStateChanged=onDesktopStateChange;desktop.m.CompressionLevel=desktopsettings.quality;desktop.m.ScalingLevel=desktopsettings.scaling;desktop.m.FrameRateTimer=desktopsettings.framerate;desktop.m.onDisplayinfo=deskDisplayInfo;desktop.m.onScreenSizeChange=deskAdjust;desktop.Start(desktopNode._id);desktop.contype=1}}else{desktop.Stop();desktopNode=desktop=null}}function onDesktopStateChange(c,a){var d=a;if((d==3)&&(c.contype==2)){d++}var b=StatusStrs[d];if((desktop!=null)&&(desktop.webRtcActive==true)){b+=", WebRTC"}QH("deskstatus",b);switch(a){case 0:desktop.Stop();desktopNode=desktop=null;QV("termdisplays",false);if(fullscreen==true){deskToggleFull()}break;case 2:break}updateDesktopButtons();deskAdjust();setTimeout(deskAdjust,50)}function showDesktopSettings(){if(xxdialogMode){return}applyDesktopSettings();updateDesktopButtons();setDialogMode(7,"Remote Desktop Settings",3,showDesktopSettingsChanged)}function showDesktopSettingsChanged(){desktopsettings.encoding=d7desktopmode.value;desktopsettings.showfocus=d7showfocus.checked;desktopsettings.showmouse=d7showcursor.checked;desktopsettings.quality=d7bitmapquality.value;desktopsettings.scaling=d7bitmapscaling.value;desktopsettings.framerate=d7framelimiter.value;localStorage.setItem("desktopsettings",JSON.stringify(desktopsettings));applyDesktopSettings();if(desktop){if(desktop.contype==1){if(desktop.State!=0){desktop.m.SendCompressionLevel(1,desktopsettings.quality,desktopsettings.scaling,desktopsettings.framerate)}}if(desktop.contype==2){if(desktop.State!=0){desktop.Stop();setTimeout(function(){connectDesktop(null,2)},50)}}}}function applyDesktopSettings(){var c="",b=(features&512)?[90,70,50,40,30,20,10,5,1]:[50,40,30,20,10,5,1];for(var a in b){c+=""+b[a]+"% "}QH("d7bitmapquality",c);d7desktopmode.value=desktopsettings.encoding;d7showfocus.checked=desktopsettings.showfocus;d7showcursor.checked=desktopsettings.showmouse;d7bitmapquality.value=40;if(b.indexOf(parseInt(desktopsettings.quality))>=0){d7bitmapquality.value=desktopsettings.quality}d7bitmapscaling.value=desktopsettings.scaling;if(desktopsettings.framerate){d7framelimiter.value=desktopsettings.framerate}}var fullscreen=false;function deskAdjust(){var c=(Q("DeskParent").clientHeight-Q("Desk").clientHeight)/2;if(c<0){var a=Q("DeskParent").clientHeight,b=9999;if(desktop){b=(desktop.m.width/desktop.m.height)*a}QS("Desk")["max-height"]=a+"px";QS("Desk")["max-width"]=b+"px";c=0}else{QS("Desk")["max-height"]=null;QS("Desk")["max-width"]=null}QS("Desk")["margin-top"]=c+"px";QS("Desk")["margin-bottom"]=c+"px"}function toggleDeskTools(){if(xxdialogMode){return}if(QS("DeskTools").display=="none"){QV("DeskTools",true);Q("DeskTools").nodeid=currentNode._id;refreshDeskTools()}else{QV("DeskTools",false)}}function refreshDeskTools(){QV("DeskToolsRefreshButton",false);setTimeout(refreshDeskToolsEx,500);meshserver.send({action:"msg",type:"ps",nodeid:currentNode._id})}function refreshDeskToolsEx(){QV("DeskToolsRefreshButton",true)}var deskTools={sort:1,msg:null};function sortProcess(a){deskTools.sort=a;showDeskToolsProcesses(deskTools.msg)}function sortProcessPid(c,d){if(c.p>d.p){return 1}if(c.pd.d){return 1}if(c.d"+d[b].p+'
'+(d[b].u?d[b].u:"")+"
"+d[b].c+"
"}}QH("DeskToolsProcesses",h)}}function deskSaveImage(){if(xxdialogMode||desktop==null||desktop.State!=3){return}var a=new Date(),b="Desktop-"+currentNode.name+"-"+a.getFullYear()+"-"+("0"+(a.getMonth()+1)).slice(-2)+"-"+("0"+a.getDate()).slice(-2)+"-"+("0"+a.getHours()).slice(-2)+"-"+("0"+a.getMinutes()).slice(-2);Q("Desk")["toBlob"](function(c){saveAs(c,b+".jpg")})}function deskDisplayInfo(e,a,c,d){var f=Q("termdisplays").value;if(a.length>0){var b="";for(var g in a){b+=""+a[g]+" "}QH("termdisplays",b)}QV("termdisplays",a.length>0)}function deskGetDisplayNumbers(a){desktop.m.GetDisplayNumbers()}function deskSetDisplay(b){var a=0,c=Q("termdisplays").value;if(c=="All Displays"){a=65535}else{a=parseInt(c.substring(8))}desktop.m.SetDisplay(a)}function dmousedown(a){if((!xxdialogMode&&desktop!=null)&&Q("DeskControl").checked){desktop.m.mousedown(a)}}function dmouseup(a){if((!xxdialogMode&&desktop!=null)&&Q("DeskControl").checked){desktop.m.mouseup(a)}}function dmousemove(a){if((!xxdialogMode&&desktop!=null)&&Q("DeskControl").checked){desktop.m.mousemove(a)}}function dmousewheel(a){if((!xxdialogMode&&desktop!=null)&&Q("DeskControl").checked&&desktop.m.mousewheel){desktop.m.mousewheel(a);haltEvent(a);return true}return false}function drotate(a){if(!xxdialogMode&&desktop!=null){desktop.m.setRotation(desktop.m.rotation+a);deskAdjust();deskAdjust()}}function stopProcess(a,b){setDialogMode(2,"Process Control",3,stopProcessEx,"Stop process #"+a+' "'+b+'"?',a)}function stopProcessEx(a,b){meshserver.send({action:"msg",type:"pskill",nodeid:currentNode._id,value:b});setTimeout(refreshDeskTools,300)}var filesNode;function setupFiles(){var b=(filesNode==currentNode);filesNode=currentNode;var a=((filesNode.conn&1)!=0)?true:false;QE("p13Connect",a);if(((b==false)||(a==false))&&files){files.Stop();files=null}}function onFilesStateChange(c,a){p13Connect.value=(a==0)?"Connect":"Disconnect";var b=StatusStrs[a];if(files.webRtcActive==true){b+=", WebRTC"}Q("p13Status").textContent=b;switch(a){case 0:QH("p13files","");p13filetree=null;p13filetreelocation=[];QH("p13currentpath","");QE("p13FolderUp",false);p13setActions();if(files!=null){files.Stop();files=null}break;case 3:p13targetpath="";files.sendText({action:"ls",reqid:1,path:""});break}}function CreateRemoteFiles(b){var a={protocol:5};a.onFileUpdate=b;a.xxStateChange=function(c){};a.ProcessData=function(c){a.onFileUpdate(c)};return a}var autoConnectFilesTimer=null;function autoConnectFiles(a){if(autoConnectFilesTimer==null){autoConnectFilesTimer=setInterval(connectFiles,100)}else{clearInterval(autoConnectFilesTimer);autoConnectFilesTimer=null}}function connectFiles(a){if(!files){files=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotFiles),serverPublicNamePort);files.attemptWebRTC=attemptWebRTC;files.onStateChanged=onFilesStateChange;files.Start(filesNode._id)}else{files.Stop();files=null}p13clipboard=p13clipboardFolder=null;p13clipboardCut=0;p13updateClipview()}var p13filetree=null;var p13targetpath=null;var p13filetreelocation=[];function p13gotFiles(b){if((b.length>0)&&(b.charCodeAt(0)!=123)){p13gotDownloadBinaryData(b);return}b=JSON.parse(decode_utf8(b));if(b.action=="download"){p13gotDownloadCommand(b);return}b.path=b.path.replace(/\//g,"\\");if((p13filetree!=null)&&(b.path==p13filetree.path)){var a=p13getCheckedNames();p13filetree=b;p13updateFiles(a)}else{var c=b.path.replace(/\//g,"\\"),d=p13targetpath.replace(/\//g,"\\");while((c.length>0)&&(c[0]=="\\")){c=c.substring(1)}while((d.length>0)&&(d[0]=="\\")){d=d.substring(1)}if((c==d)||((b.path=="\\")&&(p13targetpath==""))){p13filetree=b;p13updateFiles()}}}function p13getCheckedNames(){var b=[],a=document.getElementsByName("fd");for(var c=0;cRoot ",j="Root";var u=p13filetree.path.split("\\");p13filetreelocation=[];for(var n in u){if(u[n]!=""){p13filetreelocation.push(u[n])}}for(var n in p13filetreelocation){c+=" / "+p13filetreelocation[n]+" "}var q=p13filetreelocation.join("/");var e=p13sort_files(p13filetree.dir);for(var n in e){var d=e[n],p=d.n,s;s=p;if(p.length>70){s=''+EscapeHtml(p.substring(0,70))+"... "}else{s=EscapeHtml(p)}p=EscapeHtml(p);var g="";if(d.s!=null){g=getFileSizeStr(d.s)}var k="";if(d.t<3){var r="",t="";k=""}else{var o=s;if(d.s>0){o=''+s+" "}k=""}if(d.t<3){l+=k}else{m+=k}}QH("p13files",l+m);QH("p13currentpath",c);QE("p13FolderUp",p13filetreelocation.length!=0);if(b!=null){var a=document.getElementsByName("fd");for(var n=0;n=0){a[n].checked=true}}}p13setActions()}function p13folderset(a){p13targetpath=joinPaths(p13filetree.path,p13filetree.dir[a].n).split("\\").join("/");files.sendText({action:"ls",reqid:1,path:p13targetpath})}function p13folderup(a){if(a==null){p13filetreelocation.pop()}else{while(p13filetreelocation.length>a){p13filetreelocation.pop()}}p13targetpath=p13filetreelocation.join("/");files.sendText({action:"ls",reqid:1,path:p13targetpath})}var p13sortorder;function p13sort_filename(c,d){if(c.ln>d.ln){return(1*p13sortorder)}if(c.lnd.d){return(1*p13sortorder)}if(c.d3){p13sortorder=-1;d-=3}if(d==1){c.sort(p13sort_filename)}else{if(d==2){c.sort(p13sort_bysize)}else{if(d==3){c.sort(p13sort_timestamp)}}}return c}function p13setActions(){if(p13filetree==null){QE("p13DeleteFileButton",false);QE("p13NewFolderButton",false);QE("p13UploadButton",false);QE("p13RenameFileButton",false);QE("p13SelectAllButton",false);Q("p13SelectAllButton").value="All";QE("p13RefreshButton",false);QE("p13CutButton",false);QE("p13CopyButton",false);QE("p13PasteButton",false)}else{var a=p13getFileSelCount(),c=p13getFileCount(),b=p13getFileSelCount(false);var d=((currentNode.agent.id>0)&&(currentNode.agent.id<5));QE("p13DeleteFileButton",(a>0)&&((p13filetreelocation.length>0)||(d==false)));QE("p13NewFolderButton",((p13filetreelocation.length>0)||(d==false)));QE("p13UploadButton",((p13filetreelocation.length>0)||(d==false)));QE("p13RenameFileButton",(a==1)&&((p13filetreelocation.length>0)||(d==false)));QE("p13SelectAllButton",c>0);Q("p13SelectAllButton").value=(a>0?"None":"All");QE("p13RefreshButton",true);QE("p13CutButton",(a>0)&&(a==b)&&((p13filetreelocation.length>0)||(d==false)));QE("p13CopyButton",(a>0)&&(a==b)&&((p13filetreelocation.length>0)||(d==false)));QE("p13PasteButton",((p13filetreelocation.length>0)||(d==false))&&((p13clipboard!=null)&&(p13clipboard.length>0)))}}function p13getFileSelCount(d){var a=0;var b=document.getElementsByName("fd");for(var c=0;c ");focusTextBox("p13renameinput");p13fileNameCheck()}function p13createfolderEx(){files.sendText({action:"mkdir",reqid:1,path:p13filetreelocation.join("/")+"/"+Q("p13renameinput").value});p13folderup(999)}function p13deletefile(){var a=getFileSelCount();setDialogMode(2,"Delete",3,p13deletefileEx,(a>1)?("Delete "+a+" selected items?"):("Delete selected item?"))}function p13deletefileEx(){var b=[],a=document.getElementsByName("fd");for(var c=0;c ',{action:"rename",path:p13filetreelocation.join("/"),oldname:c});focusTextBox("p13renameinput");p13fileNameCheck()}function p13renamefileEx(a,c){c.newname=Q("p13renameinput").value;files.sendText(c);p13folderup(999)}function p13fileNameCheck(a){var b=isFilenameValid(Q("p13renameinput").value);QE("idx_dlgOkButton",b);if((b==true)&&(a!=null)&&(a.keyCode==13)){dialogclose(1)}}function p13uploadFile(){setDialogMode(2,"Upload File",3,p13uploadFileEx," ");updateUploadDialogOk("p13uploadinput")}function p13uploadFileEx(){p13doUploadFiles(Q("p13uploadinput").files)}var p13clipboard=null,p13clipboardFolder=null,p13clipboardCut=0;function p13copyFile(b){var a=document.getElementsByName("fd");p13clipboard=[];p13clipboardCut=b,p13clipboardFolder=p13targetpath;for(var c=0;c0)){a="Confim "+(p13clipboardCut==0?"copy":"move")+" of "+p13clipboard.length+" entrie"+((p13clipboard.length>1)?"s":"")+" to this location?"}setDialogMode(2,"Paste",3,p13pasteFileEx,a)}function p13pasteFileEx(){files.sendText({action:(p13clipboardCut==0?"copy":"move"),reqid:1,scpath:p13clipboardFolder,dspath:p13targetpath,names:p13clipboard});p13folderup(999);if(p13clipboardCut==1){p13clipboard=null,p13clipboardFolder=null,p13clipboardCut=0;p13updateClipview()}}function p13updateClipview(){var a="";if((p13clipboard!=null)&&(p13clipboard.length>0)){a="Holding "+p13clipboard.length+" entrie"+((p13clipboard.length>1)?"s":"")+" for "+(p13clipboardCut==0?"copy":"move")+", Clear ."}QH("p13bottomstatus",a);p13setActions()}function p13clearClip(){p13clipboard=null;p13clipboardFolder=null;p13clipboardCut=0;p13updateClipview()}function updateUploadDialogOk(a){QE("idx_dlgOkButton",Q(a).value!="")}function getFileSelCount(d){var a=0;var b=document.getElementsByName("fc");for(var c=0;c"+downloadFile.file+" ")}function p13downloadFileCancel(){setDialogMode(0);files.sendText({action:"download",sub:"cancel",id:downloadFile.id});downloadFile=null}function p13gotDownloadCommand(a){if((downloadFile==null)||(a.id!=downloadFile.id)){return}if(a.sub=="start"){downloadFile.state=1;files.sendText({action:"download",sub:"startack",id:downloadFile.id})}else{if(a.sub=="cancel"){downloadFile=null;setDialogMode(0)}}}function p13gotDownloadBinaryData(a){if(!downloadFile||downloadFile.state==0){return}if(a.length>4){downloadFile.tsize+=(a.length-4);downloadFile.data+=a.substring(4);Q("d2progressBar").value=downloadFile.tsize}if((ReadInt(a,0)&1)!=0){saveAs(data2blob(downloadFile.data),downloadFile.file);downloadFile=null;setDialogMode(0)}else{files.sendText({action:"download",sub:"ack",id:downloadFile.id})}}var uploadFile;function p13doUploadFiles(a){if(xxdialogMode){return}uploadFile={};uploadFile.xpath=p13filetreelocation.join("/");uploadFile.xfiles=a;uploadFile.xfilePtr=-1;setDialogMode(2,"Upload File",10,p13uploadFileCancel,"Connecting...
");p13uploadReconnect()}function onFileUploadStateChange(b,a){switch(a){case 0:p13folderup(9999);break;case 3:p13uploadNextFile();break}}function p13uploadReconnect(){uploadFile.ws=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotUploadData),serverPublicNamePort);uploadFile.ws.attemptWebRTC=false;uploadFile.ws.ctrlMsgAllowed=false;uploadFile.ws.onStateChanged=onFileUploadStateChange;uploadFile.ws.Start(filesNode._id)}function p13uploadNextFile(){uploadFile.xfilePtr++;if(uploadFile.xfiles.length>uploadFile.xfilePtr){uploadFile.xptr=0;var a=uploadFile.xfiles[uploadFile.xfilePtr];QH("p13dfileName",a.name);Q("d2progressBar").max=a.size;Q("d2progressBar").value=0;uploadFile.xreader=new FileReader();uploadFile.xreader.onload=function(){uploadFile.xdata=uploadFile.xreader.result;uploadFile.ws.sendText({action:"upload",reqid:uploadFile.xfilePtr,path:uploadFile.xpath,name:a.name,size:uploadFile.xdata.byteLength})};uploadFile.xreader.readAsArrayBuffer(a)}else{p13uploadFileCancel()}}function p13uploadFileCancel(a,b){if(uploadFile!=null){if(uploadFile.ws!=null){uploadFile.ws.Stop();uploadFile.ws=null}uploadFile=null}setDialogMode(0)}function p13gotUploadData(b){var a=JSON.parse(b);if((uploadFile==null)||(parseInt(uploadFile.xfilePtr)!=parseInt(a.reqid))){return}if(a.action=="uploadstart"){p13uploadNextPart(false);for(var c=0;c<8;c++){p13uploadNextPart(true)}}else{if(a.action=="uploadack"){p13uploadNextPart(false)}else{if(a.action=="uploaderror"){p13uploadFileCancel()}}}}function p13uploadNextPart(c){var a=uploadFile.xdata;var e=uploadFile.xptr;var d=uploadFile.xptr+4096;if(d>a.byteLength){if(c==true){return}d=a.byteLength}if(e==a.byteLength){if(uploadFile.ws!=null){uploadFile.ws.Stop();uploadFile.ws=null}if(uploadFile.xfiles.length>uploadFile.xfilePtr+1){p13uploadReconnect()}else{p13uploadFileCancel()}}else{var b=a.slice(e,d);uploadFile.ws.send(b);uploadFile.xptr=d;Q("d2progressBar").value=d}}var currentMesh;function p20updateMesh(){if(currentMesh==null){return}QH("p20meshName",EscapeHtml(currentMesh.name));var e="Unknown #"+currentMesh.mtype;var d=currentMesh.links["user/"+domain+"/"+userinfo.name.toLowerCase()].rights;if(currentMesh.mtype==1){e="Intel® AMT group"}if(currentMesh.mtype==2){e="Software agent group"}var k="";k+=addHtmlValue("Name",addLinkConditional(EscapeHtml(currentMesh.name),"p20editmesh(1)",(d&1)!=0));k+=addHtmlValue("Description",addLinkConditional(((currentMesh.desc&¤tMesh.desc!="")?EscapeHtml(currentMesh.desc):"None "),"p20editmesh(2)",(d&1)!=0));k+=addHtmlValue("Type",e);k+=" ";var b=currentMesh.links["user/"+domain+"/"+userinfo.name.toLowerCase()];if(b&&((b.rights&2)!=0)){k+=""}k+='User Authorizations ';var a=1,h=[];for(var c in currentMesh.links){h.push({id:c,name:c.split("/")[2],rights:currentMesh.links[c].rights})}h.sort(function(l,m){if(l.name>m.name){return 1}if(l.name '}k+='";k+=""+j+"
"+g+"
";k+=" ";++a}k+="
";if(d==4294967295){k+=""}QH("p20info",k)}function p20showDeleteMeshDialog(){if(xxdialogMode){return}var a='Are you sure you want to delete mesh "'+EscapeHtml(currentMesh.name)+'"? Deleting the mesh will also delete all information about computers within this mesh. ';a+=" Confirm";setDialogMode(2,"Delete Mesh",3,p20showDeleteMeshDialogEx,a);p20validateDeleteMeshDialog()}function p20validateDeleteMeshDialog(){QE("idx_dlgOkButton",Q("p20check").checked)}function p20showDeleteMeshDialogEx(a,b){meshserver.send({action:"deletemesh",meshid:currentMesh._id,meshname:currentMesh.name})}function p20editmesh(a){if(xxdialogMode){return}var b=addHtmlValue("Name"," ");b+=addHtmlValue("Description"," ");setDialogMode(2,"Edit Device Group",3,p20editmeshEx,b);Q("dp20meshname").value=currentMesh.name;if(currentMesh.desc){Q("dp20meshdesc").value=currentMesh.desc}p20editmeshValidate();if(a==2){Q("dp20meshdesc").focus()}else{Q("dp20meshname").focus()}}function p20editmeshEx(){meshserver.send({action:"editmesh",meshid:currentMesh._id,meshname:Q("dp20meshname").value,desc:Q("dp20meshdesc").value})}function p20editmeshValidate(){QE("idx_dlgOkButton",Q("dp20meshname").value.length>0)}function p20showAddMeshUserDialog(){if(xxdialogMode){return}var a=addHtmlValue("User"," ");a+='';a+=" Full Administrator ";a+=" Edit Device Group ";a+=" Manage Device Group Users ";a+=" Manage Device Group Computers ";a+=" Remote Control ";a+=" Mesh Agent Console ";a+=" Server Files ";a+=" Wake Devices ";a+=" Edit Device Notes ";a+=" Remote View Only ";a+="
";setDialogMode(2,"Add User to Mesh",3,p20showAddMeshUserDialogEx,a);p20validateAddMeshUserDialog();Q("dp20username").focus()}function p20validateAddMeshUserDialog(){var a=currentMesh.links["user/"+domain+"/"+userinfo.name.toLowerCase()].rights;QE("idx_dlgOkButton",(Q("dp20username").value.length>0));QE("p20fulladmin",a==4294967295);QE("p20editmesh",(!Q("p20fulladmin").checked)&&(a==4294967295));QE("p20manageusers",!Q("p20fulladmin").checked);QE("p20managecomputers",!Q("p20fulladmin").checked);QE("p20remotecontrol",!Q("p20fulladmin").checked);QE("p20meshagentconsole",!Q("p20fulladmin").checked);QE("p20meshserverfiles",!Q("p20fulladmin").checked);QE("p20wakedevices",!Q("p20fulladmin").checked);QE("p20editnotes",!Q("p20fulladmin").checked);QE("p20remoteview",!Q("p20fulladmin").checked)}function p20showAddMeshUserDialogEx(){var a=0;if(Q("p20fulladmin").checked==true){a=4294967295}else{if(Q("p20editmesh").checked==true){a+=1}if(Q("p20manageusers").checked==true){a+=2}if(Q("p20managecomputers").checked==true){a+=4}if(Q("p20remotecontrol").checked==true){a+=8}if(Q("p20meshagentconsole").checked==true){a+=16}if(Q("p20meshserverfiles").checked==true){a+=32}if(Q("p20wakedevices").checked==true){a+=64}if(Q("p20editnotes").checked==true){a+=128}if(Q("p20remoteview").checked==true){a+=256}}meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,username:Q("dp20username").value,meshadmin:a})}function p20viewuser(e){if(xxdialogMode){return}e=decodeURIComponent(e);var d="",b=currentMesh.links["user/"+domain+"/"+userinfo.name.toLowerCase()].rights,c=currentMesh.links[e].rights;if(c==4294967295){d=", Full Administrator"}else{if((c&1)!=0){d+=", Edit Device Group"}if((c&2)!=0){d+=", Manage Device Group Users"}if((c&4)!=0){d+=", Manage Device Group Computers"}if((c&8)!=0){d+=", Remote Control"}if((c&16)!=0){d+=", Agent Console"}if((c&32)!=0){d+=", Server Files"}if((c&64)!=0){d+=", Wake Devices"}if((c&128)!=0){d+=", Edit Notes"}}d=d.substring(2);if(d==""){d="No Rights"}var a=1,f=addHtmlValue("User",e.split("/")[2]);f+=addHtmlValue("Permissions",d);if((("user/"+domain+"/"+userinfo.name.toLowerCase())!=e)&&(b==4294967295||(((b&2)!=0)&&(c!=4294967295)))){a+=4}setDialogMode(2,"Mesh User",a,p20viewuserEx,f,e)}function p20viewuserEx(a,b){if(a!=2){return}setDialogMode(2,"Remote Mesh User",3,p20viewuserEx2,"Confirm removal of user "+b.split("/")[2]+"?",b)}function p20deleteUser(a,b){haltEvent(a);p20viewuserEx(2,decodeURIComponent(b))}function p20viewuserEx2(a,b){meshserver.send({action:"removemeshuser",meshid:currentMesh._id,meshname:currentMesh.name,userid:b})}var xxcurrentView=-1;function go(b){if(xxdialogMode||xxcurrentView==b){return}updateFooterMenu();setDialogMode(0);for(var a=0;a<32;a++){QV("p"+a,a==b)}xxcurrentView=b}var xxdialogMode;var xxdialogFunc;var xxdialogButtons;var xxdialogTag;function setDialogMode(j,k,a,e,d,h){xxdialogMode=j;xxdialogFunc=e;xxdialogButtons=a;xxdialogTag=h;QE("idx_dlgOkButton",true);QV("idx_dlgOkButton",a&1);QV("idx_dlgCancelButton",a&2);QV("id_dialogclose",(a&2)||(a&8));QV("idx_dlgButtonBar",a&7);if(k){QH("id_dialogtitle",k)}for(var g=1;g<24;g++){QV("dialog"+g,g==j)}QV("dialog",j);if(d){if(j==2){QH("id_dialogOptions",d)}else{QH("id_dialogMessage",d)}}}function dialogclose(e){var c=xxdialogFunc;var a=xxdialogButtons;var d=xxdialogTag;setDialogMode();if(((a&8)||e)&&c){c(e,d)}}function center(){QS("dialog").left=((((getDocWidth()-300)/2))+"px");deskAdjust();deskAdjust()}function messagebox(b,a){QH("id_dialogMessage",a);setDialogMode(1,b,1)}function statusbox(b,a){QH("id_dialogMessage",a);setDialogMode(1,b)}function getDocWidth(){if(window.innerWidth){return window.innerWidth}if(document.documentElement&&document.documentElement.clientWidth&&document.documentElement.clientWidth!=0){return document.documentElement.clientWidth}return document.getElementsByTagName("body")[0].clientWidth}function haltEvent(a){if(a.preventDefault){a.preventDefault()}if(a.stopPropagation){a.stopPropagation()}return false}function haltReturn(a){if(a.keyCode==13){haltEvent(a)}}function validateEmail(b){var a=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return a.test(b)}function reload(){window.location.href=window.location.href}function getNodeFromId(b){for(var a in nodes){if(nodes[a]._id==b){return nodes[a]}}return null}function addHtmlValue(a,b){return""}function addHtmlValue2(a,b){return""}function addLink(b,a){return"♦ "+b+" "}function addLinkConditional(d,b,a){if(a){return addLink(d,b)}return d}function passwordcheck(a){var b=/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()]).{8,}/;return b.test(a)}function getFileSizeStr(a){if(a==1){return"1 byte"}return""+a+" bytes"}function joinPaths(){var c=[];for(var a in arguments){var b=arguments[a];if((b!=null)&&(b!="")){while(b.endsWith("/")||b.endsWith("\\")){b=b.substring(0,b.length-1)}while(b.startsWith("/")||b.startsWith("\\")){b=b.substring(1)}c.push(b)}}return c.join("/")}function focusTextBox(a){setTimeout(function(){Q(a).selectionStart=Q(a).selectionEnd=65535;Q(a).focus()},0)}var isFilenameValid=(function(){var b=/^[^\\/:\*\?"<>\|]+$/,c=/^\./,d=/^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i;return function a(e){return b.test(e)&&!c.test(e)&&!d.test(e)&&(e[0]!=".")}})();