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

1 line
21 KiB
JavaScript
Raw Normal View History

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