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