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

1 line
21 KiB
JavaScript
Raw Normal View History

2021-04-29 09:22:54 +03:00
Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(e,t){return new Uint8Array(Array.prototype.slice.call(this,e,t))}});var CreateAgentRemoteDesktop=function(e,t){var l={};"string"==typeof(l.CanvasId=e)&&(l.CanvasId=Q(e)),l.Canvas=l.CanvasId.getContext("2d"),l.scrolldiv=t,l.State=0,l.PendingOperations=[],l.tilesReceived=0,l.TilesDrawn=0,l.KillDraw=0,l.ipad=!1,l.tabletKeyboardVisible=!1,l.LastX=0,l.LastY=0,l.touchenabled=0,l.submenuoffset=0,l.touchtimer=null,l.TouchArray={},l.connectmode=0,l.connectioncount=0,l.rotation=0,l.protocol=2,l.debugmode=0,l.firstUpKeys=[],l.stopInput=!1,l.localKeyMap=!0,l.remoteKeyMap=!1,l.pressedKeys=[],l.sessionid=0,l.username,l.oldie=!1,l.CompressionLevel=50,l.ScalingLevel=1024,l.FrameRateTimer=100,l.SwapMouse=!1,l.FirstDraw=!1,l.onRemoteInputLockChanged=null,l.RemoteInputLock=null,l.ScreenWidth=960,l.ScreenHeight=701,l.width=960,l.height=960,l.displays=null,l.selectedDisplay=null,l.onScreenSizeChange=null,l.onMessage=null,l.onConnectCountChanged=null,l.onDebugMessage=null,l.onTouchEnabledChanged=null,l.onDisplayinfo=null;var h=!(l.accumulator=null),g="default";l.mouseCursorActive=function(e){h!=e&&(h=e,l.CanvasId.style.cursor=1==e?g:"default")};var p=["default","progress","crosshair","pointer","help","text","no-drop","move","nesw-resize","ns-resize","nwse-resize","w-resize","alias","wait","none","not-allowed","col-resize","row-resize","copy","zoom-in","zoom-out"];l.Start=function(){l.State=0,l.accumulator=null},l.Stop=function(){l.setRotation(0),l.UnGrabKeyInput(),l.UnGrabMouseInput(),l.touchenabled=0,null!=l.onScreenSizeChange&&l.onScreenSizeChange(l,l.ScreenWidth,l.ScreenHeight,l.CanvasId),l.Canvas.clearRect(0,0,l.CanvasId.width,l.CanvasId.height)},l.xxStateChange=function(e){l.State!=e&&(l.State=e,l.CanvasId.style.cursor="default",0===e&&l.Stop())},l.send=function(e){2<l.debugmode&&console.log("KSend("+e.length+"): "+rstr2hex(e)),null!=l.parent&&l.parent.send(e)},l.ProcessPictureMsg=function(e,t,n){var o=new Image;o.xcount=l.tilesReceived++;for(var a=l.tilesReceived,r=e.slice(4),s=0,i=[];5e4<r.byteLength-s;)i.push(String.fromCharCode.apply(null,r.slice(s,s+5e4))),s+=5e4;0<s?i.push(String.fromCharCode.apply(null,r.slice(s))):i.push(String.fromCharCode.apply(null,r)),o.src="data:image/jpeg;base64,"+btoa(i.join("")),o.onload=function(){if(null!=l.Canvas&&l.KillDraw<a&&0!=l.State)for(l.PendingOperations.push([a,2,o,t,n]);l.DoPendingOperations(););else l.PendingOperations.push([a,0])},o.error=function(){console.log("DecodeTileError")}},l.DoPendingOperations=function(){if(0==l.PendingOperations.length)return!1;for(var e=0;e<l.PendingOperations.length;e++){var t=l.PendingOperations[e];if(t[0]==l.TilesDrawn+1)return 1==t[1]?l.ProcessCopyRectMsg(t[2]):2==t[1]&&(l.Canvas.drawImage(t[2],l.rotX(t[3],t[4]),l.rotY(t[3],t[4])),delete t[2]),l.PendingOperations.splice(e,1),delete t,l.TilesDrawn++,l.TilesDrawn==l.tilesReceived&&l.KillDraw<l.TilesDrawn&&(l.KillDraw=l.TilesDrawn=l.tilesReceived=0),!0}return l.oldie&&0<l.PendingOperations.length&&l.TilesDrawn++,!1},l.ProcessCopyRectMsg=function(e){var t=((255&e.charCodeAt(0))<<8)+(255&e.charCodeAt(1)),n=((255&e.charCodeAt(2))<<8)+(255&e.charCodeAt(3)),o=((255&e.charCodeAt(4))<<8)+(255&e.charCodeAt(5)),a=((255&e.charCodeAt(6))<<8)+(255&e.charCodeAt(7)),r=((255&e.charCodeAt(8))<<8)+(255&e.charCodeAt(9)),e=((255&e.charCodeAt(10))<<8)+(255&e.charCodeAt(11));l.Canvas.drawImage(Canvas.canvas,t,n,r,e,o,a,r,e)},l.SendUnPause=function(){1<l.debugmode&&console.log("SendUnPause"),l.send(String.fromCharCode(0,8,0,5,0))},l.SendPause=function(){1<l.debugmode&&console.log("SendPause"),l.send(String.fromCharCode(0,8,0,5,1))},l.SendCompressionLevel=function(e,t,n,o){t&&(l.CompressionLevel=t),n&&(l.ScalingLevel=n),o&&(l.FrameRateTimer=o),l.send(String.fromCharCode(0,5,0,10,e,l.CompressionLevel)+l.shortToStr(l.ScalingLevel)+l.shortToStr(l.FrameRateTimer))},l.SendRefresh=function(){l.send(String.fromCharCode(0,6,0,4))},l.ProcessScreenMsg=function(e,t){if(0<l.debugmode&&console.log("ScreenSize: "+e+" x "+t),l.ScreenWidth!=e||l.ScreenHei