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