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

1 line
20 KiB
JavaScript
Raw Normal View History

2020-05-24 06:12:08 +03:00
Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(e,n){return new Uint8Array(Array.prototype.slice.call(this,e,n))}});var CreateAgentRemoteDesktop=function(e,n){var h={};"string"==typeof(h.CanvasId=e)&&(h.CanvasId=Q(e)),h.Canvas=h.CanvasId.getContext("2d"),h.scrolldiv=n,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.pressedKeys=[],h.sessionid=0,h.username,h.oldie=!1,h.CompressionLevel=50,h.ScalingLevel=1024,h.FrameRateTimer=100,h.FirstDraw=!1,h.ScreenWidth=960,h.ScreenHeight=700,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 v=["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){1<h.debugmode&&console.log("KSend("+e.length+"): "+rstr2hex(e)),null!=h.parent&&h.parent.send(e)},h.ProcessPictureMsg=function(e,n,t){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,n,t]);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 n=h.PendingOperations[e];if(n[0]==h.TilesDrawn+1)return 1==n[1]?h.ProcessCopyRectMsg(n[2]):2==n[1]&&(h.Canvas.drawImage(n[2],h.rotX(n[3],n[4]),h.rotY(n[3],n[4])),delete n[2]),h.PendingOperations.splice(e,1),delete n,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 n=((255&e.charCodeAt(0))<<8)+(255&e.charCodeAt(1)),t=((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,n,t,r,i,o,a,r,i)},h.SendUnPause=function(){h.send(String.fromCharCode(0,8,0,5,0))},h.SendPause=function(){h.send(String.fromCharCode(0,8,0,5,1))},h.SendCompressionLevel=function(e,n,t,o){n&&(h.CompressionLevel=n),t&&(h.ScalingLevel=t),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,n){for(0<h.debugmode&&console.log("ScreenSize: "+e+" x "+n),h.Canvas.setTransform(1,0,0,1,0,0),h.rotation=0,h.FirstDraw=!0,h.ScreenWidth=h.width=e,h.ScreenHeight=h.height=n,h.KillDraw=h.tilesReceived;0<h.PendingOperations.length;)h.PendingOperatio