MeshCentral/public/scripts/amt-desktop-0.0.2-min.js

1 line
15 KiB
JavaScript
Raw Normal View History

2021-10-15 05:00:14 +03:00
var CreateAmtRemoteDesktop=function(a,t){var S={};function p(a){return String.fromCharCode.apply(null,a)}function m(a,t,e,n,o,r,i){var s,c,h,d,v=a[t++],f={},u=0,l=0;if(0==v){if(2==S.bpp)for(d=0;d<i;d++)b(a[t++]+(a[t++]<<8),d);else for(d=0;d<i;d++)y(a[t++],d);w(S.spare,e,n)}else if(1==v){c=a[t++]+(2==S.bpp?a[t++]<<8:0),S.canvas.fillStyle="rgb("+(1==S.bpp?(224&c)+","+((28&c)<<3)+","+L((3&c)<<6):(c>>8&248)+","+(c>>3&252)+","+((31&c)<<3))+")";var g=k(e);n=K(0,n),e=g,S.canvas.fillRect(e,n,o,r)}else if(1<v&&v<17){var p=4,m=15;if(2==S.bpp){for(d=0;d<v;d++)f[d]=a[t++]+(a[t++]<<8);for(2==v?m=p=1:v<=4&&(p=2,m=3);u<i&&t<a.byteLength;)for(c=a[t++],d=8-p;0<=d;d-=p)b(f[c>>d&m],u++)}else{for(d=0;d<v;d++)f[d]=a[t++];for(2==v?m=p=1:v<=4&&(p=2,m=3);u<i&&t<a.byteLength;)for(c=a[t++],d=8-p;0<=d;d-=p)y(f[c>>d&m],u++)}w(S.spare,e,n)}else if(128==v){if(2==S.bpp)for(;u<i&&t<a.byteLength;){for(c=a[t++]+(a[t++]<<8),l=1;l+=h=a[t++],255==h;);if(0==S.rotation)D(c,u,l),u+=l;else for(;0<=--l;)b(c,u++)}else for(;u<i&&t<a.byteLength;){for(c=a[t++],l=1;l+=h=a[t++],255==h;);if(0==S.rotation)C(c,u,l),u+=l;else for(;0<=--l;)y(c,u++)}w(S.spare,e,n)}else if(129<v){if(2==S.bpp)for(d=0;d<v-128;d++)f[d]=a[t++]+(a[t++]<<8);else for(d=0;d<v-128;d++)f[d]=a[t++];for(;u<i&&t<a.byteLength;){if(l=1,c=f[(s=a[t++])%128],127<s)for(;l+=h=a[t++],255==h;);if(0==S.rotation)(2==S.bpp?D:C)(c,u,l),u+=l;else if(2==S.bpp)for(;0<=--l;)b(c,u++);else for(;0<=--l;)y(c,u++)}w(S.spare,e,n)}}function w(a,t,e){var n,o,r;1!=S.holding&&(o=t,r=e,n=0==S.rotation?o:1==S.rotation?S.canvas.canvas.width-S.sparew2-r:2==S.rotation?S.canvas.canvas.width-S.sparew2-o:3==S.rotation?r:0,o=t,r=e,e=0==S.rotation?r:1==S.rotation?o:2==S.rotation?S.canvas.canvas.height-S.spareh2-r:3==S.rotation?S.canvas.canvas.height-S.spareh-o:0,t=n,S.canvas.putImageData(a,t,e))}function y(a,t){var e,n,o=t<<2;0<S.rotation&&(1==S.rotation?(e=t%S.sparew,n=Math.floor(t/S.sparew),o=(t=e*S.sparew2+(S.sparew2-1-n))<<2):2==S.rotation?o=S.sparew*S.spareh*4-4-o:3==S.rotation&&(e=t%S.sparew,n=Math.floor(t/S.sparew),o=(t=(S.sparew2-1-e)*S.sparew2+n)<<2)),S.spare.data[o]=224&a,S.spare.data[o+1]=(28&a)<<3,S.spare.data[o+2]=L((3&a)<<6)}function b(a,t){var e,n,o=t<<2;0<S.rotation&&(1==S.rotation?(e=t%S.sparew,n=Math.floor(t/S.sparew),o=(t=e*S.sparew2+(S.sparew2-1-n))<<2):2==S.rotation?o=S.sparew*S.spareh*4-4-o:3==S.rotation&&(e=t%S.sparew,n=Math.floor(t/S.sparew),o=(t=(S.sparew2-1-e)*S.sparew2+n)<<2)),S.spare.data[o]=a>>8&248,S.spare.data[o+1]=a>>3&252,S.spare.data[o+2]=(31&a)<<3}function C(a,t,e){for(var n=t<<2,o=224&a,r=(28&a)<<3,i=L((3&a)<<6);0<=--e;)S.spare.data[n]=o,S.spare.data[n+1]=r,S.spare.data[n+2]=i,n+=4}function D(a,t,e){for(var n=t<<2,o=a>>8&248,r=a>>3&252,i=(31&a)<<3;0<=--e;)S.spare.data[n]=o,S.spare.data[n+1]=r,S.spare.data[n+2]=i,n+=4}function k(a){return 0==S.rotation||1==S.rotation?a:2==S.rotation?a-S.canvas.canvas.width:3==S.rotation?a-S.canvas.canvas.height:0}function K(a,t){return 0==S.rotation?t:1==S.rotation?t-S.canvas.canvas.width:2==S.rotation?t-S.canvas.canvas.height:3==S.rotation?t:0}function L(a){return 127<a?a+32:a}function T(){var a;1!=S.holding&&(0<S.focusmode?(a=2*S.focusmode,S.send(String.fromCharCode(3,1)+ShortToStr(Math.max(Math.min(S.ox,S.mx)-S.focusmode,0))+ShortToStr(Math.max(Math.min(S.oy,S.my)-S.focusmode,0))+ShortToStr(a+Math.abs(S.ox-S.mx))+ShortToStr(a+Math.abs(S.oy-S.my))),S.ox=S.mx,S.oy=S.my):S.send(String.fromCharCode(3,1,0,0,0,0)+ShortToStr(S.rwidth)+ShortToStr(S.rheight)))}S.canvasid=a,S.CanvasId=Q(a),S.scrolldiv=t,S.canvas=Q(a).getContext("2d"),S.protocol=2,S.state=0,S.acc=null,S.ScreenWidth=960,S.ScreenHeight=700,S.width=0,S.height=0,S.rwidth=0,S.rheight=0,S.bpp=2,S.useZRLE=!0,S.showmouse=!0,S.buttonmask=0,S.localKeyMap=!0,S.spare=null,S.sparew=0,S.spareh=0,S.sparew2=0,S.spareh2=0,S.sparecache={},S.ZRLEfirst=1,S.onScreenSizeChange=null,S.frameRateDelay=0,S.noMouseRotate=!1,S.rotation=0,S.kvmDataSupported=!1,S.onKvmData=null,S.onKvmDataPending=[],S.onKvmDataAck=-1,S.holding=!1,S.lastKeepAlive=Date.now(),S.SwapMouse=!1,S.mNagleTimer=null,S.mx=0,S.my=0,S.ox=-1,S.oy=-1,S.focusmode=0,S.inflate