mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-30 09:03:20 -05:00
1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
|
var CreateAmtRemoteDesktop=function(a,t){var S={};function w(a,t,e,n,o,r,c){var s,i,h,d,f=a.charCodeAt(t++),v={},l=0,u=0;if(0==f){if(2==S.bpp)for(d=0;d<c;d++)A(a.charCodeAt(t++)+(a.charCodeAt(t++)<<8),d);else for(d=0;d<c;d++)y(a.charCodeAt(t++),d);C(S.spare,e,n)}else if(1==f){i=a.charCodeAt(t++)+(2==S.bpp?a.charCodeAt(t++)<<8:0),S.canvas.fillStyle="rgb("+(1==S.bpp?(224&i)+","+((28&i)<<3)+","+T((3&i)<<6):(i>>8&248)+","+(i>>3&252)+","+((31&i)<<3))+")";var p=k(e,n);n=K(e,n),e=p,S.canvas.fillRect(e,n,o,r)}else if(1<f&&f<17){var m=4,g=15;if(2==S.bpp){for(d=0;d<f;d++)v[d]=a.charCodeAt(t++)+(a.charCodeAt(t++)<<8);for(2==f?g=m=1:f<=4&&(m=2,g=3);l<c&&t<a.length;)for(i=a.charCodeAt(t++),d=8-m;0<=d;d-=m)A(v[i>>d&g],l++)}else{for(d=0;d<f;d++)v[d]=a.charCodeAt(t++);for(2==f?g=m=1:f<=4&&(m=2,g=3);l<c&&t<a.length;)for(i=a.charCodeAt(t++),d=8-m;0<=d;d-=m)y(v[i>>d&g],l++)}C(S.spare,e,n)}else if(128==f){if(2==S.bpp)for(;l<c&&t<a.length;){for(i=a.charCodeAt(t++)+(a.charCodeAt(t++)<<8),u=1;u+=h=a.charCodeAt(t++),255==h;);if(0==S.rotation)b(i,l,u),l+=u;else for(;0<=--u;)A(i,l++)}else for(;l<c&&t<a.length;){for(i=a.charCodeAt(t++),u=1;u+=h=a.charCodeAt(t++),255==h;);if(0==S.rotation)D(i,l,u),l+=u;else for(;0<=--u;)y(i,l++)}C(S.spare,e,n)}else if(129<f){if(2==S.bpp)for(d=0;d<f-128;d++)v[d]=a.charCodeAt(t++)+(a.charCodeAt(t++)<<8);else for(d=0;d<f-128;d++)v[d]=a.charCodeAt(t++);for(;l<c&&t<a.length;){if(u=1,i=v[(s=a.charCodeAt(t++))%128],127<s)for(;u+=h=a.charCodeAt(t++),255==h;);if(0==S.rotation)2==S.bpp?b(i,l,u):D(i,l,u),l+=u;else if(2==S.bpp)for(;0<=--u;)A(i,l++);else for(;0<=--u;)y(i,l++)}C(S.spare,e,n)}}function C(a,t,e){if(1!=S.holding){var n=function(a,t){return 0==S.rotation?a:1==S.rotation?S.canvas.canvas.width-S.sparew2-t:2==S.rotation?S.canvas.canvas.width-S.sparew2-a:3==S.rotation?t:0}(t,e);e=function(a,t){return 0==S.rotation?t:1==S.rotation?a:2==S.rotation?S.canvas.canvas.height-S.spareh2-t:3==S.rotation?S.canvas.canvas.height-S.spareh-a:0}(t,e),t=n,S.canvas.putImageData(a,t,e)}}function y(a,t){var e=t<<2;if(0<S.rotation)if(1==S.rotation){var n=t%S.sparew,o=Math.floor(t/S.sparew);e=(t=n*S.sparew2+(S.sparew2-1-o))<<2}else if(2==S.rotation)e=S.sparew*S.spareh*4-4-e;else if(3==S.rotation){n=t%S.sparew,o=Math.floor(t/S.sparew);e=(t=(S.sparew2-1-n)*S.sparew2+o)<<2}S.spare.data[e]=224&a,S.spare.data[e+1]=(28&a)<<3,S.spare.data[e+2]=T((3&a)<<6)}function A(a,t){var e=t<<2;if(0<S.rotation)if(1==S.rotation){var n=t%S.sparew,o=Math.floor(t/S.sparew);e=(t=n*S.sparew2+(S.sparew2-1-o))<<2}else if(2==S.rotation)e=S.sparew*S.spareh*4-4-e;else if(3==S.rotation){n=t%S.sparew,o=Math.floor(t/S.sparew);e=(t=(S.sparew2-1-n)*S.sparew2+o)<<2}S.spare.data[e]=a>>8&248,S.spare.data[e+1]=a>>3&252,S.spare.data[e+2]=(31&a)<<3}function D(a,t,e){for(var n=t<<2,o=224&a,r=(28&a)<<3,c=T((3&a)<<6);0<=--e;)S.spare.data[n]=o,S.spare.data[n+1]=r,S.spare.data[n+2]=c,n+=4}function b(a,t,e){for(var n=t<<2,o=a>>8&248,r=a>>3&252,c=(31&a)<<3;0<=--e;)S.spare.data[n]=o,S.spare.data[n+1]=r,S.spare.data[n+2]=c,n+=4}function k(a){return 0==S.rotation?a: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 T(a){return 127<a?a+32:a}function R(){if(1!=S.holding)if(0<S.focusmode){var 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}else 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="",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.noM
|