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

1 line
21 KiB
JavaScript
Raw Normal View History

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 d={};"string"==typeof(d.CanvasId=e)&&(d.CanvasId=Q(e)),d.Canvas=d.CanvasId.getContext("2d"),d.scrolldiv=t,d.State=0,d.PendingOperations=[],d.tilesReceived=0,d.TilesDrawn=0,d.KillDraw=0,d.ipad=!1,d.tabletKeyboardVisible=!1,d.LastX=0,d.LastY=0,d.touchenabled=0,d.submenuoffset=0,d.touchtimer=null,d.TouchArray={},d.connectmode=0,d.connectioncount=0,d.rotation=0,d.protocol=2,d.debugmode=0,d.firstUpKeys=[],d.stopInput=!1,d.localKeyMap=!0,d.remoteKeyMap=!1,d.pressedKeys=[],d.sessionid=0,d.username,d.oldie=!1,d.CompressionLevel=50,d.ScalingLevel=1024,d.FrameRateTimer=100,d.SwapMouse=!1,d.FirstDraw=!1,d.ScreenWidth=960,d.ScreenHeight=701,d.width=960,d.height=960,d.displays=null,d.selectedDisplay=null,d.onScreenSizeChange=null,d.onMessage=null,d.onConnectCountChanged=null,d.onDebugMessage=null,d.onTouchEnabledChanged=null,d.onDisplayinfo=null;var h=!(d.accumulator=null),g="default";d.mouseCursorActive=function(e){h!=e&&(h=e,d.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"];d.Start=function(){d.State=0,d.accumulator=null},d.Stop=function(){d.setRotation(0),d.UnGrabKeyInput(),d.UnGrabMouseInput(),d.touchenabled=0,null!=d.onScreenSizeChange&&d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId),d.Canvas.clearRect(0,0,d.CanvasId.width,d.CanvasId.height)},d.xxStateChange=function(e){d.State!=e&&(d.State=e,d.CanvasId.style.cursor="default",0===e&&d.Stop())},d.send=function(e){2<d.debugmode&&console.log("KSend("+e.length+"): "+rstr2hex(e)),null!=d.parent&&d.parent.send(e)},d.ProcessPictureMsg=function(e,t,n){var o=new Image;o.xcount=d.tilesReceived++;for(var a=d.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!=d.Canvas&&d.KillDraw<a&&0!=d.State)for(d.PendingOperations.push([a,2,o,t,n]);d.DoPendingOperations(););else d.PendingOperations.push([a,0])},o.error=function(){console.log("DecodeTileError")}},d.DoPendingOperations=function(){if(0==d.PendingOperations.length)return!1;for(var e=0;e<d.PendingOperations.length;e++){var t=d.PendingOperations[e];if(t[0]==d.TilesDrawn+1)return 1==t[1]?d.ProcessCopyRectMsg(t[2]):2==t[1]&&(d.Canvas.drawImage(t[2],d.rotX(t[3],t[4]),d.rotY(t[3],t[4])),delete t[2]),d.PendingOperations.splice(e,1),delete t,d.TilesDrawn++,d.TilesDrawn==d.tilesReceived&&d.KillDraw<d.TilesDrawn&&(d.KillDraw=d.TilesDrawn=d.tilesReceived=0),!0}return d.oldie&&0<d.PendingOperations.length&&d.TilesDrawn++,!1},d.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));d.Canvas.drawImage(Canvas.canvas,t,n,r,e,o,a,r,e)},d.SendUnPause=function(){1<d.debugmode&&console.log("SendUnPause"),d.send(String.fromCharCode(0,8,0,5,0))},d.SendPause=function(){1<d.debugmode&&console.log("SendPause"),d.send(String.fromCharCode(0,8,0,5,1))},d.SendCompressionLevel=function(e,t,n,o){t&&(d.CompressionLevel=t),n&&(d.ScalingLevel=n),o&&(d.FrameRateTimer=o),d.send(String.fromCharCode(0,5,0,10,e,d.CompressionLevel)+d.shortToStr(d.ScalingLevel)+d.shortToStr(d.FrameRateTimer))},d.SendRefresh=function(){d.send(String.fromCharCode(0,6,0,4))},d.ProcessScreenMsg=function(e,t){if(0<d.debugmode&&console.log("ScreenSize: "+e+" x "+t),d.ScreenWidth!=e||d.ScreenHeight!=t){for(d.Canvas.setTransform(1,0,0,1,0,0),d.rotati