Added device and device group notes on mobile web site.
Ylian Saint-Hilaire committed
Mar 18, 2021 at 21:09 UTC
9c2a2760871ab538ab7ff5ae8de9bf2a47abdfd0
7 files changed
+97
-54
public/images/views.png
Binary files a/public/images/views.png and b/public/images/views.png differ
public/scripts/agent-desktop-0.0.2-min.js
+1
-1
@@ -1 +1 @@
1
-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 l={};"string"==typeof(l.CanvasId=e)&&(l.CanvasId=Q(e)),l.Canvas=l.CanvasId.getContext("2d"),l.scrolldiv=t,l.State=0,l.PendingOperations=[],l.tilesReceived=0,l.TilesDrawn=0,l.KillDraw=0,l.ipad=!1,l.tabletKeyboardVisible=!1,l.LastX=0,l.LastY=0,l.touchenabled=0,l.submenuoffset=0,l.touchtimer=null,l.TouchArray={},l.connectmode=0,l.connectioncount=0,l.rotation=0,l.protocol=2,l.debugmode=0,l.firstUpKeys=[],l.stopInput=!1,l.localKeyMap=!0,l.remoteKeyMap=!1,l.pressedKeys=[],l.sessionid=0,l.username,l.oldie=!1,l.CompressionLevel=50,l.ScalingLevel=1024,l.FrameRateTimer=100,l.SwapMouse=!1,l.FirstDraw=!1,l.ScreenWidth=960,l.ScreenHeight=701,l.width=960,l.height=960,l.displays=null,l.selectedDisplay=null,l.onScreenSizeChange=null,l.onMessage=null,l.onConnectCountChanged=null,l.onDebugMessage=null,l.onTouchEnabledChanged=null,l.onDisplayinfo=null;var h=!(l.accumulator=null),g="default";l.mouseCursorActive=function(e){h!=e&&(h=e,l.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"];l.Start=function(){l.State=0,l.accumulator=null},l.Stop=function(){l.setRotation(0),l.UnGrabKeyInput(),l.UnGrabMouseInput(),l.touchenabled=0,null!=l.onScreenSizeChange&&l.onScreenSizeChange(l,l.ScreenWidth,l.ScreenHeight,l.CanvasId),l.Canvas.clearRect(0,0,l.CanvasId.width,l.CanvasId.height)},l.xxStateChange=function(e){l.State!=e&&(l.State=e,l.CanvasId.style.cursor="default",0===e&&l.Stop())},l.send=function(e){2<l.debugmode&&console.log("KSend("+e.length+"): "+rstr2hex(e)),null!=l.parent&&l.parent.send(e)},l.ProcessPictureMsg=function(e,t,n){var o=new Image;o.xcount=l.tilesReceived++;for(var a=l.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!=l.Canvas&&l.KillDraw<a&&0!=l.State)for(l.PendingOperations.push([a,2,o,t,n]);l.DoPendingOperations(););else l.PendingOperations.push([a,0])},o.error=function(){console.log("DecodeTileError")}},l.DoPendingOperations=function(){if(0==l.PendingOperations.length)return!1;for(var e=0;e<l.PendingOperations.length;e++){var t=l.PendingOperations[e];if(t[0]==l.TilesDrawn+1)return 1==t[1]?l.ProcessCopyRectMsg(t[2]):2==t[1]&&(l.Canvas.drawImage(t[2],l.rotX(t[3],t[4]),l.rotY(t[3],t[4])),delete t[2]),l.PendingOperations.splice(e,1),delete t,l.TilesDrawn++,l.TilesDrawn==l.tilesReceived&&l.KillDraw<l.TilesDrawn&&(l.KillDraw=l.TilesDrawn=l.tilesReceived=0),!0}return l.oldie&&0<l.PendingOperations.length&&l.TilesDrawn++,!1},l.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));l.Canvas.drawImage(Canvas.canvas,t,n,r,e,o,a,r,e)},l.SendUnPause=function(){1<l.debugmode&&console.log("SendUnPause"),l.send(String.fromCharCode(0,8,0,5,0))},l.SendPause=function(){1<l.debugmode&&console.log("SendPause"),l.send(String.fromCharCode(0,8,0,5,1))},l.SendCompressionLevel=function(e,t,n,o){t&&(l.CompressionLevel=t),n&&(l.ScalingLevel=n),o&&(l.FrameRateTimer=o),l.send(String.fromCharCode(0,5,0,10,e,l.CompressionLevel)+l.shortToStr(l.ScalingLevel)+l.shortToStr(l.FrameRateTimer))},l.SendRefresh=function(){l.send(String.fromCharCode(0,6,0,4))},l.ProcessScreenMsg=function(e,t){if(0<l.debugmode&&console.log("ScreenSize: "+e+" x "+t),l.ScreenWidth!=e||l.ScreenHeight!=t){for(l.Canvas.setTransform(1,0,0,1,0,0),l.rotation=0,l.FirstDraw=!0,l.ScreenWidth=l.width=e,l.ScreenHeight=l.height=t,l.KillDraw=l.tilesReceived;0<l.PendingOperations.length;)l.PendingOperations.shift();l.SendCompressionLevel(1),l.SendUnPause(),null!=l.onScreenSizeChange&&l.onScreenSizeChange(l,l.ScreenWidth,l.ScreenHeight,l.CanvasId)}},l.ProcessBinaryCommand=function(e,t,n){var o,a;switch(3!=e&&4!=e&&7!=e||(o=(n[4]<<8)+n[5],a=(n[6]<<8)+n[7]),2<l.debugmode&&console.log("CMD",e,t,o,a),null!=l.recordedData&&(65e3<t?l.recordedData.push(S(2,1,l.shortToStr(27)+l.shortToStr(8)+l.intToStr(t)+l.shortToStr(e)+l.shortToStr(0)+l.shortToStr(0)+l.shortToStr(0)+String.fromCharCode.apply(null,n))):l.recordedData.push(S(2,1,String.fromCharCode.apply(null,n)))),e){case 3:l.FirstDraw&&l.onResize(),l.ProcessPictureMsg(n.slice(4),o,a);break;case 7:l.ProcessScreenMsg(o,a),l.SendKeyMsgKC(l.KeyAction.UP,16),l.SendKeyMsgKC(l.KeyAction.UP,17),l.SendKeyMsgKC(l.KeyAction.UP,18),l.SendKeyMsgKC(l.KeyAction.UP,91),l.SendKeyMsgKC(l.KeyAction.UP,92),l.SendKeyMsgKC(l.KeyAction.UP,16),l.send(String.fromCharCode(0,14,0,4));break;case 11:var r=0,s={},i=(n[4]<<8)+n[5];if(0<i)for(var r=(n[6+2*i]<<8)+n[7+2*i],c=0;c<i;c++){var u=(n[6+2*c]<<8)+n[7+2*c];s[u]=65535==u?"All Displays":"Display "+u}l.displays=s,l.selectedDisplay=r,null!=l.onDisplayinfo&&l.onDisplayinfo(l,s,r);break;case 12:break;case 14:l.touchenabled=1,l.TouchArray={},null!=l.onTouchEnabledChanged&&l.onTouchEnabledChanged(l.touchenabled);break;case 15:l.TouchArray={};break;case 17:var d=String.fromCharCode.apply(null,data.slice(4));console.log("Got KVM Message: "+d),null!=l.onMessage&&l.onMessage(d,l);break;case 65:"."!=(d=String.fromCharCode.apply(null,data.slice(4)))[0]?(console.log(d),l.parent&&l.parent.setConsoleMessage&&l.parent.setConsoleMessage(d)):console.log("KVM: "+d.substring(1));break;case 88:if(5!=t||l.stopInput)break;d=n[4];g=p[d=p.length<d?0:d],h&&(l.CanvasId.style.cursor=g);break;default:console.log("Unknown command",e,t)}},l.MouseButton={NONE:0,LEFT:2,RIGHT:8,MIDDLE:32},l.KeyAction={NONE:0,DOWN:1,UP:2,SCROLL:3,EXUP:4,EXDOWN:5,DBLCLICK:6},l.InputType={KEY:1,MOUSE:2,CTRLALTDEL:10,TOUCH:15,KEYUNICODE:85},l.Alternate=0;var o={Pause:19,CapsLock:20,Space:32,Quote:222,Minus:189,NumpadMultiply:106,NumpadAdd:107,PrintScreen:44,Comma:188,NumpadSubtract:109,NumpadDecimal:110,Period:190,Slash:191,NumpadDivide:111,Semicolon:186,Equal:187,OSLeft:91,BracketLeft:219,OSRight:91,Backslash:220,BracketRight:221,ContextMenu:93,Backquote:192,NumLock:144,ScrollLock:145,Backspace:8,Tab:9,Enter:13,NumpadEnter:13,Escape:27,Delete:46,Home:36,PageUp:33,PageDown:34,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,End:35,Insert:45,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,MetaLeft:91,MetaRight:92,VolumeMute:181};function S(e,t,n){var o=Date.now();return"number"==typeof n?(l.recordedSize+=n,l.shortToStr(e)+l.shortToStr(t)+l.intToStr(n)+l.intToStr(o>>32)+l.intToStr(32&o)):(l.recordedSize+=n.length,l.shortToStr(e)+l.shortToStr(t)+l.intToStr(n.length)+l.intToStr(o>>32)+l.intToStr(32&o)+n)}return l.SendKeyMsg=function(e,t){var n;null!=e&&((t=t||window.event).code&&0==l.localKeyMap?null!=(n=(n=t).code.startsWith("Key")&&4==n.code.length?n.code.charCodeAt(3):n.code.startsWith("Digit")&&6==n.code.length?n.code.charCodeAt(5):n.code.startsWith("Numpad")&&7==n.code.length?n.code.charCodeAt(6)+48:o[n.code])&&l.SendKeyMsgKC(e,n):(59==(n=t.keyCode)?n=186:173==n?n=189:61==n&&(n=187),l.SendKeyMsgKC(e,n)))},l.SendMessage=function(e){3==l.State&&l.send(String.fromCharCode(0,17)+l.shortToStr(4+e.length)+e)},l.SendKeyMsgKC=function(e,t){if(3==l.State)if("object"==typeof e)for(var n in e)l.SendKeyMsgKC(e[n][0],e[n][1]);else 1==e?-1==l.pressedKeys.indexOf(t)&&l.pressedKeys.unshift(t):2==e&&-1!=(n=l.pressedKeys.indexOf(t))&&l.pressedKeys.splice(n,1),0<l.debugmode&&console.log("Sending Key "+t+", action "+e),l.send(String.fromCharCode(0,l.InputType.KEY,0,6,e-1,t))},l.SendStringUnicode=function(e){if(3==l.State)for(var t=0;t<e.length;t++)l.send(String.fromCharCode(0,l.InputType.KEYUNICODE,0,7,0)+ShortToStr(e.charCodeAt(t)))},l.SendKeyUnicode=function(e,t){3==l.State&&(0<l.debugmode&&console.log("Sending UnicodeKey "+t),l.send(String.fromCharCode(0,l.InputType.KEYUNICODE,0,7,e-1)+ShortToStr(t)))},l.sendcad=function(){l.SendCtrlAltDelMsg()},l.SendCtrlAltDelMsg=function(){3==l.State&&l.send(String.fromCharCode(0,l.InputType.CTRLALTDEL,0,4))},l.SendEscKey=function(){3==l.State&&l.send(String.fromCharCode(0,l.InputType.KEY,0,6,0,27,0,l.InputType.KEY,0,6,1,27))},l.SendStartMsg=function(){l.SendKeyMsgKC(l.KeyAction.EXDOWN,91),l.SendKeyMsgKC(l.KeyAction.EXUP,91)},l.SendCharmsMsg=function(){l.SendKeyMsgKC(l.KeyAction.EXDOWN,91),l.SendKeyMsgKC(l.KeyAction.DOWN,67),l.SendKeyMsgKC(l.KeyAction.UP,67),l.SendKeyMsgKC(l.KeyAction.EXUP,91)},l.SendTouchMsg1=function(e,t,n,o){3==l.State&&l.send(String.fromCharCode(0,l.InputType.TOUCH)+l.shortToStr(14)+String.fromCharCode(1,e)+l.intToStr(t)+l.shortToStr(n)+l.shortToStr(o))},l.SendTouchMsg2=function(e,t){var n,o,a="";for(o in l.TouchArray)o==e?n=t:1==l.TouchArray[o].f?(n=65542,l.TouchArray[o].f=3,0):2==l.TouchArray[o].f?(n=262144,0):n=131078,a+=String.fromCharCode(o)+l.intToStr(n)+l.shortToStr(l.TouchArray[o].x)+l.shortToStr(l.TouchArray[o].y),2==l.TouchArray[o].f&&delete l.TouchArray[o];3==l.State&&l.send(String.fromCharCode(0,l.InputType.TOUCH)+l.shortToStr(5+a.length)+String.fromCharCode(2)+a),0==Object.keys(l.TouchArray).length&&null!=l.touchtimer&&(clearInterval(l.touchtimer),l.touchtimer=null)},l.SendMouseMsg=function(e,t){var n,o,a,r,s,i;3==l.State&&null!=e&&null!=l.Canvas&&(t=t||window.event,s=l.Canvas.canvas.height/l.CanvasId.clientHeight,r=l.Canvas.canvas.width/l.CanvasId.clientWidth,i=l.GetPositionOfControl(l.Canvas.canvas),n=(t.pageX-i[0])*r,o=(t.pageY-i[1])*s,t.addx&&(n+=t.addx),t.addy&&(o+=t.addy),0<=n&&n<=l.Canvas.canvas.width&&0<=o&&o<=l.Canvas.canvas.height&&(r=a=0,e==l.KeyAction.UP||e==l.KeyAction.DOWN?t.which?a=1==t.which?l.MouseButton.LEFT:2==t.which?l.MouseButton.MIDDLE:l.MouseButton.RIGHT:t.button&&(a=0==t.button?l.MouseButton.LEFT:1==t.button?l.MouseButton.MIDDLE:l.MouseButton.RIGHT):e==l.KeyAction.SCROLL&&(t.detail?r=120*t.detail*-1:t.wheelDelta&&(r=3*t.wheelDelta)),!0===l.SwapMouse&&(a==l.MouseButton.LEFT?a=l.MouseButton.RIGHT:a==l.MouseButton.RIGHT&&(a=l.MouseButton.LEFT)),i="",i=e==l.KeyAction.DBLCLICK?String.fromCharCode(0,l.InputType.MOUSE,0,10,0,136,n/256&255,255&n,o/256&255,255&o):e==l.KeyAction.SCROLL?(t=r<(t=s=0)?(s=255-(Math.abs(r)>>8),255-(255&Math.abs(r))):(s=r>>8,255&r),String.fromCharCode(0,l.InputType.MOUSE,0,12,0,0,n/256&255,255&n,o/256&255,255&o,s,t)):String.fromCharCode(0,l.InputType.MOUSE,0,10,0,e==l.KeyAction.DOWN?a:2*a&255,n/256&255,255&n,o/256&255,255&o),l.Action==l.KeyAction.NONE?0==l.Alternate||l.ipad?(l.send(i),l.Alternate=1):l.Alternate=0:l.send(i)))},l.GetDisplayNumbers=function(){l.send(String.fromCharCode(0,11,0,4))},l.SetDisplay=function(e){l.send(String.fromCharCode(0,12,0,6,e>>8,255&e))},l.intToStr=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},l.shortToStr=function(e){return String.fromCharCode(e>>8&255,255&e)},l.onResize=function(){0!=l.ScreenWidth&&0!=l.ScreenHeight&&(l.Canvas.canvas.width==l.ScreenWidth&&l.Canvas.canvas.height==l.ScreenHeight||(l.FirstDraw&&(l.Canvas.canvas.width=l.ScreenWidth,l.Canvas.canvas.height=l.ScreenHeight,l.Canvas.fillRect(0,0,l.ScreenWidth,l.ScreenHeight),null!=l.onScreenSizeChange&&l.onScreenSizeChange(l,l.ScreenWidth,l.ScreenHeight,l.CanvasId)),l.FirstDraw=!1,1<l.debugmode&&console.log("onResize: "+l.ScreenWidth+" x "+l.ScreenHeight)))},l.xxMouseInputGrab=!1,l.xxKeyInputGrab=!1,l.xxMouseMove=function(e){return 3==l.State&&l.SendMouseMsg(l.KeyAction.NONE,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},l.xxMouseUp=function(e){return 3==l.State&&l.SendMouseMsg(l.KeyAction.UP,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},l.xxMouseDown=function(e){return 3==l.State&&l.SendMouseMsg(l.KeyAction.DOWN,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},l.xxMouseDblClick=function(e){return 3==l.State&&l.SendMouseMsg(l.KeyAction.DBLCLICK,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},l.xxDOMMouseScroll=function(e){return 3!=l.State||(l.SendMouseMsg(l.KeyAction.SCROLL,e),!1)},l.xxMouseWheel=function(e){return 3!=l.State||(l.SendMouseMsg(l.KeyAction.SCROLL,e),!1)},l.xxKeyUp=function(e){return"Dead"!=e.key&&3==l.State&&("string"==typeof e.key&&1==e.key.length&&1!=e.ctrlKey&&1!=e.altKey&&(0==l.remoteKeyMap||0<l.debugmode)?l.SendKeyUnicode(l.KeyAction.UP,e.key.charCodeAt(0)):l.SendKeyMsg(l.KeyAction.UP,e)),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},l.xxKeyDown=function(e){if("Dead"!=e.key&&3==l.State&&("string"!=typeof e.key||1!=e.key.length||1==e.ctrlKey||1==e.altKey||!(0==l.remoteKeyMap||0<l.debugmode)))return l.SendKeyMsg(l.KeyAction.DOWN,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},l.xxKeyPress=function(e){return"Dead"!=e.key&&3==l.State&&"string"==typeof e.key&&1==e.key.length&&1!=e.ctrlKey&&1!=e.altKey&&(0==l.remoteKeyMap||0<l.debugmode)&&l.SendKeyUnicode(l.KeyAction.DOWN,e.key.charCodeAt(0)),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},l.handleKeys=function(e){return 1!=l.stopInput&&3==desktop.State&&l.xxKeyPress(e)},l.handleKeyUp=function(e){return 1!=l.stopInput&&3==desktop.State&&(l.firstUpKeys.length<5&&(l.firstUpKeys.push(e.keyCode),5==l.firstUpKeys.length&&("16,17,91,91,16"!=(t=l.firstUpKeys.join(","))&&"16,17,18,91,92"!=t||(l.stopInput=!0))),l.xxKeyUp(e));var t},l.handleKeyDown=function(e){return 1!=l.stopInput&&3==desktop.State&&l.xxKeyDown(e)},l.handleReleaseKeys=function(){var e,t=JSON.parse(JSON.stringify(l.pressedKeys));for(e in t)l.SendKeyMsgKC(l.KeyAction.UP,t[e])},l.mousedblclick=function(e){return 1!=l.stopInput&&l.xxMouseDblClick(e)},l.mousedown=function(e){return 1!=l.stopInput&&l.xxMouseDown(e)},l.mouseup=function(e){return 1!=l.stopInput&&l.xxMouseUp(e)},l.mousemove=function(e){return 1!=l.stopInput&&l.xxMouseMove(e)},l.mousewheel=function(e){return 1!=l.stopInput&&l.xxMouseWheel(e)},l.xxMsTouchEvent=function(e){var t,n,o,a;if(4!=e.originalEvent.pointerType)return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),"MSPointerDown"==e.type||"MSPointerMove"==e.type||"MSPointerUp"==e.type?(t=0,n=e.originalEvent.pointerId%256,o=e.offsetX*(Canvas.canvas.width/l.CanvasId.clientWidth),a=e.offsetY*(Canvas.canvas.height/l.CanvasId.clientHeight),"MSPointerDown"==e.type?t=65542:"MSPointerMove"==e.type?t=131078:"MSPointerUp"==e.type&&(t=262144),l.TouchArray[n]||(l.TouchArray[n]={x:o,y:a}),l.SendTouchMsg2(n,t),"MSPointerUp"==e.type&&delete l.TouchArray[n]):alert(e.type),!0},l.xxTouchStart=function(e){if(3==l.State)if(e.preventDefault&&e.preventDefault(),0==l.touchenabled||1==l.touchenabled){var t;1<e.originalEvent.touches.length||(t=e.originalEvent.touches[0],e.which=1,l.LastX=e.pageX=t.pageX,l.LastY=e.pageY=t.pageY,l.SendMouseMsg(KeyAction.DOWN,e))}else{var n,o,a=l.GetPositionOfControl(Canvas.canvas);for(n in e.originalEvent.changedTouches)e.originalEvent.changedTouches[n].identifier&&(o=e.originalEvent.changedTouches[n].identifier%256,l.TouchArray[o]||(l.TouchArray[o]={x:(e.originalEvent.touches[n].pageX-a[0])*(Canvas.canvas.width/l.CanvasId.clientWidth),y:(e.originalEvent.touches[n].pageY-a[1])*(Canvas.canvas.height/l.CanvasId.clientHeight),f:1}));0<Object.keys(l.TouchArray).length&&null==touchtimer&&(l.touchtimer=setInterval(function(){l.SendTouchMsg2(256,0)},50))}},l.xxTouchMove=function(e){if(3==l.State)if(e.preventDefault&&e.preventDefault(),0==l.touchenabled||1==l.touchenabled){var t;1<e.originalEvent.touches.length||(t=e.originalEvent.touches[0],e.which=1,l.LastX=e.pageX=t.pageX,l.LastY=e.pageY=t.pageY,l.SendMouseMsg(l.KeyAction.NONE,e))}else{var n,o,a=l.GetPositionOfControl(Canvas.canvas);for(n in e.originalEvent.changedTouches)e.originalEvent.changedTouches[n].identifier&&(o=e.originalEvent.changedTouches[n].identifier%256,l.TouchArray[o]&&(l.TouchArray[o].x=(e.originalEvent.touches[n].pageX-a[0])*(l.Canvas.canvas.width/l.CanvasId.clientWidth),l.TouchArray[o].y=(e.originalEvent.touches[n].pageY-a[1])*(l.Canvas.canvas.height/l.CanvasId.clientHeight)))}},l.xxTouchEnd=function(e){if(3==l.State)if(e.preventDefault&&e.preventDefault(),0==l.touchenabled||1==l.touchenabled)1<e.originalEvent.touches.length||(e.which=1,e.pageX=LastX,e.pageY=LastY,l.SendMouseMsg(KeyAction.UP,e));else for(var t in e.originalEvent.changedTouches)e.originalEvent.changedTouches[t].identifier&&(t=e.originalEvent.changedTouches[t].identifier%256,l.TouchArray[t]&&(l.TouchArray[t].f=2))},l.GrabMouseInput=function(){var e;1!=l.xxMouseInputGrab&&((e=l.CanvasId).onmousemove=l.xxMouseMove,e.onmouseup=l.xxMouseUp,e.onmousedown=l.xxMouseDown,e.touchstart=l.xxTouchStart,e.touchmove=l.xxTouchMove,e.touchend=l.xxTouchEnd,e.MSPointerDown=l.xxMsTouchEvent,e.MSPointerMove=l.xxMsTouchEvent,e.MSPointerUp=l.xxMsTouchEvent,navigator.userAgent.match(/mozilla/i)?e.DOMMouseScroll=l.xxDOMMouseScroll:e.onmousewheel=l.xxMouseWheel,l.xxMouseInputGrab=!0)},l.UnGrabMouseInput=function(){var e;0!=l.xxMouseInputGrab&&((e=l.CanvasId).onmousemove=null,e.onmouseup=null,e.onmousedown=null,e.touchstart=null,e.touchmove=null,e.touchend=null,e.MSPointerDown=null,e.MSPointerMove=null,e.MSPointerUp=null,navigator.userAgent.match(/mozilla/i)?e.DOMMouseScroll=null:e.onmousewheel=null,l.xxMouseInputGrab=!1)},l.GrabKeyInput=function(){1!=l.xxKeyInputGrab&&(document.onkeyup=l.xxKeyUp,document.onkeydown=l.xxKeyDown,document.onkeypress=l.xxKeyPress,l.xxKeyInputGrab=!0)},l.UnGrabKeyInput=function(){0!=l.xxKeyInputGrab&&(document.onkeyup=null,document.onkeydown=null,document.onkeypress=null,l.xxKeyInputGrab=!1)},l.GetPositionOfControl=function(e){var t=Array(2);for(t[0]=t[1]=0;e;)t[0]+=e.offsetLeft,t[1]+=e.offsetTop,e=e.offsetParent;return t},l.crotX=function(e,t){return 0==l.rotation?e:1==l.rotation?t:2==l.rotation?l.Canvas.canvas.width-e:3==l.rotation?l.Canvas.canvas.height-t:void 0},l.crotY=function(e,t){return 0==l.rotation?t:1==l.rotation?l.Canvas.canvas.width-e:2==l.rotation?l.Canvas.canvas.height-t:3==l.rotation?e:void 0},l.rotX=function(e,t){return 0==l.rotation||1==l.rotation?e:2==l.rotation?e-l.Canvas.canvas.width:3==l.rotation?e-l.Canvas.canvas.height:void 0},l.rotY=function(e,t){return 0==l.rotation||3==l.rotation?t:1==l.rotation?t-l.Canvas.canvas.width:2==l.rotation?t-l.Canvas.canvas.height:void 0},l.tcanvas=null,l.setRotation=function(e){for(;e<0;)e+=4;var t=e%4;if(t==l.rotation)return!0;var n=l.Canvas.canvas.width,o=l.Canvas.canvas.height;1!=l.rotation&&3!=l.rotation||(n=l.Canvas.canvas.height,o=l.Canvas.canvas.width),null==l.tcanvas&&(l.tcanvas=document.createElement("canvas"));var a=l.tcanvas.getContext("2d");return a.setTransform(1,0,0,1,0,0),a.canvas.width=n,a.canvas.height=o,a.rotate(-90*l.rotation*Math.PI/180),0==l.rotation&&a.drawImage(l.Canvas.canvas,0,0),1==l.rotation&&a.drawImage(l.Canvas.canvas,-l.Canvas.canvas.width,0),2==l.rotation&&a.drawImage(l.Canvas.canvas,-l.Canvas.canvas.width,-l.Canvas.canvas.height),3==l.rotation&&a.drawImage(l.Canvas.canvas,0,-l.Canvas.canvas.height),0!=l.rotation&&2!=l.rotation||(l.Canvas.canvas.height=n,l.Canvas.canvas.width=o),1!=l.rotation&&3!=l.rotation||(l.Canvas.canvas.height=o,l.Canvas.canvas.width=n),l.Canvas.setTransform(1,0,0,1,0,0),l.Canvas.rotate(90*t*Math.PI/180),l.rotation=t,l.Canvas.drawImage(l.tcanvas,l.rotX(0,0),l.rotY(0,0)),l.ScreenWidth=l.Canvas.canvas.width,l.ScreenHeight=l.Canvas.canvas.height,null!=l.onScreenSizeChange&&l.onScreenSizeChange(l,l.ScreenWidth,l.ScreenHeight,l.CanvasId),!0},l.StartRecording=function(){null==l.recordedData&&l.CanvasId.toBlob(function(e){var s=new FileReader;s.readAsArrayBuffer(e),s.onload=function(e){for(var t="",n=new Uint8Array(s.result),o=n.byteLength,a=0;a<o;a++)t+=String.fromCharCode(n[a]);l.recordedData=[],l.recordedStart=Date.now(),l.recordedSize=0,l.recordedData.push(S(1,0,JSON.stringify({magic:"MeshCentralRelaySession",ver:1,time:(new Date).toLocaleString(),protocol:2}))),l.recordedData.push(S(2,1,l.shortToStr(7)+l.shortToStr(8)+l.shortToStr(l.ScreenWidth)+l.shortToStr(l.ScreenHeight)));var r=8+t.length;65e3<r?l.recordedData.push(S(2,1,l.shortToStr(27)+l.shortToStr(8)+l.intToStr(r)+l.shortToStr(3)+l.shortToStr(0)+l.shortToStr(0)+l.shortToStr(0)+t)):l.recordedData.push(S(2,1,l.shortToStr(3)+l.shortToStr(r)+l.shortToStr(0)+l.shortToStr(0)+t))}})},l.StopRecording=function(){if(null!=l.recordedData){var e=l.recordedData;return e.push(S(3,0,"MeshCentralMCREC")),delete l.recordedData,delete l.recordedStart,delete l.recordedSize,e}},l.MuchTheSame=function(e,t){return Math.abs(e-t)<4},l.Debug=function(e){console.log(e)},l.getIEVersion=function(){var e,t=-1;return"Microsoft Internet Explorer"==navigator.appName&&(e=navigator.userAgent,null!=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(e)&&(t=parseFloat(RegExp.$1))),t},l.haltEvent=function(e){return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},l}
\ No newline at end of file
1
+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.rotation=0,d.FirstDraw=!0,d.ScreenWidth=d.width=e,d.ScreenHeight=d.height=t,d.KillDraw=d.tilesReceived;0<d.PendingOperations.length;)d.PendingOperations.shift();d.SendCompressionLevel(1),d.SendUnPause(),null!=d.onScreenSizeChange&&d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)}},d.ProcessBinaryCommand=function(e,t,n){var o,a;switch(3!=e&&4!=e&&7!=e||(o=(n[4]<<8)+n[5],a=(n[6]<<8)+n[7]),2<d.debugmode&&console.log("CMD",e,t,o,a),null!=d.recordedData&&(65e3<t?d.recordedData.push(S(2,1,d.shortToStr(27)+d.shortToStr(8)+d.intToStr(t)+d.shortToStr(e)+d.shortToStr(0)+d.shortToStr(0)+d.shortToStr(0)+String.fromCharCode.apply(null,n))):d.recordedData.push(S(2,1,String.fromCharCode.apply(null,n)))),e){case 3:d.FirstDraw&&d.onResize(),d.ProcessPictureMsg(n.slice(4),o,a);break;case 7:d.ProcessScreenMsg(o,a),d.SendKeyMsgKC(d.KeyAction.UP,16),d.SendKeyMsgKC(d.KeyAction.UP,17),d.SendKeyMsgKC(d.KeyAction.UP,18),d.SendKeyMsgKC(d.KeyAction.UP,91),d.SendKeyMsgKC(d.KeyAction.UP,92),d.SendKeyMsgKC(d.KeyAction.UP,16),d.send(String.fromCharCode(0,14,0,4));break;case 11:var r=0,s={},i=(n[4]<<8)+n[5];if(0<i)for(var r=(n[6+2*i]<<8)+n[7+2*i],c=0;c<i;c++){var u=(n[6+2*c]<<8)+n[7+2*c];s[u]=65535==u?"All Displays":"Display "+u}d.displays=s,d.selectedDisplay=r,null!=d.onDisplayinfo&&d.onDisplayinfo(d,s,r);break;case 12:break;case 14:d.touchenabled=1,d.TouchArray={},null!=d.onTouchEnabledChanged&&d.onTouchEnabledChanged(d.touchenabled);break;case 15:d.TouchArray={};break;case 17:var l=String.fromCharCode.apply(null,n.slice(4));console.log("Got KVM Message: "+l),null!=d.onMessage&&d.onMessage(l,d);break;case 65:"."!=(l=String.fromCharCode.apply(null,n.slice(4)))[0]?(console.log(l),d.parent&&d.parent.setConsoleMessage&&d.parent.setConsoleMessage(l)):console.log("KVM: "+l.substring(1));break;case 88:if(5!=t||d.stopInput)break;l=n[4];g=p[l=p.length<l?0:l],h&&(d.CanvasId.style.cursor=g);break;default:console.log("Unknown command",e,t)}},d.MouseButton={NONE:0,LEFT:2,RIGHT:8,MIDDLE:32},d.KeyAction={NONE:0,DOWN:1,UP:2,SCROLL:3,EXUP:4,EXDOWN:5,DBLCLICK:6},d.InputType={KEY:1,MOUSE:2,CTRLALTDEL:10,TOUCH:15,KEYUNICODE:85},d.Alternate=0;var o={Pause:19,CapsLock:20,Space:32,Quote:222,Minus:189,NumpadMultiply:106,NumpadAdd:107,PrintScreen:44,Comma:188,NumpadSubtract:109,NumpadDecimal:110,Period:190,Slash:191,NumpadDivide:111,Semicolon:186,Equal:187,OSLeft:91,BracketLeft:219,OSRight:91,Backslash:220,BracketRight:221,ContextMenu:93,Backquote:192,NumLock:144,ScrollLock:145,Backspace:8,Tab:9,Enter:13,NumpadEnter:13,Escape:27,Delete:46,Home:36,PageUp:33,PageDown:34,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,End:35,Insert:45,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,MetaLeft:91,MetaRight:92,VolumeMute:181};function S(e,t,n){var o=Date.now();return"number"==typeof n?(d.recordedSize+=n,d.shortToStr(e)+d.shortToStr(t)+d.intToStr(n)+d.intToStr(o>>32)+d.intToStr(32&o)):(d.recordedSize+=n.length,d.shortToStr(e)+d.shortToStr(t)+d.intToStr(n.length)+d.intToStr(o>>32)+d.intToStr(32&o)+n)}return d.SendKeyMsg=function(e,t){var n;null!=e&&((t=t||window.event).code&&0==d.localKeyMap?null!=(n=(n=t).code.startsWith("Key")&&4==n.code.length?n.code.charCodeAt(3):n.code.startsWith("Digit")&&6==n.code.length?n.code.charCodeAt(5):n.code.startsWith("Numpad")&&7==n.code.length?n.code.charCodeAt(6)+48:o[n.code])&&d.SendKeyMsgKC(e,n):(59==(n=t.keyCode)?n=186:173==n?n=189:61==n&&(n=187),d.SendKeyMsgKC(e,n)))},d.SendMessage=function(e){3==d.State&&d.send(String.fromCharCode(0,17)+d.shortToStr(4+e.length)+e)},d.SendKeyMsgKC=function(e,t){if(3==d.State)if("object"==typeof e)for(var n in e)d.SendKeyMsgKC(e[n][0],e[n][1]);else 1==e?-1==d.pressedKeys.indexOf(t)&&d.pressedKeys.unshift(t):2==e&&-1!=(n=d.pressedKeys.indexOf(t))&&d.pressedKeys.splice(n,1),0<d.debugmode&&console.log("Sending Key "+t+", action "+e),d.send(String.fromCharCode(0,d.InputType.KEY,0,6,e-1,t))},d.SendStringUnicode=function(e){if(3==d.State)for(var t=0;t<e.length;t++)d.send(String.fromCharCode(0,d.InputType.KEYUNICODE,0,7,0)+ShortToStr(e.charCodeAt(t)))},d.SendKeyUnicode=function(e,t){3==d.State&&(0<d.debugmode&&console.log("Sending UnicodeKey "+t),d.send(String.fromCharCode(0,d.InputType.KEYUNICODE,0,7,e-1)+ShortToStr(t)))},d.sendcad=function(){d.SendCtrlAltDelMsg()},d.SendCtrlAltDelMsg=function(){3==d.State&&d.send(String.fromCharCode(0,d.InputType.CTRLALTDEL,0,4))},d.SendEscKey=function(){3==d.State&&d.send(String.fromCharCode(0,d.InputType.KEY,0,6,0,27,0,d.InputType.KEY,0,6,1,27))},d.SendStartMsg=function(){d.SendKeyMsgKC(d.KeyAction.EXDOWN,91),d.SendKeyMsgKC(d.KeyAction.EXUP,91)},d.SendCharmsMsg=function(){d.SendKeyMsgKC(d.KeyAction.EXDOWN,91),d.SendKeyMsgKC(d.KeyAction.DOWN,67),d.SendKeyMsgKC(d.KeyAction.UP,67),d.SendKeyMsgKC(d.KeyAction.EXUP,91)},d.SendTouchMsg1=function(e,t,n,o){3==d.State&&d.send(String.fromCharCode(0,d.InputType.TOUCH)+d.shortToStr(14)+String.fromCharCode(1,e)+d.intToStr(t)+d.shortToStr(n)+d.shortToStr(o))},d.SendTouchMsg2=function(e,t){var n,o,a="";for(o in d.TouchArray)o==e?n=t:1==d.TouchArray[o].f?(n=65542,d.TouchArray[o].f=3,0):2==d.TouchArray[o].f?(n=262144,0):n=131078,a+=String.fromCharCode(o)+d.intToStr(n)+d.shortToStr(d.TouchArray[o].x)+d.shortToStr(d.TouchArray[o].y),2==d.TouchArray[o].f&&delete d.TouchArray[o];3==d.State&&d.send(String.fromCharCode(0,d.InputType.TOUCH)+d.shortToStr(5+a.length)+String.fromCharCode(2)+a),0==Object.keys(d.TouchArray).length&&null!=d.touchtimer&&(clearInterval(d.touchtimer),d.touchtimer=null)},d.SendMouseMsg=function(e,t){var n,o,a,r,s,i;3==d.State&&null!=e&&null!=d.Canvas&&(t=t||window.event,s=d.Canvas.canvas.height/d.CanvasId.clientHeight,r=d.Canvas.canvas.width/d.CanvasId.clientWidth,i=d.GetPositionOfControl(d.Canvas.canvas),n=(t.pageX-i[0])*r,o=(t.pageY-i[1])*s,t.addx&&(n+=t.addx),t.addy&&(o+=t.addy),0<=n&&n<=d.Canvas.canvas.width&&0<=o&&o<=d.Canvas.canvas.height&&(r=a=0,e==d.KeyAction.UP||e==d.KeyAction.DOWN?t.which?a=1==t.which?d.MouseButton.LEFT:2==t.which?d.MouseButton.MIDDLE:d.MouseButton.RIGHT:t.button&&(a=0==t.button?d.MouseButton.LEFT:1==t.button?d.MouseButton.MIDDLE:d.MouseButton.RIGHT):e==d.KeyAction.SCROLL&&(t.detail?r=120*t.detail*-1:t.wheelDelta&&(r=3*t.wheelDelta)),!0===d.SwapMouse&&(a==d.MouseButton.LEFT?a=d.MouseButton.RIGHT:a==d.MouseButton.RIGHT&&(a=d.MouseButton.LEFT)),i="",i=e==d.KeyAction.DBLCLICK?String.fromCharCode(0,d.InputType.MOUSE,0,10,0,136,n/256&255,255&n,o/256&255,255&o):e==d.KeyAction.SCROLL?(t=r<(t=s=0)?(s=255-(Math.abs(r)>>8),255-(255&Math.abs(r))):(s=r>>8,255&r),String.fromCharCode(0,d.InputType.MOUSE,0,12,0,0,n/256&255,255&n,o/256&255,255&o,s,t)):String.fromCharCode(0,d.InputType.MOUSE,0,10,0,e==d.KeyAction.DOWN?a:2*a&255,n/256&255,255&n,o/256&255,255&o),d.Action==d.KeyAction.NONE?0==d.Alternate||d.ipad?(d.send(i),d.Alternate=1):d.Alternate=0:d.send(i)))},d.GetDisplayNumbers=function(){d.send(String.fromCharCode(0,11,0,4))},d.SetDisplay=function(e){d.send(String.fromCharCode(0,12,0,6,e>>8,255&e))},d.intToStr=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},d.shortToStr=function(e){return String.fromCharCode(e>>8&255,255&e)},d.onResize=function(){0!=d.ScreenWidth&&0!=d.ScreenHeight&&(d.Canvas.canvas.width==d.ScreenWidth&&d.Canvas.canvas.height==d.ScreenHeight||(d.FirstDraw&&(d.Canvas.canvas.width=d.ScreenWidth,d.Canvas.canvas.height=d.ScreenHeight,d.Canvas.fillRect(0,0,d.ScreenWidth,d.ScreenHeight),null!=d.onScreenSizeChange&&d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)),d.FirstDraw=!1,1<d.debugmode&&console.log("onResize: "+d.ScreenWidth+" x "+d.ScreenHeight)))},d.xxMouseInputGrab=!1,d.xxKeyInputGrab=!1,d.xxMouseMove=function(e){return 3==d.State&&d.SendMouseMsg(d.KeyAction.NONE,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},d.xxMouseUp=function(e){return 3==d.State&&d.SendMouseMsg(d.KeyAction.UP,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},d.xxMouseDown=function(e){return 3==d.State&&d.SendMouseMsg(d.KeyAction.DOWN,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},d.xxMouseDblClick=function(e){return 3==d.State&&d.SendMouseMsg(d.KeyAction.DBLCLICK,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},d.xxDOMMouseScroll=function(e){return 3!=d.State||(d.SendMouseMsg(d.KeyAction.SCROLL,e),!1)},d.xxMouseWheel=function(e){return 3!=d.State||(d.SendMouseMsg(d.KeyAction.SCROLL,e),!1)},d.xxKeyUp=function(e){return"Dead"!=e.key&&3==d.State&&("string"==typeof e.key&&1==e.key.length&&1!=e.ctrlKey&&1!=e.altKey&&(0==d.remoteKeyMap||0<d.debugmode)?d.SendKeyUnicode(d.KeyAction.UP,e.key.charCodeAt(0)):d.SendKeyMsg(d.KeyAction.UP,e)),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},d.xxKeyDown=function(e){if("Dead"!=e.key&&3==d.State&&("string"!=typeof e.key||1!=e.key.length||1==e.ctrlKey||1==e.altKey||!(0==d.remoteKeyMap||0<d.debugmode)))return d.SendKeyMsg(d.KeyAction.DOWN,e),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},d.xxKeyPress=function(e){return"Dead"!=e.key&&3==d.State&&"string"==typeof e.key&&1==e.key.length&&1!=e.ctrlKey&&1!=e.altKey&&(0==d.remoteKeyMap||0<d.debugmode)&&d.SendKeyUnicode(d.KeyAction.DOWN,e.key.charCodeAt(0)),e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},d.handleKeys=function(e){return 1!=d.stopInput&&3==desktop.State&&d.xxKeyPress(e)},d.handleKeyUp=function(e){return 1!=d.stopInput&&3==desktop.State&&(d.firstUpKeys.length<5&&(d.firstUpKeys.push(e.keyCode),5==d.firstUpKeys.length&&("16,17,91,91,16"!=(t=d.firstUpKeys.join(","))&&"16,17,18,91,92"!=t||(d.stopInput=!0))),d.xxKeyUp(e));var t},d.handleKeyDown=function(e){return 1!=d.stopInput&&3==desktop.State&&d.xxKeyDown(e)},d.handleReleaseKeys=function(){var e,t=JSON.parse(JSON.stringify(d.pressedKeys));for(e in t)d.SendKeyMsgKC(d.KeyAction.UP,t[e])},d.mousedblclick=function(e){return 1!=d.stopInput&&d.xxMouseDblClick(e)},d.mousedown=function(e){return 1!=d.stopInput&&d.xxMouseDown(e)},d.mouseup=function(e){return 1!=d.stopInput&&d.xxMouseUp(e)},d.mousemove=function(e){return 1!=d.stopInput&&d.xxMouseMove(e)},d.mousewheel=function(e){return 1!=d.stopInput&&d.xxMouseWheel(e)},d.xxMsTouchEvent=function(e){var t,n,o,a;if(4!=e.originalEvent.pointerType)return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),"MSPointerDown"==e.type||"MSPointerMove"==e.type||"MSPointerUp"==e.type?(t=0,n=e.originalEvent.pointerId%256,o=e.offsetX*(Canvas.canvas.width/d.CanvasId.clientWidth),a=e.offsetY*(Canvas.canvas.height/d.CanvasId.clientHeight),"MSPointerDown"==e.type?t=65542:"MSPointerMove"==e.type?t=131078:"MSPointerUp"==e.type&&(t=262144),d.TouchArray[n]||(d.TouchArray[n]={x:o,y:a}),d.SendTouchMsg2(n,t),"MSPointerUp"==e.type&&delete d.TouchArray[n]):alert(e.type),!0},d.xxTouchStart=function(e){if(3==d.State)if(e.preventDefault&&e.preventDefault(),0==d.touchenabled||1==d.touchenabled){var t;1<e.originalEvent.touches.length||(t=e.originalEvent.touches[0],e.which=1,d.LastX=e.pageX=t.pageX,d.LastY=e.pageY=t.pageY,d.SendMouseMsg(KeyAction.DOWN,e))}else{var n,o,a=d.GetPositionOfControl(Canvas.canvas);for(n in e.originalEvent.changedTouches)e.originalEvent.changedTouches[n].identifier&&(o=e.originalEvent.changedTouches[n].identifier%256,d.TouchArray[o]||(d.TouchArray[o]={x:(e.originalEvent.touches[n].pageX-a[0])*(Canvas.canvas.width/d.CanvasId.clientWidth),y:(e.originalEvent.touches[n].pageY-a[1])*(Canvas.canvas.height/d.CanvasId.clientHeight),f:1}));0<Object.keys(d.TouchArray).length&&null==touchtimer&&(d.touchtimer=setInterval(function(){d.SendTouchMsg2(256,0)},50))}},d.xxTouchMove=function(e){if(3==d.State)if(e.preventDefault&&e.preventDefault(),0==d.touchenabled||1==d.touchenabled){var t;1<e.originalEvent.touches.length||(t=e.originalEvent.touches[0],e.which=1,d.LastX=e.pageX=t.pageX,d.LastY=e.pageY=t.pageY,d.SendMouseMsg(d.KeyAction.NONE,e))}else{var n,o,a=d.GetPositionOfControl(Canvas.canvas);for(n in e.originalEvent.changedTouches)e.originalEvent.changedTouches[n].identifier&&(o=e.originalEvent.changedTouches[n].identifier%256,d.TouchArray[o]&&(d.TouchArray[o].x=(e.originalEvent.touches[n].pageX-a[0])*(d.Canvas.canvas.width/d.CanvasId.clientWidth),d.TouchArray[o].y=(e.originalEvent.touches[n].pageY-a[1])*(d.Canvas.canvas.height/d.CanvasId.clientHeight)))}},d.xxTouchEnd=function(e){if(3==d.State)if(e.preventDefault&&e.preventDefault(),0==d.touchenabled||1==d.touchenabled)1<e.originalEvent.touches.length||(e.which=1,e.pageX=LastX,e.pageY=LastY,d.SendMouseMsg(KeyAction.UP,e));else for(var t in e.originalEvent.changedTouches)e.originalEvent.changedTouches[t].identifier&&(t=e.originalEvent.changedTouches[t].identifier%256,d.TouchArray[t]&&(d.TouchArray[t].f=2))},d.GrabMouseInput=function(){var e;1!=d.xxMouseInputGrab&&((e=d.CanvasId).onmousemove=d.xxMouseMove,e.onmouseup=d.xxMouseUp,e.onmousedown=d.xxMouseDown,e.touchstart=d.xxTouchStart,e.touchmove=d.xxTouchMove,e.touchend=d.xxTouchEnd,e.MSPointerDown=d.xxMsTouchEvent,e.MSPointerMove=d.xxMsTouchEvent,e.MSPointerUp=d.xxMsTouchEvent,navigator.userAgent.match(/mozilla/i)?e.DOMMouseScroll=d.xxDOMMouseScroll:e.onmousewheel=d.xxMouseWheel,d.xxMouseInputGrab=!0)},d.UnGrabMouseInput=function(){var e;0!=d.xxMouseInputGrab&&((e=d.CanvasId).onmousemove=null,e.onmouseup=null,e.onmousedown=null,e.touchstart=null,e.touchmove=null,e.touchend=null,e.MSPointerDown=null,e.MSPointerMove=null,e.MSPointerUp=null,navigator.userAgent.match(/mozilla/i)?e.DOMMouseScroll=null:e.onmousewheel=null,d.xxMouseInputGrab=!1)},d.GrabKeyInput=function(){1!=d.xxKeyInputGrab&&(document.onkeyup=d.xxKeyUp,document.onkeydown=d.xxKeyDown,document.onkeypress=d.xxKeyPress,d.xxKeyInputGrab=!0)},d.UnGrabKeyInput=function(){0!=d.xxKeyInputGrab&&(document.onkeyup=null,document.onkeydown=null,document.onkeypress=null,d.xxKeyInputGrab=!1)},d.GetPositionOfControl=function(e){var t=Array(2);for(t[0]=t[1]=0;e;)t[0]+=e.offsetLeft,t[1]+=e.offsetTop,e=e.offsetParent;return t},d.crotX=function(e,t){return 0==d.rotation?e:1==d.rotation?t:2==d.rotation?d.Canvas.canvas.width-e:3==d.rotation?d.Canvas.canvas.height-t:void 0},d.crotY=function(e,t){return 0==d.rotation?t:1==d.rotation?d.Canvas.canvas.width-e:2==d.rotation?d.Canvas.canvas.height-t:3==d.rotation?e:void 0},d.rotX=function(e,t){return 0==d.rotation||1==d.rotation?e:2==d.rotation?e-d.Canvas.canvas.width:3==d.rotation?e-d.Canvas.canvas.height:void 0},d.rotY=function(e,t){return 0==d.rotation||3==d.rotation?t:1==d.rotation?t-d.Canvas.canvas.width:2==d.rotation?t-d.Canvas.canvas.height:void 0},d.tcanvas=null,d.setRotation=function(e){for(;e<0;)e+=4;var t=e%4;if(t==d.rotation)return!0;var n=d.Canvas.canvas.width,o=d.Canvas.canvas.height;1!=d.rotation&&3!=d.rotation||(n=d.Canvas.canvas.height,o=d.Canvas.canvas.width),null==d.tcanvas&&(d.tcanvas=document.createElement("canvas"));var a=d.tcanvas.getContext("2d");return a.setTransform(1,0,0,1,0,0),a.canvas.width=n,a.canvas.height=o,a.rotate(-90*d.rotation*Math.PI/180),0==d.rotation&&a.drawImage(d.Canvas.canvas,0,0),1==d.rotation&&a.drawImage(d.Canvas.canvas,-d.Canvas.canvas.width,0),2==d.rotation&&a.drawImage(d.Canvas.canvas,-d.Canvas.canvas.width,-d.Canvas.canvas.height),3==d.rotation&&a.drawImage(d.Canvas.canvas,0,-d.Canvas.canvas.height),0!=d.rotation&&2!=d.rotation||(d.Canvas.canvas.height=n,d.Canvas.canvas.width=o),1!=d.rotation&&3!=d.rotation||(d.Canvas.canvas.height=o,d.Canvas.canvas.width=n),d.Canvas.setTransform(1,0,0,1,0,0),d.Canvas.rotate(90*t*Math.PI/180),d.rotation=t,d.Canvas.drawImage(d.tcanvas,d.rotX(0,0),d.rotY(0,0)),d.ScreenWidth=d.Canvas.canvas.width,d.ScreenHeight=d.Canvas.canvas.height,null!=d.onScreenSizeChange&&(console.log("s4",d.ScreenWidth,d.ScreenHeight),d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)),!0},d.StartRecording=function(){null==d.recordedData&&d.CanvasId.toBlob(function(e){var s=new FileReader;s.readAsArrayBuffer(e),s.onload=function(e){for(var t="",n=new Uint8Array(s.result),o=n.byteLength,a=0;a<o;a++)t+=String.fromCharCode(n[a]);d.recordedData=[],d.recordedStart=Date.now(),d.recordedSize=0,d.recordedData.push(S(1,0,JSON.stringify({magic:"MeshCentralRelaySession",ver:1,time:(new Date).toLocaleString(),protocol:2}))),d.recordedData.push(S(2,1,d.shortToStr(7)+d.shortToStr(8)+d.shortToStr(d.ScreenWidth)+d.shortToStr(d.ScreenHeight)));var r=8+t.length;65e3<r?d.recordedData.push(S(2,1,d.shortToStr(27)+d.shortToStr(8)+d.intToStr(r)+d.shortToStr(3)+d.shortToStr(0)+d.shortToStr(0)+d.shortToStr(0)+t)):d.recordedData.push(S(2,1,d.shortToStr(3)+d.shortToStr(r)+d.shortToStr(0)+d.shortToStr(0)+t))}})},d.StopRecording=function(){if(null!=d.recordedData){var e=d.recordedData;return e.push(S(3,0,"MeshCentralMCREC")),delete d.recordedData,delete d.recordedStart,delete d.recordedSize,e}},d.MuchTheSame=function(e,t){return Math.abs(e-t)<4},d.Debug=function(e){console.log(e)},d.getIEVersion=function(){var e,t=-1;return"Microsoft Internet Explorer"==navigator.appName&&(e=navigator.userAgent,null!=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(e)&&(t=parseFloat(RegExp.$1))),t},d.haltEvent=function(e){return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1},d}
\ No newline at end of file
public/scripts/agent-desktop-0.0.2.js
+4
-3
@@ -78,7 +78,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
78
obj.UnGrabKeyInput();
79
obj.UnGrabMouseInput();
80
obj.touchenabled = 0;
81
- if (obj.onScreenSizeChange != null) obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId);
81
+ if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId); }
82
obj.Canvas.clearRect(0, 0, obj.CanvasId.width, obj.CanvasId.height);
83
}
84
@@ -193,6 +193,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
193
while (obj.PendingOperations.length > 0) { obj.PendingOperations.shift(); }
194
obj.SendCompressionLevel(1);
195
obj.SendUnPause();
196
+ // No need to event the display size change now, it will be evented on first draw.
197
if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId); }
198
}
199
@@ -520,7 +521,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
521
obj.Canvas.canvas.width = obj.ScreenWidth;
522
obj.Canvas.canvas.height = obj.ScreenHeight;
523
obj.Canvas.fillRect(0, 0, obj.ScreenWidth, obj.ScreenHeight);
523
- if (obj.onScreenSizeChange != null) obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId);
524
+ if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId); }
525
}
526
obj.FirstDraw = false;
527
if (obj.debugmode > 1) { console.log("onResize: " + obj.ScreenWidth + " x " + obj.ScreenHeight); }
@@ -789,7 +790,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
790
791
obj.ScreenWidth = obj.Canvas.canvas.width;
792
obj.ScreenHeight = obj.Canvas.canvas.height;
792
- if (obj.onScreenSizeChange != null) obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId);
793
+ if (obj.onScreenSizeChange != null) { console.log('s4', obj.ScreenWidth, obj.ScreenHeight); obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId); }
794
return true;
795
}
796
public/styles/style.css
+8
@@ -2851,6 +2851,14 @@ a {
2851
width: 28px;
2852
}
2853
2854
+.viewSelector7 {
2855
+ margin-left: 2px;
2856
+ margin-top: 2px;
2857
+ background: url(../images/views.png) -364px 0px;
2858
+ height: 28px;
2859
+ width: 28px;
2860
+}
2861
+
2862
.fulldesk .viewSelector5 {
2863
background: url(../images/views.png) -252px 0px;
2864
}
translate/translate.json
+8
-1
@@ -11945,10 +11945,17 @@
11945
"zh-chs": "台式机",
11946
"zh-cht": "台式電腦",
11947
"xloc": [
11948
- "default.handlebars->container->column_l->p1->devListToolbarSpan->1->0->9->devListToolbarView->viewselect->5",
11948
+ "default.handlebars->container->column_l->p1->devListToolbarSpan->1->0->9->devListToolbarView->viewselect->9",
11949
+ "default.handlebars->container->column_l->p1->p1title->devListToolbarViewIcons",
11950
"default.handlebars->container->column_l->p1->p1title->devListToolbarViewIcons"
11951
]
11952
},
11953
+ {
11954
+ "en": "Desktops Fixed Width",
11955
+ "xloc": [
11956
+ "default.handlebars->container->column_l->p1->devListToolbarSpan->1->0->9->devListToolbarView->viewselect->5"
11957
+ ]
11958
+ },
11959
{
11960
"cs": "Podrobnosti",
11961
"de": "Details",
views/default-mobile.handlebars
+27
-2
@@ -1497,6 +1497,20 @@
1497
updateDeviceDetails(getNodeFromId(message.nodeid), null, message);
1498
break;
1499
}
1500
+ case 'getNotes': {
1501
+ var n = Q('d2devNotes');
1502
+ if (n && (message.id == decodeURIComponent(n.attributes['noteid'].value))) {
1503
+ if (message.notes) { QH('d2devNotes', decodeURIComponent(message.notes)); } else { QH('d2devNotes', ''); }
1504
+ var ro = (n.attributes['ro'].value == 'true');
1505
+ if (ro == false) { // If we have permissions, set read/write on this note.
1506
+ n.removeAttribute('readonly');
1507
+ QE('idx_dlgOkButton', true);
1508
+ QV('idx_dlgOkButton', true);
1509
+ focusTextBox('d2devNotes');
1510
+ }
1511
+ }
1512
+ break;
1513
+ }
1514
case 'otpauth-request': {
1515
if ((xxdialogMode == 2) && (xxdialogTag == 'otpauth-request')) {
1516
var secret = message.secret;
@@ -3244,8 +3258,9 @@
3258
3259
x += '</table><br />';
3260
x += '<input type=button value=\"' + "Actions" + '\" onclick=deviceActionFunction() />';
3247
- //x += '<input type=button value=Notes onclick=showNotes(' + ((meshrights & 128) == 0) + ',"' + encodeURIComponent(node._id) + '") />';
3261
+ x += '<input type=button value=Notes onclick=showNotes(' + ((meshrights & 128) == 0) + ',"' + encodeURIComponent(node._id) + '") />';
3262
//if ((connectivity & 1) && (meshrights & 8) && (node.agent.id < 5)) { x += '<input type=button value=Toast onclick=deviceToastFunction() />'; }
3263
+
3264
QH('p10html', x);
3265
3266
// Show node last 7 days timeline
@@ -3355,6 +3370,16 @@
3370
setDialogMode(2, "Device Action", (count == 0) ? 1 : 3, deviceActionFunctionEx, x);
3371
}
3372
3373
+ function showNotes(readonly, noteid) {
3374
+ if (xxdialogMode) return;
3375
+ var x = '<textarea id=d2devNotes ro=' + readonly + ' noteid=' + noteid + ' readonly style=background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:scroll></textarea>';
3376
+ if (noteid.startsWith('node%2F%2F')) { x += '<span style=font-size:10px>' + "Device group notes can be viewed and changed by other device group administrators." + '<span>'; }
3377
+ setDialogMode(2, "Notes", 2, showNotesEx, x, noteid);
3378
+ meshserver.send({ action: 'getNotes', id: decodeURIComponent(noteid) });
3379
+ }
3380
+
3381
+ function showNotesEx(buttons, tag) { meshserver.send({ action: 'setNotes', id: decodeURIComponent(tag), notes: encodeURIComponentEx(Q('d2devNotes').value) }); }
3382
+
3383
function deviceChat(e) {
3384
if (xxdialogMode) return;
3385
setDialogMode(2, "Device Action", 3, function () {
@@ -5107,7 +5132,7 @@
5132
x += addHtmlValue("Type", meshtype);
5133
//x += addHtmlValue('Identifier', currentMesh._id.split('/')[2]);
5134
5110
- //x += '<br><input type=button value=Notes onclick=showNotes(false,"' + encodeURIComponent(currentMesh._id) + '") />';
5135
+ x += '<br><input type=button value=Notes onclick=showNotes(false,"' + encodeURIComponent(currentMesh._id) + '") />';
5136
5137
x += '<br style=clear:both><br>';
5138
var currentMeshLinks = currentMesh.links[userinfo._id];
views/default.handlebars
+49
-47
@@ -238,6 +238,7 @@
238
<div tabindex=0 id=devViewButton1 class=viewSelector onclick=onDeviceViewChange(1) onkeypress="if (event.key == 'Enter') { onDeviceViewChange(1); }" title="Columns"><div class="viewSelector2"></div></div>
239
<div tabindex=0 id=devViewButton2 class=viewSelector onclick=onDeviceViewChange(2) onkeypress="if (event.key == 'Enter') { onDeviceViewChange(2); }" title="List"><div class="viewSelector1"></div></div>
240
<div tabindex=0 id=devViewButton3 class=viewSelector onclick=onDeviceViewChange(3) onkeypress="if (event.key == 'Enter') { onDeviceViewChange(3); }" title="Desktops"><div class="viewSelector3"></div></div>
241
+ <div tabindex=0 id=devViewButton5 class=viewSelector onclick=onDeviceViewChange(5) onkeypress="if (event.key == 'Enter') { onDeviceViewChange(5); }" title="Desktops"><div class="viewSelector7"></div></div>
242
<div tabindex=0 id=devViewButton4 class=viewSelector onclick=onDeviceViewChange(4) onkeypress="if (event.key == 'Enter') { onDeviceViewChange(4); }" title="Map" style="display:none"><div class="viewSelector4"></div></div>
243
</div><div><h1>My Devices</h1></div>
244
</div>
@@ -283,8 +284,9 @@
284
<select id=viewselect onchange=onDeviceViewChange()>
285
<option value=1>Columns</option>
286
<option value=2>List</option>
286
- <option value=3>Desktops</option>
287
+ <option value=3>Desktops Fixed Width</option>
288
<option id=viewselectmapoption value=4 style="display:none">Map</option>
289
+ <option value=5>Desktops</option>
290
</select>
291
</div>
292
<div style="display:none" id=devListToolbarSort>
@@ -3357,7 +3359,7 @@
3359
3360
function onDeviceViewChange(i) {
3361
if (i != null) { Q('viewselect').value = i; }
3360
- for (var j = 1; j < 5; j++) { Q('devViewButton' + j).classList.remove('viewSelectorSel'); }
3362
+ for (var j = 1; j < 6; j++) { Q('devViewButton' + j).classList.remove('viewSelectorSel'); }
3363
Q('devViewButton' + Q('viewselect').value).classList.add('viewSelectorSel');
3364
putstore('deviceView', Q('viewselect').value);
3365
putstore('viewsize', Q('sizeselect').value);
@@ -3521,16 +3523,16 @@
3523
function updateDevices() {
3524
if ((nodes == null) || (xxcurrentView != 1)) { return; }
3525
var r = '', c = 0, current = null, count = 0, scount = 0, displayedMeshes = {}, view = Q('viewselect').value, groups = {}, groupCount = {};
3524
- QV('xdevices', view < 4);
3526
+ QV('xdevices', view != 4);
3527
QV('xdevicesmap', view == 4);
3528
QV('devListToolbar', view < 3);
3527
- QV('kvmListToolbar', view == 3);
3529
+ QV('kvmListToolbar', (view == 3) || (view == 5));
3530
QV('devMapToolbar', view == 4);
3529
- QV('devListToolbarSize', view == 3);
3531
+ QV('devListToolbarSize', (view == 3) || (view == 5));
3532
QV('NoMeshesPanel', (nodes.length == 0) && (meshcount == 0));
3533
//QV('devListToolbarView', (meshcount != 0) && (nodes.length > 0));
3534
QV('devListToolbarViewIcons', nodes.length > 0);
3533
- QV('devListToolbarSort', (nodes.length > 0) && (view < 4));
3535
+ QV('devListToolbarSort', (nodes.length > 0) && (view != 4));
3536
if (nodes.length == 0) { view = 1; sort = 0; }
3537
if (view == 4) {
3538
setTimeout( function() { if (xxmap.map != null) { xxmap.map.updateSize(); } }, 200);
@@ -3564,7 +3566,7 @@
3566
if (sort == 0) {
3567
// Mesh header
3568
if (((meshes[node.meshid]?node.meshid:'*') != current)) {
3567
- if (((view == 1) || (view == 3)) && (current != null)) { r += '</div>'; } // Close collapse div
3569
+ if (((view == 1) || (view == 3) || (view == 5)) && (current != null)) { r += '</div>'; } // Close collapse div
3570
deviceHeaderSet();
3571
var extra = '';
3572
if (view == 2) { r += '<tr><td colspan=5>'; }
@@ -3574,7 +3576,7 @@
3576
r += '<div class=DevSt style=width:100%;padding-top:4px><span style=float:right>';
3577
r += '<span id=DevxHeader' + deviceHeaderId + ' class=devHeaderx></span>' + extra;
3578
r += '</span>';
3577
- if ((view == 1) || (view == 2) || (view == 3)) {
3579
+ if ((view == 1) || (view == 2) || (view == 3) || (view == 5)) {
3580
var collapsed = CollapsedGroups[node.meshid];
3581
r += '<img class=collapseImage cmenu=expandAllContextMenu id="DevxColImg' + deviceHeaderId + '" src=images/c' + ((collapsed === true)?'1':'2') + '.png height=8 width=8 style=margin-left:2px;margin-right:2px;cursor:pointer onclick=toggleCollapseGroup("' + deviceHeaderId + '","' + node.meshid + '",' + view + ')></img>'; // Collapse action
3582
}
@@ -3588,19 +3590,19 @@
3590
if (view == 2) { r += '</div>'; }
3591
displayedMeshes[current] = 1;
3592
c = 0;
3591
- if ((view == 1) || (view == 3)) { r += '<div id=DevxCol' + deviceHeaderId + ((collapsed === true)?' style=display:none':'') + '>'; } // Open collapse div
3593
+ if ((view == 1) || (view == 3) || (view == 5)) { r += '<div id=DevxCol' + deviceHeaderId + ((collapsed === true)?' style=display:none':'') + '>'; } // Open collapse div
3594
}
3595
} else if (sort == 1) {
3596
// Power header
3597
var pwr = node.pwr?node.pwr:0;
3598
if (pwr !== current) {
3597
- if (((view == 1) || (view == 3)) && (current != null)) { r += '</div>'; } // Close collapse div
3599
+ if (((view == 1) || (view == 3) || (view == 5)) && (current != null)) { r += '</div>'; } // Close collapse div
3600
deviceHeaderSet();
3601
if ((view == 1) && (current !== null)) { if (c == 2) { r += '<td><div style=width:301px></div></td>'; } if (r != '') { r += '</tr></table>'; } }
3602
3603
if (view == 2) { r += '<tr><td colspan=5>'; }
3604
r += '<div class=DevSt style=width:100%;padding-top:4px><span id=DevxHeader' + deviceHeaderId + ' class=devHeaderx style=float:right></span>';
3603
- if ((view == 1) || (view == 2) || (view == 3)) {
3605
+ if ((view == 1) || (view == 2) || (view == 3) || (view == 5)) {
3606
var collapsed = CollapsedGroups['pwr:' + pwr];
3607
r += '<img class=collapseImage cmenu=expandAllContextMenu id="DevxColImg' + deviceHeaderId + '" src=images/c' + ((collapsed === true)?'1':'2') + '.png height=8 width=8 style=margin-left:2px;margin-right:2px;cursor:pointer onclick=toggleCollapseGroup("' + deviceHeaderId + '","pwr:' + pwr + '",' + view + ')></img>'; // Collapse action
3608
}
@@ -3608,7 +3610,7 @@
3610
3611
current = pwr;
3612
c = 0;
3611
- if ((view == 1) || (view == 3)) { r += '<div id=DevxCol' + deviceHeaderId + ((collapsed === true)?' style=display:none':'') + '>'; } // Open collapse div
3613
+ if ((view == 1) || (view == 3) || (view == 5)) { r += '<div id=DevxCol' + deviceHeaderId + ((collapsed === true)?' style=display:none':'') + '>'; } // Open collapse div
3614
}
3615
} else if (sort == 2) {
3616
// Device header
@@ -3626,10 +3628,10 @@
3628
else if ((sort == 3) || (sort == 4)) { collapseName = 'tag:**xx**xx*TaG*xx**xx**'; }
3629
var collapsed = (sort != 3) & (sort != 4) & CollapsedGroups[collapseName];
3630
r += '<tr name=xxdevice2 colname=DevxCol' + collapseName + ' style=height:20px' + (collapsed?';display:none':'') + ' id=xv2' + node._id + '></tr>';
3629
- } else if ((view == 3) && (node.conn & 1) && (((meshrights & 8) || (meshrights & 256)) != 0) && ((node.agent.caps & 1) != 0)) { // Check if we have rights and agent is capable of KVM.
3631
+ } else if (((view == 3) || (view == 5)) && (node.conn & 1) && (((meshrights & 8) || (meshrights & 256)) != 0) && ((node.agent.caps & 1) != 0)) { // Check if we have rights and agent is capable of KVM.
3632
// Draw the device (TODO: See if we can replace this with a standin in the future)
3633
if ((Object.keys(checkedNodeids).length == 0) || checkedNodeids[node._id]) {
3632
- r += updateDeviceViewHtml(3, null, node);
3634
+ r += updateDeviceViewHtml(view, null, node);
3635
kvmDivs.push(node._id);
3636
}
3637
}
@@ -3643,7 +3645,7 @@
3645
var collapsed = CollapsedGroups['tag:' + tag];
3646
var r2 = r.replace('**xx**xx*TaG*xx**xx**', encodeURIComponentEx(tag) + (collapsed?' style=display:none':''));
3647
if (groups[tag] == null) { groups[tag] = r2; groupCount[tag] = 1; } else { groups[tag] += r2; groupCount[tag] += 1; }
3646
- if (view == 3) break;
3648
+ if ((view == 3) || (view == 5)) break;
3649
}
3650
}
3651
r = '';
@@ -3762,21 +3764,24 @@
3764
p1updateInfo();
3765
3766
// Take care of KVM surfaces in desktop view mode
3765
- if ((view == 3) && (xxcurrentView == 1)) {
3767
+ if (((view == 3) || (view == 5)) && (xxcurrentView == 1)) {
3768
+
3769
// Figure out and adjust the size to fill the width of the div
3770
var vsize = [{ x: 180, y: 101 }, { x: 302, y: 169 }, { x: 454, y: 255 }][Q('sizeselect').selectedIndex];
3768
- //var realw = vsize.x + 2, tw = Q('xdevices').clientWidth - 30, xw = Math.floor(tw / realw);
3769
- var realw = vsize.x + 2, tw = totalDeviceViewWidth - 5, xw = Math.floor(tw / realw);
3770
- xw = realw + Math.floor((tw - (xw * realw)) / xw);
3771
- vsize.y = vsize.y * (xw / vsize.x);
3772
- vsize.x = xw;
3771
+ if ((view == 3)) { // If we are in fixed width mode, correct the size for the screen width.
3772
+ var realw = vsize.x + 2, tw = totalDeviceViewWidth - 5, xw = Math.floor(tw / realw);
3773
+ xw = realw + Math.floor((tw - (xw * realw)) / xw);
3774
+ vsize.y = vsize.y * (xw / vsize.x);
3775
+ vsize.x = xw;
3776
+ }
3777
3778
for (var i in multiDesktop) { multiDesktop[i].xxdelete = true; }
3779
for (var i in kvmDivs) {
3780
var id = kvmDivs[i], shortid = id.split('/')[2], desk = multiDesktop[id];
3781
if (desk != null) {
3782
// This device already has a canvas, use it.
3779
- desk.m.CanvasId.setAttribute('style', 'background-color:black;width:' + vsize.x + 'px;height:' + vsize.y + 'px');
3783
+ var width = (view == 5)?((desk.m.width * vsize.y) / desk.m.height):vsize.x;
3784
+ desk.m.CanvasId.setAttribute('style', 'background-color:black;width:' + width + 'px;height:' + vsize.y + 'px');
3785
Q('xkvmid_' + shortid).appendChild(desk.m.CanvasId);
3786
delete desk.xxdelete;
3787
QH('skvmid_' + shortid, ["Disconnected", "Connecting...", "Setup...", '', ''][((desk.m.State == null)?desk.m.state:desk.m.State)]);
@@ -3785,8 +3790,9 @@
3790
if ((desktopNode == node) && (desktop != null)) { // Check if the main desktop is this device, if it is, use that.
3791
// This device already has a canvas, use it.
3792
var c = desktop.m.CanvasId;
3793
+ var width = (view == 5)?((desktop.m.width * vsize.y) / desktop.m.height):vsize.x;
3794
c.setAttribute('id', 'kvmid_' + shortid);
3789
- c.setAttribute('style', 'background-color:black;width:' + vsize.x + 'px;height:' + vsize.y + 'px');
3795
+ c.setAttribute('style', 'background-color:black;width:' + width + 'px;height:' + vsize.y + 'px');
3796
c.setAttribute('onclick', 'toggleKvmDevice(\'' + id + '\')');
3797
c.removeAttribute('onmousedown');
3798
c.removeAttribute('onmouseup');
@@ -3977,12 +3983,12 @@
3983
r += '<div class=style10 style=cursor:pointer;font-size:14px title="' + title + '" onclick=gotoDevice(\'' + node._id + '\',null,null,event)><span style=width:300px>' + name + '</span></div></div>' + devNotify + '</td>';
3984
r += '<td style=text-align:center>' + getUserShortStr(node) + '<td style=text-align:center>' + (node.ip != null ? node.ip : '') + '<td style=text-align:center>' + states.join(' + ');
3985
div.innerHTML = r;
3980
- } else if (view == 3) {
3986
+ } else if ((view == 3) || (view == 5)) {
3987
// Draw the device and canvas
3988
var r = '<div id=devs cmenu=devsContentMenu style=display:inline-block;position:relative;margin:1px;background-color:lightgray;border-radius:5px;position:relative><div tabindex=0 style=padding:3px;cursor:pointer onclick=gotoDevice(\'' + node._id + '\',11,null,event) onkeypress="if (event.key==\'Enter\') gotoDevice(\'' + node._id + '\',11,null,event)">' + devNotify;
3989
//r += '<input class="' + node.meshid + ' DeviceCheckbox" onclick=p1updateInfo() value=devid_' + node._id + ' type=checkbox style=float:left>';
3990
r += '<div class="j' + icon + '" style=width:16px;float:left></div> ' + name + '</div>';
3985
- r += '<span onclick=gotoDevice(\'' + node._id + '\',null,null,event)></span><div id=xkvmid_' + node._id.split('/')[2] + '><div id=skvmid_' + node._id.split('/')[2] + ' tabindex=0 style="position:absolute;color:white;left:5px;top:27px;text-shadow:0px 0px 5px #000;z-index:1000;cursor:default" onclick=toggleKvmDevice(\'' + node._id + '\') onkeypress="if (event.key==\'Enter\') toggleKvmDevice(\'' + node._id + '\')">' + "Disconnected" + '</div></div>';
3991
+ r += '<span onclick=gotoDevice(\'' + node._id + '\',null,null,event)></span><div id=xkvmid_' + node._id.split('/')[2] + '><div id=skvmid_' + node._id.split('/')[2] + ' tabindex=0 style="position:absolute;color:white;left:5px;top:27px;text-shadow:0px 0px 5px #000;z-index:10;cursor:default" onclick=toggleKvmDevice(\'' + node._id + '\') onkeypress="if (event.key==\'Enter\') toggleKvmDevice(\'' + node._id + '\')">' + "Disconnected" + '</div></div>';
3992
r += '</div>';
3993
return r;
3994
}
@@ -4164,8 +4170,7 @@
4170
desk.m.useZRLE = true;
4171
desk.m.showmouse = true;
4172
desk.m.onKvmData = function (data) { console.log('KVM Data received in multi-desktop mode, this is not supported.'); }; // KVM Data Channel not supported in multi-desktop right now.
4167
- //desk.m.onScreenSizeChange = deskAdjust;
4168
- if (debugmode > 0) { desk.m.onScreenSizeChange = mdeskAdjust; } // Multi-Desktop Adjust
4173
+ desk.m.onScreenSizeChange = mdeskAdjust; // Multi-Desktop Adjust
4174
desk.Start(nodeid, 16994, '*', '*', 0);
4175
desk.contype = 2;
4176
multiDesktop[nodeid] = desk;
@@ -4183,8 +4188,8 @@
4188
if (multidesktopsettings.swapmouse) { desk.m.SwapMouse = multidesktopsettings.swapmouse; }
4189
if (multidesktopsettings.remotekeymap == true) { desk.m.remoteKeyMap = multidesktopsettings.remotekeymap; }
4190
//desk.m.onDisplayinfo = deskDisplayInfo;
4186
- //desk.m.onScreenSizeChange = deskAdjust;
4187
- if (debugmode > 0) { desk.m.onScreenSizeChange = mdeskAdjust; } // Multi-Desktop Adjust
4191
+ desk.m.onScreenSizeChange = mdeskAdjust; // Multi-Desktop Adjust
4192
+ //if (debugmode > 0) { desk.m.onScreenSizeChange = mdeskAdjust; }
4193
desk.Start(nodeid);
4194
desk.contype = 1;
4195
multiDesktop[nodeid] = desk;
@@ -7121,7 +7126,7 @@
7126
QV('d7meshkvm', (webRtcDesktop) || ((currentNode.agent != null) && (currentNode.agent.caps & 1) && ((deskState == false) || (desktop.contype == 1))));
7127
7128
// Enable buttons
7124
- var inputAllowed = (currentNode.agent.id != 14) && ((rights == 0xFFFFFFFF) || (((rights & 8) != 0) && ((rights & 256) == 0) && ((rights & 4096) == 0)));
7129
+ var inputAllowed = ((currentNode.agent == null) || (currentNode.agent.id != 14)) && ((rights == 0xFFFFFFFF) || (((rights & 8) != 0) && ((rights & 256) == 0) && ((rights & 4096) == 0)));
7130
var online = ((currentNode.conn & 1) != 0); // If Agent (1) connected, enable remote desktop
7131
QE('connectbutton1', online);
7132
var hwonline = ((currentNode.conn & 6) != 0); // If CIRA (2) or AMT (4) connected, enable hardware terminal
@@ -7561,6 +7566,7 @@
7566
}
7567
7568
function deskAdjust() {
7569
+ //if (xxcurrentView == 1) return;
7570
var parentH = Q('DeskParent').clientHeight, parentW = Q('DeskParent').clientWidth;
7571
var deskH = Q('Desk').height, deskW = Q('Desk').width;
7572
@@ -7582,10 +7588,10 @@
7588
if ((parentH / parentW) > (deskH / deskW)) {
7589
var hNew = ((deskH * parentW) / deskW) + 'px';
7590
//if (webPageFullScreen || fullscreen) {
7585
- //QS('deskarea3x').height = null;
7591
+ // QS('deskarea3x').height = null;
7592
//} else {
7587
- // QS('deskarea3x').height = hNew;
7588
- //QS('deskarea3x').height = null;
7593
+ // QS('deskarea3x').height = hNew;
7594
+ // QS('deskarea3x').height = null;
7595
//}
7596
QS('Desk').height = hNew;
7597
QS('Desk').width = '100%';
@@ -7603,24 +7609,20 @@
7609
}
7610
}
7611
7606
- function mdeskAdjust(mod, sw, sh, cv) {
7607
- if (!mod || !sw || !sh || !cv) return;
7612
+ function mdeskAdjust(module, sw, sh, cv) {
7613
+ if (!module || !sw || !sh || !cv) return;
7614
+ var view = Q('viewselect').value;
7615
+ if ((view != 3) && (view != 5)) return;
7616
7617
// Check if we are in single desktop mode
7618
if (cv.id == 'Desk') { deskAdjust(); return; }
7619
7612
- // Figure out and adjust the size to fill the width of the div
7613
- var vsize = [{ x: 180, y: 101 }, { x: 302, y: 169 }, { x: 454, y: 255 }][Q('sizeselect').selectedIndex];
7614
- var realw = vsize.x + 2, tw = Q('xdevices').clientWidth - 30, xw = Math.floor(tw / realw);
7615
- xw = realw + Math.floor((tw - (xw * realw)) / xw);
7616
- vsize.y = vsize.y * (xw / vsize.x);
7617
- vsize.x = xw;
7618
- var mh = vsize.y, mw = vsize.x;
7619
- if (mod.State != 0) { mh = vsize.y; mw = (sw / sh) * vsize.y; }
7620
- QS(cv.id)['max-height'] = mh + 'px';
7621
- QS(cv.id)['max-width'] = mw + 'px';
7622
- QS(cv.id)['margin-top'] = '0';
7623
- QS(cv.id)['margin-bottom'] = '0';
7620
+ if (view == 5) { // If not in fixed width mode, compute the with
7621
+ var vsize = [{ x: 180, y: 101 }, { x: 302, y: 169 }, { x: 454, y: 255 }][Q('sizeselect').selectedIndex];
7622
+ QS(cv.id)['width'] = ((module.State != 0)?((sw * vsize.y) / sh):(vsize.x)) + 'px';
7623
+ }
7624
+ QS(cv.id)['margin-top'] = null;
7625
+ QS(cv.id)['margin-bottom'] = null;
7626
}
7627
7628
// Press ESC key