Added PowerShell support

Ylian Saint-Hilaire committed Jul 24, 2019 at 16:29 UTC bac1a1010ba40d901d55b830e3110386977a9eb1
8 files changed +8504 -42
agents/meshcore.js
+10 -7
@@ -940,11 +940,11 @@ function createMeshCore(agent)
940 if (data == 'c') { this.httprequest.state = 1; /*sendConsoleText("Tunnel #" + this.httprequest.index + " now active", this.httprequest.sessionid);*/ }
941 } else {
942 // Handle tunnel data
943 - if (this.httprequest.protocol == 0) { // 1 = Terminal, 2 = Desktop, 5 = Files
943 + if (this.httprequest.protocol == 0) { // 1 = Terminal, 2 = Desktop, 5 = Files, 6 = PowerShell
944 // Take a look at the protocol
945 this.httprequest.protocol = parseInt(data);
946 if (typeof this.httprequest.protocol != 'number') { this.httprequest.protocol = 0; }
947 - if (this.httprequest.protocol == 1) {
947 + if ((this.httprequest.protocol == 1) || (this.httprequest.protocol == 6)) {
948 // Check user access rights for terminal
949 if (((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) || ((this.httprequest.rights != 0xFFFFFFFF) && ((this.httprequest.rights & MESHRIGHT_NOTERMINAL) != 0))) {
950 // Disengage this tunnel, user does not have the rights to do this!!
@@ -954,7 +954,6 @@ function createMeshCore(agent)
954 return;
955 }
956
957 -
957 this.end = function () {
958 if (process.platform == "win32") {
959 // Unpipe the web socket
@@ -977,7 +976,11 @@ function createMeshCore(agent)
976
977 // Remote terminal using native pipes
978 if (process.platform == "win32") {
980 - this.httprequest._term = require('win-terminal').Start(80, 25);
979 + if ((this.httprequest.protocol == 6) && (require('win-terminal').PowerShellCapable() == true)) {
980 + this.httprequest._term = require('win-terminal').StartPowerShell(80, 25);
981 + } else {
982 + this.httprequest._term = require('win-terminal').Start(80, 25);
983 + }
984 this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
985 this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
986 this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
@@ -1428,7 +1431,7 @@ function createMeshCore(agent)
1431 }
1432 ws.write("{\"ctrlChannel\":\"102938\",\"type\":\"webrtc1\"}"); // End of data marker
1433 } else if (obj.type == 'webrtc1') {
1431 - if (ws.httprequest.protocol == 1) { // Terminal
1434 + if ((ws.httprequest.protocol == 1) || (ws.httprequest.protocol == 6)) { // Terminal
1435 // Switch the user input from websocket to webrtc at this point.
1436 if (process.platform == 'win32')
1437 {
@@ -1450,7 +1453,7 @@ function createMeshCore(agent)
1453 ws.write("{\"ctrlChannel\":\"102938\",\"type\":\"webrtc2\"}"); // Indicates we will no longer get any data on websocket, switching to WebRTC at this point.
1454 } else if (obj.type == 'webrtc2') {
1455 // Other side received websocket end of data marker, start sending data on WebRTC channel
1453 - if (ws.httprequest.protocol == 1) { // Terminal
1456 + if ((ws.httprequest.protocol == 1) || (ws.httprequest.protocol == 6)) { // Terminal
1457 if (process.platform == 'win32')
1458 {
1459 ws.httprequest._term.pipe(ws.webrtc.rtcchannel, { dataTypeSkip: 1, end: false }); // 0 = Binary, 1 = Text.
@@ -1465,7 +1468,7 @@ function createMeshCore(agent)
1468 }
1469 } else if (obj.type == 'offer') {
1470 // This is a WebRTC offer.
1468 - if (ws.httprequest.protocol == 1) return; // TODO: Terminal is currently broken with WebRTC. Reject WebRTC upgrade for now.
1471 + if ((ws.httprequest.protocol == 1) || (ws.httprequest.protocol == 6)) return; // TODO: Terminal is currently broken with WebRTC. Reject WebRTC upgrade for now.
1472 ws.webrtc = rtc.createConnection();
1473 ws.webrtc.websocket = ws;
1474 ws.webrtc.on('connected', function () { /*sendConsoleText('Tunnel #' + this.websocket.tunnel.index + ' WebRTC connected');*/ });
agents/meshcore.min.js
+10 -7
@@ -940,11 +940,11 @@ function createMeshCore(agent)
940 if (data == 'c') { this.httprequest.state = 1; /*sendConsoleText("Tunnel #" + this.httprequest.index + " now active", this.httprequest.sessionid);*/ }
941 } else {
942 // Handle tunnel data
943 - if (this.httprequest.protocol == 0) { // 1 = Terminal, 2 = Desktop, 5 = Files
943 + if (this.httprequest.protocol == 0) { // 1 = Terminal, 2 = Desktop, 5 = Files, 6 = PowerShell
944 // Take a look at the protocol
945 this.httprequest.protocol = parseInt(data);
946 if (typeof this.httprequest.protocol != 'number') { this.httprequest.protocol = 0; }
947 - if (this.httprequest.protocol == 1) {
947 + if ((this.httprequest.protocol == 1) || (this.httprequest.protocol == 6)) {
948 // Check user access rights for terminal
949 if (((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) || ((this.httprequest.rights != 0xFFFFFFFF) && ((this.httprequest.rights & MESHRIGHT_NOTERMINAL) != 0))) {
950 // Disengage this tunnel, user does not have the rights to do this!!
@@ -954,7 +954,6 @@ function createMeshCore(agent)
954 return;
955 }
956
957 -
957 this.end = function () {
958 if (process.platform == "win32") {
959 // Unpipe the web socket
@@ -977,7 +976,11 @@ function createMeshCore(agent)
976
977 // Remote terminal using native pipes
978 if (process.platform == "win32") {
980 - this.httprequest._term = require('win-terminal').Start(80, 25);
979 + if ((this.httprequest.protocol == 6) && (require('win-terminal').PowerShellCapable() == true)) {
980 + this.httprequest._term = require('win-terminal').StartPowerShell(80, 25);
981 + } else {
982 + this.httprequest._term = require('win-terminal').Start(80, 25);
983 + }
984 this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
985 this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
986 this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
@@ -1428,7 +1431,7 @@ function createMeshCore(agent)
1431 }
1432 ws.write("{\"ctrlChannel\":\"102938\",\"type\":\"webrtc1\"}"); // End of data marker
1433 } else if (obj.type == 'webrtc1') {
1431 - if (ws.httprequest.protocol == 1) { // Terminal
1434 + if ((ws.httprequest.protocol == 1) || (ws.httprequest.protocol == 6)) { // Terminal
1435 // Switch the user input from websocket to webrtc at this point.
1436 if (process.platform == 'win32')
1437 {
@@ -1450,7 +1453,7 @@ function createMeshCore(agent)
1453 ws.write("{\"ctrlChannel\":\"102938\",\"type\":\"webrtc2\"}"); // Indicates we will no longer get any data on websocket, switching to WebRTC at this point.
1454 } else if (obj.type == 'webrtc2') {
1455 // Other side received websocket end of data marker, start sending data on WebRTC channel
1453 - if (ws.httprequest.protocol == 1) { // Terminal
1456 + if ((ws.httprequest.protocol == 1) || (ws.httprequest.protocol == 6)) { // Terminal
1457 if (process.platform == 'win32')
1458 {
1459 ws.httprequest._term.pipe(ws.webrtc.rtcchannel, { dataTypeSkip: 1, end: false }); // 0 = Binary, 1 = Text.
@@ -1465,7 +1468,7 @@ function createMeshCore(agent)
1468 }
1469 } else if (obj.type == 'offer') {
1470 // This is a WebRTC offer.
1468 - if (ws.httprequest.protocol == 1) return; // TODO: Terminal is currently broken with WebRTC. Reject WebRTC upgrade for now.
1471 + if ((ws.httprequest.protocol == 1) || (ws.httprequest.protocol == 6)) return; // TODO: Terminal is currently broken with WebRTC. Reject WebRTC upgrade for now.
1472 ws.webrtc = rtc.createConnection();
1473 ws.webrtc.websocket = ws;
1474 ws.webrtc.on('connected', function () { /*sendConsoleText('Tunnel #' + this.websocket.tunnel.index + ' WebRTC connected');*/ });
agents/modules_meshcore_min/win-terminal.min.js
+1 -1
@@ -1 +1 @@
1 -var promise=require("promise");var duplex=require("stream").Duplex;var SW_HIDE=0;var SW_MINIMIZE=6;var STARTF_USESHOWWINDOW=1;var STD_INPUT_HANDLE=-10;var STD_OUTPUT_HANDLE=-11;var EVENT_CONSOLE_CARET=16385;var EVENT_CONSOLE_END_APPLICATION=16391;var WINEVENT_OUTOFCONTEXT=0;var WINEVENT_SKIPOWNPROCESS=2;var CREATE_NEW_PROCESS_GROUP=512;var EVENT_CONSOLE_UPDATE_REGION=16386;var EVENT_CONSOLE_UPDATE_SIMPLE=16387;var EVENT_CONSOLE_UPDATE_SCROLL=16388;var EVENT_CONSOLE_LAYOUT=16389;var EVENT_CONSOLE_START_APPLICATION=16390;var KEY_EVENT=1;var MAPVK_VK_TO_VSC=0;var WM_QUIT=18;var GM=require("_GenericMarshal");var si=GM.CreateVariable(GM.PointerSize==4?68:104);var pi=GM.CreateVariable(GM.PointerSize==4?16:24);si.Deref(0,4).toBuffer().writeUInt32LE(GM.PointerSize==4?68:104);si.Deref(GM.PointerSize==4?48:64,2).toBuffer().writeUInt16LE(SW_HIDE|SW_MINIMIZE);si.Deref(GM.PointerSize==4?44:60,4).toBuffer().writeUInt32LE(STARTF_USESHOWWINDOW);var MSG=GM.CreateVariable(GM.PointerSize==4?28:48);function windows_terminal(){this._ObjectID="windows_terminal";this._user32=GM.CreateNativeProxy("User32.dll");this._user32.CreateMethod("DispatchMessageA");this._user32.CreateMethod("GetMessageA");this._user32.CreateMethod("MapVirtualKeyA");this._user32.CreateMethod("PostThreadMessageA");this._user32.CreateMethod("SetWinEventHook");this._user32.CreateMethod("ShowWindow");this._user32.CreateMethod("TranslateMessage");this._user32.CreateMethod("UnhookWinEvent");this._user32.CreateMethod("VkKeyScanA");this._user32.terminal=this;this._kernel32=GM.CreateNativeProxy("Kernel32.dll");this._kernel32.CreateMethod("AllocConsole");this._kernel32.CreateMethod("CreateProcessA");this._kernel32.CreateMethod("CloseHandle");this._kernel32.CreateMethod("FillConsoleOutputAttribute");this._kernel32.CreateMethod("FillConsoleOutputCharacterA");this._kernel32.CreateMethod("GetConsoleScreenBufferInfo");this._kernel32.CreateMethod("GetConsoleWindow");this._kernel32.CreateMethod("GetLastError");this._kernel32.CreateMethod("GetStdHandle");this._kernel32.CreateMethod("GetThreadId");this._kernel32.CreateMethod("ReadConsoleOutputA");this._kernel32.CreateMethod("SetConsoleCursorPosition");this._kernel32.CreateMethod("SetConsoleScreenBufferSize");this._kernel32.CreateMethod("SetConsoleWindowInfo");this._kernel32.CreateMethod("TerminateProcess");this._kernel32.CreateMethod("WaitForSingleObject");this._kernel32.CreateMethod("WriteConsoleInputA");var b=0;var c=0;this._scrx=0;this._scry=0;this.SendCursorUpdate=function(){var f=GM.CreateVariable(22);if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,f).Val==0){return}if(f.Deref(4,2).toBuffer().readUInt16LE()!=this.currentX||f.Deref(6,2).toBuffer().readUInt16LE()!=this.currentY){this.currentX=f.Deref(4,2).toBuffer().readUInt16LE();this.currentY=f.Deref(6,2).toBuffer().readUInt16LE()}};this.ClearScreen=function(){var g=GM.CreateVariable(22);if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,g).Val==0){return}var h=GM.CreateVariable(4);var i=g.Deref(0,2).toBuffer().readUInt16LE(0)*g.Deref(2,2).toBuffer().readUInt16LE(0);var f=GM.CreateVariable(4);if(this._kernel32.FillConsoleOutputCharacterA(this._stdoutput,32,i,h.Deref(0,4).toBuffer().readUInt32LE(),f).Val==0){return}if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,g).Val==0){return}if(this._kernel32.FillConsoleOutputAttribute(this._stdoutput,g.Deref(8,2).toBuffer().readUInt16LE(0),i,h.Deref(0,4).toBuffer().readUInt32LE(),f).Val==0){return}this._kernel32.SetConsoleCursorPosition(this._stdoutput,h.Deref(0,4).toBuffer().readUInt32LE());var j=GM.CreateVariable(8);var k=g.Deref(10,8).toBuffer();j.Deref(4,2).toBuffer().writeUInt16LE(k.readUInt16LE(4)-k.readUInt16LE(0));j.Deref(6,2).toBuffer().writeUInt16LE(k.readUInt16LE(6)-k.readUInt16LE(2));this._kernel32.SetConsoleWindowInfo(this._stdoutput,1,j)};this.Start=function d(g,f){this.stopping=null;if(this._kernel32.GetConsoleWindow().Val==0){if(this._kernel32.AllocConsole().Val==0){throw ("AllocConsole failed with: "+this._kernel32.GetLastError().Val)}}this._stdinput=this._kernel32.GetStdHandle(STD_INPUT_HANDLE);this._stdoutput=this._kernel32.GetStdHandle(STD_OUTPUT_HANDLE);this._connected=false;var h=GM.CreateVariable(4);h.Deref(0,2).toBuffer().writeUInt16LE(g);h.Deref(2,2).toBuffer().writeUInt16LE(f);var i=GM.CreateVariable(8);i.Deref(4,2).toBuffer().writeUInt16LE(g-1);i.Deref(6,2).toBuffer().writeUInt16LE(f-1);if(this._kernel32.SetConsoleWindowInfo(this._stdoutput,1,i).Val==0){throw ("Failed to set Console Screen Size")}if(this._kernel32.SetConsoleScreenBufferSize(this._stdoutput,h.Deref(0,4).toBuffer().readUInt32LE()).Val==0){throw ("Failed to set Console Buffer Size")}this._user32.ShowWindow(this._kernel32.GetConsoleWindow().Val,SW_HIDE);this.ClearScreen();this._hookThread().then(function(){this.terminal.StartCommand()},console.log);this._stream=new duplex({write:function(j,k){if(!this.terminal.connected){if(!this._promise.chunk){this._promise.chunk=[]}if(typeof(j)=="string"){this._promise.chunk.push(j)}else{this._promise.chunk.push(Buffer.alloc(j.length));j.copy(this._promise.chunk.peek())}this._promise.chunk.peek().flush=k;this._promise.then(function(){var l;while(this.chunk.length>0){l=this.chunk.shift();this.terminal._WriteBuffer(l);l.flush()}})}else{this.terminal._WriteBuffer(j);k()}return(true)},"final":function(j){var k=this.terminal._stop();k.__flush=j;k.then(function(){this.__flush()})}});this._stream.terminal=this;this._stream._promise=new promise(function(k,j){this._res=k;this._rej=j});this._stream._promise.terminal=this;return(this._stream)};this._stop=function(){if(this.stopping){return(this.stopping)}this._ConsoleWinEventProc.removeAllListeners("GlobalCallback");this.stopping=new promise(function(h,g){this._res=h;this._rej=g});var f=this._kernel32.GetThreadId(this._user32.SetWinEventHook.async.thread()).Val;this._user32.PostThreadMessageA(f,WM_QUIT,0,0);this._stream.emit("end");return(this.stopping)};this._hookThread=function(){var g=new promise(function(i,h){this._res=i;this._rej=h});g.terminal=this;this._ConsoleWinEventProc=GM.GetGenericGlobalCallback(7);this._ConsoleWinEventProc.terminal=this;var f=this._user32.SetWinEventHook.async(EVENT_CONSOLE_CARET,EVENT_CONSOLE_END_APPLICATION,0,this._ConsoleWinEventProc,0,0,WINEVENT_OUTOFCONTEXT|WINEVENT_SKIPOWNPROCESS);f.ready=g;f.terminal=this;f.then(function(h){if(h.Val==0){this.ready._rej("Error calling SetWinEventHook")}else{this.terminal.hwinEventHook=h;this.ready._res();this.terminal._GetMessage()}});this._ConsoleWinEventProc.on("GlobalCallback",function(j,i,k,n,l,m,p){if(!this.terminal.hwinEventHook||this.terminal.hwinEventHook.Val!=j.Val){return}var h=null;switch(i.Val){case EVENT_CONSOLE_CARET:break;case EVENT_CONSOLE_UPDATE_REGION:if(!this.terminal.connected){this.terminal.connected=true;this.terminal._stream._promise._res()}if(this.terminal._scrollTimer==null){h=this.terminal._GetScreenBuffer(LOWORD(n.Val),HIWORD(n.Val),LOWORD(l.Val),HIWORD(l.Val));this.terminal._SendDataBuffer(h)}break;case EVENT_CONSOLE_UPDATE_SIMPLE:var o={data:[Buffer.alloc(1,LOWORD(l.Val))],attributes:[HIWORD(l.Val)],width:1,height:1,x:LOWORD(n.Val),y:HIWORD(n.Val)};this.terminal._SendDataBuffer(o);break;case EVENT_CONSOLE_UPDATE_SCROLL:this.terminal._SendScroll(n.Val,l.Val);break;case EVENT_CONSOLE_LAYOUT:break;case EVENT_CONSOLE_START_APPLICATION:break;case EVENT_CONSOLE_END_APPLICATION:if(n.Val==this.terminal._hProcessID){this.terminal._hProcess=null;this.terminal._stop().then(function(){console.log("STOPPED")})}break;default:console.log("Unknown event: "+i.Val);break}});return(g)};this._GetMessage=function(){if(this._user32.abort){console.log("aborting loop");return}this._user32.GetMessageA.async(this._user32.SetWinEventHook.async,MSG,0,0,0).then(function(f){if(f.Val!=0){if(f.Val==-1){}else{this.nativeProxy._user32.TranslateMessage.async(this.nativeProxy.user32.SetWinEventHook.async,MSG).then(function(){this.nativeProxy._user32.DispatchMessageA.async(this.nativeProxy.user32.SetWinEventHook.async,MSG).then(function(){this.nativeProxy.terminal._GetMessage()},console.log)},console.log)}}else{this.nativeProxy.UnhookWinEvent.async(this.nativeProxy.terminal._user32.SetWinEventHook.async,this.nativeProxy.terminal.hwinEventHook).then(function(){if(this.nativeProxy.terminal._hProcess==null){return}this.nativeProxy.terminal.stopping._res();if(this.nativeProxy.terminal._kernel32.TerminateProcess(this.nativeProxy.terminal._hProcess,1067).Val==0){var g=this.nativeProxy.terminal._kernel32.GetLastError().Val;console.log("Unable to kill Terminal Process, error: "+g)}this.nativeProxy.terminal.stopping=null},function(g){console.log("REJECTED_UnhookWinEvent: "+g)})}},function(f){console.log("REJECTED_GETMessage: "+f)})};this._WriteBuffer=function(f){for(var g=0;g<f.length;++g){if(typeof(f)=="string"){this._WriteCharacter(f.charCodeAt(g),false)}else{this._WriteCharacter(f[g],false)}}};this._WriteCharacter=function(h,f){var i=GM.CreateVariable(20);i.Deref(0,2).toBuffer().writeUInt16LE(KEY_EVENT);i.Deref(4,4).toBuffer().writeUInt16LE(1);i.Deref(16,4).toBuffer().writeUInt32LE(f);i.Deref(14,1).toBuffer()[0]=h;i.Deref(8,2).toBuffer().writeUInt16LE(1);i.Deref(10,2).toBuffer().writeUInt16LE(this._user32.VkKeyScanA(h).Val);i.Deref(12,2).toBuffer().writeUInt16LE(this._user32.MapVirtualKeyA(this._user32.VkKeyScanA(h).Val,MAPVK_VK_TO_VSC).Val);var g=GM.CreateVariable(4);if(this._kernel32.WriteConsoleInputA(this._stdinput,i,1,g).Val==0){return(false)}i.Deref(4,4).toBuffer().writeUInt16LE(0);return(this._kernel32.WriteConsoleInputA(this._stdinput,i,1,g).Val!=0)};this._GetScreenBuffer=function(s,t,f,g){var i=GM.CreateVariable(22);if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,i).Val==0){throw ("Error getting screen buffer info")}var n=i.Deref(14,2).toBuffer().readUInt16LE()-i.Deref(10,2).toBuffer().readUInt16LE()+1;var m=i.Deref(16,2).toBuffer().readUInt16LE()-i.Deref(12,2).toBuffer().readUInt16LE()+1;if(arguments[3]==null){s=0;t=0;f=n-1;g=m-1}else{if(this._scrx!=0){s+=this._scrx;f+=this._scrx}if(this._scry!=0){t+=this._scry;g+=this._scry}this._scrx=this._scry=0}var l=GM.CreateVariable((f-s+1)*(g-t+1)*4);var q=GM.CreateVariable(4);q.Deref(0,2).toBuffer().writeUInt16LE(f-s+1,0);q.Deref(2,2).toBuffer().writeUInt16LE(g-t+1,0);var r=GM.CreateVariable(4);r.Deref(0,2).toBuffer().writeUInt16LE(0,0);r.Deref(2,2).toBuffer().writeUInt16LE(0,0);var o=GM.CreateVariable(8);o.buffer=o.toBuffer();o.buffer.writeUInt16LE(s,0);o.buffer.writeUInt16LE(t,2);o.buffer.writeUInt16LE(f,4);o.buffer.writeUInt16LE(g,6);if(this._kernel32.ReadConsoleOutputA(this._stdoutput,l,q.Deref(0,4).toBuffer().readUInt32LE(),r.Deref(0,4).toBuffer().readUInt32LE(),o).Val==0){throw ("Unable to read Console Output")}var p={data:[],attributes:[],width:f-s+1,height:g-t+1,x:s,y:t};var v,w,j,h,u,k=f-s+1;for(w=0;w<=(g-t);++w){p.data.push(Buffer.alloc(k));p.attributes.push(Buffer.alloc(k));j=l.Deref(w*k*4,k*4).toBuffer();for(v=0;v<k;++v){p.data.peek()[v]=j[v*4];p.attributes.peek()[v]=j[2+(v*4)]}}return(p)};this._SendDataBuffer=function(g){var h,i,f;for(h=0;h<g.height;++h){i=g.data[h];f=g.attributes[h];i.s=i.toString();this._stream.push(TranslateLine(g.x+1,g.y+h+1,i,f))}};this._SendScroll=function a(g,h){if(this._scrollTimer){return}var k=GM.CreateVariable(22);if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,k).Val==0){throw ("Error getting screen buffer info")}var m=k.Deref(14,2).toBuffer().readUInt16LE()-k.Deref(10,2).toBuffer().readUInt16LE()+1;var l=k.Deref(16,2).toBuffer().readUInt16LE()-k.Deref(12,2).toBuffer().readUInt16LE()+1;this._stream.push(GetEsc("H",[l-1,0]));for(var j=0;j>l;++j){this._stream.push(Buffer.from("\r\n"))}var f=this._GetScreenBuffer(0,0,m-1,l-1);this._SendDataBuffer(f);this._scrollTimer=setTimeout(function(p,o,n){var i=p._GetScreenBuffer(0,0,o-1,n-1);p._SendDataBuffer(i);p._scrollTimer=null},250,this,m,l)};this.StartCommand=function e(){if(this._kernel32.CreateProcessA(GM.CreateVariable(process.env.windir+"\\system32\\cmd.exe"),0,0,0,1,CREATE_NEW_PROCESS_GROUP,0,0,si,pi).Val==0){console.log("Error Spawning CMD");return}this._kernel32.CloseHandle(pi.Deref(GM.PointerSize,GM.PointerSize).Deref());this._hProcess=pi.Deref(0,GM.PointerSize).Deref();this._hProcessID=pi.Deref(GM.PointerSize==4?8:16,4).toBuffer().readUInt32LE()}}function LOWORD(a){return(a&65535)}function HIWORD(a){return((a>>16)&65535)}function GetEsc(b,a){return(Buffer.from("\x1B["+a.join(";")+b))}function MeshConsole(a){require("MeshAgent").SendCommand({action:"msg",type:"console",value:JSON.stringify(a)})}function TranslateLine(r,s,f,a){var m,l,e,q,j,c,n,k,d,p,h,b,g=[],o=[GetEsc("H",[s,r])];if(typeof a=="number"){a=[a]}for(m=0;m<f.length;m++){if(n!=a[m]){k=(a[m]&7);k=((k&1)<<2)+(k&2)+((k&4)>>2);d=(a[m]&112)>>4;d=((d&1)<<2)+(d&2)+((d&4)>>2);p=(a[m]&16384);h=(a[m]&8)>>3;b=(a[m]&128);if(p!=q){if(p!=0){g.push(7)}else{g.push(0);l=7;e=0;j=0;c=0}q=p}if(k!=l){g.push(k+30);l=k}if(d!=e){g.push(d+40);e=d}if(h!=j){g.push(2-h);j=h}if(b!=c){if(b==0){g.push(e+40)}else{g.push(e+100);c=b}}if(g.length>0){o.push(GetEsc("m",g));g=[]}n=a[m]}o.push(Buffer.from(String.fromCharCode(f[m])))}return Buffer.concat(o)}module.exports=new windows_terminal();
\ No newline at end of file
1 +var promise=require("promise");var duplex=require("stream").Duplex;var SW_HIDE=0;var SW_MINIMIZE=6;var STARTF_USESHOWWINDOW=1;var STD_INPUT_HANDLE=-10;var STD_OUTPUT_HANDLE=-11;var EVENT_CONSOLE_CARET=16385;var EVENT_CONSOLE_END_APPLICATION=16391;var WINEVENT_OUTOFCONTEXT=0;var WINEVENT_SKIPOWNPROCESS=2;var CREATE_NEW_PROCESS_GROUP=512;var EVENT_CONSOLE_UPDATE_REGION=16386;var EVENT_CONSOLE_UPDATE_SIMPLE=16387;var EVENT_CONSOLE_UPDATE_SCROLL=16388;var EVENT_CONSOLE_LAYOUT=16389;var EVENT_CONSOLE_START_APPLICATION=16390;var KEY_EVENT=1;var MAPVK_VK_TO_VSC=0;var WM_QUIT=18;var GM=require("_GenericMarshal");var si=GM.CreateVariable(GM.PointerSize==4?68:104);var pi=GM.CreateVariable(GM.PointerSize==4?16:24);si.Deref(0,4).toBuffer().writeUInt32LE(GM.PointerSize==4?68:104);si.Deref(GM.PointerSize==4?48:64,2).toBuffer().writeUInt16LE(SW_HIDE|SW_MINIMIZE);si.Deref(GM.PointerSize==4?44:60,4).toBuffer().writeUInt32LE(STARTF_USESHOWWINDOW);var MSG=GM.CreateVariable(GM.PointerSize==4?28:48);function windows_terminal(){this._ObjectID="windows_terminal";this._user32=GM.CreateNativeProxy("User32.dll");this._user32.CreateMethod("DispatchMessageA");this._user32.CreateMethod("GetMessageA");this._user32.CreateMethod("MapVirtualKeyA");this._user32.CreateMethod("PostThreadMessageA");this._user32.CreateMethod("SetWinEventHook");this._user32.CreateMethod("ShowWindow");this._user32.CreateMethod("TranslateMessage");this._user32.CreateMethod("UnhookWinEvent");this._user32.CreateMethod("VkKeyScanA");this._user32.terminal=this;this._kernel32=GM.CreateNativeProxy("Kernel32.dll");this._kernel32.CreateMethod("AllocConsole");this._kernel32.CreateMethod("CreateProcessA");this._kernel32.CreateMethod("CloseHandle");this._kernel32.CreateMethod("FillConsoleOutputAttribute");this._kernel32.CreateMethod("FillConsoleOutputCharacterA");this._kernel32.CreateMethod("GetConsoleScreenBufferInfo");this._kernel32.CreateMethod("GetConsoleWindow");this._kernel32.CreateMethod("GetLastError");this._kernel32.CreateMethod("GetStdHandle");this._kernel32.CreateMethod("GetThreadId");this._kernel32.CreateMethod("ReadConsoleOutputA");this._kernel32.CreateMethod("SetConsoleCursorPosition");this._kernel32.CreateMethod("SetConsoleScreenBufferSize");this._kernel32.CreateMethod("SetConsoleWindowInfo");this._kernel32.CreateMethod("TerminateProcess");this._kernel32.CreateMethod("WaitForSingleObject");this._kernel32.CreateMethod("WriteConsoleInputA");var b=0;var c=0;this._scrx=0;this._scry=0;this.SendCursorUpdate=function(){var g=GM.CreateVariable(22);if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,g).Val==0){return}if(g.Deref(4,2).toBuffer().readUInt16LE()!=this.currentX||g.Deref(6,2).toBuffer().readUInt16LE()!=this.currentY){this.currentX=g.Deref(4,2).toBuffer().readUInt16LE();this.currentY=g.Deref(6,2).toBuffer().readUInt16LE()}};this.ClearScreen=function(){var h=GM.CreateVariable(22);if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,h).Val==0){return}var i=GM.CreateVariable(4);var j=h.Deref(0,2).toBuffer().readUInt16LE(0)*h.Deref(2,2).toBuffer().readUInt16LE(0);var g=GM.CreateVariable(4);if(this._kernel32.FillConsoleOutputCharacterA(this._stdoutput,32,j,i.Deref(0,4).toBuffer().readUInt32LE(),g).Val==0){return}if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,h).Val==0){return}if(this._kernel32.FillConsoleOutputAttribute(this._stdoutput,h.Deref(8,2).toBuffer().readUInt16LE(0),j,i.Deref(0,4).toBuffer().readUInt32LE(),g).Val==0){return}this._kernel32.SetConsoleCursorPosition(this._stdoutput,i.Deref(0,4).toBuffer().readUInt32LE());var k=GM.CreateVariable(8);var l=h.Deref(10,8).toBuffer();k.Deref(4,2).toBuffer().writeUInt16LE(l.readUInt16LE(4)-l.readUInt16LE(0));k.Deref(6,2).toBuffer().writeUInt16LE(l.readUInt16LE(6)-l.readUInt16LE(2));this._kernel32.SetConsoleWindowInfo(this._stdoutput,1,k)};this.PowerShellCapable=function(){return(require("fs").existsSync(process.env.windir+"\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"))};this.StartEx=function d(h,g,k){this.stopping=null;if(this._kernel32.GetConsoleWindow().Val==0){if(this._kernel32.AllocConsole().Val==0){throw ("AllocConsole failed with: "+this._kernel32.GetLastError().Val)}}this._stdinput=this._kernel32.GetStdHandle(STD_INPUT_HANDLE);this._stdoutput=this._kernel32.GetStdHandle(STD_OUTPUT_HANDLE);this._connected=false;var i=GM.CreateVariable(4);i.Deref(0,2).toBuffer().writeUInt16LE(h);i.Deref(2,2).toBuffer().writeUInt16LE(g);var j=GM.CreateVariable(8);j.Deref(4,2).toBuffer().writeUInt16LE(h-1);j.Deref(6,2).toBuffer().writeUInt16LE(g-1);if(this._kernel32.SetConsoleWindowInfo(this._stdoutput,1,j).Val==0){throw ("Failed to set Console Screen Size")}if(this._kernel32.SetConsoleScreenBufferSize(this._stdoutput,i.Deref(0,4).toBuffer().readUInt32LE()).Val==0){throw ("Failed to set Console Buffer Size")}this._user32.ShowWindow(this._kernel32.GetConsoleWindow().Val,SW_HIDE);this.ClearScreen();this._hookThread(k).then(function(){this.terminal.StartCommand(this.userArgs[0])},console.log);this._stream=new duplex({write:function(l,m){if(!this.terminal.connected){if(!this._promise.chunk){this._promise.chunk=[]}if(typeof(l)=="string"){this._promise.chunk.push(l)}else{this._promise.chunk.push(Buffer.alloc(l.length));l.copy(this._promise.chunk.peek())}this._promise.chunk.peek().flush=m;this._promise.then(function(){var n;while(this.chunk.length>0){n=this.chunk.shift();this.terminal._WriteBuffer(n);n.flush()}})}else{this.terminal._WriteBuffer(l);m()}return(true)},"final":function(l){var m=this.terminal._stop();m.__flush=l;m.then(function(){this.__flush()})}});this._stream.terminal=this;this._stream._promise=new promise(function(m,l){this._res=m;this._rej=l});this._stream._promise.terminal=this;return(this._stream)};this.Start=function d(h,g){return(this.StartEx(h,g,process.env.windir+"\\System32\\cmd.exe"))};this.StartPowerShell=function f(h,g){return(this.StartEx(h,g,process.env.windir+"\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"))};this._stop=function(){if(this.stopping){return(this.stopping)}this._ConsoleWinEventProc.removeAllListeners("GlobalCallback");this.stopping=new promise(function(i,h){this._res=i;this._rej=h});var g=this._kernel32.GetThreadId(this._user32.SetWinEventHook.async.thread()).Val;this._user32.PostThreadMessageA(g,WM_QUIT,0,0);this._stream.emit("end");return(this.stopping)};this._hookThread=function(){var i=new promise(function(k,j){this._res=k;this._rej=j});i.userArgs=[];for(var g in arguments){i.userArgs.push(arguments[g])}i.terminal=this;this._ConsoleWinEventProc=GM.GetGenericGlobalCallback(7);this._ConsoleWinEventProc.terminal=this;var h=this._user32.SetWinEventHook.async(EVENT_CONSOLE_CARET,EVENT_CONSOLE_END_APPLICATION,0,this._ConsoleWinEventProc,0,0,WINEVENT_OUTOFCONTEXT|WINEVENT_SKIPOWNPROCESS);h.ready=i;h.terminal=this;h.then(function(j){if(j.Val==0){this.ready._rej("Error calling SetWinEventHook")}else{this.terminal.hwinEventHook=j;this.ready._res();this.terminal._GetMessage()}});this._ConsoleWinEventProc.on("GlobalCallback",function(l,k,m,p,n,o,r){if(!this.terminal.hwinEventHook||this.terminal.hwinEventHook.Val!=l.Val){return}var j=null;switch(k.Val){case EVENT_CONSOLE_CARET:break;case EVENT_CONSOLE_UPDATE_REGION:if(!this.terminal.connected){this.terminal.connected=true;this.terminal._stream._promise._res()}if(this.terminal._scrollTimer==null){j=this.terminal._GetScreenBuffer(LOWORD(p.Val),HIWORD(p.Val),LOWORD(n.Val),HIWORD(n.Val));this.terminal._SendDataBuffer(j)}break;case EVENT_CONSOLE_UPDATE_SIMPLE:var q={data:[Buffer.alloc(1,LOWORD(n.Val))],attributes:[HIWORD(n.Val)],width:1,height:1,x:LOWORD(p.Val),y:HIWORD(p.Val)};this.terminal._SendDataBuffer(q);break;case EVENT_CONSOLE_UPDATE_SCROLL:this.terminal._SendScroll(p.Val,n.Val);break;case EVENT_CONSOLE_LAYOUT:break;case EVENT_CONSOLE_START_APPLICATION:break;case EVENT_CONSOLE_END_APPLICATION:if(p.Val==this.terminal._hProcessID){this.terminal._hProcess=null;this.terminal._stop().then(function(){console.log("STOPPED")})}break;default:console.log("Unknown event: "+k.Val);break}});return(i)};this._GetMessage=function(){if(this._user32.abort){console.log("aborting loop");return}this._user32.GetMessageA.async(this._user32.SetWinEventHook.async,MSG,0,0,0).then(function(g){if(g.Val!=0){if(g.Val==-1){}else{this.nativeProxy._user32.TranslateMessage.async(this.nativeProxy.user32.SetWinEventHook.async,MSG).then(function(){this.nativeProxy._user32.DispatchMessageA.async(this.nativeProxy.user32.SetWinEventHook.async,MSG).then(function(){this.nativeProxy.terminal._GetMessage()},console.log)},console.log)}}else{this.nativeProxy.UnhookWinEvent.async(this.nativeProxy.terminal._user32.SetWinEventHook.async,this.nativeProxy.terminal.hwinEventHook).then(function(){if(this.nativeProxy.terminal._hProcess==null){return}this.nativeProxy.terminal.stopping._res();if(this.nativeProxy.terminal._kernel32.TerminateProcess(this.nativeProxy.terminal._hProcess,1067).Val==0){var h=this.nativeProxy.terminal._kernel32.GetLastError().Val;console.log("Unable to kill Terminal Process, error: "+h)}this.nativeProxy.terminal.stopping=null},function(h){console.log("REJECTED_UnhookWinEvent: "+h)})}},function(g){console.log("REJECTED_GETMessage: "+g)})};this._WriteBuffer=function(g){for(var h=0;h<g.length;++h){if(typeof(g)=="string"){this._WriteCharacter(g.charCodeAt(h),false)}else{this._WriteCharacter(g[h],false)}}};this._WriteCharacter=function(i,g){var j=GM.CreateVariable(20);j.Deref(0,2).toBuffer().writeUInt16LE(KEY_EVENT);j.Deref(4,4).toBuffer().writeUInt16LE(1);j.Deref(16,4).toBuffer().writeUInt32LE(g);j.Deref(14,1).toBuffer()[0]=i;j.Deref(8,2).toBuffer().writeUInt16LE(1);j.Deref(10,2).toBuffer().writeUInt16LE(this._user32.VkKeyScanA(i).Val);j.Deref(12,2).toBuffer().writeUInt16LE(this._user32.MapVirtualKeyA(this._user32.VkKeyScanA(i).Val,MAPVK_VK_TO_VSC).Val);var h=GM.CreateVariable(4);if(this._kernel32.WriteConsoleInputA(this._stdinput,j,1,h).Val==0){return(false)}j.Deref(4,4).toBuffer().writeUInt16LE(0);return(this._kernel32.WriteConsoleInputA(this._stdinput,j,1,h).Val!=0)};this._GetScreenBuffer=function(t,u,g,h){var j=GM.CreateVariable(22);if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,j).Val==0){throw ("Error getting screen buffer info")}var o=j.Deref(14,2).toBuffer().readUInt16LE()-j.Deref(10,2).toBuffer().readUInt16LE()+1;var n=j.Deref(16,2).toBuffer().readUInt16LE()-j.Deref(12,2).toBuffer().readUInt16LE()+1;if(arguments[3]==null){t=0;u=0;g=o-1;h=n-1}else{if(this._scrx!=0){t+=this._scrx;g+=this._scrx}if(this._scry!=0){u+=this._scry;h+=this._scry}this._scrx=this._scry=0}var m=GM.CreateVariable((g-t+1)*(h-u+1)*4);var r=GM.CreateVariable(4);r.Deref(0,2).toBuffer().writeUInt16LE(g-t+1,0);r.Deref(2,2).toBuffer().writeUInt16LE(h-u+1,0);var s=GM.CreateVariable(4);s.Deref(0,2).toBuffer().writeUInt16LE(0,0);s.Deref(2,2).toBuffer().writeUInt16LE(0,0);var p=GM.CreateVariable(8);p.buffer=p.toBuffer();p.buffer.writeUInt16LE(t,0);p.buffer.writeUInt16LE(u,2);p.buffer.writeUInt16LE(g,4);p.buffer.writeUInt16LE(h,6);if(this._kernel32.ReadConsoleOutputA(this._stdoutput,m,r.Deref(0,4).toBuffer().readUInt32LE(),s.Deref(0,4).toBuffer().readUInt32LE(),p).Val==0){throw ("Unable to read Console Output")}var q={data:[],attributes:[],width:g-t+1,height:h-u+1,x:t,y:u};var w,z,k,i,v,l=g-t+1;for(z=0;z<=(h-u);++z){q.data.push(Buffer.alloc(l));q.attributes.push(Buffer.alloc(l));k=m.Deref(z*l*4,l*4).toBuffer();for(w=0;w<l;++w){q.data.peek()[w]=k[w*4];q.attributes.peek()[w]=k[2+(w*4)]}}return(q)};this._SendDataBuffer=function(h){var i,j,g;for(i=0;i<h.height;++i){j=h.data[i];g=h.attributes[i];j.s=j.toString();this._stream.push(TranslateLine(h.x+1,h.y+i+1,j,g))}};this._SendScroll=function a(h,j){if(this._scrollTimer){return}var l=GM.CreateVariable(22);if(this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput,l).Val==0){throw ("Error getting screen buffer info")}var n=l.Deref(14,2).toBuffer().readUInt16LE()-l.Deref(10,2).toBuffer().readUInt16LE()+1;var m=l.Deref(16,2).toBuffer().readUInt16LE()-l.Deref(12,2).toBuffer().readUInt16LE()+1;this._stream.push(GetEsc("H",[m-1,0]));for(var k=0;k>m;++k){this._stream.push(Buffer.from("\r\n"))}var g=this._GetScreenBuffer(0,0,n-1,m-1);this._SendDataBuffer(g);this._scrollTimer=setTimeout(function(q,p,o){var i=q._GetScreenBuffer(0,0,p-1,o-1);q._SendDataBuffer(i);q._scrollTimer=null},250,this,n,m)};this.StartCommand=function e(g){if(this._kernel32.CreateProcessA(GM.CreateVariable(g),0,0,0,1,CREATE_NEW_PROCESS_GROUP,0,0,si,pi).Val==0){console.log("Error Spawning CMD");return}this._kernel32.CloseHandle(pi.Deref(GM.PointerSize,GM.PointerSize).Deref());this._hProcess=pi.Deref(0,GM.PointerSize).Deref();this._hProcessID=pi.Deref(GM.PointerSize==4?8:16,4).toBuffer().readUInt32LE()}}function LOWORD(a){return(a&65535)}function HIWORD(a){return((a>>16)&65535)}function GetEsc(b,a){return(Buffer.from("\x1B["+a.join(";")+b))}function MeshConsole(a){require("MeshAgent").SendCommand({action:"msg",type:"console",value:JSON.stringify(a)})}function TranslateLine(r,s,f,a){var m,l,e,q,j,c,n,k,d,p,h,b,g=[],o=[GetEsc("H",[s,r])];if(typeof a=="number"){a=[a]}for(m=0;m<f.length;m++){if(n!=a[m]){k=(a[m]&7);k=((k&1)<<2)+(k&2)+((k&4)>>2);d=(a[m]&112)>>4;d=((d&1)<<2)+(d&2)+((d&4)>>2);p=(a[m]&16384);h=(a[m]&8)>>3;b=(a[m]&128);if(p!=q){if(p!=0){g.push(7)}else{g.push(0);l=7;e=0;j=0;c=0}q=p}if(k!=l){g.push(k+30);l=k}if(d!=e){g.push(d+40);e=d}if(h!=j){g.push(2-h);j=h}if(b!=c){if(b==0){g.push(e+40)}else{g.push(e+100);c=b}}if(g.length>0){o.push(GetEsc("m",g));g=[]}n=a[m]}o.push(Buffer.from(String.fromCharCode(f[m])))}return Buffer.concat(o)}module.exports=new windows_terminal();
\ No newline at end of file
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.3.8-l",
3 + "version": "0.3.8-n",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
public/scripts/amt-terminal-0.0.2.js
+1
@@ -13,6 +13,7 @@ var CreateAmtRemoteTerminal = function (divid, options) {
13 obj.DivId = divid;
14 obj.DivElement = document.getElementById(divid);
15 obj.protocol = 1; // SOL
16 + if (options.protocol) { obj.protocol = options.protocol; } // 1 = Normal, 6 = PowerShell
17 // ###BEGIN###{Terminal-Enumation-All}
18 obj.terminalEmulation = 1;
19 // ###END###{Terminal-Enumation-All}
views/default-min.handlebars
+1 -1
@@ -1 +1 @@
1 -<!DOCTYPE html> <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="format-detection" content="telephone=no"> <link rel="shortcut icon" type="image/x-icon" href="{{{domainurl}}}favicon.ico"> <link keeplink="1" type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS"> <style>.ol-box{box-sizing:border-box;border-radius:2px;border:2px solid #00f;}.ol-mouse-position{top:8px;right:8px;position:absolute;}.ol-scale-line{background:rgba(0,60,136,.3);border-radius:4px;bottom:8px;left:8px;padding:2px;position:absolute;}.ol-scale-line-inner{border:1px solid #eee;border-top:none;color:#eee;font-size:10px;text-align:center;margin:1px;will-change:contents,width;}.ol-overlay-container{will-change:left,right,top,bottom;}.ol-unsupported{display:none;}.ol-unselectable, .ol-viewport{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto;}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing;}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab;}.ol-control{position:absolute;background-color:rgba(255,255,255,.4);border-radius:4px;padding:2px;}.ol-control:hover{background-color:rgba(255,255,255,.6);}.ol-zoom{top:.5em;right:.5em;}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear;}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s;}.ol-zoom-extent{top:4.643em;left:.5em;}.ol-full-screen{right:.5em;top:.5em;}@media print{.ol-control{display:none;}}.ol-control button{display:block;margin:1px;padding:0;color:#fff;font-size:1.14em;font-weight:700;text-decoration:none;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:rgba(0,60,136,.5);border:none;border-radius:2px;}.ol-control button::-moz-focus-inner{border:none;padding:0;}.ol-zoom-extent button{line-height:1.4em;}.ol-compass{display:block;font-weight:400;font-size:1.2em;will-change:transform;}.ol-touch .ol-control button{font-size:1.5em;}.ol-touch .ol-zoom-extent{top:5.5em;}.ol-control button:focus, .ol-control button:hover{text-decoration:none;background-color:rgba(0,60,136,.7);}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0;}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px;}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em);}.ol-attribution ul{margin:0;padding:0 .5em;font-size:.7rem;line-height:1.375em;color:#000;text-shadow:0 0 2px #fff;}.ol-attribution li{display:inline;list-style:none;line-height:inherit;}.ol-attribution li:not(:last-child):after{content:" ";}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle;}.ol-attribution button, .ol-attribution ul{display:inline-block;}.ol-attribution.ol-collapsed ul{display:none;}.ol-attribution.ol-logo-only ul{display:block;}.ol-attribution:not(.ol-collapsed){background:rgba(255,255,255,.8);}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0;height:1.1em;line-height:1em;}.ol-attribution.ol-logo-only{background:0 0;bottom:.4em;height:1.1em;line-height:1em;}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em;}.ol-attribution.ol-logo-only button, .ol-attribution.ol-uncollapsible button{display:none;}.ol-zoomslider{top:4.5em;left:.5em;height:200px;}.ol-zoomslider button{position:relative;height:10px;}.ol-touch .ol-zoomslider{top:5.5em;}.ol-overviewmap{left:.5em;bottom:.5em;}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0;}.ol-overviewmap .ol-overviewmap-map, .ol-overviewmap button{display:inline-block;}.ol-overviewmap .ol-overviewmap-map{border:1px solid #7b98bc;height:150px;margin:2px;width:150px;}.ol-overviewmap:not(.ol-collapsed) button{bottom:1px;left:2px;position:absolute;}.ol-overviewmap.ol-collapsed .ol-overviewmap-map, .ol-overviewmap.ol-uncollapsible button{display:none;}.ol-overviewmap:not(.ol-collapsed){background:rgba(255,255,255,.8);}.ol-overviewmap-box{border:2px dotted rgba(0,60,136,.7);}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move;}</style> <style> .ol-ctx-menu-container{position:absolute;padding:8px;background:#fff;color:#222;font-size:13px;border-radius:5px;box-shadow:3px 3px 5px rgba(0,0,0,.2);box-sizing:border-box}.ol-ctx-menu-container a,.ol-ctx-menu-container div,.ol-ctx-menu-container img,.ol-ctx-menu-container li,.ol-ctx-menu-container span,.ol-ctx-menu-container ul{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}.ol-ctx-menu-container a img{border:none}.ol-ctx-menu-container *,.ol-ctx-menu-container :after,.ol-ctx-menu-container :before{box-sizing:inherit}.ol-ctx-menu-container.ol-ctx-menu-hidden{opacity:0;visibility:hidden;-webkit-transition:visibility 0s linear .3s,opacity .3s;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container ul{list-style:none}.ol-ctx-menu-container li{position:relative;line-height:20px;padding:2px 5px}.ol-ctx-menu-container li:not(.ol-ctx-menu-separator):hover{cursor:pointer;background-color:#333;color:#eee}.ol-ctx-menu-container li.ol-ctx-menu-submenu .ol-ctx-menu-container{border:1px solid #eee;padding:8px;top:0;opacity:0;visibility:hidden;-webkit-transition:visibility 0s linear .3s,opacity .3s;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container li.ol-ctx-menu-submenu:hover .ol-ctx-menu-container{opacity:1;visibility:visible;-webkit-transition-delay:0s;transition-delay:0s}.ol-ctx-menu-container li.ol-ctx-menu-submenu:after{position:absolute;top:7px;right:10px;content:"";display:inline-block;width:.6em;height:.6em;border-right:.3em solid #222;border-top:.3em solid #222;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.ol-ctx-menu-container li.ol-ctx-menu-submenu:hover:after{border-color:#eee}.ol-ctx-menu-container li.ol-ctx-menu-separator{padding:0}.ol-ctx-menu-container li.ol-ctx-menu-separator hr{border:0;height:1px;background-image:-webkit-linear-gradient(right,transparent,rgba(0,0,0,.75),transparent);background-image:linear-gradient(270deg,transparent,rgba(0,0,0,.75),transparent)}.ol-ctx-menu-icon{text-indent:20px;background-size:20px auto;background-repeat:no-repeat;background-position:0}.ol-ctx-menu-zoom-in{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABaUlEQVQ4T72U7VHCQBCGn90GtAMuNGCswFiBWIFQgWMFxg6wArECsQKhArEBiB1Qwa1zgQn5IAYcxv13k71n3919L8KJQ07M47+BzgG9TRfZ/JBuWhS6BJFHRJICYrZGZIz3z5Ct2+B7gG6I6kt+wewdkQVwjtkAkR5mC8yu26A1oItR/cTsOweQBdgutD8G7jGm2PJ2n8oqUKIpIjd4HxTM8gvaT/F+AlmWnyWaIXKF95eNguFzTYFhNsdWu9kFgFlaFMANUH3D8wDLoLgSTSD2il8NCe2ZXQBxWDGwxmyUzzOMBZ7wy7Qb2K0wQfXjMOBuhlFpZtNty5sFaTQBuTusZdymeqs1SpYKcO9HkE3KbTd9WFijMHJQ5hBNEAYNq5Qd0dhyke0GiE4QzjqfW23mHT8Hl4DG4Lce3FPE7AtbBSdsbNqpoJLgYkRnNeUV+xwJDHTnUEkxHGbhBXUs5TjJjew/KPy94g+NRaIVRYmMXwAAAABJRU5ErkJggg==")}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-in{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABc0lEQVQ4T71U21ECQRDsJgGdvQDECMQIxAjECMQILCPwzAAjECIQI0AiEDPQAPaWCBhrcKHuCUcV5f7dY3v6tUscefHIePhfwBBCF8CZqRCReRs1tQxDCH1VfQLQz4EsSY4AvIjIsgm8AhhCGKrqa9zwrqoLAKckB5HtguR1E2gBMITQU9VPAD8GICIGtl3e+xHJBwBT59xtHcsCYJZlUwA3kcGHbfDep51OZywi3/acZZm9vyJ5WR5o38uACmDunNt6ZwAkUxFZDwghDFT1jeSjiJinhVUBVNVJkiTDKO8CQA+AsbNQ7s1Ps0VVn5MkSfcCtmBoDZi1Bdx4eJ7zbBolrwPy3o9J3rWSHPs3A1BbjVKlYBaIyDgvu9LDXDU2RTZmXVW1oKyLxRD+OrkOrJLy5mVM0iaftDhuhVbsvBzMglzKUNW6IV/OOWtCM8MmVvEkmbwt83LaB19fdgOtVquUZJeknaDdobTwbOcvBzPcN/AXH1DFFWP7u9oAAAAASUVORK5CYII=")}.ol-ctx-menu-zoom-out{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABU0lEQVQ4T72U7VECMRRFz3sNaAdkacC1AtcKxApcKnCsQOwAK3CtQKxAqEBsANYOqCDPyTIC+8WCw5jfybn33dxEOPGSE/P4b6BzQG89RT47ZJoWhy5B5BGRZAMxWyEyxvtnyFdt8AagS1F9KQ6YvSMyB84xGyDSw2yO2XUbtAJ0MaqfmH0XAPIA2y7tj4F7jAm2uG1yWQZKNEHkBu+Dg2njWBJNEbnC+8uaIFRuWfuG2QxbbrOrUd0A1Tc8D7AIjkur7DAAsVf8MiWMZ3ZR2m02LPIMscATfjHqBnY7TFD9OAy4zTCCPG/MUKMM5O6wkXFr9dZq7FQqqHk/hDzbFa73cFONTZFDdRyiCcKg5rrSiLaXkiI6RjjrfG6VzDs+B5eAxuDXeYpmNRGzL2wZ/wof+du4GNFpBVqqz5HA4MM5VEYYDrOs+1I6Q9u/4Q8O9wN/AGgWjBVqQjjgAAAAAElFTkSuQmCC")}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-out{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABYklEQVQ4T72U4VHCQBCF36tA91KAWIFYgViBWIFYgWMFYgdYgVCBWAFSgdiBFpAsFWSdxcDkQoBkhnF/ZjbfvX377ogjF4/Mw/8CVbUD4MynEJF5k2lqFapqz8yeAPRKkCXJEYAXEVnugm8BVXVgZq/FD+9mtgBwSrJfqF2QvN4FjYCq2jWzTwA/DhARh20qTdMRyQcA0xDCbZ3KCJhl2RTATaHgo+6HLMv8+xXJy+qB3l8FGoB5CKHsXcRV1b6ZvZF8FBH3NKotoJlNkiQZFONdlLtJ3rufbouZPSdJMjwIbKDQEzBrClx7eC4i33Uepmk6JnnXaOQifzMAtdGoRApugYiMI1uqKkrRWAfZo9MxM1+UZzFewl8mN4nYdVM83L7BkwbXLUrF3sfBLQDQBbDy08x8vOohXyEE71lVq9emuEk+3gZa3XYroCvwFyjP8yHJDsnxwaU08GxvS2uFhw78BbzWrxXgMbsHAAAAAElFTkSuQmCC")}</style> <script type="text/javascript" src="scripts/u2f-api.js"></script> <script type="text/javascript" src="scripts/charts.js"></script> <script type="text/javascript" src="scripts/filesaver.js"></script> <script type="text/javascript" src="scripts/ol.js"></script> <script type="text/javascript" src="scripts/ol3-contextmenu.js"></script> <title>{{{title}}}</title> </head> <body id="body" onload="if (typeof(startup) !== 'undefined') startup();" oncontextmenu="handleContextMenu(event)" style="display:none;min-width:495px"> <div id="contextMenu" class="contextMenu noselect" style="display:none"> <div id="cxinfo" class="cmtext" onclick="cmaction(1,event)"><b>Information</b></div> <div id="cxdesktop" class="cmtext" onclick="cmaction(3,event)">Desktop</div> <div id="cxterminal" class="cmtext" onclick="cmaction(2,event)">Terminal</div> <div id="cxfiles" class="cmtext" onclick="cmaction(4,event)">Files</div> <div id="cxevents" class="cmtext" onclick="cmaction(5,event)">Events</div> <div id="cxconsole" class="cmtext" onclick="cmaction(6,event)">Console</div> <hr id="cxmgroupsplit"> <div id="cxmdesktop" class="cmtext" onclick="cmaction(7,event)" style="display:none">Multi-Desktop</div> </div> <div id="meshContextMenu" class="contextMenu,noselect" style="display:none;min-width:0px"> <div id="cxselectall" class="cmtext" onclick="cmmeshaction(1,event)">Select All</div> <div id="cxselectnone" class="cmtext" onclick="cmmeshaction(2,event)">Select None</div> <hr id="cxmgroupsplit2" style="display:none"> <div id="cxmmdesktop" class="cmtext" style="display:none" onclick="cmmeshaction(3,event)">Multi-Desktop</div> </div> <div id="container"> <div id="notifiyBox" class="notifiyBox" style="display:none"></div> <div id="masthead" class="noselect"> <div class="title">{{{title}}}</div> <div class="title2">{{{title2}}}</div> <div style="float:right"> <div id="notificationCount" onclick="clickNotificationIcon()" class="unselectable" style="display:none;" title="Click to view current notifications">0</div> </div> <p id="logoutControl">{{{logoutControl}}}<span id="idleTimeoutNotify" style="color:yellow"></span></p> </div> <div id="page_leftbar"> <div style="height:16px"></div> <div id="LeftMenuMyDevices" tabindex="0" class="lbbutton lbbuttonsel" title="My Devices" onclick="go(1)" onkeypress="if (event.key=='Enter') { go(1); }"> <div class="lb2"></div> </div> <div id="LeftMenuMyAccount" tabindex="0" class="lbbutton" title="My Account" onclick="go(2)" onkeypress="if (event.key=='Enter') { go(2); }"> <div class="lb1"></div> </div> <div id="LeftMenuMyEvents" tabindex="0" class="lbbutton" title="My Events" onclick="go(3)" onkeypress="if (event.key=='Enter') { go(3); }"> <div class="lb3"></div> </div> <div id="LeftMenuMyFiles" tabindex="0" class="lbbutton" style="display:none" title="My Files" onclick="go(5)" onkeypress="if (event.key=='Enter') { go(5); }"> <div class="lb4"></div> </div> <div id="LeftMenuMyUsers" tabindex="0" class="lbbutton" style="display:none" title="My Users" onclick="go(4)" onkeypress="if (event.key=='Enter') { go(4); }"> <div class="lb5"></div> </div> <div id="LeftMenuMyServer" tabindex="0" class="lbbutton" style="display:none" title="My Server" onclick="go(6)" onkeypress="if (event.key=='Enter') { go(6); }"> <div class="lb6"></div> </div> </div> <div id="topbar" class="noselect"> <div> <div style="position:relative"> <div tabindex="0" id="uiMenuButton" title="User interface selection" onclick="showUserInterfaceSelectMenu()" onkeypress="if (event.key == 'Enter') showUserInterfaceSelectMenu()">&diams; <div id="uiMenu" style="display:none"> <div tabindex="0" id="uiViewButton1" class="uiSelector" onclick="userInterfaceSelectMenu(1)" title="Left bar interface" onkeypress="if (event.key == 'Enter') userInterfaceSelectMenu(1)"><div class="uiSelector1"></div></div> <div tabindex="0" id="uiViewButton2" class="uiSelector" onclick="userInterfaceSelectMenu(2)" title="Top bar interface" onkeypress="if (event.key == 'Enter') userInterfaceSelectMenu(2)"><div class="uiSelector2"></div></div> <div tabindex="0" id="uiViewButton3" class="uiSelector" onclick="userInterfaceSelectMenu(3)" title="Fixed width interface" onkeypress="if (event.key == 'Enter') userInterfaceSelectMenu(3)"><div class="uiSelector3"></div></div> <div tabindex="0" id="uiViewButton4" class="uiSelector" onclick="toggleNightMode()" title="Toggle night mode" onkeypress="if (event.key == 'Enter') toggleNightMode()"><div class="uiSelector4"></div></div> </div> </div> <table id="MainMenuSpan" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="MainMenuMyDevices" class="topbar_td style3x" onclick="go(1)" onkeypress="if (event.key == 'Enter') go(1)">My Devices</td> <td tabindex="0" id="MainMenuMyAccount" class="topbar_td style3x" onclick="go(2)" onkeypress="if (event.key == 'Enter') go(2)">My Account</td> <td tabindex="0" id="MainMenuMyEvents" class="topbar_td style3x" onclick="go(3)" onkeypress="if (event.key == 'Enter') go(3)">My Events</td> <td tabindex="0" id="MainMenuMyFiles" class="topbar_td style3x" onclick="go(5)" onkeypress="if (event.key == 'Enter') go(5)">My Files</td> <td tabindex="0" id="MainMenuMyUsers" class="topbar_td style3x" onclick="go(4)" onkeypress="if (event.key == 'Enter') go(4)">My Users</td> <td tabindex="0" id="MainMenuMyServer" class="topbar_td style3x" onclick="go(6)" onkeypress="if (event.key == 'Enter') go(6)">My Server</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> <div id="MainSubMenuSpan" style="display:none"> <table id="MainSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="MainDev" class="topbar_td style3x" onclick="go(10)" onkeypress="if (event.key == 'Enter') go(10)">General</td> <td tabindex="0" id="MainDevDesktop" class="topbar_td style3x" onclick="go(11)" onkeypress="if (event.key == 'Enter') go(11)">Desktop</td> <td tabindex="0" id="MainDevTerminal" class="topbar_td style3x" onclick="go(12)" onkeypress="if (event.key == 'Enter') go(12)">Terminal</td> <td tabindex="0" id="MainDevFiles" class="topbar_td style3x" onclick="go(13)" onkeypress="if (event.key == 'Enter') go(13)">Files</td> <td tabindex="0" id="MainDevEvents" class="topbar_td style3x" onclick="go(16)" onkeypress="if (event.key == 'Enter') go(16)">Events</td> <td tabindex="0" id="MainDevAmt" class="topbar_td style3x" onclick="go(14)" onkeypress="if (event.key == 'Enter') go(14)">Intel&reg; AMT</td> <td tabindex="0" id="MainDevConsole" class="topbar_td style3x" onclick="go(15)" onkeypress="if (event.key == 'Enter') go(15)">Console</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="MeshSubMenuSpan" style="display:none"> <table id="MeshSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="MeshGeneral" class="topbar_td style3x" onclick="go(20)" onkeypress="if (event.key == 'Enter') go(20)">General</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="UserSubMenuSpan" style="display:none"> <table id="UserSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="UserGeneral" class="topbar_td style3x" onclick="go(30)" onkeypress="if (event.key == 'Enter') go(30)">General</td> <td tabindex="0" id="UserEvents" class="topbar_td style3x" onclick="go(31)" onkeypress="if (event.key == 'Enter') go(31)">Events</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="ServerSubMenuSpan" style="display:none"> <table id="ServerSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="ServerGeneral" class="topbar_td style3x" onclick="go(6)" onkeypress="if (event.key == 'Enter') go(6)">General</td> <td tabindex="0" id="ServerStats" class="topbar_td style3x" onclick="go(40)" onkeypress="if (event.key == 'Enter') go(40)">Stats</td> <td tabindex="0" id="ServerConsole" class="topbar_td style3x" onclick="go(115)" onkeypress="if (event.key == 'Enter') go(115)">Console</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="UserDummyMenuSpan"> <table id="UserDummyMenu" cellpadding="0" cellspacing="0" class="style1"> <tr><td class="style3" style="">&nbsp;</td></tr> </table> </div> </div> </div> </div> <div id="column_l"> <div id="p0" style="display:none"> <div id="p0message"><span id="p0span">Server disconnected</span>, <href onclick="reload()" style="cursor:pointer"><u>click to reconnect</u></href>.</div> </div> <div id="p1" style="display:none"> <div style="display:none" id="devListToolbarViewIcons"> <div tabindex="0" id="devViewButton1" class="viewSelector" onclick="onDeviceViewChange(1)" onkeypress="if (event.key=='Enter') { onDeviceViewChange(1); }" title="Columns"><div class="viewSelector2"></div></div> <div tabindex="0" id="devViewButton2" class="viewSelector" onclick="onDeviceViewChange(2)" onkeypress="if (event.key == 'Enter') { onDeviceViewChange(2); }" title="List"><div class="viewSelector1"></div></div> <div tabindex="0" id="devViewButton3" class="viewSelector" onclick="onDeviceViewChange(3)" onkeypress="if (event.key == 'Enter') { onDeviceViewChange(3); }" title="Desktops"><div class="viewSelector3"></div></div> <div tabindex="0" id="devViewButton4" class="viewSelector" onclick="onDeviceViewChange(4)" onkeypress="if (event.key == 'Enter') { onDeviceViewChange(4); }" title="Map"><div class="viewSelector4"></div></div> </div><div><h1>My Devices</h1></div> <table id="devListToolbarSpan" class="noselect"> <tr> <td class="h1"></td> <td id="devListToolbar" class="style14" style="display:none"> &nbsp;&nbsp;<input type="button" id="SelectAllButton" onclick="selectallButtonFunction();" value="Select All">&nbsp; <input type="button" id="GroupActionButton" disabled="disabled" value="Group Action" onclick="groupActionFunction()">&nbsp; <input id="SearchInput" type="text" placeholder="Filter" onchange="masterUpdate(5)" onkeyup="masterUpdate(5)" autocomplete="off" onfocus="onSearchFocus(1)" onblur="onSearchFocus(0)">&nbsp; <label><input type="checkbox" id="RealNameCheckBox" onclick="onRealNameCheckBox()"><span title="Show devices operating system name">OS Name</span></label> </td> <td id="kvmListToolbar" class="style14" style="display:none"> &nbsp;&nbsp;<input type="button" onclick="connectAllKvmFunction()" value="Connect All">&nbsp; <input type="button" onclick="disconnectAllKvmFunction()" value="Disconnect All">&nbsp; <label><input type="checkbox" id="autoConnectDesktopCheckbox" onclick="autoConnectDesktops(event)" title="Automatic connect">Auto&nbsp;</label> <input type="button" onclick="showMultiDesktopSettings()" value="Settings">&nbsp; </td> <td id="devMapToolbar" class="style14" style="display:none"> &nbsp;&nbsp;<input type="text" id="mapSearchLocation" placeholder="Search Location" onfocus="onMapSearchFocus(1)" onblur="onMapSearchFocus(0)"> <input type="button" value="Search" title="Search for location" onclick="getSearchLocation()"> <input type="button" id="refreshmap" title="Reset map view" value="Reset" onclick="refreshMap(false,true)"> </td> <td class="auto-style1" style="height:100%"> <div style="display:none" id="devListToolbarView"> View <select id="viewselect" onchange="onDeviceViewChange()"> <option value="1">Columns <option value="2">List <option value="3">Desktops <option id="viewselectmapoption" value="4">Map </select> </div> <div style="display:none" id="devListToolbarSort"> Sort <select id="sortselect" onchange="masterUpdate(6)"> <option>Group <option>Power <option>Device <option>Tags </select> &nbsp; </div> <div style="display:none" id="devListToolbarSize"> Size <select id="sizeselect" onchange="onDeviceViewChange()"> <option value="0">Small <option value="1">Medium <option value="2">Large </select> &nbsp; </div> </td> <td class="h2"></td> </tr> </table> <div id="NoMeshesPanel" style="display:none"> <table> <tr> <td valign="top" style="width:50px"> <img src="images/info.png"> </td> <td> <div id="getStarted1">To get started, <a href="#" onclick="return account_createMesh()"><strong>click here to create a device group</strong></a>.</div> <div id="getStarted2">No device groups.</div> </td> </tr> </table> </div> <div id="xdevices" class="noselect" style="display:none"></div> <div id="xdevicesmap" style="display:none"> <div id="xmapSearchResultsDlg" style="display:none"> <div id="xmapSearchResultsBck"> <div id="xmapSearchClose" onclick="mapCloseSearchWindow()"><b>X</b></div> <div style="padding:5px">Location Results</div> <div style="width:100%;margin:6px"></div> </div> <div id="xmapSearchResults" style="margin:6px"></div> </div> </div> <div id="xmap-info-window"></div> </div> <div id="p2" style="display:none"> <h1>My Account</h1> <img id="p2AccountImage" alt="" src="images/clipboard-128.png"> <div id="p2AccountSecurity" style="display:none"> <p><strong>Account security</strong></p> <div style="margin-left:25px"> <div id="manageAuthApp"><div class="p2AccountActions"><span id="authAppSetupCheck"><strong>&#x2713;</strong></span></div><span><a href="#" onclick="return account_manageAuthApp()">Manage authenticator app</a><br></span></div> <div id="manageHardwareOtp"><div class="p2AccountActions"><span id="authKeySetupCheck"><strong>&#x2713;</strong></span></div><span><a href="#" onclick="return account_manageHardwareOtp(0)">Manage security keys</a><br></span></div> <div id="manageOtp"><div class="p2AccountActions"><span id="authCodesSetupCheck"><strong>&#x2713;</strong></span></div><span><a href="#" onclick="return account_manageOtp(0)">Manage backup codes</a><br></span></div> </div> </div> <div id="p2AccountActions"> <p><strong>Account actions</strong></p> <p class="mL"> <span id="verifyEmailId" style="display:none"><a href="#" onclick="return account_showVerifyEmail()">Verify email</a><br></span> <span id="accountEnableNotificationsSpan" style="display:none"><a href="#" onclick="return account_enableNotifications()">Enable web notifications</a><br></span> <a href="#" onclick="return account_showAccountNotifySettings()">Notification Settings</a><br> <span id="accountChangeEmailAddressSpan" style="display:none"><a href="#" onclick="return account_showChangeEmail()">Change email address</a><br></span> <a href="#" onclick="return account_showChangePassword()">Change password</a><span id="p2nextPasswordUpdateTime"></span><br> <a href="#" onclick="return account_showDeleteAccount()">Delete account</a><br> </p> <br style="clear:both"> </div> <strong>Device Groups</strong> <span id="p2createMeshLink1">( <a href="#" onclick="return account_createMesh()" class="newMeshBtn"> New</a> )</span> <br><br> <div id="p2meshes"></div> <div id="p2noMeshFound" style="display:none">No device groups.<span id="p2createMeshLink2"> <a href="#" onclick="return account_createMesh()"><strong>Get started here!</strong></a></span></div> <br style="clear:both"> </div> <div id="p3" style="display:none"> <h1>My Events</h1> <table class="pTable"> <tr> <td class="h1"></td> <td>&nbsp;<input id="p2deleteall" type="button" onclick="showDeleteAllEventsDialog()" style="display:none" value="Delete All..."></td> <td class="auto-style1"> Show <select id="p3limitdropdown" onchange="refreshEvents()"> <option value="60">Last 60 <option value="120">Last 120 <option value="250">Last 250 <option value="500">Last 500 <option value="1000">Last 1000 </select>&nbsp; <a href="#" onclick="p3showDownloadEventsDialog()"><img src="images/link4.png" height="10" width="10" title="Download Events" style="cursor:pointer"></a>&nbsp; </td> <td class="h2"></td> </tr> </table> <div id="p3events" style=""></div> </div> <div id="p4" style="display:none"> <h1>My Users</h1> <table class="pTable"> <tr> <td class="h1"></td> <td class="style14"> <div style="float:right"> <input type="button" onclick="showUserBroadcastDialog()" style="margin-right:6px" value="Broadcast"> <a href="#" onclick="p4downloadUserInfo()"><img style="cursor:pointer" title="Download user information" src="images/link4.png"></a> <a href="#" onclick="p4batchAccountCreate()"><img id="p4UserBatchCreate" style="cursor:pointer;display:none" title="Batch create many user accounts" src="images/link6.png"></a> </div> <div> <input id="UserNewAccountButton" type="button" style="margin-left:6px" onclick="showCreateNewAccountDialog()" value="New Account..."> <input id="UserSearchInput" type="text" style="width:120px;margin-left:6px" placeholder="Filter" onchange="onUserSearchInputChanged()" onkeyup="onUserSearchInputChanged()" autocomplete="off" onfocus="onUserSearchFocus(1)" onblur="onUserSearchFocus(0)"> </div> </td> <td class="h2"></td> </tr> </table> <div id="p3users"></div> </div> <div id="p5" style="display:none"> <h1>My Files</h1> <table id="p5toolbar" cellpadding="0" cellspacing="0"> <tr> <td id="p5filehead" valign="bottom"> <div id="p5rightOfButtons"></div> <div> <input type="button" id="p5FolderUp" disabled="disabled" onclick="return p5folderup();" value="Up">&nbsp; <input type="button" id="p5SelectAllButton" disabled="disabled" onclick="p5selectallfile();" value="Select All">&nbsp; <input type="button" id="p5RenameFileButton" disabled="disabled" value="Rename" onclick="p5renamefile();">&nbsp; <input type="button" id="p5DeleteFileButton" disabled="disabled" value="Delete" onclick="p5deletefile();">&nbsp; <input type="button" id="p5NewFolderButton" disabled="disabled" value="New Folder" onclick="p5createfolder();">&nbsp; <input type="button" id="p5UploadButton" disabled="disabled" value="Upload" onclick="p5uploadFile()">&nbsp; <input type="button" id="p5CutButton" disabled="disabled" value="Cut" onclick="p5copyFile(1)">&nbsp; <input type="button" id="p5CopyButton" disabled="disabled" value="Copy" onclick="p5copyFile(0)">&nbsp; <input type="button" id="p5PasteButton" disabled="disabled" value="Paste" onclick="p5pasteFile()">&nbsp; </div> </td> </tr> <tr> <td id="p5filesubhead"> <div style="float:right"> <select id="p5sortdropdown" onchange="updateFiles()"> <option value="1" selected="selected">Sort by name <option value="2">Sort by size <option value="3">Sort by date <option value="4">Descend by name <option value="5">Descend by size <option value="6">Descend by date </select> </div> <div>&nbsp;&nbsp;<span id="p5currentpath"></span></div> </td> </tr> </table> <div id="p5filetable"> <div id="p5PublicShare" style=""><div>These files are shared publicly, click "link" to get public url.</div></div> <div id="bigok" style="display:none"><b>&checkmark;</b></div> <div id="bigfail" style="display:none"><b>&#10007;</b></div> <span id="p5files"></span> </div> <table id="p5toolbarBottom" style="width:100%" cellpadding="0" cellspacing="0"> <tr><td class="style6">&nbsp;<span id="p5bottomstatus"></span></td></tr> </table> </div> <div id="p6" style="display:none"> <img id="MainMeshImage" src="serverpic.ashx"> <h1>My Server</h1> <div id="p2ServerActions"> <p><strong>Server actions</strong></p> <div class="mL"> <div id="p2ServerActionsBackup"><a href="{{{domainurl}}}backup.zip" rel="noreferrer noopener" target="_blank">Download server backup</a></div> <div id="p2ServerActionsRestore"><a href="#" onclick="return server_showRestoreDlg()">Restore server with backup</a></div> <div id="p2ServerActionsVersion"><a href="#" onclick="return server_showVersionDlg()">Check server version</a></div> <div id="p2ServerActionsErrors"><a href="#" onclick="return server_showErrorsDlg()">Show server error log</a></div> </div> </div> <br><strong>Server Statistics</strong><br><br> <div id="serverStats"> <div id="serverCpuChartView" style="display:none"> <div class="chartViewCanvas"><canvas id="serverCpuChart"></canvas></div> <div class="chartViewText" id="serverCpuChartText"></div> </div> <div id="serverMemoryChartView" style="display:none"> <div class="chartViewCanvas"><canvas id="serverMemoryChart"></canvas></div> <div class="chartViewText" id="serverMemoryChartText"></div> </div><br><br> <div id="serverStatsTable"></div> </div> </div> <div id="p10" style="display:none"> <table style="width:100%" cellpadding="0" cellspacing="0"> <tr> <td style="width:auto" valign="top"> <div id="p10title"> <div id="p10BackButton"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>General - <span id="p10deviceName"></span></h1> </div> <div id="p10html"></div> </td> <td style="width:20px"></td> <td style="width:200px"> <a href="#" onclick="p10showiconselector()"><img id="MainComputerImage"></a> <div id="MainComputerState"></div> </td> </tr> </table><br> <div id="p10html2"></div> <div id="p10html3"></div> </div> <div id="p11" class="noselect" style="display:none"> <div id="p11title"> <div id="p11deviceNameHeader"> <div id="p11BackButton"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <div id="devListToolbarViewIcons"><div class="viewSelector" onclick="deskToggleFull(event)" title="Full Screen. Hold shift to browser full screen."><div class="viewSelector5"></div></div></div> <h1>Desktop - <span id="p11deviceName"></span></h1> </div> </div> <div id="p11warning" onclick="showFeaturesDlg()"> <div class="icon2"></div> <div class="warningbox">Intel&reg; AMT Redirection port or KVM feature is disabled<span id="p11warninga">, click here to enable it.</span></div> </div> <div id="p11warning2" onclick="showPowerActionDlg()"> <div class="icon2"></div> <div class="warningbox">Remote computer is not powered on, click here to issue a power command.</div> </div> <div id="deskarea0" cellpadding="0" cellspacing="0"> <div id="deskarea1" class="areaHead"> <div class="toright2"> <span id="p11power"></span>&nbsp; <div class='deskareaicon' title="Toggle View Mode" onclick="toggleAspectRatio(1)">&#8690;</div> <div class='deskareaicon' title="Rotate Left" onclick="drotate(-1)">&olarr;</div> <div class='deskareaicon' title="Rotate Right" onclick="drotate(1)">&orarr;</div> <input id="deskFocusBtn" type="button" title="Toggle focus mode, when active only the region around the mouse is updated" onkeypress="return false" onkeydown="return false" value="Focus All" onclick="deskToggleFocus()" style="margin-right:3px;display:none"> <input id="deskSaveBtn" type="button" title="Save a screenshot of the remote desktop" onkeypress="return false" onkeydown="return false" value="Save..." onclick="deskSaveImage()" class="mR"> <input id="deskActionsBtn" type="button" title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value="Actions" onclick="deviceActionFunction()" class="mR"> <input id="deskActionsSettings" type="button" value="Settings..." title="Edit remote desktop settings" onkeypress="return false" onkeydown="return false" onclick="showDesktopSettings()" class="mR"> <input type="button" title="Change the power state of the remote machine" onkeypress="return false" onkeydown="return false" value="Power Actions..." onclick="showPowerActionDlg()" style="display:none"> </div> <div> <div id="idx_deskFullBtn2" onclick="deskToggleFull(event)">&nbsp;&#x2716;</div> <input type="button" id="autoconnectbutton1" value="AutoConnect" onclick="autoConnectDesktop(event)" onkeypress="return false" onkeydown="return false" style="display:none"> <span id="connectbutton1span"><input type="button" id="connectbutton1" value="Connect" onclick="connectDesktop(event,1)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="connectbutton1hspan">&nbsp;<input type="button" id="connectbutton1h" value="HW Connect" onclick="connectDesktop(event,2)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="disconnectbutton1span">&nbsp;<input type="button" id="disconnectbutton1" value="Disconnect" onclick="connectDesktop(event,0)" onkeypress="return false" onkeydown="return false"></span> &nbsp;<span id="deskstatus">Disconnected</span> </div> </div> <div id="deskarea2" style=""> <div class="areaProgress"><div id="progressbar" style=""></div></div> </div> <div id="deskarea3x"> <div id="DeskFocus" oncontextmenu="return false" onmousedown="dmousedown(event)" onmouseup="dmouseup(event)" onmousemove="dmousemove(event)"></div> <div id="DeskParent"> <canvas id="Desk" width="640" height="480" oncontextmenu="return false" onmousedown="dmousedown(event)" onmouseup="dmouseup(event)" onmousemove="dmousemove(event)" onmousewheel="dmousewheel(event)"></canvas> </div> <div id="DeskTools"> <a id="DeskToolsRefreshButton" style="" onclick="refreshDeskTools()">Refresh</a> <div id="DeskToolsBar">Processes</div> <div id="deskToolsArea"> <div id="deskToolsHeader"> <a class="colmn1" title="Sort by process id" onclick="sortProcess(0)">PID</a> <a class="colmn2" title="Sort by name" onclick="sortProcess(1)">Name</a></div> <div id="DeskToolsProcesses" style=""></div> </div> </div> <div id="p11DeskConsoleMsg" style="display:none;cursor:pointer;position:absolute;left:30px;top:17px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick="p11clearConsoleMsg()"></div> </div> <div id="deskarea4" class="areaFoot"> <div class="toright2"> <select id="termdisplays" style="display:none" onchange="deskSetDisplay(event)" onkeypress="return false" onkeydown="return false"></select>&nbsp; <input id="DeskToolsButton" type="button" value="Tools" title="Toggle tools view" onkeypress="return false" onkeydown="return false" onclick="toggleDeskTools()">&nbsp; <span id="DeskChatButton" class="deskarea" title="Open chat window to this computer"><img src='images/icon-chat.png' onclick="deviceChat()" height="16" width="16" style="padding-top:2px"></span> <span id="DeskNotifyButton" title="Display a notification on the remote computer"><img src='images/icon-notify.png' onclick="deviceToastFunction()" height="16" width="16" style="padding-top:2px"></span> <span id="DeskOpenWebButton" title="Open a web address on remote computer"><img src='images/icon-url2.png' onclick="deviceUrlFunction()" height="16" width="16" style="padding-top:2px"></span> </div> <div> <select id="deskkeys"> <option value="5">Win <option value="0">Win+Down <option value="1">Win+Up <option value="2">Win+L <option value="3">Win+M <option value="4">Shift+Win+M <option value="6">Win+R <option value="7">Alt-F4 <option value="8">Ctrl-W <option value="9">Alt-Tab </select> <input id="DeskWD" type="button" value="Send" onkeypress="return false" onkeydown="return false" onclick="deskSendKeys()"> <input id="DeskClip" style="" type="button" value="Clipboard" onkeypress="return false" onkeydown="return false" onclick="showDeskClip()"> <input id="DeskCAD" type="button" value="Ctrl-Alt-Del" onkeypress="return false" onkeydown="return false" onclick="sendCAD()"> <label><span id="DeskControlSpan" title="Toggle mouse and keyboard input"><input id="DeskControl" type="checkbox" onkeypress="return false" onkeydown="return false" onclick="toggleKvmControl()">Input</span></label>&nbsp; </div> </div> </div> </div> <div id="p12" style="display:none"> <div id="p12title"> <div id="p12BackButton"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>Terminal - <span id="p12deviceName"></span></h1> </div> <div id="p12warning" onclick="showFeaturesDlg()"> <div class="icon2"></div> <div class="warningbox">Intel&reg; AMT Redirection port or KVM feature is disabled<span id="p12warninga">, click here to enable it.</span></div> </div> <div id="p12warning2" onclick="showPowerActionDlg()"> <div class="icon2"></div> <div class="warningbox">Remote computer is not powered on, click here to issue a power command.</div> </div> <div id="termTable" style="position:relative"> <table style="width:100%" cellpadding="0" cellspacing="0"> <tr> <td class="areaHead"> <div class="toright2"> <input id="termActionsBtn" type="button" title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value="Actions" onclick="deviceActionFunction()/"> </div> <div> <input type="button" id="autoconnectbutton2" value="AutoConnect" onclick="autoConnectTerminal(event)" onkeypress="return false" onkeydown="return false" style="display:none"> <span id="connectbutton2span"><input type="button" id="connectbutton2" value="Connect" onclick="connectTerminal(event,1)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="connectbutton2hspan">&nbsp;<input type="button" id="connectbutton2h" value="HW Connect" onclick="connectTerminal(event,2)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="disconnectbutton2span">&nbsp;<input type="button" id="disconnectbutton2" value="Disconnect" onclick="connectTerminal(event,0)" onkeypress="return false" onkeydown="return false"></span> &nbsp;<span id="termstatus">Disconnected</span><span id="termtitle"></span> </div> </td> </tr> <tr> <td> <div class="areaProgress"><div id="termprogressbar" style=""></div></div> </td> </tr> <tr> <td id="termarea3x"> <pre id="Term"></pre> </td> </tr> <tr> <td class="areaFoot"> <div class="toright2"> <span id="terminalSettingsButtons" style="display:none"> <input id="id_tcrbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="CR+LF" title="Toggle what the return key will send" onclick="termToggleCr()"> <input id="id_tfxkeysbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Intel (F10 = ESC+[OM)" title="Toggle F1 to F10 keys emulation type" onclick="termToggleFx()"> <input id="id_ttypebutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Extended Ascii" title="Toggle terminal emulation type" onclick="termToggleType()"> </span> <span id="terminalSizeDropDown"> <select id="termSizeList" onkeypress="return false"><option value="1">80x25<option value="2">100x30<option value="3" selected="">Auto</select> </span> <select id="specialkeylist" onkeypress="return false"></select> <input id="specialkeylistinput" type="button" onkeypress="return false" class="bottombutton" value="Send" title="Send the selected special key" onclick="sendSpecialKey()"> </div> <div> &nbsp; <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlcbutton" value="Ctl-C" onclick="termSendKey(3,'ctrlcbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlxbutton" value="Ctl-X" onclick="termSendKey(24,'ctrlxbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="escbutton" value="ESC" onclick="termSendKey(27,'escbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="bsbutton" value="Backspace" onclick="termSendKey(8,'bsbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="pastebutton" value="Paste" title="Paste text into the terminal" onclick="showTermPasteDialog()"> </div> </td> </tr> </table> <div id="p12TermConsoleMsg" style="display:none;cursor:pointer;position:absolute;left:30px;top:45px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick="p12clearConsoleMsg()"></div> </div> </div> <div id="p13" style="display:none"> <div id="p13title"> <div id="p13BackButton" style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>Files - <span id="p13deviceName"></span></h1> </div> <table id="p13toolbar" cellpadding="0" cellspacing="0"> <tr> <td class="areaHead"> <div class="toright2"> <input id="filesActionsBtn" type="button" title="Perform power actions on the device" value="Actions" onclick="deviceActionFunction()"> </div> <div> <input id="p13AutoConnect" value="AutoConnect" onclick="autoConnectFiles(event)" type="button" style="display:none"> <input id="p13Connect" value="Connect" onclick="connectFiles(event)" type="button"> <span id="p13Status">Disconnected</span> </div> </td> </tr> <tr> <td class="areaHead2" valign="bottom"> <div id="p13rightOfButtons" class="toright2"></div> <div> <input type="button" id="p13FolderUp" disabled="disabled" onclick="p13folderup()" value="Up">&nbsp; <input type="button" id="p13SelectAllButton" disabled="disabled" onclick="p13selectallfile()" value="Select All">&nbsp; <input type="button" id="p13RenameFileButton" disabled="disabled" value="Rename" onclick="p13renamefile()">&nbsp; <input type="button" id="p13DeleteFileButton" disabled="disabled" value="Delete" onclick="p13deletefile()">&nbsp; <input type="button" id="p13NewFolderButton" disabled="disabled" value="New Folder" onclick="p13createfolder()">&nbsp; <input type="button" id="p13UploadButton" disabled="disabled" value="Upload" onclick="p13uploadFile()">&nbsp; <input type="button" id="p13CutButton" disabled="disabled" value="Cut" onclick="p13copyFile(1)">&nbsp; <input type="button" id="p13CopyButton" disabled="disabled" value="Copy" onclick="p13copyFile(0)">&nbsp; <input type="button" id="p13PasteButton" disabled="disabled" value="Paste" onclick="p13pasteFile()">&nbsp; <input type="button" id="p13RefreshButton" disabled="disabled" value="Refresh" onclick="p13folderup(9999)">&nbsp; </div> </td> </tr> <tr> <td class="areaHead3"> <div class="toright2"> <select id="p13sortdropdown" onchange="p13updateFiles()"> <option value="1" selected="selected">Sort by name <option value="2">Sort by size <option value="3">Sort by date <option value="4">Descend by name <option value="5">Descend by size <option value="6">Descend by date </select> </div> <div>&nbsp;&nbsp;<span id="p13currentpath"></span></div> </td> </tr> </table> <div id="p13FilesConsoleMsg" style="display:none;cursor:pointer;position:absolute;left:30px;top:165px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick="p13clearConsoleMsg()"></div> <div id="p13filetable" style=""> <div id="p13bigok" style="display:none"><b>&checkmark;</b></div> <div id="p13bigfail" style="display:none"><b>&#10007;</b></div> <span id="p13files"></span> </div> <table id="p13toolbarBottom" cellpadding="0" cellspacing="0"> <tr><td class="style6">&nbsp;<span id="p13bottomstatus"></span></td></tr> </table> </div> <div id="p14" style="display:none"> <div id="p14title"> <div id="p14BackButton" style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <div id="devListToolbarViewIcons"><div class="viewSelector" onclick="deskToggleFull(event)" title="Full Screen. Hold shift to browser full screen."><div class="viewSelector5"></div></div></div> <h1>Intel&reg; AMT - <span id="p14deviceName"></span></h1> </div> <iframe id="p14iframe" src="{{{domainurl}}}commander.htm"></iframe> </div> <div id="p15" style="display:none"> <div id="p15title"> <div id="p15BackButton" style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1><span id="p15deviceName"></span></h1> </div> <table id="consoleTable" cellpadding="0" cellspacing="0"> <tr> <td class="areaHead"> <div class="toright2"> <div id="p15coreName" title="Information about current core running on this agent"></div> <input type="button" id="p15uploadCore" value="Agent Action" onclick="p15uploadCore(event)" title="Change the agent Java Script code module"> <img onclick="p15downloadConsoleText()" style="cursor:pointer;margin-top:6px" title="Download console text" src="images/link4.png"> </div> <div id="p15statetext"></div> </td> </tr> <tr> <td> <div class="areaProgress"><div id="consoleprogressbar" style=""></div></div> </td> </tr> <tr> <td id="p15agentConsole"> <pre id="p15agentConsoleText"></pre> </td> </tr> <tr> <td class="areaFoot"> <table style="width:100%"> <tr> <td style="width:99%"> <input id="p15consoleText" style="width:100%" onkeyup="p15consoleSend(event)" onfocus="onConsoleFocus(1)" onblur="onConsoleFocus(0)"> </td> <td>&nbsp;</td> <td style="width:1%"><input id="id_p15consoleClear" type="button" class="bottombutton" value="Clear" onclick="p15consoleClear()"></td> </tr> </table> </td> </tr> </table> </div> <div id="p16" style="display:none"> <div id="p16title"> <div id="p16BackButton" style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>Events - <span id="p16deviceName"></span></h1> </div> <table class="pTable"> <tr> <td class="h1"></td> <td>&nbsp;<input type="button" onclick="refreshDeviceEvents()" value="Refresh"></td> <td class="auto-style1"> Show <select id="p16limitdropdown" onchange="refreshDeviceEvents()"> <option value="60">Last 60 <option value="120">Last 120 <option value="250">Last 250 <option value="500">Last 500 <option value="1000">Last 1000 </select> </td> <td class="h2"></td> </tr> </table> <div id="p16events"></div> </div> <div id="p20" style="display:none"> <picture id="MainMeshImage" style="border-width:0px;height:200px;width:200px;float:right"> <source type="image/webp" width="200" height="200" srcset="images/webp/mesh-256.webp"> <img alt="" width="200" height="200" src="images/mesh-256.png"> </source></picture> <div style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>General - <span id="p20meshName"></span></h1> <p id="p20info"> </div> <div id="p30" style="display:none"> <table style="width:100%" cellpadding="0" cellspacing="0"> <tr> <td style="width:auto" valign="top"> <div id="p30title"> <div style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>General - <span id="p30userName"></span></h1> </div> <div id="p30html"></div> </td> <td style="width:20px"></td> <td style="width:200px"> <picture id="MainUserImage" style="border-width:0px;height:200px;width:200px;float:right"> <source type="image/webp" width="200" height="200" srcset="images/webp/user-256.webp"> <img alt="" width="200" height="200" src="images/user-256.png"> </source></picture> <div style="width:100%;text-align:center"><strong><span id="MainUserState"></span></strong></div> </td> </tr> </table><br> <div id="p30html2"></div> <div id="p30html3"></div> </div> <div id="p31" style="display:none"> <div style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>Events - <span id="p31userName"></span></h1> <table class="pTable"> <tr> <td class="h1"></td> <td>&nbsp;<input type="button" onclick="refreshUsersEvents()" value="Refresh"></td> <td class="auto-style1"> Show <select id="p31limitdropdown" onchange="refreshUsersEvents()"> <option value="60">Last 60 <option value="120">Last 120 <option value="250">Last 250 <option value="500">Last 500 <option value="1000">Last 1000 </select> </td> <td class="h2"></td> </tr> </table> <div id="p31events"></div> </div> <div id="p40" style="display:none;"> <h1>My Server Stats</h1> <div class="areaHead"> <div class="toright2"> <select id="p40type" onchange="updateServerTimelineStats()"> <option value="0">Connections <option value="1">Memory </select>&nbsp; <select id="p40time" onchange="updateServerTimelineHours()"> <option value="3">Last 3 hours <option value="8">Last 8 hours <option value="24">Last day <option value="168">Last week <option value="720">Last 30 days </select>&nbsp; <img src="images/link4.png" height="10" width="10" title="Download data points (.csv)" style="cursor:pointer" onclick="p40downloadEvents()">&nbsp; </div> <div> <input value="Refresh" type="button" onclick="refreshServerTimelineStats()"> &nbsp;<label><input id="p40log" type="checkbox" onclick="updateServerTimelineHours()">Log-X</label> </div> </div> <canvas id="serverMainStats" style=""></canvas> </div> <br id="column_l_bottomgap"> </div> <div id="footer"> <div class="footer1">{{{footer}}}</div> <div class="footer2"> <a id="verifyEmailId2" style="display:none" href="#" onclick="account_showVerifyEmail()">Verify Email</a> &nbsp;<a href="terms">Terms &amp; Privacy</a> </div> </div> <div id="dialog" class="noselect" style="display:none"> <div id="dialogHeader"> <div tabindex="0" id="id_dialogclose" onclick="setDialogMode()" onkeypress="if (event.key == 'Enter') setDialogMode()">&#x2716;</div> <div id="id_dialogtitle"></div> </div> <div id="dialogBody"> <div id="dialog1"> <div id="id_dialogMessage" style=""></div> </div> <div id="dialog2" style=""> <div id="id_dialogOptions"></div> </div> <div id="dialog3" style=""> <div id="d3upload"> <div>File Selection</div> <select id="d3uploadMode" onchange="d3modechange()"> <option value="1">Local file upload <option value="2">Server file selection </select> </div> <div id="d3localmode" style="display:none"> <div>Upload File</div> <form id="d3localmodeform" method="post" enctype="multipart/form-data" action="uploadfile.ashx" target="fileUploadFrame"> <input type="text" id="d3attrib" name="attrib" style="display:none"> <input type="file" id="d3localFile" name="files" onchange="d3setActions()"> <input type="submit" id="d3submit" style="display:none"> </form> </div> <div id="d3servermode"> <div id="d3serveraction" valign="bottom"> <input type="button" id="p3FolderUp" disabled="disabled" onclick="d3folderup()" value="Up">&nbsp; </div> <div id="d3serverfiles"></div> </div> </div> <div id="dialog7" style=""> <div id="d7meshkvm"> <h4>Agent Remote Desktop</h4> <div> <div>Quality</div> <select id="d7bitmapquality" dir="rtl"></select> </div> <div> <div>Scaling</div> <select id="d7bitmapscaling" style="" dir="rtl"> <option selected="selected" value="1024">100% <option value="896">87.5% <option value="768">75% <option value="640">62.5% <option value="512">50% <option value="384">37.5% <option value="256">25% <option value="128">12.5% </select> </div> <div> <div>Frame rate</div> <select id="d7framelimiter" dir="rtl"> <option selected="selected" value="50">Fast <option value="100">Medium <option value="400">Slow <option value="1000">Very slow </select> </div> </div> <div id="d7amtkvm"> <h4>Intel&reg; AMT Hardware KVM</h4> <div> <div>Image Encoding</div> <select id="d7desktopmode"> <option value="1">RLE8, Fastest <option value="2">RLE16, Recommended <option value="3">RAW8, Slow <option value="4">RAW16, Very Slow </select> </div> <div> <div>Other Settings</div> <div id="d7otherset" style="display:block"> <label style="display:block"><input type="checkbox" id="d7showfocus">Show Focus Tool</label> <label style="display:block"><input type="checkbox" id="d7showcursor">Show Local Mouse Cursor</label> <label style="display:block"><input type="checkbox" id="d7localKeyMap">Local Keyboard Map</label> </div> </div> </div> </div> </div> <div id="idx_dlgButtonBar"> <input id="idx_dlgCancelButton" type="button" value="Cancel" style="" onclick="dialogclose(0)"> <input id="idx_dlgOkButton" type="button" value="OK" style="" onclick="dialogclose(1)"> <div><input id="idx_dlgDeleteButton" type="button" value="Delete" style="display:none" onclick="dialogclose(2)"></div> </div> </div> <iframe name="fileUploadFrame" style="display:none"></iframe> <form style="display:none" method="post" action="uploadfile.ashx" enctype="multipart/form-data" target="fileUploadFrame"><input id="p5fileDragName" name="name"><input id="p5fileDragSize" name="size"><input id="p5fileDragType" name="type"><input id="p5fileDragData" name="data"><input id="p5fileDragLink" name="link"><input type="submit" id="p5loginSubmit2" style="display:none"></form> <form style="display:none" method="post" action="uploadnodefile.ashx" enctype="multipart/form-data" target="fileUploadFrame"><input id="p13fileDragName" name="name"><input id="p13fileDragSize" name="size"><input id="p13fileDragType" name="type"><input id="p13fileDragData" name="data"><input id="p13fileDragLink" name="link"><input type="submit" id="p13loginSubmit2" style="display:none"></form> <audio id="chimes"><source src="sounds/chimes.mp3" type="audio/mp3"></source></audio> </div> <script>if(!String.prototype.startsWith){String.prototype.startsWith=function(a){return this.lastIndexOf(a,0)===0}}if(!String.prototype.endsWith){String.prototype.endsWith=function(a){return this.indexOf(a,this.length-a.length)!==-1}}function Q(a){return document.getElementById(a)}function QS(a){try{return Q(a).style}catch(a){}}function QE(a,b){try{Q(a).disabled=!b}catch(a){}}function QV(a,b){try{QS(a).display=(b?"":"none")}catch(a){}}function QA(a,b){Q(a).innerHTML+=b}function QH(a,b){Q(a).innerHTML=b}function QC(a){try{return Q(a).classList}catch(a){}}function inputBoxFocus(b){Q(b).focus();var a=Q(b).value;Q(b).value="";Q(b).value=a}function ReadShort(b,a){return(b.charCodeAt(a)<<8)+b.charCodeAt(a+1)}function ReadShortX(b,a){return(b.charCodeAt(a+1)<<8)+b.charCodeAt(a)}function ReadInt(b,a){return(b.charCodeAt(a)*16777216)+(b.charCodeAt(a+1)<<16)+(b.charCodeAt(a+2)<<8)+b.charCodeAt(a+3)}function ReadSInt(b,a){return(b.charCodeAt(a)<<24)+(b.charCodeAt(a+1)<<16)+(b.charCodeAt(a+2)<<8)+b.charCodeAt(a+3)}function ReadIntX(b,a){return(b.charCodeAt(a+3)*16777216)+(b.charCodeAt(a+2)<<16)+(b.charCodeAt(a+1)<<8)+b.charCodeAt(a)}function ShortToStr(a){return String.fromCharCode((a>>8)&255,a&255)}function ShortToStrX(a){return String.fromCharCode(a&255,(a>>8)&255)}function IntToStr(a){return String.fromCharCode((a>>24)&255,(a>>16)&255,(a>>8)&255,a&255)}function IntToStrX(a){return String.fromCharCode(a&255,(a>>8)&255,(a>>16)&255,(a>>24)&255)}function MakeToArray(a){if(!a||a==null||typeof a=="object"){return a}return[a]}function SplitArray(a){return a.split(",")}function Clone(a){return JSON.parse(JSON.stringify(a))}function EscapeHtml(a){if(typeof a=="string"){return a.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}if(typeof a=="boolean"){return a}if(typeof a=="number"){return a}}function EscapeHtmlBreaks(a){if(typeof a=="string"){return a.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/\r/g,"<br />").replace(/\n/g,"").replace(/\t/g,"&nbsp;&nbsp;")}if(typeof a=="boolean"){return a}if(typeof a=="number"){return a}}function ArrayElementMove(a,b,c){a.splice(c,0,a.splice(b,1)[0])}function ObjectToStringEx(e,a){var d="";if(e!=0&&(!e||e==null)){return"(Null)"}if(e instanceof Array){for(var b in e){d+="<br />"+gap(a)+"Item #"+b+": "+ObjectToStringEx(e[b],a+1)}}else{if(e instanceof Object){for(var b in e){d+="<br />"+gap(a)+b+" = "+ObjectToStringEx(e[b],a+1)}}else{d+=EscapeHtml(e)}}return d}function ObjectToStringEx2(e,a){var d="";if(e!=0&&(!e||e==null)){return"(Null)"}if(e instanceof Array){for(var b in e){d+="\r\n"+gap2(a)+"Item #"+b+": "+ObjectToStringEx2(e[b],a+1)}}else{if(e instanceof Object){for(var b in e){d+="\r\n"+gap2(a)+b+" = "+ObjectToStringEx2(e[b],a+1)}}else{d+=EscapeHtml(e)}}return d}function gap(a){var d="";for(var b=0;b<(a*4);b++){d+="&nbsp;"}return d}function gap2(a){var d="";for(var b=0;b<(a*4);b++){d+=" "}return d}function ObjectToString(a){return ObjectToStringEx(a,0)}function ObjectToString2(a){return ObjectToStringEx2(a,0)}function hex2rstr(a){if(typeof a!="string"||a.length==0){return""}var c="",b=(""+a).match(/../g),e;while(e=b.shift()){c+=String.fromCharCode("0x"+e)}return c}function char2hex(a){return(a+256).toString(16).substr(-2).toUpperCase()}function rstr2hex(b){var c="",a;for(a=0;a<b.length;a++){c+=char2hex(b.charCodeAt(a))}return c}function encode_utf8(a){return unescape(encodeURIComponent(a))}function decode_utf8(a){return decodeURIComponent(escape(a))}function data2blob(c){var b=new Array(c.length);for(var d=0;d<c.length;d++){b[d]=c.charCodeAt(d)}var a=new Blob([new Uint8Array(b)]);return a}function random(a){return Math.floor(Math.random()*a)}function trademarks(a){return a.replace(/\(R\)/g,"&reg;").replace(/\(TM\)/g,"&trade;")}var MeshServerCreateControl=function(b,a){var c={};c.State=0;c.connectstate=0;c.pingTimer=null;c.authCookie=a;c.trace=false;c.xxStateChange=function(e,d){if(c.State==e){return}var g=c.State;c.State=e;if(c.onStateChanged){c.onStateChanged(c,c.State,g,d)}};c.Start=function(){if(c.connectstate!=0){return}c.connectstate=0;var d=window.location.protocol.replace("http","ws")+"//"+window.location.host+b+"control.ashx";if(c.authCookie&&(c.authCookie!="")){d+="?auth="+c.authCookie}c.socket=new WebSocket(d);c.socket.onopen=function(g){c.connectstate=1};c.socket.onmessage=c.xxOnMessage;c.socket.onclose=function(g){c.Stop(g.code)};c.xxStateChange(1,0);if(c.pingTimer!=null){clearInterval(c.pingTimer)}c.pingTimer=setInterval(function(){c.send({action:"ping"})},29000)};c.Stop=function(d){c.connectstate=0;if(c.socket){c.socket.close();delete c.socket}if(c.pingTimer!=null){clearInterval(c.pingTimer);c.pingTimer=null}c.xxStateChange(0,d)};c.xxOnMessage=function(d){if(c.State==1){c.xxStateChange(2)}var g;try{g=JSON.parse(d.data)}catch(d){return}if((typeof g!="object")||(g.action=="pong")){return}if(g.action=="close"){if(g.msg){console.log(g.msg)}c.Stop(g.cause);return}if(c.trace){console.log("RECV",g)}if(c.onMessage){c.onMessage(c,g)}};c.send=function(d){if(c.socket!=null&&c.connectstate==1){if(c.trace){console.log("SEND",d)}c.socket.send(JSON.stringify(d))}};return c};function AmtStackCreateService(t){var s=new Object();s.wsman=t;s.pfx=["http://intel.com/wbem/wscim/1/amt-schema/1/","http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/","http://intel.com/wbem/wscim/1/ips-schema/1/"];s.PendingEnums=[];s.PendingBatchOperations=0;s.ActiveEnumsCount=0;s.MaxActiveEnumsCount=1;s.onProcessChanged=null;var n=0;var m=0;s.GetPendingActions=function(){return(s.PendingEnums.length*2)+(s.ActiveEnumsCount)+s.wsman.comm.PendingAjax.length+s.wsman.comm.ActiveAjaxCount+s.PendingBatchOperations};function r(){var u=s.GetPendingActions();if(n<u){n=u}if(s.onProcessChanged!=null&&m!=u){m=u;s.onProcessChanged(u,n)}if(u==0){n=0}}s.Subscribe=function(w,v,C,u,B,z,A,x,D,y){s.wsman.ExecSubscribe(s.CompleteName(w),v,C,function(G,F,E,H){r();u(s,w,E,H,B)},0,z,A,x,D,y);r()};s.UnSubscribe=function(v,u,y,w,x){s.wsman.ExecUnSubscribe(s.CompleteName(v),function(B,A,z,C){r();u(s,v,z,C,y)},0,w,x);r()};s.Get=function(v,u,x,w){s.wsman.ExecGet(s.CompleteName(v),function(A,z,y,B){r();u(s,v,y,B,x)},0,w);r()};s.Put=function(v,x,u,z,w,y){s.wsman.ExecPut(s.CompleteName(v),x,function(C,B,A,D){r();u(s,v,A,D,z)},0,w,y);r()};s.Create=function(v,x,u,y,w){s.wsman.ExecCreate(s.CompleteName(v),x,function(B,A,z,C){r();u(s,v,z,C,y)},0,w);r()};s.Delete=function(v,x,u,y,w){s.wsman.ExecDelete(s.CompleteName(v),x,function(B,A,z,C){r();u(s,v,z,C,y)},0,w);r()};s.Exec=function(x,w,u,v,A,y,z){s.wsman.ExecMethod(s.CompleteName(x),w,u,function(D,C,B,E){r();v(s,x,s.CompleteExecResponse(B),E,A)},0,y,z);r()};s.ExecWithXml=function(x,w,u,v,A,y,z){s.wsman.ExecMethodXml(s.CompleteName(x),w,execArgumentsToXml(u),function(D,C,B,E){r();v(s,x,s.CompleteExecResponse(B),E,A)},0,y,z);r()};s.Enum=function(v,u,x,w){if(s.ActiveEnumsCount<s.MaxActiveEnumsCount){s.ActiveEnumsCount++;s.wsman.ExecEnum(s.CompleteName(v),function(B,z,y,C,A){r();d(v,y,u,z,C,A)},x,w)}else{s.PendingEnums.push([v,u,x,w])}r()};function d(w,y,u,z,A,B,x){if(A!=200){u(s,w,null,A,B);c(1);return}if(y==null||y.Header.Method!="EnumerateResponse"||!y.Body.EnumerationContext){u(s,w,null,603,B);c(1);return}var v=y.Body.EnumerationContext;s.wsman.ExecPull(z,v,function(E,D,C,F){b(w,C,u,D,[],F,B,x)})}function b(z,B,u,C,x,D,E,A){if(D!=200){u(s,z,null,D,E);c(1);return}if(B==null||B.Header.Method!="PullResponse"){u(s,z,null,604,E);c(1);return}for(var w in B.Body.Items){if(B.Body.Items[w] instanceof Array){for(var y in B.Body.Items[w]){x.push(B.Body.Items[w][y])}}else{x.push(B.Body.Items[w])}}if(B.Body.EnumerationContext){var v=B.Body.EnumerationContext;s.wsman.ExecPull(C,v,function(H,G,F,I){b(z,F,u,G,x,I,E,1)})}else{c(1);u(s,z,x,D,E);r()}}function c(u){s.ActiveEnumsCount-=u;if(s.ActiveEnumsCount>=s.MaxActiveEnumsCount||s.PendingEnums.length==0){return}var v=s.PendingEnums.shift();s.Enum(v[0],v[1],v[2]);c(0)}s.BatchEnum=function(u,x,v,z,w,y){s.PendingBatchOperations+=(x.length*2);a(u,Clone(x),v,z,{},w,y);r()};function a(u,z,v,C,B,w,A){s.PendingBatchOperations-=2;var y=z.shift(),x=s.Enum;if(y[0]=="*"){x=s.Get;y=y.substring(1)}x(y,function(F,D,E,G,H){H[2][D]={response:(E==null?null:E.Body),responses:E,status:G};if(H[1].length==0||G==401||(w!=true&&G!=200&&G!=400)){s.PendingBatchOperations-=(z.length*2);r();v(s,u,H[2],G,C)}else{r();a(u,z,v,C,H[2],A)}},[u,z,B],A);r()}s.BatchGet=function(u,w,v,y,x){h({name:u,names:w,callback:v,current:0,responses:{},tag:y,pri:x});r()};function h(u){if(u.names.length<=u.current){u.callback(s,u.name,u.responses,200,u.tag)}else{s.wsman.ExecGet(s.CompleteName(u.names[u.current]),function(x,w,v,y){g(u,v,y)},u.pri);u.current++}r()}function g(u,v,w){if(v==null||w!=200){u.callback(s,u.name,null,w,u.tag)}else{u.responses[v.Header.Method]=v;h(u)}}s.CompleteName=function(u){if(u.indexOf("AMT_")==0){return s.pfx[0]+u}if(u.indexOf("CIM_")==0){return s.pfx[1]+u}if(u.indexOf("IPS_")==0){return s.pfx[2]+u}};s.CompleteExecResponse=function(u){if(u&&u!=null&&u.Body&&u.Body.ReturnValue){u.Body.ReturnValueStr=s.AmtStatusToStr(u.Body.ReturnValue)}return u};s.RequestPowerStateChange=function(v,u){s.CIM_PowerManagementService_RequestPowerStateChange(v,'<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="CreationClassName">CIM_ComputerSystem</Selector><Selector Name="Name">ManagedSystem</Selector></SelectorSet></ReferenceParameters>',null,null,u)};s.SetBootConfigRole=function(v,u){s.CIM_BootService_SetBootConfigRole('<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">Intel(r) AMT: Boot Configuration 0</Selector></SelectorSet></ReferenceParameters>',v,u)};s.CancelAllQueries=function(u){s.wsman.CancelAllQueries(u)};s.AMT_AgentPresenceWatchdog_RegisterAgent=function(u){s.Exec("AMT_AgentPresenceWatchdog","RegisterAgent",{},u)};s.AMT_AgentPresenceWatchdog_AssertPresence=function(v,u){s.Exec("AMT_AgentPresenceWatchdog","AssertPresence",{SequenceNumber:v},u)};s.AMT_AgentPresenceWatchdog_AssertShutdown=function(v,u){s.Exec("AMT_AgentPresenceWatchdog","AssertShutdown",{SequenceNumber:v},u)};s.AMT_AgentPresenceWatchdog_AddAction=function(z,y,x,v,u,w,C,A,B){s.Exec("AMT_AgentPresenceWatchdog","AddAction",{OldState:z,NewState:y,EventOnTransition:x,ActionSd:v,ActionEac:u},w,C,A,B)};s.AMT_AgentPresenceWatchdog_DeleteAllActions=function(u,x,v,w){s.Exec("AMT_AgentPresenceWatchdog","DeleteAllActions",{},u,x,v,w)};s.AMT_AgentPresenceWatchdogAction_GetActionEac=function(u){s.Exec("AMT_AgentPresenceWatchdogAction","GetActionEac",{},u)};s.AMT_AgentPresenceWatchdogVA_RegisterAgent=function(u){s.Exec("AMT_AgentPresenceWatchdogVA","RegisterAgent",{},u)};s.AMT_AgentPresenceWatchdogVA_AssertPresence=function(v,u){s.Exec("AMT_AgentPresenceWatchdogVA","AssertPresence",{SequenceNumber:v},u)};s.AMT_AgentPresenceWatchdogVA_AssertShutdown=function(v,u){s.Exec("AMT_AgentPresenceWatchdogVA","AssertShutdown",{SequenceNumber:v},u)};s.AMT_AgentPresenceWatchdogVA_AddAction=function(z,y,x,v,u,w){s.Exec("AMT_AgentPresenceWatchdogVA","AddAction",{OldState:z,NewState:y,EventOnTransition:x,ActionSd:v,ActionEac:u},w)};s.AMT_AgentPresenceWatchdogVA_DeleteAllActions=function(u,v){s.Exec("AMT_AgentPresenceWatchdogVA","DeleteAllActions",{_method_dummy:u},v)};s.AMT_AuditLog_ClearLog=function(u){s.Exec("AMT_AuditLog","ClearLog",{},u)};s.AMT_AuditLog_RequestStateChange=function(v,w,u){s.Exec("AMT_AuditLog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_AuditLog_ReadRecords=function(v,u,w){s.Exec("AMT_AuditLog","ReadRecords",{StartIndex:v},u,w)};s.AMT_AuditLog_SetAuditLock=function(x,v,w,u){s.Exec("AMT_AuditLog","SetAuditLock",{LockTimeoutInSeconds:x,Flag:v,Handle:w},u)};s.AMT_AuditLog_ExportAuditLogSignature=function(v,u){s.Exec("AMT_AuditLog","ExportAuditLogSignature",{SigningMechanism:v},u)};s.AMT_AuditLog_SetSigningKeyMaterial=function(y,x,w,v,u){s.Exec("AMT_AuditLog","SetSigningKeyMaterial",{SigningMechanismType:y,SigningKey:x,LengthOfCertificates:w,Certificates:v},u)};s.AMT_AuditPolicyRule_SetAuditPolicy=function(w,u,x,y,v){s.Exec("AMT_AuditPolicyRule","SetAuditPolicy",{Enable:w,AuditedAppID:u,EventID:x,PolicyType:y},v)};s.AMT_AuditPolicyRule_SetAuditPolicyBulk=function(w,u,x,y,v){s.Exec("AMT_AuditPolicyRule","SetAuditPolicyBulk",{Enable:w,AuditedAppID:u,EventID:x,PolicyType:y},v)};s.AMT_AuthorizationService_AddUserAclEntryEx=function(x,w,y,u,z,v){s.Exec("AMT_AuthorizationService","AddUserAclEntryEx",{DigestUsername:x,DigestPassword:w,KerberosUserSid:y,AccessPermission:u,Realms:z},v)};s.AMT_AuthorizationService_EnumerateUserAclEntries=function(v,u){s.Exec("AMT_AuthorizationService","EnumerateUserAclEntries",{StartIndex:v},u)};s.AMT_AuthorizationService_GetUserAclEntryEx=function(v,u,w){s.Exec("AMT_AuthorizationService","GetUserAclEntryEx",{Handle:v},u,w)};s.AMT_AuthorizationService_UpdateUserAclEntryEx=function(y,x,w,z,u,A,v){s.Exec("AMT_AuthorizationService","UpdateUserAclEntryEx",{Handle:y,DigestUsername:x,DigestPassword:w,KerberosUserSid:z,AccessPermission:u,Realms:A},v)};s.AMT_AuthorizationService_RemoveUserAclEntry=function(v,u){s.Exec("AMT_AuthorizationService","RemoveUserAclEntry",{Handle:v},u)};s.AMT_AuthorizationService_SetAdminAclEntryEx=function(w,v,u){s.Exec("AMT_AuthorizationService","SetAdminAclEntryEx",{Username:w,DigestPassword:v},u)};s.AMT_AuthorizationService_GetAdminAclEntry=function(u){s.Exec("AMT_AuthorizationService","GetAdminAclEntry",{},u)};s.AMT_AuthorizationService_GetAdminAclEntryStatus=function(u){s.Exec("AMT_AuthorizationService","GetAdminAclEntryStatus",{},u)};s.AMT_AuthorizationService_GetAdminNetAclEntryStatus=function(u){s.Exec("AMT_AuthorizationService","GetAdminNetAclEntryStatus",{},u)};s.AMT_AuthorizationService_SetAclEnabledState=function(w,v,u,x){s.Exec("AMT_AuthorizationService","SetAclEnabledState",{Handle:w,Enabled:v},u,x)};s.AMT_AuthorizationService_GetAclEnabledState=function(v,u,w){s.Exec("AMT_AuthorizationService","GetAclEnabledState",{Handle:v},u,w)};s.AMT_EndpointAccessControlService_RequestStateChange=function(v,w,u){s.Exec("AMT_EndpointAccessControlService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_EndpointAccessControlService_GetPosture=function(v,u){s.Exec("AMT_EndpointAccessControlService","GetPosture",{PostureType:v},u)};s.AMT_EndpointAccessControlService_GetPostureHash=function(v,u){s.Exec("AMT_EndpointAccessControlService","GetPostureHash",{PostureType:v},u)};s.AMT_EndpointAccessControlService_UpdatePostureState=function(v,u){s.Exec("AMT_EndpointAccessControlService","UpdatePostureState",{UpdateType:v},u)};s.AMT_EndpointAccessControlService_GetEacOptions=function(u){s.Exec("AMT_EndpointAccessControlService","GetEacOptions",{},u)};s.AMT_EndpointAccessControlService_SetEacOptions=function(v,w,u){s.Exec("AMT_EndpointAccessControlService","SetEacOptions",{EacVendors:v,PostureHashAlgorithm:w},u)};s.AMT_EnvironmentDetectionSettingData_SetSystemDefensePolicy=function(v,u){s.Exec("AMT_EnvironmentDetectionSettingData","SetSystemDefensePolicy",{Policy:v},u)};s.AMT_EnvironmentDetectionSettingData_EnableVpnRouting=function(v,u){s.Exec("AMT_EnvironmentDetectionSettingData","EnableVpnRouting",{Enable:v},u)};s.AMT_EthernetPortSettings_SetLinkPreference=function(v,w,u){s.Exec("AMT_EthernetPortSettings","SetLinkPreference",{LinkPreference:v,Timeout:w},u)};s.AMT_HeuristicPacketFilterStatistics_ResetSelectedStats=function(v,u){s.Exec("AMT_HeuristicPacketFilterStatistics","ResetSelectedStats",{SelectedStatistics:v},u)};s.AMT_KerberosSettingData_GetCredentialCacheState=function(u){s.Exec("AMT_KerberosSettingData","GetCredentialCacheState",{},u)};s.AMT_KerberosSettingData_SetCredentialCacheState=function(v,u){s.Exec("AMT_KerberosSettingData","SetCredentialCacheState",{Enable:v},u)};s.AMT_MessageLog_CancelIteration=function(v,u){s.Exec("AMT_MessageLog","CancelIteration",{IterationIdentifier:v},u)};s.AMT_MessageLog_RequestStateChange=function(v,w,u){s.Exec("AMT_MessageLog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_MessageLog_ClearLog=function(u){s.Exec("AMT_MessageLog","ClearLog",{},u)};s.AMT_MessageLog_GetRecords=function(v,w,u,x){s.Exec("AMT_MessageLog","GetRecords",{IterationIdentifier:v,MaxReadRecords:w},u,x)};s.AMT_MessageLog_GetRecord=function(v,w,u){s.Exec("AMT_MessageLog","GetRecord",{IterationIdentifier:v,PositionToNext:w},u)};s.AMT_MessageLog_PositionAtRecord=function(v,w,x,u){s.Exec("AMT_MessageLog","PositionAtRecord",{IterationIdentifier:v,MoveAbsolute:w,RecordNumber:x},u)};s.AMT_MessageLog_PositionToFirstRecord=function(u,v){s.Exec("AMT_MessageLog","PositionToFirstRecord",{},u,v)};s.AMT_MessageLog_FreezeLog=function(v,u){s.Exec("AMT_MessageLog","FreezeLog",{Freeze:v},u)};s.AMT_PublicKeyManagementService_AddCRL=function(w,v,u){s.Exec("AMT_PublicKeyManagementService","AddCRL",{Url:w,SerialNumbers:v},u)};s.AMT_PublicKeyManagementService_ResetCRLList=function(u,v){s.Exec("AMT_PublicKeyManagementService","ResetCRLList",{_method_dummy:u},v)};s.AMT_PublicKeyManagementService_AddCertificate=function(v,u){s.Exec("AMT_PublicKeyManagementService","AddCertificate",{CertificateBlob:v},u)};s.AMT_PublicKeyManagementService_AddTrustedRootCertificate=function(v,u){s.Exec("AMT_PublicKeyManagementService","AddTrustedRootCertificate",{CertificateBlob:v},u)};s.AMT_PublicKeyManagementService_AddKey=function(v,u){s.Exec("AMT_PublicKeyManagementService","AddKey",{KeyBlob:v},u)};s.AMT_PublicKeyManagementService_GeneratePKCS10Request=function(w,v,x,u){s.Exec("AMT_PublicKeyManagementService","GeneratePKCS10Request",{KeyPair:w,DNName:v,Usage:x},u)};s.AMT_PublicKeyManagementService_GeneratePKCS10RequestEx=function(v,x,w,u){s.Exec("AMT_PublicKeyManagementService","GeneratePKCS10RequestEx",{KeyPair:v,SigningAlgorithm:x,NullSignedCertificateRequest:w},u)};s.AMT_PublicKeyManagementService_GenerateKeyPair=function(v,w,u){s.Exec("AMT_PublicKeyManagementService","GenerateKeyPair",{KeyAlgorithm:v,KeyLength:w},u)};s.AMT_RedirectionService_RequestStateChange=function(v,u){s.Exec("AMT_RedirectionService","RequestStateChange",{RequestedState:v},u)};s.AMT_RedirectionService_TerminateSession=function(v,u){s.Exec("AMT_RedirectionService","TerminateSession",{SessionType:v},u)};s.AMT_RemoteAccessService_AddMpServer=function(u,z,B,v,x,C,A,y,w){s.Exec("AMT_RemoteAccessService","AddMpServer",{AccessInfo:u,InfoFormat:z,Port:B,AuthMethod:v,Certificate:x,Username:C,Password:A,CN:y},w)};s.AMT_RemoteAccessService_AddRemoteAccessPolicyRule=function(x,y,v,w,u){s.Exec("AMT_RemoteAccessService","AddRemoteAccessPolicyRule",{Trigger:x,TunnelLifeTime:y,ExtendedData:v,MpServer:w},u)};s.AMT_RemoteAccessService_CloseRemoteAccessConnection=function(u,v){s.Exec("AMT_RemoteAccessService","CloseRemoteAccessConnection",{_method_dummy:u},v)};s.AMT_SetupAndConfigurationService_CommitChanges=function(u,v){s.Exec("AMT_SetupAndConfigurationService","CommitChanges",{_method_dummy:u},v)};s.AMT_SetupAndConfigurationService_Unprovision=function(v,u){s.Exec("AMT_SetupAndConfigurationService","Unprovision",{ProvisioningMode:v},u)};s.AMT_SetupAndConfigurationService_PartialUnprovision=function(u,v){s.Exec("AMT_SetupAndConfigurationService","PartialUnprovision",{_method_dummy:u},v)};s.AMT_SetupAndConfigurationService_ResetFlashWearOutProtection=function(u,v){s.Exec("AMT_SetupAndConfigurationService","ResetFlashWearOutProtection",{_method_dummy:u},v)};s.AMT_SetupAndConfigurationService_ExtendProvisioningPeriod=function(v,u){s.Exec("AMT_SetupAndConfigurationService","ExtendProvisioningPeriod",{Duration:v},u)};s.AMT_SetupAndConfigurationService_SetMEBxPassword=function(v,u){s.Exec("AMT_SetupAndConfigurationService","SetMEBxPassword",{Password:v},u)};s.AMT_SetupAndConfigurationService_SetTLSPSK=function(v,w,u){s.Exec("AMT_SetupAndConfigurationService","SetTLSPSK",{PID:v,PPS:w},u)};s.AMT_SetupAndConfigurationService_GetProvisioningAuditRecord=function(u){s.Exec("AMT_SetupAndConfigurationService","GetProvisioningAuditRecord",{},u)};s.AMT_SetupAndConfigurationService_GetUuid=function(u){s.Exec("AMT_SetupAndConfigurationService","GetUuid",{},u)};s.AMT_SetupAndConfigurationService_GetUnprovisionBlockingComponents=function(u){s.Exec("AMT_SetupAndConfigurationService","GetUnprovisionBlockingComponents",{},u)};s.AMT_SetupAndConfigurationService_GetProvisioningAuditRecordV2=function(u){s.Exec("AMT_SetupAndConfigurationService","GetProvisioningAuditRecordV2",{},u)};s.AMT_SystemDefensePolicy_GetTimeout=function(u){s.Exec("AMT_SystemDefensePolicy","GetTimeout",{},u)};s.AMT_SystemDefensePolicy_SetTimeout=function(v,u){s.Exec("AMT_SystemDefensePolicy","SetTimeout",{Timeout:v},u)};s.AMT_SystemDefensePolicy_UpdateStatistics=function(v,x,u,z,w,y){s.Exec("AMT_SystemDefensePolicy","UpdateStatistics",{NetworkInterface:v,ResetOnRead:x},u,z,w,y)};s.AMT_SystemPowerScheme_SetPowerScheme=function(u,v,w){s.Exec("AMT_SystemPowerScheme","SetPowerScheme",{},u,w,0,{InstanceID:v})};s.AMT_TimeSynchronizationService_GetLowAccuracyTimeSynch=function(u,v){s.Exec("AMT_TimeSynchronizationService","GetLowAccuracyTimeSynch",{},u,v)};s.AMT_TimeSynchronizationService_SetHighAccuracyTimeSynch=function(v,x,y,u,w){s.Exec("AMT_TimeSynchronizationService","SetHighAccuracyTimeSynch",{Ta0:v,Tm1:x,Tm2:y},u,w)};s.AMT_UserInitiatedConnectionService_RequestStateChange=function(v,w,u){s.Exec("AMT_UserInitiatedConnectionService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_WebUIService_RequestStateChange=function(v,w,u){s.Exec("AMT_WebUIService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_WiFiPortConfigurationService_AddWiFiSettings=function(y,z,x,w,u,v){s.ExecWithXml("AMT_WiFiPortConfigurationService","AddWiFiSettings",{WiFiEndpoint:y,WiFiEndpointSettingsInput:z,IEEE8021xSettingsInput:x,ClientCredential:w,CACredential:u},v)};s.AMT_WiFiPortConfigurationService_UpdateWiFiSettings=function(y,z,x,w,u,v){s.ExecWithXml("AMT_WiFiPortConfigurationService","UpdateWiFiSettings",{WiFiEndpointSettings:y,WiFiEndpointSettingsInput:z,IEEE8021xSettingsInput:x,ClientCredential:w,CACredential:u},v)};s.AMT_WiFiPortConfigurationService_DeleteAllITProfiles=function(u,v){s.Exec("AMT_WiFiPortConfigurationService","DeleteAllITProfiles",{_method_dummy:u},v)};s.AMT_WiFiPortConfigurationService_DeleteAllUserProfiles=function(u,v){s.Exec("AMT_WiFiPortConfigurationService","DeleteAllUserProfiles",{_method_dummy:u},v)};s.CIM_Account_RequestStateChange=function(v,w,u){s.Exec("CIM_Account","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_AccountManagementService_CreateAccount=function(w,u,v){s.Exec("CIM_AccountManagementService","CreateAccount",{System:w,AccountTemplate:u},v)};s.CIM_BootConfigSetting_ChangeBootOrder=function(v,u){s.Exec("CIM_BootConfigSetting","ChangeBootOrder",{Source:v},u)};s.CIM_BootService_SetBootConfigRole=function(u,w,v){s.Exec("CIM_BootService","SetBootConfigRole",{BootConfigSetting:u,Role:w},v,0,1)};s.CIM_Card_ConnectorPower=function(v,w,u){s.Exec("CIM_Card","ConnectorPower",{Connector:v,PoweredOn:w},u)};s.CIM_Card_IsCompatible=function(v,u){s.Exec("CIM_Card","IsCompatible",{ElementToCheck:v},u)};s.CIM_Chassis_IsCompatible=function(v,u){s.Exec("CIM_Chassis","IsCompatible",{ElementToCheck:v},u)};s.CIM_Fan_SetSpeed=function(v,u){s.Exec("CIM_Fan","SetSpeed",{DesiredSpeed:v},u)};s.CIM_KVMRedirectionSAP_RequestStateChange=function(v,w,u){s.Exec("CIM_KVMRedirectionSAP","RequestStateChange",{RequestedState:v},u)};s.CIM_MediaAccessDevice_LockMedia=function(v,u){s.Exec("CIM_MediaAccessDevice","LockMedia",{Lock:v},u)};s.CIM_MediaAccessDevice_SetPowerState=function(v,w,u){s.Exec("CIM_MediaAccessDevice","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_MediaAccessDevice_Reset=function(u){s.Exec("CIM_MediaAccessDevice","Reset",{},u)};s.CIM_MediaAccessDevice_EnableDevice=function(v,u){s.Exec("CIM_MediaAccessDevice","EnableDevice",{Enabled:v},u)};s.CIM_MediaAccessDevice_OnlineDevice=function(v,u){s.Exec("CIM_MediaAccessDevice","OnlineDevice",{Online:v},u)};s.CIM_MediaAccessDevice_QuiesceDevice=function(v,u){s.Exec("CIM_MediaAccessDevice","QuiesceDevice",{Quiesce:v},u)};s.CIM_MediaAccessDevice_SaveProperties=function(u){s.Exec("CIM_MediaAccessDevice","SaveProperties",{},u)};s.CIM_MediaAccessDevice_RestoreProperties=function(u){s.Exec("CIM_MediaAccessDevice","RestoreProperties",{},u)};s.CIM_MediaAccessDevice_RequestStateChange=function(v,w,u){s.Exec("CIM_MediaAccessDevice","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_PhysicalFrame_IsCompatible=function(v,u){s.Exec("CIM_PhysicalFrame","IsCompatible",{ElementToCheck:v},u)};s.CIM_PhysicalPackage_IsCompatible=function(v,u){s.Exec("CIM_PhysicalPackage","IsCompatible",{ElementToCheck:v},u)};s.CIM_PowerManagementService_RequestPowerStateChange=function(w,v,x,y,u){s.Exec("CIM_PowerManagementService","RequestPowerStateChange",{PowerState:w,ManagedElement:v,Time:x,TimeoutPeriod:y},u,0,1)};s.CIM_PowerSupply_SetPowerState=function(v,w,u){s.Exec("CIM_PowerSupply","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_PowerSupply_Reset=function(u){s.Exec("CIM_PowerSupply","Reset",{},u)};s.CIM_PowerSupply_EnableDevice=function(v,u){s.Exec("CIM_PowerSupply","EnableDevice",{Enabled:v},u)};s.CIM_PowerSupply_OnlineDevice=function(v,u){s.Exec("CIM_PowerSupply","OnlineDevice",{Online:v},u)};s.CIM_PowerSupply_QuiesceDevice=function(v,u){s.Exec("CIM_PowerSupply","QuiesceDevice",{Quiesce:v},u)};s.CIM_PowerSupply_SaveProperties=function(u){s.Exec("CIM_PowerSupply","SaveProperties",{},u)};s.CIM_PowerSupply_RestoreProperties=function(u){s.Exec("CIM_PowerSupply","RestoreProperties",{},u)};s.CIM_PowerSupply_RequestStateChange=function(v,w,u){s.Exec("CIM_PowerSupply","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_Processor_SetPowerState=function(v,w,u){s.Exec("CIM_Processor","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_Processor_Reset=function(u){s.Exec("CIM_Processor","Reset",{},u)};s.CIM_Processor_EnableDevice=function(v,u){s.Exec("CIM_Processor","EnableDevice",{Enabled:v},u)};s.CIM_Processor_OnlineDevice=function(v,u){s.Exec("CIM_Processor","OnlineDevice",{Online:v},u)};s.CIM_Processor_QuiesceDevice=function(v,u){s.Exec("CIM_Processor","QuiesceDevice",{Quiesce:v},u)};s.CIM_Processor_SaveProperties=function(u){s.Exec("CIM_Processor","SaveProperties",{},u)};s.CIM_Processor_RestoreProperties=function(u){s.Exec("CIM_Processor","RestoreProperties",{},u)};s.CIM_Processor_RequestStateChange=function(v,w,u){s.Exec("CIM_Processor","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_RecordLog_ClearLog=function(u){s.Exec("CIM_RecordLog","ClearLog",{},u)};s.CIM_RecordLog_RequestStateChange=function(v,w,u){s.Exec("CIM_RecordLog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_RedirectionService_RequestStateChange=function(v,w,u){s.Exec("CIM_RedirectionService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_Sensor_SetPowerState=function(v,w,u){s.Exec("CIM_Sensor","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_Sensor_Reset=function(u){s.Exec("CIM_Sensor","Reset",{},u)};s.CIM_Sensor_EnableDevice=function(v,u){s.Exec("CIM_Sensor","EnableDevice",{Enabled:v},u)};s.CIM_Sensor_OnlineDevice=function(v,u){s.Exec("CIM_Sensor","OnlineDevice",{Online:v},u)};s.CIM_Sensor_QuiesceDevice=function(v,u){s.Exec("CIM_Sensor","QuiesceDevice",{Quiesce:v},u)};s.CIM_Sensor_SaveProperties=function(u){s.Exec("CIM_Sensor","SaveProperties",{},u)};s.CIM_Sensor_RestoreProperties=function(u){s.Exec("CIM_Sensor","RestoreProperties",{},u)};s.CIM_Sensor_RequestStateChange=function(v,w,u){s.Exec("CIM_Sensor","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_StatisticalData_ResetSelectedStats=function(v,u){s.Exec("CIM_StatisticalData","ResetSelectedStats",{SelectedStatistics:v},u)};s.CIM_Watchdog_KeepAlive=function(u){s.Exec("CIM_Watchdog","KeepAlive",{},u)};s.CIM_Watchdog_SetPowerState=function(v,w,u){s.Exec("CIM_Watchdog","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_Watchdog_Reset=function(u){s.Exec("CIM_Watchdog","Reset",{},u)};s.CIM_Watchdog_EnableDevice=function(v,u){s.Exec("CIM_Watchdog","EnableDevice",{Enabled:v},u)};s.CIM_Watchdog_OnlineDevice=function(v,u){s.Exec("CIM_Watchdog","OnlineDevice",{Online:v},u)};s.CIM_Watchdog_QuiesceDevice=function(v,u){s.Exec("CIM_Watchdog","QuiesceDevice",{Quiesce:v},u)};s.CIM_Watchdog_SaveProperties=function(u){s.Exec("CIM_Watchdog","SaveProperties",{},u)};s.CIM_Watchdog_RestoreProperties=function(u){s.Exec("CIM_Watchdog","RestoreProperties",{},u)};s.CIM_Watchdog_RequestStateChange=function(v,w,u){s.Exec("CIM_Watchdog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_WiFiPort_SetPowerState=function(v,w,u){s.Exec("CIM_WiFiPort","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_WiFiPort_Reset=function(u){s.Exec("CIM_WiFiPort","Reset",{},u)};s.CIM_WiFiPort_EnableDevice=function(v,u){s.Exec("CIM_WiFiPort","EnableDevice",{Enabled:v},u)};s.CIM_WiFiPort_OnlineDevice=function(v,u){s.Exec("CIM_WiFiPort","OnlineDevice",{Online:v},u)};s.CIM_WiFiPort_QuiesceDevice=function(v,u){s.Exec("CIM_WiFiPort","QuiesceDevice",{Quiesce:v},u)};s.CIM_WiFiPort_SaveProperties=function(u){s.Exec("CIM_WiFiPort","SaveProperties",{},u)};s.CIM_WiFiPort_RestoreProperties=function(u){s.Exec("CIM_WiFiPort","RestoreProperties",{},u)};s.CIM_WiFiPort_RequestStateChange=function(v,w,u){s.Exec("CIM_WiFiPort","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.IPS_HostBasedSetupService_Setup=function(y,z,x,v,A,w,u){s.Exec("IPS_HostBasedSetupService","Setup",{NetAdminPassEncryptionType:y,NetworkAdminPassword:z,McNonce:x,Certificate:v,SigningAlgorithm:A,DigitalSignature:w},u)};s.IPS_HostBasedSetupService_AddNextCertInChain=function(x,v,w,u){s.Exec("IPS_HostBasedSetupService","AddNextCertInChain",{NextCertificate:x,IsLeafCertificate:v,IsRootCertificate:w},u)};s.IPS_HostBasedSetupService_AdminSetup=function(x,y,w,z,v,u){s.Exec("IPS_HostBasedSetupService","AdminSetup",{NetAdminPassEncryptionType:x,NetworkAdminPassword:y,McNonce:w,SigningAlgorithm:z,DigitalSignature:v},u)};s.IPS_HostBasedSetupService_UpgradeClientToAdmin=function(w,x,v,u){s.Exec("IPS_HostBasedSetupService","UpgradeClientToAdmin",{McNonce:w,SigningAlgorithm:x,DigitalSignature:v},u)};s.IPS_HostBasedSetupService_DisableClientControlMode=function(u,v){s.Exec("IPS_HostBasedSetupService","DisableClientControlMode",{_method_dummy:u},v)};s.IPS_KVMRedirectionSettingData_TerminateSession=function(u){s.Exec("IPS_KVMRedirectionSettingData","TerminateSession",{},u)};s.IPS_OptInService_StartOptIn=function(u){s.Exec("IPS_OptInService","StartOptIn",{},u)};s.IPS_OptInService_CancelOptIn=function(u){s.Exec("IPS_OptInService","CancelOptIn",{},u)};s.IPS_OptInService_SendOptInCode=function(v,u){s.Exec("IPS_OptInService","SendOptInCode",{OptInCode:v},u)};s.IPS_OptInService_StartService=function(u){s.Exec("IPS_OptInService","StartService",{},u)};s.IPS_OptInService_StopService=function(u){s.Exec("IPS_OptInService","StopService",{},u)};s.IPS_OptInService_RequestStateChange=function(v,w,u){s.Exec("IPS_OptInService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.IPS_ProvisioningRecordLog_RequestStateChange=function(v,w,u){s.Exec("IPS_ProvisioningRecordLog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.IPS_ProvisioningRecordLog_ClearLog=function(u,v){s.Exec("IPS_ProvisioningRecordLog","ClearLog",{_method_dummy:u},v)};s.IPS_SecIOService_RequestStateChange=function(v,w,u){s.Exec("IPS_SecIOService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AmtStatusToStr=function(u){if(s.AmtStatusCodes[u]){return s.AmtStatusCodes[u]}else{return"UNKNOWN_ERROR"}};s.AmtStatusCodes={0:"SUCCESS",1:"INTERNAL_ERROR",2:"NOT_READY",3:"INVALID_PT_MODE",4:"INVALID_MESSAGE_LENGTH",5:"TABLE_FINGERPRINT_NOT_AVAILABLE",6:"INTEGRITY_CHECK_FAILED",7:"UNSUPPORTED_ISVS_VERSION",8:"APPLICATION_NOT_REGISTERED",9:"INVALID_REGISTRATION_DATA",10:"APPLICATION_DOES_NOT_EXIST",11:"NOT_ENOUGH_STORAGE",12:"INVALID_NAME",13:"BLOCK_DOES_NOT_EXIST",14:"INVALID_BYTE_OFFSET",15:"INVALID_BYTE_COUNT",16:"NOT_PERMITTED",17:"NOT_OWNER",18:"BLOCK_LOCKED_BY_OTHER",19:"BLOCK_NOT_LOCKED",20:"INVALID_GROUP_PERMISSIONS",21:"GROUP_DOES_NOT_EXIST",22:"INVALID_MEMBER_COUNT",23:"MAX_LIMIT_REACHED",24:"INVALID_AUTH_TYPE",25:"AUTHENTICATION_FAILED",26:"INVALID_DHCP_MODE",27:"INVALID_IP_ADDRESS",28:"INVALID_DOMAIN_NAME",29:"UNSUPPORTED_VERSION",30:"REQUEST_UNEXPECTED",31:"INVALID_TABLE_TYPE",32:"INVALID_PROVISIONING_STATE",33:"UNSUPPORTED_OBJECT",34:"INVALID_TIME",35:"INVALID_INDEX",36:"INVALID_PARAMETER",37:"INVALID_NETMASK",38:"FLASH_WRITE_LIMIT_EXCEEDED",39:"INVALID_IMAGE_LENGTH",40:"INVALID_IMAGE_SIGNATURE",41:"PROPOSE_ANOTHER_VERSION",42:"INVALID_PID_FORMAT",43:"INVALID_PPS_FORMAT",44:"BIST_COMMAND_BLOCKED",45:"CONNECTION_FAILED",46:"CONNECTION_TOO_MANY",47:"RNG_GENERATION_IN_PROGRESS",48:"RNG_NOT_READY",49:"CERTIFICATE_NOT_READY",1024:"DISABLED_BY_POLICY",2048:"NETWORK_IF_ERROR_BASE",2049:"UNSUPPORTED_OEM_NUMBER",2050:"UNSUPPORTED_BOOT_OPTION",2051:"INVALID_COMMAND",2052:"INVALID_SPECIAL_COMMAND",2053:"INVALID_HANDLE",2054:"INVALID_PASSWORD",2055:"INVALID_REALM",2056:"STORAGE_ACL_ENTRY_IN_USE",2057:"DATA_MISSING",2058:"DUPLICATE",2059:"EVENTLOG_FROZEN",2060:"PKI_MISSING_KEYS",2061:"PKI_GENERATING_KEYS",2062:"INVALID_KEY",2063:"INVALID_CERT",2064:"CERT_KEY_NOT_MATCH",2065:"MAX_KERB_DOMAIN_REACHED",2066:"UNSUPPORTED",2067:"INVALID_PRIORITY",2068:"NOT_FOUND",2069:"INVALID_CREDENTIALS",2070:"INVALID_PASSPHRASE",2072:"NO_ASSOCIATION",2075:"AUDIT_FAIL",2076:"BLOCKING_COMPONENT",2081:"USER_CONSENT_REQUIRED",4096:"APP_INTERNAL_ERROR",4097:"NOT_INITIALIZED",4098:"LIB_VERSION_UNSUPPORTED",4099:"INVALID_PARAM",4100:"RESOURCES",4101:"HARDWARE_ACCESS_ERROR",4102:"REQUESTOR_NOT_REGISTERED",4103:"NETWORK_ERROR",4104:"PARAM_BUFFER_TOO_SHORT",4105:"COM_NOT_INITIALIZED_IN_THREAD",4106:"URL_REQUIRED"};s.GetMessageLog=function(u,v){s.AMT_MessageLog_PositionToFirstRecord(k,[u,v,[]])};function k(w,u,v,x,y){if(x!=200||v.Body.ReturnValue!="0"){y[0](s,null,y[2]);return}s.AMT_MessageLog_GetRecords(v.Body.IterationIdentifier,390,l,y)}function l(D,A,C,E,G){if(E!=200||C.Body.ReturnValue!="0"){G[0](s,null,G[2]);return}var y,z,I,v,u=G[2],F=new Date(),H,B=C.Body.RecordArray;if(typeof B==="string"){C.Body.RecordArray=[C.Body.RecordArray]}for(y in B){v=null;try{v=window.atob(B[y])}catch(w){}if(v!=null){H=ReadIntX(v,0);if((H>0)&&(H<4294967295)){I={DeviceAddress:v.charCodeAt(4),EventSensorType:v.charCodeAt(5),EventType:v.charCodeAt(6),EventOffset:v.charCodeAt(7),EventSourceType:v.charCodeAt(8),EventSeverity:v.charCodeAt(9),SensorNumber:v.charCodeAt(10),Entity:v.charCodeAt(11),EntityInstance:v.charCodeAt(12),EventData:[],Time:new Date((H+(F.getTimezoneOffset()*60))*1000)};for(z=13;z<21;z++){I.EventData.push(v.charCodeAt(z))}I.EntityStr=o[I.Entity];I.Desc=j(I.EventSensorType,I.EventOffset,I.EventData,I.Entity);if(!I.EntityStr){I.EntityStr="Unknown"}u.push(I)}}}if(C.Body.NoMoreRecords!=true){s.AMT_MessageLog_GetRecords(C.Body.IterationIdentifier,390,l,[G[0],u,G[2]])}else{G[0](s,u,G[2])}}var e="Platform firmware (e.g. BIOS)|SMI handler|ISV system management software|Alert ASIC|IPMI|BIOS vendor|System board set vendor|System integrator|Third party add-in|OSV|NIC|System management card".split("|");var p="Unspecified.|No system memory is physically installed in the system.|No usable system memory, all installed memory has experienced an unrecoverable failure.|Unrecoverable hard-disk/ATAPI/IDE device failure.|Unrecoverable system-board failure.|Unrecoverable diskette subsystem failure.|Unrecoverable hard-disk controller failure.|Unrecoverable PS/2 or USB keyboard failure.|Removable boot media not found.|Unrecoverable video controller failure.|No video device detected.|Firmware (BIOS) ROM corruption detected.|CPU voltage mismatch (processors that share same supply have mismatched voltage requirements)|CPU speed matching failure".split("|");var q="Unspecified.|Memory initialization.|Starting hard-disk initialization and test|Secondary processor(s) initialization|User authentication|User-initiated system setup|USB resource configuration|PCI resource configuration|Option ROM initialization|Video initialization|Cache initialization|SM Bus initialization|Keyboard controller initialization|Embedded controller/management controller initialization|Docking station attachment|Enabling docking station|Docking station ejection|Disabling docking station|Calling operating system wake-up vector|Starting operating system boot process|Baseboard or motherboard initialization|reserved|Floppy initialization|Keyboard test|Pointing device test|Primary processor initialization".split("|");var o="Unspecified|Other|Unknown|Processor|Disk|Peripheral|System management module|System board|Memory module|Processor module|Power supply|Add in card|Front panel board|Back panel board|Power system board|Drive backplane|System internal expansion board|Other system board|Processor board|Power unit|Power module|Power management board|Chassis back panel board|System chassis|Sub chassis|Other chassis board|Disk drive bay|Peripheral bay|Device bay|Fan cooling|Cooling unit|Cable interconnect|Memory device|System management software|BIOS|Intel(r) ME|System bus|Group|Intel(r) ME|External environment|Battery|Processing blade|Connectivity switch|Processor/memory module|I/O module|Processor I/O module|Management controller firmware|IPMI channel|PCI bus|PCI express bus|SCSI bus|SATA/SAS bus|Processor front side bus".split("|");s.RealmNames="||Redirection|PT Administration|Hardware Asset|Remote Control|Storage|Event Manager|Storage Admin|Agent Presence Local|Agent Presence Remote|Circuit Breaker|Network Time|General Information|Firmware Update|EIT|LocalUN|Endpoint Access Control|Endpoint Access Control Admin|Event Log Reader|Audit Log|ACL Realm|||Local System".split("|");s.WatchdogCurrentStates={1:"Not Started",2:"Stopped",4:"Running",8:"Expired",16:"Suspended"};function j(x,w,v,u){if(x==15){if(v[0]==235){return"Invalid Data"}if(w==0){return p[v[1]]}return q[v[1]]}if(x==18&&v[0]==170){return"Agent watchdog "+char2hex(v[4])+char2hex(v[3])+char2hex(v[2])+char2hex(v[1])+"-"+char2hex(v[6])+char2hex(v[5])+"-... changed to "+s.WatchdogCurrentStates[v[7]]}if(x==6){return"Authentication failed "+(v[1]+(v[2]<<8))+" times. The system may be under attack."}if(x==30){return"No bootable media"}if(x==32){return"Operating system lockup or power interrupt"}if(x==35){return"System boot failure"}if(x==37){return"System firmware started (at least one CPU is properly executing)."}return"Unknown Sensor Type #"+x}return s}var md5_k=[];for(var i=0;i<64;){md5_k[i]=0|(Math.abs(Math.sin(++i))*4294967296)}function hex_md5(p){var g,k,l,o,r=[],q=unescape(encodeURI(p)),e=q.length,m=[g=1732584193,k=-271733879,~g,~k],n=0;for(;n<=e;){r[n>>2]|=(q.charCodeAt(n)||128)<<8*(n++%4)}r[p=(e+8>>6)*16+14]=e*8;n=0;for(;n<p;n+=16){e=m;o=0;for(;o<64;){e=[l=e[3],((g=e[1]|0)+((l=((e[0]+[g&(k=e[2])|~g&l,l&g|~l&k,g^k^l,k^(g|~l)][e=o>>4])+(md5_k[o]+(r[[o,5*o+1,3*o+5,7*o][e]%16+n]|0))))<<(e=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*e+o++%4])|l>>>32-e)),g,k]}for(o=4;o;){m[--o]=m[o]+e[o]}}p="";for(;o<32;){p+=((m[o>>3]>>((1^o++&7)*4))&15).toString(16)}return p}function rstr_md5(a){return hex2rstr(hex_md5(a))}function execArgumentsToXml(c){if(c===undefined||c===null){return null}var d="";for(var b in c){var a=c[b];if(!a){continue}if(a.__parameterType==="reference"){d+=referenceToXml(b,a)}else{d+=instanceToXml(b,a)}}return d}function instanceToXml(d,c){if(c===undefined||c===null){return null}var b=!!c.__namespace;var j=b?"<q:":"<";var a=b?"</q:":"</";var e=b?(' xmlns:q="'+c.__namespace+'"'):"";var h="<r:"+d+e+">";for(var g in c){if(!c.hasOwnProperty(g)||g.indexOf("__")===0){continue}if(typeof c[g]==="function"||Array.isArray(c[g])){continue}if(typeof c[g]==="object"){console.error("only convert one level down...")}else{h+=j+g+">"+c[g].toString()+a+g+">"}}h+="</r:"+d+">";return h}function referenceToXml(b,a){if(a===undefined||a===null){return null}var c="<r:"+b+"><a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>"+a.__resourceUri+"</w:ResourceURI><w:SelectorSet>";for(var d in a){if(!a.hasOwnProperty(d)||d.indexOf("__")===0){continue}if(typeof a[d]==="function"||typeof a[d]==="object"||Array.isArray(a[d])){continue}c+='<w:Selector Name="'+d+'">'+a[d].toString()+"</w:Selector>"}c+="</w:SelectorSet></a:ReferenceParameters></r:"+b+">";return c}function GetSidString(c){var b="S-"+c.charCodeAt(0)+"-"+c.charCodeAt(7);for(var a=2;a<(c.length/4);a++){b+="-"+ReadIntX(c,a*4)}return b}function GetSidByteArray(d){if(!d||d==null){return null}var c=d.split("-");if(c.length<4||(c[0]!="s"&&c[0]!="S")){return null}for(var a=1;a<c.length;a++){var e=parseInt(c[a]);if(e!=c[a]){return null}c[a]=e}var b=String.fromCharCode(c[1])+String.fromCharCode(c.length-3)+ShortToStr(Math.floor(c[2]/Math.pow(2,32)))+IntToStr((c[2])&65535);for(var a=3;a<c.length;a++){b+=IntToStrX(c[a])}return b}var WsmanStackCreateService=function(h,l,n,k,m,g){var j={};j.NextMessageId=1;j.Address="/wsman";j.comm=CreateWsmanComm(h,l,n,k,m,g);j.PerformAjax=function(q,o,s,r,p){if(p==undefined){p=""}j.comm.PerformAjax('<?xml version="1.0" encoding="utf-8"?><Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns="http://www.w3.org/2003/05/soap-envelope" '+p+"><Header><a:Action>"+q,function(t,u,v){if(u!=200){o(j,null,{Header:{HttpError:u}},u,v);return}var w=j.ParseWsman(t);if(!w||w==null){o(j,null,{Header:{HttpError:u}},601,v)}else{o(j,w.Header.ResourceURI,w,200,v)}},s,r)};j.CancelAllQueries=function(o){j.comm.CancelAllQueries(o)};j.GetNameFromUrl=function(o){var p=o.lastIndexOf("/");return(p==-1)?o:o.substring(p+1)};j.ExecSubscribe=function(w,q,z,o,y,v,x,t,A,u){var r="",s="";if(A!=undefined&&u!=undefined){r="<t:IssuedTokens><t:RequestSecurityTokenResponse><t:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</t:TokenType><t:RequestedSecurityToken><se:UsernameToken><se:Username>"+A+'</se:Username><se:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#PasswordText">'+u+"</se:Password></se:UsernameToken></t:RequestedSecurityToken></t:RequestSecurityTokenResponse></t:IssuedTokens>";s='<Auth Profile="http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/secprofile/http/digest"/>'}if(t!=undefined&&t!=null){t="<a:ReferenceParameters>"+t+"</a:ReferenceParameters>"}else{t=""}var p="http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+w+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"+d(x)+r+'</Header><Body><e:Subscribe><e:Delivery Mode="http://schemas.dmtf.org/wbem/wsman/1/wsman/'+q+'"><e:NotifyTo><a:Address>'+z+"</a:Address></e:NotifyTo>"+s+"</e:Delivery><e:Expires>PT0.000000S</e:Expires></e:Subscribe>";j.PerformAjax(p+"</Body></Envelope>",o,y,v,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:m="http://x.com"')};j.ExecUnSubscribe=function(r,o,t,q,s){var p="http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+r+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"+d(s)+"</Header><Body><e:Unsubscribe/>";j.PerformAjax(p+"</Body></Envelope>",o,t,q,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"')};j.ExecPut=function(s,r,o,u,q,t){var p="http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+s+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout>"+d(t)+"</Header><Body>"+c(s,r);j.PerformAjax(p+"</Body></Envelope>",o,u,q)};j.ExecCreate=function(u,t,o,w,s,v){var r=j.GetNameFromUrl(u);var p="http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+u+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+d(v)+"</Header><Body><g:"+r+' xmlns:g="'+u+'">';for(var q in t){p+="<g:"+q+">"+t[q]+"</g:"+q+">"}j.PerformAjax(p+"</g:"+r+"></Body></Envelope>",o,w,s)};j.ExecCreateXml=function(s,o,p,u,r){var q=j.GetNameFromUrl(s),t="";j.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+s+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout></Header><Body><r:"+q+' xmlns:r="'+s+'">'+o+"</r:"+q+"></Body></Envelope>",p,u,r)};j.ExecDelete=function(s,r,o,t,q){var p="http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+s+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+d(r)+"</Header><Body /></Envelope>";j.PerformAjax(p,o,t,q)};j.ExecGet=function(q,o,r,p){j.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+q+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body /></Envelope>",o,r,p)};j.ExecMethod=function(u,s,o,q,w,t,v){var p="";for(var r in o){if(o[r]!=null){if(Array.isArray(o[r])){for(var y in o[r]){p+="<r:"+r+">"+o[r][y]+"</r:"+r+">"}}else{p+="<r:"+r+">"+o[r]+"</r:"+r+">"}}}j.ExecMethodXml(u,s,p,q,w,t,v)};j.ExecMethodXml=function(s,q,o,p,u,r,t){j.PerformAjax(s+"/"+q+"</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+s+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+d(t)+"</Header><Body><r:"+q+'_INPUT xmlns:r="'+s+'">'+o+"</r:"+q+"_INPUT></Body></Envelope>",p,u,r)};j.ExecEnum=function(q,o,r,p){j.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+q+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+'</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Enumerate xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration" /></Body></Envelope>',o,r,p)};j.ExecPull=function(r,p,o,s,q){j.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+r+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+'</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration"><EnumerationContext>'+p+"</EnumerationContext><MaxElements>999</MaxElements><MaxCharacters>99999</MaxCharacters></Pull></Body></Envelope>",o,s,q)};j.ParseWsman=function(x){try{if(!x.childNodes){x=e(x)}var v={Header:{}},s=x.getElementsByTagName("Header")[0],w;if(!s){s=x.getElementsByTagName("a:Header")[0]}if(!s){return null}for(var u=0;u<s.childNodes.length;u++){var p=s.childNodes[u];v.Header[p.localName]=p.textContent}var o=x.getElementsByTagName("Body")[0];if(!o){o=x.getElementsByTagName("a:Body")[0]}if(!o){return null}if(o.childNodes.length>0){w=o.childNodes[0].localName;if(w.indexOf("_OUTPUT")==w.length-7){w=w.substring(0,w.length-7)}v.Header.Method=w;v.Body=b(o.childNodes[0])}return v}catch(q){console.log("Unable to parse XML: "+x);return null}};function b(u){var q,v={};for(var s=0;s<u.childNodes.length;s++){var o=u.childNodes[s];if(o.childElementCount==0){q=o.textContent}else{q=b(o)}if(q=="true"){q=true}if(q=="false"){q=false}var p=q;if(o.attributes.length>0){p={Value:q};for(var t=0;t<o.attributes.length;t++){p["@"+o.attributes[t].name]=o.attributes[t].value}}if(v[o.localName] instanceof Array){v[o.localName].push(p)}else{if(v[o.localName]==undefined){v[o.localName]=p}else{v[o.localName]=[v[o.localName],p]}}}return v}function c(t,r){if(!t||r===undefined||r===null){return""}var p=j.GetNameFromUrl(t);var s="<r:"+p+' xmlns:r="'+t+'">';for(var q in r){if(!r.hasOwnProperty(q)||q.indexOf("__")===0||q.indexOf("@")===0){continue}if(r[q]===undefined||r[q]===null||typeof r[q]==="function"){continue}if(typeof r[q]==="object"&&r[q]["ReferenceParameters"]){s+="<r:"+q+"><a:Address>"+r[q].Address+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+r[q]["ReferenceParameters"]["ResourceURI"]+"</w:ResourceURI><w:SelectorSet>";var u=r[q]["ReferenceParameters"]["SelectorSet"]["Selector"];if(Array.isArray(u)){for(var o=0;o<u.length;o++){s+="<w:Selector"+a(u[o])+">"+u[o]["Value"]+"</w:Selector>"}}else{s+="<w:Selector"+a(u)+">"+u.Value+"</w:Selector>"}s+="</w:SelectorSet></a:ReferenceParameters></r:"+q+">"}else{if(Array.isArray(r[q])){for(var o=0;o<r[q].length;o++){s+="<r:"+q+">"+r[q][o].toString()+"</r:"+q+">"}}else{s+="<r:"+q+">"+r[q].toString()+"</r:"+q+">"}}}s+="</r:"+p+">";return s}function a(o){if(!o){return""}var q=" ";for(var p in o){if(!o.hasOwnProperty(p)||p.indexOf("@")!==0){continue}q+=p.substring(1)+'="'+o[p]+'" '}return q}function d(s){if(!s){return""}if(typeof s=="string"){return s}if(s.InstanceID){return'<w:SelectorSet><w:Selector Name="InstanceID">'+s.InstanceID+"</w:Selector></w:SelectorSet>"}var q="<w:SelectorSet>";for(var p in s){if(!s.hasOwnProperty(p)){continue}q+='<w:Selector Name="'+p+'">';if(s[p]["ReferenceParameters"]){q+="<a:EndpointReference>";q+="<a:Address>"+s[p]["Address"]+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+s[p]["ReferenceParameters"]["ResourceURI"]+"</w:ResourceURI><w:SelectorSet>";var r=s[p]["ReferenceParameters"]["SelectorSet"]["Selector"];if(Array.isArray(r)){for(var o=0;o<r.length;o++){q+="<w:Selector"+a(r[o])+">"+r[o]["Value"]+"</w:Selector>"}}else{q+="<w:Selector"+a(r)+">"+r.Value+"</w:Selector>"}q+="</w:SelectorSet></a:ReferenceParameters></a:EndpointReference>"}else{q+=s[p]}q+="</w:Selector>"}q+="</w:SelectorSet>";return q}function e(o){if(window.DOMParser){return new DOMParser().parseFromString(o,"text/xml")}else{var p=new ActiveXObject("Microsoft.XMLDOM");p.async=false;p.loadXML(o);return p}}return j};var CreateAmtRemoteDesktop=function(p,s){var r={};r.canvasid=p;r.CanvasId=Q(p);r.scrolldiv=s;r.canvas=Q(p).getContext("2d");r.protocol=2;r.state=0;r.acc="";r.ScreenWidth=960;r.ScreenHeight=700;r.width=0;r.height=0;r.rwidth=0;r.rheight=0;r.bpp=2;r.useZRLE=true;r.showmouse=true;r.buttonmask=0;r.localKeyMap=true;r.spare=null;r.sparew=0;r.spareh=0;r.sparew2=0;r.spareh2=0;r.sparecache={};r.ZRLEfirst=1;r.onScreenSizeChange=null;r.frameRateDelay=0;r.kvmDataSupported=false;r.onKvmData=null;r.onKvmDataPending=[];r.onKvmDataAck=-1;r.holding=false;r.lastKeepAlive=Date.now();r.mNagleTimer=null;r.mx=0;r.my=0;r.Debug=function(t){console.log(t)};r.xxStateChange=function(t){if(t==0){r.canvas.fillStyle="#000000";r.canvas.fillRect(0,0,r.width,r.height);r.canvas.canvas.width=r.rwidth=r.width=640;r.canvas.canvas.height=r.rheight=r.height=400;QS(r.canvasid).cursor="default"}else{QS(r.canvasid).cursor=r.showmouse?"default":"none"}};r.ProcessData=function(v){if(!v){return}r.acc+=v;while(r.acc.length>0){var t=0;if(r.state==0&&r.acc.length>=12){t=12;r.state=1;r.send("RFB 003.008\n")}else{if(r.state==1&&r.acc.length>=1){t=r.acc.charCodeAt(0)+1;r.send(String.fromCharCode(1));r.state=2}else{if(r.state==2&&r.acc.length>=4){t=4;if(ReadInt(r.acc,0)!=0){return r.Stop()}r.send(String.fromCharCode(1));r.state=3}else{if(r.state==3&&r.acc.length>=24){var G=ReadInt(r.acc,20);if(r.acc.length<24+G){return}t=24+G;r.canvas.canvas.width=r.rwidth=r.width=r.ScreenWidth=ReadShort(r.acc,0);r.canvas.canvas.height=r.rheight=r.height=r.ScreenHeight=ReadShort(r.acc,2);var J="";if(r.useZRLE){J+=IntToStr(16)}J+=IntToStr(0);J+=IntToStr(1092);r.send(String.fromCharCode(2,0)+ShortToStr((J.length/4)+1)+J+IntToStr(-223));if(r.bpp==1){r.send(String.fromCharCode(0,0,0,0,8,8,0,1)+ShortToStr(7)+ShortToStr(7)+ShortToStr(3)+String.fromCharCode(5,2,0,0,0,0))}r.state=4;r.parent.xxStateChange(3);h();if(r.onScreenSizeChange!=null){r.onScreenSizeChange(r,r.ScreenWidth,r.ScreenHeight)}}else{if(r.state==4){switch(r.acc.charCodeAt(0)){case 0:if(r.acc.length<4){return}r.state=100+ReadShort(r.acc,2);t=4;break;case 2:t=1;break;case 3:if(r.acc.length<8){return}var F=ReadInt(r.acc,4)+8;if(r.acc.length<F){return}t=q(r.acc);break}}else{if(r.state>100&&r.acc.length>=12){var L=ReadShort(r.acc,0),N=ReadShort(r.acc,2),K=ReadShort(r.acc,4),C=ReadShort(r.acc,6),I=K*C,B=ReadInt(r.acc,8);if(B<17){if(K<1||K>64||C<1||C>64){console.log("Invalid tile size ("+K+","+C+"), disconnecting.");return r.Stop()}if(r.sparew!=K||r.spareh!=C){r.sparew=r.sparew2=K;r.spareh=r.spareh2=C;var M=r.sparew2+"x"+r.spareh2;r.spare=r.sparecache[M];if(!r.spare){r.sparecache[M]=r.spare=r.canvas.createImageData(r.sparew2,r.spareh2);var E=(r.sparew2*r.spareh2)<<2;for(var D=3;D<E;D+=4){r.spare.data[D]=255}}}}if(B==4294967073){r.canvas.canvas.width=r.rwidth=r.width=K;r.canvas.canvas.height=r.rheight=r.height=C;r.send(String.fromCharCode(3,0,0,0,0,0)+ShortToStr(r.width)+ShortToStr(r.height));t=12;if(r.onScreenSizeChange!=null){r.onScreenSizeChange(r,r.ScreenWidth,r.ScreenHeight)}}else{if(B==0){var H=12,u=12+(I*r.bpp);if(r.acc.length<u){return}t=u;if(r.bpp==2){for(var D=0;D<I;D++){j(r.acc.charCodeAt(H++)+(r.acc.charCodeAt(H++)<<8),D)}}else{for(var D=0;D<I;D++){l(r.acc.charCodeAt(H++),D)}}g(r.spare,L,N)}else{if(B==16){if(r.acc.length<16){return}var w=ReadInt(r.acc,12);if(r.acc.length<(16+w)){return}var H=16,z=5,A=0;if(w>5&&r.acc.charCodeAt(H)==0&&ReadShortX(r.acc,H+1)==(w-z)){a(r.acc,H+5,L,N,K,C,I,w)}t=16+w}else{r.Debug("Unknown Encoding: "+B);return r.Stop()}}}if(--r.state==100){r.state=4;if(r.frameRateDelay==0){h()}else{setTimeout(h,r.frameRateDelay)}}}}}}}}if(t==0){return}r.acc=r.acc.substring(t)}};function a(w,E,M,N,L,A,I,z){var J=w.charCodeAt(E++),C,K,H,D={},F=0,G=0,B;if(J==0){if(r.bpp==2){for(B=0;B<I;B++){j(w.charCodeAt(E++)+(w.charCodeAt(E++)<<8),B)}}else{for(B=0;B<I;B++){l(w.charCodeAt(E++),B)}}g(r.spare,M,N)}else{if(J==1){K=w.charCodeAt(E++)+((r.bpp==2)?(w.charCodeAt(E++)<<8):0);r.canvas.fillStyle="rgb("+((r.bpp==1)?((K&224)+","+((K&28)<<3)+","+b((K&3)<<6)):(((K>>8)&248)+","+((K>>3)&252)+","+((K&31)<<3)))+")";r.canvas.fillRect(M,N,L,A)}else{if(J>1&&J<17){var u=4,t=15;if(r.bpp==2){for(B=0;B<J;B++){D[B]=w.charCodeAt(E++)+(w.charCodeAt(E++)<<8)}if(J==2){u=1;t=1}else{if(J<=4){u=2;t=3}}while(F<I&&E<w.length){K=w.charCodeAt(E++);for(B=(8-u);B>=0;B-=u){j(D[(K>>B)&t],F++)}}}else{for(B=0;B<J;B++){D[B]=w.charCodeAt(E++)}if(J==2){u=1;t=1}else{if(J<=4){u=2;t=3}}while(F<I&&E<w.length){K=w.charCodeAt(E++);for(B=(8-u);B>=0;B-=u){l(D[(K>>B)&t],F++)}}}g(r.spare,M,N)}else{if(J==128){if(r.bpp==2){while(F<I&&E<w.length){K=w.charCodeAt(E++)+(w.charCodeAt(E++)<<8);G=1;do{G+=(H=w.charCodeAt(E++))}while(H==255);if(r.rotation==0){k(K,F,G);F+=G}else{while(--G>=0){j(K,F++)}}}}else{while(F<I&&E<w.length){K=w.charCodeAt(E++);G=1;do{G+=(H=w.charCodeAt(E++))}while(H==255);if(r.rotation==0){m(K,F,G);F+=G}else{while(--G>=0){l(K,F++)}}}}g(r.spare,M,N)}else{if(J>129){if(r.bpp==2){for(B=0;B<(J-128);B++){D[B]=w.charCodeAt(E++)+(w.charCodeAt(E++)<<8)}}else{for(B=0;B<(J-128);B++){D[B]=w.charCodeAt(E++)}}while(F<I&&E<w.length){G=1;C=w.charCodeAt(E++);K=D[C%128];if(C>127){do{G+=(H=w.charCodeAt(E++))}while(H==255)}if(r.rotation==0){if(r.bpp==2){k(K,F,G);F+=G}else{m(K,F,G);F+=G}}else{if(r.bpp==2){while(--G>=0){j(K,F++)}}else{while(--G>=0){l(K,F++)}}}}g(r.spare,M,N)}}}}}}r.hold=function(t){if(r.holding==t){return}r.holding=t;r.canvas.fillStyle="#000000";r.canvas.fillRect(0,0,r.width,r.height);if(r.holding==false){if((r.canvas.canvas.width!=r.width)||(r.canvas.canvas.height!=r.height)){r.canvas.canvas.width=r.width;r.canvas.canvas.height=r.height;if(r.onScreenSizeChange!=null){r.onScreenSizeChange(r,r.ScreenWidth,r.ScreenHeight)}}r.Send(String.fromCharCode(3,0,0,0,0,0)+ShortToStr(r.width)+ShortToStr(r.height))}else{r.UnGrabMouseInput();r.UnGrabKeyInput()}};function g(t,u,v){if(r.holding==true){return}r.canvas.putImageData(t,u,v)}function l(w,t){var u=t<<2;r.spare.data[u]=w&224;r.spare.data[u+1]=(w&28)<<3;r.spare.data[u+2]=b((w&3)<<6)}function j(w,t){var u=t<<2;r.spare.data[u]=(w>>8)&248;r.spare.data[u+1]=(w>>3)&252;r.spare.data[u+2]=(w&31)<<3}function m(A,w,z){var x=(w<<2),y=(A&224),u=((A&28)<<3),t=(b((A&3)<<6));while(--z>=0){r.spare.data[x]=y;r.spare.data[x+1]=u;r.spare.data[x+2]=t;x+=4}}function k(A,w,z){var x=(w<<2),y=((A>>8)&248),u=((A>>3)&252),t=((A&31)<<3);while(--z>=0){r.spare.data[x]=y;r.spare.data[x+1]=u;r.spare.data[x+2]=t;x+=4}}function b(t){return(t>127)?(t+32):t}function h(){if(r.holding==true){return}r.send(String.fromCharCode(3,1,0,0,0,0)+ShortToStr(r.rwidth)+ShortToStr(r.rheight))}r.Start=function(){r.state=0;r.acc="";r.ZRLEfirst=1;r.onKvmDataPending=[];r.onKvmDataAck=-1;r.kvmDataSupported=false;for(var t in r.sparecache){delete r.sparecache[t]}};r.Stop=function(){r.UnGrabMouseInput();r.UnGrabKeyInput();r.parent.Stop()};r.send=function(t){r.parent.send(t)};var o={Pause:19,CapsLock:20,Space:32,Quote:39,Minus:45,NumpadMultiply:42,NumpadAdd:43,PrintScreen:44,Comma:44,NumpadSubtract:45,NumpadDecimal:46,Period:46,Slash:47,NumpadDivide:47,Semicolon:59,Equal:61,OSLeft:91,BracketLeft:91,OSRight:91,Backslash:92,BracketRight:93,ContextMenu:93,Backquote:96,NumLock:144,ScrollLock:145,Backspace:65288,Tab:65289,Enter:65293,NumpadEnter:65293,Escape:65307,Delete:65535,Home:65360,PageUp:65365,PageDown:65366,ArrowLeft:65361,ArrowUp:65362,ArrowRight:65363,ArrowDown:65364,End:65367,Insert:65379,F1:65470,F2:65471,F3:65472,F4:65473,F5:65474,F6:65475,F7:65476,F8:65477,F9:65478,F10:65479,F11:65480,F12:65481,ShiftLeft:65505,ShiftRight:65506,ControlLeft:65507,ControlRight:65508,AltLeft:65513,AltRight:65514,MetaLeft:65511,MetaRight:65512};function n(t){if(t.code.startsWith("Key")&&t.code.length==4){return t.code.charCodeAt(3)+((t.shiftKey==false)?32:0)}if(t.code.startsWith("Digit")&&t.code.length==6){return t.code.charCodeAt(5)}if(t.code.startsWith("Numpad")&&t.code.length==7){return t.code.charCodeAt(6)}return o[t.code]}function c(t,u){if(!u){u=window.event}if(u.code&&(r.localKeyMap==false)){var v=n(u);if(v!=null){r.sendkey(v,t)}}else{var v=u.keyCode,w=v;if(u.shiftKey==false&&v>=65&&v<=90){w=v+32}if(v>=112&&v<=124){w=v+65358}if(v==8){w=65288}if(v==9){w=65289}if(v==13){w=65293}if(v==16){w=65505}if(v==17){w=65507}if(v==18){w=65513}if(v==27){w=65307}if(v==33){w=65365}if(v==34){w=65366}if(v==35){w=65367}if(v==36){w=65360}if(v==37){w=65361}if(v==38){w=65362}if(v==39){w=65363}if(v==40){w=65364}if(v==45){w=65379}if(v==46){w=65535}if(v>=96&&v<=105){w=v-48}if(v==106){w=42}if(v==107){w=43}if(v==109){w=45}if(v==110){w=46}if(v==111){w=47}if(v==186){w=59}if(v==187){w=61}if(v==188){w=44}if(v==189){w=45}if(v==190){w=46}if(v==191){w=47}if(v==192){w=96}if(v==219){w=91}if(v==220){w=92}if(v==221){w=93}if(v==222){w=39}r.sendkey(w,t)}return r.haltEvent(u)}r.sendkey=function(v,t){if(typeof v=="object"){for(var u in v){r.sendkey(v[u][0],v[u][1])}}else{r.send(String.fromCharCode(4,t,0,0)+IntToStr(v))}};function q(t){if(t.length<8){return 0}var v=ReadInt(r.acc,4)+8;if(t.length<v){return 0}if(r.onKvmData!=null){var u=t.substring(8,v);if((u.length>=16)&&(u.substring(0,15)=="\0KvmDataChannel")){if(r.kvmDataSupported==false){r.kvmDataSupported=true;console.log("KVM Data Channel Supported.")}if(((r.onKvmDataAck==-1)&&(u.length==16))||(u.charCodeAt(15)!=0)){r.onKvmDataAck=true}if(u.length>=16){r.onKvmData(u.substring(16))}if((r.onKvmDataAck==true)&&(r.onKvmDataPending.length>0)){r.sendKvmData(r.onKvmDataPending.shift())}}}return v}r.sendKvmData=function(t){if(r.onKvmDataAck!==true){r.onKvmDataPending.push(t)}else{t="\0KvmDataChannel\0"+t;r.send(String.fromCharCode(6,0,0,0)+IntToStr(t.length)+t);r.onKvmDataAck=false}};r.sendKeepAlive=function(){if(r.lastKeepAlive<Date.now()-5000){r.lastKeepAlive=Date.now();r.send(String.fromCharCode(6,0,0,0)+IntToStr(16)+"\0KvmDataChannel\0")}};r.SendCtrlAltDelMsg=function(){r.sendcad()};r.sendcad=function(){r.sendkey([[65507,1],[65513,1],[65535,1],[65535,0],[65513,0],[65507,0]])};var e=false;var d=false;r.GrabMouseInput=function(){if(e==true){return}var t=r.canvas.canvas;t.onmouseup=r.mouseup;t.onmousedown=r.mousedown;t.onmousemove=r.mousemove;e=true};r.UnGrabMouseInput=function(){if(e==false){return}var t=r.canvas.canvas;t.onmousemove=null;t.onmouseup=null;t.onmousedown=null;e=false};r.GrabKeyInput=function(){if(d==true){return}document.onkeyup=r.handleKeyUp;document.onkeydown=r.handleKeyDown;document.onkeypress=r.handleKeys;d=true};r.UnGrabKeyInput=function(){if(d==false){return}document.onkeyup=null;document.onkeydown=null;document.onkeypress=null;d=false};r.handleKeys=function(t){return r.haltEvent(t)};r.handleKeyUp=function(t){return c(0,t)};r.handleKeyDown=function(t){return c(1,t)};r.haltEvent=function(t){if(t.preventDefault){t.preventDefault()}if(t.stopPropagation){t.stopPropagation()}return false};r.mousedblclick=function(t){};r.mousedown=function(t){r.buttonmask|=(1<<t.button);return r.mousemove(t,1)};r.mouseup=function(t){r.buttonmask&=(65535-(1<<t.button));return r.mousemove(t,1)};r.mousemove=function(t,u){if(r.state<4){return true}var w=(r.canvas.canvas.height/Q(r.canvasid).offsetHeight);var x=(r.canvas.canvas.width/Q(r.canvasid).offsetWidth);var v=r.getPositionOfControl(Q(r.canvasid));r.mx=((event.pageX-v[0])*x);r.my=((event.pageY-v[1])*w);if(event.addx){r.mx+=event.addx}if(event.addy){r.my+=event.addy}if(u==1){r.send(String.fromCharCode(5,r.buttonmask)+ShortToStr(r.mx)+ShortToStr(r.my));if(r.mNagleTimer!=null){clearTimeout(r.mNagleTimer);r.mNagleTimer=null}}else{if(r.mNagleTimer==null){r.mNagleTimer=setTimeout(function(){r.send(String.fromCharCode(5,r.buttonmask)+ShortToStr(r.mx)+ShortToStr(r.my));r.mNagleTimer=null},50)}}return r.haltEvent(t)};r.getPositionOfControl=function(t){var u=Array(2);u[0]=u[1]=0;while(t){u[0]+=t.offsetLeft;u[1]+=t.offsetTop;t=t.offsetParent}return u};return r};var CreateAmtRemoteTerminal=function(J,L){var K={};K.DivId=J;K.DivElement=document.getElementById(J);K.protocol=1;K.fxEmulation=0;K.lineFeed="\r\n";K.debugmode=0;K.width=80;K.height=25;K.heightLock=0;var x=21;var y=13;var s=["000000","BB0000","00BB00","BBBB00","0000BB","BB00BB","00BBBB","BBBBBB","555555","FF5555","55FF55","FFFF55","5555FF","FF55FF","55FFFF","FFFFFF"];var v=0;var u=7;var t=0;var z=true;var E=0;var F=0;var B=0;var C=0;var D=0;var h=[];var k=0;var j=0;var q=[];var G=[];var I=1;var H=2;var b=false;var c=true;var r;var a=false;var M=[];K.title=null;K.onTitleChange=null;K.Start=function(){};K.Init=function(O,N){K.width=O?O:80;K.height=N?N:25;for(var R=0;R<K.height;R++){G[R]=[];q[R]=[];for(var P=0;P<K.width;P++){G[R][P]=" ";q[R][P]=(7<<6)}}K.TermInit();K.TermDraw()};K.xxStateChange=function(N){if((N==3)&&(L!=null)&&(L.xterm==true)){K.TermSendKeys("stty rows "+K.height+" cols "+K.width+"\nclear\n")}};K.ProcessData=function(N){if(K.debugmode==2){console.log("TRecv("+N.length+"): "+rstr2hex(N))}if(K.capture!=null){K.capture+=N}o(N);K.TermDraw()};function o(O){for(var N=0;N<O.length;N++){n(String.fromCharCode(O.charCodeAt(N)),O.charCodeAt(N))}}function n(N,P){switch(D){case 0:switch(P){case 27:D=1;h=[];k=0;j=0;break;default:m(N);break}break;case 1:switch(N){case"[":D=2;break;case"(":D=4;break;case")":D=5;break;case"]":D=6;break;case"=":a=true;D=0;break;case">":a=false;D=0;break;case"7":B=E;C=F;D=0;break;case"8":E=B;F=C;D=0;break;case"M":var R=1;for(var S=r[1];S>=r[0]+R;S--){for(var T=0;T<K.width;T++){G[S][T]=G[S-R][T];q[S][T]=q[S-R][T]}}for(var S=r[0]+R-1;S>r[0]-1;S--){for(var T=0;T<K.width;T++){G[S][T]=" ";q[S][T]=(7<<6)}}D=0;break;default:console.log("unknown terminal short code",N);D=0;break}break;case 2:if(N>="0"&&N<="9"){if(!h[k]){h[k]=(N-"0")}else{h[k]=((h[k]*10)+(N-"0"))}break}else{if(N==";"){k++;break}else{if(N=="?"){j=1;break}else{if(!h[0]){h[0]=0}l(N,h,k+1,j);D=0}}}break;case 4:D=0;break;case 5:D=0;break;case 6:var O=N.charCodeAt(0);if(N==";"){k++}else{if(O==7){p(h);D=0}else{if(!h[k]){h[k]=N}else{h[k]+=N}}}break}}function p(N){if(N.length==0){return}var O=parseInt(N[0]);if((O==0||O==2)&&(N.length>1)&&(N[1]!="?")){if(K.onTitleChange){K.onTitleChange(K,K.title=N[1])}}}function l(R,N,O,U){if(U==1){switch(R){case"l":if(N[0]==25){c=false}break;case"h":if(N[0]==25){c=true}break}}else{if(U==0){var S;switch(R){case"c":K.TermResetScreen();break;case"A":if(O==1){if(N[0]==0){F--}else{F-=N[0]}if(F<0){F=0}}break;case"B":if(O==1){if(N[0]==0){F++}else{F+=N[0]}if(F>K.height){F=K.height}}break;case"C":if(O==1){if(N[0]==0){E++}else{E+=N[0]}if(E>K.width){E=K.width}}break;case"D":if(O==1){if(N[0]==0){E--}else{E-=N[0]}if(E<0){E=0}}break;case"d":if(O==1){F=N[0]-1;if(F>K.height){F=K.height}if(F<0){F=0}}break;case"G":if(O==1){E=N[0]-1;if(E<0){E=0}if(E>(K.width-1)){E=(K.width-1)}}break;case"P":var V=1;if(O==1){V=N[0]}for(S=E;S<K.width-V;S++){G[F][S]=G[F][S+V];q[F][S]=q[F][S+V]}for(S=(K.width-V);S<K.width;S++){G[F][S]=" ";q[F][S]=(7<<6)}break;case"L":var T=1;if(O==1){T=N[0]}if(T==0){T=1}for(W=r[1];W>=F+T;W--){G[W]=G[W-T];q[W]=q[W-T]}for(W=F;W<F+T;W++){G[W]=[];q[W]=[];for(V=0;V<K.width;V++){G[W][V]=" ";q[W][V]=(7<<6)}}break;case"J":if(O==1&&N[0]==2){K.TermClear((t<<12)+(u<<6));E=0;F=0;M=[]}else{if(O==0||O==1&&N[0]==0){e();for(S=F+1;S<K.height;S++){g(S)}}else{if(O==1&&N[0]==1){e();for(S=0;S<F-1;S++){g(S)}}}}break;case"H":if(O==2){if(N[0]<1){N[0]=1}if(N[1]<1){N[1]=1}if(N[0]>K.height){N[0]=K.height}if(N[1]>K.width){N[1]=K.width}F=N[0]-1;E=N[1]-1}else{F=0;E=0}break;case"m":for(S=0;S<O;S++){if(!N[S]||N[S]==0){t=0;u=7;v=0}else{if(N[S]==1){if(u<8){u+=8}}else{if(N[S]==2||N[S]==22){if(u>=8){u-=8}}else{if(N[S]==7){v=2}else{if(N[S]==27){v=0}else{if(N[S]>=30&&N[S]<=37){var P=(u>=8);u=(N[S]-30);if(P&&u<=8){u+=8}}else{if(N[S]>=40&&N[S]<=47){t=(N[S]-40)}else{if(N[S]>=90&&N[S]<=99){u=(N[S]-82)}else{if(N[S]>=100&&N[S]<=109){t=(N[S]-92)}}}}}}}}}}break;case"K":if(O==0||(O==1&&(!N[0]||N[0]==0))){e()}else{if(O==1){if(N[0]==1){d()}else{if(N[0]==2){g(F)}}}}break;case"h":z=true;break;case"l":z=false;break;case"r":if(O==2){r=[N[0]-1,N[1]-1]}if(r[0]<0){r[0]=0}if(r[0]>(K.height-1)){r[0]=(K.height-1)}if(r[1]<0){r[1]=0}if(r[1]>(K.height-1)){r[1]=(K.height-1)}if(r[0]>r[1]){r[0]=r[1]}break;case"S":var V=1;if(O==1){V=N[0]}for(var W=r[0];W<=r[1]-V;W++){for(var X=0;X<K.width;X++){G[W][X]=G[W+V][X];q[W][X]=q[W+V][X]}}for(var W=r[1]-V+1;W<r[1];W++){for(var X=0;X<K.width;X++){G[W][X]=" ";q[W][X]=(7<<6)}}break;case"M":var V=1;if(O==1){V=N[0]}for(var W=F;W<=r[1]-V;W++){for(var X=0;X<K.width;X++){G[W][X]=G[W+V][X];q[W][X]=q[W+V][X]}}for(var W=r[1]-V+1;W<r[1];W++){for(var X=0;X<K.width;X++){G[W][X]=" ";q[W][X]=(7<<6)}}break;case"T":var V=1;if(O==1){V=N[0]}for(var W=r[1];W>r[0]+V;W--){for(var X=0;X<K.width;X++){G[W][X]=G[W-V][X];q[W][X]=q[W-V][X]}}for(var W=r[0]+V;W>r[0];W--){for(var X=0;X<K.width;X++){G[W][X]=" ";q[W][X]=(7<<6)}}break;case"X":var V=1;if(O==1){V=N[0]}while((V>0)&&(E>0)){G[F][E]=" ";E--;V--}break;default:console.log("unknown terminal code",R,N,U);break}}}}K.ProcessVt100String=function(O){for(var N=0;N<O.length;N++){m(String.fromCharCode(O.charCodeAt(N)))}};function m(N){if(N=="\0"||N.charCodeAt()==7){return}var O=N.charCodeAt();switch(O){case 16:N=" ";break;case 24:N="?";break;case 25:N="?";break}if(E>K.width){E=K.width}if(F>(K.height-1)){F=(K.height-1)}switch(N){case"\b":if(E>0){E--;if(b){w(" ")}}break;case"\t":var P=8-(E%8);for(var R=0;R<P;R++){m(" ")}break;case"\n":F++;if(F>r[1]){K.recordLineTobackBuffer(0);A(1);F=r[1]}if(K.lineFeed="\r"){E=0}break;case"\r":E=0;break;default:if(E>=K.width){E=0;if(z){F++}if(F>=(K.height-1)){A(1);F=(K.height-1)}}w(N);E++;break}}function w(N){G[F][E]=N;q[F][E]=(u<<6)+(t<<12)+v}K.TermClear=function(N){for(var P=0;P<K.height;P++){for(var O=0;O<K.width;O++){G[P][O]=" ";q[P][O]=N}}M=[]};K.TermResetScreen=function(){v=0;u=7;t=0;z=c=true;E=F=0;b=false;r=[0,(K.height-1)];a=false;K.TermClear(7<<6)};function e(){var N=(u<<6)+(t<<12)+v;for(var O=E;O<K.width;O++){G[F][O]=" ";q[F][O]=N}}function d(){var N=(u<<6)+(t<<12)+v;for(var O=0;O<E;O++){G[F][O]=" ";q[F][O]=N}}function g(N){var O=(u<<6)+(t<<12)+v;for(var P=0;P<K.width;P++){G[N][P]=" ";q[N][P]=O}}K.TermSendKeys=function(N){if(K.debugmode==2){console.log("TSend("+N.length+"): "+rstr2hex(N),N)}K.parent.send(N)};K.TermSendKey=function(N){if(K.debugmode==2){console.log("TSend(1): "+rstr2hex(String.fromCharCode(N)),N)}K.parent.send(String.fromCharCode(N))};function A(N){var O,P;for(P=r[0];P<=r[1]-N;P++){G[P]=G[P+N];q[P]=q[P+N]}for(P=r[1]-N+1;P<=r[1];P++){G[P]=[];q[P]=[];for(O=0;O<K.width;O++){G[P][O]=" ";q[P][O]=(7<<6)}}}K.TermHandleKeys=function(N){if(!N.ctrlKey){if(N.which==127){K.TermSendKey(8)}else{if(N.which==13){K.TermSendKeys(K.lineFeed)}else{if(N.which!=0){K.TermSendKey(N.which)}}}return false}if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}};K.TermHandleKeyUp=function(N){if((N.which!=8)&&(N.which!=32)&&(N.which!=9)){return true}if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}return false};K.TermHandleKeyDown=function(N){if((N.which>=65)&&(N.which<=90)&&(N.ctrlKey==true)){K.TermSendKey(N.which-64);if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}return}if(N.which==27){K.TermSendKeys(String.fromCharCode(27));return true}if(a==true){if(N.which==37){K.TermSendKeys(String.fromCharCode(27,79,68));return true}if(N.which==38){K.TermSendKeys(String.fromCharCode(27,79,65));return true}if(N.which==39){K.TermSendKeys(String.fromCharCode(27,79,67));return true}if(N.which==40){K.TermSendKeys(String.fromCharCode(27,79,66));return true}}else{if(N.which==37){K.TermSendKeys(String.fromCharCode(27,91,68));return true}if(N.which==38){K.TermSendKeys(String.fromCharCode(27,91,65));return true}if(N.which==39){K.TermSendKeys(String.fromCharCode(27,91,67));return true}if(N.which==40){K.TermSendKeys(String.fromCharCode(27,91,66));return true}}if(N.which==33){K.TermSendKeys(String.fromCharCode(27,91,53,126));return true}if(N.which==34){K.TermSendKeys(String.fromCharCode(27,91,54,126));return true}if(N.which==35){K.TermSendKeys(String.fromCharCode(27,91,70));return true}if(N.which==36){K.TermSendKeys(String.fromCharCode(27,91,72));return true}if(N.which==45){K.TermSendKeys(String.fromCharCode(27,91,50,126));return true}if(N.which==46){K.TermSendKeys(String.fromCharCode(27,91,51,126));return true}if(N.which==9){K.TermSendKeys("\t");if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}return true}if(N.which!=8&&N.which!=32&&N.which!=9){return true}K.TermSendKey(N.which);if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}return false};K.recordLineTobackBuffer=function(R){var O="",N="";var P=K.TermDrawLine(N,R,O);N=P[0];O=P[1];M.push(N+O+"<br>")};K.TermDrawLine=function(N,W,P){var R,O,S=1,U,V;for(var T=0;T<K.width;++T){R=q[W][T];if(E==T&&F==W&&c){R|=H}if(R!=S){N+=P;P="";U=6;V=12;if(R&H){U=12;V=6}N+='<span style="color:#'+s[(R>>U)&63]+";background-color:#"+s[(R>>V)&63];if(R&I){N+=";text-decoration:underline"}N+=';">';P="</span>"+P;S=R}O=G[W][T];switch(O){case"&":N+="&amp;";break;case"<":N+="&lt;";break;case">":N+="&gt;";break;case" ":N+="&nbsp;";break;default:N+=O;break}}return[N,P]};K.TermDraw=function(){var P="",O="";for(var S=0;S<K.height;++S){var R=K.TermDrawLine(O,S,P);O=R[0];P=R[1];if(S!=(K.height-1)){O+="<br>"}}if(M.length>800){M=M.slice(M.length-800)}var N=M.join("");K.DivElement.innerHTML="<font size='4'><b>"+N+O+P+"</b></font>";K.DivElement.scrollTop=K.DivElement.scrollHeight;if(K.heightLock==0){setTimeout(K.TermLockHeight,10)}};K.TermLockHeight=function(){K.heightLock=K.DivElement.clientHeight;K.DivElement.style.height=K.DivElement.parentNode.style.height=K.heightLock+"px";K.DivElement.style["overflow-y"]="scroll"};K.TermInit=function(){K.TermResetScreen()};K.heightLock=0;K.DivElement.style.height="";if((L!=null)&&(L.width!=null)&&(L.height!=null)){K.Init(L.width,L.height)}else{K.Init()}return K};var ZLIB=(ZLIB||{});if(typeof ZLIB.common_initialized==="undefined"){ZLIB.Z_NO_FLUSH=0;ZLIB.Z_PARTIAL_FLUSH=1;ZLIB.Z_SYNC_FLUSH=2;ZLIB.Z_FULL_FLUSH=3;ZLIB.Z_FINISH=4;ZLIB.Z_BLOCK=5;ZLIB.Z_TREES=6;ZLIB.Z_OK=0;ZLIB.Z_STREAM_END=1;ZLIB.Z_NEED_DICT=2;ZLIB.Z_ERRNO=(-1);ZLIB.Z_STREAM_ERROR=(-2);ZLIB.Z_DATA_ERROR=(-3);ZLIB.Z_MEM_ERROR=(-4);ZLIB.Z_BUF_ERROR=(-5);ZLIB.Z_VERSION_ERROR=(-6);ZLIB.Z_DEFLATED=8;ZLIB.z_stream=function(){this.next_in=0;this.avail_in=0;this.total_in=0;this.next_out=0;this.avail_out=0;this.total_out=0;this.msg=null;this.state=null;this.data_type=0;this.adler=0;this.input_data="";this.output_data="";this.error=0;this.checksum_function=null};ZLIB.gz_header=function(){this.text=0;this.time=0;this.xflags=0;this.os=255;this.extra=null;this.extra_len=0;this.extra_max=0;this.name=null;this.name_max=0;this.comment=null;this.comm_max=0;this.hcrc=0;this.done=0};ZLIB.common_initialized=true}if(typeof ZLIB==="undefined"){alert("ZLIB is not defined. SRC zlib.js before zlib-inflate.js")}(function(){var o=15;var G=0;var D=1;var am=2;var af=3;var A=4;var B=5;var ac=6;var j=7;var F=8;var q=9;var p=10;var an=11;var ao=12;var aj=13;var l=14;var k=15;var al=16;var W=17;var g=18;var S=19;var R=20;var T=21;var r=22;var s=23;var aa=24;var Y=25;var d=26;var V=27;var v=28;var a=29;var ab=30;var ak=31;var z=852;var y=592;var x=(z+y);var h=0;var X=1;var u=2;var N=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0];var O=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,203,69];var L=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0];var M=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];ZLIB.inflate_copyright=" inflate 1.2.6 Copyright 1995-2012 Mark Adler ";function K(aR,aV){var aM=15;var aU=aR.next;var at=(aV==u?aR.distbits:aR.lenbits);var aX=aR.work;var aH=aR.lens;var aI=(aV==u?aR.nlen:0);var aS=aR.codes;var au;if(aV==X){au=aR.nlen}else{if(aV==u){au=aR.ndist}else{au=19}}var aG;var aT;var aN,aL;var aQ;var aw;var ax;var aF;var aW;var aD;var aE;var aB;var aJ;var aK;var aC;var aO;var aq;var ar;var az;var aA;var ay;var av=new Array(aM+1);var aP=new Array(aM+1);for(aG=0;aG<=aM;aG++){av[aG]=0}for(aT=0;aT<au;aT++){av[aH[aI+aT]]++}aQ=at;for(aL=aM;aL>=1;aL--){if(av[aL]!=0){break}}if(aQ>aL){aQ=aL}if(aL==0){aC={op:64,bits:1,val:0};aS[aU++]=aC;aS[aU++]=aC;if(aV==u){aR.distbits=1}else{aR.lenbits=1}aR.next=aU;return 0}for(aN=1;aN<aL;aN++){if(av[aN]!=0){break}}if(aQ<aN){aQ=aN}aF=1;for(aG=1;aG<=aM;aG++){aF<<=1;aF-=av[aG];if(aF<0){return -1}}if(aF>0&&(aV==h||aL!=1)){aR.next=aU;return -1}aP[1]=0;for(aG=1;aG<aM;aG++){aP[aG+1]=aP[aG]+av[aG]}for(aT=0;aT<au;aT++){if(aH[aI+aT]!=0){aX[aP[aH[aI+aT]]++]=aT}}switch(aV){case h:aq=az=aX;ar=0;aA=0;ay=19;break;case X:aq=N;ar=-257;az=O;aA=-257;ay=256;break;default:aq=L;az=M;ar=0;aA=0;ay=-1}aD=0;aT=0;aG=aN;aO=aU;aw=aQ;ax=0;aJ=-1;aW=1<<aQ;aK=aW-1;if((aV==X&&aW>=z)||(aV==u&&aW>=y)){aR.next=aU;return 1}for(;;){aC={op:0,bits:aG-ax,val:0};if(aX[aT]<ay){aC.val=aX[aT]}else{if(aX[aT]>ay){aC.op=az[aA+aX[aT]];aC.val=aq[ar+aX[aT]]}else{aC.op=32+64}}aE=1<<(aG-ax);aB=1<<aw;aN=aB;do{aB-=aE;aS[aO+(aD>>>ax)+aB]=aC}while(aB!=0);aE=1<<(aG-1);while(aD&aE){aE>>>=1}if(aE!=0){aD&=aE-1;aD+=aE}else{aD=0}aT++;if(--(av[aG])==0){if(aG==aL){break}aG=aH[aI+aX[aT]]}if(aG>aQ&&(aD&aK)!=aJ){if(ax==0){ax=aQ}aO+=aN;aw=aG-ax;aF=(1<<aw);while(aw+ax<aL){aF-=av[aw+ax];if(aF<=0){break}aw++;aF<<=1}aW+=1<<aw;if((aV==X&&aW>=z)||(aV==u&&aW>=y)){aR.next=aU;return 1}aJ=aD&aK;aS[aU+aJ]={op:aw,bits:aQ,val:aO-aU}}}if(aD!=0){aS[aO+aD]={op:64,bits:aG-ax,val:0}}aR.next=aU+aW;if(aV==u){aR.distbits=aQ}else{aR.lenbits=aQ}return 0}function H(aN,aL){var aM;var aC;var aI;var aD;var aK;var aq;var ax;var aR;var aO;var aQ;var aP;var aB;var ar;var at;var aE;var au;var aH;var aw;var aA;var aJ;var aF;var av;var az=-1;var ay=-1;aM=aN.state;aC=aN.input_data;aI=aN.next_in;aD=aI+aN.avail_in-5;aK=aN.next_out;aq=aK-(aL-aN.avail_out);ax=aK+(aN.avail_out-257);aR=aM.wsize;aO=aM.whave;aQ=aM.wnext;aP=aM.window;aB=aM.hold;ar=aM.bits;at=aM.codes;aE=aM.lencode;au=aM.distcode;aH=(1<<aM.lenbits)-1;aw=(1<<aM.distbits)-1;loop:do{if(ar<15){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8;aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8}aA=at[aE+(aB&aH)];dolen:while(true){aJ=aA.bits;aB>>>=aJ;ar-=aJ;aJ=aA.op;if(aJ==0){aN.output_data+=String.fromCharCode(aA.val);aK++}else{if(aJ&16){aF=aA.val;aJ&=15;if(aJ){if(ar<aJ){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8}aF+=aB&((1<<aJ)-1);aB>>>=aJ;ar-=aJ}if(ar<15){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8;aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8}aA=at[au+(aB&aw)];dodist:while(true){aJ=aA.bits;aB>>>=aJ;ar-=aJ;aJ=aA.op;if(aJ&16){av=aA.val;aJ&=15;if(ar<aJ){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8;if(ar<aJ){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8}}av+=aB&((1<<aJ)-1);aB>>>=aJ;ar-=aJ;aJ=aK-aq;if(av>aJ){aJ=av-aJ;if(aJ>aO){if(aM.sane){aN.msg="invalid distance too far back";aM.mode=a;break loop}}az=0;ay=-1;if(aQ==0){az+=aR-aJ;if(aJ<aF){aF-=aJ;aN.output_data+=aP.substring(az,az+aJ);aK+=aJ;aJ=0;az=-1;ay=aK-av}}else{az+=aQ-aJ;if(aJ<aF){aF-=aJ;aN.output_data+=aP.substring(az,az+aJ);aK+=aJ;az=-1;ay=aK-av}}}else{az=-1;ay=aK-av}if(az>=0){aN.output_data+=aP.substring(az,az+aF);aK+=aF;az+=aF}else{var aG=aF;if(aG>aK-ay){aG=aK-ay}aN.output_data+=aN.output_data.substring(ay,ay+aG);aK+=aG;aF-=aG;ay+=aG;aK+=aF;while(aF>2){aN.output_data+=aN.output_data.charAt(ay++);aN.output_data+=aN.output_data.charAt(ay++);aN.output_data+=aN.output_data.charAt(ay++);aF-=3}if(aF){aN.output_data+=aN.output_data.charAt(ay++);if(aF>1){aN.output_data+=aN.output_data.charAt(ay++)}}}}else{if((aJ&64)==0){aA=at[au+(aA.val+(aB&((1<<aJ)-1)))];continue dodist}else{aN.msg="invalid distance code";aM.mode=a;break loop}}break dodist}}else{if((aJ&64)==0){aA=at[aE+(aA.val+(aB&((1<<aJ)-1)))];continue dolen}else{if(aJ&32){aM.mode=an;break loop}else{aN.msg="invalid literal/length code";aM.mode=a;break loop}}}}break dolen}}while(aI<aD&&aK<ax);aF=ar>>>3;aI-=aF;ar-=aF<<3;aB&=(1<<ar)-1;aN.next_in=aI;aN.next_out=aK;aN.avail_in=(aI<aD?5+(aD-aI):5-(aI-aD));aN.avail_out=(aK<ax?257+(ax-aK):257-(aK-ax));aM.hold=aB;aM.bits=ar}function ae(at){var ar;var aq=new Array(at);for(ar=0;ar<at;ar++){aq[ar]=0}return aq}function E(at,ar,aq){return(at&&(ar in at))?at[ar]:aq}function e(){return 0}function J(){var ar;this.mode=0;this.last=0;this.wrap=0;this.havedict=0;this.flags=0;this.dmax=0;this.check=0;this.total=0;this.head=null;this.wbits=0;this.wsize=0;this.whave=0;this.wnext=0;this.window=null;this.hold=0;this.bits=0;this.length=0;this.offset=0;this.extra=0;this.lencode=0;this.distcode=0;this.lenbits=0;this.distbits=0;this.ncode=0;this.nlen=0;this.ndist=0;this.have=0;this.next=0;this.lens=ae(320);this.work=ae(288);this.codes=new Array(x);var aq={op:0,bits:0,val:0};for(ar=0;ar<x;ar++){this.codes[ar]=aq}this.sane=0;this.back=0;this.was=0}ZLIB.inflateResetKeep=function(ar){var aq;if(!ar||!ar.state){return ZLIB.Z_STREAM_ERROR}aq=ar.state;ar.total_in=ar.total_out=aq.total=0;ar.msg=null;if(aq.wrap){ar.adler=aq.wrap&1}aq.mode=G;aq.last=0;aq.havedict=0;aq.dmax=32768;aq.head=null;aq.hold=0;aq.bits=0;aq.lencode=0;aq.distcode=0;aq.next=0;aq.sane=1;aq.back=-1;return ZLIB.Z_OK};ZLIB.inflateReset=function(ar,at){var au;var aq;if(!ar||!ar.state){return ZLIB.Z_STREAM_ERROR}aq=ar.state;if(typeof at==="undefined"){at=o}if(at<0){au=0;at=-at}else{au=(at>>>4)+1;if(at<48){at&=15}}if(au==1&&(typeof ZLIB.adler32==="function")){ar.checksum_function=ZLIB.adler32}else{if(au==2&&(typeof ZLIB.crc32==="function")){ar.checksum_function=ZLIB.crc32}else{ar.checksum_function=e}}if(at&&(at<8||at>15)){return ZLIB.Z_STREAM_ERROR}if(aq.window&&aq.wbits!=at){aq.window=null}aq.wrap=au;aq.wbits=at;aq.wsize=0;aq.whave=0;aq.wnext=0;return ZLIB.inflateResetKeep(ar)};ZLIB.inflateInit=function(ar){var aq=new ZLIB.z_stream();aq.state=new J();ZLIB.inflateReset(aq,ar);return aq};ZLIB.inflatePrime=function(at,aq,au){var ar;if(!at||!at.state){return ZLIB.Z_STREAM_ERROR}ar=at.state;if(aq<0){ar.hold=0;ar.bits=0;return ZLIB.Z_OK}if(aq>16||ar.bits+aq>32){return ZLIB.Z_STREAM_ERROR}au&=(1<<aq)-1;ar.hold+=au<<ar.bits;ar.bits+=aq;return ZLIB.Z_OK};var U=null;var t=null;function C(ar){var aq;if(!U){U=[{op:96,bits:7,val:0},{op:0,bits:8,val:80},{op:0,bits:8,val:16},{op:20,bits:8,val:115},{op:18,bits:7,val:31},{op:0,bits:8,val:112},{op:0,bits:8,val:48},{op:0,bits:9,val:192},{op:16,bits:7,val:10},{op:0,bits:8,val:96},{op:0,bits:8,val:32},{op:0,bits:9,val:160},{op:0,bits:8,val:0},{op:0,bits:8,val:128},{op:0,bits:8,val:64},{op:0,bits:9,val:224},{op:16,bits:7,val:6},{op:0,bits:8,val:88},{op:0,bits:8,val:24},{op:0,bits:9,val:144},{op:19,bits:7,val:59},{op:0,bits:8,val:120},{op:0,bits:8,val:56},{op:0,bits:9,val:208},{op:17,bits:7,val:17},{op:0,bits:8,val:104},{op:0,bits:8,val:40},{op:0,bits:9,val:176},{op:0,bits:8,val:8},{op:0,bits:8,val:136},{op:0,bits:8,val:72},{op:0,bits:9,val:240},{op:16,bits:7,val:4},{op:0,bits:8,val:84},{op:0,bits:8,val:20},{op:21,bits:8,val:227},{op:19,bits:7,val:43},{op:0,bits:8,val:116},{op:0,bits:8,val:52},{op:0,bits:9,val:200},{op:17,bits:7,val:13},{op:0,bits:8,val:100},{op:0,bits:8,val:36},{op:0,bits:9,val:168},{op:0,bits:8,val:4},{op:0,bits:8,val:132},{op:0,bits:8,val:68},{op:0,bits:9,val:232},{op:16,bits:7,val:8},{op:0,bits:8,val:92},{op:0,bits:8,val:28},{op:0,bits:9,val:152},{op:20,bits:7,val:83},{op:0,bits:8,val:124},{op:0,bits:8,val:60},{op:0,bits:9,val:216},{op:18,bits:7,val:23},{op:0,bits:8,val:108},{op:0,bits:8,val:44},{op:0,bits:9,val:184},{op:0,bits:8,val:12},{op:0,bits:8,val:140},{op:0,bits:8,val:76},{op:0,bits:9,val:248},{op:16,bits:7,val:3},{op:0,bits:8,val:82},{op:0,bits:8,val:18},{op:21,bits:8,val:163},{op:19,bits:7,val:35},{op:0,bits:8,val:114},{op:0,bits:8,val:50},{op:0,bits:9,val:196},{op:17,bits:7,val:11},{op:0,bits:8,val:98},{op:0,bits:8,val:34},{op:0,bits:9,val:164},{op:0,bits:8,val:2},{op:0,bits:8,val:130},{op:0,bits:8,val:66},{op:0,bits:9,val:228},{op:16,bits:7,val:7},{op:0,bits:8,val:90},{op:0,bits:8,val:26},{op:0,bits:9,val:148},{op:20,bits:7,val:67},{op:0,bits:8,val:122},{op:0,bits:8,val:58},{op:0,bits:9,val:212},{op:18,bits:7,val:19},{op:0,bits:8,val:106},{op:0,bits:8,val:42},{op:0,bits:9,val:180},{op:0,bits:8,val:10},{op:0,bits:8,val:138},{op:0,bits:8,val:74},{op:0,bits:9,val:244},{op:16,bits:7,val:5},{op:0,bits:8,val:86},{op:0,bits:8,val:22},{op:64,bits:8,val:0},{op:19,bits:7,val:51},{op:0,bits:8,val:118},{op:0,bits:8,val:54},{op:0,bits:9,val:204},{op:17,bits:7,val:15},{op:0,bits:8,val:102},{op:0,bits:8,val:38},{op:0,bits:9,val:172},{op:0,bits:8,val:6},{op:0,bits:8,val:134},{op:0,bits:8,val:70},{op:0,bits:9,val:236},{op:16,bits:7,val:9},{op:0,bits:8,val:94},{op:0,bits:8,val:30},{op:0,bits:9,val:156},{op:20,bits:7,val:99},{op:0,bits:8,val:126},{op:0,bits:8,val:62},{op:0,bits:9,val:220},{op:18,bits:7,val:27},{op:0,bits:8,val:110},{op:0,bits:8,val:46},{op:0,bits:9,val:188},{op:0,bits:8,val:14},{op:0,bits:8,val:142},{op:0,bits:8,val:78},{op:0,bits:9,val:252},{op:96,bits:7,val:0},{op:0,bits:8,val:81},{op:0,bits:8,val:17},{op:21,bits:8,val:131},{op:18,bits:7,val:31},{op:0,bits:8,val:113},{op:0,bits:8,val:49},{op:0,bits:9,val:194},{op:16,bits:7,val:10},{op:0,bits:8,val:97},{op:0,bits:8,val:33},{op:0,bits:9,val:162},{op:0,bits:8,val:1},{op:0,bits:8,val:129},{op:0,bits:8,val:65},{op:0,bits:9,val:226},{op:16,bits:7,val:6},{op:0,bits:8,val:89},{op:0,bits:8,val:25},{op:0,bits:9,val:146},{op:19,bits:7,val:59},{op:0,bits:8,val:121},{op:0,bits:8,val:57},{op:0,bits:9,val:210},{op:17,bits:7,val:17},{op:0,bits:8,val:105},{op:0,bits:8,val:41},{op:0,bits:9,val:178},{op:0,bits:8,val:9},{op:0,bits:8,val:137},{op:0,bits:8,val:73},{op:0,bits:9,val:242},{op:16,bits:7,val:4},{op:0,bits:8,val:85},{op:0,bits:8,val:21},{op:16,bits:8,val:258},{op:19,bits:7,val:43},{op:0,bits:8,val:117},{op:0,bits:8,val:53},{op:0,bits:9,val:202},{op:17,bits:7,val:13},{op:0,bits:8,val:101},{op:0,bits:8,val:37},{op:0,bits:9,val:170},{op:0,bits:8,val:5},{op:0,bits:8,val:133},{op:0,bits:8,val:69},{op:0,bits:9,val:234},{op:16,bits:7,val:8},{op:0,bits:8,val:93},{op:0,bits:8,val:29},{op:0,bits:9,val:154},{op:20,bits:7,val:83},{op:0,bits:8,val:125},{op:0,bits:8,val:61},{op:0,bits:9,val:218},{op:18,bits:7,val:23},{op:0,bits:8,val:109},{op:0,bits:8,val:45},{op:0,bits:9,val:186},{op:0,bits:8,val:13},{op:0,bits:8,val:141},{op:0,bits:8,val:77},{op:0,bits:9,val:250},{op:16,bits:7,val:3},{op:0,bits:8,val:83},{op:0,bits:8,val:19},{op:21,bits:8,val:195},{op:19,bits:7,val:35},{op:0,bits:8,val:115},{op:0,bits:8,val:51},{op:0,bits:9,val:198},{op:17,bits:7,val:11},{op:0,bits:8,val:99},{op:0,bits:8,val:35},{op:0,bits:9,val:166},{op:0,bits:8,val:3},{op:0,bits:8,val:131},{op:0,bits:8,val:67},{op:0,bits:9,val:230},{op:16,bits:7,val:7},{op:0,bits:8,val:91},{op:0,bits:8,val:27},{op:0,bits:9,val:150},{op:20,bits:7,val:67},{op:0,bits:8,val:123},{op:0,bits:8,val:59},{op:0,bits:9,val:214},{op:18,bits:7,val:19},{op:0,bits:8,val:107},{op:0,bits:8,val:43},{op:0,bits:9,val:182},{op:0,bits:8,val:11},{op:0,bits:8,val:139},{op:0,bits:8,val:75},{op:0,bits:9,val:246},{op:16,bits:7,val:5},{op:0,bits:8,val:87},{op:0,bits:8,val:23},{op:64,bits:8,val:0},{op:19,bits:7,val:51},{op:0,bits:8,val:119},{op:0,bits:8,val:55},{op:0,bits:9,val:206},{op:17,bits:7,val:15},{op:0,bits:8,val:103},{op:0,bits:8,val:39},{op:0,bits:9,val:174},{op:0,bits:8,val:7},{op:0,bits:8,val:135},{op:0,bits:8,val:71},{op:0,bits:9,val:238},{op:16,bits:7,val:9},{op:0,bits:8,val:95},{op:0,bits:8,val:31},{op:0,bits:9,val:158},{op:20,bits:7,val:99},{op:0,bits:8,val:127},{op:0,bits:8,val:63},{op:0,bits:9,val:222},{op:18,bits:7,val:27},{op:0,bits:8,val:111},{op:0,bits:8,val:47},{op:0,bits:9,val:190},{op:0,bits:8,val:15},{op:0,bits:8,val:143},{op:0,bits:8,val:79},{op:0,bits:9,val:254},{op:96,bits:7,val:0},{op:0,bits:8,val:80},{op:0,bits:8,val:16},{op:20,bits:8,val:115},{op:18,bits:7,val:31},{op:0,bits:8,val:112},{op:0,bits:8,val:48},{op:0,bits:9,val:193},{op:16,bits:7,val:10},{op:0,bits:8,val:96},{op:0,bits:8,val:32},{op:0,bits:9,val:161},{op:0,bits:8,val:0},{op:0,bits:8,val:128},{op:0,bits:8,val:64},{op:0,bits:9,val:225},{op:16,bits:7,val:6},{op:0,bits:8,val:88},{op:0,bits:8,val:24},{op:0,bits:9,val:145},{op:19,bits:7,val:59},{op:0,bits:8,val:120},{op:0,bits:8,val:56},{op:0,bits:9,val:209},{op:17,bits:7,val:17},{op:0,bits:8,val:104},{op:0,bits:8,val:40},{op:0,bits:9,val:177},{op:0,bits:8,val:8},{op:0,bits:8,val:136},{op:0,bits:8,val:72},{op:0,bits:9,val:241},{op:16,bits:7,val:4},{op:0,bits:8,val:84},{op:0,bits:8,val:20},{op:21,bits:8,val:227},{op:19,bits:7,val:43},{op:0,bits:8,val:116},{op:0,bits:8,val:52},{op:0,bits:9,val:201},{op:17,bits:7,val:13},{op:0,bits:8,val:100},{op:0,bits:8,val:36},{op:0,bits:9,val:169},{op:0,bits:8,val:4},{op:0,bits:8,val:132},{op:0,bits:8,val:68},{op:0,bits:9,val:233},{op:16,bits:7,val:8},{op:0,bits:8,val:92},{op:0,bits:8,val:28},{op:0,bits:9,val:153},{op:20,bits:7,val:83},{op:0,bits:8,val:124},{op:0,bits:8,val:60},{op:0,bits:9,val:217},{op:18,bits:7,val:23},{op:0,bits:8,val:108},{op:0,bits:8,val:44},{op:0,bits:9,val:185},{op:0,bits:8,val:12},{op:0,bits:8,val:140},{op:0,bits:8,val:76},{op:0,bits:9,val:249},{op:16,bits:7,val:3},{op:0,bits:8,val:82},{op:0,bits:8,val:18},{op:21,bits:8,val:163},{op:19,bits:7,val:35},{op:0,bits:8,val:114},{op:0,bits:8,val:50},{op:0,bits:9,val:197},{op:17,bits:7,val:11},{op:0,bits:8,val:98},{op:0,bits:8,val:34},{op:0,bits:9,val:165},{op:0,bits:8,val:2},{op:0,bits:8,val:130},{op:0,bits:8,val:66},{op:0,bits:9,val:229},{op:16,bits:7,val:7},{op:0,bits:8,val:90},{op:0,bits:8,val:26},{op:0,bits:9,val:149},{op:20,bits:7,val:67},{op:0,bits:8,val:122},{op:0,bits:8,val:58},{op:0,bits:9,val:213},{op:18,bits:7,val:19},{op:0,bits:8,val:106},{op:0,bits:8,val:42},{op:0,bits:9,val:181},{op:0,bits:8,val:10},{op:0,bits:8,val:138},{op:0,bits:8,val:74},{op:0,bits:9,val:245},{op:16,bits:7,val:5},{op:0,bits:8,val:86},{op:0,bits:8,val:22},{op:64,bits:8,val:0},{op:19,bits:7,val:51},{op:0,bits:8,val:118},{op:0,bits:8,val:54},{op:0,bits:9,val:205},{op:17,bits:7,val:15},{op:0,bits:8,val:102},{op:0,bits:8,val:38},{op:0,bits:9,val:173},{op:0,bits:8,val:6},{op:0,bits:8,val:134},{op:0,bits:8,val:70},{op:0,bits:9,val:237},{op:16,bits:7,val:9},{op:0,bits:8,val:94},{op:0,bits:8,val:30},{op:0,bits:9,val:157},{op:20,bits:7,val:99},{op:0,bits:8,val:126},{op:0,bits:8,val:62},{op:0,bits:9,val:221},{op:18,bits:7,val:27},{op:0,bits:8,val:110},{op:0,bits:8,val:46},{op:0,bits:9,val:189},{op:0,bits:8,val:14},{op:0,bits:8,val:142},{op:0,bits:8,val:78},{op:0,bits:9,val:253},{op:96,bits:7,val:0},{op:0,bits:8,val:81},{op:0,bits:8,val:17},{op:21,bits:8,val:131},{op:18,bits:7,val:31},{op:0,bits:8,val:113},{op:0,bits:8,val:49},{op:0,bits:9,val:195},{op:16,bits:7,val:10},{op:0,bits:8,val:97},{op:0,bits:8,val:33},{op:0,bits:9,val:163},{op:0,bits:8,val:1},{op:0,bits:8,val:129},{op:0,bits:8,val:65},{op:0,bits:9,val:227},{op:16,bits:7,val:6},{op:0,bits:8,val:89},{op:0,bits:8,val:25},{op:0,bits:9,val:147},{op:19,bits:7,val:59},{op:0,bits:8,val:121},{op:0,bits:8,val:57},{op:0,bits:9,val:211},{op:17,bits:7,val:17},{op:0,bits:8,val:105},{op:0,bits:8,val:41},{op:0,bits:9,val:179},{op:0,bits:8,val:9},{op:0,bits:8,val:137},{op:0,bits:8,val:73},{op:0,bits:9,val:243},{op:16,bits:7,val:4},{op:0,bits:8,val:85},{op:0,bits:8,val:21},{op:16,bits:8,val:258},{op:19,bits:7,val:43},{op:0,bits:8,val:117},{op:0,bits:8,val:53},{op:0,bits:9,val:203},{op:17,bits:7,val:13},{op:0,bits:8,val:101},{op:0,bits:8,val:37},{op:0,bits:9,val:171},{op:0,bits:8,val:5},{op:0,bits:8,val:133},{op:0,bits:8,val:69},{op:0,bits:9,val:235},{op:16,bits:7,val:8},{op:0,bits:8,val:93},{op:0,bits:8,val:29},{op:0,bits:9,val:155},{op:20,bits:7,val:83},{op:0,bits:8,val:125},{op:0,bits:8,val:61},{op:0,bits:9,val:219},{op:18,bits:7,val:23},{op:0,bits:8,val:109},{op:0,bits:8,val:45},{op:0,bits:9,val:187},{op:0,bits:8,val:13},{op:0,bits:8,val:141},{op:0,bits:8,val:77},{op:0,bits:9,val:251},{op:16,bits:7,val:3},{op:0,bits:8,val:83},{op:0,bits:8,val:19},{op:21,bits:8,val:195},{op:19,bits:7,val:35},{op:0,bits:8,val:115},{op:0,bits:8,val:51},{op:0,bits:9,val:199},{op:17,bits:7,val:11},{op:0,bits:8,val:99},{op:0,bits:8,val:35},{op:0,bits:9,val:167},{op:0,bits:8,val:3},{op:0,bits:8,val:131},{op:0,bits:8,val:67},{op:0,bits:9,val:231},{op:16,bits:7,val:7},{op:0,bits:8,val:91},{op:0,bits:8,val:27},{op:0,bits:9,val:151},{op:20,bits:7,val:67},{op:0,bits:8,val:123},{op:0,bits:8,val:59},{op:0,bits:9,val:215},{op:18,bits:7,val:19},{op:0,bits:8,val:107},{op:0,bits:8,val:43},{op:0,bits:9,val:183},{op:0,bits:8,val:11},{op:0,bits:8,val:139},{op:0,bits:8,val:75},{op:0,bits:9,val:247},{op:16,bits:7,val:5},{op:0,bits:8,val:87},{op:0,bits:8,val:23},{op:64,bits:8,val:0},{op:19,bits:7,val:51},{op:0,bits:8,val:119},{op:0,bits:8,val:55},{op:0,bits:9,val:207},{op:17,bits:7,val:15},{op:0,bits:8,val:103},{op:0,bits:8,val:39},{op:0,bits:9,val:175},{op:0,bits:8,val:7},{op:0,bits:8,val:135},{op:0,bits:8,val:71},{op:0,bits:9,val:239},{op:16,bits:7,val:9},{op:0,bits:8,val:95},{op:0,bits:8,val:31},{op:0,bits:9,val:159},{op:20,bits:7,val:99},{op:0,bits:8,val:127},{op:0,bits:8,val:63},{op:0,bits:9,val:223},{op:18,bits:7,val:27},{op:0,bits:8,val:111},{op:0,bits:8,val:47},{op:0,bits:9,val:191},{op:0,bits:8,val:15},{op:0,bits:8,val:143},{op:0,bits:8,val:79},{op:0,bits:9,val:255}]}if(!t){t=[{op:16,bits:5,val:1},{op:23,bits:5,val:257},{op:19,bits:5,val:17},{op:27,bits:5,val:4097},{op:17,bits:5,val:5},{op:25,bits:5,val:1025},{op:21,bits:5,val:65},{op:29,bits:5,val:16385},{op:16,bits:5,val:3},{op:24,bits:5,val:513},{op:20,bits:5,val:33},{op:28,bits:5,val:8193},{op:18,bits:5,val:9},{op:26,bits:5,val:2049},{op:22,bits:5,val:129},{op:64,bits:5,val:0},{op:16,bits:5,val:2},{op:23,bits:5,val:385},{op:19,bits:5,val:25},{op:27,bits:5,val:6145},{op:17,bits:5,val:7},{op:25,bits:5,val:1537},{op:21,bits:5,val:97},{op:29,bits:5,val:24577},{op:16,bits:5,val:4},{op:24,bits:5,val:769},{op:20,bits:5,val:49},{op:28,bits:5,val:12289},{op:18,bits:5,val:13},{op:26,bits:5,val:3073},{op:22,bits:5,val:193},{op:64,bits:5,val:0}]}ar.lencode=0;ar.distcode=512;for(aq=0;aq<512;aq++){ar.codes[aq]=U[aq]}for(aq=0;aq<32;aq++){ar.codes[aq+512]=t[aq]}ar.lenbits=9;ar.distbits=5}function ap(at){var ar=at.state;var aq=at.output_data.length;if(ar.window===null){ar.window=""}if(ar.wsize==0){ar.wsize=1<<ar.wbits}if(aq>=ar.wsize){ar.window=at.output_data.substring(aq-ar.wsize)}else{if(ar.whave+aq<ar.wsize){ar.window+=at.output_data}else{ar.window=ar.window.substring(ar.whave-(ar.wsize-aq))+at.output_data}}ar.whave=ar.window.length;if(ar.whave<ar.wsize){ar.wnext=ar.whave}else{ar.wnext=0}return 0}function m(ar,at){var aq=[at&255,(at>>>8)&255];ar.state.check=ar.checksum_function(ar.state.check,aq,0,2)}function n(ar,at){var aq=[at&255,(at>>>8)&255,(at>>>16)&255,(at>>>24)&255];ar.state.check=ar.checksum_function(ar.state.check,aq,0,4)}function Z(ar,aq){aq.strm=ar;aq.left=ar.avail_out;aq.next=ar.next_in;aq.have=ar.avail_in;aq.hold=ar.state.hold;aq.bits=ar.state.bits;return aq}function ah(aq){var ar=aq.strm;ar.next_in=aq.next;ar.avail_out=aq.left;ar.avail_in=aq.have;ar.state.hold=aq.hold;ar.state.bits=aq.bits}function P(aq){aq.hold=0;aq.bits=0}function ag(aq){if(aq.have==0){return false}aq.have--;aq.hold+=(aq.strm.input_data.charCodeAt(aq.next++)&255)<<aq.bits;aq.bits+=8;return true}function ad(ar,aq){while(ar.bits<aq){if(!ag(ar)){return false}}return true}function b(ar,aq){return ar.hold&((1<<aq)-1)}function w(ar,aq){ar.hold>>>=aq;ar.bits-=aq}function c(aq){aq.hold>>>=aq.bits&7;aq.bits-=aq.bits&7}function ai(aq){return((aq>>>24)&255)+((aq>>>8)&65280)+((aq&65280)<<8)+((aq&255)<<24)}var I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];ZLIB.inflate=function(aD,at){var aC;var aB;var aq,az;var ar;var av=-1;var au=-1;var aw;var ax;var ay;var aA;if(!aD||!aD.state||(!aD.input_data&&aD.avail_in!=0)){return ZLIB.Z_STREAM_ERROR}aC=aD.state;if(aC.mode==an){aC.mode=ao}aB={};Z(aD,aB);aq=aB.have;az=aB.left;aA=ZLIB.Z_OK;inf_leave:for(;;){switch(aC.mode){case G:if(aC.wrap==0){aC.mode=ao;break}if(!ad(aB,16)){break inf_leave}if((aC.wrap&2)&&aB.hold==35615){aC.check=aD.checksum_function(0,null,0,0);m(aD,aB.hold);P(aB);aC.mode=D;break}aC.flags=0;if(aC.head!==null){aC.head.done=-1}if(!(aC.wrap&1)||((b(aB,8)<<8)+(aB.hold>>>8))%31){aD.msg="incorrect header check";aC.mode=a;break}if(b(aB,4)!=ZLIB.Z_DEFLATED){aD.msg="unknown compression method";aC.mode=a;break}w(aB,4);ay=b(aB,4)+8;if(aC.wbits==0){aC.wbits=ay}else{if(ay>aC.wbits){aD.msg="invalid window size";aC.mode=a;break}}aC.dmax=1<<ay;aD.adler=aC.check=aD.checksum_function(0,null,0,0);aC.mode=aB.hold&512?q:an;P(aB);break;case D:if(!ad(aB,16)){break inf_leave}aC.flags=aB.hold;if((aC.flags&255)!=ZLIB.Z_DEFLATED){aD.msg="unknown compression method";aC.mode=a;break}if(aC.flags&57344){aD.msg="unknown header flags set";aC.mode=a;break}if(aC.head!==null){aC.head.text=(aB.hold>>>8)&1}if(aC.flags&512){m(aD,aB.hold)}P(aB);aC.mode=am;case am:if(!ad(aB,32)){break inf_leave}if(aC.head!==null){aC.head.time=aB.hold}if(aC.flags&512){n(aD,aB.hold)}P(aB);aC.mode=af;case af:if(!ad(aB,16)){break inf_leave}if(aC.head!==null){aC.head.xflags=aB.hold&255;aC.head.os=aB.hold>>>8}if(aC.flags&512){m(aD,aB.hold)}P(aB);aC.mode=A;case A:if(aC.flags&1024){if(!ad(aB,16)){break inf_leave}aC.length=aB.hold;if(aC.head!==null){aC.head.extra_len=aB.hold}if(aC.flags&512){m(aD,aB.hold)}P(aB);aC.head.extra=""}else{if(aC.head!==null){aC.head.extra=null}}aC.mode=B;case B:if(aC.flags&1024){ar=aC.length;if(ar>aB.have){ar=aB.have}if(ar){if(aC.head!==null&&aC.head.extra!==null){ay=aC.head.extra_len-aC.length;aC.head.extra+=aD.input_data.substring(aB.next,aB.next+(ay+ar>aC.head.extra_max?aC.head.extra_max-ay:ar))}if(aC.flags&512){aC.check=aD.checksum_function(aC.check,aD.input_data,aB.next,ar)}aB.have-=ar;aB.next+=ar;aC.length-=ar}if(aC.length){break inf_leave}}aC.length=0;aC.mode=ac;case ac:if(aC.flags&2048){if(aB.have==0){break inf_leave}if(aC.head!==null&&aC.head.name===null){aC.head.name=""}ar=0;do{ay=aD.input_data.charAt(aB.next+ar);ar++;if(ay==="\0"){break}if(aC.head!==null&&aC.length<aC.head.name_max){aC.head.name+=ay;aC.length++}}while(ar<aB.have);if(aC.flags&512){aC.check=aD.checksum_function(aC.check,aD.input_data,aB.next,ar)}aB.have-=ar;aB.next+=ar;if(ay!=="\0"){break inf_leave}}else{if(aC.head!==null){aC.head.name=null}}aC.length=0;aC.mode=j;case j:if(aC.flags&4096){if(aB.have==0){break inf_leave}ar=0;if(aC.head!==null&&aC.head.comment===null){aC.head.comment=""}do{ay=aD.input_data.charAt(aB.next+ar);ar++;if(ay==="\0"){break}if(aC.head!==null&&aC.length<aC.head.comm_max){aC.head.comment+=ay;aC.length++}}while(ar<aB.have);if(aC.flags&512){aC.check=aD.checksum_function(aC.check,aD.input_data,aB.next,ar)}aB.have-=ar;aB.next+=ar;if(ay!=="\0"){break inf_leave}}else{if(aC.head!==null){aC.head.comment=null}}aC.mode=F;case F:if(aC.flags&512){if(!ad(aB,16)){break inf_leave}if(aB.hold!=(aC.check&65535)){aD.msg="header crc mismatch";aC.mode=a;break}P(aB)}if(aC.head!==null){aC.head.hcrc=(aC.flags>>>9)&1;aC.head.done=1}aD.adler=aC.check=aD.checksum_function(0,null,0,0);aC.mode=an;break;case q:if(!ad(aB,32)){break inf_leave}aD.adler=aC.check=ai(aB.hold);P(aB);aC.mode=p;case p:if(aC.havedict==0){ah(aB);return ZLIB.Z_NEED_DICT}aD.adler=aC.check=aD.checksum_function(0,null,0,0);aC.mode=an;case an:if(at==ZLIB.Z_BLOCK||at==ZLIB.Z_TREES){break inf_leave}case ao:if(aC.last){c(aB);aC.mode=d;break}if(!ad(aB,3)){break inf_leave}aC.last=b(aB,1);w(aB,1);switch(b(aB,2)){case 0:aC.mode=aj;break;case 1:C(aC);aC.mode=S;if(at==ZLIB.Z_TREES){w(aB,2);break inf_leave}break;case 2:aC.mode=al;break;case 3:aD.msg="invalid block type";aC.mode=a}w(aB,2);break;case aj:c(aB);if(!ad(aB,32)){break inf_leave}if((aB.hold&65535)!=(((aB.hold>>>16)&65535)^65535)){aD.msg="invalid stored block lengths";aC.mode=a;break}aC.length=aB.hold&65535;P(aB);aC.mode=l;if(at==ZLIB.Z_TREES){break inf_leave}case l:aC.mode=k;case k:ar=aC.length;if(ar){if(ar>aB.have){ar=aB.have}if(ar>aB.left){ar=aB.left}if(ar==0){break inf_leave}aD.output_data+=aD.input_data.substring(aB.next,aB.next+ar);aD.next_out+=ar;aB.have-=ar;aB.next+=ar;aB.left-=ar;aC.length-=ar;break}aC.mode=an;break;case al:if(!ad(aB,14)){break inf_leave}aC.nlen=b(aB,5)+257;w(aB,5);aC.ndist=b(aB,5)+1;w(aB,5);aC.ncode=b(aB,4)+4;w(aB,4);if(aC.nlen>286||aC.ndist>30){aD.msg="too many length or distance symbols";aC.mode=a;break}aC.have=0;aC.mode=W;case W:while(aC.have<aC.ncode){if(!ad(aB,3)){break inf_leave}var aE=b(aB,3);aC.lens[I[aC.have++]]=aE;w(aB,3)}while(aC.have<19){aC.lens[I[aC.have++]]=0}aC.next=0;aC.lencode=0;aC.lenbits=7;aA=K(aC,h);if(aA){aD.msg="invalid code lengths set";aC.mode=a;break}aC.have=0;aC.mode=g;case g:while(aC.have<aC.nlen+aC.ndist){for(;;){aw=aC.codes[aC.lencode+b(aB,aC.lenbits)];if(aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}if(aw.val<16){w(aB,aw.bits);aC.lens[aC.have++]=aw.val}else{if(aw.val==16){if(!ad(aB,aw.bits+2)){break inf_leave}w(aB,aw.bits);if(aC.have==0){aD.msg="invalid bit length repeat";aC.mode=a;break}ay=aC.lens[aC.have-1];ar=3+b(aB,2);w(aB,2)}else{if(aw.val==17){if(!ad(aB,aw.bits+3)){break inf_leave}w(aB,aw.bits);ay=0;ar=3+b(aB,3);w(aB,3)}else{if(!ad(aB,aw.bits+7)){break inf_leave}w(aB,aw.bits);ay=0;ar=11+b(aB,7);w(aB,7)}}if(aC.have+ar>aC.nlen+aC.ndist){aD.msg="invalid bit length repeat";aC.mode=a;break}while(ar--){aC.lens[aC.have++]=ay}}}if(aC.mode==a){break}if(aC.lens[256]==0){aD.msg="invalid code -- missing end-of-block";aC.mode=a;break}aC.next=0;aC.lencode=aC.next;aC.lenbits=9;aA=K(aC,X);if(aA){aD.msg="invalid literal/lengths set";aC.mode=a;break}aC.distcode=aC.next;aC.distbits=6;aA=K(aC,u);if(aA){aD.msg="invalid distances set";aC.mode=a;break}aC.mode=S;if(at==ZLIB.Z_TREES){break inf_leave}case S:aC.mode=R;case R:if(aB.have>=6&&aB.left>=258){ah(aB);H(aD,az);Z(aD,aB);if(aC.mode==an){aC.back=-1}break}aC.back=0;for(;;){aw=aC.codes[aC.lencode+b(aB,aC.lenbits)];if(aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}if(aw.op&&(aw.op&240)==0){ax=aw;for(;;){aw=aC.codes[aC.lencode+ax.val+(b(aB,ax.bits+ax.op)>>>ax.bits)];if(ax.bits+aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}w(aB,ax.bits);aC.back+=ax.bits}w(aB,aw.bits);aC.back+=aw.bits;aC.length=aw.val;if(aw.op==0){aC.mode=Y;break}if(aw.op&32){aC.back=-1;aC.mode=an;break}if(aw.op&64){aD.msg="invalid literal/length code";aC.mode=a;break}aC.extra=aw.op&15;aC.mode=T;case T:if(aC.extra){if(!ad(aB,aC.extra)){break inf_leave}aC.length+=b(aB,aC.extra);w(aB,aC.extra);aC.back+=aC.extra}aC.was=aC.length;aC.mode=r;case r:for(;;){aw=aC.codes[aC.distcode+b(aB,aC.distbits)];if(aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}if((aw.op&240)==0){ax=aw;for(;;){aw=aC.codes[aC.distcode+ax.val+(b(aB,ax.bits+ax.op)>>>ax.bits)];if((ax.bits+aw.bits)<=aB.bits){break}if(!ag(aB)){break inf_leave}}w(aB,ax.bits);aC.back+=ax.bits}w(aB,aw.bits);aC.back+=aw.bits;if(aw.op&64){aD.msg="invalid distance code";aC.mode=a;break}aC.offset=aw.val;aC.extra=aw.op&15;aC.mode=s;case s:if(aC.extra){if(!ad(aB,aC.extra)){break inf_leave}aC.offset+=b(aB,aC.extra);w(aB,aC.extra);aC.back+=aC.extra}aC.mode=aa;case aa:if(aB.left==0){break inf_leave}ar=az-aB.left;if(aC.offset>ar){ar=aC.offset-ar;if(ar>aC.whave){if(aC.sane){aD.msg="invalid distance too far back";aC.mode=a;break}}if(ar>aC.wnext){ar-=aC.wnext;av=aC.wsize-ar;au=-1}else{av=aC.wnext-ar;au=-1}if(ar>aC.length){ar=aC.length}}else{av=-1;au=aD.next_out-aC.offset;ar=aC.length}if(ar>aB.left){ar=aB.left}aB.left-=ar;aC.length-=ar;if(av>=0){aD.output_data+=aC.window.substring(av,av+ar);aD.next_out+=ar;ar=0}else{aD.next_out+=ar;do{aD.output_data+=aD.output_data.charAt(au++)}while(--ar)}if(aC.length==0){aC.mode=R}break;case Y:if(aB.left==0){break inf_leave}aD.output_data+=String.fromCharCode(aC.length);aD.next_out++;aB.left--;aC.mode=R;break;case d:if(aC.wrap){if(!ad(aB,32)){break inf_leave}az-=aB.left;aD.total_out+=az;aC.total+=az;if(az){aD.adler=aC.check=aD.checksum_function(aC.check,aD.output_data,aD.output_data.length-az,az)}az=aB.left;if((aC.flags?aB.hold:ai(aB.hold))!=aC.check){aD.msg="incorrect data check";aC.mode=a;break}P(aB)}aC.mode=V;case V:if(aC.wrap&&aC.flags){if(!ad(aB,32)){break inf_leave}if(aB.hold!=(aC.total&4294967295)){aD.msg="incorrect length check";aC.mode=a;break}P(aB)}aC.mode=v;case v:aA=ZLIB.Z_STREAM_END;break inf_leave;case a:aA=ZLIB.Z_DATA_ERROR;break inf_leave;case ab:return ZLIB.Z_MEM_ERROR;case ak:default:return ZLIB.Z_STREAM_ERROR}}inf_leave:ah(aB);if(aC.wsize||(az!=aD.avail_out&&aC.mode<a&&(aC.mode<d||at!=ZLIB.Z_FINISH))){if(ap(aD)){aC.mode=ab;return ZLIB.Z_MEM_ERROR}}aq-=aD.avail_in;az-=aD.avail_out;aD.total_in+=aq;aD.total_out+=az;aC.total+=az;if(aC.wrap&&az){aD.adler=aC.check=aD.checksum_function(aC.check,aD.output_data,0,aD.output_data.length)}aD.data_type=aC.bits+(aC.last?64:0)+(aC.mode==an?128:0)+(aC.mode==S||aC.mode==l?256:0);if(((aq==0&&az==0)||at==ZLIB.Z_FINISH)&&aA==ZLIB.Z_OK){aA=ZLIB.Z_BUF_ERROR}return aA};ZLIB.inflateEnd=function(ar){var aq;if(!ar||!ar.state){return ZLIB.Z_STREAM_ERROR}aq=ar.state;aq.window=null;ar.state=null;return ZLIB.Z_OK};ZLIB.z_stream.prototype.inflate=function(au,av){var at;var aq;var ar=16384;this.input_data=au;this.next_in=E(av,"next_in",0);this.avail_in=E(av,"avail_in",au.length-this.next_in);at=E(av,"flush",ZLIB.Z_SYNC_FLUSH);aq=E(av,"avail_out",-1);var aw="";do{this.avail_out=(aq>=0?aq:ar);this.output_data="";this.next_out=0;this.error=ZLIB.inflate(this,at);if(aq>=0){return this.output_data}aw+=this.output_data;if(this.avail_out>0){break}}while(this.error==ZLIB.Z_OK);return aw};ZLIB.z_stream.prototype.inflateReset=function(aq){return ZLIB.inflateReset(this,aq)}}());if(typeof ZLIB==="undefined"){alert("ZLIB is not defined. SRC zlib.js before zlib-adler32.js")}(function(){var c=65521;var d=5552;function b(e,g,k,h){var l;var j;l=(e>>>16)&65535;e&=65535;if(h==1){e+=g.charCodeAt(k)&255;if(e>=c){e-=c}l+=e;if(l>=c){l-=c}return e|(l<<16)}if(g===null){return 1}if(h<16){while(h--){e+=g.charCodeAt(k++)&255;l+=e}if(e>=c){e-=c}l%=c;return e|(l<<16)}while(h>=d){h-=d;j=d>>4;do{e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e}while(--j);e%=c;l%=c}if(h){while(h>=16){h-=16;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e}while(h--){e+=g.charCodeAt(k++)&255;l+=e}e%=c;l%=c}return e|(l<<16)}function a(e,g,k,h){var l;var j;l=(e>>>16)&65535;e&=65535;if(h==1){e+=g[k];if(e>=c){e-=c}l+=e;if(l>=c){l-=c}return e|(l<<16)}if(g===null){return 1}if(h<16){while(h--){e+=g[k++];l+=e}if(e>=c){e-=c}l%=c;return e|(l<<16)}while(h>=d){h-=d;j=d>>4;do{e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e}while(--j);e%=c;l%=c}if(h){while(h>=16){h-=16;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e}while(h--){e+=g[k++];l+=e}e%=c;l%=c}return e|(l<<16)}ZLIB.adler32=function(e,g,j,h){if(typeof g==="string"){return b(e,g,j,h)}else{return a(e,g,j,h)}};ZLIB.adler32_combine=function(e,g,h){var k;var l;var j;if(h<0){return 4294967295}h%=c;j=h;k=e&65535;l=j*k;l%=c;k+=(g&65535)+c-1;l+=((e>>16)&65535)+((g>>16)&65535)+c-j;if(k>=c){k-=c}if(k>=c){k-=c}if(l>=(c<<1)){l-=(c<<1)}if(l>=c){l-=c}return k|(l<<16)}}());if(typeof ZLIB==="undefined"){alert("ZLIB is not defined. SRC zlib.js before zlib-crc32.js")}(function(){var a=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918000,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];function c(j,h,l,k){if(h==null){return 0}j=j^4294967295;while(k>=8){j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);k-=8}if(k){do{j=a[(j^h.charCodeAt(l++))&255]^(j>>>8)}while(--k)}return j^4294967295}function b(j,h,l,k){if(h==null){return 0}j=j^4294967295;while(k>=8){j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);k-=8}if(k){do{j=a[(j^h[l++])&255]^(j>>>8)}while(--k)}return j^4294967295}ZLIB.crc32=function(j,h,l,k){if(typeof h==="string"){return c(j,h,l,k)}else{return b(j,h,l,k)}};var d=32;function g(h,l){var k;var j=0;k=0;while(l){if(l&1){k^=h[j]}l>>=1;j++}return k}function e(k,h){var j;for(j=0;j<d;j++){k[j]=g(h,h[j])}}ZLIB.crc32_combine=function(h,j,l){var m;var p;var k;var o;if(l<=0){return h}k=new Array(d);o=new Array(d);o[0]=3988292384;p=1;for(m=1;m<d;m++){o[m]=p;p<<=1}e(k,o);e(o,k);do{e(k,o);if(l&1){h=g(k,h)}l>>=1;if(l==0){break}e(o,k);if(l&1){h=g(o,h)}l>>=1}while(l!=0);h^=j;return h}}());var CreateAmtRedirect=function(e,a){var g={};g.m=e;e.parent=g;g.authCookie=a;g.State=0;g.socket=null;g.host=null;g.port=0;g.user=null;g.pass=null;g.authuri="/RedirectionService";g.tlsv1only=0;g.inDataCount=0;g.connectstate=0;g.protocol=e.protocol;g.debugmode=0;g.amtaccumulator="";g.amtsequence=1;g.amtkeepalivetimer=null;g.onStateChanged=null;g.Start=function(h,k,n,j,l){g.host=h;g.port=k;g.user=n;g.pass=j;g.connectstate=0;g.inDataCount=0;var m=window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=2&host="+h+"&port="+k+"&tls="+l+((n=="*")?"&serverauth=1":"")+((typeof j==="undefined")?("&serverauth=1&user="+n):"");if((a!=null)&&(a!="")){m+="&auth="+a}g.socket=new WebSocket(m);g.socket.onopen=g.xxOnSocketConnected;g.socket.onmessage=g.xxOnMessage;g.socket.onclose=g.xxOnSocketClosed;g.xxStateChange(1)};g.xxOnSocketConnected=function(){if(g.debugmode==1){console.log("onSocketConnected")}g.xxStateChange(2);if(g.protocol==1){g.xxSend(g.RedirectStartSol)}if(g.protocol==2){g.xxSend(g.RedirectStartKvm)}if(g.protocol==3){g.xxSend(g.RedirectStartIder)}};var b=new FileReader();var d=false,c=[];if(b.readAsBinaryString){b.onload=function(h){g.xxOnSocketData(h.target.result);if(c.length==0){d=false}else{b.readAsBinaryString(new Blob([c.shift()]))}}}else{if(b.readAsArrayBuffer){b.onloadend=function(h){g.xxOnSocketData(h.target.result);if(c.length==0){d=false}else{b.readAsArrayBuffer(c.shift())}}}}g.xxOnMessage=function(k){g.inDataCount++;if(typeof k.data=="object"){if(d==true){c.push(k.data);return}if(b.readAsBinaryString){d=true;b.readAsBinaryString(new Blob([k.data]))}else{if(b.readAsArrayBuffer){d=true;b.readAsArrayBuffer(k.data)}else{var h="",j=new Uint8Array(k.data),m=j.byteLength;for(var l=0;l<m;l++){h+=String.fromCharCode(j[l])}g.xxOnSocketData(h)}}}else{g.xxOnSocketData(k.data)}};g.xxOnSocketData=function(t){if(!t||g.connectstate==-1){return}if(typeof t==="object"){var m="";var o=new Uint8Array(t);var y=o.byteLength;for(var x=0;x<y;x++){m+=String.fromCharCode(o[x])}t=m}else{if(typeof t!=="string"){return}}if((g.protocol==2||g.protocol==3)&&g.connectstate==1){return g.m.ProcessData(t)}g.amtaccumulator+=t;while(g.amtaccumulator.length>=1){var p=0;switch(g.amtaccumulator.charCodeAt(0)){case 17:if(g.amtaccumulator.length<4){return}var L=g.amtaccumulator.charCodeAt(1);switch(L){case 0:if(g.amtaccumulator.length<13){return}var C=g.amtaccumulator.charCodeAt(12);if(g.amtaccumulator.length<13+C){return}g.xxSend(String.fromCharCode(19,0,0,0,0,0,0,0,0));p=(13+C);break;default:g.Stop(1);break}break;case 20:if(g.amtaccumulator.length<9){return}var k=ReadIntX(g.amtaccumulator,5);if(g.amtaccumulator.length<9+k){return}var K=g.amtaccumulator.charCodeAt(1);var l=g.amtaccumulator.charCodeAt(4);var h=[];for(x=0;x<k;x++){h.push(g.amtaccumulator.charCodeAt(9+x))}var j=g.amtaccumulator.substring(9,9+k);p=9+k;if(l==0){if(h.indexOf(4)>=0){g.xxSend(String.fromCharCode(19,0,0,0,4)+IntToStrX(g.user.length+g.authuri.length+8)+String.fromCharCode(g.user.length)+g.user+String.fromCharCode(0,0)+String.fromCharCode(g.authuri.length)+g.authuri+String.fromCharCode(0,0,0,0))}else{if(h.indexOf(3)>=0){g.xxSend(String.fromCharCode(19,0,0,0,3)+IntToStrX(g.user.length+g.authuri.length+7)+String.fromCharCode(g.user.length)+g.user+String.fromCharCode(0,0)+String.fromCharCode(g.authuri.length)+g.authuri+String.fromCharCode(0,0,0))}else{if(h.indexOf(1)>=0){g.xxSend(String.fromCharCode(19,0,0,0,1)+IntToStrX(g.user.length+g.pass.length+2)+String.fromCharCode(g.user.length)+g.user+String.fromCharCode(g.pass.length)+g.pass)}else{g.Stop(2)}}}}else{if((l==3||l==4)&&K==1){var s=0;var G=j.charCodeAt(s);var F=j.substring(s+1,s+1+G);s+=(G+1);var B=j.charCodeAt(s);var A=j.substring(s+1,s+1+B);s+=(B+1);var E=0;var D=null;var q=g.xxRandomNonce(32);var J="00000002";var v="";if(l==4){E=j.charCodeAt(s);D=j.substring(s+1,s+1+E);s+=(E+1);v=J+":"+q+":"+D+":"}var u=hex_md5(hex_md5(g.user+":"+F+":"+g.pass)+":"+A+":"+v+hex_md5("POST:"+g.authuri));var M=g.user.length+F.length+A.length+g.authuri.length+q.length+J.length+u.length+7;if(l==4){M+=(D.length+1)}var n=String.fromCharCode(19,0,0,0,l)+IntToStrX(M)+String.fromCharCode(g.user.length)+g.user+String.fromCharCode(F.length)+F+String.fromCharCode(A.length)+A+String.fromCharCode(g.authuri.length)+g.authuri+String.fromCharCode(q.length)+q+String.fromCharCode(J.length)+J+String.fromCharCode(u.length)+u;if(l==4){n+=(String.fromCharCode(D.length)+D)}g.xxSend(n)}else{if(K==0){if(g.protocol==1){var z=10000;var O=100;var N=0;var I=10000;var H=100;var w=0;g.xxSend(String.fromCharCode(32,0,0,0)+IntToStrX(g.amtsequence++)+ShortToStrX(z)+ShortToStrX(O)+ShortToStrX(N)+ShortToStrX(I)+ShortToStrX(H)+ShortToStrX(w)+IntToStrX(0))}if(g.protocol==2){g.xxSend(String.fromCharCode(64,0,0,0,0,0,0,0))}if(g.protocol==3){g.connectstate=1;g.xxStateChange(3)}}else{g.Stop(3)}}}break;case 33:if(g.amtaccumulator.length<23){break}p=23;g.xxSend(String.fromCharCode(39,0,0,0)+IntToStrX(g.amtsequence++)+String.fromCharCode(0,0,27,0,0,0));if(g.protocol==1){g.amtkeepalivetimer=setInterval(g.xxSendAmtKeepAlive,2000)}g.connectstate=1;g.xxStateChange(3);break;case 41:if(g.amtaccumulator.length<10){break}p=10;break;case 42:if(g.amtaccumulator.length<10){break}var r=(10+((g.amtaccumulator.charCodeAt(9)&255)<<8)+(g.amtaccumulator.charCodeAt(8)&255));if(g.amtaccumulator.length<r){break}g.m.ProcessData(g.amtaccumulator.substring(10,r));p=r;break;case 43:if(g.amtaccumulator.length<8){break}p=8;break;case 65:if(g.amtaccumulator.length<8){break}g.connectstate=1;g.m.Start();if(g.amtaccumulator.length>8){g.m.ProcessData(g.amtaccumulator.substring(8))}p=g.amtaccumulator.length;break;default:console.log("Unknown Intel AMT command: "+g.amtaccumulator.charCodeAt(0)+" acclen="+g.amtaccumulator.length);g.Stop(4);return}if(p==0){return}g.amtaccumulator=g.amtaccumulator.substring(p)}};g.xxSend=function(l){if(g.socket!=null&&g.socket.readyState==WebSocket.OPEN){if(g.debugmode==1){console.log("Send",l)}var h=new Uint8Array(l.length);for(var k=0;k<l.length;++k){h[k]=l.charCodeAt(k)}try{g.socket.send(h.buffer)}catch(j){}}};g.send=function(h){if(g.socket==null||g.connectstate!=1){return}if(g.protocol==1){g.xxSend(String.fromCharCode(40,0,0,0)+IntToStrX(g.amtsequence++)+ShortToStrX(h.length)+h)}else{g.xxSend(h)}};g.xxSendAmtKeepAlive=function(){if(g.socket==null){return}g.xxSend(String.fromCharCode(43,0,0,0)+IntToStrX(g.amtsequence++))};g.xxRandomNonceX="abcdef0123456789";g.xxRandomNonce=function(j){var k="";for(var h=0;h<j;h++){k+=g.xxRandomNonceX.charAt(Math.floor(Math.random()*g.xxRandomNonceX.length))}return k};g.xxOnSocketClosed=function(){if(g.debugmode==1){console.log("onSocketClosed")}if((g.inDataCount==0)&&(g.tlsv1only==0)){g.tlsv1only=1;g.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=2&host="+g.host+"&port="+g.port+"&tls="+g.tls+"&tls1only=1"+((g.user=="*")?"&serverauth=1":"")+((typeof pass==="undefined")?("&serverauth=1&user="+g.user):""));g.socket.onopen=g.xxOnSocketConnected;g.socket.onmessage=g.xxOnMessage;g.socket.onclose=g.xxOnSocketClosed}else{g.Stop(5)}};g.xxStateChange=function(h){if(g.State==h){return}g.State=h;g.m.xxStateChange(g.State);if(g.onStateChanged!=null){g.onStateChanged(g,g.State)}};g.Stop=function(h){if(g.debugmode==1){console.log("onSocketStop",h)}g.xxStateChange(0);g.connectstate=-1;g.amtaccumulator="";if(g.socket!=null){g.socket.close();g.socket=null}if(g.amtkeepalivetimer!=null){clearInterval(g.amtkeepalivetimer);g.amtkeepalivetimer=null}};g.RedirectStartSol=String.fromCharCode(16,0,0,0,83,79,76,32);g.RedirectStartKvm=String.fromCharCode(16,1,0,0,75,86,77,82);g.RedirectStartIder=String.fromCharCode(16,0,0,0,73,68,69,82);return g};var CreateWsmanComm=function(l,o,q,n,p){var m={};m.PendingAjax=[];m.ActiveAjaxCount=0;m.MaxActiveAjaxCount=1;m.FailAllError=0;m.challengeParams=null;m.noncecounter=1;m.authcounter=0;m.socket=null;m.socketState=0;m.host=l;m.port=o;m.user=q;m.pass=n;m.tls=p;m.tlsv1only=1;m.cnonce=Math.random().toString(36).substring(7);m.PerformAjax=function(t,s,v,u,w,r){if(m.ActiveAjaxCount<m.MaxActiveAjaxCount&&m.PendingAjax.length==0){m.PerformAjaxEx(t,s,v,w,r)}else{if(u==1){m.PendingAjax.unshift([t,s,v,w,r])}else{m.PendingAjax.push([t,s,v,w,r])}}};m.PerformNextAjax=function(){if(m.ActiveAjaxCount>=m.MaxActiveAjaxCount||m.PendingAjax.length==0){return}var r=m.PendingAjax.shift();m.PerformAjaxEx(r[0],r[1],r[2],r[3],r[4]);m.PerformNextAjax()};m.PerformAjaxEx=function(t,s,u,v,r){if(m.FailAllError!=0){m.gotNextMessagesError({status:m.FailAllError},"error",null,[t,s,u,v,r]);return}if(!t){t=""}m.ActiveAjaxCount++;return m.PerformAjaxExNodeJS(t,s,u,v,r)};m.pendingAjaxCall=[];m.PerformAjaxExNodeJS=function(t,s,u,v,r){m.PerformAjaxExNodeJS2(t,s,u,v,r,3)};m.PerformAjaxExNodeJS2=function(t,s,v,w,r,u){if(u<=0||m.FailAllError!=0){m.ActiveAjaxCount--;if(m.FailAllError!=999){m.gotNextMessages(null,"error",{status:((m.FailAllError==0)?408:m.FailAllError)},[t,s,v,w,r])}m.PerformNextAjax();return}m.pendingAjaxCall.push([t,s,v,w,r,u]);if(m.socketState==0){m.xxConnectHttpSocket()}else{if(m.socketState==2){m.sendRequest(t,w,r)}}};m.sendRequest=function(t,v,r){v=v?v:"/wsman";r=r?r:"POST";var s=r+" "+v+" HTTP/1.1\r\n";if(m.challengeParams!=null){var u=hex_md5(hex_md5(m.user+":"+m.challengeParams.realm+":"+m.pass)+":"+m.challengeParams.nonce+":"+m.noncecounter+":"+m.cnonce+":"+m.challengeParams.qop+":"+hex_md5(r+":"+v));s+="Authorization: "+m.renderDigest({username:m.user,realm:m.challengeParams.realm,nonce:m.challengeParams.nonce,uri:v,qop:m.challengeParams.qop,response:u,nc:m.noncecounter++,cnonce:m.cnonce})+"\r\n"}s+="Host: "+m.host+":"+m.port+"\r\nTransfer-Encoding: chunked\r\n\r\n"+t.length.toString(16).toUpperCase()+"\r\n"+t+"\r\n0\r\n\r\n";g(s)};m.parseDigest=function(r){var s=r.substring(7).split(",");for(i in s){s[i]=s[i].trim()}return s.reduce(function(t,v){var u=v.split("=");t[u[0]]=u[1].replace(/"/g,"");return t},{})};m.renderDigest=function(r){var s=[];for(i in r){s.push(i)}return"Digest "+s.reduce(function(u,t){return u+","+t+'="'+r[t]+'"'},"").substring(1)};m.xxConnectHttpSocket=function(){m.socketParseState=0;m.socketAccumulator="";m.socketHeader=null;m.socketData="";m.socketState=1;console.log(m.tlsv1only);m.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=1&host="+m.host+"&port="+m.port+"&tls="+m.tls+"&tlsv1only="+m.tlsv1only+((q=="*")?"&serverauth=1":"")+((typeof n==="undefined")?("&serverauth=1&user="+q):""));m.socket.onopen=c;m.socket.onmessage=a;m.socket.onclose=b};function c(){m.socketState=2;for(i in m.pendingAjaxCall){m.sendRequest(m.pendingAjaxCall[i][0],m.pendingAjaxCall[i][3],m.pendingAjaxCall[i][4])}}var h=new FileReader();var k=false,j=[];if(h.readAsBinaryString){h.onload=function(r){d(r.target.result);if(j.length==0){k=false}else{h.readAsBinaryString(new Blob([j.shift()]))}}}else{if(h.readAsArrayBuffer){h.onloadend=function(r){d(r.target.result);if(j.length==0){k=false}else{h.readAsArrayBuffer(j.shift())}}}}function a(t){if(typeof t.data=="object"){if(k==true){j.push(t.data);return}if(h.readAsBinaryString){k=true;h.readAsBinaryString(new Blob([t.data]))}else{if(h.readAsArrayBuffer){k=true;h.readAsArrayBuffer(t.data)}else{var r="",s=new Uint8Array(t.data),v=s.byteLength;for(var u=0;u<v;u++){r+=String.fromCharCode(s[u])}d(r)}}}else{d(t.data)}}function d(v){if(typeof v==="object"){var r="",s=new Uint8Array(v),y=s.byteLength;for(var x=0;x<y;x++){r+=String.fromCharCode(s[x])}v=r}else{if(typeof v!=="string"){return}}m.socketAccumulator+=v;while(true){if(m.socketParseState==0){var w=m.socketAccumulator.indexOf("\r\n\r\n");if(w<0){return}m.socketHeader=m.socketAccumulator.substring(0,w).split("\r\n");m.socketAccumulator=m.socketAccumulator.substring(w+4);m.socketParseState=1;m.socketData="";m.socketXHeader={Directive:m.socketHeader[0].split(" ")};for(x in m.socketHeader){if(x!=0){var z=m.socketHeader[x].indexOf(":");m.socketXHeader[m.socketHeader[x].substring(0,z).toLowerCase()]=m.socketHeader[x].substring(z+2)}}}if(m.socketParseState==1){var u=-1;if((m.socketXHeader.connection!=undefined)&&(m.socketXHeader.connection.toLowerCase()=="close")&&((m.socketXHeader["transfer-encoding"]==undefined)||(m.socketXHeader["transfer-encoding"].toLowerCase()!="chunked"))){u=0}else{if(m.socketXHeader["content-length"]!=undefined){u=parseInt(m.socketXHeader["content-length"]);if(m.socketAccumulator.length<u){return}var v=m.socketAccumulator.substring(0,u);m.socketAccumulator=m.socketAccumulator.substring(u);m.socketData=v;u=0}else{var t=m.socketAccumulator.indexOf("\r\n");if(t<0){return}u=parseInt(m.socketAccumulator.substring(0,t),16);if(isNaN(u)){if(m.websocket){m.websocket.close()}return}if(m.socketAccumulator.length<t+2+u+2){return}var v=m.socketAccumulator.substring(t+2,t+2+u);m.socketAccumulator=m.socketAccumulator.substring(t+2+u+2);m.socketData+=v}}if(u==0){e(m.socketXHeader,m.socketData);m.socketParseState=0;m.socketHeader=null}}}}function e(u,t){var w=parseInt(u.Directive[1]);if(isNaN(w)){w=602}if(w==401&&++(m.authcounter)<3){m.challengeParams=m.parseDigest(u["www-authenticate"])}else{var v=m.pendingAjaxCall.shift();m.authcounter=0;m.ActiveAjaxCount--;m.gotNextMessages(t,"success",{status:w},v);m.PerformNextAjax()}}function b(s){m.socketState=0;if(m.socket!=null){m.socket.close();m.socket=null}if(m.pendingAjaxCall.length>0){var t=m.pendingAjaxCall.shift();var u=t[5];m.PerformAjaxExNodeJS2(t[0],t[1],t[2],t[3],t[4],--u)}}function g(u){if(m.socketState==2&&m.socket!=null&&m.socket.readyState==WebSocket.OPEN){var r=new Uint8Array(u.length);for(var t=0;t<u.length;++t){r[t]=u.charCodeAt(t)}try{m.socket.send(r.buffer)}catch(s){}}}m.gotNextMessages=function(s,u,t,r){if(m.FailAllError==999){return}if(m.FailAllError!=0){r[1](null,m.FailAllError,r[2]);return}if(t.status!=200){r[1](null,t.status,r[2]);return}r[1](s,200,r[2])};m.gotNextMessagesError=function(t,u,s,r){if(m.FailAllError==999){return}if(m.FailAllError!=0){r[1](null,m.FailAllError,r[2]);return}r[1](m,null,{Header:{HttpError:t.status}},t.status,r[2])};m.CancelAllQueries=function(r){while(m.PendingAjax.length>0){var t=m.PendingAjax.shift();t[1](null,r,t[2])}if(m.websocket!=null){m.websocket.close();m.websocket=null;m.socketState=0}};return m};var CreateAgentRedirect=function(g,h,l,a,b){var j={};j.m=h;h.parent=j;j.meshserver=g;j.authCookie=a;j.State=0;j.nodeid=null;j.socket=null;j.connectstate=-1;j.tunnelid=Math.random().toString(36).substring(2);j.protocol=h.protocol;j.onStateChanged=null;j.ctrlMsgAllowed=true;j.attemptWebRTC=false;j.webRtcActive=false;j.webSwitchOk=false;j.webchannel=null;j.webrtc=null;j.debugmode=0;if(b==null){b="/"}j.consoleMessage=null;j.onConsoleMessageChange=null;j.Start=function(m){var o,n=window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/meshrelay.ashx?id="+j.tunnelid;if((a!=null)&&(a!="")){n+="&auth="+a}j.nodeid=m;j.connectstate=0;j.socket=new WebSocket(n);j.socket.onopen=j.xxOnSocketConnected;j.socket.onmessage=j.xxOnMessage;j.socket.onerror=function(p){};j.socket.onclose=j.xxOnSocketClosed;j.xxStateChange(1);j.meshserver.send({action:"msg",type:"tunnel",nodeid:j.nodeid,value:"*"+b+"meshrelay.ashx?id="+j.tunnelid,usage:j.protocol})};j.xxOnSocketConnected=function(){if(j.debugmode==1){console.log("onSocketConnected")}j.xxStateChange(2)};j.xxOnControlCommand=function(o){var m;try{m=JSON.parse(o)}catch(n){return}if(m.ctrlChannel!="102938"){j.xxOnSocketData(o);return}if(m.type=="console"){j.consoleMessage=m.msg;if(j.onConsoleMessageChange){j.onConsoleMessageChange(j,j.consoleMessage)}}else{if(j.webrtc!=null){if(m.type=="answer"){j.webrtc.setRemoteDescription(new RTCSessionDescription(m),function(){},j.xxCloseWebRTC)}else{if(m.type=="webrtc0"){j.webSwitchOk=true;k()}else{if(m.type=="webrtc1"){j.sendCtrlMsg('{"ctrlChannel":"102938","type":"webrtc2"}')}else{if(m.type=="webrtc2"){}}}}}}};j.sendCtrlMsg=function(n){if(j.ctrlMsgAllowed==true){if((typeof args!="undefined")&&args.redirtrace){console.log("RedirSend",typeof n,n)}try{j.socket.send(n)}catch(m){}}};function k(){if((j.webSwitchOk==true)&&(j.webRtcActive==true)){j.sendCtrlMsg('{"ctrlChannel":"102938","type":"webrtc0"}');j.sendCtrlMsg('{"ctrlChannel":"102938","type":"webrtc1"}');if(j.onStateChanged!=null){j.onStateChanged(j,j.State)}}}j.xxOnMessage=function(p){if(j.State<3){if(p.data=="c"){try{j.socket.send(j.protocol)}catch(q){}j.xxStateChange(3);if(j.attemptWebRTC==true){var o=null;if(typeof RTCPeerConnection!=="undefined"){j.webrtc=new RTCPeerConnection(o)}else{if(typeof webkitRTCPeerConnection!=="undefined"){j.webrtc=new webkitRTCPeerConnection(o)}}if(j.webrtc!=null){j.webchannel=j.webrtc.createDataChannel("DataChannel",{});j.webchannel.onmessage=j.xxOnMessage;j.webchannel.onopen=function(){j.webRtcActive=true;k()};j.webchannel.onclose=function(t){if(j.webRtcActive){j.Stop()}};j.webrtc.onicecandidate=function(t){if(t.candidate==null){try{j.socket.send(JSON.stringify(j.webrtcoffer))}catch(u){}}else{j.webrtcoffer.sdp+=("a="+t.candidate.candidate+"\r\n")}};j.webrtc.oniceconnectionstatechange=function(){if(j.webrtc!=null){if(j.webrtc.iceConnectionState=="disconnected"){if(j.webRtcActive==true){j.Stop()}else{j.xxCloseWebRTC()}}else{if(j.webrtc.iceConnectionState=="failed"){j.xxCloseWebRTC()}}}};j.webrtc.createOffer(function(t){j.webrtcoffer=t;j.webrtc.setLocalDescription(t,function(){},j.xxCloseWebRTC)},j.xxCloseWebRTC,{mandatory:{OfferToReceiveAudio:false,OfferToReceiveVideo:false}})}}return}}if(typeof p.data=="string"){j.xxOnControlCommand(p.data);return}if(typeof p.data=="object"){if(e==true){d.push(p.data);return}if(c.readAsBinaryString){e=true;c.readAsBinaryString(new Blob([p.data]))}else{if(c.readAsArrayBuffer){e=true;c.readAsArrayBuffer(p.data)}else{var m="",n=new Uint8Array(p.data),s=n.byteLength;for(var r=0;r<s;r++){m+=String.fromCharCode(n[r])}j.xxOnSocketData(m)}}}else{j.xxOnSocketData(p.data)}};var c=new FileReader();var e=false,d=[];if(c.readAsBinaryString){c.onload=function(m){j.xxOnSocketData(m.target.result);if(d.length==0){e=false}else{c.readAsBinaryString(new Blob([d.shift()]))}}}else{if(c.readAsArrayBuffer){c.onloadend=function(m){j.xxOnSocketData(m.target.result);if(d.length==0){e=false}else{c.readAsArrayBuffer(d.shift())}}}}j.xxOnSocketData=function(o){if(!o||j.connectstate==-1){return}if(typeof o==="object"){var m="",n=new Uint8Array(o),q=n.byteLength;for(var p=0;p<q;p++){m+=String.fromCharCode(n[p])}o=m}else{if(typeof o!=="string"){return}}if((typeof args!="undefined")&&args.redirtrace){console.log("RedirRecv",typeof o,o.length,o)}return j.m.ProcessData(o)};j.sendText=function(m){if(typeof m!="string"){m=JSON.stringify(m)}j.send(encode_utf8(m))};j.send=function(q){if((typeof args!="undefined")&&args.redirtrace){console.log("RedirSend",typeof q,q.length,q)}try{if(j.socket!=null&&j.socket.readyState==WebSocket.OPEN){if(typeof q=="string"){if(j.debugmode==1){var m=new Uint8Array(q.length),n=[];for(var p=0;p<q.length;++p){m[p]=q.charCodeAt(p);n.push(q.charCodeAt(p))}if(j.webRtcActive==true){j.webchannel.send(m.buffer)}else{j.socket.send(m.buffer)}}else{var m=new Uint8Array(q.length);for(var p=0;p<q.length;++p){m[p]=q.charCodeAt(p)}if(j.webRtcActive==true){j.webchannel.send(m.buffer)}else{j.socket.send(m.buffer)}}}else{if(j.webRtcActive==true){j.webchannel.send(q)}else{j.socket.send(q)}}}}catch(o){}};j.xxOnSocketClosed=function(){j.Stop(1)};j.xxStateChange=function(m){if(j.State==m){return}j.State=m;j.m.xxStateChange(j.State);if(j.onStateChanged!=null){j.onStateChanged(j,j.State)}};j.xxCloseWebRTC=function(){if(j.webchannel!=null){try{j.webchannel.close()}catch(m){}j.webchannel=null}if(j.webrtc!=null){try{j.webrtc.close()}catch(m){}j.webrtc=null}j.webRtcActive=false};j.Stop=function(n){if(j.debugmode==1){console.log("stop",n)}j.xxCloseWebRTC();j.connectstate=-1;if(j.socket!=null){try{if(j.socket.readyState==1){j.sendCtrlMsg('{"ctrlChannel":"102938","type":"close"}');j.socket.close()}}catch(m){}j.socket=null}j.xxStateChange(0)};return j};var CreateKvmDataChannel=function(h,e,d){var g={};g.m=e;e.parent=g;g.webchannel=h;g.State=0;g.protocol=e.protocol;g.onStateChanged=null;g.onControlMsg=null;g.debugmode=0;g.keepalive=d;g.rtcKeepAlive=null;g.Start=function(){if(g.debugmode==1){console.log("start")}g.xxStateChange(3);g.webchannel.onmessage=g.xxOnMessage;g.rtcKeepAlive=setInterval(g.xxSendRtcKeepAlive,30000)};var a=new FileReader();var c=false,b=[];if(a.readAsBinaryString){a.onload=function(j){g.xxOnSocketData(j.target.result);if(b.length==0){c=false}else{a.readAsBinaryString(new Blob([b.shift()]))}}}else{if(a.readAsArrayBuffer){a.onloadend=function(j){g.xxOnSocketData(j.target.result);if(b.length==0){c=false}else{a.readAsArrayBuffer(b.shift())}}}}g.xxOnMessage=function(l){if(typeof l.data=="string"){if(g.onControlMsg!=null){g.onControlMsg(l.data)}return}if(typeof l.data=="object"){if(c==true){b.push(l.data);return}if(a.readAsBinaryString){c=true;a.readAsBinaryString(new Blob([l.data]))}else{if(f.readAsArrayBuffer){c=true;a.readAsArrayBuffer(l.data)}else{var j="",k=new Uint8Array(l.data),n=k.byteLength;for(var m=0;m<n;m++){j+=String.fromCharCode(k[m])}g.xxOnSocketData(j)}}}else{g.xxOnSocketData(l.data)}};g.xxOnSocketData=function(l){if(!l){return}if(typeof l==="object"){var j="",k=new Uint8Array(l),n=k.byteLength;for(var m=0;m<n;m++){j+=String.fromCharCode(k[m])}l=j}else{if(typeof l!=="string"){return}}return g.m.ProcessData(l)};g.sendCtrlMsg=function(j){if(typeof j=="string"){g.webchannel.send(j);if(g.keepalive!=null){g.keepalive.sendKeepAlive()}}};g.send=function(l){if(typeof l=="string"){var j=new Uint8Array(l.length);for(var k=0;k<l.length;++k){j[k]=l.charCodeAt(k)}l=j}g.webchannel.send(l)};g.xxStateChange=function(j){if(g.State==j){return}g.State=j;g.m.xxStateChange(g.State);if(g.onStateChanged!=null){g.onStateChanged(g,g.State)}};g.Stop=function(){if(g.debugmode==1){console.log("stop")}if(g.rtcKeepAlive!=null){clearInterval(g.rtcKeepAlive);g.rtcKeepAlive=null}g.xxStateChange(0)};g.xxSendRtcKeepAlive=function(){g.sendCtrlMsg(JSON.stringify({action:"ping"}))};return g};var CreateAgentRemoteDesktop=function(a,e){var d={};d.CanvasId=a;if(typeof a==="string"){d.CanvasId=Q(a)}d.Canvas=d.CanvasId.getContext("2d");d.scrolldiv=e;d.State=0;d.PendingOperations=[];d.tilesReceived=0;d.TilesDrawn=0;d.KillDraw=0;d.ipad=false;d.tabletKeyboardVisible=false;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=false;d.localKeyMap=true;d.altPressed=false;d.ctrlPressed=false;d.shiftPressed=false;d.sessionid=0;d.username;d.oldie=false;d.CompressionLevel=50;d.ScalingLevel=1024;d.FrameRateTimer=50;d.FirstDraw=false;d.ScreenWidth=960;d.ScreenHeight=700;d.width=960;d.height=960;d.onScreenSizeChange=null;d.onMessage=null;d.onConnectCountChanged=null;d.onDebugMessage=null;d.onTouchEnabledChanged=null;d.onDisplayinfo=null;d.accumulator=null;d.Start=function(){d.State=0;d.accumulator=null};d.Stop=function(){d.setRotation(0);d.UnGrabKeyInput();d.UnGrabMouseInput();d.touchenabled=0;if(d.onScreenSizeChange!=null){d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)}d.Canvas.clearRect(0,0,d.CanvasId.width,d.CanvasId.height)};d.xxStateChange=function(g){if(d.State==g){return}d.State=g;d.CanvasId.style.cursor="default";switch(g){case 0:d.Stop();break;case 3:break}};d.send=function(g){if(d.debugmode>1){console.log("KSend("+g.length+"): "+rstr2hex(g))}d.parent.send(g)};d.ProcessPictureMsg=function(h,k,l){var j=new Image();j.xcount=d.tilesReceived++;var g=d.tilesReceived;j.src="data:image/jpeg;base64,"+btoa(h.substring(4,h.length));j.onload=function(){if(d.Canvas!=null&&d.KillDraw<g&&d.State!=0){d.PendingOperations.push([g,2,j,k,l]);while(d.DoPendingOperations()){}}};j.error=function(){console.log("DecodeTileError")}};d.DoPendingOperations=function(){if(d.PendingOperations.length==0){return false}for(var g=0;g<d.PendingOperations.length;g++){var h=d.PendingOperations[g];if(h[0]==(d.TilesDrawn+1)){if(h[1]==1){d.ProcessCopyRectMsg(h[2])}else{if(h[1]==2){d.Canvas.drawImage(h[2],d.rotX(h[3],h[4]),d.rotY(h[3],h[4]));delete h[2]}}d.PendingOperations.splice(g,1);delete h;d.TilesDrawn++;if(d.TilesDrawn==d.tilesReceived&&d.KillDraw<d.TilesDrawn){d.KillDraw=d.TilesDrawn=d.tilesReceived=0}return true}}if(d.oldie&&d.PendingOperations.length>0){d.TilesDrawn++}return false};d.ProcessCopyRectMsg=function(k){var l=((k.charCodeAt(0)&255)<<8)+(k.charCodeAt(1)&255);var m=((k.charCodeAt(2)&255)<<8)+(k.charCodeAt(3)&255);var g=((k.charCodeAt(4)&255)<<8)+(k.charCodeAt(5)&255);var h=((k.charCodeAt(6)&255)<<8)+(k.charCodeAt(7)&255);var n=((k.charCodeAt(8)&255)<<8)+(k.charCodeAt(9)&255);var j=((k.charCodeAt(10)&255)<<8)+(k.charCodeAt(11)&255);d.Canvas.drawImage(Canvas.canvas,l,m,n,j,g,h,n,j)};d.SendUnPause=function(){d.send(String.fromCharCode(0,8,0,5,0))};d.SendPause=function(){d.send(String.fromCharCode(0,8,0,5,1))};d.SendCompressionLevel=function(k,h,j,g){if(h){d.CompressionLevel=h}if(j){d.ScalingLevel=j}if(g){d.FrameRateTimer=g}d.send(String.fromCharCode(0,5,0,10,k,d.CompressionLevel)+d.shortToStr(d.ScalingLevel)+d.shortToStr(d.FrameRateTimer))};d.SendRefresh=function(){d.send(String.fromCharCode(0,6,0,4))};d.ProcessScreenMsg=function(h,g){if(d.debugmode>0){console.log("ScreenSize: "+h+" x "+g)}d.Canvas.setTransform(1,0,0,1,0,0);d.rotation=0;d.FirstDraw=true;d.ScreenWidth=d.width=h;d.ScreenHeight=d.height=g;d.KillDraw=d.tilesReceived;while(d.PendingOperations.length>0){d.PendingOperations.shift()}d.SendCompressionLevel(1);d.SendUnPause();if(d.onScreenSizeChange!=null){d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)}};d.ProcessData=function(h){var g=0;while(g<h.length){g+=d.ProcessDataEx(h.substring(g))}};d.ProcessDataEx=function(q){if(d.accumulator!=null){q=d.accumulator+q;d.accumulator=null}if(d.debugmode>1){console.log("KRecv("+q.length+"): "+rstr2hex(q.substring(0,Math.min(q.length,40))))}if(q.length<4){return}var g=null,r=0,s=0,j=ReadShort(q,0),h=ReadShort(q,2),o=0;if((j==27)&&(h==8)){if(q.length<12){return}j=ReadShort(q,8);h=ReadInt(q,4);if((h+8)>q.length){d.accumulator=q;return}q=q.substring(8);o=8}if((h!=q.length)&&(d.debugmode>0)){console.log(h,q.length,h==q.length)}if((j>=18)&&(j!=65)){console.error("Invalid KVM command "+j+" of size "+h);console.log("Invalid KVM data",q.length,rstr2hex(q.substring(0,40))+"...");return}if(h>q.length){d.accumulator=q;return}if(j==3||j==4||j==7){g=q.substring(4,h);r=((g.charCodeAt(0)&255)<<8)+(g.charCodeAt(1)&255);s=((g.charCodeAt(2)&255)<<8)+(g.charCodeAt(3)&255);if(d.debugmode>0){console.log("CMD"+j+" at X="+r+" Y="+s)}}switch(j){case 3:if(d.FirstDraw){d.onResize()}d.ProcessPictureMsg(g,r,s);break;case 4:if(d.FirstDraw){d.onResize()}if(d.TilesDrawn==d.tilesReceived){d.ProcessCopyRectMsg(g)}else{d.PendingOperations.push([++tilesReceived,1,g])}break;case 7:d.ProcessScreenMsg(r,s);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 p=0,m={},k=((q.charCodeAt(4)&255)<<8)+(q.charCodeAt(5)&255);if(k>0){p=((q.charCodeAt(6+(k*2))&255)<<8)+(q.charCodeAt(7+(k*2))&255);for(var n=0;n<k;n++){var l=((q.charCodeAt(6+(n*2))&255)<<8)+(q.charCodeAt(7+(n*2))&255);if(l==65535){m[l]="All Displays"}else{m[l]="Display "+l}}}if(d.onDisplayinfo!=null){d.onDisplayinfo(d,m,p)}break;case 12:break;case 14:d.touchenabled=1;d.TouchArray={};if(d.onTouchEnabledChanged!=null){d.onTouchEnabledChanged(d.touchenabled)}break;case 15:d.TouchArray={};break;case 16:d.connectioncount=ReadInt(q,4);if(d.onConnectCountChanged!=null){d.onConnectCountChanged(d.connectioncount,d)}break;case 17:if(d.onMessage!=null){d.onMessage(q.substring(4,h),d)}break;case 65:q=q.substring(4);if(q[0]!="."){console.log(q);d.parent.consoleMessage=q;if(d.parent.onConsoleMessageChange){d.parent.onConsoleMessageChange(d.parent,q)}}else{console.log("KVM: "+q.substring(1))}break}return h+o};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};d.Alternate=0;var c={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 b(g){if(g.code.startsWith("Key")&&g.code.length==4){return g.code.charCodeAt(3)}if(g.code.startsWith("Digit")&&g.code.length==6){return g.code.charCodeAt(5)}if(g.code.startsWith("Numpad")&&g.code.length==7){return g.code.charCodeAt(6)+48}return c[g.code]}d.SendKeyMsg=function(g,h){if(g==null){return}if(!h){h=window.event}if(h.code&&(d.localKeyMap==false)){var j=b(h);if(j!=null){d.SendKeyMsgKC(g,j)}}else{var j=h.keyCode;if(j==59){j=186}else{if(j==173){j=189}else{if(j==61){j=187}}}d.SendKeyMsgKC(g,j)}};d.SendMessage=function(g){if(d.State==3){d.send(String.fromCharCode(0,17)+d.shortToStr(4+g.length)+g)}};d.SendKeyMsgKC=function(g,j){if(d.State!=3){return}if(typeof g=="object"){for(var h in g){d.SendKeyMsgKC(g[h][0],g[h][1])}}else{d.send(String.fromCharCode(0,d.InputType.KEY,0,6,(g-1),j))}};d.sendcad=function(){d.SendCtrlAltDelMsg()};d.SendCtrlAltDelMsg=function(){if(d.State==3){d.send(String.fromCharCode(0,d.InputType.CTRLALTDEL,0,4))}};d.SendEscKey=function(){if(d.State==3){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(h,g,j,k){if(d.State==3){d.send(String.fromCharCode(0,d.InputType.TOUCH)+d.shortToStr(14)+String.fromCharCode(1,h)+d.intToStr(g)+d.shortToStr(j)+d.shortToStr(k))}};d.SendTouchMsg2=function(j,g){var m="";var h;var n="TOUCHSEND: ";for(var l in d.TouchArray){if(l==j){h=g}else{if(d.TouchArray[l].f==1){h=65536|2|4;d.TouchArray[l].f=3;n+="START"+l}else{if(d.TouchArray[l].f==2){h=262144;n+="STOP"+l}else{h=2|4|131072}}}m+=String.fromCharCode(l)+d.intToStr(h)+d.shortToStr(d.TouchArray[l].x)+d.shortToStr(d.TouchArray[l].y);if(d.TouchArray[l].f==2){delete d.TouchArray[l]}}if(d.State==3){d.send(String.fromCharCode(0,d.InputType.TOUCH)+d.shortToStr(5+m.length)+String.fromCharCode(2)+m)}if(Object.keys(d.TouchArray).length==0&&d.touchtimer!=null){clearInterval(d.touchtimer);d.touchtimer=null}};d.SendMouseMsg=function(g,k){if(d.State!=3){return}if(g!=null&&d.Canvas!=null){if(!k){var k=window.event}var n=(d.Canvas.canvas.height/d.CanvasId.clientHeight);var o=(d.Canvas.canvas.width/d.CanvasId.clientWidth);var m=d.GetPositionOfControl(d.Canvas.canvas);var p=((k.pageX-m[0])*o);var q=((k.pageY-m[1])*n);if(k.addx){p+=k.addx}if(k.addy){q+=k.addy}if(p>=0&&p<=d.Canvas.canvas.width&&q>=0&&q<=d.Canvas.canvas.height){var h=0;var j=0;if(g==d.KeyAction.UP||g==d.KeyAction.DOWN){if(k.which){((k.which==1)?(h=d.MouseButton.LEFT):((k.which==2)?(h=d.MouseButton.MIDDLE):(h=d.MouseButton.RIGHT)))}else{if(k.button){((k.button==0)?(h=d.MouseButton.LEFT):((k.button==1)?(h=d.MouseButton.MIDDLE):(h=d.MouseButton.RIGHT)))}}}else{if(g==d.KeyAction.SCROLL){if(k.detail){j=(-1*(k.detail*120))}else{if(k.wheelDelta){j=(k.wheelDelta*3)}}}}var l="";if(g==d.KeyAction.DBLCLICK){l=String.fromCharCode(0,d.InputType.MOUSE,0,10,0,136,((p/256)&255),(p&255),((q/256)&255),(q&255))}else{if(g==d.KeyAction.SCROLL){l=String.fromCharCode(0,d.InputType.MOUSE,0,12,0,0,((p/256)&255),(p&255),((q/256)&255),(q&255),((j/256)&255),(j&255))}else{l=String.fromCharCode(0,d.InputType.MOUSE,0,10,0,((g==d.KeyAction.DOWN)?h:((h*2)&255)),((p/256)&255),(p&255),((q/256)&255),(q&255))}}if(d.Action==d.KeyAction.NONE){if(d.Alternate==0||d.ipad){d.send(l);d.Alternate=1}else{d.Alternate=0}}else{d.send(l)}}}};d.GetDisplayNumbers=function(){d.send(String.fromCharCode(0,11,0,4))};d.SetDisplay=function(g){console.log("Set display",g);d.send(String.fromCharCode(0,12,0,6,g>>8,g&255))};d.intToStr=function(g){return String.fromCharCode((g>>24)&255,(g>>16)&255,(g>>8)&255,g&255)};d.shortToStr=function(g){return String.fromCharCode((g>>8)&255,g&255)};d.onResize=function(){if(d.ScreenWidth==0||d.ScreenHeight==0){return}if(d.Canvas.canvas.width==d.ScreenWidth&&d.Canvas.canvas.height==d.ScreenHeight){return}if(d.FirstDraw){d.Canvas.canvas.width=d.ScreenWidth;d.Canvas.canvas.height=d.ScreenHeight;d.Canvas.fillRect(0,0,d.ScreenWidth,d.ScreenHeight);if(d.onScreenSizeChange!=null){d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)}}d.FirstDraw=false};d.xxMouseInputGrab=false;d.xxKeyInputGrab=false;d.xxMouseMove=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.NONE,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxMouseUp=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.UP,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxMouseDown=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.DOWN,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxMouseDblClick=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.DBLCLICK,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxDOMMouseScroll=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.SCROLL,g);return false}return true};d.xxMouseWheel=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.SCROLL,g);return false}return true};d.xxKeyUp=function(g){if(d.State==3){d.SendKeyMsg(d.KeyAction.UP,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxKeyDown=function(g){if(d.State==3){d.SendKeyMsg(d.KeyAction.DOWN,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxKeyPress=function(g){if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.handleKeys=function(g){if(d.stopInput==true||desktop.State!=3){return false}return d.xxKeyPress(g)};d.handleKeyUp=function(g){if(d.stopInput==true||desktop.State!=3){return false}if(d.firstUpKeys.length<5){d.firstUpKeys.push(g.keyCode);if((d.firstUpKeys.length==5)){var h=d.firstUpKeys.join(",");if((h=="16,17,91,91,16")||(h=="16,17,18,91,92")){d.stopInput=true}}}if(g.keyCode==16){d.shiftPressed=false}if(g.keyCode==17){d.ctrlPressed=false}if(g.keyCode==18){d.altPressed=false}return d.xxKeyUp(g)};d.handleKeyDown=function(g){if(d.stopInput==true||desktop.State!=3){return false}if(g.keyCode==16){d.shiftPressed=true}if(g.keyCode==17){d.ctrlPressed=true}if(g.keyCode==18){d.altPressed=true}return d.xxKeyDown(g)};d.handleReleaseKeys=function(){if(d.shiftPressed){d.SendKeyMsgKC(d.KeyAction.UP,16)}if(d.ctrlPressed){d.SendKeyMsgKC(d.KeyAction.UP,17)}if(d.altPressed){d.SendKeyMsgKC(d.KeyAction.UP,18)}d.shiftPressed=d.ctrlPressed=d.altPressed=false};d.mousedblclick=function(g){if(d.stopInput==true){return false}return d.xxMouseDblClick(g)};d.mousedown=function(g){if(d.stopInput==true){return false}return d.xxMouseDown(g)};d.mouseup=function(g){if(d.stopInput==true){return false}return d.xxMouseUp(g)};d.mousemove=function(g){if(d.stopInput==true){return false}return d.xxMouseMove(g)};d.mousewheel=function(g){if(d.stopInput==true){return false}return d.xxMouseWheel(g)};d.xxMsTouchEvent=function(g){if(g.originalEvent.pointerType==4){return}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}if(g.type=="MSPointerDown"||g.type=="MSPointerMove"||g.type=="MSPointerUp"){var h=0;var j=g.originalEvent.pointerId%256;var k=g.offsetX*(Canvas.canvas.width/d.CanvasId.clientWidth);var l=g.offsetY*(Canvas.canvas.height/d.CanvasId.clientHeight);if(g.type=="MSPointerDown"){h=65536|2|4}else{if(g.type=="MSPointerMove"){h=131072|2|4}else{if(g.type=="MSPointerUp"){h=262144}}}if(!d.TouchArray[j]){d.TouchArray[j]={x:k,y:l}}d.SendTouchMsg2(j,h);if(g.type=="MSPointerUp"){delete d.TouchArray[j]}}else{alert(g.type)}return true};d.xxTouchStart=function(g){if(d.State!=3){return}if(g.preventDefault){g.preventDefault()}if(d.touchenabled==0||d.touchenabled==1){if(g.originalEvent.touches.length>1){return}var l=g.originalEvent.touches[0];g.which=1;d.LastX=g.pageX=l.pageX;d.LastY=g.pageY=l.pageY;d.SendMouseMsg(KeyAction.DOWN,g)}else{var k=d.GetPositionOfControl(Canvas.canvas);for(var h in g.originalEvent.changedTouches){if(!g.originalEvent.changedTouches[h].identifier){continue}var j=g.originalEvent.changedTouches[h].identifier%256;if(!d.TouchArray[j]){d.TouchArray[j]={x:(g.originalEvent.touches[h].pageX-k[0])*(Canvas.canvas.width/d.CanvasId.clientWidth),y:(g.originalEvent.touches[h].pageY-k[1])*(Canvas.canvas.height/d.CanvasId.clientHeight),f:1}}}if(Object.keys(d.TouchArray).length>0&&touchtimer==null){d.touchtimer=setInterval(function(){d.SendTouchMsg2(256,0)},50)}}};d.xxTouchMove=function(g){if(d.State!=3){return}if(g.preventDefault){g.preventDefault()}if(d.touchenabled==0||d.touchenabled==1){if(g.originalEvent.touches.length>1){return}var l=g.originalEvent.touches[0];g.which=1;d.LastX=g.pageX=l.pageX;d.LastY=g.pageY=l.pageY;d.SendMouseMsg(d.KeyAction.NONE,g)}else{var k=d.GetPositionOfControl(Canvas.canvas);for(var h in g.originalEvent.changedTouches){if(!g.originalEvent.changedTouches[h].identifier){continue}var j=g.originalEvent.changedTouches[h].identifier%256;if(d.TouchArray[j]){d.TouchArray[j].x=(g.originalEvent.touches[h].pageX-k[0])*(d.Canvas.canvas.width/d.CanvasId.clientWidth);d.TouchArray[j].y=(g.originalEvent.touches[h].pageY-k[1])*(d.Canvas.canvas.height/d.CanvasId.clientHeight)}}}};d.xxTouchEnd=function(g){if(d.State!=3){return}if(g.preventDefault){g.preventDefault()}if(d.touchenabled==0||d.touchenabled==1){if(g.originalEvent.touches.length>1){return}g.which=1;g.pageX=LastX;g.pageY=LastY;d.SendMouseMsg(KeyAction.UP,g)}else{for(var h in g.originalEvent.changedTouches){if(!g.originalEvent.changedTouches[h].identifier){continue}var j=g.originalEvent.changedTouches[h].identifier%256;if(d.TouchArray[j]){d.TouchArray[j].f=2}}}};d.GrabMouseInput=function(){if(d.xxMouseInputGrab==true){return}var g=d.CanvasId;g.onmousemove=d.xxMouseMove;g.onmouseup=d.xxMouseUp;g.onmousedown=d.xxMouseDown;g.touchstart=d.xxTouchStart;g.touchmove=d.xxTouchMove;g.touchend=d.xxTouchEnd;g.MSPointerDown=d.xxMsTouchEvent;g.MSPointerMove=d.xxMsTouchEvent;g.MSPointerUp=d.xxMsTouchEvent;if(navigator.userAgent.match(/mozilla/i)){g.DOMMouseScroll=d.xxDOMMouseScroll}else{g.onmousewheel=d.xxMouseWheel}d.xxMouseInputGrab=true};d.UnGrabMouseInput=function(){if(d.xxMouseInputGrab==false){return}var g=d.CanvasId;g.onmousemove=null;g.onmouseup=null;g.onmousedown=null;g.touchstart=null;g.touchmove=null;g.touchend=null;g.MSPointerDown=null;g.MSPointerMove=null;g.MSPointerUp=null;if(navigator.userAgent.match(/mozilla/i)){g.DOMMouseScroll=null}else{g.onmousewheel=null}d.xxMouseInputGrab=false};d.GrabKeyInput=function(){if(d.xxKeyInputGrab==true){return}document.onkeyup=d.xxKeyUp;document.onkeydown=d.xxKeyDown;document.onkeypress=d.xxKeyPress;d.xxKeyInputGrab=true};d.UnGrabKeyInput=function(){if(d.xxKeyInputGrab==false){return}document.onkeyup=null;document.onkeydown=null;document.onkeypress=null;d.xxKeyInputGrab=false};d.GetPositionOfControl=function(g){var h=Array(2);h[0]=h[1]=0;while(g){h[0]+=g.offsetLeft;h[1]+=g.offsetTop;g=g.offsetParent}return h};d.crotX=function(g,h){if(d.rotation==0){return g}if(d.rotation==1){return h}if(d.rotation==2){return d.Canvas.canvas.width-g}if(d.rotation==3){return d.Canvas.canvas.height-h}};d.crotY=function(g,h){if(d.rotation==0){return h}if(d.rotation==1){return d.Canvas.canvas.width-g}if(d.rotation==2){return d.Canvas.canvas.height-h}if(d.rotation==3){return g}};d.rotX=function(g,h){if(d.rotation==0||d.rotation==1){return g}if(d.rotation==2){return g-d.Canvas.canvas.width}if(d.rotation==3){return g-d.Canvas.canvas.height}};d.rotY=function(g,h){if(d.rotation==0||d.rotation==3){return h}if(d.rotation==1){return h-d.Canvas.canvas.width}if(d.rotation==2){return h-d.Canvas.canvas.height}};d.tcanvas=null;d.setRotation=function(l){while(l<0){l+=4}var g=l%4;if(g==d.rotation){return true}var j=d.Canvas.canvas.width;var h=d.Canvas.canvas.height;if(d.rotation==1||d.rotation==3){j=d.Canvas.canvas.height;h=d.Canvas.canvas.width}if(d.tcanvas==null){d.tcanvas=document.createElement("canvas")}var k=d.tcanvas.getContext("2d");k.setTransform(1,0,0,1,0,0);k.canvas.width=j;k.canvas.height=h;k.rotate((d.rotation*-90)*Math.PI/180);if(d.rotation==0){k.drawImage(d.Canvas.canvas,0,0)}if(d.rotation==1){k.drawImage(d.Canvas.canvas,-d.Canvas.canvas.width,0)}if(d.rotation==2){k.drawImage(d.Canvas.canvas,-d.Canvas.canvas.width,-d.Canvas.canvas.height)}if(d.rotation==3){k.drawImage(d.Canvas.canvas,0,-d.Canvas.canvas.height)}if(d.rotation==0||d.rotation==2){d.Canvas.canvas.height=j;d.Canvas.canvas.width=h}if(d.rotation==1||d.rotation==3){d.Canvas.canvas.height=h;d.Canvas.canvas.width=j}d.Canvas.setTransform(1,0,0,1,0,0);d.Canvas.rotate((g*90)*Math.PI/180);d.rotation=g;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;if(d.onScreenSizeChange!=null){d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)}return true};d.MuchTheSame=function(g,h){return(Math.abs(g-h)<4)};d.Debug=function(g){console.log(g)};d.getIEVersion=function(){var g=-1;if(navigator.appName=="Microsoft Internet Explorer"){var j=navigator.userAgent;var h=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");if(h.exec(j)!=null){g=parseFloat(RegExp.$1)}}return g};d.haltEvent=function(g){if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};return d};var QRCode;!function(){function t(c){this.mode=v.MODE_8BIT_BYTE,this.data=c,this.parsedData=[];for(var g=[],h=0,j=this.data.length;j>h;h++){var k=this.data.charCodeAt(h);k>65536?(g[0]=240|(1835008&k)>>>18,g[1]=128|(258048&k)>>>12,g[2]=128|(4032&k)>>>6,g[3]=128|63&k):k>2048?(g[0]=224|(61440&k)>>>12,g[1]=128|(4032&k)>>>6,g[2]=128|63&k):k>128?(g[0]=192|(1984&k)>>>6,g[1]=128|63&k):g[0]=k,this.parsedData=this.parsedData.concat(g)}this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function u(c,d){this.typeNumber=c,this.errorCorrectLevel=d,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function B(e,g){if(void 0==e.length){throw new Error(e.length+"/"+g)}for(var h=0;h<e.length&&0==e[h];){h++}this.num=new Array(e.length-h+g);for(var j=0;j<e.length-h;j++){this.num[j]=e[j+h]}}function C(c,d){this.totalCount=c,this.dataCount=d}function D(){this.buffer=[],this.length=0}function F(){return"undefined"!=typeof CanvasRenderingContext2D}function G(){var c=!1,d=navigator.userAgent;return/android/i.test(d)&&(c=!0,aMat=d.toString().match(/android ([0-9]\.[0-9])/i),aMat&&aMat[1]&&(c=parseFloat(aMat[1]))),c}function K(d,j){for(var k=1,l=L(d),m=0,n=E.length;n>=m;m++){var o=0;switch(j){case w.L:o=E[m][0];break;case w.M:o=E[m][1];break;case w.Q:o=E[m][2];break;case w.H:o=E[m][3]}if(o>=l){break}k++}if(k>E.length){throw new Error("Too long data")}return k}function L(c){var d=encodeURI(c).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return d.length+(d.length!=c?3:0)}t.prototype={getLength:function(){return this.parsedData.length},write:function(d){for(var e=0,g=this.parsedData.length;g>e;e++){d.put(this.parsedData[e],8)}}},u.prototype={addData:function(a){var d=new t(a);this.dataList.push(d),this.dataCache=null},isDark:function(c,d){if(0>c||this.moduleCount<=c||0>d||this.moduleCount<=d){throw new Error(c+","+d)}return this.modules[c][d]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(b,g){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var h=0;h<this.moduleCount;h++){this.modules[h]=new Array(this.moduleCount);for(var j=0;j<this.moduleCount;j++){this.modules[h][j]=null}}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(b,g),this.typeNumber>=7&&this.setupTypeNumber(b),null==this.dataCache&&(this.dataCache=u.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,g)},setupPositionProbePattern:function(e,g){for(var h=-1;7>=h;h++){if(!(-1>=e+h||this.moduleCount<=e+h)){for(var j=-1;7>=j;j++){-1>=g+j||this.moduleCount<=g+j||(this.modules[e+h][g+j]=h>=0&&6>=h&&(0==j||6==j)||j>=0&&6>=j&&(0==h||6==h)||h>=2&&4>=h&&j>=2&&4>=j?!0:!1)}}}},getBestMaskPattern:function(){for(var e=0,g=0,h=0;8>h;h++){this.makeImpl(!0,h);var j=y.getLostPoint(this);(0==h||e>j)&&(e=j,g=h)}return g},createMovieClip:function(k,l,m){var n=k.createEmptyMovieClip(l,m),o=1;this.make();for(var p=0;p<this.modules.length;p++){for(var q=p*o,r=0;r<this.modules[p].length;r++){var s=r*o,M=this.modules[p][r];M&&(n.beginFill(0,100),n.moveTo(s,q),n.lineTo(s+o,q),n.lineTo(s+o,q+o),n.lineTo(s,q+o),n.endFill())}}return n},setupTimingPattern:function(){for(var c=8;c<this.moduleCount-8;c++){null==this.modules[c][6]&&(this.modules[c][6]=0==c%2)}for(var d=8;d<this.moduleCount-8;d++){null==this.modules[6][d]&&(this.modules[6][d]=0==d%2)}},setupPositionAdjustPattern:function(){for(var j=y.getPatternPosition(this.typeNumber),k=0;k<j.length;k++){for(var l=0;l<j.length;l++){var m=j[k],n=j[l];if(null==this.modules[m][n]){for(var o=-2;2>=o;o++){for(var p=-2;2>=p;p++){this.modules[m+o][n+p]=-2==o||2==o||-2==p||2==p||0==o&&0==p?!0:!1}}}}}},setupTypeNumber:function(e){for(var g=y.getBCHTypeNumber(this.typeNumber),h=0;18>h;h++){var j=!e&&1==(1&g>>h);this.modules[Math.floor(h/3)][h%3+this.moduleCount-8-3]=j}for(var h=0;18>h;h++){var j=!e&&1==(1&g>>h);this.modules[h%3+this.moduleCount-8-3][Math.floor(h/3)]=j}},setupTypeInfo:function(h,j){for(var k=this.errorCorrectLevel<<3|j,l=y.getBCHTypeInfo(k),m=0;15>m;m++){var n=!h&&1==(1&l>>m);6>m?this.modules[m][8]=n:8>m?this.modules[m+1][8]=n:this.modules[this.moduleCount-15+m][8]=n}for(var m=0;15>m;m++){var n=!h&&1==(1&l>>m);8>m?this.modules[8][this.moduleCount-m-1]=n:9>m?this.modules[8][15-m-1+1]=n:this.modules[8][15-m-1]=n}this.modules[this.moduleCount-8][8]=!h},mapData:function(l,m){for(var n=-1,o=this.moduleCount-1,p=7,q=0,r=this.moduleCount-1;r>0;r-=2){for(6==r&&r--;;){for(var s=0;2>s;s++){if(null==this.modules[o][r-s]){var M=!1;q<l.length&&(M=1==(1&l[q]>>>p));var N=y.getMask(m,o,r-s);N&&(M=!M),this.modules[o][r-s]=M,p--,-1==p&&(q++,p=7)}}if(o+=n,0>o||this.moduleCount<=o){o-=n,n=-n;break}}}}},u.PAD0=236,u.PAD1=17,u.createData=function(b,j,k){for(var m=C.getRSBlocks(b,j),n=new D,o=0;o<k.length;o++){var p=k[o];n.put(p.mode,4),n.put(p.getLength(),y.getLengthInBits(p.mode,b)),p.write(n)}for(var q=0,o=0;o<m.length;o++){q+=m[o].dataCount}if(n.getLengthInBits()>8*q){throw new Error("code length overflow. ("+n.getLengthInBits()+">"+8*q+")")}for(n.getLengthInBits()+4<=8*q&&n.put(0,4);0!=n.getLengthInBits()%8;){n.putBit(!1)}for(;;){if(n.getLengthInBits()>=8*q){break}if(n.put(u.PAD0,8),n.getLengthInBits()>=8*q){break}n.put(u.PAD1,8)}return u.createBytes(n,m)},u.createBytes=function(M,N){for(var O=0,P=0,R=0,S=new Array(N.length),T=new Array(N.length),U=0;U<N.length;U++){var V=N[U].dataCount,W=N[U].totalCount-V;P=Math.max(P,V),R=Math.max(R,W),S[U]=new Array(V);for(var X=0;X<S[U].length;X++){S[U][X]=255&M.buffer[X+O]}O+=V;var Y=y.getErrorCorrectPolynomial(W),Z=new B(S[U],Y.getLength()-1),aa=Z.mod(Y);T[U]=new Array(Y.getLength()-1);for(var X=0;X<T[U].length;X++){var ab=X+aa.getLength()-T[U].length;T[U][X]=ab>=0?aa.get(ab):0}}for(var ac=0,X=0;X<N.length;X++){ac+=N[X].totalCount}for(var ad=new Array(ac),ae=0,X=0;P>X;X++){for(var U=0;U<N.length;U++){X<S[U].length&&(ad[ae++]=S[U][X])}}for(var X=0;R>X;X++){for(var U=0;U<N.length;U++){X<T[U].length&&(ad[ae++]=T[U][X])}}return ad};for(var v={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},w={L:1,M:0,Q:3,H:2},x={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},y={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(c){for(var d=c<<10;y.getBCHDigit(d)-y.getBCHDigit(y.G15)>=0;){d^=y.G15<<y.getBCHDigit(d)-y.getBCHDigit(y.G15)}return(c<<10|d)^y.G15_MASK},getBCHTypeNumber:function(c){for(var d=c<<12;y.getBCHDigit(d)-y.getBCHDigit(y.G18)>=0;){d^=y.G18<<y.getBCHDigit(d)-y.getBCHDigit(y.G18)}return c<<12|d},getBCHDigit:function(c){for(var d=0;0!=c;){d++,c>>>=1}return d},getPatternPosition:function(b){return y.PATTERN_POSITION_TABLE[b-1]},getMask:function(d,e,g){switch(d){case x.PATTERN000:return 0==(e+g)%2;case x.PATTERN001:return 0==e%2;case x.PATTERN010:return 0==g%3;case x.PATTERN011:return 0==(e+g)%3;case x.PATTERN100:return 0==(Math.floor(e/2)+Math.floor(g/3))%2;case x.PATTERN101:return 0==e*g%2+e*g%3;case x.PATTERN110:return 0==(e*g%2+e*g%3)%2;case x.PATTERN111:return 0==(e*g%3+(e+g)%2)%2;default:throw new Error("bad maskPattern:"+d)}},getErrorCorrectPolynomial:function(d){for(var e=new B([1],0),g=0;d>g;g++){e=e.multiply(new B([1,z.gexp(g)],0))}return e},getLengthInBits:function(c,d){if(d>=1&&10>d){switch(c){case v.MODE_NUMBER:return 10;case v.MODE_ALPHA_NUM:return 9;case v.MODE_8BIT_BYTE:return 8;case v.MODE_KANJI:return 8;default:throw new Error("mode:"+c)}}else{if(27>d){switch(c){case v.MODE_NUMBER:return 12;case v.MODE_ALPHA_NUM:return 11;case v.MODE_8BIT_BYTE:return 16;case v.MODE_KANJI:return 10;default:throw new Error("mode:"+c)}}else{if(!(41>d)){throw new Error("type:"+d)}switch(c){case v.MODE_NUMBER:return 14;case v.MODE_ALPHA_NUM:return 13;case v.MODE_8BIT_BYTE:return 16;case v.MODE_KANJI:return 12;default:throw new Error("mode:"+c)}}}},getLostPoint:function(m){for(var n=m.getModuleCount(),o=0,p=0;n>p;p++){for(var q=0;n>q;q++){for(var r=0,s=m.isDark(p,q),M=-1;1>=M;M++){if(!(0>p+M||p+M>=n)){for(var N=-1;1>=N;N++){0>q+N||q+N>=n||(0!=M||0!=N)&&s==m.isDark(p+M,q+N)&&r++}}}r>5&&(o+=3+r-5)}}for(var p=0;n-1>p;p++){for(var q=0;n-1>q;q++){var O=0;m.isDark(p,q)&&O++,m.isDark(p+1,q)&&O++,m.isDark(p,q+1)&&O++,m.isDark(p+1,q+1)&&O++,(0==O||4==O)&&(o+=3)}}for(var p=0;n>p;p++){for(var q=0;n-6>q;q++){m.isDark(p,q)&&!m.isDark(p,q+1)&&m.isDark(p,q+2)&&m.isDark(p,q+3)&&m.isDark(p,q+4)&&!m.isDark(p,q+5)&&m.isDark(p,q+6)&&(o+=40)}}for(var q=0;n>q;q++){for(var p=0;n-6>p;p++){m.isDark(p,q)&&!m.isDark(p+1,q)&&m.isDark(p+2,q)&&m.isDark(p+3,q)&&m.isDark(p+4,q)&&!m.isDark(p+5,q)&&m.isDark(p+6,q)&&(o+=40)}}for(var P=0,q=0;n>q;q++){for(var p=0;n>p;p++){m.isDark(p,q)&&P++}}var R=Math.abs(100*P/n/n-50)/5;return o+=10*R}},z={glog:function(b){if(1>b){throw new Error("glog("+b+")")}return z.LOG_TABLE[b]},gexp:function(b){for(;0>b;){b+=255}for(;b>=256;){b-=255}return z.EXP_TABLE[b]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},A=0;8>A;A++){z.EXP_TABLE[A]=1<<A}for(var A=8;256>A;A++){z.EXP_TABLE[A]=z.EXP_TABLE[A-4]^z.EXP_TABLE[A-5]^z.EXP_TABLE[A-6]^z.EXP_TABLE[A-8]}for(var A=0;255>A;A++){z.LOG_TABLE[z.EXP_TABLE[A]]=A}B.prototype={get:function(b){return this.num[b]},getLength:function(){return this.num.length},multiply:function(e){for(var g=new Array(this.getLength()+e.getLength()-1),h=0;h<this.getLength();h++){for(var j=0;j<e.getLength();j++){g[h+j]^=z.gexp(z.glog(this.get(h))+z.glog(e.get(j)))}}return new B(g,0)},mod:function(e){if(this.getLength()-e.getLength()<0){return this}for(var g=z.glog(this.get(0))-z.glog(e.get(0)),h=new Array(this.getLength()),j=0;j<this.getLength();j++){h[j]=this.get(j)}for(var j=0;j<e.getLength();j++){h[j]^=z.gexp(z.glog(e.get(j))+g)}return new B(h,0).mod(e)}},C.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],C.getRSBlocks=function(j,l){var m=C.getRsBlockTable(j,l);if(void 0==m){throw new Error("bad rs block @ typeNumber:"+j+"/errorCorrectLevel:"+l)}for(var n=m.length/3,o=[],p=0;n>p;p++){for(var q=m[3*p+0],r=m[3*p+1],s=m[3*p+2],M=0;q>M;M++){o.push(new C(r,s))}}return o},C.getRsBlockTable=function(c,d){switch(d){case w.L:return C.RS_BLOCK_TABLE[4*(c-1)+0];case w.M:return C.RS_BLOCK_TABLE[4*(c-1)+1];case w.Q:return C.RS_BLOCK_TABLE[4*(c-1)+2];case w.H:return C.RS_BLOCK_TABLE[4*(c-1)+3];default:return void 0}},D.prototype={get:function(c){var d=Math.floor(c/8);return 1==(1&this.buffer[d]>>>7-c%8)},put:function(d,e){for(var g=0;e>g;g++){this.putBit(1==(1&d>>>e-g-1))}},getLengthInBits:function(){return this.length},putBit:function(c){var d=Math.floor(this.length/8);this.buffer.length<=d&&this.buffer.push(0),c&&(this.buffer[d]|=128>>>this.length%8),this.length++}};var E=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]],H=function(){var b=function(c,d){this._el=c,this._htOption=d};return b.prototype.draw=function(e){function o(g,h){var j=document.createElementNS("http://www.w3.org/2000/svg",g);for(var k in h){h.hasOwnProperty(k)&&j.setAttribute(k,h[k])}return j}var l=this._htOption,m=this._el,n=e.getModuleCount();Math.floor(l.width/n),Math.floor(l.height/n),this.clear();var p=o("svg",{viewBox:"0 0 "+String(n)+" "+String(n),width:"100%",height:"100%",fill:l.colorLight});p.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),m.appendChild(p),p.appendChild(o("rect",{fill:l.colorDark,width:"1",height:"1",id:"template"}));for(var q=0;n>q;q++){for(var r=0;n>r;r++){if(e.isDark(q,r)){var s=o("use",{x:String(q),y:String(r)});s.setAttributeNS("http://www.w3.org/1999/xlink","href","#template"),p.appendChild(s)}}}},b.prototype.clear=function(){for(;this._el.hasChildNodes();){this._el.removeChild(this._el.lastChild)}},b}(),I="svg"===document.documentElement.tagName.toLowerCase(),J=I?H:F()?function(){function g(){this._elImage.src=this._elCanvas.toDataURL("image/png"),this._elImage.style.display="block",this._elCanvas.style.display="none"}function k(m,n){var o=this;if(o._fFail=n,o._fSuccess=m,null===o._bSupportDataURI){var p=document.createElement("img"),q=function(){o._bSupportDataURI=!1,o._fFail&&_fFail.call(o)},r=function(){o._bSupportDataURI=!0,o._fSuccess&&o._fSuccess.call(o)};return p.onabort=q,p.onerror=q,p.onload=r,p.src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",void 0}o._bSupportDataURI===!0&&o._fSuccess?o._fSuccess.call(o):o._bSupportDataURI===!1&&o._fFail&&o._fFail.call(o)}if(this._android&&this._android<=2.1){var h=1/window.devicePixelRatio,j=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(b,c,m,n,o,p,q,r){if("nodeName" in b&&/img/i.test(b.nodeName)){for(var s=arguments.length-1;s>=1;s--){arguments[s]=arguments[s]*h}}else{"undefined"==typeof r&&(arguments[1]*=h,arguments[2]*=h,arguments[3]*=h,arguments[4]*=h)}j.apply(this,arguments)}}var l=function(c,d){this._bIsPainted=!1,this._android=G(),this._htOption=d,this._elCanvas=document.createElement("canvas"),this._elCanvas.width=d.width,this._elCanvas.height=d.height,c.appendChild(this._elCanvas),this._el=c,this._oContext=this._elCanvas.getContext("2d"),this._bIsPainted=!1,this._elImage=document.createElement("img"),this._elImage.style.display="none",this._el.appendChild(this._elImage),this._bSupportDataURI=null};return l.prototype.draw=function(o){var p=this._elImage,q=this._oContext,r=this._htOption,s=o.getModuleCount(),M=r.width/s,N=r.height/s,O=Math.round(M),P=Math.round(N);p.style.display="none",this.clear();for(var R=0;s>R;R++){for(var S=0;s>S;S++){var T=o.isDark(R,S),U=S*M,V=R*N;q.strokeStyle=T?r.colorDark:r.colorLight,q.lineWidth=1,q.fillStyle=T?r.colorDark:r.colorLight,q.fillRect(U,V,M,N),q.strokeRect(Math.floor(U)+0.5,Math.floor(V)+0.5,O,P),q.strokeRect(Math.ceil(U)-0.5,Math.ceil(V)-0.5,O,P)}}this._bIsPainted=!0},l.prototype.makeImage=function(){this._bIsPainted&&k.call(this,g)},l.prototype.isPainted=function(){return this._bIsPainted},l.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height),this._bIsPainted=!1},l.prototype.round=function(b){return b?Math.floor(1000*b)/1000:b},l}():function(){var b=function(c,d){this._el=c,this._htOption=d};return b.prototype.draw=function(m){for(var n=this._htOption,o=this._el,p=m.getModuleCount(),q=Math.floor(n.width/p),r=Math.floor(n.height/p),s=['<table style="border:0;border-collapse:collapse;">'],M=0;p>M;M++){s.push("<tr>");for(var N=0;p>N;N++){s.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:'+q+"px;height:"+r+"px;background-color:"+(m.isDark(M,N)?n.colorDark:n.colorLight)+';"></td>')}s.push("</tr>")}s.push("</table>"),o.innerHTML=s.join("");var O=o.childNodes[0],P=(n.width-O.offsetWidth)/2,R=(n.height-O.offsetHeight)/2;P>0&&R>0&&(O.style.margin=R+"px "+P+"px")},b.prototype.clear=function(){this._el.innerHTML=""},b}();QRCode=function(d,e){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:w.H},"string"==typeof e&&(e={text:e}),e){for(var g in e){this._htOption[g]=e[g]}}"string"==typeof d&&(d=document.getElementById(d)),this._android=G(),this._el=d,this._oQRCode=null,this._oDrawing=new J(this._el,this._htOption),this._htOption.text&&this.makeCode(this._htOption.text)},QRCode.prototype.makeCode=function(b){this._oQRCode=new u(K(b,this._htOption.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(b),this._oQRCode.make(),this._el.title=b,this._oDrawing.draw(this._oQRCode),this.makeImage()},QRCode.prototype.makeImage=function(){"function"==typeof this._oDrawing.makeImage&&(!this._android||this._android>=3)&&this._oDrawing.makeImage()},QRCode.prototype.clear=function(){this._oDrawing.clear()},QRCode.CorrectLevel=w}();"use strict";var webState="{{{webstate}}}";if(webState!=""){webState=JSON.parse(decodeURIComponent(webState))}for(var i in webState){localStorage.setItem(i,webState[i])}var args;var autoReconnect=true;var powerStatetable=["","Powered","Sleep","Sleep","Sleep","Hibernating","Power off","Present"];var StatusStrs=["Disconnected","Connecting...","Setup...","Connected","Intel&reg; AMT Connected"];var sort=0;var searchFocus=0;var mapSearchFocus=0;var userSearchFocus=0;var consoleFocus=0;var showRealNames=false;var meshserver=null;var meshes={};var meshcount=0;var nodes=null;var filetree={};var userinfo=null;var serverinfo=null;var events=[];var users=null;var wssessions=null;var nodeShortIdent=0;var desktop;var desktopsettings={encoding:2,showfocus:false,showmouse:true,showcad:true,quality:40,scaling:1024,framerate:50,localkeymap:false};var multidesktopsettings={quality:20,scaling:128,framerate:1000};var terminal;var files;var debugLevel=parseInt("{{{debuglevel}}}");var features=parseInt("{{{features}}}");var sessionTime=parseInt("{{{sessiontime}}}");var domain="{{{domain}}}";var domainUrl="{{{domainurl}}}";var authCookie="{{{authCookie}}}";var authCookieRenewTimer=null;var multiDesktop={};var multiDesktopFilter=null;var serverPublicNamePort="{{{serverDnsName}}}:{{{serverPublicPort}}}";var amtScanResults=null;var debugmode=0;var clickOnce=(((features&256)!=0)&&detectClickOnce());var attemptWebRTC=((features&128)!=0);var passRequirements="{{{passRequirements}}}";if(passRequirements!=""){passRequirements=JSON.parse(decodeURIComponent(passRequirements))}var deskAspectRatio=0;try{deskAspectRatio=parseInt(getstore("deskAspectRatio","0"))}catch(ex){}var uiMode=parseInt(getstore("uiMode",1));var webPageStackMenu=false;var webPageFullScreen=true;var nightMode=(getstore("_nightMode","0")=="1");var sessionActivity=Date.now();var p11DeskConsoleMsgTimer=null;var p12TermConsoleMsgTimer=null;var p13FilesConsoleMsgTimer=null;function startup(){if((features&32)==0){var h=null;try{h=top.location.toString().toLowerCase()}catch(b){}if(top!=self&&(h==null||top.active==false)){top.location=self.location;return}}args=parseUriArgs();debugmode=args.debug;if(args.webrtc!=null){attemptWebRTC=(args.webrtc==1)}QV("p13AutoConnect",debugmode);QV("autoconnectbutton2",debugmode);QV("autoconnectbutton1",debugmode);if(nightMode){QC("body").add("night")}toggleFullScreen();if(args.hide){var d=parseInt(args.hide);QV("masthead",!(d&1));QV("topbar",!(d&2));QV("footer",!(d&4));QV("p10title",!(d&8));QV("p11title",!(d&8));QV("p12title",!(d&8));QV("p13title",!(d&8));QV("p14title",!(d&8));QV("p15title",!(d&8));QV("p16title",!(d&8));QS("container")["grid-template-rows"]=((d&1)?"0":"66")+"px "+((d&2)?"0":"24")+"px auto "+((d&4)?"0":"45")+"px";QS("container")["-ms-grid-rows"]=((d&1)?"0":"66")+"px "+((d&2)?"0":"24")+"px auto "+((d&4)?"0":"45")+"px";var m=(((d&1)?0:66)+((d&2)?0:24)+((d&4)?0:45)+((d&8)?0:60));QS("p3users")["max-height"]="calc(100vh - "+(124+m)+"px)";QS("p3events")["height"]="calc(100vh - "+(124+m)+"px)";QS("deskarea3x")["height"]="calc(100vh - "+(75+m)+"px)";QS("deskarea3x")["max-height"]="calc(100vh - "+(75+m)+"px)";QS("p5filetable")["height"]="calc(100vh - "+(160+m)+"px)";QS("p13filetable")["height"]="calc(100vh - "+(124+m)+"px)";QS("serverMainStats")["height"]="calc(100vh - "+(110+m)+"px)";QS("serverMainStats")["max-height"]="calc(100vh - "+(110+m)+"px)";QS("xdevices")["max-height"]="calc(100vh - "+(124+m)+"px)";QS("xdevicesmap")["max-height"]="calc(100vh - "+(124+m)+"px)";QS("p15agentConsole")["height"]="calc(100vh - "+(84+m)+"px)";QS("p15agentConsole")["max-height"]="calc(100vh - "+(84+m)+"px)";QS("p15agentConsoleText")["height"]="calc(100vh - "+(81+m)+"px)";QS("p15agentConsoleText")["max-height"]="calc(100vh - "+(81+m)+"px)"}if("{{currentNode}}"!=""){QV("p10BackButton",false);QV("p11BackButton",false);QV("p12BackButton",false);QV("p13BackButton",false);QV("p14BackButton",false);QV("p15BackButton",false);QV("p16BackButton",false)}p1updateInfo();document.onclick=function(c){hideContextMenu()};document.onkeypress=ondockeypress;document.onkeydown=ondockeydown;document.onkeyup=ondockeyup;window.addEventListener("blur",ondocblur,false);window.onresize=function(){masterUpdate(512)};setTimeout("masterUpdate(512)",200);meshserver=MeshServerCreateControl(domainUrl,authCookie);meshserver.onStateChanged=onStateChanged;meshserver.onMessage=onMessage;meshserver.trace=(args.trace==1);meshserver.Start();Q("sortselect").selectedIndex=sort=getstore("sort",0);Q("sizeselect").selectedIndex=getstore("_viewsize",1);Q("SearchInput").value=getstore("_search","");showRealNames=(getstore("showRealNames",0)==1);Q("RealNameCheckBox").checked=showRealNames;Q("viewselect").value=getstore("_deviceView",1);Q("DeskControl").checked=(getstore("DeskControl",1)==1);QV("accountChangeEmailAddressSpan",(features&2097152)==0);masterUpdate(3);for(var g=1;g<5;g++){Q("devViewButton"+g).classList.remove("viewSelectorSel")}Q("devViewButton"+Q("viewselect").value).classList.add("viewSelectorSel");Q("p5filetable").addEventListener("drop",p5fileDragDrop,false);Q("p5filetable").addEventListener("dragover",p5fileDragOver,false);Q("p5filetable").addEventListener("dragleave",p5fileDragLeave,false);Q("p13filetable").addEventListener("drop",p13fileDragDrop,false);Q("p13filetable").addEventListener("dragover",p13fileDragOver,false);Q("p13filetable").addEventListener("dragleave",p13fileDragLeave,false);setInterval(updateDeviceTimeline,120000);var k=localStorage.getItem("desktopsettings");if(k!=null){desktopsettings=JSON.parse(k)}k=localStorage.getItem("multidesktopsettings");if(k!=null){multidesktopsettings=JSON.parse(k)}applyDesktopSettings();var l="";for(var a=1;a<27;a++){l+="<option value='"+a+"'>Ctrl-"+String.fromCharCode(64+a)+" ("+a+")</option>"}QH("specialkeylist",l);setupGeneralServerStats();setupServerTimelineStats();userInterfaceSelectMenu();QV("p4UserBatchCreate",(features&524288)==0)}function toggleAspectRatio(a){if(a===1){deskAspectRatio=((deskAspectRatio+1)%3);putstore("deskAspectRatio",deskAspectRatio)}deskAdjust()}function toggleStackMenu(a){if(webPageFullScreen==true){if(a===1){webPageStackMenu=!webPageStackMenu;putstore("webPageStackMenu",webPageStackMenu)}if(webPageStackMenu==false){QC("body").remove("menu_stack")}else{QC("body").add("menu_stack");if(xxcurrentView>=10){QC("column_l").remove("room4submenu")}}deskAdjust()}}function showUserInterfaceSelectMenu(){Q("uiViewButton1").classList.remove("uiSelectorSel");Q("uiViewButton2").classList.remove("uiSelectorSel");Q("uiViewButton3").classList.remove("uiSelectorSel");Q("uiViewButton4").classList.remove("uiSelectorSel");try{Q("uiViewButton"+uiMode).classList.add("uiSelectorSel")}catch(a){}QV("uiMenu",(QS("uiMenu").display=="none"));if(nightMode){Q("uiViewButton4").classList.add("uiSelectorSel")}}function userInterfaceSelectMenu(a){if(a){uiMode=a;putstore("uiMode",uiMode)}webPageFullScreen=(uiMode<3);webPageStackMenu=(uiMode>1);toggleFullScreen(0);toggleStackMenu(0);if(webPageStackMenu&&(xxcurrentView>=10)){QC("column_l").add("room4submenu")}else{QC("column_l").remove("room4submenu")}}function toggleNightMode(){nightMode=!nightMode;if(nightMode){QC("body").add("night")}else{QC("body").remove("night")}putstore("_nightMode",nightMode?"1":"0")}function toggleFullScreen(b){if(b===1){webPageFullScreen=!webPageFullScreen;putstore("webPageFullScreen",webPageFullScreen)}var a=0;if(args.hide){a=parseInt(args.hide)}if(webPageFullScreen==false){QC("body").remove("menu_stack");QC("body").remove("fullscreen");QC("body").remove("arg_hide");if(xxcurrentView>=10){QC("column_l").add("room4submenu")}QV("UserDummyMenuSpan",false)}else{QC("body").add("fullscreen");if(a&16){QC("body").add("arg_hide")}if(xxcurrentView>=10){QC("column_l").remove("room4submenu")}QV("UserDummyMenuSpan",(xxcurrentView<10)&&webPageFullScreen)}masterUpdate(512);QV("body",true)}function getNodeFromId(b){if(nodes!=null){for(var a in nodes){if(nodes[a]._id==b){return nodes[a]}}}return null}function reload(){var a=window.location.href;if(a.endsWith("/#")){a=a.substring(0,a.length-2)}window.location.href=a}function onStateChanged(c,d,b,a){if(d==0){setDialogMode(0);go(0);powerTimeline=null;powerTimelineReq=null;powerTimelineNode=null;powerTimelineUpdate=null;deleteAllNotifications();hideContextMenu();QV("verifyEmailId2",false);QV("logoutControl",false);if(a=="noauth"){QH("p0span","Unable to perform authentication");return}if(b==2){if(autoReconnect){setTimeout(serverPoll,5000)}}else{QH("p0span","Unable to connect web socket")}if(authCookieRenewTimer!=null){clearInterval(authCookieRenewTimer);authCookieRenewTimer=null}}else{if(d==2){meshserver.send({action:"meshes"});meshserver.send({action:"nodes",id:"{{currentNode}}"});if("{{currentNode}}"==""){meshserver.send({action:"files"})}go(1);authCookieRenewTimer=setInterval(function(){meshserver.send({action:"authcookie"})},1800000)}}}function serverPoll(){var b=null;try{b=new XDomainRequest()}catch(a){}if(!b){b=new XMLHttpRequest()}b.open("HEAD",window.location.href);b.timeout=15000;b.onload=function(){reload()};b.onerror=b.ontimeout=function(){setTimeout(serverPoll,10000)};b.send()}function detectClickOnce(){for(var a in window.navigator.mimeTypes){if(window.navigator.mimeTypes[a].type=="application/x-ms-application"){return true}}var b=window.navigator.userAgent.toUpperCase();return(b.indexOf(".NET CLR 3.5")>=0)||(b.indexOf("(WINDOWS NT ")>=0)}function updateSiteAdmin(){var a="{{{noServerBackup}}}";var b=userinfo.siteadmin;if(a==1){b&=4294967290}QV("p2AccountSecurity",((features&4)==0)&&(serverinfo.domainauth==false)&&((features&4096)!=0));QV("p2AccountActions",((features&4)==0)&&(serverinfo.domainauth==false));QV("p2AccountImage",((features&4)==0)&&(serverinfo.domainauth==false));QV("p2ServerActions",b&21);QV("LeftMenuMyServer",b&21);QV("MainMenuMyServer",b&21);QV("p2ServerActionsBackup",b&1);QV("p2ServerActionsRestore",b&4);QV("p2ServerActionsVersion",b&16);QV("MainMenuMyFiles",b&8);QV("LeftMenuMyFiles",b&8);if(((b&8)==0)&&(xxcurrentView==5)){setDialogMode(0);go(1)}if(currentNode!=null){gotoDevice(currentNode._id,xxcurrentView,true)}if((userinfo.siteadmin&2)!=0){if(users==null){meshserver.send({action:"users"})}if(wssessions==null){meshserver.send({action:"wssessioncount"})}}else{users=null;wssessions=null;updateUsers();if(xxcurrentView==4||((xxcurrentView>=30)&&(xxcurrentView<40))){setDialogMode(0);go(1);currentUser=null}}meshserver.send({action:"events",limit:parseInt(p3limitdropdown.value)});QV("p2deleteall",userinfo.siteadmin==4294967295);QV("ServerConsole",userinfo.siteadmin===4294967295);if((xxcurrentView==115)&&(userinfo.siteadmin!=4294967295)){go(6)}if((xxcurrentView==6)&&((userinfo.siteadmin&21)==0)){go(1)}if((b&21)!=0){meshserver.send({action:"serverstats",interval:10000})}}var updateNaggleTimer=null;var updateNaggleFlags=0;function masterUpdate(a){updateNaggleFlags|=a;if(updateNaggleTimer==null){updateNaggleTimer=setTimeout(function(){if(updateNaggleFlags&512){center()}if(updateNaggleFlags&1){onSearchInputChanged()}if(updateNaggleFlags&2){onSortSelectChange(false)}if(updateNaggleFlags&128){updateMeshes()}if(updateNaggleFlags&4){updateDevices()}if(updateNaggleFlags&8){drawNotifications()}if(updateNaggleFlags&16){updateMapMarkers()}if(updateNaggleFlags&32){eventsUpdate()}if(updateNaggleFlags&64){refreshMap(false,true)}if(updateNaggleFlags&256){drawDeviceTimeline()}if(updateNaggleFlags&1024){deviceEventsUpdate()}if(updateNaggleFlags&2048){userEventsUpdate()}if(updateNaggleFlags&4096){p20updateMesh()}updateNaggleTimer=null;updateNaggleFlags=0},150)}}function updateSelf(){QV("verifyEmailId",(userinfo.emailVerified!==true)&&(userinfo.email!=null)&&(serverinfo.emailcheck==true));QV("verifyEmailId2",(userinfo.emailVerified!==true)&&(userinfo.email!=null)&&(serverinfo.emailcheck==true));QV("manageOtp",(userinfo.otpsecret==1)||(userinfo.otphkeys>0));QV("authAppSetupCheck",userinfo.otpsecret==1);QV("authKeySetupCheck",userinfo.otphkeys>0);QV("authCodesSetupCheck",userinfo.otpkeys>0);masterUpdate(4+128+4096);var a=((userinfo.siteadmin==4294967295)||((userinfo.siteadmin&64)==0));QV("p2createMeshLink1",a);QV("p2createMeshLink2",a);QV("getStarted1",a);QV("getStarted2",!a);if(typeof userinfo.passchange=="number"){if(userinfo.passchange==-1){QH("p2nextPasswordUpdateTime"," - Reset on next login.")}else{if((passRequirements!=null)&&(typeof passRequirements.reset=="number")){var b=(userinfo.passchange)+(passRequirements.reset*86400)-Math.floor(Date.now()/1000);if(b<0){QH("p2nextPasswordUpdateTime"," - Reset on next login.")}else{if(b<3600){QH("p2nextPasswordUpdateTime"," - Reset in "+Math.floor(b/60)+" minute"+addLetterS(Math.floor(b/60))+".")}else{if(b<86400){QH("p2nextPasswordUpdateTime"," - Reset in "+Math.floor(b/3600)+" hour"+addLetterS(Math.floor(b/3600))+".")}else{QH("p2nextPasswordUpdateTime"," - Reset in "+Math.floor(b/86400)+" day"+addLetterS(Math.floor(b/86400))+".")}}}}}}}function addLetterS(a){return(a>1)?"s":""}function setSessionActivity(){sessionActivity=Date.now();QH("idleTimeoutNotify","")}function checkIdleSessionTimeout(){var a=(Date.now()-sessionActivity);if(a>serverinfo.timeout){window.location.href="logout"}else{var b=Math.round((serverinfo.timeout-a)/1000);if(b<=60){QH("idleTimeoutNotify","<br />"+b+" second"+addLetterS(b)+" until disconnect")}else{b=Math.round(b/60);if(b<=5){QH("idleTimeoutNotify","<br />"+b+" minute"+addLetterS(b)+" until disconnect")}}}}function onMessage(N,o){switch(o.action){case"serverstats":updateGeneralServerStats(o);break;case"servertimelinestats":setServerTimelineStats(o.events);break;case"authcookie":authCookie=o.cookie;break;case"serverinfo":serverinfo=o.serverinfo;if(serverinfo.timeout){setInterval(checkIdleSessionTimeout,10000);checkIdleSessionTimeout()}break;case"userinfo":userinfo=o.userinfo;updateSiteAdmin();updateSelf();break;case"users":users={};for(var l in o.users){users[o.users[l]._id]=o.users[l]}updateUsers();break;case"wssessioncount":wssessions=o.wssessions;updateUsers();break;case"meshes":meshes={};for(var l in o.meshes){meshes[o.meshes[l]._id]=o.meshes[l]}masterUpdate(4+128);break;case"files":filetree=setupBackPointers(o.filetree);updateFiles();d3updatefiles();break;case"nodes":nodes=[];for(var l in o.nodes){if(!meshes[l]){console.log("Invalid mesh (1): "+l);continue}for(var q in o.nodes[l]){if(o.nodes[l][q]._id==null){console.log("Invalid node ("+q+"): "+JSON.stringify(o.nodes));continue}o.nodes[l][q].namel=o.nodes[l][q].name.toLowerCase();if(o.nodes[l][q].rname){o.nodes[l][q].rnamel=o.nodes[l][q].rname.toLowerCase()}else{o.nodes[l][q].rnamel=o.nodes[l][q].namel}o.nodes[l][q].meshnamel=meshes[l].name.toLowerCase();o.nodes[l][q].meshid=l;o.nodes[l][q].state=(o.nodes[l][q].state)?(o.nodes[l][q].state):0;o.nodes[l][q].desc=o.nodes[l][q].desc;o.nodes[l][q].ip=o.nodes[l][q].ip;if(!o.nodes[l][q].icon){o.nodes[l][q].icon=1}o.nodes[l][q].ident=++nodeShortIdent;nodes.push(o.nodes[l][q])}}masterUpdate(1|2|4|64);if(xxcurrentView==0){if("{{viewmode}}"!=""){go(parseInt("{{viewmode}}"))}else{setDialogMode(0);go(1)}}if("{{currentNode}}"!=""){gotoDevice("{{currentNode}}",parseInt("{{viewmode}}"))}break;case"powertimeline":if(o.nodeid!=powerTimelineReq){break}powerTimelineNode=o.nodeid;powerTimeline=o.timeline;powerTimelineUpdate=Date.now()+300000;for(var e in powerTimeline){if(e%2==1){powerTimeline[e]=powerTimeline[e]*1000}}if(currentNode._id==o.nodeid){masterUpdate(256)}break;case"lastconnect":var z=getNodeFromId(o.nodeid);if(z!=null){z.lastconnect=o.time;z.lastaddr=o.addr;if((currentNode._id==z._id)&&(Q("MainComputerState").innerHTML=="")){QH("MainComputerState","<span>Last seen:<br />"+printDateTime(new Date(z.lastconnect))+"</span>")}}break;case"msg":if(o.nodeid!=null){var g=-1;if(nodes!=null){for(var e in nodes){if(nodes[e]._id==o.nodeid){g=e;break}}}if(g!=-1){if(o.type=="console"){p15consoleReceive(nodes[g],o.value)}else{if(o.type=="notify"){var q=getstore("notifications",0);if(((q&8)==0)&&(o.amtMessage!=null)){break}var q={text:o.value,title:o.title,icon:o.icon};if(o.nodeid!=null){q.nodeid=o.nodeid}if(o.tag!=null){q.tag=o.tag}if(o.username!=null){q.username=o.username}addNotification(q)}else{if(o.type=="ps"){showDeskToolsProcesses(o)}else{if((o.type=="getclip")&&(xxdialogTag=="clipboard")&&(currentNode!=null)&&(currentNode._id==o.nodeid)){Q("d2clipText").value=o.data}else{if((o.type=="setclip")&&(xxdialogTag=="clipboard")&&(currentNode!=null)&&(currentNode._id==o.nodeid)){QH("dlgClipStatus",o.success?"<span style=color:green>Success</span>":"<span style=color:red>Failed</span>");setTimeout(function(){try{QH("dlgClipStatus","")}catch(j){}},2000)}}}}}}}else{if(o.type=="notify"){var q={text:o.value,title:o.title,icon:o.icon};if(o.tag!=null){q.tag=o.tag}if(o.username!=null){q.username=o.username}addNotification(q)}}break;case"getnetworkinfo":if((currentNode._id==o.nodeid)&&(xxdialogMode==2)&&(xxdialogTag=="if"+o.nodeid)){if(o.netif==null){QH("d2netinfo","No network interface information available for this device.")}else{var Y="<div class=dialogText>";if(currentNode.lastconnect){Y+=addHtmlValue2("Last agent connection",printDateTime(new Date(currentNode.lastconnect)))}if(currentNode.lastaddr){var R=currentNode.lastaddr.split(":");if(R.length>2){Y+=addHtmlValue2("Last agent address",currentNode.lastaddr)}else{if(isPrivateIP(currentNode.lastaddr)){Y+=addHtmlValue2("Last agent address",R[0])}else{Y+=addHtmlValue2("Last agent address",'<a href="https://iplocation.com/?ip='+R[0]+'" rel="noreferrer noopener" target="MeshIPLoopup">'+R[0]+"</a>")}}}Y+=addHtmlValue2("Last interfaces update",printDateTime(new Date(o.updateTime)));for(var e in o.netif){var s=o.netif[e];Y+="<hr />";if(s.name){Y+=addHtmlValue2("Name","<b>"+EscapeHtml(s.name)+"</b>")}if(s.desc){Y+=addHtmlValue2("Description",EscapeHtml(s.desc).replace("(R)","&reg;").replace("(r)","&reg;"))}if(s.dnssuffix){Y+=addHtmlValue2("DNS suffix",EscapeHtml(s.dnssuffix))}if(s.mac){Y+=addHtmlValue2("MAC address",'<a href="https://dnslytics.com/mac-address-lookup/'+s.mac.substring(0,6)+'" rel="noreferrer noopener" target="MeshMACLoopup">'+EscapeHtml(s.mac.toLowerCase())+"</a>")}if(s.v4addr){Y+=addHtmlValue2("IPv4 address",EscapeHtml(s.v4addr))}if(s.v4mask){Y+=addHtmlValue2("IPv4 mask",EscapeHtml(s.v4mask))}if(s.v4gateway){Y+=addHtmlValue2("IPv4 gateway",EscapeHtml(s.v4gateway))}if(s.gatewaymac){Y+=addHtmlValue2("Gateway MAC",'<a href="https://dnslytics.com/mac-address-lookup/'+s.gatewaymac.substring(0,6)+'" rel="noreferrer noopener" target="MeshMACLoopup">'+EscapeHtml(s.gatewaymac.toLowerCase())+"</a>")}}Y+="</div>";QH("d2netinfo",Y)}}break;case"serverversion":if((xxdialogMode==2)&&(xxdialogTag=="MeshCentralServerUpdate")){var Y="<div class=dialogText>";if(!o.current){o.current="Unknown"}if(!o.latest){o.latest="Unknown"}Y+=addHtmlValue2("Current Version","<b>"+EscapeHtml(o.current)+"</b>");Y+=addHtmlValue2("Latest Version","<b>"+EscapeHtml(o.latest)+"</b>");Y+="</div>";if((o.latest.indexOf(".")==-1)||(o.current==o.latest)||((features&2048)==0)){setDialogMode(2,"MeshCentral Version",1,null,Y)}else{setDialogMode(2,"MeshCentral Version",3,server_showVersionDlgEx,Y+"<br /><label><input id=d2updateCheck type=checkbox onclick=server_showVersionDlgUpdate() /> Check and click OK to start server self-update.</label>");server_showVersionDlgUpdate()}}break;case"servererrors":if((xxdialogMode==2)&&(xxdialogTag=="MeshCentralServerErrors")){if(o.data==null){setDialogMode(2,"MeshCentral Server Errors",1,null,"Server has no error log.")}else{var Y='<div class="dialogText dialogTextLog"><pre id=d2ServerErrorsLogPre>'+o.data+"<pre></div>";setDialogMode(2,"MeshCentral Server Errors",3,server_showErrorsDlgEx,Y+'<br /><div style=float:right><img src=images/link4.png height=10 width=10 title="Download error log" style=cursor:pointer onclick=d2CopyServerErrorsToClip()></div><div><label><input id=d2updateCheck type=checkbox onclick=server_showVersionDlgUpdate() /> Check and click OK to clear error log.</label></div>');server_showVersionDlgUpdate()}}break;case"serverconsole":p15consoleReceive("serverconsole",o.value);break;case"events":if((o.nodeid!=null)&&(o.nodeid==currentNode._id)){currentDeviceEvents=o.events;masterUpdate(1024)}else{if((o.user!=null)&&(o.user==currentUser.name)){currentUserEvents=o.events;masterUpdate(2048)}else{events=o.events;masterUpdate(32)}}break;case"getcookie":if(o.tag=="clickonce"){var a="{{{serverRedirPort}}}"==""?"{{{serverPublicPort}}}":"{{{serverRedirPort}}}";var K="http://"+window.location.hostname+":"+a+"/clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F"+window.location.hostname+"%2Fmeshrelay.ashx%3Fauth="+o.cookie+"&CH={{{webcerthash}}}&AP="+o.protocol+((debugmode==1)?"":"&HOL=1");var w=window.open(K,"_blank");w.opener=null}break;case"getNotes":var q=Q("d2devNotes");if(q&&(o.id==decodeURIComponent(q.attributes.noteid.value))){if(o.notes){QH("d2devNotes",decodeURIComponent(o.notes))}else{QH("d2devNotes","")}var L=(q.attributes.ro.value=="true");if(L==false){q.removeAttribute("readonly");QE("idx_dlgOkButton",true);QV("idx_dlgOkButton",true);focusTextBox("d2devNotes")}}break;case"otpauth-request":if((xxdialogMode==2)&&(xxdialogTag=="otpauth-request")){var M=o.secret;if(M.length==52){M=M.split(/(.............)/).filter(Boolean).join(" ")}else{if(M.length==32){M=M.split(/(....)/).filter(Boolean).join(" ");M=M.substring(0,20)+"<br/>"+M.substring(20)}}QH("d2optinfo",'<table style=width:380px><tr><td style=vertical-align:top>Install <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2" rel="noreferrer noopener" target=_blank>Google Authenticator</a> or a compatible application and scan the barcode, use <a href="'+o.url+'" rel="noreferrer noopener" target=_blank> this link</a> or enter the secret. Then, enter the current 6 digit token below to activate 2-Step login.<br /><br />Secret<br /><tt id=d2optsecret secret="'+o.secret+'" style=font-size:12px>'+M+'</tt><br /><br /></td><td style=width:1px;vertical-align:top><a href="'+o.url+'" rel="noreferrer noopener" target=_blank><div id="qrcode"></div></a></td><tr><td colspan=2 style="text-align:center;border-top:1px solid black"><br />Enter the token here for 2-step login: <input type=text onkeypress="return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)" onkeyup=account_addOtpCheck(event) onkeydown=account_addOtpCheck() maxlength=6 id=d2otpauthinput type=text></td></table>');new QRCode(Q("qrcode"),{text:o.url,width:128,height:128,colorDark:"#000000",colorLight:"#EEE",correctLevel:QRCode.CorrectLevel.H});QV("idx_dlgOkButton",true);QE("idx_dlgOkButton",false);Q("d2otpauthinput").focus()}break;case"otpauth-setup":if(xxdialogMode){return}setDialogMode(2,"Authenticator App",1,null,o.success?"<b style=color:green>Authenticator app activation successful</b>. You will now need a valid token to login again.":"<b style=color:red>2-step login activation failed</b>. Clear the secret from the application and try again. You only have a few minutes to enter the proper code.");break;case"otpauth-clear":if(xxdialogMode){return}setDialogMode(2,"Authenticator App",1,null,o.success?"<b>Authenticator application removed</b>. You can reactivate this feature at any time.":"<b style=color:red>2-step login activation removal failed</b>. Try again.");break;case"otpauth-getpasswords":if(xxdialogMode){return}var Y="One time tokens can be used as secondary authentication. Generate a set, print them and keep them in a safe place.";Y+="<div style='border-radius:6px;border: 2px dashed #888;width:100%;margin-top:8px'><div style='padding:8px;font-family:Arial, Helvetica, sans-serif;font-size:20px;font-weight:bold'><table style=width:100%;text-align:center>";if(o.passwords){var h=0;for(var e in o.passwords){if(++h%2){Y+="<tr>"}var G=""+o.passwords[e].p;while(G.length<8){G="0"+G}if(o.passwords[e].u===true){Y+="<td>"+G.substring(0,4)+"&nbsp;"+G.substring(4)}else{Y+="<td><strike style=color:#BBB>"+G.substring(0,4)+"&nbsp;"+G.substring(4);+"</strike>"}}}else{Y+="<tr><td>No Active Tokens"}Y+="</table></div></div><br />";Y+="<div><input type=button value='Close' onclick=setDialogMode(0) style=float:right></input>";Y+="<input type=button value='Generate New Tokens' onclick='account_manageOtp(1);'></input>";if(o.passwords!=null){Y+="<input type=button value='Clear Tokens' onclick='account_manageOtp(2);'></input>"}Y+="</div><br />";setDialogMode(2,"Manage Backup Codes",8,null,Y,"otpauth-manage");break;case"otp-hkey-get":if(xxdialogMode&&(xxdialogTag!="otpauth-hardware-manage")){return}var S="<div style='border-radius:6px;border:2px solid #CCC;background-color:#BBB;width:100%;box-sizing:border-box;margin-bottom:6px'><div style='margin:3px;font-family:Arial, Helvetica, sans-serif;font-size:16px;font-weight:bold'><table style=width:100%;text-align:left>";var c="</table></div></div>";var Y="<a href='https://www.yubico.com/' rel='noreferrer noopener' target='_blank'>Hardware keys</a> are used as secondary login authentication.";Y+="<div style='max-height:150px;overflow-y:auto;overflow-x:hidden;margin-top:6px;margin-bottom:6px'>";if(o.keys&&o.keys.length>0){for(var e in o.keys){var k=o.keys[e],V=(k.type==2)?"OTP":"WebAuthn";Y+=S+'<tr style=margin:5px><td style=width:30px><img width=24 height=18 src="images/hardware-key-'+V+'-24.png" style=margin-top:4px><td style=width:250px>'+k.name+"<td><input type=button value='Remove' onclick=account_removehkey("+k.i+")></input>"+c}}else{Y+=S+"<tr style=text-align:center><td>No Keys Configured"+c}Y+="</div>";Y+="<div><input type=button value='Close' onclick=setDialogMode(0) style=float:right></input>";if((features&131072)!=0){Y+="<input id=d2addkey3 type=button value='Add Key' onclick='account_addhkey(3);'></input>"}if((features&16384)!=0){Y+="<input id=d2addkey2 type=button value='Add YubiKey&reg; OTP' onclick='account_addhkey(2);'></input>"}Y+="</div><br />";setDialogMode(2,"Manage Security Keys",8,null,Y,"otpauth-hardware-manage");if(u2fSupported()==false){QE("d2addkey1",false)}break;case"otp-hkey-yubikey-add":if(o.result){meshserver.send({action:"otp-hkey-get"})}else{setDialogMode(2,"Add Security Key",1,null,"<br />Error, Unable to add key.<br /><br />")}break;case"otp-hkey-setup-response":if(xxdialogMode&&(xxdialogTag!="otpauth-hardware-manage")){return}if(o.result==true){meshserver.send({action:"otp-hkey-get"})}else{setDialogMode(2,"Add Security Key",1,null,"<br />ERROR: Unable to add key.<br /><br />","otpauth-hardware-manage")}break;case"webauthn-startregister":if(xxdialogMode&&(xxdialogTag!="otpauth-hardware-manage")){return}var Y="Press the key button now.<br /><br /><div style=width:100%;text-align:center><img width=120 height=117 src='images/hardware-keypress-120.png' /></div><input id=dp1keyname style=display:none value="+o.name+" />";setDialogMode(2,"Add Security Key",2,null,Y);var I=o.request;o.request.challenge=Uint8Array.from(atob(o.request.challenge),function(j){return j.charCodeAt(0)});o.request.user.id=Uint8Array.from(atob(o.request.user.id),function(j){return j.charCodeAt(0)});navigator.credentials.create({publicKey:I}).then(function(j){var m={rawId:btoa(String.fromCharCode.apply(null,new Uint8Array(j.rawId))),response:{attestationObject:btoa(String.fromCharCode.apply(null,new Uint8Array(j.response.attestationObject))),clientDataJSON:btoa(String.fromCharCode.apply(null,new Uint8Array(j.response.clientDataJSON)))},type:j.type};meshserver.send({action:"webauthn-endregister",response:m});setDialogMode(0)},function(j){setDialogMode(2,"Add Security Key",1,null,"ERROR: "+j)});break;case"event":if(!o.event.nolog){events.unshift(o.event);var d=parseInt(p3limitdropdown.value);while(events.length>d){events.pop()}masterUpdate(32)}if(o.event.noact){break}switch(o.event.action){case"userWebState":if(localStorage!=null){var C=localStorage.getItem("showRealNames");var F=localStorage.getItem("uiMode");var E=localStorage.getItem("sort");var X=JSON.parse(o.event.state);for(var e in X){localStorage.setItem(e,X[e])}if((X.deskAspectRatio!=null)&&(X.deskAspectRatio!=deskAspectRatio)){deskAspectRatio=X.deskAspectRatio;deskAdjust()}if((X.showRealNames!=null)&&(X.showRealNames!=C)){showRealNames=Q("RealNameCheckBox").checked=(X.showRealNames=="1");masterUpdate(6)}if((X.uiMode!=null)&&(X.uiMode!=F)){userInterfaceSelectMenu(parseInt(X.uiMode))}if((X.sort!=null)&&(X.sort!=E)){document.getElementById("sortselect").selectedIndex=sort=parseInt(X.sort);masterUpdate(6)}}break;case"servertimelinestats":addServerTimelineStats(o.event.data);break;case"accountcreate":case"accountchange":if(userinfo.name==o.event.account.name){var v=o.event.account.siteadmin?o.event.account.siteadmin:0;var D=userinfo.siteadmin?userinfo.siteadmin:0;if((o.event.account.quota!=userinfo.quota)||(((userinfo.siteadmin&8)==0)&&((o.event.account.siteadmin&8)!=0))){meshserver.send({action:"files"})}var B=userinfo.groups;userinfo=o.event.account;if(D!=v){updateSiteAdmin()}updateSelf();if((userinfo.siteadmin&2)!=0){var A=B?B:[];var y=userinfo.groups?userinfo.groups:[];if(A.join(",")!=y.join(",")){users=wssessions=null;meshserver.send({action:"users"});meshserver.send({action:"wssessioncount"})}}}if(users==null){break}if((userinfo.groups==null)||(userinfo.groups.length==0)||(findOne(o.event.account.groups,userinfo.groups)==true)){users[o.event.account._id]=o.event.account}else{delete users[o.event.account._id]}updateUsers();break;case"accountremove":if(users==null){break}delete users["user/"+domain+"/"+o.event.username.toLowerCase()];updateUsers();break;case"createmesh":if((meshes[o.event.meshid]==null)&&(o.event.links[userinfo._id]!=null)){meshes[o.event.meshid]={_id:o.event.meshid,name:o.event.name,mtype:o.event.mtype,desc:o.event.desc,links:o.event.links};masterUpdate(4+128);meshserver.send({action:"files"})}break;case"meshchange":if(meshes[o.event.meshid]==null){meshes[o.event.meshid]={_id:o.event.meshid,name:o.event.name,mtype:o.event.mtype,desc:o.event.desc,links:o.event.links};meshserver.send({action:"nodes"})}else{if(o.event.name!=null){meshes[o.event.meshid].name=o.event.name}if(o.event.desc!=null){meshes[o.event.meshid].desc=o.event.desc}if(o.event.flags!=null){meshes[o.event.meshid].flags=o.event.flags}if(o.event.consent!=null){meshes[o.event.meshid].consent=o.event.consent}if(o.event.links){meshes[o.event.meshid].links=o.event.links}if(o.event.amt){meshes[o.event.meshid].amt=o.event.amt}if(meshes[o.event.meshid].links[userinfo._id]==null){if((xxcurrentView==20)&&(currentMesh==meshes[o.event.meshid])){go(2)}delete meshes[o.event.meshid];var u=[];for(var e in nodes){if(nodes[e].meshid!=o.event.meshid){u.push(nodes[e])}}nodes=u;if(xxcurrentView>=10&&xxcurrentView<20&&currentNode&&currentNode.meshid==o.event.meshid){setDialogMode(0);go(1)}}}masterUpdate(4+128);if(currentNode&&(currentNode.meshid==o.event.meshid)){currentNode=null;if((xxcurrentView>=10)&&(xxcurrentView<20)){go(1)}}if(xxcurrentView==20&&currentMesh._id==o.event.meshid){masterUpdate(4096)}break;case"deletemesh":if(meshes[o.event.meshid]){delete meshes[o.event.meshid];masterUpdate(128);meshserver.send({action:"files"})}var u=[];if(nodes!=null){for(var e in nodes){if(nodes[e].meshid!=o.event.meshid){u.push(nodes[e])}}}nodes=u;masterUpdate(4);if(xxcurrentView>=20&&xxcurrentView<30&&currentMesh._id==o.event.meshid){setDialogMode(0);go(2)}if(xxcurrentView>=10&&xxcurrentView<20&&currentNode&&currentNode.meshid==o.event.meshid){setDialogMode(0);go(1)}break;case"addnode":var z=o.event.node;if(!meshes[z.meshid]){break}if(getNodeFromId(z._id)!=null){break}z.namel=z.name.toLowerCase();if(z.rname){z.rnamel=z.rname.toLowerCase()}else{z.rnamel=z.namel}z.meshnamel=meshes[z.meshid].name.toLowerCase();z.state=0;if(!z.icon){z.icon=1}z.ident=++nodeShortIdent;if(nodes==null){}nodes.push(z);masterUpdate(1|2|4|16);break;case"removenode":var g=-1;for(var e in nodes){if(nodes[e]._id==o.event.nodeid){g=e;break}}if(g!=-1){var z=nodes[g];if(currentNode==z){if(xxcurrentView>=10&&xxcurrentView<20){setDialogMode(0);go(1)}currentNode=null}nodes.splice(g,1);masterUpdate(4|16)}break;case"changenode":var g=-1;for(var e in nodes){if(nodes[e]._id==o.event.nodeid){g=e;break}}if(g!=-1){var z=nodes[g];z.name=o.event.node.name;z.rname=o.event.node.rname;z.users=o.event.node.users;z.host=o.event.node.host;z.desc=o.event.node.desc;z.ip=o.event.node.ip;z.osdesc=o.event.node.osdesc;z.publicip=o.event.node.publicip;z.iploc=o.event.node.iploc;z.wifiloc=o.event.node.wifiloc;z.gpsloc=o.event.node.gpsloc;z.tags=o.event.node.tags;z.userloc=o.event.node.userloc;if(o.event.node.agent!=null){if(z.agent==null){z.agent={}}if(o.event.node.agent.ver!=null){z.agent.ver=o.event.node.agent.ver}if(o.event.node.agent.id!=null){z.agent.id=o.event.node.agent.id}if(o.event.node.agent.caps!=null){z.agent.caps=o.event.node.agent.caps}if(o.event.node.agent.core!=null){z.agent.core=o.event.node.agent.core}else{if(z.agent.core){delete z.agent.core}}z.agent.tag=o.event.node.agent.tag}if(o.event.node.intelamt!=null){if(z.intelamt==null){z.intelamt={}}if(o.event.node.intelamt.state!=null){z.intelamt.state=o.event.node.intelamt.state}if(o.event.node.intelamt.host!=null){z.intelamt.user=o.event.node.intelamt.host}if(o.event.node.intelamt.user!=null){z.intelamt.user=o.event.node.intelamt.user}if(o.event.node.intelamt.tls!=null){z.intelamt.tls=o.event.node.intelamt.tls}if(o.event.node.intelamt.ver!=null){z.intelamt.ver=o.event.node.intelamt.ver}if(o.event.node.intelamt.tag!=null){z.intelamt.tag=o.event.node.intelamt.tag}if(o.event.node.intelamt.uuid!=null){z.intelamt.uuid=o.event.node.intelamt.uuid}if(o.event.node.intelamt.realm!=null){z.intelamt.realm=o.event.node.intelamt.realm}}z.namel=z.name.toLowerCase();if(z.rname){z.rnamel=z.rname.toLowerCase()}else{z.rnamel=z.namel}if(o.event.node.icon){z.icon=o.event.node.icon}masterUpdate(2|4|8|16);refreshDevice(z._id);if((currentNode==z)&&(xxdialogMode!=null)&&(xxdialogTag=="@xxmap")){p10showNodeLocationDialog()}}break;case"nodemeshchange":var g=-1;for(var e in nodes){if(nodes[e]._id==o.event.nodeid){g=e;break}}if(g!=-1){var z=nodes[g];if(meshes[o.event.newMeshId]==null){if(currentNode==z){if(xxcurrentView>=10&&xxcurrentView<20){setDialogMode(0);go(1)}currentNode=null}nodes.splice(g,1);masterUpdate(4|16)}else{z.meshid=o.event.newMeshId;z.meshnamel=meshes[o.event.newMeshId].name.toLowerCase();masterUpdate(1|2|4)}refreshDevice(o.event.nodeid)}else{var z=o.event.node;if(!meshes[z.meshid]){break}z.namel=z.name.toLowerCase();if(z.rname){z.rnamel=z.rname.toLowerCase()}else{z.rnamel=z.namel}z.meshnamel=meshes[z.meshid].name.toLowerCase();z.state=0;if(!z.icon){z.icon=1}z.ident=++nodeShortIdent;if(nodes==null){}nodes.push(z);masterUpdate(1|2|4|16)}break;case"nodeconnect":var g=-1;for(var e in nodes){if(nodes[e]._id==o.event.nodeid){g=e;break}}if(g!=-1){var z=nodes[g];var q=getstore("notifications",0);if(o.event.meshid&&userinfo.links&&userinfo.links[o.event.meshid]&&userinfo.links[o.event.meshid].notify){q|=userinfo.links[o.event.meshid].notify}if(q&2){if(((z.conn&1)==0)&&((o.event.conn&1)!=0)){addNotification({text:"Agent connected",title:z.name,icon:z.icon,nodeid:z._id})}if(((z.conn&2)==0)&&((o.event.conn&2)!=0)){addNotification({text:"Intel AMT detected",title:z.name,icon:z.icon,nodeid:z._id})}if(((z.conn&4)==0)&&((o.event.conn&4)!=0)){addNotification({text:"Intel AMT CIRA connected",title:z.name,icon:z.icon,nodeid:z._id})}}if(q&4){if(((z.conn&1)!=0)&&((o.event.conn&1)==0)){addNotification({text:"Agent disconnected",title:z.name,icon:z.icon,nodeid:z._id})}if(((z.conn&2)!=0)&&((o.event.conn&2)==0)){addNotification({text:"Intel AMT not detected",title:z.name,icon:z.icon,nodeid:z._id})}if(((z.conn&4)!=0)&&((o.event.conn&4)==0)){addNotification({text:"Intel AMT CIRA disconnected",title:z.name,icon:z.icon,nodeid:z._id})}}z.conn=o.event.conn;z.pwr=o.event.pwr;masterUpdate(4|16);refreshDevice(z._id)}break;case"wssessioncount":if(wssessions!=null){if(o.event.count==0&&wssessions["user/"+domain+"/"+o.event.username.toLowerCase()]){delete wssessions["user/"+domain+"/"+o.event.username.toLowerCase()]}else{wssessions["user/"+domain+"/"+o.event.username.toLowerCase()]=o.event.count}updateUsers()}break;case"clearevents":events=[];masterUpdate(32);break;case"login":if(users!=null&&users["user/"+domain+"/"+o.event.username.toLowerCase()]){users["user/"+domain+"/"+o.event.username.toLowerCase()].login=Math.floor(new Date(o.event.time).getTime()/1000)}break;case"scanamtdevice":if((xxdialogMode==null)||(!Q("dp1range"))||(Q("dp1range").value!=o.event.range)){return}var Y="";if(o.event.results==null){Y="<div style=width:100%;text-align:center;margin-top:12px>Unable to scan this address range.</div><div style=width:100%;text-align:center;margin-top:12px;color:gray;line-height:1.5>Sample IP range values<br />192.168.0.100<br />192.168.1.0/24<br />192.167.0.1-192.168.0.100</div>"}else{amtScanResults=o.event.results;for(var e in o.event.results){var J=o.event.results[e],P=J.hostname;if(P.length>20){P=P.substring(0,20)+"..."}var T='<b title="'+EscapeHtml(J.hostname)+'">'+EscapeHtml(P)+"</b> - v"+J.ver;if(J.state==2){if(J.tls==1){T+=" with TLS."}else{T+=" without TLS."}}else{T+=" not activated."}Y+='<div style=width:100%;margin-bottom:2px;background-color:lightgray><div style=padding:4px><div style=display:inline-block;margin-right:5px><input class=DevScanCheckbox name=dp1checkbox tag="'+EscapeHtml(e)+'" type=checkbox onclick=addAmtScanToMeshCheckbox() /></div><div class=j1 style=display:inline-block></div><div style=display:inline-block;margin-left:5px;overflow-x:auto;white-space:nowrap>'+T+"</div></div></div>"}if(Y==""){Y="<div style=width:100%;text-align:center;margin-top:12px>Scan returned no results.</div><div style=width:100%;text-align:center;margin-top:12px;color:gray;line-height:1.5>Sample IP range values<br />192.168.0.100<br />192.168.1.0/24<br />192.167.0.1-192.168.0.100</div>"}}QH("dp1results",Y);QE("dp1range",true);QE("dp1rangebutton",true);break;case"notify":var q={text:o.event.value,title:o.event.title,icon:o.event.icon};if(o.event.tag!=null){q.tag=o.event.tag}addNotification(q);break;case"stopped":break;default:break}break;case"createInviteLink":if(xxdialogTag!=o.meshid){break}var O=serverinfo.name;if((O.indexOf(".")==-1)||((features&2)!=0)){O=window.location.hostname}var b=domainUrl.substring(0,domainUrl.length-1);var W;if(serverinfo.https==true){var H=(serverinfo.port==443)?"":(":"+serverinfo.port);W="https://"+O+H+domainUrl+"agentinvite?c="+o.cookie}else{var H=(serverinfo.port==80)?"":(":"+serverinfo.port);W="http://"+O+H+domainUrl+"agentinvite?c="+o.cookie}Q("agentInvitationLink").href=W;var U=o.expire+" hour"+addLetterS(o.expire);if(o.expire==24){U="1 day"}if(o.expire==168){U="1 week"}if(o.expire==5040){U="1 month"}if(o.expire==0){U="Unlimited"}QH("agentInvitationLink","Invitation Link ("+U+")");QV("agentInvitationLinkDiv",true);break;case"stopped":autoReconnect=false;QH("p0span",o.msg);break;default:console.log("Unknown message.action",o.action);break}}function onRealNameCheckBox(){showRealNames=Q("RealNameCheckBox").checked;putstore("showRealNames",showRealNames?1:0);masterUpdate(6);return}function onDeviceViewChange(a){if(a!=null){Q("viewselect").value=a}for(var b=1;b<5;b++){Q("devViewButton"+b).classList.remove("viewSelectorSel")}Q("devViewButton"+Q("viewselect").value).classList.add("viewSelectorSel");putstore("_deviceView",Q("viewselect").value);putstore("_viewsize",Q("sizeselect").value);masterUpdate(4);setTimeout("masterUpdate(512)",200)}function ondockeypress(a){setSessionActivity();if(!xxdialogMode&&xxcurrentView==11&&desktop&&Q("DeskControl").checked){if(currentNode!=null){var d=meshes[currentNode.meshid];var g=d.links[userinfo._id].rights;var b=((g==4294967295)||(((g&8)!=0)&&((g&256)==0)));if(b==false){return false}var c=((g!=4294967295)&&(((g&8)!=0)&&((g&256)==0)&&((g&4096)!=0)));if(c==true){if((a.altKey==true)||(a.ctrlKey==true)||((a.keyCode<32)&&(a.keyCode!=8)&&(a.keyCode!=13))||(a.keyCode>90)){return false}}}return desktop.m.handleKeys(a)}if(!xxdialogMode&&xxcurrentView==12&&terminal&&terminal.State==3){return terminal.m.TermHandleKeys(a)}if(!xxdialogMode&&((xxcurrentView==15)||(xxcurrentView==115))){return agentConsoleHandleKeys(a)}if(!xxdialogMode&&xxcurrentView==4){if(a.ctrlKey==true||a.altKey==true||a.metaKey==true){return}var h=0;if(a.key){if(a.key.length===1&&userSearchFocus==0){Q("UserSearchInput").value=((Q("UserSearchInput").value+a.key));h=1}if(a.keyCode==8&&userSearchFocus==0){var j=Q("UserSearchInput").value;Q("UserSearchInput").value=j.substring(0,j.length-1);h=1}if(a.keyCode==27){Q("UserSearchInput").value="";h=1}}else{if(a.charCode!=0&&userSearchFocus==0){Q("UserSearchInput").value=((Q("UserSearchInput").value+String.fromCharCode(a.charCode)));h=1}}if(h>0){if(h==1){onUserSearchInputChanged()}return haltEvent(a)}}if(xxdialogMode||xxcurrentView!=1){return}if(a.ctrlKey==true&&a.charCode==96){showRealNames=!showRealNames;Q("RealNameCheckBox").value=showRealNames;putstore("showRealNames",showRealNames?1:0);masterUpdate(6);return}if(a.ctrlKey==true||a.altKey==true||a.metaKey==true){return}if(Q("viewselect").value<3){var h=0;if(a.key){if(a.key.length===1&&searchFocus==0){Q("SearchInput").value=((Q("SearchInput").value+a.key));h=1}if(a.keyCode==8&&searchFocus==0){var j=Q("SearchInput").value;Q("SearchInput").value=j.substring(0,j.length-1);h=1}if(a.keyCode==27){Q("SearchInput").value="";h=1}}else{if(a.charCode!=0&&searchFocus==0){Q("SearchInput").value=((Q("SearchInput").value+String.fromCharCode(a.charCode)));h=1}}if(h>0){if(h==1){masterUpdate(5)}return haltEvent(a)}}if(Q("viewselect").value==3){if(a.key){if(a.key.length===1&&mapSearchFocus==0){Q("mapSearchLocation").value=((Q("mapSearchLocation").value+a.key));h=1}if(a.keyCode==27){Q("mapSearchLocation").value="";mapCloseSearchWindow();h=1}if(a.keyCode==13){getSearchLocation()}}else{if(a.charCode!=0&&mapSearchFocus==0){Q("mapSearchLocation").value=((Q("mapSearchLocation").value+String.fromCharCode(a.charCode)));h=1}}}}function ondockeydown(a){setSessionActivity();if(!xxdialogMode&&xxcurrentView==11&&desktop&&Q("DeskControl").checked){if(currentNode!=null){var d=meshes[currentNode.meshid];var g=d.links[userinfo._id].rights;var b=((g==4294967295)||(((g&8)!=0)&&((g&256)==0)));if(b==false){return false}var c=((g!=4294967295)&&(((g&8)!=0)&&((g&256)==0)&&((g&4096)!=0)));if(c==true){if((a.altKey==true)||(a.ctrlKey==true)||((a.keyCode<32)&&(a.keyCode!=8)&&(a.keyCode!=13))||(a.keyCode>90)){return false}}}return desktop.m.handleKeyDown(a)}if(!xxdialogMode&&xxcurrentView==12&&terminal&&terminal.State==3){terminal.m.TermHandleKeyDown(a);if((a.keyCode>=37)&&(a.keyCode<=40)){haltEvent(a)}}if(!xxdialogMode&&xxcurrentView==13&&a.keyCode==116&&p13filetree!=null){haltEvent(a);return false}if(!xxdialogMode&&((xxcurrentView==15)||(xxcurrentView==115))){return agentConsoleHandleKeys(a)}if(!xxdialogMode&&xxcurrentView==4){if(a.keyCode===8&&userSearchFocus==0){var j=Q("UserSearchInput").value;Q("UserSearchInput").value=(j.substring(0,j.length-1));h=1}if(a.keyCode===27){Q("UserSearchInput").value="";h=1}if(h>0){if(h==1){masterUpdate(5)}return haltEvent(a)}}if(xxdialogMode||xxcurrentView!=1||a.ctrlKey==true||a.altKey==true||a.metaKey==true){return}var h=0;if(Q("viewselect").value<3){if(a.keyCode===8&&searchFocus==0){var j=Q("SearchInput").value;Q("SearchInput").value=(j.substring(0,j.length-1));h=1}if(a.keyCode===27){Q("SearchInput").value="";h=1}if(h>0){if(h==1){masterUpdate(5)}return haltEvent(a)}}if(Q("viewselect").value==3){if(a.keyCode===8&&mapSearchFocus==0){var j=Q("mapSearchLocation").value;Q("mapSearchLocation").value=(j.substring(0,j.length-1));h=1}if(a.keyCode===27){Q("mapSearchLocation").value="";mapCloseSearchWindow();h=1}}}function ondockeyup(a){setSessionActivity();if(!xxdialogMode&&xxcurrentView==11&&desktop&&Q("DeskControl").checked){if(currentNode!=null){var d=meshes[currentNode.meshid];var g=d.links[userinfo._id].rights;var b=((g==4294967295)||(((g&8)!=0)&&((g&256)==0)));if(b==false){return false}var c=((g!=4294967295)&&(((g&8)!=0)&&((g&256)==0)&&((g&4096)!=0)));if(c==true){if((a.altKey==true)||(a.ctrlKey==true)||((a.keyCode<32)&&(a.keyCode!=8)&&(a.keyCode!=13))||(a.keyCode>90)){return false}}}return desktop.m.handleKeyUp(a)}if(!xxdialogMode&&xxcurrentView==12&&terminal&&terminal.State==3){return terminal.m.TermHandleKeyUp(a)}if(!xxdialogMode&&xxcurrentView==13&&a.keyCode==116&&p13filetree!=null){p13folderup(9999);haltEvent(a);return false}if(!xxdialogMode&&xxcurrentView==4){if((a.keyCode===8&&searchFocus==0)||a.keyCode===27){return haltEvent(a)}}if(xxdialogMode&&a.keyCode==27){dialogclose(0)}if(xxdialogMode||xxcurrentView!=0||a.ctrlKey==true||a.altKey==true||a.metaKey==true){return}if(Q("viewselect").value<3){if((a.keyCode===8&&searchFocus==0)||a.keyCode===27){return haltEvent(a)}}if(Q("viewselect").value==3){if((a.keyCode===8&&mapSearchFocus==0)||a.keyCode===27){return haltEvent(a)}}}function ondocblur(){if(!xxdialogMode&&xxcurrentView==11&&desktop&&Q("DeskControl").checked){return desktop.m.handleReleaseKeys()}}function devMouseHover(b,c){setSessionActivity();var d=Q("viewselect").value;if(d==1){var a=b.children[1].children[1];a.children[0].classList.remove("g1s");a.children[1].classList.remove("e2s");a.children[2].classList.remove("g2s");if(c==1){a.children[0].classList.add("g1s");a.children[1].classList.add("e2s");a.children[2].classList.add("g2s")}}else{if(d==2){var a=b;a.children[2].classList.remove("g1s");a.children[4].classList.remove("e2s");a.children[3].classList.remove("g2s");if(c==1){a.children[2].classList.add("g1s");a.children[4].classList.add("e2s");a.children[3].classList.add("g2s")}}}}var deviceHeaderId=0;var deviceHeaderTotal=0;var deviceHeadersTitles={};var deviceHeaderCount;var deviceHeaders={};var oldviewmode=0;function updateDevices(){if(nodes==null){return}var G="",a=0,g=null,e=0,l={},O=Q("viewselect").value,s={},p={};QV("xdevices",O<4);QV("xdevicesmap",O==4);QV("devListToolbar",O<3);QV("kvmListToolbar",O==3);QV("devMapToolbar",O==4);QV("devListToolbarSize",O==3);QV("NoMeshesPanel",meshcount==0);QV("devListToolbarViewIcons",(meshcount!=0)&&(nodes.length>0));QV("devListToolbarSort",(meshcount!=0)&&(nodes.length>0)&&(O<4));if((meshcount==0)||(nodes.length==0)){O=1;sort=0}if(O==4){setTimeout(function(){if(xxmap.map!=null){xxmap.map.updateSize()}},200)}else{deviceHeaderId=0;deviceHeaderCount={};deviceHeaderTotal=0;deviceHeaders={};deviceHeadersTitles={};var x=[];if(sort==0){nodes.sort(meshSort)}else{if(sort==1){nodes.sort(powerSort)}else{if(sort==2){if(showRealNames==true){nodes.sort(deviceHostSort)}else{nodes.sort(deviceSort)}}}}var d=[],m=document.getElementsByClassName("DeviceCheckbox"),b=0;for(var t=0;t<m.length;t++){if(m[t].checked){d.push(m[t].value)}}if((oldviewmode<3)&&(O==3)){multiDesktopFilter=d}else{if((oldviewmode==3)&&(O<3)){d=multiDesktopFilter}}var M=Q("column_l").clientWidth-60;var k=Math.floor(M/301);k=301+Math.floor((M-(k*301))/k);if(O==2){G+="<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>User<th style=color:gray;width:120px>Address<th style=color:gray;width:100px>Connectivity"}for(var t in nodes){var E=nodes[t];if(E.v==false){continue}var z=meshes[E.meshid],B=z.links[userinfo._id];if(B==null){continue}var C=B.rights;if((O==3)&&(z.mtype==1)){continue}if(sort==0){if(E.meshid!=g){deviceHeaderSet();var o="";if(O==2){G+="<tr><td colspan=5>"}if(meshes[E.meshid].mtype==1){o="<span class=devHeaderx>, Intel&reg; AMT only</span>"}if((O==1)&&(g!=null)){if(a==2){G+="<td><div style=width:301px></div></td>"}if(G!=""){G+="</tr></table>"}}if(O==2){G+="<div>"}G+="<div class=DevSt style=width:100%;padding-top:4px><span style=float:right>";G+="<span id=DevxHeader"+deviceHeaderId+" class=devHeaderx></span>"+o;G+='</span><span id=MxMESH tabindex=0 style=cursor:pointer onclick=gotoMesh("'+E.meshid+"\") onkeypress=\"if (event.key=='Enter') gotoMesh('"+E.meshid+"')\">"+EscapeHtml(meshes[E.meshid].name)+"</span>"+getMeshActions(z,C)+"</div>";if(O==2){G+="</div>"}g=E.meshid;l[g]=1;a=0}}else{if(sort==1){var F=E.pwr?E.pwr:0;if(F!==g){deviceHeaderSet();if((O==1)&&(g!==null)){if(a==2){G+="<td><div style=width:301px></div></td>"}if(G!=""){G+="</tr></table>"}}G+="<div class=DevSt style=width:100%;padding-top:4px><span id=DevxHeader"+deviceHeaderId+" class=devHeaderx style=float:right></span><span>"+PowerStateStr2(E.pwr)+"</span></div>";g=F;a=0}}else{if(sort==2){if(g==null){g="1"}}}}e++;var L=EscapeHtml(E.name);if(L.length==0){L="<i>None</i>"}if((E.rname!=null)&&(E.rname.length>0)){L+=" / "+EscapeHtml(E.rname)}var D=EscapeHtml(E.name);if(showRealNames==true&&E.rname!=null){D=EscapeHtml(E.rname)}if(D.length==0){D="<i>None</i>"}var u=E.icon;if((!E.conn)||(E.conn==0)){u+=" gray"}if(O==1){G+="<div id=devs onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=display:inline-block;width:"+k+'px;height:50px;padding-top:1px;padding-bottom:1px><div style=width:22px;height:50%;float:left;padding-top:12px><input class="'+E.meshid+' DeviceCheckbox" onclick=p1updateInfo() value=devid_'+E._id+" type=checkbox></div><div style=height:100%;cursor:pointer tabindex=0 onclick=gotoDevice('"+E._id+"',null,null,event) onkeypress=\"if (event.key=='Enter') gotoDevice('"+E._id+'\',null,null,event)"><div class="i'+u+'" style=width:50px;float:left></div><div style=height:100%><div class=g1></div><div class=e2><div class=e1 style=width:'+(k-100)+'px title="'+L+'">'+D+"</div><div>"+NodeStateStr(E)+"</div></div><div class=g2></div></div></div></div>"}else{if(O==2){var J=[];if(E.conn){if((E.conn&1)!=0){J.push('<span title="Mesh agent is connected and ready for use.">Agent</span>')}if((E.conn&2)!=0){J.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">CIRA</span>')}else{if((E.conn&4)!=0){J.push('<span title="Intel&reg; AMT is routable.">AMT</span>')}}if((E.conn&8)!=0){J.push('<span title="Mesh agent is reachable using another agent as relay.">Relay</span>')}}G+="<tr><td><div id=devs class=bar18 tabindex=0 onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=height:18px;width:100%;font-size:medium onkeypress=\"if (event.key=='Enter') gotoDevice('"+E._id+"',null,null,event)\">";G+='<div class=deviceBarCheckbox><input class="'+E.meshid+' DeviceCheckbox" onclick=p1updateInfo() value=devid_'+E._id+" type=checkbox></div>";G+="<div class=deviceBarIcon onclick=gotoDevice('"+E._id+"',null,null,event)><div class=\"j"+u+'" style=width:16px;margin-top:1px;margin-left:2px;height:16px></div></div>';G+="<div class=g1 style=height:18px;float:left></div><div class=g2 style=height:18px;float:right></div>";G+='<div style=cursor:pointer;font-size:14px title="'+L+"\" onclick=gotoDevice('"+E._id+"',null,null,event)><span style=width:300px>"+D+"</span></div></div></td>";G+="<td style=text-align:center>"+getUserShortStr(E);G+="<td style=text-align:center>"+(E.ip!=null?E.ip:"");G+="<td style=text-align:center>"+J.join("&nbsp;+&nbsp;");G+="</tr>"}else{if((O==3)&&(E.conn&1)&&(((C&8)||(C&256))!=0)&&((E.agent.caps&1)!=0)){if((multiDesktopFilter.length==0)||(multiDesktopFilter.indexOf("devid_"+E._id)>=0)){G+="<div id=devs style=display:inline-block;margin:1px;background-color:lightgray;border-radius:5px;position:relative><div tabindex=0 style=padding:3px;cursor:pointer onclick=gotoDevice('"+E._id+"',11,null,event) onkeypress=\"if (event.key=='Enter') gotoDevice('"+E._id+"',11,null,event)\">";G+='<div class="j'+u+'" style=width:16px;float:left></div>&nbsp;'+D+"</div>";G+="<span onclick=gotoDevice('"+E._id+"',null,null,event)></span><div id=xkvmid_"+E._id.split("/")[2]+"><div id=skvmid_"+E._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(\''+E._id+"') onkeypress=\"if (event.key=='Enter') toggleKvmDevice('"+E._id+"')\">Disconnected</div></div>";G+="</div>";x.push(E._id)}}}}if((sort==3)&&(G!="")){if(E.tags){for(var w in E.tags){var K=E.tags[w];if(s[K]==null){s[K]=G;p[K]=1}else{s[K]+=G;p[K]+=1}if(O==3){break}}}G=""}deviceHeaderTotal++;if(typeof deviceHeaderCount[E.state]=="undefined"){deviceHeaderCount[E.state]=1}else{deviceHeaderCount[E.state]++}}if(sort==3){var q=[];for(var t in s){q.push(t)}q.sort(function(c,j){return c.toLowerCase().localeCompare(j.toLowerCase())});for(var w in q){var t=q[w];G+="<div class=DevSt style=width:100%;padding-top:4px><span class=devHeaderx style=float:right>"+p[t]+" node"+((p[t]>1)?"s":"")+"</span><span>"+t+"</span></div>"+s[t]}}if((G=="")&&(meshcount>0)&&(Q("SearchInput").value!="")){if(sort==3){G='<div style="margin:30px">No devices are included in any groups, click on a device\'s "Groups" to add to a group.</div>'}else{G='<div style="margin:30px">No devices matching this search.</div>'}}if((O==1)&&(a==2)){G+="<td><div style=width:301px></div></td>"}if((sort==0)&&(Q("SearchInput").value=="")&&(O<3)){for(var t in meshes){var y=meshes[t],A=y.links[userinfo._id];if(A!=null){var C=A.rights;if(l[y._id]==null){if((g!="")&&(G!="")){G+="</tr></table>"}G+='<table style=width:100%;padding-top:4px cellpadding=0 cellspacing=0><tr><td colspan=3 class=DevSt><span id=MxMESH style=cursor:pointer onclick=gotoMesh("'+y._id+'")>'+EscapeHtml(y.name)+"</span><span>";G+=getMeshActions(y,C);G+="</span></td></tr><tr>";if(y.mtype==1){G+="<td><div style=padding:10px><i>No Intel&reg; AMT devices in this mesh";if((C&4)!=0){G+=", <a href=# style=cursor:pointer onclick='return addDeviceToMesh(\""+y._id+"\"')>add one</a>"}}if(y.mtype==2){G+="<td><div style=padding:10px><i>No devices in this mesh";if((C&4)!=0){G+=", <a href=# style=cursor:pointer onclick='return addAgentToMesh(\""+y._id+"\")'>add one</a>"}}G+=".</i></div></td>";g=y._id;e++}}}}G+="</tr></table><div style=height:1px></div>";G+="<div style=border-top-style:solid;border-top-width:1px;border-top-color:#DDDDDD;cursor:pointer;font-size:10px>";if((O<3)&&(sort==0)&&(meshcount>0)&&((userinfo.siteadmin==4294967295)||((userinfo.siteadmin&64)==0))){G+='<a href=# onclick="return account_createMesh()" title="Create a new group of devices." style=cursor:pointer>Add Device Group</a>&nbsp'}if((userinfo.siteadmin==4294967295)||((userinfo.siteadmin&128)==0)){G+="<a href=# onclick='return p10showMeshCmdDialog(0)' style=cursor:pointer title=\"Download MeshCmd, a command line tool that performs many functions.\">MeshCmd</a>&nbsp";if(navigator.platform.toLowerCase()=="win32"){G+="<a href=# onclick='return p10showMeshRouterDialog()' style=cursor:pointer title=\"Download MeshCentral Router, a TCP port mapping tool.\">Router</a>&nbsp"}}G+="</div><br/>";QH("xdevices",G);deviceHeaderSet();var m=document.getElementsByClassName("DeviceCheckbox"),b=0;for(var t=0;t<m.length;t++){m[t].checked=(d.indexOf(m[t].value)>=0)}for(var t in deviceHeaders){QH(t,deviceHeaders[t])}for(var t in deviceHeadersTitles){Q(t).title=deviceHeadersTitles[t]}p1updateInfo();if(O==3){var P=[{x:180,y:101},{x:302,y:169},{x:454,y:255}][Q("sizeselect").selectedIndex];var H=P.x+2,N=M-5,R=Math.floor(N/H);R=H+Math.floor((N-(R*H))/R);P.y=P.y*(R/P.x);P.x=R;for(var t in multiDesktop){multiDesktop[t].xxdelete=true}for(var t in x){var v=x[t],I=v.split("/")[2],h=multiDesktop[v];if(h!=null){h.m.CanvasId.setAttribute("style","background-color:black;width:"+P.x+"px;height:"+P.y+"px");Q("xkvmid_"+I).appendChild(h.m.CanvasId);delete h.xxdelete;QH("skvmid_"+I,["Disconnected","Connecting...","Setup...","",""][((h.m.State==null)?h.m.state:h.m.State)])}else{var E=getNodeFromId(v);if((desktopNode==E)&&(desktop!=null)){var a=desktop.m.CanvasId;a.setAttribute("id","kvmid_"+I);a.setAttribute("style","background-color:black;width:"+P.x+"px;height:"+P.y+"px");a.setAttribute("onclick","toggleKvmDevice('"+v+"')");a.removeAttribute("onmousedown");a.removeAttribute("onmouseup");a.removeAttribute("onmousemove");Q("xkvmid_"+I).appendChild(a);QH("skvmid_"+I,["Disconnected","Connecting...","Setup...","",""][((desktop.m.State==null)?desktop.m.state:desktop.m.State)]);if(desktop.m.SendCompressionLevel){desktop.m.SendCompressionLevel(1,multidesktopsettings.quality,multidesktopsettings.scaling,multidesktopsettings.framerate)}desktop.shortid=I;desktop.onStateChanged=onMultiDesktopStateChange;multiDesktop[v]=desktop;desktop=desktopNode=currentNode=null;QH("DeskParent",'<canvas id="Desk" oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>')}else{var a=document.createElement("canvas");a.setAttribute("id","kvmid_"+I);a.setAttribute("width",640);a.setAttribute("height",480);a.setAttribute("oncontextmenu","return false");a.setAttribute("style","background-color:black;width:"+P.x+"px;height:"+P.y+"px");a.setAttribute("onclick","toggleKvmDevice('"+v+"')");try{Q("xkvmid_"+I).appendChild(a)}catch(n){}if(Q("autoConnectDesktopCheckbox").checked==true){setTimeout(function(){connectMultiDesktop(E,1)},100)}}}}for(var t in multiDesktop){if(multiDesktop[t].xxdelete==true){multiDesktop[t].Stop();delete multiDesktop[t]}else{if(debugmode&&multiDesktop[t].m&&multiDesktop[t].m.onScreenSizeChange){mdeskAdjust(multiDesktop[t].m,multiDesktop[t].m.ScreenWidth,multiDesktop[t].m.ScreenHeight,multiDesktop[t].m.CanvasId)}}}deskAdjust()}else{disconnectAllKvmFunction();Q("autoConnectDesktopCheckbox").checked=false}}oldviewmode=O}function toggleKvmDevice(d){var c=getNodeFromId(d),a=meshes[c.meshid],b=a.links[userinfo._id].rights;if((b&8)||(b&256)){if(c.conn&1){connectMultiDesktop(c,1)}}}function getUserShortStr(b){if(b==null||b.users==null||b.users.length==0){return""}if(b.users.length>1){return'<span title="'+EscapeHtml(b.users.join(", "))+'">'+b.users.length+"&nbsp;users</span>"}var d=b.users[0],c=d,a=d.indexOf("\\");if(a>0){c=d.substring(a+1)}c=EscapeHtml(c);if(c.length>15){c=c.substring(0,14)+"&#8230;"}return'<span title="'+EscapeHtml(d)+'">'+c+"</span>"}function autoConnectDesktops(){if(Q("autoConnectDesktopCheckbox").checked==true){connectAllKvmFunction()}}function connectAllKvmFunction(){for(var a in nodes){if(multiDesktop[nodes[a]._id]==null){toggleKvmDevice(nodes[a]._id)}}}function disconnectAllKvmFunction(){for(var a in multiDesktop){multiDesktop[a].Stop()}multiDesktop={}}function onMultiDesktopStateChange(a,c){try{QH("skvmid_"+a.shortid,["Disconnected","Connecting...","Setup...","",""][c])}catch(b){}}function showMultiDesktopSettings(){QV("d7amtkvm",false);QV("d7meshkvm",true);d7bitmapquality.value=multidesktopsettings.quality;d7bitmapscaling.value=multidesktopsettings.scaling;if(multidesktopsettings.framerate){d7framelimiter.value=multidesktopsettings.framerate}else{d7framelimiter.value=1000}setDialogMode(7,"Remote Desktop Settings",3,showMultiDesktopSettingsChanged)}function showMultiDesktopSettingsChanged(){multidesktopsettings.quality=d7bitmapquality.value;multidesktopsettings.scaling=d7bitmapscaling.value;multidesktopsettings.framerate=d7framelimiter.value;localStorage.setItem("multidesktopsettings",JSON.stringify(multidesktopsettings));for(var a in multiDesktop){multiDesktop[a].m.SendCompressionLevel(1,multidesktopsettings.quality,multidesktopsettings.scaling,multidesktopsettings.framerate)}}function connectMultiDesktop(c,a){var d=c._id,e=d.split("/")[2];var b=multiDesktop[d];if(b==null){if(Q("kvmid_"+e)==null){return}if(a==2){if((c.intelamt.user==null)||(c.intelamt.user=="")){return}b=CreateAmtRedirect(CreateAmtRemoteDesktop("kvmid_"+e),authCookie);b.shortid=e;b.onStateChanged=onMultiDesktopStateChange;b.m.bpp=1;b.m.useZRLE=true;b.m.showmouse=true;b.m.onKvmData=function(g){console.log("KVM Data received in multi-desktop mode, this is not supported.")};if(debugmode>0){b.m.onScreenSizeChange=mdeskAdjust}b.Start(d,16994,"*","*",0);b.contype=2;multiDesktop[d]=b}else{if(a==1){b=CreateAgentRedirect(meshserver,CreateAgentRemoteDesktop("kvmid_"+e),serverPublicNamePort,authCookie,domainUrl);b.shortid=e;b.attemptWebRTC=attemptWebRTC;b.onStateChanged=onMultiDesktopStateChange;b.m.CompressionLevel=multidesktopsettings.quality;b.m.ScalingLevel=multidesktopsettings.scaling;b.m.FrameRateTimer=multidesktopsettings.framerate;if(debugmode>0){b.m.onScreenSizeChange=mdeskAdjust}b.Start(d);b.contype=1;multiDesktop[d]=b}}}else{b.Stop();delete multiDesktop[d]}}function getMeshActions(a,b){if((b&4)==0){return""}var c="";if((features&1024)==0){c+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer that is located on the internet." onclick=\'return addCiraDeviceToMesh("'+a._id+"\")'>Add CIRA</a>"}if(a.mtype==1){if((features&1)==0){c+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer that is located on the local network." onclick=\'return addDeviceToMesh("'+a._id+"\")'>Add Local</a>";c+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer by scanning the local network." onclick=\'return addAmtScanToMesh("'+a._id+"\")'>Scan Network</a>"}if(a.amt&&(a.amt.type==2)){c+=' <a href=# style=cursor:pointer;font-size:10px title="Perform Intel AMT client control mode (CCM) activation." onclick=\'return showCcmActivation("'+a._id+"\")'>Activation</a>"}else{if(a.amt&&(a.amt.type==3)&&((features&1048576)!=0)){c+=' <a href=# style=cursor:pointer;font-size:10px title="Perform Intel AMT admin control mode (ACM) activation." onclick=\'return showAcmActivation("'+a._id+"\")'>Activation</a>"}}}if(a.mtype==2){c+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new computer to this mesh by installing the mesh agent." onclick=\'return addAgentToMesh("'+a._id+"\")'>Add Agent</a>";c+=' <a href=# style=cursor:pointer;font-size:10px title="Invite someone to install the mesh agent on this mesh." onclick=\'return inviteAgentToMesh("'+a._id+"\")'>Invite</a>"}return c}function addDeviceToMesh(b){if(xxdialogMode){return false}var a=meshes[b];var c='Add a new Intel&reg; AMT device to device group "'+EscapeHtml(a.name)+'".<br /><br />';c+=addHtmlValue("Device Name","<input id=dp1devicename style=width:230px maxlength=32 autocomplete=off onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />");c+=addHtmlValue("Hostname",'<input id=dp1hostname style=width:230px maxlength=32 autocomplete=off placeholder="Same as device name" onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />');c+=addHtmlValue("Username",'<input id=dp1username style=width:230px maxlength=32 autocomplete=off placeholder="admin" onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />');c+=addHtmlValue("Password","<input id=dp1password type=password style=width:230px autocomplete=off maxlength=32 onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />");c+=addHtmlValue("Security","<select id=dp1tls style=width:236px><option value=0>No TLS security</option><option value=1>TLS security required</option></select>");setDialogMode(2,"Add Intel&reg; AMT device",3,addDeviceToMeshEx,c,b);validateDeviceToMesh();Q("dp1devicename").focus();return false}function showCcmActivation(c){if(xxdialogMode){return false}var e=serverinfo.name,b=meshes[c];if((e.indexOf(".")==-1)||((features&2)!=0)){e=window.location.hostname}var g,a=domainUrl.substring(0,domainUrl.length-1);if(serverinfo.https==true){var d=(serverinfo.port==443)?"":(":"+serverinfo.port);g="wss://"+e+d+domainUrl}else{var d=(serverinfo.port==80)?"":(":"+serverinfo.port);g="ws://"+e+d+domainUrl}var h='Perform Intel AMT client control mode (CCM) activation to group "'+EscapeHtml(b.name)+'" by downloading the MeshCMD tool and running it like this:<br /><br />';h+="<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtccm --url "+g+"amtactivate?id="+c.split("/")[2]+" --serverhttpshash "+serverinfo.tlshash+"</textarea>";setDialogMode(2,"Intel&reg; AMT activation",9,null,h);Q("idx_dlgOkButton").focus();return false}function showAcmActivation(c){if(xxdialogMode){return false}var e=serverinfo.name,b=meshes[c];if((e.indexOf(".")==-1)||((features&2)!=0)){e=window.location.hostname}var g,a=domainUrl.substring(0,domainUrl.length-1);if(serverinfo.https==true){var d=(serverinfo.port==443)?"":(":"+serverinfo.port);g="wss://"+e+d+domainUrl}else{var d=(serverinfo.port==80)?"":(":"+serverinfo.port);g="ws://"+e+d+domainUrl}var h='Perform Intel AMT admin control mode (ACM) activation to group "'+EscapeHtml(b.name)+'" by downloading the MeshCMD tool and running it like this:<br /><br />';h+="<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtacm --url "+g+"amtactivate?id="+c.split("/")[2]+" --serverhttpshash "+serverinfo.tlshash+"</textarea>";if(serverinfo.amtAcmFqdn!=null){h+="<div style=margin-top:8px>Intel AMT will need to be set with a Trusted FQDN in MEBx or have a wired LAN on the network: <b>"+serverinfo.amtAcmFqdn.join(", ")+"</b></div>"}setDialogMode(2,"Intel&reg; AMT activation",9,null,h);Q("idx_dlgOkButton").focus();return false}function addAmtScanToMesh(a){if(xxdialogMode){return false}var b="Enter a range of IP addresses to scan for Intel AMT devices.<br /><br />";b+=addHtmlValue("IP Range",'<input id=dp1range style=width:184px value="192.168.1.0/24" onkeyup=addAmtScanToMeshKeyUp(event) /><input id=dp1rangebutton type=button value=Scan onclick=addAmtScanToMeshButton()></input>');b+='<div id=dp1results style="width:100%;height:200px;background-color:white;border:1px gray solid;overflow-y:scroll"></div>';setDialogMode(2,"Scan for Intel&reg; AMT devices",3,addAmtScanToMeshEx,b,a);QE("idx_dlgOkButton",false);QH("dp1results","<div style=width:100%;text-align:center;margin-top:12px;color:gray;line-height:1.5>Sample IP range values<br />192.168.0.100<br />192.168.1.0/24<br />192.167.0.1-192.168.0.100</div>");focusTextBox("dp1range");return false}function addAmtScanToMeshKeyUp(a){if(a.keyCode==13){haltEvent(a);addAmtScanToMeshButton()}}function addAmtScanToMeshEx(b,h){var d=document.getElementsByClassName("DevScanCheckbox"),c=0;for(var e=0;e<d.length;e++){if(d[e].checked){var g=d[e].getAttribute("tag");var a=amtScanResults[g];meshserver.send({action:"addamtdevice",meshid:h,devicename:g,hostname:a.hostname,amtusername:"",amtpassword:"",amttls:a.tls})}}}function addAmtScanToMeshButton(){QE("dp1range",false);QE("dp1rangebutton",false);QH("dp1results","<div style=width:100%;text-align:center;margin-top:12px>Scanning...</div>");meshserver.send({action:"scanamtdevice",range:Q("dp1range").value})}function addAmtScanToMeshCheckbox(){var b=document.getElementsByClassName("DevScanCheckbox"),a=0;for(var c=0;c<b.length;c++){if(b[c].checked){a++}}QE("idx_dlgOkButton",a>0)}function addCiraDeviceToMesh(b){if(xxdialogMode){return false}var a=meshes[b];var c=b.split("/")[2].replace(/\@/g,"X").replace(/\$/g,"X");var e="<select id=dlgAddCiraSel onclick=dlgAddCiraSelClick() style=width:230px><option value=0>MeshCommander Script</option><option value=1>Manual Username/Password</option>";if((features&16)==0){e+="<option value=2>Manual Certificate</option></select>"}var d="";d+=addHtmlValue("Setup Method",e);d+="<hr>";d+='<div id=dlgAddCira0>To add a new Intel&reg; AMT device to device group "'+EscapeHtml(a.name)+"\" with CIRA, download the following script files and use <a href='http://meshcommander.com' rel='noreferrer noopener' target='_blank'>MeshCommander</a> to run the script to configure computers.<br /><br />";d+=addHtmlValue("Setup CIRA",'<a href="mescript.ashx?type=1&meshid='+c.substring(0,16)+'" download>cira_setup.mescript</a>');d+=addHtmlValue("Cleanup CIRA",'<a href="mescript.ashx?type=2" download>cira_clean.mescript</a>');d+="</div>";d+='<div id=dlgAddCira1 style=display:none>To add a new Intel&reg; AMT device to device group "'+EscapeHtml(a.name)+'" with CIRA, load the following certificate as trusted root within Intel AMT';if(serverinfo.mpspass){d+=" and authenticate to the server using this username and password.<br /><br />"}else{d+=" and authenticate to the server using this username and any password.<br /><br />"}d+=addHtmlValue("Root Certificate",'<a href="MeshServerRootCert.cer" download>Root Certificate File</a>');d+=addHtmlValue("Username",'<input style=width:230px readonly value="'+c.substring(0,16)+'" />');if(serverinfo.mpspass){d+=addHtmlValue("Password",'<input style=width:230px readonly value="'+EscapeHtml(serverinfo.mpspass)+'" />')}if(serverinfo!=null){d+=addHtmlValue("MPS Server",'<input style=width:230px readonly value="'+EscapeHtml(serverinfo.mpsname)+":"+serverinfo.mpsport+'" />')}d+="</div>";if((features&16)==0){d+='<div id=dlgAddCira2 style=display:none>To add a new Intel&reg; AMT device to device group "'+EscapeHtml(a.name)+'" with CIRA, load the following certificate as trusted root within Intel AMT, authenticate using a client certificate with the following common name and connect to the following server.<br /><br />';d+=addHtmlValue("Root Certificate",'<a href="MeshServerRootCert.cer" download>Root Certificate File</a>');d+=addHtmlValue("Organization",'<input style=width:230px readonly value="'+c+'" />');if(serverinfo!=null){d+=addHtmlValue("MPS Server",'<input style=width:230px readonly value="'+EscapeHtml(serverinfo.mpsname)+":"+serverinfo.mpsport+'" />')}d+="</div>"}setDialogMode(2,"Add Intel&reg; AMT CIRA device",2,null,d,"fileDownload");Q("dlgAddCiraSel").focus();return false}function dlgAddCiraSelClick(){var a=Q("dlgAddCiraSel").value;QV("dlgAddCira0",a==0);QV("dlgAddCira1",a==1);QV("dlgAddCira2",a==2)}function checkEmail(c){var d=c.split("@");var b=((d.length==2)&&(d[0].length>0)&&(d[1].split(".").length>1)&&(d[1].length>2));if(b==true){var e=d[1].split(".");for(var a in e){if(e[a].length==0){b=false}}}return b}function inviteAgentToMesh(b){if(xxdialogMode){return false}var c="",a=meshes[b];if(features&64){c+=addHtmlValue("Invitation Type","<select id=d2InviteType onchange=d2ChangedInviteType() style=width:236px><option value=0>Link invitation</option><option value=1>Email invitation</option></select>")+"<hr />";c+='<div id=emailInviteDiv style=display:none>Invite someone to install the mesh agent. An email with be sent with the link to the mesh agent installation for the "'+EscapeHtml(a.name)+'" device group.<br /><br />';c+=addHtmlValue("Name (optional)",'<input id=agentInviteName value="" style=width:230px maxlength=64 />');c+=addHtmlValue("Email",'<input id=agentInviteEmail style=width:230px placeholder="example@email.com" onkeyup=validateAgentInvite()></input>');c+=addHtmlValue("Operating System","<select id=agentInviteNameOs onchange=d2ChangedInviteType() style=width:236px><option value=4>Send installation link</option><option value=0 selected>Any supported</option><option value=1>Windows only</option><option value=3>Apple MacOS only</option><option value=2>Linux only</option></select>");c+="<div id=d2agentexpirediv>";c+=addHtmlValue("Link Expiration","<select id=agentInviteExpire style=width:236px><option value=1>1 hour</option><option value=8>8 hours</option><option value=24>1 day</option><option value=168>1 week</option><option value=5040>1 month</option><option value=0>Unlimited</option></select>");c+="</div>";c+=addHtmlValue("Installation Type","<select id=agentInviteType style=width:236px><option value=0>Background and interactive</option><option value=2>Background only</option><option value=1>Interactive only</option></select>");c+=addHtmlValue("Message<br />(optional)",'<textarea id=agentInviteMessage value="" style=width:230px;height:100px;resize:none maxlength=1024 /></textarea>');c+="</div>"}c+='<div id=urlInviteDiv>Invite someone to install the mesh agent by sharing an invitation link. This link points the user to installation instructions for the "'+EscapeHtml(a.name)+'" device group. The link is public and no account for this server is needed.<br /><br />';c+=addHtmlValue("Link Expiration","<select id=d2inviteExpire style=width:236px onchange=d2RequestInvitationLink()><option value=1>1 hour</option><option value=8>8 hours</option><option value=24>1 day</option><option value=168>1 week</option><option value=5040>1 month</option><option value=0>Unlimited</option></select>");c+='<div id=agentInvitationLinkDiv style="text-align:center;font-size:large;margin:16px;display:none"><a href=# id=agentInvitationLink target="_blank" style=cursor:pointer></a> <img src=images/link4.png height=10 width=10 title="Copy link to clipboard" style=cursor:pointer onclick=d2CopyInviteToClip()></div></div>';setDialogMode(2,"Invite",3,performAgentInvite,c,b);if(features&64){Q("d2InviteType").focus();d2ChangedInviteType()}else{Q("d2inviteExpire").focus();validateAgentInvite()}d2RequestInvitationLink();return false}function d2RequestInvitationLink(){meshserver.send({action:"createInviteLink",meshid:xxdialogTag,expire:parseInt(Q("d2inviteExpire").value),flags:0})}function d2ChangedInviteType(){QV("urlInviteDiv",Q("d2InviteType").value==0);QV("d2agentexpirediv",Q("agentInviteNameOs").value==4);QV("emailInviteDiv",Q("d2InviteType").value==1);validateAgentInvite()}function d2CopyInviteToClip(){copyTextToClip(Q("agentInvitationLink").href)}function validateAgentInvite(){if((features&64)&&(Q("d2InviteType").value==1)){QE("idx_dlgOkButton",checkEmail(Q("agentInviteEmail").value));QV("idx_dlgCancelButton",true)}else{QE("idx_dlgOkButton",true);QV("idx_dlgCancelButton",false)}}function performAgentInvite(a,b){if((features&64)&&(Q("d2InviteType").value==1)){meshserver.send({action:"inviteAgent",meshid:b,email:Q("agentInviteEmail").value,name:Q("agentInviteName").value,os:Q("agentInviteNameOs").value,flags:Q("agentInviteType").value,msg:Q("agentInviteMessage").value,expire:parseInt(Q("agentInviteExpire").value)})}}function addAgentToMesh(e){if(xxdialogMode){return false}var c=meshes[e],j="",b=0;j+=addHtmlValue("Operating System","<select id=aginsSelect onchange=addAgentToMeshClick() style=width:236px><option value=0>Windows</option><option value=1>Linux / BSD</option><option value=2>Apple MacOS</option><option value=3>Windows (UnInstall)</option><option value=4>Linux / BSD (UnInstall)</option></select>");j+="<div id=aginsTypeDiv>";j+=addHtmlValue("Installation Type","<select id=aginsType onchange=addAgentToMeshClick() style=width:236px><option value=0>Background & interactive</option><option value=2>Background only</option><option value=1>Interactive only</option></select>");j+="</div><hr>";var d=c.name;d=d.split("\\").join("").split("/").join("").split(":").join("").split("*").join("").split("?").join("").split('"').join("").split("<").join("").split(">").join("").split("|").join("").split(" ").join("").split("'").join("");j+='<div id=agins_windows>To add a new computer to device group "'+EscapeHtml(c.name)+'", download the mesh agent and install it the computer to manage. This agent has server and device group information embedded within it.<br /><br />';j+=addHtmlValue("Mesh Agent",'<a id=aginsw32lnk href="meshagents?id=3&meshid='+e.split("/")[2]+'&installflags=0" download onclick="setDialogMode(0)" title="32bit version of the MeshAgent">Windows (.exe)</a> <img src=images/link4.png height=10 width=10 title="Copy Windows 32bit agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshagents?id=3&meshid='+e.split("/")[2]+'&installflags=",1)>');j+=addHtmlValue("Mesh Agent",'<a id=aginsw64lnk href="meshagents?id=4&meshid='+e.split("/")[2]+'&installflags=0" download onclick="setDialogMode(0)" title="64bit version of the MeshAgent">Windows x64 (.exe)</a> <img src=images/link4.png height=10 width=10 title="Copy Windows 64bit agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshagents?id=4&meshid='+e.split("/")[2]+'&installflags=",1)>');if(debugmode>0){j+=addHtmlValue("Settings File",'<a id=aginswmshlnk href="meshsettings?id='+e.split("/")[2]+'&installflags=0" rel="noreferrer noopener" target="_blank">'+EscapeHtml(c.name)+" settings (.msh)</a>")}j+="</div>";j+="<div id=agins_linux style=display:none>To add a computer to "+EscapeHtml(c.name)+" run the following command. Root credentials will be needed.<br />";j+="<textarea id=agins_linux_area rows=2 cols=20 readonly=readonly style=width:100%;resize:none;height:120px;overflow:scroll;font-size:12px readonly></textarea>";j+="<div style='font-size:x-small'>* For BSD, run \"pkg install wget sudo bash\" first.</div></div>";j+='<div id=agins_osx style=display:none>To add a new computer to device group "'+EscapeHtml(c.name)+'", download the mesh agent and install it the computer to manage. This agent installer has server and device group information embedded within it.<br /><br />';j+=addHtmlValue("Mesh Agent",'<a href="meshosxagent?id=16&meshid='+e.split("/")[2]+'" rel="noreferrer noopener" target="_blank" title="64bit version of MacOS Mesh Agent">MacOS Agent (64bit)</a> <img src=images/link4.png height=10 width=10 title="Copy MacOS agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshosxagent?id=16&meshid='+e.split("/")[2]+'",0)>');j+="</div>";j+='<div id=agins_windows_un style=display:none>To remove a mesh agent, download the file below, run it and click "uninstall".<br /><br />';j+=addHtmlValue("Mesh Agent",'<a href="meshagents?id=3" download onclick="setDialogMode(0)" title="32bit version of the MeshAgent">Windows (.exe)</a>');j+=addHtmlValue("Mesh Agent",'<a href="meshagents?id=4" download onclick="setDialogMode(0)" title="64bit version of the MeshAgent">Windows x64 (.exe)</a>');j+="</div>";j+="<div id=agins_linux_un style=display:none>To remove a mesh agent, run the following command. Root credentials will be needed.<br />";j+="<textarea id=agins_linux_area_un rows=2 cols=20 readonly=readonly style=width:100%;resize:none;height:120px;overflow:scroll;font-size:12px readonly></textarea>";j+="</div>";setDialogMode(2,"Add Mesh Agent",2,null,j,"fileDownload");var h=serverinfo.name;if((h.indexOf(".")==-1)||((features&2)!=0)){h=window.location.hostname}var a=domainUrl.substring(0,domainUrl.length-1);if(serverinfo.https==true){var g=(serverinfo.port==443)?"":(":"+serverinfo.port);if((features&8192)==0){Q("agins_linux_area").value="(wget https://"+h+g+domainUrl+"meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://"+h+g+domainUrl+"meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://"+h+g+a+" '"+e.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="(wget https://"+h+g+domainUrl+"meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://"+h+g+domainUrl+"meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}else{Q("agins_linux_area").value="wget https://"+h+g+domainUrl+"meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://"+h+g+a+" '"+e.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="wget https://"+h+g+domainUrl+"meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}}else{var g=(serverinfo.port==80)?"":(":"+serverinfo.port);if((features&8192)==0){Q("agins_linux_area").value="(wget http://"+h+g+domainUrl+"meshagents?script=1 -O ./meshinstall.sh || wget http://"+h+g+domainUrl+"meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://"+h+g+a+" '"+e.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="(wget http://"+h+g+domainUrl+"meshagents?script=1 -O ./meshinstall.sh || wget http://"+h+g+domainUrl+"meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}else{Q("agins_linux_area").value="wget http://"+h+g+domainUrl+"meshagents?script=1 --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://"+h+g+a+" '"+e.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="wget http://"+h+g+domainUrl+"meshagents?script=1 --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}}Q("aginsSelect").focus();addAgentToMeshClick();return false}function copyAgentUrl(h,a){var g=serverinfo.name;if((g.indexOf(".")==-1)||((features&2)!=0)){g=window.location.hostname}var d=domainUrl.substring(0,domainUrl.length-1);var e=(serverinfo.port==443)?"":(":"+serverinfo.port);var b="https://"+g+e+domainUrl+h;if(a==1){b+=Q("aginsType").value}copyTextToClip(b)}function addAgentToMeshClick(){var a=Q("aginsSelect").value;QV("agins_windows",a==0);QV("agins_linux",a==1);QV("agins_osx",a==2);QV("agins_windows_un",a==3);QV("agins_linux_un",a==4);QV("aginsTypeDiv",a==0);Q("aginsw32lnk").href=(Q("aginsw32lnk").href.split("installflags=")[0])+"installflags="+Q("aginsType").value;Q("aginsw64lnk").href=(Q("aginsw64lnk").href.split("installflags=")[0])+"installflags="+Q("aginsType").value;if(debugmode>0){Q("aginswmshlnk").href=(Q("aginswmshlnk").href.split("installflags=")[0])+"installflags="+Q("aginsType").value}}function validateDeviceToMesh(){QE("idx_dlgOkButton",(Q("dp1devicename").value.length>0)&&(passwordcheck(Q("dp1password").value)))}function addDeviceToMeshEx(b,d){var a=Q("dp1username").value;if(a==""){a="admin"}var c=Q("dp1hostname").value;if(c==""){c=Q("dp1devicename").value}meshserver.send({action:"addamtdevice",meshid:d,devicename:Q("dp1devicename").value,hostname:c,amtusername:a,amtpassword:Q("dp1password").value,amttls:Q("dp1tls").value})}function deviceHeaderSet(){if(deviceHeaderId==0){deviceHeaderId=1;return}deviceHeaders["DevxHeader"+deviceHeaderId]=deviceHeaderTotal+((deviceHeaderTotal==1)?" node":" nodes");deviceHeaderId++;deviceHeaderCount={};deviceHeaderTotal=0}var powerStateStrings=["",'<span title="Device is powered on.">Powered</span>','<span title="Device is in sleep state (S1).">Sleeping</span>','<span title="Device is in sleep state (S2).">Sleeping</span>','<span title="Device is in deep sleep state (S3).">Deep Sleep</span>','<span title="Device is in hibernating state (S4).">Hibernating</span>','<span title="Device is in powered off state (S5).">Soft-Off</span>','<span title="Device is detected but power state could not be obtained.">Present</span>'];var powerStateStrings2=["","Device is powered","Device is in sleep state (S1)","Device is in sleep state (S2)","Device is in deep sleep state (S3)","Device is hibernating (S4)","Device is in soft-off state (S5)","Device is present, but power state cannot be determined"];var powerColorTable=["pwsTransparent","pwsBlack","pwsBlue","pwsBlue2","pwsLightblue","pwsBlueviolet","pwsDarkgreen","pwsLightseagreen","pwsLightseagreen2"];function NodeStateStr(a){var b=[];if(a.state>0&&a.state<powerStatetable.length){state.push(powerStatetable[a.state])}if(a.conn){if((a.conn&1)!=0){b.push('<span title="Mesh agent is connected and ready for use.">Agent</span>')}if((a.conn&2)!=0){b.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">CIRA</span>')}else{if((a.conn&4)!=0){b.push('<span title="Intel&reg; AMT is routable.">Intel&reg; AMT</span>')}}if((a.conn&8)!=0){b.push('<span title="Mesh agent is reachable using another agent as relay.">Relay</span>')}}if((a.pwr!=null)&&(a.pwr!=0)){b.push(powerStateStrings[a.pwr])}return b.join(", ")}function PowerStateStr(a){if(a<powerStatetable.length){return powerStatetable[a]}return""}function PowerStateStr2(a){if((a!=0)&&(a<powerStatetable.length)){return powerStatetable[a]}return"Unknown"}function selectallButtonFunction(){var b=document.getElementsByClassName("DeviceCheckbox"),a=0;for(var c=0;c<b.length;c++){if(b[c].checked===true){a++}}for(var c=0;c<b.length;c++){b[c].checked=(a==0)}p1updateInfo()}function p1updateInfo(){var b=document.getElementsByClassName("DeviceCheckbox"),a=0;for(var c=0;c<b.length;c++){if(b[c].checked===true){a++}}if(a>0){QE("GroupActionButton",true);Q("SelectAllButton").value="Select None";QV("cxmgroupsplit",true);QV("cxmdesktop",true)}else{QE("GroupActionButton",false);Q("SelectAllButton").value="Select All";QV("cxmgroupsplit",false);QV("cxmdesktop",false)}}function groupActionFunction(){var a="Select an operation to perform on all selected devices. Actions will be performed only with proper rights.<br /><br />";a+=addHtmlValue("Operation","<select id=d2groupop><option value=100>Wake-up devices</option><option value=4>Sleep devices</option><option value=3>Reset devices</option><option value=2>Power off devices</option><option value=102>Move to device group</option><option value=101>Delete devices</option></select>");setDialogMode(2,"Group Action",3,groupActionFunctionEx,a)}function getCheckedDevices(){var e=[],b=document.getElementsByClassName("DeviceCheckbox"),a=0;for(var c=0;c<b.length;c++){if(b[c].checked){if(b[c].value){var d=b[c].value.substring(6);if(e.indexOf(d)==-1){e.push(d)}}}}return e}function groupActionFunctionEx(){var a=Q("d2groupop").value;if(a==100){meshserver.send({action:"wakedevices",nodeids:getCheckedDevices()})}else{if(a==101){var b="Confirm delete selected devices(s)?<br /><br />";b+="<label><input id=d2check type=checkbox onchange=d2groupActionFunctionDelEx() />Confirm</label>";setDialogMode(2,"Delete Nodes",3,groupActionFunctionDelEx,b);QE("idx_dlgOkButton",false)}else{if(a==102){p10showChangeGroupDialog(getCheckedDevices())}else{meshserver.send({action:"poweraction",nodeids:getCheckedDevices(),actiontype:a})}}}}function d2groupActionFunctionDelEx(){QE("idx_dlgOkButton",Q("d2check").checked)}function groupActionFunctionDelEx(){meshserver.send({action:"removedevices",nodeids:getCheckedDevices()})}function onSortSelectChange(a){sort=document.getElementById("sortselect").selectedIndex;if(!a){putstore("sort",sort)}}function meshSort(c,d){if(c.meshnamel>d.meshnamel){return 1}if(c.meshnamel<d.meshnamel){return -1}if(c.meshid==d.meshid){if(showRealNames==true){if(c.rnamel>d.rnamel){return 1}if(c.rnamel<d.rnamel){return -1}return 0}else{if(c.namel>d.namel){return 1}if(c.namel<d.namel){return -1}return 0}}return 0}function powerSort(c,e){var d=c.pwr?c.pwr:0;var g=e.pwr?e.pwr:0;if(d>g){return -1}if(d<g){return 1}if(d==g){if(showRealNames==true){if(c.rnamel>e.rnamel){return 1}if(c.rnamel<e.rnamel){return -1}return 0}else{if(c.namel>e.namel){return 1}if(c.namel<e.namel){return -1}return 0}}return 0}function deviceSort(c,d){if(c.namel>d.namel){return 1}if(c.namel<d.namel){return -1}return 0}function deviceHostSort(c,d){if(c.rnamel>d.rnamel){return 1}if(c.rnamel<d.rnamel){return -1}return 0}function onSearchFocus(a){searchFocus=a}function onMapSearchFocus(a){mapSearchFocus=a}function onUserSearchFocus(a){userSearchFocus=a}function onConsoleFocus(a){consoleFocus=a}function onSearchInputChanged(){var m=Q("SearchInput").value.toLowerCase().trim();putstore("_search",m);var l=null,g=null,c=null;if(m.startsWith("user:")){l=m.substring(5)}else{if(m.startsWith("u:")){l=m.substring(2)}else{if(m.startsWith("ip:")){g=m.substring(3)}else{if(m.startsWith("group:")){c=m.substring(6)}else{if(m.startsWith("g:")){c=m.substring(2)}}}}}if(m==""){for(var a in nodes){nodes[a].v=true}}else{if(g!=null){for(var a in nodes){nodes[a].v=((nodes[a].ip!=null)&&(nodes[a].ip.indexOf(g)>=0))}}else{if(c!=null){for(var a in nodes){nodes[a].v=(meshes[nodes[a].meshid].name.toLowerCase().indexOf(c)>=0)}}else{if(l!=null){for(var a in nodes){nodes[a].v=false;if(nodes[a].users&&nodes[a].users.length>0){for(var e in nodes[a].users){if(nodes[a].users[e].toLowerCase().indexOf(l)>=0){nodes[a].v=true}}}}}else{try{var h=m.split(/\s+/).join("|"),j=new RegExp(h);for(var a in nodes){nodes[a].v=(j.test(nodes[a].name.toLowerCase()))||(nodes[a].rnamel!=null&&j.test(nodes[a].rnamel.toLowerCase()));if((nodes[a].v==false)&&nodes[a].tags){for(var k in nodes[a].tags){if(j.test(nodes[a].tags[k].toLowerCase())){nodes[a].v=true;break}else{nodes[a].v=false}}}}}catch(b){for(var a in nodes){nodes[a].v=true}}}}}}}var contextelement=null;function handleContextMenu(d){hideContextMenu();var m=(window.pageXOffset!==null)?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft;var n=(window.pageYOffset!==null)?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;var c=document.elementFromPoint(d.pageX-m,d.pageY-n);if(c&&c!=null&&c.id=="MxMESH"){contextelement=c;var b=document.getElementById("meshContextMenu");b.style.left=d.pageX+"px";b.style.top=d.pageY+"px";b.style.display="block"}else{while(c&&c!=null&&c.id!="devs"){c=c.parentElement}if(!c||c==null){return true}contextelement=c;var b=document.getElementById("contextMenu");b.style.left=d.pageX+"px";b.style.top=d.pageY+"px";b.style.display="block"}var l=contextelement.children[1].attributes.onclick.value;var k=getNodeFromId(l.substring(12,l.length-18));var g=meshes[k.meshid];var h=g.links[userinfo._id];var j=h.rights;var a=((j&16)!=0);var o=((j==4294967295)||((j&512)==0));var e=((j==4294967295)||((j&1024)==0));QV("cxdesktop",((g.mtype==1)||(k.agent==null)||(k.agent.caps==null)||((k.agent.caps&1)!=0)||(k.intelamt&&(k.intelamt.state==2)))&&((j&8)||(j&256)));QV("cxterminal",((g.mtype==1)||(k.agent==null)||(k.agent.caps==null)||((k.agent.caps&2)!=0)||(k.intelamt&&(k.intelamt.state==2)))&&(j&8)&&o);QV("cxfiles",((g.mtype==2)&&((k.agent==null)||(k.agent.caps==null)||((k.agent.caps&4)!=0)))&&(j&8)&&e);QV("cxevents",(k.intelamt!=null)&&((k.intelamt.state==2)||(k.conn&2))&&(j&8));QV("cxconsole",(a&&(g.mtype==2)&&((k.agent==null)||(k.agent.caps==null)||((k.agent.caps&8)!=0)))&&(j&8));return haltEvent(d)}function cmaction(a,b){var d=contextelement.children[1].attributes.onclick.value;d=d.substring(12,d.length-18);if(a==7){Q("viewselect").value=3;Q("viewselect").onchange();Q("autoConnectDesktopCheckbox").checked=true;Q("autoConnectDesktopCheckbox").onclick()}if((a>0)&&(a<7)){var e=[0,10,12,11,13,16,15][a];if(b&&(b.shiftKey==true)){window.open(window.location.origin+"?node="+d.split("/")[2]+"&viewmode="+e+"&hide=16","meshcentral:"+d)}else{gotoDevice(d,e);var c=meshes[currentNode.meshid];if((currentNode.conn&1)&&(c.mtype==2)){if((e==11)&&(desktop==null)&&(currentNode.agent.caps&1)){connectDesktop(null,1)}if((e==12)&&(terminal==null)&&(currentNode.agent.caps&2)){connectTerminal(null,1)}if((e==13)&&(files==null)){connectFiles(null)}}}}}function cmmeshaction(a){var d=contextelement.attributes.onclick.value.substring(32,(32+69));var b=document.getElementsByClassName("DeviceCheckbox");if(a==1){for(var c=0;c<b.length;c++){if((b[c].attributes)&&(b[c].attributes["class"]["value"].substring(0,69)==d)){b[c].checked=true}}}if(a==2){for(var c=0;c<b.length;c++){if((b[c].attributes)&&(b[c].attributes["class"]["value"].substring(0,69)==d)){b[c].checked=false}}}p1updateInfo()}function hideContextMenu(){QV("contextMenu",false);QV("meshContextMenu",false);contextelement=null}var xxmap={map:null,contextmenu:null,activeInteractions:[],showindex:0,markersSource:null,markersLayer:null,mapLayer:null,mapView:null,};function updateMapMarkers(j){if((xxmap!=null)&&(xxmap.map==null)){try{loadmap()}catch(b){console.error("loadmap() exception",b)}}if(xxmap==null){return}var a=null;for(var d in nodes){try{var g=map_parseNodeLoc(nodes[d]),c=xxmap.markersSource.getFeatureById(nodes[d]._id);if((g!=null)&&((nodes[d].meshid==j)||(j==null))){var e=g[0],h=g[1],k=g[2];if(a==null){a=[e,h,e,h,0]}else{if(e<a[0]){a[0]=e}if(h<a[1]){a[1]=h}if(e>a[2]){a[2]=e}if(h>a[3]){a[3]=h}}if(c==null){addFeature(nodes[d]);a[4]=1}else{updateFeature(nodes[d],c);c.setStyle(markerStyle(nodes[d],g[2]))}}else{if(c){xxmap.markersSource.removeFeature(c)}}}catch(b){console.error("updateMapMarkers() exception",b,JSON.stringify(nodes[d]))}}return a}var map_cm_popup=new ol.Overlay({element:Q("xmap-info-window"),positioning:"bottom-center",stopEvent:false});var map_cm_editMarker={text:"Modify node location",callback:function(a){modifyMarkerloc(a.data)}};var map_cm_clearMarker={text:"Remove node location",callback:function(a){meshserver.send({action:"changedevice",nodeid:a.data.a,userloc:[]})}};var map_cm_saveMarker={text:"Save node location",callback:function(a){saveMarkerloc(a.data)}};var map_cm_nodemenu_items=[{text:"General information",callback:function(a){if(a.data!=null){gotoDevice(a.data,10)}}},{text:"Desktop",callback:function(a){if(a.data!=null){gotoDevice(a.data,11)}}},{text:"Terminal",callback:function(a){if(a.data!=null){gotoDevice(a.data,12)}}},{text:"Intel&reg; AMT",callback:function(a){if(a.data!=null){gotoDevice(a.data,14)}}},"-",{text:"Zoom-in to extent",callback:function(b){var a=b.data.getGeometry().getCoordinates();zoomToLocation(a,19)}},{text:"Zoom-out to extent",callback:function(b){var a=b.data.getGeometry().getCoordinates();zoomToLocation(a,2)}}];var contextmenu_items=[{text:"Refresh",callback:function(){refreshMap(true,true)}},{text:"Zoom to fit extent",callback:function(){zoomToFitExtent()}},{text:"Center map here",callback:function(a){xxmap.mapView.animate({center:a.coordinate})}},{text:"Place node here",callback:function(a){placeNode(a.coordinate)}}];function stringToIntHash(c){var a=0,b;for(b=0;b<c.length;b++){a=((a<<5)-a)+c.charCodeAt(b);a|=0}return a}function map_parseNodeLoc(b){var a=null,c=0;if(b.iploc){a=b.iploc;c=1}if(b.wifiloc){a=b.wifiloc;c=2}if(b.gpsloc){a=b.gpsloc;c=3}if(b.userloc){a=b.userloc;c=4}if((a==null)||(typeof a!="string")){return null}a=a.split(",");if(c==1){return[parseFloat(a[0])+(stringToIntHash(b._id.substring(0,20))/100000000000),parseFloat(a[1])+(stringToIntHash(b._id.substring(20))/100000000000),c]}else{return[parseFloat(a[0]),parseFloat(a[1]),c]}}function loadmap(){if(xxmap==null){return}if((features&32768)==0){QV("viewselectmapoption",false);QV("devViewButton4",false);xxmap=null;return}try{xxmap.markersSource=new ol.source.Vector();xxmap.markersLayer=new ol.layer.Vector({source:xxmap.markersSource});xxmap.mapLayer=new ol.layer.Tile({source:new ol.source.OSM()});xxmap.mapView=new ol.View({center:ol.proj.transform([0,0],"EPSG:4326","EPSG:3857"),zoom:2,minZoom:2,maxZoom:20,extent:ol.proj.transformExtent([-100000,-69.55,100000,69.55],"EPSG:4326","EPSG:3857")});xxmap.map=new ol.Map({target:"xdevicesmap",layers:[xxmap.mapLayer,xxmap.markersLayer],view:xxmap.mapView});xxmap.map.addOverlay(map_cm_popup);xxmap.map.on("click",function(c){var d=xxmap.map.forEachFeatureAtPixel(c.pixel,function(h,j){return h});if(d){var g=d.getId();if(g!=null){gotoDevice(g,10)}else{var e=getCorrespondingFeature(d);gotoDevice(e.getId(),10)}}});xxmap.map.on("pointermove",function(d){var g=xxmap.map.forEachFeatureAtPixel(d.pixel,function(j,k){return j});if(g){xxmap.map.getTargetElement().style.cursor="pointer";var c=g.getGeometry().getCoordinates();map_cm_popup.setPosition(c);var e=g.getId();if(e){QH("xmap-info-window",g.get("name"))}else{var h=getCorrespondingFeature(g);QH("xmap-info-window",h.get("name"))}}else{xxmap.map.getTargetElement().style.cursor="";QH("xmap-info-window","")}});var a=new ContextMenu({width:160,defaultItems:false,items:contextmenu_items});a.on("open",function(c){var e=xxmap.map.forEachFeatureAtPixel(c.pixel,function(h,j){return h});xxmap.contextmenu.clear();if(e){var d=e.getId();if(d){addContextMenuItems(e)}else{var g=getCorrespondingFeature(e);if(g){addContextMenuItems(g)}else{xxmap.contextmenu.extend(contextmenu_items)}}}else{xxmap.contextmenu.extend(contextmenu_items)}});if(xxmap.contextmenu==null){xxmap.contextmenu=a}xxmap.map.addControl(xxmap.contextmenu)}catch(b){console.log(b);QV("viewselectmapoption",false);QV("devViewButton4",false);xxmap=null}}function addFeature(g,c,e){var a=getModifiedFeature(g._id);if(a){xxmap.markersSource.addFeature(a)}else{if(!c&&!e){var d=map_parseNodeLoc(g);c=d[0];e=d[1]}if(e>180){e=180-e;meshserver.send({action:"changedevice",nodeid:g._id,userloc:[c,e]})}if((c<90)&&(c>-90)&&(e<180)&&(e>-180)){var b=new ol.Feature({geometry:new ol.geom.Point(ol.proj.transform([e,c],"EPSG:4326","EPSG:3857")),name:g.name,status:g.conn,lat:c,lon:e});b.setId(g._id);b.setStyle(markerStyle(g));xxmap.markersSource.addFeature(b)}}}function removeFeature(b){var a=xxmap.markersSource.getFeatureById(b._id);if(a){xxmap.markersSource.removeFeature(a)}}function updateFeature(g,a){if(g.conn!=a.get("status")){a.set("status",g.conn);a.setStyle(markerStyle(g))}var c=map_parseNodeLoc(g);if(c!=null){var b=c[0],d=c[1];if((b!=a.get("lat"))||(d!=a.get("lon"))){a.set("lat",b);a.set("lon",d);var e=ol.proj.transform([parseFloat(d),parseFloat(b)],"EPSG:4326","EPSG:3857");a.getGeometry().setCoordinates(e)}}if(g.name!=a.get("name")){a.set("name",g.name)}}function modifyMarkerloc(c){var b=c.getId();if(b){c.setStyle(markerStyle(getNodeFromId(c.a),4));if(!getActiveInteractions(c)){var a=new ol.interaction.Modify({features:new ol.Collection([c]),pixelTolerance:10});xxmap.activeInteractions.push({featureid:b,feature:c,interaction:a});xxmap.map.addInteraction(a)}}}function saveMarkerloc(d){var c=d.getId();if(c){var a=getActiveInteractions(d);if(a){xxmap.map.removeInteraction(a);removeInteraction(c);var b=d.getGeometry().getCoordinates();var e=ol.proj.transform(b,"EPSG:3857","EPSG:4326");if(e[0]>180){e[0]=180-e[0]}var g=[e[1],e[0]];meshserver.send({action:"changedevice",nodeid:c,userloc:g})}}}function markerStyle(b,d){if(d==null){d=0;if(b.iploc){d=1}if(b.wifiloc){d=2}if(b.gpsloc){d=3}if(b.userloc){d=4}}var e=["","-ip","-wifi","-gps","-user"];var a=connStateColor(b);var c=new ol.style.Style({image:new ol.style.Icon({color:a,anchor:[0.5,1],src:"images/mapmarker"+e[d]+".png"})});return[c]}function connStateColor(a){if(a.conn==1||a.conn==3||a.conn==5){return"#00ffdd"}return"#C70039"}function addContextMenuItems(a){if(getActiveInteractions(a)){map_cm_saveMarker.data=a;xxmap.contextmenu.push(map_cm_saveMarker)}else{map_cm_editMarker.data=a;xxmap.contextmenu.push(map_cm_editMarker);var b=getNodeFromId(a.a);if(b.userloc){map_cm_clearMarker.data=a;xxmap.contextmenu.push(map_cm_clearMarker)}}map_cm_nodemenu_items.forEach(function(c){if(c.text=="Zoom-in to extent"||c.text=="Zoom-out to extent"){c.data=a}else{if(c!="-"){c.data=a.getId()}}});xxmap.contextmenu.extend(map_cm_nodemenu_items)}function getActiveInteractions(b){var a=b.getId();for(var c=0;c<xxmap.activeInteractions.length;c++){if(xxmap.activeInteractions[c].featureid==a){return xxmap.activeInteractions[c].interaction}}return false}function getModifiedFeature(a){if(a){for(var b=0;b<xxmap.activeInteractions.length;b++){if(xxmap.activeInteractions[b].featureid==a){return xxmap.activeInteractions[b].feature}}}return null}function removeInteraction(a){var c=-1;for(var b=0;b<xxmap.activeInteractions.length;b++){if(xxmap.activeInteractions[b].featureid===a){c=b;break}}if(c>=0){xxmap.activeInteractions.splice(c,1)}}function getCorrespondingFeature(e){var d=e.getGeometry().getCoordinates();for(var b=0;b<xxmap.activeInteractions.length;b++){var c=xxmap.activeInteractions[b].feature;var a=c.getGeometry().getCoordinates();if(a[0].toFixed(5)==d[0].toFixed(5)&&a[1].toFixed(5)==d[1].toFixed(5)){return c}}return null}function refreshMap(k,h){if(k){xxmap.map.setTarget(null);xxmap.map=null;xxmap.markersSource=null;xxmap.mapView=null;xxmap.mapLayer=null;xxmap.activeInteractions=[]}var a=updateMapMarkers();if((a!=null)&&(h||(a[4]==1))){var b=(a[0]+a[2])/2;var c=(a[1]+a[3])/2;var d=Math.max(Math.abs(a[0]-a[2]),Math.abs(a[1]-a[3]));var l=xxmap.map.getView();l.setCenter(ol.proj.transform([c,b],"EPSG:4326","EPSG:3857"));var e=360,g=-2;while(e>d){g++;e=e/2}l.setZoom(g)}}function placeNode(a){if(xxdialogMode){return}var c='<div style=margin-bottom:6px><label for=selectnode-search>Search</label>&nbsp&nbsp<input type=text placeholder="Device name" id="selectnode-search" onchange=onPlaceNodeInputChange() onkeyup=onPlaceNodeInputChange() autocomplete=off style=width:120px></div><div id=placenode style="height:254px;overflow-y:auto;width:100%;margin:12px 1px 4px 1px;"><div id=noNodesMapPlace style=text-align:center;width:100%;display:none>No devices found.</div>';for(var b in nodes){c+="<div class=noselect id="+nodes[b]._id+"-rowid onclick=selectNodeToPlace(event,'"+nodes[b]._id+"') style=background-color:lightgray;margin-bottom:4px;border-radius:2px><input name=PlaceMapDeviceCheckbox id="+nodes[b]._id+"-checkid type=checkbox style=width:16px;display:inline />";c+="<div class=j"+nodes[b].icon+" style=width:16px;height:16px;margin-top:2px;margin-right:4px;display:inline-block></div><div style=width:16px;display:inline>"+nodes[b].name+"</div></div>"}setDialogMode(2,"Select a node to place",3,placeNodeEx,c+"</div>",a);onPlaceNodeInputChange()}function placeNodeEx(b,c){var d=document.getElementsByName("PlaceMapDeviceCheckbox");for(var g in d){if(d[g].checked){var h=getNodeFromId(d[g].id.substring(0,d[g].id.length-8));if(h){var e=xxmap.markersSource.getFeatureById(g);var j=ol.proj.transform(c,"EPSG:3857","EPSG:4326");var k=[j[1],j[0]];if(e){e.getGeometry().setCoordinates(c);var a=getActiveInteractions(e);if(a){saveMarkerloc(e)}else{meshserver.send({action:"changedevice",nodeid:h._id,userloc:k})}}else{meshserver.send({action:"changedevice",nodeid:h._id,userloc:k})}}}}}function onPlaceNodeInputChange(){updatePlaceNodeTable(Q("selectnode-search").value.trim().toLowerCase())}function updatePlaceNodeTable(d){var b=document.getElementsByName("PlaceMapDeviceCheckbox"),a=0;for(var c in nodes){var e=((nodes[c].namel.indexOf(d)>=0||d=="")||(nodes[c].rnamel!=null&&nodes[c].rnamel.indexOf(d)>=0));if(e){a++}QV(nodes[c]._id+"-rowid",e)}QV("noNodesMapPlace",a==0)}function selectNodeToPlace(b,g){if(b.target.name!="PlaceMapDeviceCheckbox"){var h=Q(g+"-checkid");h.checked=!h.checked}var c=document.getElementsByName("PlaceMapDeviceCheckbox"),a=0;for(var d in c){if(c[d].checked){a++}}QE("idx_dlgOkButton",a>0)}function addMeshOptions(a,b){}function meshOptionRmvMod(a,b){}function meshExists(){for(var a in meshes){if(meshes[a]){return true}}return false}function setMeshView(a){var c=Q("select-mesh");var b=c.selectedIndex;if(c[b].value==a){c[0].selected=true;onSelectMeshChange()}}function clearMeshOptions(){}function getSearchLocation(){try{var b=Q("mapSearchLocation").value.trim();if(b.length>0){var c=new XMLHttpRequest();c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){formatSearchData(c.responseText)}};c.open("GET","https://nominatim.openstreetmap.org/search?q="+b+"&format=json",true);c.send()}}catch(a){}}function formatSearchData(b){try{QH("xmapSearchResults","");var c=JSON.parse(b),a=0,k='<div class="xmapItem">';for(var h=0;h<c.length;h++){if(c[h].display_name&&c[h].boundingbox[0]&&c[h].boundingbox[1]&&c[h].boundingbox[2]&&c[h].boundingbox[3]){a++;var j=(h%2==0)?"xmapItemSel1":"xmapItemSel1";k+='<div class="'+j+'" onclick=mapGotoSelectedLocation(this)><div>'+c[h].display_name+"</div><div style=display:none>"+c[h].boundingbox[0]+"!#!"+c[h].boundingbox[1]+"!#!"+c[h].boundingbox[2]+"!#!"+c[h].boundingbox[3]+"</div></div>"}}k+="</div>";if(a==1){var g=[parseFloat(c[0].boundingbox[2]),parseFloat(c[0].boundingbox[0]),parseFloat(c[0].boundingbox[3]),parseFloat(c[0].boundingbox[1])];zoomToExtent(g)}else{if(a==0){k="<div style=width:200px>No location found.<div>"}QV("xmapSearchResultsDlg",true)}QH("xmapSearchResults",k)}catch(d){}}function mapGotoSelectedLocation(c){var d=c.children;var a=d[1].innerHTML.split("!#!");var b=[parseFloat(a[2]),parseFloat(a[0]),parseFloat(a[3]),parseFloat(a[1])];zoomToExtent(b);mapCloseSearchWindow()}function mapCloseSearchWindow(){QH("xmapSearchResults","");QV("xmapSearchResultsDlg",false)}function zoomToLocation(a,c){var b=xxmap.map.getView();b.setCenter(a);b.setZoom(c)}function zoomToFitExtent(){var b=xxmap.markersSource.getFeatures();if(b.length>0){var a=xxmap.markersSource.getExtent();xxmap.map.getView().fit(a,xxmap.map.getSize())}}function zoomToExtent(b){var a=ol.proj.transformExtent(b,ol.proj.get("EPSG:4326"),ol.proj.get("EPSG:3857"));xxmap.map.getView().fit(a,xxmap.map.getSize())}function refreshDevice(a){if(!currentNode||currentNode._id!=a){return}gotoDevice(a,xxcurrentView,true)}function getNodeRights(c){var b=getNodeFromId(c),a=meshes[b.meshid];return a.links[userinfo._id].rights}var currentNode;var powerTimelineNode=null;var powerTimelineReq=null;var powerTimelineUpdate=null;var powerTimeline=null;function getCurrentNode(){return currentNode}function gotoDevice(r,t,w,j){if((userinfo.emailVerified!==true)&&(serverinfo.emailcheck==true)&&(userinfo.siteadmin!=4294967295)){setDialogMode(2,"Account Security",1,null,'Unable to access a device until a email address is verified. This is required for password recovery. Go to the "My Account" tab to change and verify an email address.');return}if((features&262144)&&!((userinfo.otpsecret==1)||(userinfo.otphkeys>0)||(userinfo.otpkeys>0))){setDialogMode(2,"Account Security",1,null,'Unable to access a device until two-factor authentication is enabled. This is required for extra security. Go to the "My Account" tab and look at the "Account Security" section.');return}if(j&&(j.shiftKey==true)){window.open(window.location.origin+"?node="+r.split("/")[2]+"&viewmode=10&hide=16","meshcentral:"+r);return}var q=getNodeFromId(r);var n=meshes[q.meshid];var o=n.links[userinfo._id].rights;if(!currentNode||currentNode._id!=q._id||w==true){currentNode=q;var p=EscapeHtml(q.name);if(p.length==0){p="<i>None</i>"}if(((o&4)!=0)&&((!n.flags)||((n.flags&2)==0))){p='<span tabindex=0 title="Click here to edit the server-side device name" onclick=showEditNodeValueDialog(0) onkeyup="if (event.key == \'Enter\') showEditNodeValueDialog(0)" style=cursor:pointer>'+p+' <img class=hoverButton src="images/link5.png" /></span>'}QH("p10deviceName",p);QH("p11deviceName",p);QH("p12deviceName",p);QH("p13deviceName",p);QH("p14deviceName",p);QH("p15deviceName","Console - "+p);QH("p16deviceName",p);var B="<table style=width:100%>";B+=addDeviceAttribute('<span title="The name of the device group this computer belong to.">Group</span>','<a href=# title="The name of the device group this computer belong to" onclick=gotoMesh("'+q.meshid+'") style=cursor:pointer>'+EscapeHtml(meshes[q.meshid].name)+"</a>");if((q.rname!=null)&&(q.name!=q.rname)){B+=addDeviceAttribute('<span title="The name of this computer as set in the operating system">Name</span>','<span title="The name of this computer as set in the operating system">'+EscapeHtml(q.rname)+"</span>")}if((features&1)==0){if((o&4)!=0){if(q.host){B+=addDeviceAttribute("Hostname","<span onclick=showEditNodeValueDialog(1) style=cursor:pointer>"+EscapeHtml(q.host)+"</span>")}else{B+=addDeviceAttribute("Hostname","<span onclick=showEditNodeValueDialog(1) style=cursor:pointer><i>None</i></span>")}}else{B+=addDeviceAttribute("Hostname",EscapeHtml(q.host))}}var h=q.desc?EscapeHtml(q.desc):"<i>None</i>";if((o&4)!=0){B+=addDeviceAttribute("Description","<span onclick=showEditNodeValueDialog(2) style=cursor:pointer>"+h+' <img class=hoverButton src="images/link5.png" /></span>')}else{B+=addDeviceAttribute("Description",h)}var a=["Unknown","Windows 32bit console","Windows 64bit console","Windows 32bit service","Windows 64bit service","Linux 32bit","Linux 64bit","MIPS","XENx86","Android ARM","Linux ARM","MacOS 32bit","Android x86","PogoPlug ARM","Android APK","Linux Poky x86-32bit","MacOS 64bit","ChromeOS","Linux Poky x86-64bit","Linux NoKVM x86-32bit","Linux NoKVM x86-64bit","Windows MinCore console","Windows MinCore service","NodeJS","ARM-Linaro","ARMv6l / ARMv7l","ARMv8 64bit","ARMv6l / ARMv7l / NoKVM","Unknown","Unknown","FreeBSD x86-64"];if((q.agent!=null)&&(q.agent.id!=null)&&(q.agent.ver!=null)){var y="";if(q.agent.id<=a.length){y=a[q.agent.id]}else{y=a[0]}if(q.agent.ver!=0){y+=" v"+q.agent.ver}B+=addDeviceAttribute("Mesh Agent",y)}if(q.intelamt!=null){var y="";var v={0:"Not Activated (Pre)",1:"Not Activated (In)",2:"Activated"};if(q.intelamt.ver!=null&&q.intelamt.state==null){y+="<i>Unknown State</i>, v"+q.intelamt.ver}else{if((q.intelamt.ver==null)&&(q.intelamt.state==2)){y+="<i>Activated</i>"}else{if((q.intelamt.ver==null)||(q.intelamt.state==null)){y+="<i>Unknown Version & State</i>"}else{y+=v[q.intelamt.state];if((q.intelamt.state==2)&&q.intelamt.flags){if(q.intelamt.flags&2){y+=' <span title="Intel AMT is activated in Client Control Mode">CCM</span>'}else{if(q.intelamt.flags&4){y+=' <span title="Intel AMT is activated in Admin Control Mode">ACM</span>'}}}y+=(", v"+q.intelamt.ver)}}}if(q.intelamt.tls==1){y+=', <span title="Intel AMT is setup with TLS network security">TLS</span>'}if(q.intelamt.state==2){if(q.intelamt.user==null||q.intelamt.user==""){if((o&4)!=0){y+=', <i style=color:#FF0000;cursor:pointer title="Edit Intel&reg; AMT credentials" onclick=editDeviceAmtSettings("'+q._id+'")>No Credentials</i>'}else{y+=", <i style=color:#FF0000>No Credentials</i>"}}y+=" ";if((o&4)!=0){y+='<img src=images/link4.png height=10 width=10 title="Edit Intel&reg; AMT credentials" style=cursor:pointer onclick=editDeviceAmtSettings("'+q._id+'")>'}}B+=addDeviceAttribute("Intel&reg; AMT",y)}if(n.mtype==2){if((q.agent!=null)&&(q.agent.tag!=null)){var z=EscapeHtml(q.agent.tag);if(z.startsWith("mailto:")){z='<a href="'+z+'">'+z.substring(7)+"</a>"}B+=addDeviceAttribute("Agent Tag",z)}}else{if((q.intelamt!=null)&&(q.intelamt.tag!=null)){var z=EscapeHtml(q.intelamt.tag);if(z.startsWith("mailto:")){z='<a href="'+z+'">'+z.substring(7)+"</a>"}B+=addDeviceAttribute("Intel&reg; AMT Tag",z)}}if(q.osdesc){B+=addDeviceAttribute("Operating System",q.osdesc)}if(q.users&&q.conn&&(q.users.length>0)&&(q.conn&1)){B+=addDeviceAttribute("Active User"+((q.users.length>1)?"s":""),q.users.join(", "))}var d=q.conn;if(d&&d>1){var g=[];if((q.conn&1)!=0){g.push('<span title="Mesh agent is connected and ready for use.">Mesh Agent</span>')}if((q.conn&2)!=0){g.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">Intel&reg; AMT CIRA</span>')}else{if((q.conn&4)!=0){g.push('<span title="Intel&reg; AMT is routable and ready for use.">Intel&reg; AMT</span>')}}if((q.conn&8)!=0){g.push('<span title="Mesh agent is reachable using another agent as relay.">Mesh Relay</span>')}B+=addDeviceAttribute("Connectivity",g.join(", "))}var l="<i>None</i>";if(q.tags!=null){l="";for(var m in q.tags){l+='<span class="tagSpan">'+q.tags[m]+"</span>"}}if((o&4)!=0){B+=addDeviceAttribute("Tags","<span onclick=showEditNodeValueDialog(3) style=cursor:pointer>"+l+' <img class=hoverButton src="images/link5.png" /></span>')}else{B+=addDeviceAttribute("Tags",l)}B+="</table><br />";if((o&76)!=0){B+='<input type=button value=Actions title="Perform power actions on the device" onclick=deviceActionFunction() />'}B+='<input type=button value=Notes title="View notes about this device" onclick=showNotes('+((o&128)==0)+',"'+encodeURIComponent(q._id)+'") />';QH("p10html",B);masterUpdate(256);B='<div class="p10html3right">';if((o&4)!=0){B+='&nbsp;<a href=# onclick=p10showChangeGroupDialog(["'+q._id+'"]) title="Move this device to a different device group">Change Group</a>';B+='&nbsp;<a href=# onclick=p10showDeleteNodeDialog("'+q._id+'") title="Remove this device">Delete Device</a>'}B+='</div><div class="p10html3left">';if(n.mtype==2){B+='<a href=# onclick=p10showNodeNetInfoDialog("'+q._id+'") title="Show device network interface information">Interfaces</a>&nbsp;'}if(xxmap!=null){B+='<a href=# onclick=p10showNodeLocationDialog("'+q._id+'") title="Show device locations information">Location</a>&nbsp;'}if(((o&8)!=0)&&(n.mtype==2)){B+='<a href=# onclick=p10showMeshCmdDialog(1,"'+q._id+'") title="Traffic router used to connect to a device thru this server.">Router</a>&nbsp;'}if(((d&1)!=0)&&(clickOnce==true)&&(n.mtype==2)&&((o&8)!=0)){if((q.agent.id>0)&&(q.agent.id<5)){B+='<a href=# onclick=p10clickOnce("'+q._id+'","RDP2",3389) title="Requires Microsoft ClickOnce support in your browser.">RDP</a>&nbsp;'}if(q.agent.id>4){B+='<a href=# onclick=p10clickOnce("'+q._id+'","PSSH",22) title="Requires Microsoft ClickOnce support in your browser.">Putty</a>&nbsp;';B+='<a href=# onclick=p10clickOnce("'+q._id+'","WSCP",22) title="Requires Microsoft ClickOnce support in your browser.">WinSCP</a>&nbsp;'}}B+="</div><br>";QH("p10html3",B);var u=PowerStateStr(q.state);if((d&1)!=0){if(u.length>0){u+="<br/>"}u+='<span style=font-size:12px title="Agent connected">Agent connected</span>'}if((d&2)!=0){if(u.length>0){u+="<br/>"}u+='<span style=font-size:12px title="Intel&reg; AMT connected">Intel&reg; AMT connected</span>'}else{if((d&4)!=0){if(u.length>0){u+="<br/>"}u+='<span style=font-size:12px title="Intel&reg; AMT detected">Intel&reg; AMT detected</span>'}}if((u=="")&&q.lastconnect){u="<span style=font-size:12px>Last seen:<br />"+printDateTime(new Date(q.lastconnect))+"</span>"}QH("MainComputerState",u);Q("MainComputerImage").setAttribute("src","images/icons256-"+q.icon+"-1.png");Q("MainComputerImage").className=((!q.conn)||(q.conn==0)?"gray":"");var A=((o==4294967295)||((o&512)==0));var k=((o==4294967295)||((o&1024)==0));var b=((o==4294967295)||((o&2048)==0));if(A){setupTerminal()}if(k){setupFiles()}var e=((o&16)!=0);if(e){setupConsole()}else{if(t==15){t=10}}QV("MainDevDesktop",((n.mtype==1)||(q.agent==null)||(q.agent.caps==null)||((q.agent.caps&1)!=0)||(q.intelamt&&(q.intelamt.state==2)))&&((o&8)||(o&256)));QV("MainDevTerminal",((n.mtype==1)||(q.agent==null)||(q.agent.caps==null)||((q.agent.caps&2)!=0)||(q.intelamt&&(q.intelamt.state==2)))&&(o&8)&&A);QV("MainDevFiles",((n.mtype==2)&&((q.agent==null)||(q.agent.caps==null)||((q.agent.caps&4)!=0)))&&(o&8)&&k);QV("MainDevAmt",(q.intelamt!=null)&&((q.intelamt.state==2)||(q.conn&2))&&(o&8)&&b);QV("MainDevConsole",(e&&(n.mtype==2)&&((q.agent==null)||(q.agent.caps==null)||((q.agent.caps&8)!=0)))&&(o&8));QV("p15uploadCore",(q.agent!=null)&&(q.agent.caps!=null)&&((q.agent.caps&16)!=0));QH("p15coreName",((q.agent!=null)&&(q.agent.core!=null))?q.agent.core:"");var c=Q("p14iframe").contentWindow.getCurrentMeshNode();if((c!=null)&&(c._id!=currentNode._id)){Q("p14iframe").contentWindow.disconnect()}var s=((q.conn&6)!=0)?true:false;Q("p14iframe").contentWindow.setConnectionState(s);Q("p14iframe").contentWindow.setFrameHeight("650px");Q("p14iframe").contentWindow.setAuthCallback(updateAmtCredentials);QV("deskActionsBtn",(o&72)!=0);QV("termActionsBtn",(o&72)!=0);QV("filesActionsBtn",(o&72)!=0);if((powerTimelineNode!=currentNode._id)&&(powerTimelineReq!=currentNode._id)){QH("p10html2","");powerTimelineReq=currentNode._id;meshserver.send({action:"powertimeline",nodeid:currentNode._id});meshserver.send({action:"lastconnect",nodeid:currentNode._id})}QV("DeskTools",false);showDeskToolsProcesses();refreshDeviceEvents();if((currentNode)&&(xxcurrentView>=10)&&(xxcurrentView<20)){document.title=decodeURIComponent("{{{extitle}}}")+" - "+currentNode.name}else{document.title=decodeURIComponent("{{{extitle}}}")}p11clearConsoleMsg();p12clearConsoleMsg();p13clearConsoleMsg()}setupDesktop();if(!t){t=10}go(t)}function showNotes(b,a){if(xxdialogMode){return}setDialogMode(2,"Notes",2,showNotesEx,"<textarea id=d2devNotes ro="+b+" noteid="+a+" readonly style=background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:scroll></textarea><span style=font-size:10px>Device group notes can be viewed and changed by other device group administrators.<span>",a);meshserver.send({action:"getNotes",id:decodeURIComponent(a)})}function showNotesEx(a,b){meshserver.send({action:"setNotes",id:decodeURIComponent(b),notes:encodeURIComponent(Q("d2devNotes").value)})}function deviceChat(){if(xxdialogMode){return}var a="/messenger?id=meshmessenger/"+encodeURIComponent(currentNode._id)+"/"+encodeURIComponent(userinfo._id)+"&title="+currentNode.name;if((authCookie!=null)&&(authCookie!="")){a+="&auth="+authCookie}window.open(a,"meshmessenger:"+currentNode._id);meshserver.send({action:"meshmessenger",nodeid:decodeURIComponent(currentNode._id)})}function deviceUrlFunction(){if(xxdialogMode){return}setDialogMode(2,"Open Page on Device",3,deviceUrlFunctionEx,'<input id=d2devurl placeholder="http://server.com" style=width:100%;overflow-y:scroll></input>')}function deviceUrlFunctionEx(){meshserver.send({action:"msg",type:"openUrl",nodeid:currentNode._id,url:Q("d2devurl").value})}function deviceToastFunction(){if(xxdialogMode){return}setDialogMode(2,"Device Notification",3,deviceToastFunctionEx,"<textarea id=d2devToast style=width:100%;height:80px;resize:none;overflow-y:scroll></textarea>")}function deviceToastFunctionEx(){meshserver.send({action:"toast",nodeids:[currentNode._id],title:"MeshCentral",msg:Q("d2devToast").value})}function deviceActionFunction(){if(xxdialogMode){return}var a=meshes[currentNode.meshid].links[userinfo._id].rights;var b="Select an operation to perform on this device.<br /><br />";var c="<select id=d2deviceop style=float:right;width:250px>";if((a&64)!=0){c+="<option value=100>Wake-up</option>"}if((a&8)!=0){c+="<option value=4>Sleep</option><option value=3>Reset</option><option value=2>Power off</option>"}c+="</select>";b+=addHtmlValue("Operation",c);setDialogMode(2,"Device Action",3,deviceActionFunctionEx,b)}function deviceActionFunctionEx(){var a=Q("d2deviceop").value;if(a==100){meshserver.send({action:"wakedevices",nodeids:[currentNode._id]})}else{meshserver.send({action:"poweraction",nodeids:[currentNode._id],actiontype:a})}}function updateAmtCredentials(a){var b=getNodeFromId(currentNode._id);if((a==true)||(b.intelamt.user==null)||(b.intelamt.user=="")){editDeviceAmtSettings(currentNode._id,updateAmtCredentialsEx)}else{Q("p14iframe").contentWindow.connectButtonfunctionEx()}}function updateAmtCredentialsEx(a,b){Q("p14iframe").contentWindow.connectButtonfunctionEx()}function updateDeviceTimeline(){if((meshserver.State!=2)||(powerTimelineNode==null)||(powerTimelineUpdate==null)||(currentNode==null)){return}if((powerTimelineNode==powerTimelineReq)&&(currentNode._id==powerTimelineNode)&&(powerTimelineUpdate<Date.now())){powerTimelineUpdate=null;meshserver.send({action:"powertimeline",nodeid:currentNode._id});meshserver.send({action:"lastconnect",nodeid:currentNode._id})}}function drawDeviceTimeline(){if((currentNode==null)||(xxcurrentView<10)||(xxcurrentView>19)){return}var s=null,o=Date.now();if(currentNode._id==powerTimelineNode){s=powerTimeline}var e=new Date();e.setHours(0,0,0,0);e=new Date(e.getTime()-(1000*60*60*24*6));var u=e.getTime();var t=[];if(s!=null&&s.length>1){t.push([0,s[1],s[0]]);var c=s[1];for(var m=2;m<s.length;m+=2){var p=s[m],k=o;if(s.length>(m+1)){k=s[m+1]}t.push([c,c+k,p]);c=c+k}}var A="",b=1,h=new Date();var w=Q("masthead").offsetWidth-(160+9+9+14);h.setHours(0,0,0,0);for(var m=0;m<7;m++){var g="",q=h.getTime(),l=q+(1000*60*60*24);for(var n in t){var a=t[n];if(isTimeBlockInside(q,l,a[0],a[1])==true){var y=Math.max(q,a[0]);var r=Math.min(Math.min(l,a[1]),o);var z=Math.round(((r-y)*w)/86400000);if(z>0){var v=powerStateStrings2[a[2]]+" from "+printTime(new Date(y))+" to "+printTime(new Date(r))+".";g+='<div class="pwState '+powerColor(a[2])+'" title="'+v+'" style="width:'+z+'px;"></div>'}}}A+="<tr class="+(((b%2)==0)?"altBack":"")+"><td><div>&nbsp;"+printDate(h)+"<div></div></div></td><td><div>"+g+"</div></td></tr>";++b;h=new Date(h.getTime()-(1000*60*60*24))}QH("p10html2",'<table cellpadding=2 cellspacing=0><thead><tr style=><th scope=col style=text-align:center;width:150px>Day</th><th scope=col style=text-align:center><a download href="devicepowerevents.ashx?id='+currentNode._id+'" onclick="setDialogMode(0)"><img title="Download power events" src="images/link4.png" /></a>7 Day Power State</th></tr></thead><tbody>'+A+"</tbody></table>")}function powerColor(a){if(a<powerColorTable.length){return powerColorTable[a]}return"pwsYellow"}function isTimeBlockInside(d,c,b,a){if((b<d)&&(a>c)){return true}if((b>d)&&(b<c)){return true}if((a>d)&&(a<c)){return true}return false}function addDeviceAttribute(a,b){return"<tr><td class=style7>"+a+"</td><td class=style9>"+b+"</td></tr>"}function editDeviceAmtSettings(g,c,a){if(xxdialogMode){return}var h="",e=getNodeFromId(g),b=3,d=getNodeRights(g);if((d&4)==0){return}h+=addHtmlValue("Username",'<input id=dp10username style=width:230px maxlength=32 autocomplete=nope placeholder="admin" onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />');h+=addHtmlValue("Password","<input id=dp10password type=password style=width:230px autocomplete=nope maxlength=32 onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />");h+=addHtmlValue("Security","<select id=dp10tls style=width:236px><option value=0>No TLS security</option><option value=1>TLS security required</option></select>");if((e.intelamt.user!=null)&&(e.intelamt.user!="")){b=7}setDialogMode(2,"Edit Intel&reg; AMT credentials",b,editDeviceAmtSettingsEx,h,{node:e,func:c,arg:a});if((e.intelamt.user!=null)&&(e.intelamt.user!="")){Q("dp10username").value=e.intelamt.user}else{Q("dp10username").value="admin"}Q("dp10tls").value=e.intelamt.tls;validateDeviceAmtSettings()}function validateDeviceAmtSettings(){QE("idx_dlgOkButton",passwordcheck(Q("dp10password").value))}function editDeviceAmtSettingsEx(c,d){if(c==2){meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:"",pass:""}})}else{var b=Q("dp10username").value;if(b==""){b="admin"}var a=Q("dp10password").value;if(a==""){b=""}meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:b,pass:a,tls:Q("dp10tls").value}});d.node.intelamt.user=b;d.node.intelamt.tls=Q("dp10tls").value;if(d.func){setTimeout(function(){d.func(null,d.arg)},300)}}}function p10showChangeGroupDialog(e){if(xxdialogMode){return false}var g=null;if(e.length==1){try{g=meshes[getNodeFromId(e[0])]._id}catch(b){}}var j="<select id=p10newGroup style=width:236px>",a=0;for(var c in meshes){var d=meshes[c].links[userinfo._id].rights;if((meshes[c]._id!=g)&&(d&4)){a++;j+="<option value='"+meshes[c]._id+"'>"+meshes[c].name+"</option>"}}j+="</select>";if(a>0){var h=(e.length==1)?"Select a new group for this device<br /><br />":"Select a new group for selected devices<br /><br />";h+=addHtmlValue("New Device Group",j);setDialogMode(2,"Change Group",3,p10showChangeGroupDialogEx,h,e)}else{setDialogMode(2,"Change Group",1,null,"No other device group of same type exists.")}return false}function p10showChangeGroupDialogEx(a,c){meshserver.send({action:"changeDeviceMesh",nodeids:c,meshid:Q("p10newGroup").value})}function p10showDeleteNodeDialog(a){if(xxdialogMode){return false}var b='Are you sure you want to delete node "'+EscapeHtml(currentNode.name)+'"?<br /><br />';b+="<label><input id=p10check type=checkbox onchange=p10validateDeleteNodeDialog() />Confirm</label>";setDialogMode(2,"Delete Node",3,p10showDeleteNodeDialogEx,b,a);p10validateDeleteNodeDialog();return false}function p10validateDeleteNodeDialog(){QE("idx_dlgOkButton",Q("p10check").checked)}function p10showDeleteNodeDialogEx(a,b){meshserver.send({action:"removedevices",nodeids:[b]})}function p10clickOnce(a,c,b){meshserver.send({action:"getcookie",nodeid:a,tcpport:b,tag:"clickonce",protocol:c});return false}var d2map=null;function p10showNodeLocationDialog(){if((xxdialogMode!=null)&&(xxdialogTag=="@xxmap")){setDialogMode(0)}else{if(xxdialogMode){return false}}var m=[],n=["iploc","wifiloc","gpsloc","userloc"],a=null;for(var k in n){if(currentNode[n[k]]!=null){var j=currentNode[n[k]].split(","),h=parseFloat(j[0]),l=parseFloat(j[1]);if((h<90)&&(h>-90)&&(l<180)&&(l>-180)){var e=new ol.Feature({geometry:new ol.geom.Point(ol.proj.fromLonLat([l,h]))});e.setStyle(markerStyle(currentNode,parseInt(k)+1));m.push(e);if(a==null){a=[h,l,h,l,0]}else{if(h<a[0]){a[0]=h}if(l<a[1]){a[1]=l}if(h>a[2]){a[2]=h}if(l>a[3]){a[3]=l}}}}}var p=new ol.source.Vector({features:m});var o=new ol.layer.Vector({source:p});var q="<div id=d2map style=width:100%;height:300px></div>";setDialogMode(2,"Device Location",1,null,q,"@xxmap");var c=0,b=0,r=8;if(a!=null){var b=(a[0]+a[2])/2;var c=(a[1]+a[3])/2;var d=Math.max(Math.abs(a[0]-a[2]),Math.abs(a[1]-a[3]));var g=360,r=-2;while(g>d){r++;g=g/2}}if(m.length==1){r=8}d2map=new ol.Map({target:"d2map",interactions:ol.interaction.defaults({dragPan:false,mouseWheelZoom:false}),layers:[new ol.layer.Tile({source:new ol.source.OSM()}),o],view:new ol.View({center:ol.proj.fromLonLat([c,b]),zoom:r})});return false}function p10showNodeNetInfoDialog(){if(xxdialogMode){return false}setDialogMode(2,"Network Interfaces",1,null,"<div id=d2netinfo>Loading...</div>","if"+currentNode._id);meshserver.send({action:"getnetworkinfo",nodeid:currentNode._id});return false}function p10showMeshRouterDialog(){if(xxdialogMode){return}var a="<div>MeshCentral Router is a Windows tool for TCP port mapping. You can, for example, RDP into a remote device thru this server.</div><br />";a+=addHtmlValue("Win32 Executable",'<a style=cursor:pointer download href="meshagents?meshaction=winrouter" onclick="setDialogMode(0)">MeshCentralRouter.exe</a>');setDialogMode(2,"MeshCentral Router",1,null,a,"fileDownload")}function p10showMeshCmdDialog(a,b){if(xxdialogMode){return}var d="<select id=aginsSelect onclick=meshCmdOsClick() style=width:236px>";d+="<option value=3>Windows (32bit)</option>";d+="<option value=4>Windows (64bit)</option>";d+="<option value=5>Linux x86 (32bit)</option>";d+="<option value=6>Linux x86 (64bit)</option>";d+="<option value=16>MacOS (64bit)</option>";d+="<option value=25>Linux ARM, Raspberry Pi (32bit)</option>";d+="</select>";var c="";if(a==0){c+="<div>MeshCmd is a command line tool that performs lots of different operations. The action file can optionally be downloaded and edited to provide server information and credentials.<br /><br />"}if(a==1){c+='<div>Download "meshcmd" with an action file to route traffic thru this server to this device. Make sure to edit meshaction.txt and add your account password or make any changes needed.<br /><br />'}c+=addHtmlValue("Operating System",d);c+=addHtmlValue("MeshCmd",'<a id=meshcmddownloadid href="meshagents?meshcmd=3" download></a>');if(a==0){c+=addHtmlValue("Action File",'<a href="meshagents?meshaction=generic" download>MeshAction (.txt)</a>')}if(a==1){c+=addHtmlValue("Action File",'<a href="meshagents?meshaction=route&nodeid='+b+'" download>MeshAction (.txt)</a>')}c+="</div>";setDialogMode(2,["Download MeshCmd","Network Router"][a],9,null,c,"fileDownload");meshCmdOsClick()}function meshCmdOsClick(){var a=Q("aginsSelect").value,b="",c="";if(a==3){b="MeshCmd (Win32 executable)"}if(a==4){b="MeshCmd (Win64 executable)"}if(a==5){b="MeshCmd (Linux x86, 32bit)"}if(a==6){b="MeshCmd (Linux x86, 64bit)"}if(a==16){b="MeshCmd (MacOS, 64bit)"}if(a==25){b="MeshCmd (Linux ARM, 32bit)"}QH("meshcmddownloadid",b);Q("meshcmddownloadid").setAttribute("href","meshagents?meshcmd="+a)}function p10showiconselector(){if(xxdialogMode){return}var a=meshes[currentNode.meshid];var b=a.links[userinfo._id].rights;if((b&4)==0){return}var c="<br><div style=display:inline-block;width:40px></div>";c+="<div tabindex=0 style=display:inline-block class=i1 onclick=p10setIcon(1) onkeypress=\"if (event.key=='Enter') p10setIcon(1)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i2 onclick=p10setIcon(2) onkeypress=\"if (event.key=='Enter') p10setIcon(2)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i3 onclick=p10setIcon(3) onkeypress=\"if (event.key=='Enter') p10setIcon(3)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i4 onclick=p10setIcon(4) onkeypress=\"if (event.key=='Enter') p10setIcon(4)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i5 onclick=p10setIcon(5) onkeypress=\"if (event.key=='Enter') p10setIcon(5)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i6 onclick=p10setIcon(6) onkeypress=\"if (event.key=='Enter') p10setIcon(6)\"></div><br><br>";setDialogMode(2,"Icon Selection",0,null,c);QV("id_dialogclose",true)}function p10setIcon(a){setDialogMode(0);meshserver.send({action:"changedevice",nodeid:currentNode._id,icon:a})}var showEditNodeValueDialog_modes=["Device Name","Hostname","Description","Tags"];var showEditNodeValueDialog_modes2=["name","host","desc","tags"];var showEditNodeValueDialog_modes3=["","","","Tag1, Tag2, Tag3"];function showEditNodeValueDialog(a){if(xxdialogMode){return}var c=addHtmlValue(showEditNodeValueDialog_modes[a],'<input id=dp10devicevalue maxlength=64 placeholder="'+showEditNodeValueDialog_modes3[a]+'" onchange=p10editdevicevalueValidate('+a+",event) onkeyup=p10editdevicevalueValidate("+a+",event) />");setDialogMode(2,"Edit Device",3,showEditNodeValueDialogEx,c,a);var b=currentNode[showEditNodeValueDialog_modes2[a]];if(b==null){b=""}if(Array.isArray(b)){b=b.join(", ")}Q("dp10devicevalue").value=b;p10editdevicevalueValidate();Q("dp10devicevalue").focus()}function showEditNodeValueDialogEx(a,b){var c={action:"changedevice",nodeid:currentNode._id};c[showEditNodeValueDialog_modes2[b]]=Q("dp10devicevalue").value;meshserver.send(c)}function p10editdevicevalueValidate(b,a){var c=((b>1)||(Q("dp10devicevalue").value.length>0));QE("idx_dlgOkButton",c);if((a!=null)&&(c==true)&&(a.keyCode==13)){dialogclose(1)}}var desktopNode;function setupDesktop(){if((desktopNode!=currentNode)&&(desktop!=null)){desktop.Stop();desktopNode=null;desktop=null}if((desktopNode!=currentNode)||(desktop==null)){var b=multiDesktop[currentNode._id];if(b!=null){QH("DeskParent","");var a=b.m.CanvasId;a.setAttribute("id","Desk");a.setAttribute("onmousedown","dmousedown(event)");a.setAttribute("onmouseup","dmouseup(event)");a.setAttribute("onmousemove","dmousemove(event)");a.removeAttribute("onclick");Q("DeskParent").appendChild(a);desktop=b;if(desktop.m.SendCompressionLevel){desktop.m.SendCompressionLevel(1,desktopsettings.quality,desktopsettings.scaling,desktopsettings.framerate)}desktop.onStateChanged=onDesktopStateChange;desktopNode=currentNode;onDesktopStateChange(desktop,desktop.State);delete multiDesktop[currentNode._id]}else{QH("DeskParent",'<canvas id=Desk oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>');desktopNode=currentNode}Q("Desk").addEventListener("DOMMouseScroll",function(c){return dmousewheel(c)});Q("Desk").addEventListener("mousewheel",function(c){return dmousewheel(c)})}desktopNode=currentNode;updateDesktopButtons();deskAdjust();if(!Q("Desk")["toBlob"]){QV("deskSaveBtn",false)}}function updateDesktopButtons(){var d=meshes[currentNode.meshid];var a=0;if(desktop!=null){a=desktop.State}var e=d.links[userinfo._id].rights;QV("disconnectbutton1span",(a!=0));QV("connectbutton1span",(a==0)&&((e&8)||(e&256))&&(d.mtype==2)&&(currentNode.agent.caps&1));QV("connectbutton1hspan",(a==0)&&(e&8)&&((currentNode.intelamt!=null)&&(d.mtype==1||currentNode.intelamt.state==2)&&((currentNode.intelamt.ver!=null)||(d.mtype==1))));QV("d7amtkvm",(currentNode.intelamt!=null&&((currentNode.intelamt.ver!=null)||(d.mtype==1)))&&((a==0)||(desktop.contype==2)));QV("d7meshkvm",(webRtcDesktop)||((d.mtype==2)&&(currentNode.agent.caps&1)&&((a==false)||(desktop.contype==1))));var c=(e==4294967295)||(((e&8)!=0)&&((e&256)==0)&&((e&4096)==0));var g=((currentNode.conn&1)!=0);QE("connectbutton1",g);var b=((currentNode.conn&6)!=0);QE("connectbutton1h",b);QE("deskSaveBtn",a==3);QV("deskFocusBtn",(desktop!=null)&&(desktop.contype==2)&&(a!=0)&&(desktopsettings.showfocus));QV("DeskCAD",c);QE("DeskCAD",a==3);QV("DeskClip",(currentNode.agent)&&(currentNode.agent.id!=11)&&(currentNode.agent.id!=16)&&((desktop==null)||(desktop.contype!=2)));QE("DeskClip",a==3);QV("DeskWD",(currentNode.agent)&&(currentNode.agent.id<5)&&c);QE("DeskWD",a==3);QV("deskkeys",(currentNode.agent)&&(currentNode.agent.id<5)&&c);QE("deskkeys",a==3);QV("DeskToolsButton",(c)&&(d.mtype==2)&&g);QV("DeskChatButton",(browserfullscreen==false)&&(c)&&(d.mtype==2)&&g);QV("DeskNotifyButton",(browserfullscreen==false)&&(currentNode.agent)&&(currentNode.agent.id<5)&&(c)&&(d.mtype==2)&&g);QV("DeskOpenWebButton",(browserfullscreen==false)&&(c)&&(d.mtype==2)&&g);QV("DeskControlSpan",c);QV("deskActionsBtn",(browserfullscreen==false));QV("deskActionsSettings",(browserfullscreen==false));if(e&8){Q("DeskControl").checked=(getstore("DeskControl",1)==1)}else{Q("DeskControl").checked=false}if(g==false){QV("DeskTools",false)}}var autoConnectDesktopTimer=null;function autoConnectDesktop(a){if(autoConnectDesktopTimer==null){autoConnectDesktopTimer=setInterval(connectDesktop,100)}else{clearInterval(autoConnectDesktopTimer);autoConnectDesktopTimer=null}}function connectDesktop(b,a){p11clearConsoleMsg();if(desktop==null){desktopNode=currentNode;if(a==2){if((desktopNode.intelamt.user==null)||(desktopNode.intelamt.user=="")){editDeviceAmtSettings(desktopNode._id,connectDesktop,2);return}desktop=CreateAmtRedirect(CreateAmtRemoteDesktop("Desk"),authCookie);desktop.debugmode=debugmode;desktop.onStateChanged=onDesktopStateChange;desktop.m.bpp=(desktopsettings.encoding==1||desktopsettings.encoding==3)?1:2;desktop.m.useZRLE=(desktopsettings.encoding<3);desktop.m.localKeyMap=desktopsettings.localkeymap;desktop.m.showmouse=desktopsettings.showmouse;desktop.m.onScreenSizeChange=deskAdjust;desktop.m.onKvmData=function(h){if(h.length==0){if(!desktop.m._sentPresence){desktop.m._sentPresence=true;desktop.m.sendKvmData(JSON.stringify({action:"present",ver:1}))}return}var d=null;try{d=JSON.parse(h)}catch(g){}if((d!=null)&&(d.action!=null)){if(d.action=="restart"){webRtcDesktopReset();desktop.m.sendKvmData(JSON.stringify({action:"present",ver:1}))}else{if((d.action=="present")&&(webRtcDesktop==null)){webRtcDesktop={platform:d.platform};var c=null;if(typeof RTCPeerConnection!=="undefined"){webRtcDesktop.webrtc=new RTCPeerConnection(c)}else{if(typeof webkitRTCPeerConnection!=="undefined"){webRtcDesktop.webrtc=new webkitRTCPeerConnection(c)}}webRtcDesktop.webchannel=webRtcDesktop.webrtc.createDataChannel("DataChannel",{});webRtcDesktop.webchannel.onopen=function(){console.log("WebRTC Data Channel Open");Q("deskstatus").textContent=StatusStrs[desktop.State]+", Soft-KVM";desktop.m.hold(true);webRtcDesktop.webRtcActive=true;webRtcDesktop.softdesktop=CreateKvmDataChannel(webRtcDesktop.webchannel,CreateAgentRemoteDesktop("Desk",Q("id_mainarea")),desktop.m);webRtcDesktop.softdesktop.m.setRotation(desktop.m.rotation);webRtcDesktop.softdesktop.m.onScreenSizeChange=deskAdjust;if(desktopsettings.quality){webRtcDesktop.softdesktop.m.CompressionLevel=desktopsettings.quality}if(desktopsettings.scaling){webRtcDesktop.softdesktop.m.ScalingLevel=desktopsettings.scaling}webRtcDesktop.softdesktop.Start()};webRtcDesktop.webchannel.onclose=function(e){console.log("WebRTC Data Channel Closed");webRtcDesktopReset()};webRtcDesktop.webrtc.onicecandidate=function(j){if(j.candidate==null){desktop.m.sendKvmData(JSON.stringify({action:"offer",ver:1,sdp:webRtcDesktop.webrtcoffer.sdp}))}else{webRtcDesktop.webrtcoffer.sdp+=("a="+j.candidate.candidate+"\r\n")}};webRtcDesktop.webrtc.oniceconnectionstatechange=function(){if((webRtcDesktop!=null)&&(webRtcDesktop.webrtc!=null)&&((webRtcDesktop.webrtc.iceConnectionState=="disconnected")||(webRtcDesktop.webrtc.iceConnectionState=="failed"))){webRtcDesktopReset()}};webRtcDesktop.webrtc.createOffer(function(e){webRtcDesktop.webrtcoffer=e;webRtcDesktop.webrtc.setLocalDescription(e,function(){},webRtcDesktopReset)},webRtcDesktopReset,{mandatory:{OfferToReceiveAudio:false,OfferToReceiveVideo:false}})}else{if((d.action=="answer")&&(webRtcDesktop!=null)){webRtcDesktop.webrtc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:d.sdp}),function(){},webRtcDesktopReset)}}}}};desktop.Start(desktopNode._id,16994,"*","*",0);desktop.contype=2}else{desktop=CreateAgentRedirect(meshserver,CreateAgentRemoteDesktop("Desk"),serverPublicNamePort,authCookie,domainUrl);desktop.debugmode=debugmode;desktop.m.debugmode=debugmode;desktop.attemptWebRTC=attemptWebRTC;desktop.onStateChanged=onDesktopStateChange;desktop.onConsoleMessageChange=function(){p11clearConsoleMsg();if(desktop.consoleMessage){QH("p11DeskConsoleMsg",EscapeHtml(desktop.consoleMessage).split("\n").join("<br />"));QV("p11DeskConsoleMsg",true);p11DeskConsoleMsgTimer=setTimeout(p11clearConsoleMsg,8000)}};desktop.m.CompressionLevel=desktopsettings.quality;desktop.m.ScalingLevel=desktopsettings.scaling;desktop.m.FrameRateTimer=desktopsettings.framerate;desktop.m.onDisplayinfo=deskDisplayInfo;desktop.m.onScreenSizeChange=deskAdjust;desktop.Start(desktopNode._id);desktop.contype=1}}else{desktop.Stop();webRtcDesktopReset();desktopNode=desktop=null}}function p11clearConsoleMsg(){QV("p11DeskConsoleMsg",false);if(p11DeskConsoleMsgTimer){clearTimeout(p11DeskConsoleMsgTimer);p11DeskConsoleMsgTimer=null}}function p12clearConsoleMsg(){QV("p12TermConsoleMsg",false);if(p12TermConsoleMsgTimer){clearTimeout(p12TermConsoleMsgTimer);p12TermConsoleMsgTimer=null}}function p13clearConsoleMsg(){QV("p13FilesConsoleMsg",false);if(p13FilesConsoleMsgTimer){clearTimeout(p13FilesConsoleMsgTimer);p13FilesConsoleMsgTimer=null}}var webRtcDesktop=null;function webRtcDesktopReset(){if(webRtcDesktop==null){return}if(webRtcDesktop.softdesktop!=null){webRtcDesktop.softdesktop.Stop();webRtcDesktop.softdesktop=null}if(webRtcDesktop.webchannel!=null){try{webRtcDesktop.webchannel.close()}catch(a){}webRtcDesktop.webchannel=null}if(webRtcDesktop.webrtc!=null){try{webRtcDesktop.webrtc.close()}catch(a){}webRtcDesktop.webrtc=null}webRtcDesktop=null;if(desktop&&desktop.m){desktop.m.hold(false);Q("deskstatus").textContent=StatusStrs[desktop.State]}}function onDesktopStateChange(c,a){var d=a;if((d==3)&&(c.contype==2)){d++}var b=StatusStrs[d];if((desktop!=null)&&(desktop.webRtcActive==true)){b+=", WebRTC"}QH("deskstatus",b);switch(a){case 0:desktop.Stop();desktopNode=desktop=null;QV("DeskFocus",false);QV("termdisplays",false);deskFocusBtn.value="All Focus";if(fullscreen==true){deskToggleFull()}webRtcDesktopReset();deskPreferedStickyDisplay=0;break;case 2:break;default:break}updateDesktopButtons();deskAdjust();setTimeout(deskAdjust,50)}function showDesktopSettings(){if(xxdialogMode){return}applyDesktopSettings();updateDesktopButtons();setDialogMode(7,"Remote Desktop Settings",3,showDesktopSettingsChanged)}function showDesktopSettingsChanged(){desktopsettings.encoding=d7desktopmode.value;desktopsettings.showfocus=d7showfocus.checked;desktopsettings.showmouse=d7showcursor.checked;desktopsettings.quality=d7bitmapquality.value;desktopsettings.scaling=d7bitmapscaling.value;desktopsettings.framerate=d7framelimiter.value;desktopsettings.localkeymap=d7localKeyMap.checked;localStorage.setItem("desktopsettings",JSON.stringify(desktopsettings));applyDesktopSettings();if(desktop){if(desktop.contype==1){if(desktop.State!=0){desktop.m.SendCompressionLevel(1,desktopsettings.quality,desktopsettings.scaling,desktopsettings.framerate)}}if(desktop.contype==2){if(desktopsettings.showfocus==false){desktop.m.focusmode=0;deskFocusBtn.value="All Focus"}if(desktop.State!=0){desktop.Stop();setTimeout(function(){connectDesktop(null,2)},50)}}}}function applyDesktopSettings(){var c="",b=(features&512)?[90,80,70,60,50,40,30,20,10,5,1]:[60,50,40,30,20,10,5,1];for(var a in b){c+="<option value="+b[a]+">"+b[a]+"%</option>"}QH("d7bitmapquality",c);d7desktopmode.value=desktopsettings.encoding;d7showfocus.checked=desktopsettings.showfocus;d7showcursor.checked=desktopsettings.showmouse;d7bitmapquality.value=40;if(b.indexOf(parseInt(desktopsettings.quality))>=0){d7bitmapquality.value=desktopsettings.quality}d7bitmapscaling.value=desktopsettings.scaling;if(desktopsettings.framerate){d7framelimiter.value=desktopsettings.framerate}if(desktopsettings.localkeymap){d7localKeyMap.checked=desktopsettings.localkeymap}QV("deskFocusBtn",(desktop!=null)&&(desktop.contype==2)&&(desktop.state!=0)&&(desktopsettings.showfocus))}function enterBrowserFullscreen(a){if(a.requestFullscreen){a.requestFullscreen()}else{if(a.msRequestFullscreen){a.msRequestFullscreen()}else{if(a.mozRequestFullScreen){a.mozRequestFullScreen()}else{if(a.webkitRequestFullscreen){a.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}}}}}function exitBrowserFullscreen(){if(document.exitFullscreen){document.exitFullscreen()}else{if(document.msExitFullscreen){document.msExitFullscreen()}else{if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else{if(document.webkitExitFullscreen){document.webkitExitFullscreen()}}}}}function isBrowserFullscreen(){if(!document.fullscreenElement&&!document.mozFullScreenElement&&!document.webkitFullscreenElement&&!document.msFullscreenElement){return false}else{return true}}var fullscreen=false;var browserfullscreen=false;function deskToggleFull(a){fullscreen=!fullscreen;if(fullscreen){QC("body").add("fulldesk");if(a.shiftKey==true){enterBrowserFullscreen(Q("deskarea0"));browserfullscreen=true}}else{QC("body").remove("fulldesk");exitBrowserFullscreen();browserfullscreen=false;toggleFullScreen()}deskAdjust();updateDesktopButtons()}function deskToggleFocus(){desktop.m.focusmode=(desktop.m.focusmode+64)%192;Q("deskFocusBtn").value=["All Focus","Small Focus","Large Focus"][desktop.m.focusmode/64]}function deskAdjust(){var d=Q("DeskParent").clientHeight,e=Q("DeskParent").clientWidth;var a=Q("Desk").height,b=Q("Desk").width;if(deskAspectRatio==2){QS("Desk")["margin-top"]=null;QS("Desk").height="100%";QS("Desk").width="100%";QS("DeskParent").overflow="hidden"}else{if(deskAspectRatio==1){QS("Desk")["margin-top"]="0px";QS("Desk").height=a+"px";QS("Desk").width=b+"px";QS("DeskParent").overflow="scroll"}else{if((d/e)>(a/b)){var c=((a*e)/b)+"px";QS("Desk").height=c;QS("Desk").width="100%"}else{var g=((b*d)/a)+"px";if(webPageFullScreen||fullscreen){QS("Desk").height=null}else{QS("Desk").height="100%"}QS("Desk").width=g}QS("Desk")["margin-top"]=null;QS("DeskParent").overflow="hidden"}}}function mdeskAdjust(c,h,g,a){if(!c||!h||!g||!a){return}if(a.id=="Desk"){deskAdjust();return}var k=[{x:180,y:101},{x:302,y:169},{x:454,y:255}][Q("sizeselect").selectedIndex];var e=k.x+2,j=Q("xdevices").clientWidth-30,l=Math.floor(j/e);l=e+Math.floor((j-(l*e))/l);k.y=k.y*(l/k.x);k.x=l;var b=k.y,d=k.x;if(c.State!=0){b=k.y;d=(h/g)*k.y}QS(a.id)["max-height"]=b+"px";QS(a.id)["max-width"]=d+"px";QS(a.id)["margin-top"]="0";QS(a.id)["margin-bottom"]="0"}function deskSendKeys(){if(xxdialogMode||desktop==null||desktop.State!=3){return}var a=Q("deskkeys").value;if(a==0){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[65364,1],[65364,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,40],[desktop.m.KeyAction.UP,40],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==1){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[65362,1],[65362,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,38],[desktop.m.KeyAction.UP,38],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==2){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[108,1],[108,0],[65511,0]])}else{desktop.sendCtrlMsg('{"action":"lock"}')}}else{if(a==3){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[109,1],[109,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==4){if(desktop.contype==2){desktop.m.sendkey([[65505,1],[65511,1],[109,1],[109,0],[65511,0],[65505,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.DOWN,16],[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,91],[desktop.m.KeyAction.UP,16]])}}else{if(a==5){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==6){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[114,1],[114,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,82],[desktop.m.KeyAction.UP,82],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==7){if(desktop.contype==2){desktop.m.sendkey([[65513,1],[65473,1],[65473,0],[65513,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,18],[desktop.m.KeyAction.DOWN,115],[desktop.m.KeyAction.UP,115],[desktop.m.KeyAction.EXUP,18]])}}else{if(a==8){if(desktop.contype==2){desktop.m.sendkey([[65507,1],[119,1],[119,0],[65507,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,17],[desktop.m.KeyAction.DOWN,87],[desktop.m.KeyAction.UP,87],[desktop.m.KeyAction.EXUP,17]])}}else{if(a==9){if(desktop.contype==2){desktop.m.sendkey([[65513,1],[65289,1],[65289,0],[65513,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,18],[desktop.m.KeyAction.DOWN,9],[desktop.m.KeyAction.UP,9],[desktop.m.KeyAction.EXUP,18]])}}}}}}}}}}}}function showDeskClip(){if(xxdialogMode||desktop==null||desktop.State!=3){return}Q("DeskClip").blur();var a="";a+='<input id=dlgClipGet type=button value="Get Clipboard" style=width:120px onclick=showDeskClipGet()>';a+='<input id=dlgClipSet type=button value="Set Clipboard" style=width:120px onclick=showDeskClipSet()>';a+='<div id=dlgClipStatus style="display:inline-block;margin-left:8px" ></div>';a+='<textarea id=d2clipText style="width:100%;height:184px;resize:none" maxlength=65535></textarea>';a+='<input type=button value="Close" style=width:80px;float:right onclick=dialogclose(0)><div style=height:26px;margin-top:3px><span id=linuxClipWarn style=display:none>Remote clipboard is valid for 60 seconds.</span>&nbsp;</div><div></div>';setDialogMode(2,"Remote Clipboard",8,null,a,"clipboard");Q("d2clipText").focus()}function showDeskClipGet(){if(desktop==null||desktop.State!=3){return}meshserver.send({action:"msg",type:"getclip",nodeid:currentNode._id})}function showDeskClipSet(){if(desktop==null||desktop.State!=3){return}meshserver.send({action:"msg",type:"setclip",nodeid:currentNode._id,data:Q("d2clipText").value});QV("linuxClipWarn",currentNode&&currentNode.agent&&(currentNode.agent.id>4)&&(currentNode.agent.id!=21)&&(currentNode.agent.id!=22))}function sendCAD(){if(xxdialogMode||desktop==null||desktop.State!=3){return}desktop.m.sendcad()}function toggleDeskTools(){if(xxdialogMode){return}if(QS("DeskTools").display=="none"){QV("DeskTools",true);Q("DeskTools").nodeid=currentNode._id;refreshDeskTools()}else{QV("DeskTools",false)}}function refreshDeskTools(){QV("DeskToolsRefreshButton",false);setTimeout(refreshDeskToolsEx,500);meshserver.send({action:"msg",type:"ps",nodeid:currentNode._id})}function refreshDeskToolsEx(){QV("DeskToolsRefreshButton",true)}var deskTools={sort:1,msg:null};function sortProcess(a){deskTools.sort=a;showDeskToolsProcesses(deskTools.msg)}function sortProcessPid(c,d){if(c.p>d.p){return 1}if(c.p<d.p){return(-1)}return 0}function sortProcessName(c,d){if(c.d>d.d){return 1}if(c.d<d.d){return(-1)}return 0}function showDeskToolsProcesses(c){deskTools.msg=c;if(c==null){QH("DeskToolsProcesses","");return}if(Q("DeskTools").nodeid!=c.nodeid){return}var d=[],h=null;try{h=JSON.parse(c.value)}catch(a){}if(h!=null){for(var g in h){d.push({p:parseInt(g),c:h[g].cmd,d:h[g].cmd.toLowerCase(),u:h[g].user})}if(deskTools.sort==0){d.sort(sortProcessPid)}else{if(deskTools.sort==1){d.sort(sortProcessName)}}var j="";for(var b in d){if(d[b].p!=0){j+="<div class=deskToolsBar><div style=width:50px;float:left;text-align:right;padding-right:5px>"+d[b].p+'</div><a href=# style=float:right;padding-right:5px;cursor:pointer title="Stop process" onclick=\'return stopProcess('+d[b].p+',"'+d[b].c+'")\'><img width=10 height=10 src="images/trash.png"></a><div style=float:right;padding-right:5px>'+(d[b].u?d[b].u:"")+"</div><div>"+d[b].c+"</div></div>"}}QH("DeskToolsProcesses",j)}}function toggleKvmControl(){putstore("DeskControl",(Q("DeskControl").checked?1:0))}function deskSaveImage(){if(xxdialogMode||desktop==null||desktop.State!=3){return}var a=new Date(),b="Desktop-"+currentNode.name+"-"+a.getFullYear()+"-"+("0"+(a.getMonth()+1)).slice(-2)+"-"+("0"+a.getDate()).slice(-2)+"-"+("0"+a.getHours()).slice(-2)+"-"+("0"+a.getMinutes()).slice(-2);Q("Desk")["toBlob"](function(c){saveAs(c,b+".jpg")})}function deskDisplayInfo(g,b,e){var a=0,c="";for(var d in b){a++;c+="<option"+((e==d)?" selected":"")+" value="+d+">"+b[d]+"</option>";if((deskPreferedStickyDisplay==d)&&(e!=deskPreferedStickyDisplay)){desktop.m.SetDisplay(d)}}QH("termdisplays",c);QV("termdisplays",a>1)}function deskGetDisplayNumbers(a){desktop.m.GetDisplayNumbers()}var deskPreferedStickyDisplay=0;function deskSetDisplay(a){desktop.m.SetDisplay(deskPreferedStickyDisplay=parseInt(Q("termdisplays").value));Q("termdisplays").blur()}var dblClickDetectArgs={t:0,x:0,y:0};function dblClickDetect(a){if(a.buttons!=1){return}var b=Date.now();if(((b-dblClickDetectArgs.t)<250)&&(Math.abs(a.clientX-dblClickDetectArgs.x)<2)&&(Math.abs(a.clientY-dblClickDetectArgs.y)<2)){if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousedblclick(a);desktop.m.sendKeepAlive()}else{desktop.m.mousedblclick(a)}}}dblClickDetectArgs.t=b;dblClickDetectArgs.x=a.clientX;dblClickDetectArgs.y=a.clientY}function dmousedown(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousedown(a);desktop.m.sendKeepAlive()}else{desktop.m.mousedown(a)}}dblClickDetect(a)}function dmouseup(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mouseup(a);desktop.m.sendKeepAlive()}else{desktop.m.mouseup(a)}}}function dmousemove(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousemove(a);desktop.m.sendKeepAlive()}else{desktop.m.mousemove(a)}}}function dmousewheel(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousewheel(a);desktop.m.sendKeepAlive()}else{if(desktop.m.mousewheel){desktop.m.mousewheel(a)}}haltEvent(a);return true}return false}function drotate(a){if(!xxdialogMode&&desktop!=null){desktop.m.setRotation(desktop.m.rotation+a);deskAdjust();deskAdjust()}}function stopProcess(a,b){setDialogMode(2,"Process Control",3,stopProcessEx,"Stop process #"+a+' "'+b+'"?',a);return false}function stopProcessEx(a,b){meshserver.send({action:"msg",type:"pskill",nodeid:currentNode._id,value:b});setTimeout(refreshDeskTools,300)}var terminalNode;function setupTerminal(){if((terminalNode!=currentNode)&&(terminal!=null)){terminal.Stop();terminal=null}terminalNode=currentNode;updateTerminalButtons()}function updateTerminalButtons(){var b=meshes[terminalNode.meshid];var d=((terminal!=null)&&(terminal.state!=0));QV("disconnectbutton2span",(d==true));QV("connectbutton2span",(d==false)&&(b.mtype==2)&&(currentNode.agent.caps&2));QV("connectbutton2hspan",(d==false)&&((terminalNode.intelamt!=null)&&(b.mtype==1||terminalNode.intelamt.state==2)&&((terminalNode.intelamt.ver!=null)||(b.mtype==1))));var c=((terminalNode.conn&1)!=0);QE("connectbutton2",c);var a=((terminalNode.conn&6)!=0);QE("connectbutton2h",a);QE("ctrlcbutton",d);QE("ctrlxbutton",d);QE("escbutton",d);QE("bsbutton",d);QE("pastebutton",d);QE("specialkeylist",d);QE("specialkeylistinput",d);QV("terminalSettingsButtons",(terminal)&&(terminal.contype==2));if(terminal){Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation];Q("id_tfxkeysbutton").value=fxEmulations[terminal.m.fxEmulation];Q("id_tcrbutton").value=(terminal.m.lineFeed=="\r\n")?"CR+LF":"LF"}}function onTerminalStateChange(d,a){var c=a;if((c==3)&&(d.contype==2)){c++}var b=StatusStrs[c];if(terminal.webRtcActive==true){b+=", WebRTC"}QH("termstatus",b);switch(a){case 0:QE("termSizeList",true);QH("termtitle","");d.m.TermResetScreen();d.m.TermDraw();if(terminal!=null){terminal.Stop();terminal=null}break;case 3:QE("termSizeList",false);break;default:QE("termSizeList",false);break}updateTerminalButtons()}var autoConnectTerminalTimer=null;function autoConnectTerminal(a){if(autoConnectTerminalTimer==null){autoConnectTerminalTimer=setInterval(connectTerminal,100)}else{clearInterval(autoConnectTerminalTimer);autoConnectTerminalTimer=null}}function connectTerminal(b,a){p12clearConsoleMsg();if(!terminal){if(a==2){if((terminalNode.intelamt.user==null)||(terminalNode.intelamt.user=="")){editDeviceAmtSettings(terminalNode._id,connectTerminal,2);return}var c={};if(Q("termSizeList").value==2){c.width=100;c.height=30}terminal=CreateAmtRedirect(CreateAmtRemoteTerminal("Term",c),authCookie);terminal.debugmode=debugmode;terminal.m.debugmode=debugmode;terminal.m.onTitleChange=function(d,e){QH("termtitle"," - "+EscapeHtml(e))};terminal.onStateChanged=onTerminalStateChange;terminal.Start(terminalNode._id,16994,"*","*",0);terminal.contype=2;Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation]}else{var c={};if([1,2,3,4,21,22].indexOf(currentNode.agent.id)==-1){if(Q("termSizeList").value==2){c.width=100;c.height=30;c.xterm=true}if(Q("termSizeList").value==3){c.width=Math.floor((Q("column_l").clientWidth-60)/10);c.height=Math.floor((Q("column_l").clientHeight-120)/20);c.xterm=true}}terminal=CreateAgentRedirect(meshserver,CreateAmtRemoteTerminal("Term",c),serverPublicNamePort,authCookie,domainUrl);terminal.debugmode=debugmode;terminal.m.debugmode=debugmode;terminal.m.onTitleChange=function(d,e){QH("termtitle"," - "+EscapeHtml(e))};terminal.m.lineFeed=([1,2,3,4,21,22].indexOf(currentNode.agent.id)>=0)?"\r\n":"\r";terminal.attemptWebRTC=attemptWebRTC;terminal.onStateChanged=onTerminalStateChange;terminal.onConsoleMessageChange=function(){p12clearConsoleMsg();if(terminal.consoleMessage){QH("p12TermConsoleMsg",EscapeHtml(terminal.consoleMessage).split("\n").join("<br />"));QV("p12TermConsoleMsg",true);p12TermConsoleMsgTimer=setTimeout(p12clearConsoleMsg,8000)}};terminal.Start(terminalNode._id);terminal.contype=1;terminal.m.terminalEmulation=0;terminal.m.fxEmulation=0;Q("id_ttypebutton").value=terminalEmulations[0]}}else{terminal.Stop();terminal=null}Q("connectbutton2").blur()}var terminalEmulations=["UTF8 Terminal","Extended ASCII","Intel ASCII"];function termToggleType(){if(!terminal||xxdialogMode){return}terminal.m.terminalEmulation=(terminal.m.terminalEmulation+1)%3;Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation];Q("id_ttypebutton").blur()}var fxEmulations=["Intel (F10 = ESC+[OM)","Alternate (F10 = ESC+0)","VT100+ (F10 = ESC+[OY)"];function termToggleFx(){if(!terminal||xxdialogMode){return}terminal.m.fxEmulation=(terminal.m.fxEmulation+1)%3;Q("id_tfxkeysbutton").value=fxEmulations[terminal.m.fxEmulation];Q("id_tfxkeysbutton").blur()}function termToggleCr(){if(!terminal||xxdialogMode){return}if(terminal.m.lineFeed=="\n"){terminal.m.lineFeed="\r\n"}else{terminal.m.lineFeed="\n"}Q("id_tcrbutton").value=(terminal.m.lineFeed=="\r\n")?"CR+LF":"LF"}function termSendKey(b,a){if(!terminal||xxdialogMode){return}terminal.m.TermSendKey(b);Q(a).blur()}function showTermPasteDialog(){if(!terminal||xxdialogMode){return}Q("pastebutton").blur();setDialogMode(2,"Paste",3,showTermPasteDialogEx,'<textarea id=d2pasteText style="width:100%;height:184px;resize:none"></textarea>');Q("d2pasteText").focus()}function showTermPasteDialogEx(){if(!terminal){return}terminal.m.TermSendKeys(Q("d2pasteText").value)}function sendSpecialKey(){terminal.m.TermSendKey(Q("specialkeylist").value);Q("specialkeylist").blur();Q("specialkeylistinput").blur()}var filesNode;function setupFiles(){var b=(filesNode==currentNode);filesNode=currentNode;var a=((filesNode.conn&1)!=0)?true:false;QE("p13Connect",a);if(((b==false)||(a==false))&&files){files.Stop();files=null}}function onFilesStateChange(c,a){p13Connect.value=(a==0)?"Connect":"Disconnect";var b=StatusStrs[a];if(files.webRtcActive==true){b+=", WebRTC"}Q("p13Status").textContent=b;switch(a){case 0:QH("p13files","");p13filetree=null;p13filetreelocation=[];QH("p13currentpath","");QE("p13FolderUp",false);p13setActions();if(files!=null){files.Stop();files=null}break;case 3:p13targetpath="";files.sendText({action:"ls",reqid:1,path:""});break;default:break}}function CreateRemoteFiles(b){var a={protocol:5};a.onFileUpdate=b;a.xxStateChange=function(c){};a.ProcessData=function(c){a.onFileUpdate(c)};return a}var autoConnectFilesTimer=null;function autoConnectFiles(a){if(autoConnectFilesTimer==null){autoConnectFilesTimer=setInterval(connectFiles,100)}else{clearInterval(autoConnectFilesTimer);autoConnectFilesTimer=null}}function connectFiles(a){p13clearConsoleMsg();if(!files){files=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotFiles),serverPublicNamePort,authCookie,domainUrl);files.attemptWebRTC=attemptWebRTC;files.onStateChanged=onFilesStateChange;files.onConsoleMessageChange=function(){p13clearConsoleMsg();if(files.consoleMessage){QH("p13FilesConsoleMsg",EscapeHtml(files.consoleMessage).split("\n").join("<br />"));QV("p13FilesConsoleMsg",true);p13FilesConsoleMsgTimer=setTimeout(p13clearConsoleMsg,8000)}};files.Start(filesNode._id)}else{files.Stop();files=null}p13clipboard=p13clipboardFolder=null;p13clipboardCut=0;p13updateClipview()}var p13filetree=null;var p13targetpath=null;var p13filetreelocation=[];function p13gotFiles(b){if((b.length>0)&&(b.charCodeAt(0)!=123)){p13gotDownloadBinaryData(b);return}b=JSON.parse(decode_utf8(b));if(b.action=="download"){p13gotDownloadCommand(b);return}b.path=b.path.replace(/\//g,"\\");if((p13filetree!=null)&&(b.path==p13filetree.path)){var a=p13getCheckedNames();p13filetree=b;p13updateFiles(a)}else{var c=b.path.replace(/\//g,"\\"),d=p13targetpath.replace(/\//g,"\\");while((c.length>0)&&(c[0]=="\\")){c=c.substring(1)}while((d.length>0)&&(d[0]=="\\")){d=d.substring(1)}if((c==d)||((b.path=="\\")&&(p13targetpath==""))){p13filetree=b;p13updateFiles()}}}function p13getCheckedNames(){var b=[],a=document.getElementsByName("fd");for(var c=0;c<a.length;c++){if(a[c].checked){b.push(p13filetree.dir[a[c].value].n)}}return b}function p13updateFiles(b){var n="",o="",c='<a href=# style=cursor:pointer onclick="return p13folderup(0)">Root</a>',l="Root";var w=p13filetree.path.split("\\");p13filetreelocation=[];for(var p in w){if(w[p]!=""){p13filetreelocation.push(w[p])}}for(var p in p13filetreelocation){c+=' / <a href=# style=cursor:pointer onclick="return p13folderup('+(parseInt(p)+1)+')">'+p13filetreelocation[p]+"</a>"}var s=p13filetreelocation.join("/");var j=p13sort_files(p13filetree.dir);for(var p in j){var d=j[p],r=d.n,u;u=r;if(r.length>70){u='<span title="'+EscapeHtml(r)+'">'+EscapeHtml(r.substring(0,70))+"...</span>"}else{u=EscapeHtml(r)}r=EscapeHtml(r);var g="";if(d.d!=null){var e=new Date(d.d),g=printDateTime(e)+"&nbsp;"}var k="";if(d.s!=null){k=getFileSizeStr(d.s)}var m="";if(d.t<3){var t="",v="";m="<div class=filelist file=999><input file=999 style=float:left name=fd class=fcb type=checkbox onchange=p13setActions() value='"+d.nx+"'>&nbsp;<span style=float:right title=\""+v+'">'+t+"</span><span><div class=fileIcon"+d.t+' onclick=p13folderset("'+encodeURIComponent(d.nx)+'")></div><a href=# style=cursor:pointer onclick=\'return p13folderset("'+encodeURIComponent(d.nx)+"\")'>"+u+"</a></span></div>"}else{var q=u;if(d.s>0){q='<a hrf=# rel="noreferrer noopener" target="_blank" style=cursor:pointer onclick="return p13downloadfile(\''+encodeURIComponent(s+"/"+r)+"','"+encodeURIComponent(r)+"',"+d.s+')">'+u+"</a>"}m="<div class=filelist file=3><input file=3 style=float:left name=fd class=fcb type=checkbox onchange=p13setActions() value='"+d.nx+"'>&nbsp;<span class=fsize>"+g+"</span><span style=float:right>"+k+"</span><span><div class=fileIcon"+d.t+"></div>"+q+"</span></div>"}if(d.t<3){n+=m}else{o+=m}}QH("p13files",n+o);QH("p13currentpath",c);QE("p13FolderUp",p13filetreelocation.length!=0);if(b!=null){var a=document.getElementsByName("fd");for(var p=0;p<a.length;p++){if(b.indexOf(p13filetree.dir[a[p].value].n)>=0){a[p].checked=true}}}p13setActions()}function p13folderset(a){p13targetpath=joinPaths(p13filetree.path,p13filetree.dir[a].n).split("\\").join("/");files.sendText({action:"ls",reqid:1,path:p13targetpath})}function p13folderup(a){if(a==null){p13filetreelocation.pop()}else{while(p13filetreelocation.length>a){p13filetreelocation.pop()}}p13targetpath=p13filetreelocation.join("/");files.sendText({action:"ls",reqid:1,path:p13targetpath});return false}var p13sortorder;function p13sort_filename(c,d){if(c.ln>d.ln){return(1*p13sortorder)}if(c.ln<d.ln){return(-1*p13sortorder)}return 0}function p13sort_timestamp(c,d){if(c.d>d.d){return(1*p13sortorder)}if(c.d<d.d){return(-1*p13sortorder)}return 0}function p13sort_bysize(c,d){if(c.s==d.s){return p13sort_filename(c,d)}return(((c.s-d.s))*p13sortorder)}function p13sort_files(a){var c=[],d=Q("p13sortdropdown").value;for(var b in a){a[b].nx=b;if(a[b].s==null){a[b].s=0}if(a[b].n==null){a[b].n=b}a[b].ln=a[b].n.toLowerCase();c.push(a[b])}p13sortorder=1;if(d>3){p13sortorder=-1;d-=3}if(d==1){c.sort(p13sort_filename)}else{if(d==2){c.sort(p13sort_bysize)}else{if(d==3){c.sort(p13sort_timestamp)}}}return c}function p13setActions(){if(p13filetree==null){QE("p13DeleteFileButton",false);QE("p13NewFolderButton",false);QE("p13UploadButton",false);QE("p13RenameFileButton",false);QE("p13SelectAllButton",false);Q("p13SelectAllButton").value="Select All";QE("p13RefreshButton",false);QE("p13CutButton",false);QE("p13CopyButton",false);QE("p13PasteButton",false)}else{var a=p13getFileSelCount(),c=p13getFileCount(),b=p13getFileSelCount(false);var d=((currentNode.agent.id>0)&&(currentNode.agent.id<5));QE("p13DeleteFileButton",(a>0)&&((p13filetreelocation.length>0)||(d==false)));QE("p13NewFolderButton",((p13filetreelocation.length>0)||(d==false)));QE("p13UploadButton",((p13filetreelocation.length>0)||(d==false)));QE("p13RenameFileButton",(a==1)&&((p13filetreelocation.length>0)||(d==false)));QE("p13SelectAllButton",c>0);Q("p13SelectAllButton").value=(a>0?"Select None":"Select All");QE("p13RefreshButton",true);QE("p13CutButton",(a>0)&&(a==b)&&((p13filetreelocation.length>0)||(d==false)));QE("p13CopyButton",(a>0)&&(a==b)&&((p13filetreelocation.length>0)||(d==false)));QE("p13PasteButton",((p13filetreelocation.length>0)||(d==false))&&((p13clipboard!=null)&&(p13clipboard.length>0)))}}function p13getFileSelCount(d){var a=0;var b=document.getElementsByName("fd");for(var c=0;c<b.length;c++){if((b[c].checked)&&((d!=false)||(b[c].attributes.file.value=="3"))){a++}}return a}function p13getFileSelDirCount(){var a=0,b=document.getElementsByName("fd");for(var c=0;c<b.length;c++){if((b[c].checked)&&(b[c].attributes.file.value=="999")){a++}}return a}function p13getFileCount(){var a=0;var b=document.getElementsByName("fd");return b.length}function p13selectallfile(){var c=(p13getFileSelCount()==0),a=document.getElementsByName("fd");for(var b=0;b<a.length;b++){a[b].checked=c}p13setActions()}function p13createfolder(){setDialogMode(2,"New Folder",3,p13createfolderEx,"<input type=text id=p13renameinput maxlength=64 onkeyup=p13fileNameCheck(event) style=width:100% />");focusTextBox("p13renameinput");p13fileNameCheck()}function p13createfolderEx(){files.sendText({action:"mkdir",reqid:1,path:p13filetreelocation.join("/")+"/"+Q("p13renameinput").value});p13folderup(999)}function p13deletefile(){var a=p13getFileSelCount(),b=(p13getFileSelDirCount()>0)?"<br /><br /><label><input type=checkbox id=p13recdeleteinput>Recursive delete</label><br>":"<input type=checkbox id=p13recdeleteinput style='display:none'>";setDialogMode(2,"Delete",3,p13deletefileEx,(a>1)?("Delete "+a+" selected items?"+b):("Delete selected item?"+b))}function p13deletefileEx(){var b=[],a=document.getElementsByName("fd");for(var c=0;c<a.length;c++){if(a[c].checked){b.push(p13filetree.dir[a[c].value].n)}}files.sendText({action:"rm",reqid:1,path:p13filetreelocation.join("/"),delfiles:b,rec:Q("p13recdeleteinput").checked});p13folderup(999)}function p13renamefile(){var c,a=document.getElementsByName("fd");for(var b=0;b<a.length;b++){if(a[b].checked){c=p13filetree.dir[a[b].value].n}}setDialogMode(2,"Rename",3,p13renamefileEx,'<input type=text id=p13renameinput maxlength=64 onkeyup=p13fileNameCheck(event) style=width:100% value="'+c+'" />',{action:"rename",path:p13filetreelocation.join("/"),oldname:c});focusTextBox("p13renameinput");p13fileNameCheck()}function p13renamefileEx(a,c){c.newname=Q("p13renameinput").value;files.sendText(c);p13folderup(999)}function p13fileNameCheck(a){var b=isFilenameValid(Q("p13renameinput").value);QE("idx_dlgOkButton",b);if((b==true)&&(a!=null)&&(a.keyCode==13)){dialogclose(1)}}function p13uploadFile(){setDialogMode(2,"Upload File",3,p13uploadFileEx,"<input type=file name=files id=p13uploadinput style=width:100% multiple=multiple onchange=\"updateUploadDialogOk('p13uploadinput')\" />");updateUploadDialogOk("p13uploadinput")}function p13uploadFileEx(){p13doUploadFiles(Q("p13uploadinput").files)}var p13clipboard=null,p13clipboardFolder=null,p13clipboardCut=0;function p13copyFile(b){var a=document.getElementsByName("fd");p13clipboard=[];p13clipboardCut=b,p13clipboardFolder=p13targetpath;for(var c=0;c<a.length;c++){if((a[c].checked)&&(a[c].attributes.file.value=="3")){p13clipboard.push(p13filetree.dir[a[c].value].n)}}p13updateClipview()}function p13pasteFile(){var a="";if((p13clipboard!=null)&&(p13clipboard.length>0)){a="Confim "+(p13clipboardCut==0?"copy":"move")+" of "+p13clipboard.length+" entrie"+((p13clipboard.length>1)?"s":"")+" to this location?"}setDialogMode(2,"Paste",3,p13pasteFileEx,a)}function p13pasteFileEx(){files.sendText({action:(p13clipboardCut==0?"copy":"move"),reqid:1,scpath:p13clipboardFolder,dspath:p13targetpath,names:p13clipboard});p13folderup(999);if(p13clipboardCut==1){p13clipboard=null,p13clipboardFolder=null,p13clipboardCut=0;p13updateClipview()}}function p13updateClipview(){var a="";if((p13clipboard!=null)&&(p13clipboard.length>0)){a="Holding "+p13clipboard.length+" entrie"+((p13clipboard.length>1)?"s":"")+" for "+(p13clipboardCut==0?"copy":"move")+', <a href=# onclick="return p13clearClip()" style=cursor:pointer>Clear</a>.'}QH("p13bottomstatus",a);p13setActions()}function p13clearClip(){p13clipboard=null;p13clipboardFolder=null;p13clipboardCut=0;p13updateClipview();return false}function p13fileDragDrop(a){haltEvent(a);QV("p13bigfail",false);QV("p13bigok",false);if(a.dataTransfer==null||a.dataTransfer.files.length==0||p13filetree==null){return}p13doUploadFiles(a.dataTransfer.files)}var p13dragtimer=null;function p13fileDragOver(b){haltEvent(b);if(p13dragtimer!=null){clearTimeout(p13dragtimer);p13dragtimer=null}var a=(p13filetree!=null);QV("p13bigok",a);QV("p13bigfail",!a)}function p13fileDragLeave(a){haltEvent(a);if(a.target.id!="p13filetable"){QV("p13bigfail",false);QV("p13bigok",false)}else{p13dragtimer=setTimeout(function(){QV("p13bigfail",false);QV("p13bigok",false);p13dragtimer=null},10)}}var downloadFile;function p13downloadfile(a,b,c){if(xxdialogMode||downloadFile||!files){return}downloadFile={path:decodeURIComponent(a),file:decodeURIComponent(b),size:c,tsize:0,data:"",state:0,id:Math.random()};files.sendText({action:"download",sub:"start",id:downloadFile.id,path:downloadFile.path});setDialogMode(2,"Download File",10,p13downloadFileCancel,"<div>"+downloadFile.file+"</div><br /><progress id=d2progressBar style=width:100% value=0 max="+c+" />")}function p13downloadFileCancel(){setDialogMode(0);files.sendText({action:"download",sub:"cancel",id:downloadFile.id});downloadFile=null}function p13gotDownloadCommand(a){if((downloadFile==null)||(a.id!=downloadFile.id)){return}if(a.sub=="start"){downloadFile.state=1;files.sendText({action:"download",sub:"startack",id:downloadFile.id})}else{if(a.sub=="cancel"){downloadFile=null;setDialogMode(0)}}}function p13gotDownloadBinaryData(a){if(!downloadFile||downloadFile.state==0){return}if(a.length>4){downloadFile.tsize+=(a.length-4);downloadFile.data+=a.substring(4);Q("d2progressBar").value=downloadFile.tsize}if((ReadInt(a,0)&1)!=0){saveAs(data2blob(downloadFile.data),downloadFile.file);downloadFile=null;setDialogMode(0)}else{files.sendText({action:"download",sub:"ack",id:downloadFile.id})}}var uploadFile;function p13doUploadFiles(a){if(xxdialogMode){return}uploadFile={};uploadFile.xpath=p13filetreelocation.join("/");uploadFile.xfiles=a;uploadFile.xfilePtr=-1;setDialogMode(2,"Upload File",10,p13uploadFileCancel,"<div id=p13dfileName>Connecting...</div><br /><progress id=d2progressBar style=width:100% value=0 max=0 />");p13uploadReconnect()}function onFileUploadStateChange(b,a){switch(a){case 0:p13folderup(9999);break;case 3:p13uploadNextFile();break;default:break}}function p13uploadReconnect(){uploadFile.ws=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotUploadData),serverPublicNamePort,authCookie,domainUrl);uploadFile.ws.attemptWebRTC=false;uploadFile.ws.ctrlMsgAllowed=false;uploadFile.ws.onStateChanged=onFileUploadStateChange;uploadFile.ws.Start(filesNode._id)}function p13uploadNextFile(){uploadFile.xfilePtr++;if(uploadFile.xfiles.length>uploadFile.xfilePtr){uploadFile.xptr=0;var a=uploadFile.xfiles[uploadFile.xfilePtr];QH("p13dfileName",a.name);Q("d2progressBar").max=a.size;Q("d2progressBar").value=0;uploadFile.xreader=new FileReader();uploadFile.xreader.onload=function(){uploadFile.xdata=uploadFile.xreader.result;uploadFile.ws.sendText(JSON.stringify({action:"upload",reqid:uploadFile.xfilePtr,path:uploadFile.xpath,name:a.name,size:uploadFile.xdata.byteLength}))};uploadFile.xreader.readAsArrayBuffer(a)}else{p13uploadFileCancel()}}function p13uploadFileCancel(a,b){if(uploadFile!=null){if(uploadFile.ws!=null){uploadFile.ws.Stop();uploadFile.ws=null}uploadFile=null}setDialogMode(0)}function p13gotUploadData(b){var a=JSON.parse(b);if((uploadFile==null)||(parseInt(uploadFile.xfilePtr)!=parseInt(a.reqid))){return}if(a.action=="uploadstart"){p13uploadNextPart(false);for(var c=0;c<8;c++){p13uploadNextPart(true)}}else{if(a.action=="uploadack"){p13uploadNextPart(false)}else{if(a.action=="uploaderror"){p13uploadFileCancel()}}}}function p13uploadNextPart(c){var a=uploadFile.xdata;var e=uploadFile.xptr;var d=uploadFile.xptr+4096;if(d>a.byteLength){if(c==true){return}d=a.byteLength}if(e==a.byteLength){if(uploadFile.ws!=null){uploadFile.ws.Stop();uploadFile.ws=null}if(uploadFile.xfiles.length>uploadFile.xfilePtr+1){p13uploadReconnect()}else{p13uploadFileCancel()}}else{var b=a.slice(e,d);uploadFile.ws.send(b);uploadFile.xptr=d;Q("d2progressBar").value=d}}var currentDeviceEvents=null;function deviceEventsUpdate(){var h="",a=null;for(var c in currentDeviceEvents){var b=currentDeviceEvents[c];var g=new Date(b.time);if(printDate(g)!=a){if(a!=null){h+="</table>"}a=printDate(g);h+="<table style=width:100% cellpadding=0 cellspacing=0><tr><td class=DevSt colspan=4>"+a+"</td></tr>"}var d="si3";if(b.etype=="user"){d="m2"}if(b.etype=="server"){d="si3"}var e=b.msg.split("(R)").join("&reg;");h+="<tr><td style=width:18px><div class="+d+"></div></td><td class=g1 style=float:none>&nbsp;</td><td style=background-color:#C9C9C9>"+printTime(g)+" - "+e+"</td><td class=g2 style=float:none>&nbsp;</td></tr><tr style=height:2px></tr>"}if(a!=null){h+="</table>"}if(h==""){h="<br><i>No Events Found</i><br><br>"}QH("p16events",h)}function refreshDeviceEvents(){meshserver.send({action:"events",nodeid:currentNode._id,limit:parseInt(p16limitdropdown.value)})}function agentConsoleHandleKeys(b){if((b.ctrlKey)||(b.altKey)){return true}var d=0,a=Q("p15consoleText");if(b.key){if(b.keyCode==13&&consoleFocus==0){p15consoleSend(b);d=1}else{if(b.keyCode==8&&consoleFocus==0){var g=a.value;a.value=g.substring(0,g.length-1);d=1}else{if(b.keyCode==27){a.value="";d=1}else{if((b.keyCode==38)||(b.keyCode==40)){var c=consoleHistory.indexOf(a.value);if((b.keyCode==38)&&((consoleHistory.length-1)>c)){a.value=consoleHistory[c+1]}else{if((b.keyCode==40)&&(c>0)){a.value=consoleHistory[c-1]}else{if((b.keyCode==40)&&(c==0)){a.value=""}}}d=1}else{if(b.key.length===1){insertTextAtCursor(a,b.key);d=1}}}}}}else{if(b.charCode!=0&&consoleFocus==0){a.value=((a.value+String.fromCharCode(b.charCode)));d=1}}if(d>0){return haltEvent(b)}}function insertTextAtCursor(a,d){if(document.selection){a.focus();sel=document.selection.createRange();sel.text=d}else{if(a.selectionStart||a.selectionStart=="0"){var c=a.selectionStart,b=a.selectionEnd;a.value=a.value.substring(0,c)+d+a.value.substring(b,a.value.length);a.setSelectionRange(b+1,b+1)}else{a.value+=myValue}}}var consoleNode;var consoleServerText="";function setupConsole(){if(xxcurrentView==115){var d=(consoleNode=="server");consoleNode="server";QH("p15deviceName","My Server Console");QE("p15consoleText",true);QH("p15statetext","");QH("p15coreName","");if(d==false){QH("p15agentConsoleText",consoleServerText);Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight}}else{var d=(consoleNode==currentNode);consoleNode=currentNode;var a=meshes[consoleNode.meshid];var b=a.links[userinfo._id].rights;if((b&16)!=0){if(consoleNode.consoleText==null){consoleNode.consoleText=""}if(d==false){QH("p15agentConsoleText",consoleNode.consoleText);Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight}var c=((consoleNode.conn&1)!=0)?true:false;QH("p15statetext",c?"Agent is online":"Agent is offline");QE("p15consoleText",c);QE("p15uploadCore",c)}else{QH("p15statetext","Access Denied");QE("p15consoleText",false);QE("p15uploadCore",false)}}}function p15consoleClear(){QH("p15agentConsoleText","");Q("id_p15consoleClear").blur();if(xxcurrentView==115){consoleServerText=""}else{consoleNode.consoleText=""}}var consoleHistory=[];function p15consoleSend(a){if(a&&a.keyCode!=13){return}var d=Q("p15consoleText").value,c="<div style=color:green>&gt; "+EscapeHtml(Q("p15consoleText").value)+"<br/></div>";Q("p15agentConsoleText").innerHTML+=c;Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight;Q("p15consoleText").value="";if(xxcurrentView==115){consoleServerText+=c;meshserver.send({action:"serverconsole",value:d})}else{consoleNode.consoleText+=c;meshserver.send({action:"msg",type:"console",nodeid:consoleNode._id,value:d})}if(d.length>0){var b=consoleHistory.indexOf(d);if(b>=0){consoleHistory.splice(b,1)}consoleHistory.unshift(d);consoleHistory.splice(10)}}function p15consoleReceive(b,a){a="<div>"+a+"</div>";if(b==="serverconsole"){consoleServerText+=a;if(consoleNode=="server"){Q("p15agentConsoleText").innerHTML+=a;Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight}}else{if(b.consoleText==null){b.consoleText=a}else{b.consoleText+=a}if(consoleNode==b){Q("p15agentConsoleText").innerHTML+=a;Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight}}}function p15downloadConsoleText(){saveAs(new Blob([Q("p15agentConsoleText").innerText],{type:"application/octet-stream"}),"console.txt")}function p15uploadCore(a){if(xxdialogMode){return}if(a.shiftKey==true){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"default"})}else{if(a.altKey==true){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"clear"})}else{if(a.ctrlKey==true){p15uploadCore2()}else{setDialogMode(2,"Perform Agent Action",3,p15uploadCoreEx,addHtmlValue("Action","<select id=d3coreMode style=width:230px><option value=1>Upload default server core</option><option value=2>Clear the core</option><option value=6>Upload recovery core</option><option value=3>Upload a core file</option><option value=4>Soft disconnect agent</option><option value=5>Hard disconnect agent</option></select>"))}}}}function p15uploadCoreEx(){if(Q("d3coreMode").value==1){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"default"})}else{if(Q("d3coreMode").value==2){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"clear"})}else{if(Q("d3coreMode").value==3){p15uploadCore2()}else{if(Q("d3coreMode").value==4){meshserver.send({action:"agentdisconnect",nodeid:consoleNode._id,disconnectMode:1})}else{if(Q("d3coreMode").value==5){meshserver.send({action:"agentdisconnect",nodeid:consoleNode._id,disconnectMode:2})}else{if(Q("d3coreMode").value==6){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"recovery"})}}}}}}}function p15uploadCore2(){if(xxdialogMode){return}Q("d3localmodeform").action="uploadmeshcorefile.ashx";Q("d3attrib").value=currentNode._id;setDialogMode(3,"Upload Mesh Agent Core",3,p15uploadCoreEx2);d3init()}function p15uploadCoreEx2(){var b=Q("d3uploadMode").value;if(b==1){Q("d3submit").click()}else{var a=d3getFileSel();if(a.length==1){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"custom",path:d3filetreelocation.join("/")+"/"+a[0]})}}}function account_manageAuthApp(){if(xxdialogMode||((features&4096)==0)){return}if(userinfo.otpsecret==1){account_removeOtp()}else{account_addOtp()}return false}function account_addOtp(){if(xxdialogMode||(userinfo.otpsecret==1)||((features&4096)==0)){return}setDialogMode(2,"Authenticator App",2,function(){meshserver.send({action:"otpauth-setup",secret:Q("d2optsecret").attributes.secret.value,token:Q("d2otpauthinput").value})},"<div id=d2optinfo>Loading...</div>","otpauth-request");meshserver.send({action:"otpauth-request"})}function account_addOtpCheck(a){var b=(Q("d2otpauthinput").value.length==6);QE("idx_dlgOkButton",b);if(a&&(a.keyCode==13)&&b){dialogclose(1)}}function account_removeOtp(){if(xxdialogMode||(userinfo.otpsecret!=1)||((features&4096)==0)){return}setDialogMode(2,"Authenticator App",3,function(){meshserver.send({action:"otpauth-clear"})},"Confirm removal of authenticator application 2-step login?")}function account_manageOtp(a){if((xxdialogMode==2)&&(xxdialogTag=="otpauth-manage")){dialogclose(0)}if(xxdialogMode||((features&4096)==0)){return false}if((userinfo.otpsecret==1)||(userinfo.otphkeys>0)){meshserver.send({action:"otpauth-getpasswords",subaction:a})}return false}function account_manageHardwareOtp(){if((xxdialogMode==2)&&(xxdialogTag=="otpauth-hardware-manage")){dialogclose(0)}if(xxdialogMode||((features&4096)==0)){return false}meshserver.send({action:"otp-hkey-get"});return false}function account_addhkey(a){if(a==3){var b="Type in the name of the key to add.<br /><br />";b+=addHtmlValue("Key Name",'<input id=dp1keyname style=width:230px maxlength=20 autocomplete=off placeholder="MyKey" onkeyup=account_addhkeyValidate(event,2) />')}else{if(a==2){var b="Type in a key name, select the OTP box and press the button on the YubiKey&trade;.<br /><br />";b+=addHtmlValue("Key Name",'<input id=dp1keyname style=width:230px maxlength=20 autocomplete=off placeholder="MyKey" onkeyup=account_addhkeyValidate(event,1) />');b+=addHtmlValue("YubiKey&trade; OTP","<input id=dp1key style=width:230px autocomplete=off onkeyup=account_addhkeyValidate(event,2) />")}}setDialogMode(2,"Add Security Key",3,account_addhkeyEx,b,a);Q("dp1keyname").focus()}function account_addhkeyValidate(b,a){if((b!=null)&&(b.keyCode==13)){if(a==2){dialogclose(1)}else{Q("dp1key").focus()}}}function account_addhkeyEx(a,c){var b=Q("dp1keyname").value;if(b==""){b="MyKey"}if(c==2){meshserver.send({action:"otp-hkey-yubikey-add",name:b,otp:Q("dp1key").value});setDialogMode(2,"Add Security Key",0,null,"<br />Checking...<br /><br /><br />","otpauth-hardware-manage")}else{if(c==3){meshserver.send({action:"webauthn-startregister",name:b})}}}function account_removehkey(a){meshserver.send({action:"otp-hkey-remove",index:a});meshserver.send({action:"otp-hkey-get"})}function account_enableNotifications(){if(Notification){Notification.requestPermission().then(function(a){QV("accountEnableNotificationsSpan",a!="granted")})}return false}function account_showAccountNotifySettings(){if(xxdialogMode){return false}var b="";b+="<div><label><input id=p2notifyPlayNotifySound type=checkbox />Notification sound.</label></div>";b+="<div><label><input id=p2notifyIntelDeviceConnect type=checkbox />Device connections.</label></div>";b+="<div><label><input id=p2notifyIntelDeviceDisconnect type=checkbox />Device disconnections.</label></div>";b+="<div><label><input id=p2notifyIntelAmtKvmActions type=checkbox />Intel&reg; AMT desktop and serial events.</label></div>";setDialogMode(2,"Notification Settings",3,account_showAccountNotifySettingsEx,b);var a=getstore("notifications",0);Q("p2notifyPlayNotifySound").checked=(a&1);Q("p2notifyIntelDeviceConnect").checked=(a&2);Q("p2notifyIntelDeviceDisconnect").checked=(a&4);Q("p2notifyIntelAmtKvmActions").checked=(a&8);return false}function account_showAccountNotifySettingsEx(){var a=0;a+=Q("p2notifyPlayNotifySound").checked?1:0;a+=Q("p2notifyIntelDeviceConnect").checked?2:0;a+=Q("p2notifyIntelDeviceDisconnect").checked?4:0;a+=Q("p2notifyIntelAmtKvmActions").checked?8:0;putstore("notifications",a)}function account_showVerifyEmail(){if(xxdialogMode||(userinfo.emailVerified==true)||(serverinfo.emailcheck!=true)){return false}var a="Click ok to send a verification mail to:<br /><div style=padding:8px><b>"+EscapeHtml(userinfo.email)+"</b></div>Please wait a few minute to receive the verification.";setDialogMode(2,"Email Verification",3,account_showVerifyEmailEx,a);return false}function account_showVerifyEmailEx(){meshserver.send({action:"verifyemail",email:userinfo.email})}function account_showChangeEmail(){if(xxdialogMode){return false}var a="Change your account email address here.<br /><br />";a+=addHtmlValue("Email","<input id=dp2email style=width:230px maxlength=256 onchange=account_validateEmail() onkeyup=account_validateEmail(event) />");setDialogMode(2,"Email Address Change",3,account_changeEmail,a);if(userinfo.email!=null){Q("dp2email").value=userinfo.email}account_validateEmail();Q("dp2email").focus();return false}function account_validateEmail(a,b){QE("idx_dlgOkButton",validateEmail(Q("dp2email").value)&&(Q("dp2email").value!=userinfo.email));if((a!=null)&&(a.keyCode==13)){dialogclose(1)}}function account_changeEmail(){meshserver.send({action:"changeemail",email:Q("dp2email").value})}function account_showDeleteAccount(){if(xxdialogMode){return false}var a="To delete this account, type in the account password in both boxes below and hit ok.<br /><br />";a+="<form action='"+domainUrl+"deleteaccount' method=post><table style=margin-left:80px><tr>";a+="<td align=right>Password:</td><td><input id=apassword1 type=password name=apassword1 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>";a+="</tr><tr><td align=right>Password:</td><td><input id=apassword2 type=password name=apassword2 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>";a+="</tr></table><br /><div style=padding:10px;margin-bottom:4px>";a+="<input id=account_dlgCancelButton type=button value=Cancel style=float:right;width:80px;margin-left:5px onclick=dialogclose(0)>";a+='<input id=account_dlgOkButton type=submit value=OK style="float:right;width:80px" onclick=dialogclose(1)>';a+="</div><br /></form>";setDialogMode(2,"Delete Account",0,null,a);account_validateDeleteAccount();Q("apassword1").focus();return false}function account_showChangePassword(){if(xxdialogMode){return false}var d="Change your account password by entering the old password and new password twice in the boxes below.";if(features&65536){" Password hint can be used but is not recommanded."}d+="<br /><br />";d+="<table style=margin-left:60px>";d+="<tr><td align=right>Old password:</td><td><input id=apassword0 type=password name=apassword0 autocomplete=off onchange=account_validateNewPassword() onkeyup=account_validateNewPassword() onkeydown=account_validateNewPassword() /> <b></b></td></tr>";d+="<tr><td align=right>New password:</td><td><input id=apassword1 type=password name=apassword1 autocomplete=off onchange=account_validateNewPassword() onkeyup=account_validateNewPassword() onkeydown=account_validateNewPassword() /> <b><span id=dxPassWarn></span></b></td></tr>";d+="<tr><td align=right>New password:</td><td><input id=apassword2 type=password name=apassword2 autocomplete=off onchange=account_validateNewPassword() onkeyup=account_validateNewPassword() onkeydown=account_validateNewPassword() /></td></tr>";if(features&65536){d+="<tr><td align=right>Password hint:</td><td><input id=apasswordhint name=apasswordhint maxlength=250 type=text autocomplete=off onchange=account_validateNewPassword() onkeyup=account_validateNewPassword() onkeydown=account_validateNewPassword() /></td></tr>"}d+="</table>";if(passRequirements){var b=[],c=0;for(var a in passRequirements){if((a!="reset")&&(a!="hint")){b.push(a+":"+passRequirements[a]);c++}}if(c>0){d+="<br /><span style=font-size:x-small>Requirements: "+b.join(", ")+".</span>"}}d+="<br />";setDialogMode(2,"Change Password",3,account_showChangePasswordEx,d);Q("apassword0").focus();account_validateNewPassword();return false}function account_showChangePasswordEx(){if(Q("apassword1").value==Q("apassword2").value){var a={action:"changepassword",oldpass:Q("apassword0").value,newpass:Q("apassword1").value};if(features&65536){a.hint=Q("apasswordhint").value}meshserver.send(a)}}function account_createMesh(){if(xxdialogMode){return false}if((userinfo.siteadmin!=4294967295)&&((userinfo.siteadmin&64)!=0)){setDialogMode(2,"New Device Group",1,null,"This account does not have the rights to create a new device group.");return false}if((userinfo.emailVerified!==true)&&(serverinfo.emailcheck==true)&&(userinfo.siteadmin!=4294967295)){setDialogMode(2,"Account Security",1,null,'Unable to access a device until a email address is verified. This is required for password recovery. Go to the "My Account" tab to change and verify an email address.');return false}if((features&262144)&&!((userinfo.otpsecret==1)||(userinfo.otphkeys>0)||(userinfo.otpkeys>0))){setDialogMode(2,"Account Security",1,null,'Unable to access a device until two-factor authentication is enabled. This is required for extra security. Go to the "My Account" tab and look at the "Account Security" section.');return false}var a="Create a new device group using the options below.<br /><br />";a+=addHtmlValue("Name","<input id=dp2meshname style=width:230px maxlength=64 onchange=account_validateMeshCreate() onkeyup=account_validateMeshCreate(event,1) />");a+=addHtmlValue("Type","<div style=width:230px;margin:0;padding:0><select id=dp2meshtype style=width:100% onchange=account_validateMeshCreate() onkeyup=account_validateMeshCreate(event,2) ><option value=2>Manage using a software agent</option><option value=1>Intel&reg; AMT only, no agent</option></select></div>");a+=addHtmlValue("Description","<div style=width:230px;margin:0;padding:0><textarea id=dp2meshdesc maxlength=1024 style=width:100%;resize:none></textarea></div>");setDialogMode(2,"New Device Group",3,account_createMeshEx,a);account_validateMeshCreate();Q("dp2meshname").focus();return false}function account_validateMeshCreate(a,b){if((b==1)&&(a!=null)&&(a.key=="Enter")&&(Q("dp2meshname").value.length>0)){Q("dp2meshtype").focus()}if((b==2)&&(a!=null)&&(a.key=="Enter")){Q("dp2meshdesc").focus()}QE("idx_dlgOkButton",Q("dp2meshname").value.length>0)}function account_createMeshEx(a,b){meshserver.send({action:"createmesh",meshname:Q("dp2meshname").value,meshtype:Q("dp2meshtype").value,desc:Q("dp2meshdesc").value})}function account_validateDeleteAccount(){QE("account_dlgOkButton",(Q("apassword1").value.length>0)&&(Q("apassword1").value==Q("apassword2").value))}function account_validateNewPassword(){var d="",a=(Q("apassword0").value.length>0)&&(Q("apassword1").value.length>0)&&(Q("apassword1").value==Q("apassword2").value)&&(Q("apassword0").value!=Q("apassword1").value);if((features&65536)&&(Q("apasswordhint").value==Q("apassword1").value)){a=false}if(Q("apassword1").value!=""){if(passRequirements==null||passRequirements==""){var c=checkPasswordStrength(Q("apassword1").value);if(c>=80){d="<span style=color:green>Strong<span>"}else{if(c>=60){d="<span style=color:blue>Good<span>"}else{d="<span style=color:red>Weak<span>"}}}else{var b=checkPasswordRequirements(Q("apassword1").value,passRequirements);if(b==false){a=false;d="<span style=color:red>Policy<span>"}}}QH("dxPassWarn",d);QE("idx_dlgOkButton",a)}function checkPasswordStrength(e){var g=0,d={},h=0,j={digits:/\d/.test(e),lower:/[a-z]/.test(e),upper:/[A-Z]/.test(e),nonWords:/\W/.test(e)};if(!e){return 0}for(var b=0;b<e.length;b++){d[e[b]]=(d[e[b]]||0)+1;g+=5/d[e[b]]}for(var a in j){h+=(j[a]==true)?1:0}return parseInt(g+(h-1)*10)}function checkPasswordRequirements(e,g){if((g==null)||(g=="")||(typeof g!="object")){return true}if(g.min){if(e.length<g.min){return false}}if(g.max){if(e.length>g.max){return false}}var d=0,b=0,h=0,c=0;for(var a=0;a<e.length;a++){if(/\d/.test(e[a])){d++}if(/[a-z]/.test(e[a])){b++}if(/[A-Z]/.test(e[a])){h++}if(/\W/.test(e[a])){c++}}if(g.num&&(d<g.num)){return false}if(g.lower&&(b<g.lower)){return false}if(g.upper&&(h<g.upper)){return false}if(g.nonalpha&&(c<g.nonalpha)){return false}return true}function updateMeshes(){var e="";var a=0,b=0;for(i in meshes){if(a>1){e+="</tr><tr>";a=0}a++;b++;var d=0;if(meshes[i].links[userinfo._id]){d=meshes[i].links[userinfo._id].rights}var g="Partial Rights";if(d==4294967295){g="Full Administrator"}else{if(d==0){g="No Rights"}}e+="<div onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=display:inline-block;width:431px;height:50px;padding-top:1px;padding-bottom:1px;float:left><div style=float:left;width:30px;height:100%></div><div tabindex=0 style=height:100%;cursor:pointer onclick=gotoMesh('"+i+"') onkeypress=\"if (event.key=='Enter') gotoMesh('"+i+"')\"><div class=mi style=float:left;width:50px;height:50px></div><div style=height:100%><div class=g1></div><div class=e2 style=width:300px><div class=e1>"+EscapeHtml(meshes[i].name)+"</div><div>"+g+"</div></div><div class=g2 style=float:left></div></div></div></div>"}meshcount=b;QH("p2meshes",e);QV("p2noMeshFound",b==0)}function gotoMesh(a){currentMesh=meshes[a];p20updateMesh();go(20);return false}function server_showRestoreDlg(){if(xxdialogMode){return false}var a="Restore the server using a backup, <span style=color:red>this will delete the existing server data</span>. Only do this if you know what you are doing.<br /><br />";a+='<form action="/restoreserver.ashx" enctype="multipart/form-data" method="post"><div>';a+='<input id=account_dlgFileInput type=file name=datafile style=width:100% accept=".zip,application/octet-stream,application/zip,application/x-zip,application/x-zip-compressed" onchange=account_validateServerRestore()>';a+="<input id=account_dlgCancelButton type=button value=Cancel style=float:right;width:80px;margin-left:5px onclick=dialogclose(0)>";a+="<input id=account_dlgOkButton type=submit value=OK style=float:right;width:80px onclick=dialogclose(1)>";a+="</div><br /><br /></form>";setDialogMode(2,"Restore Server",0,null,a);account_validateServerRestore();return false}function account_validateServerRestore(){QE("account_dlgOkButton",Q("account_dlgFileInput").files.length==1)}function server_showVersionDlg(){if(xxdialogMode){return false}setDialogMode(2,"MeshCentral Version",1,null,"Loading...","MeshCentralServerUpdate");meshserver.send({action:"serverversion"});return false}function server_showVersionDlgUpdate(){QE("idx_dlgOkButton",Q("d2updateCheck").checked)}function server_showVersionDlgEx(){meshserver.send({action:"serverupdate"})}function server_showErrorsDlg(){if(xxdialogMode){return false}setDialogMode(2,"MeshCentral Errors",1,null,"Loading...","MeshCentralServerErrors");meshserver.send({action:"servererrors"});return false}function server_showErrorsDlgUpdate(){QE("idx_dlgOkButton",Q("d2updateCheck").checked)}function server_showErrorsDlgEx(){meshserver.send({action:"serverclearerrorlog"})}function d2CopyServerErrorsToClip(){saveAs(new Blob([Q("d2ServerErrorsLogPre").innerText],{type:"application/octet-stream"}),"servererrors.txt")}var currentMesh;function p20updateMesh(){if(currentMesh==null){return}QH("p20meshName",EscapeHtml(currentMesh.name));var m="Unknown #"+currentMesh.mtype;var l=0;try{l=currentMesh.links[userinfo._id].rights}catch(d){}if(currentMesh.mtype==1){m="Intel&reg; AMT only, no agent"}if(currentMesh.mtype==2){m="Managed using a software agent"}var t="";t+=addHtmlValue("Name",addLinkConditional(EscapeHtml(currentMesh.name),"p20editmesh(1)",(l&1)!=0));t+=addHtmlValue("Description",addLinkConditional(((currentMesh.desc&&currentMesh.desc!="")?EscapeHtml(currentMesh.desc):"<i>None</i>"),"p20editmesh(2)",(l&1)!=0));t+=addHtmlValue("Type",m);if(currentMesh.mtype==2){var h=[];if(currentMesh.flags){if(currentMesh.flags&1){h.push("Auto-Remove")}if(currentMesh.flags&2){h.push("Hostname Sync")}}h=h.join(", ");if(h==""){h="<i>None</i>"}t+=addHtmlValue("Features",addLinkConditional(h,"p20editmeshfeatures()",l&1))}if(currentMesh.mtype==2){h=[];var a=0;if(currentMesh.consent){a=currentMesh.consent}if(serverinfo.consent){a|=serverinfo.consent}if(a&8){h.push("Desktop Prompt")}else{if(a&1){h.push("Desktop Notify")}}if(a&16){h.push("Terminal Prompt")}else{if(a&2){h.push("Terminal Notify")}}if(a&32){h.push("Files Prompt")}else{if(a&4){h.push("Files Notify")}}if(a==7){h=["Always Notify"]}if((a&56)==56){h=["Always Prompt"]}h=h.join(", ");if(h==""){h="<i>None</i>"}t+=addHtmlValue("User Consent",addLinkConditional(h,"p20editmeshconsent()",l&1))}var j=0,k=[];if(userinfo.links&&userinfo.links[currentMesh._id]&&userinfo.links[currentMesh._id].notify){j=userinfo.links[currentMesh._id].notify}if(j&2){k.push("Connect")}if(j&4){k.push("Disconnect")}if(j&8){k.push("Intel&reg; AMT")}if(k.length==0){k.push("None")}t+=addHtmlValue("Notifications",addLink(k.join(", "),"p20editMeshNotify()"));var g="No Policy";if(currentMesh.amt){if(currentMesh.amt.type==1){g="Deactivate Client Control Mode (CCM)"}else{if(currentMesh.amt.type==2){g="Simple Client Control Mode (CCM)";if(currentMesh.amt.cirasetup==2){g+=" + CIRA"}}else{if(currentMesh.amt.type==3){g="Simple Admin Control Mode (ACM)";if(currentMesh.amt.cirasetup==2){g+=" + CIRA"}}}}}t+=addHtmlValue("Intel&reg; AMT",addLinkConditional(g,"p20editMeshAmt()",l&1));if(l&1){t+='<br><input type=button value=Notes title="View notes about this device group" onclick=showNotes(false,"'+encodeURIComponent(currentMesh._id)+'") />'}t+="<br style=clear:both><br>";var c=currentMesh.links[userinfo._id];if(c&&((c.rights&2)!=0)){t+='<a href=# onclick="return p20showAddMeshUserDialog()" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add Users</a>'}if((l&4)!=0){if(currentMesh.mtype==1){t+="<a href=# onclick='return addCiraDeviceToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Add a new Intel&reg; AMT computer that is located on the internet."><img src=images/icon-installmesh.png border=0 height=12 width=12> Install CIRA</a>';t+="<a href=# onclick='return addDeviceToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Add a new Intel&reg; AMT computer that is located on the local network."><img src=images/icon-installmesh.png border=0 height=12 width=12> Install local</a>';if(currentMesh.amt&&(currentMesh.amt.type==2)){t+="<a href=# onclick='return showCcmActivation(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Perform Intel AMT client control mode (CCM) activation."><img src=images/icon-installmesh.png border=0 height=12 width=12> Activation</a>'}else{if(currentMesh.amt&&(currentMesh.amt.type==3)&&((features&1048576)!=0)){t+="<a href=# onclick='return showAcmActivation(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Perform Intel AMT admin control mode (ACM) activation."><img src=images/icon-installmesh.png border=0 height=12 width=12> Activation</a>'}}}if(currentMesh.mtype==2){t+="<a href=# onclick='return addAgentToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Add a new computer to this mesh by installing the mesh agent."><img src=images/icon-addnew.png border=0 height=12 width=12> Install</a>';t+="<a href=# onclick='return inviteAgentToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Invite someone to install the mesh agent on this mesh."><img src=images/icon-addnew.png border=0 height=12 width=12> Invite</a>'}}t+='<table style="color:black;background-color:#EEE;border-color:#AAA;border-width:1px;border-style:solid;border-collapse:collapse" border=0 cellpadding=2 cellspacing=0 width=100%><tbody><tr style=background-color:#AAAAAA;font-weight:bold><th scope=col style=text-align:left;width:430px>User Authorizations</th><th scope=col style=text-align:left></th></tr>';var b=1,p=[];for(var e in currentMesh.links){var s=e.split("/")[2];if(currentMesh.links[e].name){s=currentMesh.links[e].name}if(e==userinfo._id){s=userinfo.name}p.push({id:e,name:s,rights:currentMesh.links[e].rights})}p.sort(function(r,u){if(r.name>u.name){return 1}if(r.name<u.name){return -1}return 0});for(var e in p){var q="",o="Partial Rights",n=p[e].rights;if(n==4294967295){o="Full Administrator"}else{if(n==0){o="No Rights"}}if((p[e].id!=userinfo._id)&&(l==4294967295||(((l&2)!=0)))){q="<a href=# onclick='return p20deleteUser(event,\""+encodeURIComponent(p[e].id)+'")\' title="Remote user rights to this mesh" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>'}t+='<tr tabindex=0 onclick=p20viewuser("'+encodeURIComponent(p[e].id)+"\") onkeypress=\"if (event.key=='Enter') p20viewuser('"+encodeURIComponent(p[e].id)+"')\" style=cursor:pointer"+(((b%2)==0)?";background-color:#DDD":"")+'><td><div title="User" class=m2></div><div>&nbsp;'+EscapeHtml(decodeURIComponent(p[e].name))+"<div></div></div></td><td><div style=float:right>"+q+"</div><div>"+o+"</div></td></tr>";++b}t+="</tbody></table>";if(l==4294967295){t+="<div style=font-size:x-small;text-align:right><span><a href=# onclick=p20showDeleteMeshDialog() style=cursor:pointer>Delete Group</a></span></div>"}QH("p20info",t)}function p20editMeshAmt(){if(xxdialogMode){return}var b="",a="";if((features&1048576)!=0){a="<option value=3>Simple Admin Control Mode (ACM)</option>"}if(currentMesh.mtype==1){b+=addHtmlValue("Type","<select id=dp20amtpolicy style=width:230px onchange=p20editMeshAmtChange()><option value=0>No Policy</option><option value=2>Simple Client Control Mode (CCM)</option>"+a+"</select>")}else{b+=addHtmlValue("Type","<select id=dp20amtpolicy style=width:230px onchange=p20editMeshAmtChange()><option value=0>No Policy</option><option value=1>Deactivate Client Control Mode (CCM)</option><option value=2>Simple Client Control Mode (CCM)</option>"+a+"</select>")}b+="<div id=dp20amtpolicydiv></div>";setDialogMode(2,"Intel&reg; AMT Policy",3,p20editMeshAmtEx,b);if(currentMesh.amt){Q("dp20amtpolicy").value=currentMesh.amt.type}p20editMeshAmtChange();if(currentMesh.amt&&(currentMesh.amt.type==2)||(currentMesh.amt.type==3)){Q("dp20amtpolicypass").value=currentMesh.amt.password;if((currentMesh.amt.type==2)&&(currentMesh.amt.badpass!=null)){Q("dp20amtbadpass").value=currentMesh.amt.badpass}if((features&1024)==0){Q("dp20amtcira").value=currentMesh.amt.cirasetup}}dp20amtValidatePolicy()}function p20editMeshAmtChange(){var a=Q("dp20amtpolicy").value,b="";if(a>=2){b=addHtmlValue("Password*","<input id=dp20amtpolicypass type=password style=width:230px maxlength=32 onchange=dp20amtValidatePolicy() onkeyup=dp20amtValidatePolicy() autocomplete=off />");b+=addHtmlValue("Password*","<input id=dp20amtpolicypass2 type=password style=width:230px maxlength=32 onchange=dp20amtValidatePolicy() onkeyup=dp20amtValidatePolicy() autocomplete=off />");if((a==2)&&(currentMesh.mtype==2)){b+=addHtmlValue("Password mismatch","<select id=dp20amtbadpass style=width:230px><option value=0>Do nothing</option><option value=1>Reactivate Intel&reg; AMT</option></select>")}if((features&1024)==0){if(a==2){b+=addHtmlValue('<span title="Client Initiated Remote Access">CIRA</span>',"<select id=dp20amtcira style=width:230px><option value=0>Don't configure</option><option value=1>Don't connect to server</option><option value=2>Connect to server</option></select>")}else{b+=addHtmlValue('<span title="Client Initiated Remote Access">CIRA</span>',"<select id=dp20amtcira style=width:230px><option value=0>Don't configure</option><option value=2>Connect to server</option></select>")}}b+='<br/><span style="font-size:10px">* Leave blank to assign a random password to each device.</span><br/>';if(currentMesh.mtype==2){if(a==2){b+='<span style="font-size:10px">This policy will not impact devices with Intel&reg; AMT in ACM mode.</span><br/>';b+='<span style="font-size:10px">This is not a secure policy as agents will be performing activation.</span>'}else{b+='<span style="font-size:10px">During activation, the agent will have access to admin password infomation.</span>'}}}QH("dp20amtpolicydiv",b);setTimeout(dp20amtValidatePolicy,1)}function dp20amtValidatePolicy(){var a=true,d=Q("dp20amtpolicy").value;if((d==2)||(d==3)){var b=Q("dp20amtpolicypass").value,c=Q("dp20amtpolicypass2").value;a=((b===c)&&((b==="")?true:passwordcheck(b)))}QE("idx_dlgOkButton",a)}function p20editMeshAmtEx(){var b=parseInt(Q("dp20amtpolicy").value),a={type:b};if(b==2){a={type:b,password:Q("dp20amtpolicypass").value};if(currentMesh.mtype==2){a.badpass=parseInt(Q("dp20amtbadpass").value)}if((features&1024)==0){a.cirasetup=parseInt(Q("dp20amtcira").value)}else{a.cirasetup=1}}else{if(b==3){a={type:b,password:Q("dp20amtpolicypass").value};if((features&1024)==0){a.cirasetup=parseInt(Q("dp20amtcira").value)}else{a.cirasetup=1}}}meshserver.send({action:"meshamtpolicy",meshid:currentMesh._id,amtpolicy:a})}function p20showDeleteMeshDialog(){if(xxdialogMode){return false}var a='Are you sure you want to delete group "'+EscapeHtml(currentMesh.name)+'"? Deleting the device group will also delete all information about devices within this group.<br /><br />';a+="<label><input id=p20check type=checkbox onchange=p20validateDeleteMeshDialog() />Confirm</label>";setDialogMode(2,"Delete Group",3,p20showDeleteMeshDialogEx,a);p20validateDeleteMeshDialog();return false}function p20validateDeleteMeshDialog(){QE("idx_dlgOkButton",Q("p20check").checked)}function p20showDeleteMeshDialogEx(a,b){meshserver.send({action:"deletemesh",meshid:currentMesh._id,meshname:currentMesh.name})}function p20editmesh(a){if(xxdialogMode){return}var b=addHtmlValue("Name","<input id=dp20meshname style=width:230px maxlength=32 onchange=p20editmeshValidate() onkeyup=p20editmeshValidate() />");b+=addHtmlValue("Description","<div style=width:230px;margin:0;padding:0><textarea id=dp20meshdesc maxlength=1024 style=width:100%;resize:none></textarea></div>");setDialogMode(2,"Edit Device Group",3,p20editmeshEx,b);Q("dp20meshname").value=currentMesh.name;if(currentMesh.desc){Q("dp20meshdesc").value=currentMesh.desc}p20editmeshValidate();if(a==2){Q("dp20meshdesc").focus()}else{Q("dp20meshname").focus()}}function p20editmeshEx(){meshserver.send({action:"editmesh",meshid:currentMesh._id,meshname:Q("dp20meshname").value,desc:Q("dp20meshdesc").value})}function p20editmeshValidate(){QE("idx_dlgOkButton",Q("dp20meshname").value.length>0)}function p20editmeshconsent(){if(xxdialogMode){return}var b="",a=(currentMesh.consent)?currentMesh.consent:0;b+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px"><b>Desktop</b></div>';b+="<div><label><input type=checkbox id=d20flag1 "+((a&1)?"checked":"")+">Notify user</label></div>";b+="<div><label><input type=checkbox id=d20flag2 "+((a&8)?"checked":"")+">Prompt for user consent</label></div>";b+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:8px"><b>Terminal</b></div>';b+="<div><label><input type=checkbox id=d20flag3 "+((a&2)?"checked":"")+">Notify user</label></div>";b+="<div><label><input type=checkbox id=d20flag4 "+((a&16)?"checked":"")+">Prompt for user consent</label></div>";b+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:8px"><b>Files</b></div>';b+="<div><label><input type=checkbox id=d20flag5 "+((a&4)?"checked":"")+">Notify user</label></div>";b+="<div><label><input type=checkbox id=d20flag6 "+((a&32)?"checked":"")+">Prompt for user consent</label></div>";setDialogMode(2,"Edit Device Group User Consent",3,p20editmeshconsentEx,b);if(serverinfo.consent){if(serverinfo.consent&1){Q("d20flag1").checked=true}if(serverinfo.consent&8){Q("d20flag2").checked=true}if(serverinfo.consent&2){Q("d20flag3").checked=true}if(serverinfo.consent&16){Q("d20flag4").checked=true}if(serverinfo.consent&4){Q("d20flag5").checked=true}if(serverinfo.consent&32){Q("d20flag6").checked=true}QE("d20flag1",!(serverinfo.consent&1));QE("d20flag2",!(serverinfo.consent&8));QE("d20flag3",!(serverinfo.consent&2));QE("d20flag4",!(serverinfo.consent&16));QE("d20flag5",!(serverinfo.consent&4));QE("d20flag6",!(serverinfo.consent&32))}}function p20editmeshconsentEx(){var a=0;if(Q("d20flag1").checked){a+=1}if(Q("d20flag2").checked){a+=8}if(Q("d20flag3").checked){a+=2}if(Q("d20flag4").checked){a+=16}if(Q("d20flag5").checked){a+=4}if(Q("d20flag6").checked){a+=32}meshserver.send({action:"editmesh",meshid:currentMesh._id,consent:a})}function p20editmeshfeatures(){if(xxdialogMode){return}var a=(currentMesh.flags)?currentMesh.flags:0;var b="<div><label><input type=checkbox id=d20flag1 "+((a&1)?"checked":"")+">Remove device on disconnect</label><br></div>";b+="<div><label><input type=checkbox id=d20flag2 "+((a&2)?"checked":"")+">Sync server device name to hostname</label><br></div>";setDialogMode(2,"Edit Device Group Features",3,p20editmeshfeaturesEx,b)}function p20editmeshfeaturesEx(){var a=0;if(Q("d20flag1").checked){a+=1}if(Q("d20flag2").checked){a+=2}meshserver.send({action:"editmesh",meshid:currentMesh._id,flags:a})}function p20showAddMeshUserDialog(d){if(xxdialogMode){return false}var e="";if(d==null){e+="Allow users to manage this device group and devices in this group.";if(features&524288){e+=" Users need to login to this server once before they can be added to a device group."}e+="<br /><br /><div style='position:relative'>";e+=addHtmlValue("User Names",'<input id=dp20username style=width:230px maxlength=32 onchange=p20validateAddMeshUserDialog() onkeyup=p20validateAddMeshUserDialog() placeholder="user1, user2, user3" />');e+="<div id=dp20usersuggest class=suggestionBox style='top:30px;left:130px;display:none'></div>";e+="</div><br>"}else{d=decodeURIComponent(d);var c=d.split("/")[2];if(users&&users[d]){c=users[d].name}if(userinfo._id==d){c=userinfo.name}e+="Group permissions for user "+c+".<br /><br />"}e+='<div style="height:120px;overflow-y:scroll;border:1px solid gray">';e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20fulladmin>Full Administrator</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editmesh>Edit Device Group</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20manageusers>Manage Device Group Users</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20managecomputers>Manage Device Group Computers</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remotecontrol>Remote Control</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remoteview style=margin-left:12px>Remote View Only</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remotelimitedinput style=margin-left:12px>Limited Input Only</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20noterminal style=margin-left:12px>No Terminal Access</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20nofiles style=margin-left:12px>No File Access</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20noamt style=margin-left:12px>No Intel&reg; AMT</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20meshagentconsole>Mesh Agent Console</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20meshserverfiles>Server Files</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20wakedevices>Wake Devices</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editnotes>Edit Device Notes</label><br>";e+="</div>";if(d==null){setDialogMode(2,"Add Users to Device Group",3,p20showAddMeshUserDialogEx,e);Q("dp20username").focus()}else{setDialogMode(2,"Edit User Device Group Permissions",7,p20showAddMeshUserDialogEx,e,d);var a=currentMesh.links[userinfo._id].rights,b=currentMesh.links[d].rights;if(b==4294967295){Q("p20fulladmin").checked=true}else{if(b&1){Q("p20editmesh").checked=true}if(b&2){Q("p20manageusers").checked=true}if(b&4){Q("p20managecomputers").checked=true}if(b&8){Q("p20remotecontrol").checked=true;if(b&256){Q("p20remoteview").checked=true}if(b&512){Q("p20remotelimitedinput").checked=true}if(b&1024){Q("p20noterminal").checked=true}if(b&2048){Q("p20nofiles").checked=true}if(b&4096){Q("p20noamt").checked=true}}if(b&16){Q("p20meshagentconsole").checked=true}if(b&32){Q("p20meshserverfiles").checked=true}if(b&64){Q("p20wakedevices").checked=true}if(b&128){Q("p20editnotes").checked=true}}}p20validateAddMeshUserDialog();return false}function p20setname(b){b=decodeURIComponent(b);var c=Q("dp20username").value.split(",");for(var a in c){c[a]=c[a].trim()}c[c.length-1]=b;Q("dp20username").value=c.join(", ");p20validateAddMeshUserDialog();return false}function p20validateAddMeshUserDialog(){var g=currentMesh.links[userinfo._id].rights;var h=true,m=null;if(Q("dp20username")){Q("dp20username").value.split(",");for(var b in m){var l=m[b]=m[b].trim();if(l.length==0){h=false}else{if(l.indexOf('"')>=0){h=false}}}var j=false,a=false;if(users!=null){var c=m[m.length-1].trim(),d=c.toLowerCase(),e=[];if(c.length>0){for(var b in users){if(users[b].name===c){a=true;break}if(users[b].name.toLowerCase().indexOf(d)>=0){e.push(users[b].name);if(e.length>=8){break}}}if((a==false)&&(e.length>0)){var k="";for(var b in e){k+="<a href=# onclick='p20setname(\""+encodeURIComponent(e[b])+"\")'>"+e[b]+"</a><br />"}QH("dp20usersuggest",k);j=true}}}QV("dp20usersuggest",j)}QE("idx_dlgOkButton",h);QE("p20fulladmin",g==4294967295);QE("p20editmesh",(!Q("p20fulladmin").checked)&&(g==4294967295));QE("p20manageusers",!Q("p20fulladmin").checked);QE("p20managecomputers",!Q("p20fulladmin").checked);QE("p20remotecontrol",!Q("p20fulladmin").checked);QE("p20meshagentconsole",!Q("p20fulladmin").checked);QE("p20meshserverfiles",!Q("p20fulladmin").checked);QE("p20wakedevices",!Q("p20fulladmin").checked);QE("p20editnotes",!Q("p20fulladmin").checked);QE("p20remoteview",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20remotelimitedinput",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked&&!Q("p20remoteview").checked);QE("p20noterminal",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20nofiles",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20noamt",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked)}function p20showAddMeshUserDialogEx(a,e){if(a==2){p20viewuserEx(a,e)}else{var d=0;if(Q("p20fulladmin").checked==true){d=4294967295}else{if(Q("p20editmesh").checked==true){d+=1}if(Q("p20manageusers").checked==true){d+=2}if(Q("p20managecomputers").checked==true){d+=4}if(Q("p20remotecontrol").checked==true){d+=8}if(Q("p20meshagentconsole").checked==true){d+=16}if(Q("p20meshserverfiles").checked==true){d+=32}if(Q("p20wakedevices").checked==true){d+=64}if(Q("p20editnotes").checked==true){d+=128}if(Q("p20remoteview").checked==true){d+=256}if(Q("p20noterminal").checked==true){d+=512}if(Q("p20nofiles").checked==true){d+=1024}if(Q("p20noamt").checked==true){d+=2048}if(Q("p20remotelimitedinput").checked==true){d+=4096}}if(e==null){var g=Q("dp20username").value.split(","),h=[];for(var c in g){h.push(g[c].trim())}meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,usernames:h,meshadmin:d})}else{meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,usernames:[e.split("/")[2]],meshadmin:d})}}}function p20viewuser(g){if(xxdialogMode){return}var j=decodeURIComponent(g);var b=currentMesh.links[userinfo._id].rights,c=currentMesh.links[j].rights;if(((userinfo._id)!=j)&&(b==4294967295||(((b&2)!=0)&&(c!=4294967295)))){p20showAddMeshUserDialog(g)}else{var d="";if(c==4294967295){d=", Full Administrator (all rights)"}else{if((c&1)!=0){d+=", Edit Device Group"}if((c&2)!=0){d+=", Manage Device Group Users"}if((c&4)!=0){d+=", Manage Device Group Computers"}if((c&8)!=0){d+=", Remote Control"}if((c&16)!=0){d+=", Agent Console"}if((c&32)!=0){d+=", Server Files"}if((c&64)!=0){d+=", Wake Devices"}if((c&128)!=0){d+=", Edit Notes"}if(((c&8)!=0)&&(c&256)!=0){d+=", Remote View Only"}if(((c&8)!=0)&&(c&512)!=0){d+=", No Terminal"}if(((c&8)!=0)&&(c&1024)!=0){d+=", No Files"}if(((c&8)!=0)&&(c&2048)!=0){d+=", No Intel&reg; AMT"}if(((c&8)!=0)&&((c&4096)!=0)&&((c&256)==0)){d+=", Limited Input"}}d=d.substring(2);if(d==""){d="No Rights"}var e=j.split("/")[2];if(users&&users[j]){e=users[j].name}if(userinfo._id==j){e=userinfo.name}var a=1,h=addHtmlValue("User Name",EscapeHtml(decodeURIComponent(e)));if(j.split("/")[2]!=e){h+=addHtmlValue("User Identifier",EscapeHtml(j.split("/")[2]))}h+=addHtmlValue("Permissions",d);if(((userinfo._id)!=j)&&(b==4294967295||(((b&2)!=0)&&(c!=4294967295)))){a+=4}setDialogMode(2,"Device Group User",a,p20viewuserEx,h,j)}}function p20viewuserEx(a,c){if(a!=2){return}var b=c.split("/")[2];if(users&&users[c]){b=users[c].name}if(userinfo._id==c){b=userinfo.name}setDialogMode(2,"Remote Mesh User",3,p20viewuserEx2,"Confirm removal of user "+EscapeHtml(decodeURIComponent(b))+"?",c)}function p20deleteUser(a,b){haltEvent(a);p20viewuserEx(2,decodeURIComponent(b));return false}function p20viewuserEx2(a,b){meshserver.send({action:"removemeshuser",meshid:currentMesh._id,meshname:currentMesh.name,userid:b})}function p20editMeshNotify(){if(xxdialogMode){return false}var a=0;if(userinfo.links&&userinfo.links[currentMesh._id]&&userinfo.links[currentMesh._id].notify){a=userinfo.links[currentMesh._id].notify}var b="";b+="<div><label><input id=p20notifyIntelDeviceConnect type=checkbox />Device connections.</label></div>";b+="<div><label><input id=p20notifyIntelDeviceDisconnect type=checkbox />Device disconnections.</label></div>";b+="<div><label><input id=p20notifyIntelAmtKvmActions type=checkbox />Intel&reg; AMT desktop and serial events.</label></div>";setDialogMode(2,"Notification Settings",3,p20editMeshNotifyEx,b);Q("p20notifyIntelDeviceConnect").checked=(a&2);Q("p20notifyIntelDeviceDisconnect").checked=(a&4);Q("p20notifyIntelAmtKvmActions").checked=(a&8);return false}function p20editMeshNotifyEx(){var a=0;a+=Q("p20notifyIntelDeviceConnect").checked?2:0;a+=Q("p20notifyIntelDeviceDisconnect").checked?4:0;a+=Q("p20notifyIntelAmtKvmActions").checked?8:0;meshserver.send({action:"changemeshnotify",meshid:currentMesh._id,notify:a})}var filetreelinkpath;var filetreelocation=[];function updateFiles(){QV("MainMenuMyFiles",((features&8)==0));if((features&8)!=0){return}var q="",r="",c='<a href=# style=cursor:pointer onclick="return p5folderup(0)">Root</a>',o="Root",y,k=filetree,m=1;var j=[],v=filetreelinkpath,b=[],a=document.getElementsByName("fc");for(var s=0;s<a.length;s++){if(a[s].checked){b.push(a[s].value)}}filetreelinkpath="";for(var s in filetreelocation){if((k.f!=null)&&(k.f[filetreelocation[s]]!=null)){j.push(filetreelocation[s]);o+=" / "+filetreelocation[s];if((m==1)){var B=filetreelocation[s].split("/");y=window.location+B[0]+"files/"+B[2];filetreelinkpath+=filetreelocation[s]}else{if(filetreelinkpath!=""){filetreelinkpath+="/"+filetreelocation[s];if(m>2){y+="/"+filetreelocation[s]}}}k=k.f[filetreelocation[s]];c+=' / <a href=# style=cursor:pointer onclick="return p5folderup('+m+')">'+(k.n!=null?k.n:filetreelocation[s])+"</a>";m++}else{break}}filetreelocation=j;var w=o.toLowerCase().startsWith("root / "+userinfo._id+" / public");var l=p5sort_files(k.f);for(var s in l){var d=l[s],u=d.n,A;A=u;if(u.length>70){A='<span title="'+EscapeHtml(u)+'">'+EscapeHtml(u.substring(0,70))+"...</span>"}else{A=EscapeHtml(u)}u=EscapeHtml(u);var g="";if(d.d!=null){var e=new Date(d.d),g=printDateTime(e)+"&nbsp;"}var n="";if(d.s!=null){n=getFileSizeStr(d.s)}var p="";if(d.t<3||d.t==4){var z=(d.t==1||d.t==4)?p5getQuotabar(d):"",C="";p="<div class=filelist file=999><input file=999 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value='"+u+"'>&nbsp;<span style=float:right title=\""+C+'">'+z+"</span><span><div class=fileIcon"+d.t+' onclick=p5folderset("'+encodeURIComponent(d.nx)+'")></div><a href=# style=cursor:pointer onclick=\'return p5folderset("'+encodeURIComponent(d.nx)+"\")'>"+A+"</a></span></div>"}else{var t=A;var x="";if(w){x=' (<a href=# style=cursor:pointer title="Display public link" onclick=\'return p5showPublicLink("'+y+"/"+d.nx+"\")'>Link</a>)"}if(d.s>0){t='<a rel="noreferrer noopener" target="_blank" href="downloadfile.ashx?link='+encodeURIComponent(filetreelinkpath+"/"+d.nx)+'">'+A+"</a>"+x}p="<div class=filelist file=3><input file=3 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value='"+d.nx+"'>&nbsp;<span class=fsize>"+g+"</span><span style=float:right>"+n+"</span><span><div class=fileIcon"+d.t+"></div>"+t+"</span></div>"}if(d.t<3){q+=p}else{r+=p}}QH("p5rightOfButtons",p5getQuotabar(k));QH("p5files",q+r);QH("p5currentpath",c);QE("p5FolderUp",filetreelocation.length!=0);QV("p5PublicShare",w);if(v==filetreelinkpath){a=document.getElementsByName("fc");for(var s=0;s<a.length;s++){a[s].checked=(b.indexOf(a[s].value)>=0)}}p5setActions()}function getNiceSize(a){if(a<=0){return"Storage limit exceed"}if(a<2048){return a+" bytes remaining"}if(a<2097152){return Math.round(a/1024)+" kilobytes remaining"}if(a<2147483648){return Math.round(a/1024/1024)+" megabytes remaining"}return Math.round(a/1024/1024/1024)+" gigabytes remaining"}function getNiceSize2(a){if(a<=0){return"None"}if(a<2048){return a+" b"}if(a<2097152){return Math.round(a/1024)+" Kb"}if(a<2147483648){return Math.round(a/1024/1024)+" Mb"}return Math.round(a/1024/1024/1024)+" Gb"}function p5getQuotabar(a){while(a.t>1&&a.t!=4){a=a.parent}if((a.t!=1&&a.t!=4)||(a.maxbytes==null)){return""}var b=Math.floor(a.s/1024),c=(a.maxbytes-a.s);return'<span title="'+b+"k in "+a.c+" file"+(a.c>1?"s":"")+". "+(Math.floor(a.maxbytes/1024/1024))+'k maxinum">'+getNiceSize(c)+" <progress style=height:10px;width:100px value="+a.s+" max="+a.maxbytes+" /></span>"}function p5showPublicLink(a){setDialogMode(2,"Public Link",1,null,'<input type=text style=width:100% value="'+a+'" readonly />')}var sortorder;function p5sort_filename(c,d){if(c.ln>d.ln){return(1*sortorder)}if(c.ln<d.ln){return(-1*sortorder)}return 0}function p5sort_timestamp(c,d){if(c.d>d.d){return(1*sortorder)}if(c.d<d.d){return(-1*sortorder)}return 0}function p5sort_bysize(c,d){if(c.s==d.s){return p5sort_filename(c,d)}return(((c.s-d.s))*sortorder)}function p5sort_files(a){var c=[],d=Q("p5sortdropdown").value;for(var b in a){a[b].nx=b;if(a[b].n==null){a[b].n=b}a[b].ln=a[b].n.toLowerCase();c.push(a[b])}sortorder=1;if(d>3){sortorder=-1;d-=3}if(d==1){c.sort(p5sort_filename)}else{if(d==2){c.sort(p5sort_bysize)}else{if(d==3){c.sort(p5sort_timestamp)}}}return c}function p5setActions(){var a=getFileSelCount(),c=getFileCount(),b=getFileSelCount(false);QE("p5DeleteFileButton",(a>0)&&(filetreelocation.length>0));QE("p5NewFolderButton",filetreelocation.length>0);QE("p5UploadButton",filetreelocation.length>0);QE("p5RenameFileButton",(a==1)&&(filetreelocation.length>0));QE("p5SelectAllButton",c>0);Q("p5SelectAllButton").value=(a>0?"Select None":"Select All");QE("p5CutButton",(b>0)&&(a==b));QE("p5CopyButton",(b>0)&&(a==b));QE("p5PasteButton",(p5clipboard!=null)&&(p5clipboard.length>0)&&(filetreelocation.length>0))}function getFileSelCount(d){var a=0,b=document.getElementsByName("fc");for(var c=0;c<b.length;c++){if((b[c].checked)&&((d!=false)||(b[c].attributes.file.value=="3"))){a++}}return a}function getFileSelDirCount(){var a=0,b=document.getElementsByName("fc");for(var c=0;c<b.length;c++){if((b[c].checked)&&(b[c].attributes.file.value=="999")){a++}}return a}function getFileCount(){var a=0;var b=document.getElementsByName("fc");return b.length}function p5selectallfile(){var c=(getFileSelCount()==0),a=document.getElementsByName("fc");for(var b=0;b<a.length;b++){a[b].checked=c}p5setActions()}function setupBackPointers(d){if(d.f!=null){var b=0,a=0;for(var c in d.f){setupBackPointers(d.f[c]);d.f[c].parent=d;if(d.f[c].s){b+=d.f[c].s}if(d.f[c].c){a+=d.f[c].c}if(d.f[c].t==3){a++}}d.s=b;d.c=a}return d}function getFileSizeStr(a){if(a==1){return"1 byte"}return""+a+" bytes"}function p5folderup(a){if(a==null){filetreelocation.pop()}else{while(filetreelocation.length>a){filetreelocation.pop()}}updateFiles();return false}function p5folderset(a){filetreelocation.push(decodeURIComponent(a));updateFiles()}function p5createfolder(){setDialogMode(2,"New Folder",3,p5createfolderEx,"<input type=text id=p5renameinput maxlength=64 onkeyup=p5fileNameCheck(event) style=width:100% />");focusTextBox("p5renameinput");p5fileNameCheck()}function p5createfolderEx(){meshserver.send({action:"fileoperation",fileop:"createfolder",path:filetreelocation,newfolder:Q("p5renameinput").value})}function p5deletefile(){var a=getFileSelCount(),b=(getFileSelDirCount()>0)?"<br /><br /><label><input type=checkbox id=p5recdeleteinput>Recursive delete</label><br>":"<input type=checkbox id=p5recdeleteinput style='display:none'>";setDialogMode(2,"Delete",3,p5deletefileEx,(a>1)?("Delete "+a+" selected items?"+b):("Delete selected item?"+b))}function p5deletefileEx(){var b=[],a=document.getElementsByName("fc");for(var c=0;c<a.length;c++){if(a[c].checked){b.push(a[c].value)}}meshserver.send({action:"fileoperation",fileop:"delete",path:filetreelocation,delfiles:b,rec:Q("p5recdeleteinput").checked})}function p5renamefile(){var c,a=document.getElementsByName("fc");for(var b=0;b<a.length;b++){if(a[b].checked){c=a[b].value}}setDialogMode(2,"Rename",3,p5renamefileEx,'<input type=text id=p5renameinput maxlength=64 onkeyup=p5fileNameCheck(event) style=width:100% value="'+c+'" />',{action:"fileoperation",fileop:"rename",path:filetreelocation,oldname:c});focusTextBox("p5renameinput");p5fileNameCheck()}function p5renamefileEx(a,c){c.newname=Q("p5renameinput").value;meshserver.send(c)}function p5fileNameCheck(a){var b=isFilenameValid(Q("p5renameinput").value);QE("idx_dlgOkButton",b);if((b==true)&&(a&&a.keyCode==13)){dialogclose(1)}}var isFilenameValid=(function(){var b=/^[^\\/:\*\?"<>\|]+$/,c=/^\./,d=/^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i;return function a(e){return b.test(e)&&!c.test(e)&&!d.test(e)&&(e[0]!=".")}})();function p5uploadFile(){setDialogMode(2,"Upload File",3,p5uploadFileEx,'<form method=post enctype=multipart/form-data action=uploadfile.ashx target=fileUploadFrame><input type=text name=link style=display:none id=p5uploadpath value="'+encodeURIComponent(filetreelinkpath)+'" /><input type=file name=files id=p5uploadinput style=width:100% multiple=multiple onchange="updateUploadDialogOk(\'p5uploadinput\')" /><input type=submit id=p5loginSubmit style=display:none /></form>');updateUploadDialogOk("p5uploadinput")}function p5uploadFileEx(){Q("p5loginSubmit").click()}function updateUploadDialogOk(a){QE("idx_dlgOkButton",Q(a).value!="")}var p5clipboard=null,p5clipboardFolder=null,p5clipboardCut=0;function p5copyFile(b){var a=document.getElementsByName("fc");p5clipboard=[];p5clipboardCut=b,p5clipboardFolder=Clone(filetreelocation);for(var c=0;c<a.length;c++){if((a[c].checked)&&(a[c].attributes.file.value=="3")){p5clipboard.push(a[c].value)}}p5updateClipview()}function p5pasteFile(){var a="";if((p5clipboard!=null)&&(p5clipboard.length>0)){a="Confim "+(p5clipboardCut==0?"copy":"move")+" of "+p5clipboard.length+" entrie"+((p5clipboard.length>1)?"s":"")+" to this location?"}setDialogMode(2,"Paste",3,p5pasteFileEx,a)}function p5pasteFileEx(){meshserver.send({action:"fileoperation",fileop:(p5clipboardCut==0?"copy":"move"),scpath:p5clipboardFolder,path:filetreelocation,names:p5clipboard});p5folderup(999);if(p5clipboardCut==1){p5clipboard=null,p5clipboardFolder=null,p5clipboardCut=0;p5updateClipview()}}function p5updateClipview(){var a="";if((p5clipboard!=null)&&(p5clipboard.length>0)){a="Holding "+p5clipboard.length+" entrie"+((p5clipboard.length>1)?"s":"")+" for "+(p5clipboardCut==0?"copy":"move")+', <a href=# onclick="return p5clearClip()" style=cursor:pointer>Clear</a>.'}QH("p5bottomstatus",a);p5setActions()}function p5clearClip(){p5clipboard=null;p5clipboardFolder=null;p5clipboardCut=0;p5updateClipview();return false}function p5fileDragDrop(b){if(xxdialogMode){return}haltEvent(b);QV("bigfail",false);QV("bigok",false);var c=0;p5uploadFile();try{Q("p5uploadinput").files=b.dataTransfer.files}catch(d){c=1}if(c==0){p5uploadFileEx()}setDialogMode(0);if(c==1){if(b.dataTransfer==null||b.dataTransfer.files.length==0||filetreelocation.length==0){return}var j=[],m=[],o=[],a=[],l=b.dataTransfer.files.length,n=0;for(var h=0;h<b.dataTransfer.files.length;h++){n+=b.dataTransfer.files[h].size}if(n>1300000){p5uploadFile();return}for(var h=0;h<b.dataTransfer.files.length;h++){var k=new FileReader(),g=b.dataTransfer.files[h];j.push(g.name);m.push(g.size);o.push(g.type);k.onload=function(e){a.push(e.target.result);if(--l==0){Q("p5fileDragName").value=j.join("*");Q("p5fileDragSize").value=m.join("*");Q("p5fileDragType").value=o.join("*");Q("p5fileDragData").value=a.join("*");Q("p5fileDragLink").value=encodeURIComponent(filetreelinkpath);Q("p5loginSubmit2").click()}};k.readAsDataURL(g)}}}var p5dragtimer=null;function p5fileDragOver(b){if(xxdialogMode){return}haltEvent(b);if(p5dragtimer!=null){clearTimeout(p5dragtimer);p5dragtimer=null}var a=true;if(filetreelocation.length==0){a=false}QV("bigok",a);QV("bigfail",!a)}function p5fileDragLeave(a){if(xxdialogMode){return}haltEvent(a);if(a.target.id!="p5filetable"){QV("bigfail",false);QV("bigok",false)}else{p5dragtimer=setTimeout(function(){QV("bigfail",false);QV("bigok",false);p5dragtimer=null},10)}}function eventMouseHover(a,b){a.children[1].classList.remove("g1s");a.children[2].style["background-color"]=((b==0)?"#c9c9c9":"#b9b9b9");a.children[3].classList.remove("g2s");if(b==1){a.children[1].classList.add("g1s");a.children[3].classList.add("g2s")}}function eventsUpdate(){var h="",a=null;for(var c in events){var b=events[c],g=new Date(b.time);if(b.msg){if(printDate(g)!=a){if(a!=null){h+="</table>"}a=printDate(g);h+="<table class=p3eventsTable cellpadding=0 cellspacing=0><tr><td colspan=4 class=DevSt>"+a+"</td></tr>"}var d="si3";if(b.etype=="user"){d="m2"}if(b.etype=="server"){d="si3"}var e=b.msg.split("(R)").join("&reg;");if(b.username&&b.username!=userinfo.name){e+=": "+b.username}h+="<tr onmouseover=eventMouseHover(this,1) onmouseout=eventMouseHover(this,0) style=cursor:pointer><td style=width:18px><div class="+d+"></div></td><td class=g1>&nbsp;</td><td class=style10>"+printTime(g)+" - "+e+"</td><td class=g2>&nbsp;</td></tr><tr style=height:2px></tr>"}}if(a!=null){h+="</table>"}if(h==""){h="<br><i>No Events Found</i><br><br>"}QH("p3events",h)}function showDeleteAllEventsDialog(){if(xxdialogMode){return}var a="Delete all events in the server event log?<br /><br />";a+="<label><input id=p3check type=checkbox onchange=validateDeleteAllEventsDialog() />Confirm</label>";setDialogMode(2,"Delete All Events",3,showDeleteAllEventsDialogEx,a);validateDeleteAllEventsDialog()}function validateDeleteAllEventsDialog(){QE("idx_dlgOkButton",Q("p3check").checked)}function showDeleteAllEventsDialogEx(a,b){meshserver.send({action:"clearevents"})}function refreshEvents(){meshserver.send({action:"events",limit:parseInt(p3limitdropdown.value)})}function p3showDownloadEventsDialog(){if(xxdialogMode){return}var a="Download the list of events with one of the file formats below.<br /><br />";a+=addHtmlValue("CSV Format",'<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogCSV()">eventslist.csv</a>');a+=addHtmlValue("JSON Format",'<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogJSON()">eventslist.json</a>');setDialogMode(2,"Event List Export",1,null,a)}function p3downloadEventsDialogCSV(){var a="time, type, action, user, message\r\n";for(var b in events){a+='"'+events[b].time+'","'+events[b].etype+'","'+((events[b].action!=null)?events[b].action:"")+'","'+((events[b].username!=null)?events[b].username:"")+'","'+((events[b].msg!=null)?events[b].msg:"")+'"\r\n'}saveAs(new Blob([a],{type:"application/octet-stream"}),"eventslist.csv");return false}function p3downloadEventsDialogJSON(){var b=[];for(var a in events){b.push(events[a])}saveAs(new Blob([JSON.stringify(b)],{type:"application/octet-stream"}),"eventslist.json");return false}function updateUsers(){QV("MainMenuMyUsers",(users!=null)&&((features&4)==0));QV("LeftMenuMyUsers",(users!=null)&&((features&4)==0));QV("UserNewAccountButton",((features&4)==0)&&(serverinfo.domainauth==false));if((users==null)||((features&4)!=0)){QH("p3users","");return}var h=[],e=100,c=0;for(var d in users){h.push(d)}h.sort();var k=Q("UserSearchInput").value.toLowerCase();var b=k;if(k.startsWith("email:")){k=null;b=b.substring(6)}else{if(k.startsWith("name:")){b=null;k=k.substring(5)}else{if(k.startsWith("e:")){k=null;b=b.substring(2)}else{if(k.startsWith("n:")){b=null;k=k.substring(2)}}}}var l="<table class=p3usersTable cellpadding=0 cellspacing=0>",a=true;l+="<th>Name<th style=width:80px>Groups<th style=width:120px>Last&nbsp;Access<th style=width:120px>Permissions";for(var d in h){var j=users[h[d]],g=null;if(wssessions!=null){g=wssessions[j._id]}if((g!=null)&&((k!=null)&&((k=="")||(j.name.toLowerCase().indexOf(k)>=0))||((b!=null)&&((j.email!=null)&&(j.email.toLowerCase().indexOf(b)>=0))))){if(e>0){if(a){l+="<tr><td class=userTableHeader colspan=4>Online Users";a=false}l+=addUserHtml(j,g);e--}else{c++}}}a=true;for(var d in h){var j=users[h[d]],g=null;if(wssessions!=null){g=wssessions[j._id]}if((g==null)&&((k!=null)&&((k=="")||(j.name.toLowerCase().indexOf(k)>=0))||((b!=null)&&((j.email!=null)&&(j.email.toLowerCase().indexOf(b)>=0))))){if(e>0){if(a){l+="<tr><td class=userTableHeader colspan=4>Offline Users";a=false}l+=addUserHtml(j,g);e--}else{c++}}}l+="</table>";if(c==1){l+="<br />1 more user not shown, use search box to look for users...<br />"}else{if(c>1){l+="<br />"+c+" more users not shown, use search box to look for users...<br />"}}if(e==100){l+="<br />No users found.<br />"}QH("p3users",l);if((currentUser!=null)&&(xxcurrentView==30)){gotoUser(encodeURIComponent(currentUser._id),true)}}function addUserHtml(n,l){var p="",b=" gray",e="m2",h="",k=(n.name!=userinfo.name),g="",j="";if(l!=null){b="";if(k){h='<span style=float:right;margin-top:1px;margin-right:4px title=Chat><a href=# onclick=userChat(event,"'+encodeURIComponent(n._id)+'","'+encodeURIComponent(n.name)+"\")><img src='images/icon-chat.png' height=16 width=16 style=padding-top:2px /></a></span>";h+="<span style=float:right;margin-top:1px;margin-left:4px;margin-right:4px title=Notify><a href=# onclick='return showUserAlertDialog(event,\""+encodeURIComponent(n._id)+"\")'><img src='images/icon-notify.png' height=16 width=16 style=padding-top:2px /></a></span>"}if(l==1){g+="1&nbsp;session"}else{g+=l+"&nbsp;sessions"}}else{if(n.login){g+='<span title="Last login: '+printDateTime(new Date(n.login*1000))+'">'+printDate(new Date(n.login*1000))+"</span>"}}if(k){j+="<a href=# style=cursor:pointer onclick='return showUserAdminDialog(event,\""+encodeURIComponent(n._id)+"\")'>"}if((n.siteadmin!=null)&&((n.siteadmin&32)!=0)&&(n.siteadmin!=4294967295)){j+="Locked,&nbsp;"}j+="<span title='Server Permissions'>";var m=n.siteadmin&(4294967295-224);if((n.siteadmin==null)||(m==0)){j+="User"}else{if(m==8){j+="User + Files"}else{if(n.siteadmin==4294967295){j+="Administrator"}else{if((m&2)!=0){j+="Manager"}else{j+="Partial"}}}}if((n.siteadmin!=null)&&(n.siteadmin!=4294967295)&&((n.siteadmin&(64+128))!=0)){j+="*"}j+="</span>";if(k){j+="</a>"}var c=0;if(n.links){for(var d in n.links){c++}}var o=EscapeHtml(n.name),a="";if(serverinfo.emailcheck==true){a=((n.emailVerified!=true)?' <b style=color:red title="Email is not verified">&#x2717;</b>':' <b style=color:green title="Email is verified">&#x2713</b>')}if(n.email!=null){if(((features&2097152)==0)||(n.email.toLowerCase()!=n.name.toLowerCase())){o+=", <a href=# onclick='return doemail(event,\""+n.email+"\")'>"+n.email+"</a>"+a}else{o+=" <a href=# onclick='return doemail(event,\""+n.email+'")\'><img src="images/mail12.png" height=9 width=12 title="Send email to user" style="margin-top:2px" /></a>'+a}}if((n.otpsecret>0)||(n.otphkeys>0)){o+=' <img src="images/key12.png" height=12 width=11 title="2nd factor authentication enabled" style="margin-top:2px" />'}if((n.siteadmin!=null)&&((n.siteadmin&32)!=0)&&(n.siteadmin!=4294967295)){o+=' <img src="images/padlock12.png" height=12 width=8 title="Account is locked" style="margin-top:2px" />'}p+="<tr tabindex=0 onmouseover=userMouseHover(this,1) onmouseout=userMouseHover(this,0) onkeypress=\"if (event.key=='Enter') gotoUser('"+encodeURIComponent(n._id)+'\')"><td style=cursor:pointer onclick=gotoUser("'+encodeURIComponent(n._id)+'")>';p+="<div class=bar>";p+='<div class=baricon><div class="'+e+b+'"></div></div>';p+="<div class=g1></div><div class=g2></div>";p+="<div><span>"+o+"</span>"+h+"</div></div><td style=text-align:center>"+c+"<td style=text-align:center>"+g+"<td style=text-align:center>"+j;return p}function userMouseHover(b,c){var a=b.children[0].children[0];a.children[1].classList.remove("g1s");a.children[2].classList.remove("g2s");if(c==1){a.children[1].classList.add("g1s");a.children[2].classList.add("g2s")}b.children[0].children[0].style["background-color"]=((c==0)?"#c9c9c9":"#b9b9b9")}function userChat(a,d,b){haltEvent(a);var c="/messenger?id=meshmessenger/"+d+"/"+encodeURIComponent(userinfo._id)+"&title="+b;if((authCookie!=null)&&(authCookie!="")){c+="&auth="+authCookie}window.open(c,"meshmessenger:"+d);meshserver.send({action:"meshmessenger",userid:decodeURIComponent(d)});return false}function showUserAlertDialog(a,b){if(xxdialogMode){return}haltEvent(a);setDialogMode(2,"Notify "+EscapeHtml(users[decodeURIComponent(b)].name),3,showUserAlertDialogEx,'Send a text notification to this user.<textarea id=d2notifyText maxlength=2048 style="width:100%;height:184px;resize:none"></textarea>',b);Q("d2notifyText").focus();return false}function showUserAlertDialogEx(a,b){meshserver.send({action:"notifyuser",userid:decodeURIComponent(b),msg:Q("d2notifyText").value})}function doemail(b,a){if(xxdialogMode){return false}haltEvent(b);window.open("mailto:"+a);return false}function p4batchAccountCreate(){if(xxdialogMode){return}var a='Create many accounts at once by importing a JSON file with the following format:<br /><pre>[\r\n {"user":"x1","pass":"x","email":"x1@x"},\r\n {"user":"x2","pass":"x","resetNextLogin":true}\r\n]</pre><input style=width:370px type=file id=d4importFile accept=".json" onchange=p4batchAccountCreateValidate() />';setDialogMode(2,"User Account Import",3,p4batchAccountCreateEx,a);QE("idx_dlgOkButton",false)}function p4batchAccountCreateValidate(){QE("idx_dlgOkButton",Q("d4importFile").value!=null)}function p4batchAccountCreateEx(){var a=new FileReader();a.onload=function(g){var d=null;try{d=JSON.parse(g.target.result)}catch(b){setDialogMode(2,"User Account Import",1,null,"Invalid JSON file: "+b+".");return}if((d!=null)&&(Array.isArray(d))){var e=true;for(var c in d){if((typeof d[c].user!="string")||(d[c].user.length<1)||(d[c].user.length>64)){e=false}if((typeof d[c].pass!="string")||(d[c].pass.length<1)||(d[c].pass.length>256)){e=false}if(checkPasswordRequirements(d[c].pass,passRequirements)==false){e=false}if((d[c].email!=null)&&((typeof d[c].email!="string")||(d[c].email.length<1)||(d[c].email.length>128))){e=false}}if(e==false){setDialogMode(2,"User Account Import",1,null,"Invalid JSON file format.")}else{meshserver.send({action:"adduserbatch",users:d})}}else{setDialogMode(2,"User Account Import",1,null,"Invalid JSON file format.")}};a.readAsText(Q("d4importFile").files[0])}function p4downloadUserInfo(){if(xxdialogMode){return}var a="Download the list of users with one of the file formats below.<br /><br />";a+=addHtmlValue("CSV Format","<a href=# style=cursor:pointer onclick='return p4downloadUserInfoCSV()'>userlist.csv</a>");a+=addHtmlValue("JSON Format","<a href=# style=cursor:pointer onclick='return p4downloadUserInfoJSON()'>userlist.json</a>");setDialogMode(2,"User List Export",1,null,a)}function p4downloadUserInfoCSV(){var a="id, name, email, creation, lastlogin, groups, authfactors\r\n";for(var c in users){var d=false,b=[];if((users[c].otpsecret>0)||(users[c].otphkeys>0)){d=true;if(users[c].otpsecret>0){b.push("AuthApp")}if(users[c].otphkeys>0){b.push("SecurityKey")}if(users[c].otpkeys>0){b.push("BackupCodes")}}a+='"'+users[c]._id+'","'+users[c].name+'","'+(users[c].email?users[c].email:"")+'","'+(users[c].creation?new Date(users[c].creation*1000):"")+'","'+(users[c].login?new Date(users[c].login*1000):"")+'","'+(users[c].groups?users[c].groups.join(","):"")+'","'+(d?b.join(","):"")+'"\r\n'}saveAs(new Blob([a],{type:"application/octet-stream"}),"userlist.csv");return false}function p4downloadUserInfoJSON(){var b=[];for(var a in users){b.push(users[a])}saveAs(new Blob([JSON.stringify(b)],{type:"application/octet-stream"}),"userlist.json");return false}function showUserBroadcastDialog(){if(xxdialogMode){return}var a='Broadcast a message to all connected users.<textarea id=broadcastMessage value="" maxlength="256"/></textarea>';setDialogMode(2,"Broadcast Message",3,showUserBroadcastDialogEx,a);Q("broadcastMessage").focus()}function showUserBroadcastDialogEx(){meshserver.send({action:"userbroadcast",msg:Q("broadcastMessage").value})}function showCreateNewAccountDialog(){if(xxdialogMode){return}var d="";if((features&2097152)==0){d+=addHtmlValue("Name","<input id=p4name maxlength=64 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />")}d+=addHtmlValue("Email","<input id=p4email maxlength=256 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />");d+=addHtmlValue("Password","<input id=p4pass1 type=password maxlength=256 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />");d+=addHtmlValue("Password","<input id=p4pass2 type=password maxlength=256 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />");d+="<div><label><input id=p4randomPassword onchange=showCreateNewAccountDialogValidate() type=checkbox />Randomize the password.</label></div>";d+="<div><label><input id=p4resetNextLogin onchange=showCreateNewAccountDialogValidate() type=checkbox />Force password reset on next login.</label></div>";if(serverinfo.emailcheck){d+="<div><label><input id=p4verifiedEmail onchange=showCreateNewAccountDialogValidate() type=checkbox />Email is verified.</label></div>";d+="<div><label><input id=p4invitationEmail type=checkbox />Send invitation email.</label></div>"}if(passRequirements){var b=[],c=0;for(var a in passRequirements){if((a!="reset")&&(a!="hint")){b.push(a+":"+passRequirements[a]);c++}}if(c>0){d+="<div style=font-size:x-small;padding:6px>Requirements: "+b.join(", ")+".</div>"}}setDialogMode(2,"Create Account",3,showCreateNewAccountDialogEx,d);showCreateNewAccountDialogValidate();if((features&2097152)==0){Q("p4name").focus()}else{Q("p4email").focus()}}function showCreateNewAccountDialogValidate(c){var b=validateEmail(Q("p4email").value);if(serverinfo.emailcheck){QE("p4verifiedEmail",b);QE("p4invitationEmail",b&&Q("p4resetNextLogin").checked&&Q("p4verifiedEmail").checked);if(b==false){Q("p4verifiedEmail").checked=false}if((Q("p4resetNextLogin").checked==false)||(Q("p4verifiedEmail").checked==false)){Q("p4invitationEmail").checked=false}}QE("p4pass1",!Q("p4randomPassword").checked);QE("p4pass2",!Q("p4randomPassword").checked);if((c==null)&&(Q("p4email").value.length>0)&&(b==false)){QE("idx_dlgOkButton",false);return}var a=true;if((features&2097152)==0){a&=(!Q("p4name")||((Q("p4name").value.length>0)&&(Q("p4name").value.indexOf(" ")==-1)))}if(Q("p4randomPassword").checked==false){a&=(Q("p4pass1").value.length>0&&Q("p4pass1").value==Q("p4pass2").value&&checkPasswordRequirements(Q("p4pass1").value,passRequirements))}if(a&&passRequirements){if(checkPasswordRequirements(Q("p4pass1").value,passRequirements)==false){a=false}}QE("idx_dlgOkButton",a)}function showCreateNewAccountDialogEx(){var a=((features&2097152)==0)?Q("p4name").value:Q("p4email").value;var b={action:"adduser",username:a,email:Q("p4email").value,pass:Q("p4pass1").value,resetNextLogin:Q("p4resetNextLogin").checked,randomPassword:Q("p4randomPassword").checked};if(serverinfo.emailcheck){b.emailVerified=Q("p4verifiedEmail").checked;b.emailInvitation=Q("p4invitationEmail").checked}meshserver.send(b)}function showUserGroupDialog(a,d){if(xxdialogMode){return}haltEvent(a);d=decodeURIComponent(d);var c=users[d.toLowerCase()],b="";if(c.groups!=null){b=c.groups.join(", ")}var g="Enter a comma seperate list of groups.<br /><br />";g+=addHtmlValue("Groups",'<input id=dp4usergroups style=width:230px value="'+b+'" placeholder="Group1, Group2, Group3" maxlength=256 onchange=p4validateUserGroups() onkeyup=p4validateUserGroups() />');setDialogMode(2,"User Groups",3,showUserGroupDialogEx,g,c);focusTextBox("dp4usergroups");p4validateUserGroups();return false}function p4validateUserGroups(){var b=Q("dp4usergroups").value;var e=0,c=b.indexOf('"')+b.indexOf("/")+b.indexOf(">")+b.indexOf("<")+b.indexOf("'");var a=b.split(",");for(var d in a){if(a[d].trim().length==0){e++}}QE("idx_dlgOkButton",(b=="")||((c==-5)&&(e<1)))}function showUserGroupDialogEx(a,h){var d=Q("dp4usergroups").value,b=d.split(","),c=[];for(var e in b){var k=b[e].trim();if(k.length>0){c.push(k)}}meshserver.send({action:"edituser",id:h._id,groups:c})}function showUserAdminDialog(a,c){if(xxdialogMode){return}haltEvent(a);c=decodeURIComponent(c);var d="<div><div id=d2AdminPermissions>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_fileaccess>Server Files</label>, <input type=number onchange=showUserAdminDialogValidate() maxlength=10 id=ua_fileaccessquota>k max, blank for default<br><hr/>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_fulladmin>Full Administrator</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverbackup>Server Backup</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverrestore>Server Restore</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverupdate>Server Updates</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_manageusers>Manage Users</label><br>";d+="<hr/></div><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_lockedaccount>Lock Account</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nonewgroups>No New Device Groups</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nomeshcmd>No Tools (MeshCmd/Router)</label><br>";d+="</div>";var b=users[c.toLowerCase()];setDialogMode(2,"Server Permissions",3,showUserAdminDialogEx,d,b);if(b.siteadmin&&b.siteadmin!=0){Q("ua_fulladmin").checked=(b.siteadmin==4294967295);Q("ua_serverbackup").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&1)!=0));Q("ua_manageusers").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&2)!=0));Q("ua_serverrestore").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&4)!=0));Q("ua_fileaccess").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&8)!=0));Q("ua_serverupdate").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&16)!=0));Q("ua_lockedaccount").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&32)!=0));Q("ua_nonewgroups").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&64)!=0));Q("ua_nomeshcmd").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&128)!=0))}QE("ua_fulladmin",userinfo.siteadmin==4294967295);QE("ua_serverbackup",userinfo.siteadmin==4294967295);QE("ua_manageusers",userinfo.siteadmin==4294967295);QE("ua_serverrestore",userinfo.siteadmin==4294967295);QE("ua_fileaccess",userinfo.siteadmin==4294967295);QE("ua_fileaccessquota",userinfo.siteadmin==4294967295);QE("ua_serverupdate",userinfo.siteadmin==4294967295);QV("d2AdminPermissions",userinfo.siteadmin==4294967295);QE("ua_lockedaccount",(userinfo.siteadmin&2)&&(b.siteadmin!=4294967295)&&(userinfo._id!=b._id));QE("ua_nonewgroups",(userinfo.siteadmin&2)&&(b.siteadmin!=4294967295)&&(userinfo._id!=b._id));QE("ua_nomeshcmd",(userinfo.siteadmin&2)&&(b.siteadmin!=4294967295)&&(userinfo._id!=b._id));Q("ua_fileaccessquota").value=(b.quota!=null)?(b.quota/1024):"";showUserAdminDialogValidate();return false}function showUserAdminDialogValidate(){if(userinfo.siteadmin==4294967295){QE("ua_serverbackup",!Q("ua_fulladmin").checked);QE("ua_manageusers",!Q("ua_fulladmin").checked);QE("ua_serverrestore",!Q("ua_fulladmin").checked);QE("ua_fileaccess",!Q("ua_fulladmin").checked);QE("ua_serverupdate",!Q("ua_fulladmin").checked);QE("ua_lockedaccount",!Q("ua_fulladmin").checked);QE("ua_nonewgroups",!Q("ua_fulladmin").checked);QE("ua_nomeshcmd",!Q("ua_fulladmin").checked);QE("ua_fileaccessquota",Q("ua_fileaccess").checked&&!Q("ua_fulladmin").checked)}}function showUserAdminDialogEx(a,d){var c=0,b=parseInt(Q("ua_fileaccessquota").value);if(Q("ua_fulladmin").checked==true){c=4294967295}else{if(Q("ua_serverbackup").checked==true){c+=1}if(Q("ua_manageusers").checked==true){c+=2}if(Q("ua_serverrestore").checked==true){c+=4}if(Q("ua_fileaccess").checked==true){c+=8}if(Q("ua_serverupdate").checked==true){c+=16}if(Q("ua_lockedaccount").checked==true){c+=32}if(Q("ua_nonewgroups").checked==true){c+=64}if(Q("ua_nomeshcmd").checked==true){c+=128}}var e={action:"edituser",id:d._id,siteadmin:c};if(isNaN(b)==false){e.quota=(b*1024)}meshserver.send(e)}function onUserSearchInputChanged(){updateUsers()}var currentUser=null;function gotoUser(r,g){if(xxdialogMode&&!g){return}var p=currentUser=users[decodeURIComponent(r)];if(p==null){setDialogMode(0);go(4);return}QH("p30userName",p.name);QH("p31userName",p.name);var o=(p.name==userinfo.name),a=0;if(wssessions!=null&&wssessions[p._id]){a=wssessions[p._id]}Q("MainUserImage").classList.remove("gray");if(a==0){Q("MainUserImage").classList.add("gray")}var l=[],n="";if((p.siteadmin!=null)&&((p.siteadmin&32)!=0)&&(p.siteadmin!=4294967295)){n='<img src="images/padlock12.png" height=12 width=8 title="Account is locked" style="margin-top:2px" /> ';l.push("Locked account")}if((p.siteadmin==null)||((p.siteadmin&(4294967295-224))==0)){l.push("No server rights")}else{if(p.siteadmin==8){l.push("Access to server files")}else{if(p.siteadmin==4294967295){l.push("Full administrator")}else{l.push("Partial rights")}}}if((p.siteadmin!=null)&&(p.siteadmin!=4294967295)&&((p.siteadmin&(64+128))!=0)){l.push("Restrictions")}var s="<div style=min-height:80px><table style=width:100%>";var c=p.email?EscapeHtml(p.email):"<i>Not set</i>",d="";if(serverinfo.emailcheck){d=((p.emailVerified==true)?'<b style=color:green;cursor:pointer title="Email is verified">&#x2713</b> ':'<b style=color:red;cursor:pointer title="Email not verified">&#x2717;</b> ')}if(p.name.toLowerCase()!=p._id.split("/")[2]){s+=addDeviceAttribute("User Identifier",p._id.split("/")[2])}if(((features&2097152)==0)&&((p.siteadmin!=4294967295)||(userinfo.siteadmin==4294967295))){s+=addDeviceAttribute("Email",d+'<a href=# style=cursor:pointer onclick=p30showUserEmailChangeDialog(event,"'+r+'")>'+c+"</a> <a href=# style=cursor:pointer onclick='return doemail(event,\""+p.email+'")\'><img class=hoverButton src="images/link1.png" /></a>')}else{s+=addDeviceAttribute("Email",d+c+" <a href=# style=cursor:pointer onclick='return doemail(event,\""+p.email+'")\'><img class=hoverButton src="images/link1.png" /></a>')}s+=addDeviceAttribute("Server Rights",n+"<a href=# style=cursor:pointer onclick='return showUserAdminDialog(event,\""+r+"\")'>"+l.join(", ")+"</a>");if(p.quota){s+=addDeviceAttribute("Server Quota",EscapeHtml(parseInt(p.quota)/1024)+" k")}s+=addDeviceAttribute("Creation",printDateTime(new Date(p.creation*1000)));if(p.login){s+=addDeviceAttribute("Last Login",printDateTime(new Date(p.login*1000)))}if(p.passchange==-1){s+=addDeviceAttribute("Password","Will be changed on next login.")}else{if(p.passchange){s+=addDeviceAttribute("Password","Last changed: "+printDateTime(new Date(p.passchange*1000)))}}var j=0,k="<i>None<i>";if(p.links){for(var h in p.links){j++}if(j==1){k="1 group"}else{if(j>1){k=j+" groups"}}}s+=addDeviceAttribute("Device Groups",k);var q="<i>None</i>";if(p.groups){q="";for(var h in p.groups){q+='<span class="tagSpan">'+p.groups[h]+"</span>"}}s+=addDeviceAttribute("User Groups",addLinkConditional(q,'showUserGroupDialog(event,"'+r+'")',(userinfo.siteadmin==4294967295)||((userinfo.groups==null)&&(userinfo.siteadmin&2)&&(userinfo._id!=p._id)&&(p._id!=4294967295))));var m=0;if((p.otpsecret>0)||(p.otphkeys>0)){m=1;var e=[];if(p.otpsecret>0){e.push("Authentication App")}if(p.otphkeys>0){e.push("Security Key")}if(p.otpkeys>0){e.push("Backup Codes")}s+=addDeviceAttribute("Security",'<img src="images/key12.png" height=12 width=11 title="2nd factor authentication enabled" style="margin-top:2px" /> '+e.join(", "))}s+="</table></div><br />";s+='<input type=button value=Notes title="View notes about this user" onclick=showNotes(false,"'+r+'") />';if(!o&&(a>0)){s+='<input type=button value=Notify title="Send user notification" onclick=showUserAlertDialog(event,"'+r+'") />'}QH("p30html",s);drawUserTimeline();var b=true;if(p._id==userinfo._id){b=false}if(p.siteadmin&&p.siteadmin>0&&userinfo.siteadmin!=4294967295){b=false}s="<div style=float:right;font-size:x-small>";if(b){s+="<a href=# style=cursor:pointer onclick='return p30showDeleteUserDialog()' title=\"Remove this user\">Delete User</a>"}s+="</div><div style=font-size:x-small>";if(userinfo.siteadmin==4294967295){s+="<a href=# style=cursor:pointer onclick='return p30showUserChangePassDialog("+m+')\' title="Change the password for this user">Change Password</a>'}s+="</div><br>";QH("p30html3",s);s="";if(a==1){s="1 active session"}else{if(a>1){s=a+" active sessions"}}QH("MainUserState",s);go(30);QH("p31events","");refreshUsersEvents()}function p30showUserEmailChangeDialog(a){if(xxdialogMode){return false}var b="";b+=addHtmlValue("Email","<input id=dp30email style=width:230px maxlength=32 onchange=p30validateEmail() onkeyup=p30validateEmail() />");if(serverinfo.emailcheck){b+=addHtmlValue("Status","<select id=dp30verified style=width:230px onchange=p30validateEmail()><option value=0>Not verified</option><option value=1>Verified</option></select>")}setDialogMode(2,"Change Email for "+EscapeHtml(currentUser.name),3,p30showUserEmailChangeDialogEx,b);Q("dp30email").focus();Q("dp30email").value=(currentUser.email?currentUser.email:"");if(serverinfo.emailcheck){Q("dp30verified").value=currentUser.emailVerified?1:0}p30validateEmail();return false}function p30validateEmail(){var a=Q("dp30email").value,b=a.split("@");b=(b.length==2)&&(b[0].length>0)&&(b[1].split(".").length>1)&&(b[1].length>2)&&(a.length<1024)&&((a!=userinfo.email)||((serverinfo.emailcheck==true)&&(Q("dp30verified").value!=(userinfo.emailVerified?1:0))));QE("idx_dlgOkButton",b)}function p30showUserEmailChangeDialogEx(){var a={action:"edituser",id:currentUser._id,email:Q("dp30email").value};if(serverinfo.emailcheck){a.emailVerified=(Q("dp30verified").value==1)}meshserver.send(a)}function p30showUserChangePassDialog(b){if(xxdialogMode){return}var e="";e+=addHtmlValue("Password","<input id=p4pass1 type=password style=width:230px maxlength=256 onchange=showCreateNewAccountDialogValidate(1) onkeyup=p30showUserChangePassDialogValidate(1)></input>");e+=addHtmlValue("Password","<input id=p4pass2 type=password style=width:230px maxlength=256 onchange=showCreateNewAccountDialogValidate(1) onkeyup=p30showUserChangePassDialogValidate(1)></input>");if(features&65536){e+=addHtmlValue("Password hint","<input id=p4hint type=text style=width:230px maxlength=256></input>")}if(passRequirements){var c=[],d=0;for(var a in passRequirements){if((a!="reset")&&(a!="hint")){c.push(a+":"+passRequirements[a]);d++}}if(d>0){e+="<div style=font-size:x-small;padding:6px>Requirements: "+c.join(", ")+".</div>"}}e+="<div><label><input id=p4resetNextLogin type=checkbox />Force password reset on next login.</label></div>";if(b==1){e+="<div><label><input id=p4twoFactorRemove type=checkbox />Remove all 2nd factor authentication.</label></div>"}setDialogMode(2,"Change Password for "+EscapeHtml(currentUser.name),3,p30showUserChangePassDialogEx,e,b);p30showUserChangePassDialogValidate();Q("p4pass1").focus();if(currentUser.passchange==-1){Q("p4resetNextLogin").checked=true}}function p30showUserChangePassDialogValidate(){var a=true;if((Q("p4pass1").value!="")||(Q("p4pass2").value!="")){if(Q("p4pass1").value!=Q("p4pass2").value){a=false}else{if(passRequirements){if(checkPasswordRequirements(Q("p4pass1").value,passRequirements)==false){a=false}}}}QE("idx_dlgOkButton",a)}function p30showUserChangePassDialogEx(a,e){var d=false;if((e==1)&&(Q("p4twoFactorRemove").checked==true)){d=true}if(Q("p4pass1").value==Q("p4pass2").value){var c={action:"changeuserpass",userid:currentUser._id,pass:Q("p4pass1").value,removeMultiFactor:d,resetNextLogin:Q("p4resetNextLogin").checked};if(features&65536){c.hint=Q("p4hint").value}meshserver.send(c)}}function p30showDeleteUserDialog(){if(xxdialogMode){return}setDialogMode(2,"Delete User "+EscapeHtml(currentUser.name),3,p30showDeleteUserDialogEx,"Confirm deletion of user "+EscapeHtml(currentUser.name)+"?")}function p30showDeleteUserDialogEx(){meshserver.send({action:"deleteuser",userid:currentUser._id,username:currentUser.name})}function drawUserTimeline(){var s=null,o=Date.now();s=[];var e=new Date();e.setHours(0,0,0,0);e=new Date(e.getTime()-(1000*60*60*24*6));var u=e.getTime();var t=[];if(s!=null&&s.length>1){t.push([0,s[1],s[0]]);var c=s[1];for(var m=2;m<s.length;m+=2){var p=s[m],k=o;if(s.length>(m+1)){k=s[m+1]}t.push([c,c+k,p]);c=c+k}}var z="",b=1,h=new Date();h.setHours(0,0,0,0);for(var m=0;m<7;m++){var g="",q=h.getTime(),l=q+(1000*60*60*24);for(var n in t){var a=t[n];if(isTimeBlockInside(q,l,a[0],a[1])==true){var w=Math.max(q,a[0]);var r=Math.min(Math.min(l,a[1]),o);var y=Math.round((r-w)/112794);if(y>0){var v=powerStateStrings2[a[2]]+" from "+printTime(new Date(w))+" to "+printTime(new Date(r))+".";g+='<div title="'+v+'" style=display:table-cell;width:'+y+"px;background-color:"+powerColor(a[2])+";height:16px></div>"}}}z+="<tr style="+(((b%2)==0)?"background-color:#DDD":"")+"><td><div>&nbsp;"+printDate(h)+"<div></div></div></td><td><div>"+g+"</div></td></tr>";++b;h=new Date(h.getTime()-(1000*60*60*24))}QH("p30html2",'<table style="color:black;background-color:#EEE;border-color:#AAA;border-width:1px;border-style:solid;border-collapse:collapse" border=0 cellpadding=2 cellspacing=0 width=100%><tbody><tr style=background-color:#AAAAAA;font-weight:bold><th scope=col style=text-align:center;width:150px>Day</th><th scope=col style=text-align:center>7 Day Login State</th></tr>'+z+"</tbody></table>")}var currentUserEvents=null;function userEventsUpdate(){var h="",a=null;for(var c in currentUserEvents){var b=currentUserEvents[c];var g=new Date(b.time);if(printDate(g)!=a){if(a!=null){h+="</table>"}a=printDate(g);h+="<table style=width:100% cellpadding=0 cellspacing=0><tr><td class=DevSt>"+a+"</td></tr>"}var d="si3";if(b.etype=="user"){d="m2"}if(b.etype=="server"){d="si3"}var e=b.msg.split("(R)").join("&reg;");if(b.username&&b.username!=userinfo.name){e+=": "+b.username}h+="<tr><td><div class=bar18 style=height:18px;width:100%;font-size:medium>";h+="<div style=float:left;height:18px;width:18px;background-color:white><div class="+d+" style=width:16px;margin-top:1px;margin-left:2px;height:16px></div></div>";h+="<div class=g1 style=height:18px;float:left></div><div class=g2 style=height:18px;float:right></div>";h+="<div style=font-size:14px><span style=width:300px>"+printTime(g)+" - "+e+"</span></div></div></td></tr>"}if(a!=null){h+="</table>"}if(h==""){h="<br><i>No Events Found</i><br><br>"}QH("p31events",h)}function refreshUsersEvents(){meshserver.send({action:"events",limit:parseInt(p31limitdropdown.value),user:currentUser.name})}function d3init(){Q("d3localFile").value="";d3modechange()}function d3modechange(){var a=Q("d3uploadMode").value;QV("d3localmode",a==1);QV("d3servermode",a==2);if(a==1){d3setActions()}else{d3updatefiles()}}var d3filetreelinkpath;var d3filetreelocation=[];function d3updatefiles(){if(Q("d3uploadMode").value==1){return}var m="",n="",e=filetree,j=1;var c=[],r=d3filetreelinkpath,b=[],a=document.getElementsByName("fc");for(var o=0;o<a.length;o++){if(a[o].checked){b.push(a[o].value)}}d3filetreelinkpath="";for(var o in d3filetreelocation){if((e.f!=null)&&(e.f[d3filetreelocation[o]]!=null)){c.push(d3filetreelocation[o]);if((j==1)){var t=d3filetreelocation[o].split("/");publicPath=window.location+t[0]+"files/"+t[2];if(d3filetreelocation[o]===userinfo._id){d3filetreelinkpath+="self"}else{d3filetreelinkpath+=(t[0]+"/"+t[2])}}else{if(d3filetreelinkpath!=""){d3filetreelinkpath+="/"+d3filetreelocation[o];if(j>2){publicPath+="/"+d3filetreelocation[o]}}}e=e.f[d3filetreelocation[o]];j++}else{break}}d3filetreelocation=c;var g=p5sort_files(e.f);for(var o in g){var d=g[o],q=d.n,s;s=q;if(q.length>70){s='<span title="'+EscapeHtml(q)+'">'+EscapeHtml(q.substring(0,70))+"...</span>"}else{s=EscapeHtml(q)}q=EscapeHtml(q);var k="";if(d.s!=null){k=getFileSizeStr(d.s)}var l="";if(d.t<3){var u="";l='<div class=filelist file=999><span style=float:right title="'+u+'"></span><span><div class=fileIcon'+d.t+' onclick=d3folderset("'+encodeURIComponent(d.nx)+'")></div>&nbsp;<a href=# style=cursor:pointer onclick=\'return d3folderset("'+encodeURIComponent(d.nx)+"\")'>"+s+"</a></span></div>"}else{var p=s;l="<div class=filelist file=3><input style=float:left name=fcx class=fcb type=checkbox onchange=d3setActions() value='"+d.nx+"'>&nbsp;<span style=float:right>"+k+"</span><span><div class=fileIcon"+d.t+"></div>"+p+"</span></div>"}if(d.t<3){m+=l}else{n+=l}}QH("d3serverfiles",m+n);QE("p3FolderUp",d3filetreelocation.length>0);d3setActions()}function d3folderset(a){d3filetreelocation.push(decodeURIComponent(a));d3updatefiles();return false}function d3folderup(a){if(a==null){d3filetreelocation.pop()}else{while(d3filetreelocation.length>a){d3filetreelocation.pop()}}d3updatefiles()}function d3getFileSel(){var a=[];var b=document.getElementsByName("fcx");for(var c=0;c<b.length;c++){if(b[c].checked){a.push(b[c].value)}}return a}function d3setActions(){var a=Q("d3uploadMode").value;if(a==1){QE("idx_dlgOkButton",Q("d3localFile").value.length>0)}else{QE("idx_dlgOkButton",d3getFileSel().length==1)}}var notifications=[];function clickNotificationIcon(a){if(a==true){QV("notifiyBox",true)}else{if(a==false){QV("notifiyBox",false)}else{QV("notifiyBox",QS("notifiyBox")["display"]=="none")}}drawNotifications()}function setNotificationCount(a){if(parseInt(Q("notificationCount").innerHTML)==a){return}QH("notificationCount",a);QS("notificationCount")["background-color"]=(a==0)?"lightblue":"orange";QV("notificationCount",a>0)}function drawNotifications(){var j="";if(notifications.length==0){j="<div style=margin:5px>There are currently no notifications</div>"}else{for(var c in notifications){var g=notifications[c];var k="";if(g.title!=null){k="<b>"+g.title+"</b>: "}var a=new Date(g.time);var e=0;if(g.nodeid!=null){var h=getNodeFromId(g.nodeid);if(h!=null){e=h.icon;k="<b>"+h.name+"</b>: "}}j+='<div title="Occured at '+printDateTime(a)+'" id="notifyx'+g.id+'" class=notification style="cursor:pointer;border-top:1px solid '+((j=="")?"transparent":"orange")+'">';if(e){j+="<div class=j"+e+' onclick="notificationSelected('+g.id+')" style=margin:5px;float:left></div>'}j+='<div onclick="notificationDelete('+g.id+')" class=unselectable title="Clear this notification" style=margin:5px;float:right;color:orange><b>X</b></div><div onclick="notificationSelected('+g.id+')" style=margin:5px>'+k+g.text+"</div></div>"}}var b="";if(notifications.length>1){b='<div id="notifyRemoveAll" onclick="deleteAllNotifications()" style="cursor:pointer;border-top:1px solid orange;margin:5px;color:orange;text-align:right;padding-right:3px">Clear all</div>'}QH("notifiyBox",'<div class=customScroll style="max-height:170px;overflow-y:auto;margin:5px">'+j+"</div>"+b)}function notificationSelected(c,a){var d=-1;for(var b in notifications){if(notifications[b].id==c){d=b}}if(d!=-1){notificationSelectedEx(notifications[d],c);if(a&&notifications[d]){if(notifications[d].notification){notifications[d].notification.close();delete notifications[d].notification}notificationDelete(c)}}}function notificationSelectedEx(b,a){if(b.nodeid!=null){if(b.tag=="desktop"){gotoDevice(b.nodeid,12)}else{if(b.tag=="terminal"){gotoDevice(b.nodeid,11)}else{if(b.tag=="files"){gotoDevice(b.nodeid,13)}else{if(b.tag=="intelamt"){gotoDevice(b.nodeid,14)}else{if(b.tag=="console"){gotoDevice(b.nodeid,15)}else{gotoDevice(b.nodeid,10)}}}}}}else{if((b.tag!=null)&&b.tag.startsWith("meshmessenger/")){window.open("/messenger?id="+b.tag+"&title="+encodeURIComponent(b.username),b.tag.split("/")[2]);notificationDelete(a)}}}function notificationDelete(c){var d=-1,a=Q("notifyx"+c);if(a!=null){for(var b in notifications){if(notifications[b].id==c){d=b}}if(d!=-1){if(notifications[d].notification){notifications[d].notification.close();delete notifications[d].notification}notifications.splice(d,1);a.parentNode.removeChild(a);setNotificationCount(notifications.length);if(notifications.length==0){QV("notifiyBox",false)}if(notifications.length==1){QV("notifyRemoveAll",false)}if((notifications.length>0)&&(d==0)){var g=notifications[0];QS("notifyx"+g.id)["border-top"]="1px solid transparent"}}}}function addNotification(a){if(a.time==null){a.time=Date.now()}if(a.id==null){a.id=Math.random()}notifications.unshift(a);setNotificationCount(notifications.length);clickNotificationIcon(true);var d=getstore("notifications",0);if(d&1){Q("chimes").play()}var c=null;if(Notification&&(Notification.permission=="granted")){var e=a.text.split("&reg;").join("").split("<b>").join("").split("</b>").join("").split("<br />").join("\r\n");if(a.nodeid){var b=getNodeFromId(a.nodeid);if(b){c=new Notification("{{{title}}} - "+b.name,{tag:a.tag,body:e,icon:"/images/notify/icons128-"+b.icon+".png"})}}else{if(a.icon==null){a.icon=0}var g=a.title;if(g==null){g=""}else{g=" - "+a.title}c=new Notification("{{{title}}}"+g,{tag:a.tag,body:e,icon:"/images/notify/icons128-"+a.icon+".png"})}c.id=a.id;c.xtag=a.tag;c.nodeid=a.nodeid;c.username=a.username;c.onclick=function(h){notificationSelected(h.target.id,true)};a.notification=c}}function deleteAllNotifications(){notifications=[];setNotificationCount(0);drawNotifications();QV("notifiyBox",false)}function setupGeneralServerStats(){window.serverStatCpu=new Chart(document.getElementById("serverCpuChart").getContext("2d"),{type:"doughnut",data:{datasets:[{data:[0,0],backgroundColor:["#AAAAAA","#00AA00"]}],labels:["Used","Free"]},options:{responsive:true,legend:{position:"none",},animation:{animateScale:true,animateRotate:true},width:"60px"}});window.serverStatMemory=new Chart(document.getElementById("serverMemoryChart").getContext("2d"),{type:"doughnut",data:{datasets:[{data:[0,0],backgroundColor:["#AAAAAA","#00AA00"]}],labels:["Used","Free"]},options:{responsive:true,legend:{position:"none",},animation:{animateScale:true,animateRotate:true},width:"60px"}})}var lastServerStats=null;function updateGeneralServerStats(d){if(d!=null){lastServerStats=d}else{d=lastServerStats}if(d==null){return}if(typeof d.cpuavg=="object"){var c=Math.min(d.cpuavg[0],1);window.serverStatCpu.config.data.datasets[0].data=[c,1-c];QH("serverCpuChartText",'<div style=margin-bottom:5px>CPU Load</div><div><b title="CPU load in the last minute">'+(Math.round(d.cpuavg[0]*100)/100)+'</b>, <b title="CPU load in the last 5 minutes">'+(Math.round(d.cpuavg[1]*100)/100)+'</b>, <b title="CPU load in the 15 minutes">'+(Math.round(d.cpuavg[2]*100)/100)+"</b></div>");QS("serverCpuChartView")["display"]="inline-block";window.serverStatCpu.update()}if((typeof d.totalmem=="number")&&(typeof d.freemem=="number")){window.serverStatMemory.config.data.datasets[0].data=[d.totalmem-d.freemem,d.freemem];QH("serverMemoryChartText","<div style=margin-bottom:5px>Memory</div><div><b>"+getNiceSize2(d.freemem)+"</b> free, <b>"+getNiceSize2(d.totalmem)+"</b> total</div>");QS("serverMemoryChartView")["display"]="inline-block";window.serverStatMemory.update()}var e="<div style=width:100% cellpadding=0 cellspacing=0>";if(typeof d.values=="object"){for(var a in d.values){e+="<div class=userTableHeader style=margin-bottom:4px;width:200px>"+a+"</div>";for(var b in d.values[a]){e+="<div style=display:inline-block><table class=serverStateTableCell><tr><td class=h1></td><td><span>"+b+"</span><span style=float:right>"+d.values[a][b]+"</span></td><td class=h2></td></tr></table></div>"}}}e+="</div>";QH("serverStatsTable",e)}var serverTimelineStats=null;var serverTimelineConfig={type:"line",data:{labels:[],datasets:[{label:"",backgroundColor:"rgba(255, 99, 132, .5)",borderColor:"rgb(255, 99, 132)",data:[],fill:true}]},options:{responsive:true,maintainAspectRatio:false,elements:{line:{tension:0.001}},scales:{xAxes:[{type:"time",time:{tooltipFormat:"ll HH:mm"},display:true,scaleLabel:{display:false,labelString:""}}],yAxes:[{type:"linear",display:true,scaleLabel:{display:true,labelString:""}}]}}};function refreshServerTimelineStats(a){meshserver.send({action:"servertimelinestats",hours:24*30})}function pastDate(a){var b=new Date();b.setTime(b.getTime()-(60*60*1000*a));return b}function setServerTimelineStats(a){serverTimelineStats=a;updateServerTimelineStats()}function addServerTimelineStats(b){if(serverTimelineStats==null){return}serverTimelineStats.push(b);var a=Q("p40type").value;if(a==0){serverTimelineConfig.data.datasets[0].data.push({x:b.time,y:b.conn.ca});serverTimelineConfig.data.datasets[1].data.push({x:b.time,y:b.conn.cu});serverTimelineConfig.data.datasets[2].data.push({x:b.time,y:b.conn.us});serverTimelineConfig.data.datasets[3].data.push({x:b.time,y:b.conn.rs});if(b.conn.am!=null){serverTimelineConfig.data.datasets[4].data.push({x:b.time,y:b.conn.am})}}else{if(a==1){serverTimelineConfig.data.datasets[0].data.push({x:b.time,y:b.mem.external/(1024*1024)});serverTimelineConfig.data.datasets[1].data.push({x:b.time,y:b.mem.heapUsed/(1024*1024)});serverTimelineConfig.data.datasets[2].data.push({x:b.time,y:b.mem.heapTotal/(1024*1024)});serverTimelineConfig.data.datasets[3].data.push({x:b.time,y:b.mem.rss/(1024*1024)})}}updateServerTimelineHours()}function updateServerTimelineHours(){serverTimelineConfig.options.scales.yAxes[0].type=(Q("p40log").checked?"logarithmic":"linear");serverTimelineConfig.options.scales.xAxes[0].time={min:pastDate(Q("p40time").value)};window.serverMainStats.update()}function setupServerTimelineStats(){window.serverMainStats=new Chart(document.getElementById("serverMainStats").getContext("2d"),serverTimelineConfig)}function updateServerTimelineStats(){var b,a=Q("p40type").value,e=pastDate(Q("p40time").value);serverTimelineConfig.options.scales.xAxes[0].time={min:e};if(a==0){serverTimelineConfig.options.scales.yAxes[0].scaleLabel.labelString="Connection Count";b={labels:[pastDate(0),e],datasets:[{label:"Agents",data:[],backgroundColor:"rgba(158, 151, 16, .1)",borderColor:"rgb(158, 151, 16)",fill:true},{label:"Users",data:[],backgroundColor:"rgba(16, 84, 158, .1)",borderColor:"rgb(16, 84, 158)",fill:true},{label:"User Sessions",data:[],backgroundColor:"rgba(255, 99, 132, .1)",borderColor:"rgb(255, 99, 132)",fill:true},{label:"Relay Sessions",data:[],backgroundColor:"rgba(39, 158, 16, .1)",borderColor:"rgb(39, 158, 16)",fill:true},{label:"Intel AMT",data:[],backgroundColor:"rgba(134, 16, 158, .1)",borderColor:"rgb(134, 16, 158)",fill:true}]};for(var c=0;c<serverTimelineStats.length;c++){var d=new Date(serverTimelineStats[c].time);if(serverTimelineStats[c].conn){b.datasets[0].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.ca});b.datasets[1].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.cu});b.datasets[2].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.us});b.datasets[3].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.rs});if(serverTimelineStats[c].conn.am!=null){b.datasets[4].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.am})}}}}else{if(a==1){serverTimelineConfig.options.scales.yAxes[0].scaleLabel.labelString="Megabytes";b={labels:[pastDate(0),e],datasets:[{label:"External",data:[],backgroundColor:"rgba(158, 151, 16, .1)",borderColor:"rgb(158, 151, 16)",fill:true},{label:"Heap Used",data:[],backgroundColor:"rgba(16, 84, 158, .1)",borderColor:"rgb(16, 84, 158)",fill:true},{label:"Heap Total",data:[],backgroundColor:"rgba(255, 99, 132, .1)",borderColor:"rgb(255, 99, 132)",fill:true},{label:"RSS",data:[],backgroundColor:"rgba(39, 158, 16, .1)",borderColor:"rgb(39, 158, 16)",fill:true}]};for(var c=0;c<serverTimelineStats.length;c++){b.datasets[0].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].mem.external/(1024*1024)});b.datasets[1].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].mem.heapUsed/(1024*1024)});b.datasets[2].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].mem.heapTotal/(1024*1024)});b.datasets[3].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].mem.rss/(1024*1024)})}}}serverTimelineConfig.data=b;window.serverMainStats.update()}function p40downloadEvents(){var a="time, conn.agent, conn.users, conn.usersessions, conn.relaysession, conn.intelamt, mem.external, mem.heapused, mem.heaptotal, mem.rss\r\n";for(var b=0;b<serverTimelineStats.length;b++){if(serverTimelineStats[b].conn&&serverTimelineStats[b].mem){a+=new Date(serverTimelineStats[b].time)+", "+serverTimelineStats[b].conn.ca+", "+serverTimelineStats[b].conn.cu+", "+serverTimelineStats[b].conn.us+", "+serverTimelineStats[b].conn.rs+", "+(serverTimelineStats[b].conn.am?serverTimelineStats[b].conn.am:"")+", "+serverTimelineStats[b].mem.external+", "+serverTimelineStats[b].mem.heapUsed+", "+serverTimelineStats[b].mem.heapTotal+", "+serverTimelineStats[b].mem.rss+"\r\n"}}saveAs(new Blob([a],{type:"application/octet-stream"}),"ServerStats.csv")}var xxdialogMode;var xxdialogFunc;var xxdialogButtons;var xxdialogTag;var xxcurrentView=-1;function setDialogMode(j,k,a,e,d,h){setSessionActivity();QV("uiMenu",false);xxdialogMode=j;xxdialogFunc=e;xxdialogButtons=a;xxdialogTag=h;QE("idx_dlgOkButton",true);QV("idx_dlgOkButton",a&1);QV("idx_dlgCancelButton",a&2);QV("id_dialogclose",(a&2)||(a&8));QV("idx_dlgDeleteButton",a&4);QV("idx_dlgButtonBar",a&7);if(k){QH("id_dialogtitle",k)}for(var g=1;g<24;g++){QV("dialog"+g,g==j)}QV("dialog",j);if(d){if(j==2){QH("id_dialogOptions",d)}else{QH("id_dialogMessage",d)}}}function dialogclose(e){setSessionActivity();var c=xxdialogFunc,a=xxdialogButtons,d=xxdialogTag;setDialogMode();if(((a&8)||e)&&c){c(e,d)}}function center(){setSessionActivity();if(xxcurrentView==11){deskAdjust()}else{if(xxcurrentView==10){masterUpdate(256)}else{if(xxcurrentView==1){masterUpdate(4)}}}}function messagebox(b,a){setSessionActivity();QH("id_dialogMessage",a);setDialogMode(1,b,1)}function statusbox(b,a){setSessionActivity();QH("id_dialogMessage",a);setDialogMode(1,b)}function goBack(){setSessionActivity();if(xxdialogMode){return}if(fullscreen){deskToggleFull()}if((xxcurrentView>=10)&&(xxcurrentView<20)){go(1)}if((xxcurrentView>=20)&&(xxcurrentView<30)){go(2)}if((xxcurrentView>=30)&&(xxcurrentView<40)){go(4)}}function go(h){setSessionActivity();if(xxdialogMode||xxcurrentView==h){return}QV("uiMenu",false);for(var a=0;a<41;a++){QV("p"+a,a==h)}xxcurrentView=h;var d=["MainMenuMyDevices","MainMenuMyAccount","MainMenuMyEvents","MainMenuMyFiles","MainMenuMyUsers","MainMenuMyServer"];for(var a in d){QC(d[a]).remove("fullselect");QC(d[a]).remove("semiselect")}var b=["LeftMenuMyDevices","LeftMenuMyAccount","LeftMenuMyEvents","LeftMenuMyFiles","LeftMenuMyUsers","LeftMenuMyServer"];for(var a in b){QC(b[a]).remove("lbbuttonsel");QC(b[a]).remove("lbbuttonsel2")}var e=(h<9?"fullselect":"semiselect");var c=(h<9?"lbbuttonsel2":"lbbuttonsel");if(h==1||(h>=10&&h<20)){QC("MainMenuMyDevices").add(e)}if(h==1||(h>=10&&h<20)){QC("LeftMenuMyDevices").add(c)}if(h==2||(h>=20&&h<30)){QC("MainMenuMyAccount").add(e)}if(h==2||(h>=20&&h<30)){QC("LeftMenuMyAccount").add(c)}if(h==3){QC("MainMenuMyEvents").add(e)}if(h==3){QC("LeftMenuMyEvents").add(c)}if(h==4||(h>=30&&h<40)){QC("MainMenuMyUsers").add(e)}if(h==4||(h>=30&&h<40)){QC("LeftMenuMyUsers").add(c)}if(h==5){QC("MainMenuMyFiles").add(e)}if(h==5){QC("LeftMenuMyFiles").add(c)}if((h==6)||(h==115)){QC("MainMenuMyServer").add(e)}if((h==6)||(h==115)||(h==40)){QC("LeftMenuMyServer").add(c)}if(webPageStackMenu&&(h>=10)){QC("column_l").add("room4submenu")}else{QC("column_l").remove("room4submenu")}QV("topbar",h!=0);if((h==0)&&(webPageFullScreen)){QC("body").add("arg_hide")}QV("MainSubMenuSpan",h>=10&&h<20);QV("UserDummyMenuSpan",(h<10)&&(h!=6)&&webPageFullScreen);QV("MeshSubMenuSpan",h>=20&&h<30);QV("UserSubMenuSpan",h>=30&&h<40);QV("ServerSubMenuSpan",h==6||h==115||h==40);var g={10:"MainDev",11:"MainDevDesktop",12:"MainDevTerminal",13:"MainDevFiles",14:"MainDevAmt",15:"MainDevConsole",16:"MainDevEvents",20:"MeshGeneral",30:"UserGeneral",31:"UserEvents",6:"ServerGeneral",40:"ServerStats",115:"ServerConsole"};for(var a in g){QC(g[a]).remove("style3x");QC(g[a]).remove("style3sel");QC(g[a]).add((h==a)?"style3sel":"style3x")}if(h==11){deskAdjust()}if(h==115){QV("p15",true)}QV("p15uploadCore",h!=115);QV("p15BackButton",h!=115);if((h==15)||(h==115)){setupConsole()}if(h==1){masterUpdate(4)}if((h==2)&&Notification){QV("accountEnableNotificationsSpan",Notification.permission!="granted")}if((h==40)&&(serverTimelineStats==null)){refreshServerTimelineStats()}if((currentNode)&&(h>=10)&&(h<20)){document.title=decodeURIComponent("{{{extitle}}}")+" - "+currentNode.name}else{document.title=decodeURIComponent("{{{extitle}}}")}}function joinPaths(){var c=[];for(var a in arguments){var b=arguments[a];if((b!=null)&&(b!="")){while(b.endsWith("/")||b.endsWith("\\")){b=b.substring(0,b.length-1)}while(b.startsWith("/")||b.startsWith("\\")){b=b.substring(1)}c.push(b)}}return c.join("/")}function putstore(g,j){try{if((typeof(localStorage)==="undefined")||(localStorage.getItem(g)==j)){return}localStorage.setItem(g,j)}catch(a){}if(g[0]!="_"){var h={};for(var b=0,d=localStorage.length;b<d;++b){var c=localStorage.key(b);if(c[0]!="_"){h[c]=localStorage.getItem(c)}}meshserver.send({action:"userWebState",state:JSON.stringify(h)})}}function getstore(b,d){try{if(typeof(localStorage)==="undefined"){return d}var c=localStorage.getItem(b);if((c==null)||(c==null)){return d}return c}catch(a){return d}}function addLink(b,a){return"<span tabindex=0 style=cursor:pointer;text-decoration:none onclick='"+a+"' onkeypress=\"if (event.key=='Enter') {"+a+'} ">'+b+" <img class=hoverButton src=images/link5.png></span>"}function addLinkConditional(d,b,a){if(a){return addLink(d,b)}return d}function haltEvent(a){if(a.preventDefault){a.preventDefault()}if(a.stopPropagation){a.stopPropagation()}return false}function addOption(c,d,a){var b=document.createElement("option");b.text=d;b.value=a;Q(c).add(b)}function passwordcheck(a){return(a.length>7)&&(/\d/.test(a))&&(/[a-z]/.test(a))&&(/[A-Z]/.test(a))&&(/\W/.test(a))}function methodcheck(a){if(a&&a!=null&&a.Body&&a.Body.ReturnValueStr!="SUCCESS"){messagebox("Call Error",a.Header.Method+": "+a.Body.ReturnValueStr.replace("_"," "));return true}return false}function TableStart(){return"<table cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px><tr><td width=200px><p><td>"}function TableStart2(){return"<table cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px><tr><td><p><td>"}function TableEntry(a,b){return"<tr><td><p>"+a+"<td>"+b}function FullTable(c,a){var b=TableStart();for(i in c){if(i&&c[i]){b+=TableEntry(i,c[i])}}return b+TableEnd(a)}function TableEnd(a){return"<tr><td colspan=2><p>"+(a?a:"")+"</table>"}function AddButton(b,a){return"<input type=button value='"+b+"' onclick='"+a+"' style=margin:4px>"}function AddButton2(b,a){return"<input type=button value='"+b+"' onclick='"+a+"'>"}function AddRefreshButton(a){return"<input type=button name=refreshbtn value=Refresh onclick='refreshButtons(false);"+a+"' style=margin:4px "+(refreshButtonsState==false?"disabled":"")+">"}function MoreStart(){return'<a href=# style=cursor:pointer;color:blue id=morexxx1 onclick=QV("morexxx1",false);QV("morexxx2",true)>&#x25BC; More</a><div id=morexxx2 style=display:none><br><hr>'}function MoreEnd(){return'<a href=# style=cursor:pointer;color:blue onclick=QV("morexxx2",false);QV("morexxx1",true)>&#x25B2; Less</a></div>'}function getSelectedOptions(e){var d=[],c;for(var a=0,b=e.options.length;a<b;a++){c=e.options[a];if(c.selected){d.push(c.value)}}return d}function getInstance(b,c){for(var a in b){if(b[a]["InstanceID"]==c){return b[a]}}return null}function getItem(b,c,d){for(var a in b){if(b[a][c]==d){return b[a]}}return null}function guidToStr(a){return a.substring(6,8)+a.substring(4,6)+a.substring(2,4)+a.substring(0,2)+"-"+a.substring(10,12)+a.substring(8,10)+"-"+a.substring(14,16)+a.substring(12,14)+"-"+a.substring(16,20)+"-"+a.substring(20)}function getUrlVars(){var d,a,e=[],b=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(var c=0;c<b.length;c++){d=b[c].indexOf("=");if(d>0){e[b[c].substring(0,d)]=b[c].substring(d+1,b[c].length)}}return e}function addHtmlValue(a,b){return"<table><td style=width:120px>"+a+"<td><b>"+b+"</b></table>"}function addHtmlValue2(a,b){return"<div><div style=display:inline-block;float:right>"+b+"</div><div style=display:inline-block>"+a+"</div></div>"}function parseUriArgs(){var a,c={},b=window.document.location.href.split(/[\?&|\=]/);b.splice(0,1);for(d in b){switch(d%2){case 0:a=decodeURIComponent(b[d]);break;case 1:c[a]=decodeURIComponent(b[d]);var d=parseInt(c[a]);if(d==c[a]){c[a]=d}break;default:break}}return c}function focusTextBox(a){setTimeout(function(){Q(a).selectionStart=Q(a).selectionEnd=65535;Q(a).focus()},0)}function validateEmail(b){var a=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return a.test(b)}function isPrivateIP(b){return(b.startsWith("10.")||b.startsWith("172.16.")||b.startsWith("192.168."))}function u2fSupported(){return(window.u2f&&((navigator.userAgent.indexOf("Chrome/")>0)||(navigator.userAgent.indexOf("Firefox/")>0)||(navigator.userAgent.indexOf("Opera/")>0)||(navigator.userAgent.indexOf("Safari/")>0)))}function findOne(a,b){if((a==null)||(b==null)){return false}return b.some(function(c){return a.indexOf(c)>=0})}function copyTextToClip(c){function b(d){if(document.selection){var g=document.body.createTextRange();g.moveToElementText(d);g.select()}else{if(window.getSelection){var g=document.createRange();g.selectNode(d);window.getSelection().removeAllRanges();window.getSelection().addRange(g)}}}var a=document.createElement("DIV");a.textContent=c;document.body.appendChild(a);b(a);document.execCommand("copy");a.remove()}function printDate(a){return a.toLocaleDateString(args.locale)}function printTime(a){return a.toLocaleTimeString(args.locale)}function printDateTime(a){return a.toLocaleString(args.locale)};</script></body></html>
\ No newline at end of file
1 +<!DOCTYPE html> <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="format-detection" content="telephone=no"> <link rel="shortcut icon" type="image/x-icon" href="{{{domainurl}}}favicon.ico"> <link keeplink="1" type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS"> <style>.ol-box{box-sizing:border-box;border-radius:2px;border:2px solid #00f;}.ol-mouse-position{top:8px;right:8px;position:absolute;}.ol-scale-line{background:rgba(0,60,136,.3);border-radius:4px;bottom:8px;left:8px;padding:2px;position:absolute;}.ol-scale-line-inner{border:1px solid #eee;border-top:none;color:#eee;font-size:10px;text-align:center;margin:1px;will-change:contents,width;}.ol-overlay-container{will-change:left,right,top,bottom;}.ol-unsupported{display:none;}.ol-unselectable, .ol-viewport{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto;}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing;}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab;}.ol-control{position:absolute;background-color:rgba(255,255,255,.4);border-radius:4px;padding:2px;}.ol-control:hover{background-color:rgba(255,255,255,.6);}.ol-zoom{top:.5em;right:.5em;}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear;}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s;}.ol-zoom-extent{top:4.643em;left:.5em;}.ol-full-screen{right:.5em;top:.5em;}@media print{.ol-control{display:none;}}.ol-control button{display:block;margin:1px;padding:0;color:#fff;font-size:1.14em;font-weight:700;text-decoration:none;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:rgba(0,60,136,.5);border:none;border-radius:2px;}.ol-control button::-moz-focus-inner{border:none;padding:0;}.ol-zoom-extent button{line-height:1.4em;}.ol-compass{display:block;font-weight:400;font-size:1.2em;will-change:transform;}.ol-touch .ol-control button{font-size:1.5em;}.ol-touch .ol-zoom-extent{top:5.5em;}.ol-control button:focus, .ol-control button:hover{text-decoration:none;background-color:rgba(0,60,136,.7);}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0;}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px;}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em);}.ol-attribution ul{margin:0;padding:0 .5em;font-size:.7rem;line-height:1.375em;color:#000;text-shadow:0 0 2px #fff;}.ol-attribution li{display:inline;list-style:none;line-height:inherit;}.ol-attribution li:not(:last-child):after{content:" ";}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle;}.ol-attribution button, .ol-attribution ul{display:inline-block;}.ol-attribution.ol-collapsed ul{display:none;}.ol-attribution.ol-logo-only ul{display:block;}.ol-attribution:not(.ol-collapsed){background:rgba(255,255,255,.8);}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0;height:1.1em;line-height:1em;}.ol-attribution.ol-logo-only{background:0 0;bottom:.4em;height:1.1em;line-height:1em;}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em;}.ol-attribution.ol-logo-only button, .ol-attribution.ol-uncollapsible button{display:none;}.ol-zoomslider{top:4.5em;left:.5em;height:200px;}.ol-zoomslider button{position:relative;height:10px;}.ol-touch .ol-zoomslider{top:5.5em;}.ol-overviewmap{left:.5em;bottom:.5em;}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0;}.ol-overviewmap .ol-overviewmap-map, .ol-overviewmap button{display:inline-block;}.ol-overviewmap .ol-overviewmap-map{border:1px solid #7b98bc;height:150px;margin:2px;width:150px;}.ol-overviewmap:not(.ol-collapsed) button{bottom:1px;left:2px;position:absolute;}.ol-overviewmap.ol-collapsed .ol-overviewmap-map, .ol-overviewmap.ol-uncollapsible button{display:none;}.ol-overviewmap:not(.ol-collapsed){background:rgba(255,255,255,.8);}.ol-overviewmap-box{border:2px dotted rgba(0,60,136,.7);}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move;}</style> <style> .ol-ctx-menu-container{position:absolute;padding:8px;background:#fff;color:#222;font-size:13px;border-radius:5px;box-shadow:3px 3px 5px rgba(0,0,0,.2);box-sizing:border-box}.ol-ctx-menu-container a,.ol-ctx-menu-container div,.ol-ctx-menu-container img,.ol-ctx-menu-container li,.ol-ctx-menu-container span,.ol-ctx-menu-container ul{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}.ol-ctx-menu-container a img{border:none}.ol-ctx-menu-container *,.ol-ctx-menu-container :after,.ol-ctx-menu-container :before{box-sizing:inherit}.ol-ctx-menu-container.ol-ctx-menu-hidden{opacity:0;visibility:hidden;-webkit-transition:visibility 0s linear .3s,opacity .3s;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container ul{list-style:none}.ol-ctx-menu-container li{position:relative;line-height:20px;padding:2px 5px}.ol-ctx-menu-container li:not(.ol-ctx-menu-separator):hover{cursor:pointer;background-color:#333;color:#eee}.ol-ctx-menu-container li.ol-ctx-menu-submenu .ol-ctx-menu-container{border:1px solid #eee;padding:8px;top:0;opacity:0;visibility:hidden;-webkit-transition:visibility 0s linear .3s,opacity .3s;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container li.ol-ctx-menu-submenu:hover .ol-ctx-menu-container{opacity:1;visibility:visible;-webkit-transition-delay:0s;transition-delay:0s}.ol-ctx-menu-container li.ol-ctx-menu-submenu:after{position:absolute;top:7px;right:10px;content:"";display:inline-block;width:.6em;height:.6em;border-right:.3em solid #222;border-top:.3em solid #222;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.ol-ctx-menu-container li.ol-ctx-menu-submenu:hover:after{border-color:#eee}.ol-ctx-menu-container li.ol-ctx-menu-separator{padding:0}.ol-ctx-menu-container li.ol-ctx-menu-separator hr{border:0;height:1px;background-image:-webkit-linear-gradient(right,transparent,rgba(0,0,0,.75),transparent);background-image:linear-gradient(270deg,transparent,rgba(0,0,0,.75),transparent)}.ol-ctx-menu-icon{text-indent:20px;background-size:20px auto;background-repeat:no-repeat;background-position:0}.ol-ctx-menu-zoom-in{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABaUlEQVQ4T72U7VHCQBCGn90GtAMuNGCswFiBWIFQgWMFxg6wArECsQKhArEBiB1Qwa1zgQn5IAYcxv13k71n3919L8KJQ07M47+BzgG9TRfZ/JBuWhS6BJFHRJICYrZGZIz3z5Ct2+B7gG6I6kt+wewdkQVwjtkAkR5mC8yu26A1oItR/cTsOweQBdgutD8G7jGm2PJ2n8oqUKIpIjd4HxTM8gvaT/F+AlmWnyWaIXKF95eNguFzTYFhNsdWu9kFgFlaFMANUH3D8wDLoLgSTSD2il8NCe2ZXQBxWDGwxmyUzzOMBZ7wy7Qb2K0wQfXjMOBuhlFpZtNty5sFaTQBuTusZdymeqs1SpYKcO9HkE3KbTd9WFijMHJQ5hBNEAYNq5Qd0dhyke0GiE4QzjqfW23mHT8Hl4DG4Lce3FPE7AtbBSdsbNqpoJLgYkRnNeUV+xwJDHTnUEkxHGbhBXUs5TjJjew/KPy94g+NRaIVRYmMXwAAAABJRU5ErkJggg==")}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-in{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABc0lEQVQ4T71U21ECQRDsJgGdvQDECMQIxAjECMQILCPwzAAjECIQI0AiEDPQAPaWCBhrcKHuCUcV5f7dY3v6tUscefHIePhfwBBCF8CZqRCReRs1tQxDCH1VfQLQz4EsSY4AvIjIsgm8AhhCGKrqa9zwrqoLAKckB5HtguR1E2gBMITQU9VPAD8GICIGtl3e+xHJBwBT59xtHcsCYJZlUwA3kcGHbfDep51OZywi3/acZZm9vyJ5WR5o38uACmDunNt6ZwAkUxFZDwghDFT1jeSjiJinhVUBVNVJkiTDKO8CQA+AsbNQ7s1Ps0VVn5MkSfcCtmBoDZi1Bdx4eJ7zbBolrwPy3o9J3rWSHPs3A1BbjVKlYBaIyDgvu9LDXDU2RTZmXVW1oKyLxRD+OrkOrJLy5mVM0iaftDhuhVbsvBzMglzKUNW6IV/OOWtCM8MmVvEkmbwt83LaB19fdgOtVquUZJeknaDdobTwbOcvBzPcN/AXH1DFFWP7u9oAAAAASUVORK5CYII=")}.ol-ctx-menu-zoom-out{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABU0lEQVQ4T72U7VECMRRFz3sNaAdkacC1AtcKxApcKnCsQOwAK3CtQKxAqEBsANYOqCDPyTIC+8WCw5jfybn33dxEOPGSE/P4b6BzQG89RT47ZJoWhy5B5BGRZAMxWyEyxvtnyFdt8AagS1F9KQ6YvSMyB84xGyDSw2yO2XUbtAJ0MaqfmH0XAPIA2y7tj4F7jAm2uG1yWQZKNEHkBu+Dg2njWBJNEbnC+8uaIFRuWfuG2QxbbrOrUd0A1Tc8D7AIjkur7DAAsVf8MiWMZ3ZR2m02LPIMscATfjHqBnY7TFD9OAy4zTCCPG/MUKMM5O6wkXFr9dZq7FQqqHk/hDzbFa73cFONTZFDdRyiCcKg5rrSiLaXkiI6RjjrfG6VzDs+B5eAxuDXeYpmNRGzL2wZ/wof+du4GNFpBVqqz5HA4MM5VEYYDrOs+1I6Q9u/4Q8O9wN/AGgWjBVqQjjgAAAAAElFTkSuQmCC")}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-out{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABYklEQVQ4T72U4VHCQBCF36tA91KAWIFYgViBWIFYgWMFYgdYgVCBWAFSgdiBFpAsFWSdxcDkQoBkhnF/ZjbfvX377ogjF4/Mw/8CVbUD4MynEJF5k2lqFapqz8yeAPRKkCXJEYAXEVnugm8BVXVgZq/FD+9mtgBwSrJfqF2QvN4FjYCq2jWzTwA/DhARh20qTdMRyQcA0xDCbZ3KCJhl2RTATaHgo+6HLMv8+xXJy+qB3l8FGoB5CKHsXcRV1b6ZvZF8FBH3NKotoJlNkiQZFONdlLtJ3rufbouZPSdJMjwIbKDQEzBrClx7eC4i33Uepmk6JnnXaOQifzMAtdGoRApugYiMI1uqKkrRWAfZo9MxM1+UZzFewl8mN4nYdVM83L7BkwbXLUrF3sfBLQDQBbDy08x8vOohXyEE71lVq9emuEk+3gZa3XYroCvwFyjP8yHJDsnxwaU08GxvS2uFhw78BbzWrxXgMbsHAAAAAElFTkSuQmCC")}</style> <script type="text/javascript" src="scripts/u2f-api.js"></script> <script type="text/javascript" src="scripts/charts.js"></script> <script type="text/javascript" src="scripts/filesaver.js"></script> <script type="text/javascript" src="scripts/ol.js"></script> <script type="text/javascript" src="scripts/ol3-contextmenu.js"></script> <title>{{{title}}}</title> </head> <body id="body" onload="if (typeof(startup) !== 'undefined') startup();" oncontextmenu="handleContextMenu(event)" style="display:none;min-width:495px"> <div id="contextMenu" class="contextMenu noselect" style="display:none"> <div id="cxinfo" class="cmtext" onclick="cmaction(1,event)"><b>Information</b></div> <div id="cxdesktop" class="cmtext" onclick="cmaction(3,event)">Desktop</div> <div id="cxterminal" class="cmtext" onclick="cmaction(2,event)">Terminal</div> <div id="cxfiles" class="cmtext" onclick="cmaction(4,event)">Files</div> <div id="cxevents" class="cmtext" onclick="cmaction(5,event)">Events</div> <div id="cxconsole" class="cmtext" onclick="cmaction(6,event)">Console</div> <hr id="cxmgroupsplit"> <div id="cxmdesktop" class="cmtext" onclick="cmaction(7,event)" style="display:none">Multi-Desktop</div> </div> <div id="meshContextMenu" class="contextMenu noselect" style="display:none;min-width:0px"> <div id="cxselectall" class="cmtext" onclick="cmmeshaction(1,event)">Select All</div> <div id="cxselectnone" class="cmtext" onclick="cmmeshaction(2,event)">Select None</div> </div> <div id="termShellContextMenu" class="contextMenu noselect" style="display:none;min-width:0px"> <div id="cxtermnorm" class="cmtext" onclick="cmtermaction(1,event)">Normal Connect</div> <div id="cxtermps" class="cmtext" onclick="cmtermaction(2,event)">PowerShell Connect</div> </div> <div id="container"> <div id="notifiyBox" class="notifiyBox" style="display:none"></div> <div id="masthead" class="noselect"> <div class="title">{{{title}}}</div> <div class="title2">{{{title2}}}</div> <div style="float:right"> <div id="notificationCount" onclick="clickNotificationIcon()" class="unselectable" style="display:none;" title="Click to view current notifications">0</div> </div> <p id="logoutControl">{{{logoutControl}}}<span id="idleTimeoutNotify" style="color:yellow"></span></p> </div> <div id="page_leftbar"> <div style="height:16px"></div> <div id="LeftMenuMyDevices" tabindex="0" class="lbbutton lbbuttonsel" title="My Devices" onclick="go(1)" onkeypress="if (event.key=='Enter') { go(1); }"> <div class="lb2"></div> </div> <div id="LeftMenuMyAccount" tabindex="0" class="lbbutton" title="My Account" onclick="go(2)" onkeypress="if (event.key=='Enter') { go(2); }"> <div class="lb1"></div> </div> <div id="LeftMenuMyEvents" tabindex="0" class="lbbutton" title="My Events" onclick="go(3)" onkeypress="if (event.key=='Enter') { go(3); }"> <div class="lb3"></div> </div> <div id="LeftMenuMyFiles" tabindex="0" class="lbbutton" style="display:none" title="My Files" onclick="go(5)" onkeypress="if (event.key=='Enter') { go(5); }"> <div class="lb4"></div> </div> <div id="LeftMenuMyUsers" tabindex="0" class="lbbutton" style="display:none" title="My Users" onclick="go(4)" onkeypress="if (event.key=='Enter') { go(4); }"> <div class="lb5"></div> </div> <div id="LeftMenuMyServer" tabindex="0" class="lbbutton" style="display:none" title="My Server" onclick="go(6)" onkeypress="if (event.key=='Enter') { go(6); }"> <div class="lb6"></div> </div> </div> <div id="topbar" class="noselect"> <div> <div style="position:relative"> <div tabindex="0" id="uiMenuButton" title="User interface selection" onclick="showUserInterfaceSelectMenu()" onkeypress="if (event.key == 'Enter') showUserInterfaceSelectMenu()">&diams; <div id="uiMenu" style="display:none"> <div tabindex="0" id="uiViewButton1" class="uiSelector" onclick="userInterfaceSelectMenu(1)" title="Left bar interface" onkeypress="if (event.key == 'Enter') userInterfaceSelectMenu(1)"><div class="uiSelector1"></div></div> <div tabindex="0" id="uiViewButton2" class="uiSelector" onclick="userInterfaceSelectMenu(2)" title="Top bar interface" onkeypress="if (event.key == 'Enter') userInterfaceSelectMenu(2)"><div class="uiSelector2"></div></div> <div tabindex="0" id="uiViewButton3" class="uiSelector" onclick="userInterfaceSelectMenu(3)" title="Fixed width interface" onkeypress="if (event.key == 'Enter') userInterfaceSelectMenu(3)"><div class="uiSelector3"></div></div> <div tabindex="0" id="uiViewButton4" class="uiSelector" onclick="toggleNightMode()" title="Toggle night mode" onkeypress="if (event.key == 'Enter') toggleNightMode()"><div class="uiSelector4"></div></div> </div> </div> <table id="MainMenuSpan" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="MainMenuMyDevices" class="topbar_td style3x" onclick="go(1)" onkeypress="if (event.key == 'Enter') go(1)">My Devices</td> <td tabindex="0" id="MainMenuMyAccount" class="topbar_td style3x" onclick="go(2)" onkeypress="if (event.key == 'Enter') go(2)">My Account</td> <td tabindex="0" id="MainMenuMyEvents" class="topbar_td style3x" onclick="go(3)" onkeypress="if (event.key == 'Enter') go(3)">My Events</td> <td tabindex="0" id="MainMenuMyFiles" class="topbar_td style3x" onclick="go(5)" onkeypress="if (event.key == 'Enter') go(5)">My Files</td> <td tabindex="0" id="MainMenuMyUsers" class="topbar_td style3x" onclick="go(4)" onkeypress="if (event.key == 'Enter') go(4)">My Users</td> <td tabindex="0" id="MainMenuMyServer" class="topbar_td style3x" onclick="go(6)" onkeypress="if (event.key == 'Enter') go(6)">My Server</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> <div id="MainSubMenuSpan" style="display:none"> <table id="MainSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="MainDev" class="topbar_td style3x" onclick="go(10)" onkeypress="if (event.key == 'Enter') go(10)">General</td> <td tabindex="0" id="MainDevDesktop" class="topbar_td style3x" onclick="go(11)" onkeypress="if (event.key == 'Enter') go(11)">Desktop</td> <td tabindex="0" id="MainDevTerminal" class="topbar_td style3x" onclick="go(12)" onkeypress="if (event.key == 'Enter') go(12)">Terminal</td> <td tabindex="0" id="MainDevFiles" class="topbar_td style3x" onclick="go(13)" onkeypress="if (event.key == 'Enter') go(13)">Files</td> <td tabindex="0" id="MainDevEvents" class="topbar_td style3x" onclick="go(16)" onkeypress="if (event.key == 'Enter') go(16)">Events</td> <td tabindex="0" id="MainDevAmt" class="topbar_td style3x" onclick="go(14)" onkeypress="if (event.key == 'Enter') go(14)">Intel&reg; AMT</td> <td tabindex="0" id="MainDevConsole" class="topbar_td style3x" onclick="go(15)" onkeypress="if (event.key == 'Enter') go(15)">Console</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="MeshSubMenuSpan" style="display:none"> <table id="MeshSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="MeshGeneral" class="topbar_td style3x" onclick="go(20)" onkeypress="if (event.key == 'Enter') go(20)">General</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="UserSubMenuSpan" style="display:none"> <table id="UserSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="UserGeneral" class="topbar_td style3x" onclick="go(30)" onkeypress="if (event.key == 'Enter') go(30)">General</td> <td tabindex="0" id="UserEvents" class="topbar_td style3x" onclick="go(31)" onkeypress="if (event.key == 'Enter') go(31)">Events</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="ServerSubMenuSpan" style="display:none"> <table id="ServerSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td tabindex="0" id="ServerGeneral" class="topbar_td style3x" onclick="go(6)" onkeypress="if (event.key == 'Enter') go(6)">General</td> <td tabindex="0" id="ServerStats" class="topbar_td style3x" onclick="go(40)" onkeypress="if (event.key == 'Enter') go(40)">Stats</td> <td tabindex="0" id="ServerConsole" class="topbar_td style3x" onclick="go(115)" onkeypress="if (event.key == 'Enter') go(115)">Console</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="UserDummyMenuSpan"> <table id="UserDummyMenu" cellpadding="0" cellspacing="0" class="style1"> <tr><td class="style3" style="">&nbsp;</td></tr> </table> </div> </div> </div> </div> <div id="column_l"> <div id="p0" style="display:none"> <div id="p0message"><span id="p0span">Server disconnected</span>, <href onclick="reload()" style="cursor:pointer"><u>click to reconnect</u></href>.</div> </div> <div id="p1" style="display:none"> <div style="display:none" id="devListToolbarViewIcons"> <div tabindex="0" id="devViewButton1" class="viewSelector" onclick="onDeviceViewChange(1)" onkeypress="if (event.key=='Enter') { onDeviceViewChange(1); }" title="Columns"><div class="viewSelector2"></div></div> <div tabindex="0" id="devViewButton2" class="viewSelector" onclick="onDeviceViewChange(2)" onkeypress="if (event.key == 'Enter') { onDeviceViewChange(2); }" title="List"><div class="viewSelector1"></div></div> <div tabindex="0" id="devViewButton3" class="viewSelector" onclick="onDeviceViewChange(3)" onkeypress="if (event.key == 'Enter') { onDeviceViewChange(3); }" title="Desktops"><div class="viewSelector3"></div></div> <div tabindex="0" id="devViewButton4" class="viewSelector" onclick="onDeviceViewChange(4)" onkeypress="if (event.key == 'Enter') { onDeviceViewChange(4); }" title="Map"><div class="viewSelector4"></div></div> </div><div><h1>My Devices</h1></div> <table id="devListToolbarSpan" class="noselect"> <tr> <td class="h1"></td> <td id="devListToolbar" class="style14" style="display:none"> &nbsp;&nbsp;<input type="button" id="SelectAllButton" onclick="selectallButtonFunction();" value="Select All">&nbsp; <input type="button" id="GroupActionButton" disabled="disabled" value="Group Action" onclick="groupActionFunction()">&nbsp; <input id="SearchInput" type="text" placeholder="Filter" onchange="masterUpdate(5)" onkeyup="masterUpdate(5)" autocomplete="off" onfocus="onSearchFocus(1)" onblur="onSearchFocus(0)">&nbsp; <label><input type="checkbox" id="RealNameCheckBox" onclick="onRealNameCheckBox()"><span title="Show devices operating system name">OS Name</span></label> </td> <td id="kvmListToolbar" class="style14" style="display:none"> &nbsp;&nbsp;<input type="button" onclick="connectAllKvmFunction()" value="Connect All">&nbsp; <input type="button" onclick="disconnectAllKvmFunction()" value="Disconnect All">&nbsp; <label><input type="checkbox" id="autoConnectDesktopCheckbox" onclick="autoConnectDesktops(event)" title="Automatic connect">Auto&nbsp;</label> <input type="button" onclick="showMultiDesktopSettings()" value="Settings">&nbsp; </td> <td id="devMapToolbar" class="style14" style="display:none"> &nbsp;&nbsp;<input type="text" id="mapSearchLocation" placeholder="Search Location" onfocus="onMapSearchFocus(1)" onblur="onMapSearchFocus(0)"> <input type="button" value="Search" title="Search for location" onclick="getSearchLocation()"> <input type="button" id="refreshmap" title="Reset map view" value="Reset" onclick="refreshMap(false,true)"> </td> <td class="auto-style1" style="height:100%"> <div style="display:none" id="devListToolbarView"> View <select id="viewselect" onchange="onDeviceViewChange()"> <option value="1">Columns <option value="2">List <option value="3">Desktops <option id="viewselectmapoption" value="4">Map </select> </div> <div style="display:none" id="devListToolbarSort"> Sort <select id="sortselect" onchange="masterUpdate(6)"> <option>Group <option>Power <option>Device <option>Tags </select> &nbsp; </div> <div style="display:none" id="devListToolbarSize"> Size <select id="sizeselect" onchange="onDeviceViewChange()"> <option value="0">Small <option value="1">Medium <option value="2">Large </select> &nbsp; </div> </td> <td class="h2"></td> </tr> </table> <div id="NoMeshesPanel" style="display:none"> <table> <tr> <td valign="top" style="width:50px"> <img src="images/info.png"> </td> <td> <div id="getStarted1">To get started, <a href="#" onclick="return account_createMesh()"><strong>click here to create a device group</strong></a>.</div> <div id="getStarted2">No device groups.</div> </td> </tr> </table> </div> <div id="xdevices" class="noselect" style="display:none"></div> <div id="xdevicesmap" style="display:none"> <div id="xmapSearchResultsDlg" style="display:none"> <div id="xmapSearchResultsBck"> <div id="xmapSearchClose" onclick="mapCloseSearchWindow()"><b>X</b></div> <div style="padding:5px">Location Results</div> <div style="width:100%;margin:6px"></div> </div> <div id="xmapSearchResults" style="margin:6px"></div> </div> </div> <div id="xmap-info-window"></div> </div> <div id="p2" style="display:none"> <h1>My Account</h1> <img id="p2AccountImage" alt="" src="images/clipboard-128.png"> <div id="p2AccountSecurity" style="display:none"> <p><strong>Account security</strong></p> <div style="margin-left:25px"> <div id="manageAuthApp"><div class="p2AccountActions"><span id="authAppSetupCheck"><strong>&#x2713;</strong></span></div><span><a href="#" onclick="return account_manageAuthApp()">Manage authenticator app</a><br></span></div> <div id="manageHardwareOtp"><div class="p2AccountActions"><span id="authKeySetupCheck"><strong>&#x2713;</strong></span></div><span><a href="#" onclick="return account_manageHardwareOtp(0)">Manage security keys</a><br></span></div> <div id="manageOtp"><div class="p2AccountActions"><span id="authCodesSetupCheck"><strong>&#x2713;</strong></span></div><span><a href="#" onclick="return account_manageOtp(0)">Manage backup codes</a><br></span></div> </div> </div> <div id="p2AccountActions"> <p><strong>Account actions</strong></p> <p class="mL"> <span id="verifyEmailId" style="display:none"><a href="#" onclick="return account_showVerifyEmail()">Verify email</a><br></span> <span id="accountEnableNotificationsSpan" style="display:none"><a href="#" onclick="return account_enableNotifications()">Enable web notifications</a><br></span> <a href="#" onclick="return account_showAccountNotifySettings()">Notification Settings</a><br> <span id="accountChangeEmailAddressSpan" style="display:none"><a href="#" onclick="return account_showChangeEmail()">Change email address</a><br></span> <a href="#" onclick="return account_showChangePassword()">Change password</a><span id="p2nextPasswordUpdateTime"></span><br> <a href="#" onclick="return account_showDeleteAccount()">Delete account</a><br> </p> <br style="clear:both"> </div> <strong>Device Groups</strong> <span id="p2createMeshLink1">( <a href="#" onclick="return account_createMesh()" class="newMeshBtn"> New</a> )</span> <br><br> <div id="p2meshes"></div> <div id="p2noMeshFound" style="display:none">No device groups.<span id="p2createMeshLink2"> <a href="#" onclick="return account_createMesh()"><strong>Get started here!</strong></a></span></div> <br style="clear:both"> </div> <div id="p3" style="display:none"> <h1>My Events</h1> <table class="pTable"> <tr> <td class="h1"></td> <td>&nbsp;<input id="p2deleteall" type="button" onclick="showDeleteAllEventsDialog()" style="display:none" value="Delete All..."></td> <td class="auto-style1"> Show <select id="p3limitdropdown" onchange="refreshEvents()"> <option value="60">Last 60 <option value="120">Last 120 <option value="250">Last 250 <option value="500">Last 500 <option value="1000">Last 1000 </select>&nbsp; <a href="#" onclick="p3showDownloadEventsDialog()"><img src="images/link4.png" height="10" width="10" title="Download Events" style="cursor:pointer"></a>&nbsp; </td> <td class="h2"></td> </tr> </table> <div id="p3events" style=""></div> </div> <div id="p4" style="display:none"> <h1>My Users</h1> <table class="pTable"> <tr> <td class="h1"></td> <td class="style14"> <div style="float:right"> <input type="button" onclick="showUserBroadcastDialog()" style="margin-right:6px" value="Broadcast"> <a href="#" onclick="p4downloadUserInfo()"><img style="cursor:pointer" title="Download user information" src="images/link4.png"></a> <a href="#" onclick="p4batchAccountCreate()"><img id="p4UserBatchCreate" style="cursor:pointer;display:none" title="Batch create many user accounts" src="images/link6.png"></a> </div> <div> <input id="UserNewAccountButton" type="button" style="margin-left:6px" onclick="showCreateNewAccountDialog()" value="New Account..."> <input id="UserSearchInput" type="text" style="width:120px;margin-left:6px" placeholder="Filter" onchange="onUserSearchInputChanged()" onkeyup="onUserSearchInputChanged()" autocomplete="off" onfocus="onUserSearchFocus(1)" onblur="onUserSearchFocus(0)"> </div> </td> <td class="h2"></td> </tr> </table> <div id="p3users"></div> </div> <div id="p5" style="display:none"> <h1>My Files</h1> <table id="p5toolbar" cellpadding="0" cellspacing="0"> <tr> <td id="p5filehead" valign="bottom"> <div id="p5rightOfButtons"></div> <div> <input type="button" id="p5FolderUp" disabled="disabled" onclick="return p5folderup();" value="Up">&nbsp; <input type="button" id="p5SelectAllButton" disabled="disabled" onclick="p5selectallfile();" value="Select All">&nbsp; <input type="button" id="p5RenameFileButton" disabled="disabled" value="Rename" onclick="p5renamefile();">&nbsp; <input type="button" id="p5DeleteFileButton" disabled="disabled" value="Delete" onclick="p5deletefile();">&nbsp; <input type="button" id="p5NewFolderButton" disabled="disabled" value="New Folder" onclick="p5createfolder();">&nbsp; <input type="button" id="p5UploadButton" disabled="disabled" value="Upload" onclick="p5uploadFile()">&nbsp; <input type="button" id="p5CutButton" disabled="disabled" value="Cut" onclick="p5copyFile(1)">&nbsp; <input type="button" id="p5CopyButton" disabled="disabled" value="Copy" onclick="p5copyFile(0)">&nbsp; <input type="button" id="p5PasteButton" disabled="disabled" value="Paste" onclick="p5pasteFile()">&nbsp; </div> </td> </tr> <tr> <td id="p5filesubhead"> <div style="float:right"> <select id="p5sortdropdown" onchange="updateFiles()"> <option value="1" selected="selected">Sort by name <option value="2">Sort by size <option value="3">Sort by date <option value="4">Descend by name <option value="5">Descend by size <option value="6">Descend by date </select> </div> <div>&nbsp;&nbsp;<span id="p5currentpath"></span></div> </td> </tr> </table> <div id="p5filetable"> <div id="p5PublicShare" style=""><div>These files are shared publicly, click "link" to get public url.</div></div> <div id="bigok" style="display:none"><b>&checkmark;</b></div> <div id="bigfail" style="display:none"><b>&#10007;</b></div> <span id="p5files"></span> </div> <table id="p5toolbarBottom" style="width:100%" cellpadding="0" cellspacing="0"> <tr><td class="style6">&nbsp;<span id="p5bottomstatus"></span></td></tr> </table> </div> <div id="p6" style="display:none"> <img id="MainMeshImage" src="serverpic.ashx"> <h1>My Server</h1> <div id="p2ServerActions"> <p><strong>Server actions</strong></p> <div class="mL"> <div id="p2ServerActionsBackup"><a href="{{{domainurl}}}backup.zip" rel="noreferrer noopener" target="_blank">Download server backup</a></div> <div id="p2ServerActionsRestore"><a href="#" onclick="return server_showRestoreDlg()">Restore server with backup</a></div> <div id="p2ServerActionsVersion"><a href="#" onclick="return server_showVersionDlg()">Check server version</a></div> <div id="p2ServerActionsErrors"><a href="#" onclick="return server_showErrorsDlg()">Show server error log</a></div> </div> </div> <br><strong>Server Statistics</strong><br><br> <div id="serverStats"> <div id="serverCpuChartView" style="display:none"> <div class="chartViewCanvas"><canvas id="serverCpuChart"></canvas></div> <div class="chartViewText" id="serverCpuChartText"></div> </div> <div id="serverMemoryChartView" style="display:none"> <div class="chartViewCanvas"><canvas id="serverMemoryChart"></canvas></div> <div class="chartViewText" id="serverMemoryChartText"></div> </div><br><br> <div id="serverStatsTable"></div> </div> </div> <div id="p10" style="display:none"> <table style="width:100%" cellpadding="0" cellspacing="0"> <tr> <td style="width:auto" valign="top"> <div id="p10title"> <div id="p10BackButton"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>General - <span id="p10deviceName"></span></h1> </div> <div id="p10html"></div> </td> <td style="width:20px"></td> <td style="width:200px"> <a href="#" onclick="p10showiconselector()"><img id="MainComputerImage"></a> <div id="MainComputerState"></div> </td> </tr> </table><br> <div id="p10html2"></div> <div id="p10html3"></div> </div> <div id="p11" class="noselect" style="display:none"> <div id="p11title"> <div id="p11deviceNameHeader"> <div id="p11BackButton"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <div id="devListToolbarViewIcons"><div class="viewSelector" onclick="deskToggleFull(event)" title="Full Screen. Hold shift to browser full screen."><div class="viewSelector5"></div></div></div> <h1>Desktop - <span id="p11deviceName"></span></h1> </div> </div> <div id="p11warning" onclick="showFeaturesDlg()"> <div class="icon2"></div> <div class="warningbox">Intel&reg; AMT Redirection port or KVM feature is disabled<span id="p11warninga">, click here to enable it.</span></div> </div> <div id="p11warning2" onclick="showPowerActionDlg()"> <div class="icon2"></div> <div class="warningbox">Remote computer is not powered on, click here to issue a power command.</div> </div> <div id="deskarea0" cellpadding="0" cellspacing="0"> <div id="deskarea1" class="areaHead"> <div class="toright2"> <span id="p11power"></span>&nbsp; <div class='deskareaicon' title="Toggle View Mode" onclick="toggleAspectRatio(1)">&#8690;</div> <div class='deskareaicon' title="Rotate Left" onclick="drotate(-1)">&olarr;</div> <div class='deskareaicon' title="Rotate Right" onclick="drotate(1)">&orarr;</div> <input id="deskFocusBtn" type="button" title="Toggle focus mode, when active only the region around the mouse is updated" onkeypress="return false" onkeydown="return false" value="Focus All" onclick="deskToggleFocus()" style="margin-right:3px;display:none"> <input id="deskSaveBtn" type="button" title="Save a screenshot of the remote desktop" onkeypress="return false" onkeydown="return false" value="Save..." onclick="deskSaveImage()" class="mR"> <input id="deskActionsBtn" type="button" title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value="Actions" onclick="deviceActionFunction()" class="mR"> <input id="deskActionsSettings" type="button" value="Settings..." title="Edit remote desktop settings" onkeypress="return false" onkeydown="return false" onclick="showDesktopSettings()" class="mR"> <input type="button" title="Change the power state of the remote machine" onkeypress="return false" onkeydown="return false" value="Power Actions..." onclick="showPowerActionDlg()" style="display:none"> </div> <div> <div id="idx_deskFullBtn2" onclick="deskToggleFull(event)">&nbsp;&#x2716;</div> <input type="button" id="autoconnectbutton1" value="AutoConnect" onclick="autoConnectDesktop(event)" onkeypress="return false" onkeydown="return false" style="display:none"> <span id="connectbutton1span"><input type="button" id="connectbutton1" value="Connect" onclick="connectDesktop(event,1)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="connectbutton1hspan">&nbsp;<input type="button" id="connectbutton1h" value="HW Connect" onclick="connectDesktop(event,2)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="disconnectbutton1span">&nbsp;<input type="button" id="disconnectbutton1" value="Disconnect" onclick="connectDesktop(event,0)" onkeypress="return false" onkeydown="return false"></span> &nbsp;<span id="deskstatus">Disconnected</span> </div> </div> <div id="deskarea2" style=""> <div class="areaProgress"><div id="progressbar" style=""></div></div> </div> <div id="deskarea3x"> <div id="DeskFocus" oncontextmenu="return false" onmousedown="dmousedown(event)" onmouseup="dmouseup(event)" onmousemove="dmousemove(event)"></div> <div id="DeskParent"> <canvas id="Desk" width="640" height="480" oncontextmenu="return false" onmousedown="dmousedown(event)" onmouseup="dmouseup(event)" onmousemove="dmousemove(event)" onmousewheel="dmousewheel(event)"></canvas> </div> <div id="DeskTools"> <a id="DeskToolsRefreshButton" style="" onclick="refreshDeskTools()">Refresh</a> <div id="DeskToolsBar">Processes</div> <div id="deskToolsArea"> <div id="deskToolsHeader"> <a class="colmn1" title="Sort by process id" onclick="sortProcess(0)">PID</a> <a class="colmn2" title="Sort by name" onclick="sortProcess(1)">Name</a></div> <div id="DeskToolsProcesses" style=""></div> </div> </div> <div id="p11DeskConsoleMsg" style="display:none;cursor:pointer;position:absolute;left:30px;top:17px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick="p11clearConsoleMsg()"></div> </div> <div id="deskarea4" class="areaFoot"> <div class="toright2"> <select id="termdisplays" style="display:none" onchange="deskSetDisplay(event)" onkeypress="return false" onkeydown="return false"></select>&nbsp; <input id="DeskToolsButton" type="button" value="Tools" title="Toggle tools view" onkeypress="return false" onkeydown="return false" onclick="toggleDeskTools()">&nbsp; <span id="DeskChatButton" class="deskarea" title="Open chat window to this computer"><img src='images/icon-chat.png' onclick="deviceChat()" height="16" width="16" style="padding-top:2px"></span> <span id="DeskNotifyButton" title="Display a notification on the remote computer"><img src='images/icon-notify.png' onclick="deviceToastFunction()" height="16" width="16" style="padding-top:2px"></span> <span id="DeskOpenWebButton" title="Open a web address on remote computer"><img src='images/icon-url2.png' onclick="deviceUrlFunction()" height="16" width="16" style="padding-top:2px"></span> </div> <div> <select id="deskkeys"> <option value="10">Ctrl+Alt+Del <option value="5">Win <option value="0">Win+Down <option value="1">Win+Up <option value="2">Win+L <option value="3">Win+M <option value="4">Shift+Win+M <option value="6">Win+R <option value="7">Alt-F4 <option value="8">Ctrl-W <option value="9">Alt-Tab </select> <input id="DeskWD" type="button" value="Send" onkeypress="return false" onkeydown="return false" onclick="deskSendKeys()"> <input id="DeskClip" style="" type="button" value="Clipboard" onkeypress="return false" onkeydown="return false" onclick="showDeskClip()"> <label><span id="DeskControlSpan" title="Toggle mouse and keyboard input"><input id="DeskControl" type="checkbox" onkeypress="return false" onkeydown="return false" onclick="toggleKvmControl()">Input</span></label>&nbsp; </div> </div> </div> </div> <div id="p12" style="display:none"> <div id="p12title"> <div id="p12BackButton"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>Terminal - <span id="p12deviceName"></span></h1> </div> <div id="p12warning" onclick="showFeaturesDlg()"> <div class="icon2"></div> <div class="warningbox">Intel&reg; AMT Redirection port or KVM feature is disabled<span id="p12warninga">, click here to enable it.</span></div> </div> <div id="p12warning2" onclick="showPowerActionDlg()"> <div class="icon2"></div> <div class="warningbox">Remote computer is not powered on, click here to issue a power command.</div> </div> <div id="termTable" style="position:relative"> <table style="width:100%" cellpadding="0" cellspacing="0"> <tr> <td class="areaHead"> <div class="toright2"> <input id="termActionsBtn" type="button" title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value="Actions" onclick="deviceActionFunction()"> </div> <div> <input type="button" id="autoconnectbutton2" value="AutoConnect" onclick="autoConnectTerminal(event)" onkeypress="return false" onkeydown="return false" style="display:none"> <span id="connectbutton2span"><input type="button" id="connectbutton2" value="Connect" onclick="connectTerminal(event,1)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="connectbutton2hspan">&nbsp;<input type="button" id="connectbutton2h" value="HW Connect" onclick="connectTerminal(event,2)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="disconnectbutton2span">&nbsp;<input type="button" id="disconnectbutton2" value="Disconnect" onclick="connectTerminal(event,0)" onkeypress="return false" onkeydown="return false"></span> &nbsp;<span id="termstatus">Disconnected</span><span id="termtitle"></span> </div> </td> </tr> <tr> <td> <div class="areaProgress"><div id="termprogressbar" style=""></div></div> </td> </tr> <tr> <td id="termarea3x"> <pre id="Term"></pre> </td> </tr> <tr> <td class="areaFoot"> <div class="toright2"> <span id="terminalSettingsButtons" style="display:none"> <input id="id_tcrbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="CR+LF" title="Toggle what the return key will send" onclick="termToggleCr()"> <input id="id_tfxkeysbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Intel (F10 = ESC+[OM)" title="Toggle F1 to F10 keys emulation type" onclick="termToggleFx()"> <input id="id_ttypebutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Extended Ascii" title="Toggle terminal emulation type" onclick="termToggleType()"> </span> <span id="terminalSizeDropDown"> <select id="termSizeList" onkeypress="return false"><option value="1">80x25<option value="2">100x30<option value="3" selected="">Auto</select> </span> <select id="specialkeylist" onkeypress="return false"></select> <input id="specialkeylistinput" type="button" onkeypress="return false" class="bottombutton" value="Send" title="Send the selected special key" onclick="sendSpecialKey()"> </div> <div> &nbsp; <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlcbutton" value="Ctl-C" onclick="termSendKey(3,'ctrlcbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlxbutton" value="Ctl-X" onclick="termSendKey(24,'ctrlxbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="escbutton" value="ESC" onclick="termSendKey(27,'escbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="bsbutton" value="Backspace" onclick="termSendKey(8,'bsbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="pastebutton" value="Paste" title="Paste text into the terminal" onclick="showTermPasteDialog()"> </div> </td> </tr> </table> <div id="p12TermConsoleMsg" style="display:none;cursor:pointer;position:absolute;left:30px;top:45px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick="p12clearConsoleMsg()"></div> </div> </div> <div id="p13" style="display:none"> <div id="p13title"> <div id="p13BackButton" style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>Files - <span id="p13deviceName"></span></h1> </div> <table id="p13toolbar" cellpadding="0" cellspacing="0"> <tr> <td class="areaHead"> <div class="toright2"> <input id="filesActionsBtn" type="button" title="Perform power actions on the device" value="Actions" onclick="deviceActionFunction()"> </div> <div> <input id="p13AutoConnect" value="AutoConnect" onclick="autoConnectFiles(event)" type="button" style="display:none"> <input id="p13Connect" value="Connect" onclick="connectFiles(event)" type="button"> <span id="p13Status">Disconnected</span> </div> </td> </tr> <tr> <td class="areaHead2" valign="bottom"> <div id="p13rightOfButtons" class="toright2"></div> <div> <input type="button" id="p13FolderUp" disabled="disabled" onclick="p13folderup()" value="Up">&nbsp; <input type="button" id="p13SelectAllButton" disabled="disabled" onclick="p13selectallfile()" value="Select All">&nbsp; <input type="button" id="p13RenameFileButton" disabled="disabled" value="Rename" onclick="p13renamefile()">&nbsp; <input type="button" id="p13DeleteFileButton" disabled="disabled" value="Delete" onclick="p13deletefile()">&nbsp; <input type="button" id="p13NewFolderButton" disabled="disabled" value="New Folder" onclick="p13createfolder()">&nbsp; <input type="button" id="p13UploadButton" disabled="disabled" value="Upload" onclick="p13uploadFile()">&nbsp; <input type="button" id="p13CutButton" disabled="disabled" value="Cut" onclick="p13copyFile(1)">&nbsp; <input type="button" id="p13CopyButton" disabled="disabled" value="Copy" onclick="p13copyFile(0)">&nbsp; <input type="button" id="p13PasteButton" disabled="disabled" value="Paste" onclick="p13pasteFile()">&nbsp; <input type="button" id="p13RefreshButton" disabled="disabled" value="Refresh" onclick="p13folderup(9999)">&nbsp; </div> </td> </tr> <tr> <td class="areaHead3"> <div class="toright2"> <select id="p13sortdropdown" onchange="p13updateFiles()"> <option value="1" selected="selected">Sort by name <option value="2">Sort by size <option value="3">Sort by date <option value="4">Descend by name <option value="5">Descend by size <option value="6">Descend by date </select> </div> <div>&nbsp;&nbsp;<span id="p13currentpath"></span></div> </td> </tr> </table> <div id="p13FilesConsoleMsg" style="display:none;cursor:pointer;position:absolute;left:30px;top:165px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick="p13clearConsoleMsg()"></div> <div id="p13filetable" style=""> <div id="p13bigok" style="display:none"><b>&checkmark;</b></div> <div id="p13bigfail" style="display:none"><b>&#10007;</b></div> <span id="p13files"></span> </div> <table id="p13toolbarBottom" cellpadding="0" cellspacing="0"> <tr><td class="style6">&nbsp;<span id="p13bottomstatus"></span></td></tr> </table> </div> <div id="p14" style="display:none"> <div id="p14title"> <div id="p14BackButton" style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <div id="devListToolbarViewIcons"><div class="viewSelector" onclick="deskToggleFull(event)" title="Full Screen. Hold shift to browser full screen."><div class="viewSelector5"></div></div></div> <h1>Intel&reg; AMT - <span id="p14deviceName"></span></h1> </div> <iframe id="p14iframe" src="{{{domainurl}}}commander.htm"></iframe> </div> <div id="p15" style="display:none"> <div id="p15title"> <div id="p15BackButton" style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1><span id="p15deviceName"></span></h1> </div> <table id="consoleTable" cellpadding="0" cellspacing="0"> <tr> <td class="areaHead"> <div class="toright2"> <div id="p15coreName" title="Information about current core running on this agent"></div> <input type="button" id="p15uploadCore" value="Agent Action" onclick="p15uploadCore(event)" title="Change the agent Java Script code module"> <img onclick="p15downloadConsoleText()" style="cursor:pointer;margin-top:6px" title="Download console text" src="images/link4.png"> </div> <div id="p15statetext"></div> </td> </tr> <tr> <td> <div class="areaProgress"><div id="consoleprogressbar" style=""></div></div> </td> </tr> <tr> <td id="p15agentConsole"> <pre id="p15agentConsoleText"></pre> </td> </tr> <tr> <td class="areaFoot"> <table style="width:100%"> <tr> <td style="width:99%"> <input id="p15consoleText" style="width:100%" onkeyup="p15consoleSend(event)" onfocus="onConsoleFocus(1)" onblur="onConsoleFocus(0)"> </td> <td>&nbsp;</td> <td style="width:1%"><input id="id_p15consoleClear" type="button" class="bottombutton" value="Clear" onclick="p15consoleClear()"></td> </tr> </table> </td> </tr> </table> </div> <div id="p16" style="display:none"> <div id="p16title"> <div id="p16BackButton" style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>Events - <span id="p16deviceName"></span></h1> </div> <table class="pTable"> <tr> <td class="h1"></td> <td>&nbsp;<input type="button" onclick="refreshDeviceEvents()" value="Refresh"></td> <td class="auto-style1"> Show <select id="p16limitdropdown" onchange="refreshDeviceEvents()"> <option value="60">Last 60 <option value="120">Last 120 <option value="250">Last 250 <option value="500">Last 500 <option value="1000">Last 1000 </select> </td> <td class="h2"></td> </tr> </table> <div id="p16events"></div> </div> <div id="p20" style="display:none"> <picture id="MainMeshImage" style="border-width:0px;height:200px;width:200px;float:right"> <source type="image/webp" width="200" height="200" srcset="images/webp/mesh-256.webp"> <img alt="" width="200" height="200" src="images/mesh-256.png"> </source></picture> <div style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>General - <span id="p20meshName"></span></h1> <p id="p20info"> </div> <div id="p30" style="display:none"> <table style="width:100%" cellpadding="0" cellspacing="0"> <tr> <td style="width:auto" valign="top"> <div id="p30title"> <div style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>General - <span id="p30userName"></span></h1> </div> <div id="p30html"></div> </td> <td style="width:20px"></td> <td style="width:200px"> <picture id="MainUserImage" style="border-width:0px;height:200px;width:200px;float:right"> <source type="image/webp" width="200" height="200" srcset="images/webp/user-256.webp"> <img alt="" width="200" height="200" src="images/user-256.png"> </source></picture> <div style="width:100%;text-align:center"><strong><span id="MainUserState"></span></strong></div> </td> </tr> </table><br> <div id="p30html2"></div> <div id="p30html3"></div> </div> <div id="p31" style="display:none"> <div style="float:left"><div class="backButton" tabindex="0" onclick="goBack()" title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <h1>Events - <span id="p31userName"></span></h1> <table class="pTable"> <tr> <td class="h1"></td> <td>&nbsp;<input type="button" onclick="refreshUsersEvents()" value="Refresh"></td> <td class="auto-style1"> Show <select id="p31limitdropdown" onchange="refreshUsersEvents()"> <option value="60">Last 60 <option value="120">Last 120 <option value="250">Last 250 <option value="500">Last 500 <option value="1000">Last 1000 </select> </td> <td class="h2"></td> </tr> </table> <div id="p31events"></div> </div> <div id="p40" style="display:none;"> <h1>My Server Stats</h1> <div class="areaHead"> <div class="toright2"> <select id="p40type" onchange="updateServerTimelineStats()"> <option value="0">Connections <option value="1">Memory </select>&nbsp; <select id="p40time" onchange="updateServerTimelineHours()"> <option value="3">Last 3 hours <option value="8">Last 8 hours <option value="24">Last day <option value="168">Last week <option value="720">Last 30 days </select>&nbsp; <img src="images/link4.png" height="10" width="10" title="Download data points (.csv)" style="cursor:pointer" onclick="p40downloadEvents()">&nbsp; </div> <div> <input value="Refresh" type="button" onclick="refreshServerTimelineStats()"> &nbsp;<label><input id="p40log" type="checkbox" onclick="updateServerTimelineHours()">Log-X</label> </div> </div> <canvas id="serverMainStats" style=""></canvas> </div> <br id="column_l_bottomgap"> </div> <div id="footer"> <div class="footer1">{{{footer}}}</div> <div class="footer2"> <a id="verifyEmailId2" style="display:none" href="#" onclick="account_showVerifyEmail()">Verify Email</a> &nbsp;<a href="terms">Terms &amp; Privacy</a> </div> </div> <div id="dialog" class="noselect" style="display:none"> <div id="dialogHeader"> <div tabindex="0" id="id_dialogclose" onclick="setDialogMode()" onkeypress="if (event.key == 'Enter') setDialogMode()">&#x2716;</div> <div id="id_dialogtitle"></div> </div> <div id="dialogBody"> <div id="dialog1"> <div id="id_dialogMessage" style=""></div> </div> <div id="dialog2" style=""> <div id="id_dialogOptions"></div> </div> <div id="dialog3" style=""> <div id="d3upload"> <div>File Selection</div> <select id="d3uploadMode" onchange="d3modechange()"> <option value="1">Local file upload <option value="2">Server file selection </select> </div> <div id="d3localmode" style="display:none"> <div>Upload File</div> <form id="d3localmodeform" method="post" enctype="multipart/form-data" action="uploadfile.ashx" target="fileUploadFrame"> <input type="text" id="d3attrib" name="attrib" style="display:none"> <input type="file" id="d3localFile" name="files" onchange="d3setActions()"> <input type="submit" id="d3submit" style="display:none"> </form> </div> <div id="d3servermode"> <div id="d3serveraction" valign="bottom"> <input type="button" id="p3FolderUp" disabled="disabled" onclick="d3folderup()" value="Up">&nbsp; </div> <div id="d3serverfiles"></div> </div> </div> <div id="dialog7" style=""> <div id="d7meshkvm"> <h4>Agent Remote Desktop</h4> <div> <div>Quality</div> <select id="d7bitmapquality" dir="rtl"></select> </div> <div> <div>Scaling</div> <select id="d7bitmapscaling" style="" dir="rtl"> <option selected="selected" value="1024">100% <option value="896">87.5% <option value="768">75% <option value="640">62.5% <option value="512">50% <option value="384">37.5% <option value="256">25% <option value="128">12.5% </select> </div> <div> <div>Frame rate</div> <select id="d7framelimiter" dir="rtl"> <option selected="selected" value="50">Fast <option value="100">Medium <option value="400">Slow <option value="1000">Very slow </select> </div> </div> <div id="d7amtkvm"> <h4>Intel&reg; AMT Hardware KVM</h4> <div> <div>Image Encoding</div> <select id="d7desktopmode"> <option value="1">RLE8, Fastest <option value="2">RLE16, Recommended <option value="3">RAW8, Slow <option value="4">RAW16, Very Slow </select> </div> <div> <div>Other Settings</div> <div id="d7otherset" style="display:block"> <label style="display:block"><input type="checkbox" id="d7showfocus">Show Focus Tool</label> <label style="display:block"><input type="checkbox" id="d7showcursor">Show Local Mouse Cursor</label> <label style="display:block"><input type="checkbox" id="d7localKeyMap">Local Keyboard Map</label> </div> </div> </div> </div> </div> <div id="idx_dlgButtonBar"> <input id="idx_dlgCancelButton" type="button" value="Cancel" style="" onclick="dialogclose(0)"> <input id="idx_dlgOkButton" type="button" value="OK" style="" onclick="dialogclose(1)"> <div><input id="idx_dlgDeleteButton" type="button" value="Delete" style="display:none" onclick="dialogclose(2)"></div> </div> </div> <iframe name="fileUploadFrame" style="display:none"></iframe> <form style="display:none" method="post" action="uploadfile.ashx" enctype="multipart/form-data" target="fileUploadFrame"><input id="p5fileDragName" name="name"><input id="p5fileDragSize" name="size"><input id="p5fileDragType" name="type"><input id="p5fileDragData" name="data"><input id="p5fileDragLink" name="link"><input type="submit" id="p5loginSubmit2" style="display:none"></form> <form style="display:none" method="post" action="uploadnodefile.ashx" enctype="multipart/form-data" target="fileUploadFrame"><input id="p13fileDragName" name="name"><input id="p13fileDragSize" name="size"><input id="p13fileDragType" name="type"><input id="p13fileDragData" name="data"><input id="p13fileDragLink" name="link"><input type="submit" id="p13loginSubmit2" style="display:none"></form> <audio id="chimes"><source src="sounds/chimes.mp3" type="audio/mp3"></source></audio> </div> <script>if(!String.prototype.startsWith){String.prototype.startsWith=function(a){return this.lastIndexOf(a,0)===0}}if(!String.prototype.endsWith){String.prototype.endsWith=function(a){return this.indexOf(a,this.length-a.length)!==-1}}function Q(a){return document.getElementById(a)}function QS(a){try{return Q(a).style}catch(a){}}function QE(a,b){try{Q(a).disabled=!b}catch(a){}}function QV(a,b){try{QS(a).display=(b?"":"none")}catch(a){}}function QA(a,b){Q(a).innerHTML+=b}function QH(a,b){Q(a).innerHTML=b}function QC(a){try{return Q(a).classList}catch(a){}}function inputBoxFocus(b){Q(b).focus();var a=Q(b).value;Q(b).value="";Q(b).value=a}function ReadShort(b,a){return(b.charCodeAt(a)<<8)+b.charCodeAt(a+1)}function ReadShortX(b,a){return(b.charCodeAt(a+1)<<8)+b.charCodeAt(a)}function ReadInt(b,a){return(b.charCodeAt(a)*16777216)+(b.charCodeAt(a+1)<<16)+(b.charCodeAt(a+2)<<8)+b.charCodeAt(a+3)}function ReadSInt(b,a){return(b.charCodeAt(a)<<24)+(b.charCodeAt(a+1)<<16)+(b.charCodeAt(a+2)<<8)+b.charCodeAt(a+3)}function ReadIntX(b,a){return(b.charCodeAt(a+3)*16777216)+(b.charCodeAt(a+2)<<16)+(b.charCodeAt(a+1)<<8)+b.charCodeAt(a)}function ShortToStr(a){return String.fromCharCode((a>>8)&255,a&255)}function ShortToStrX(a){return String.fromCharCode(a&255,(a>>8)&255)}function IntToStr(a){return String.fromCharCode((a>>24)&255,(a>>16)&255,(a>>8)&255,a&255)}function IntToStrX(a){return String.fromCharCode(a&255,(a>>8)&255,(a>>16)&255,(a>>24)&255)}function MakeToArray(a){if(!a||a==null||typeof a=="object"){return a}return[a]}function SplitArray(a){return a.split(",")}function Clone(a){return JSON.parse(JSON.stringify(a))}function EscapeHtml(a){if(typeof a=="string"){return a.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}if(typeof a=="boolean"){return a}if(typeof a=="number"){return a}}function EscapeHtmlBreaks(a){if(typeof a=="string"){return a.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/\r/g,"<br />").replace(/\n/g,"").replace(/\t/g,"&nbsp;&nbsp;")}if(typeof a=="boolean"){return a}if(typeof a=="number"){return a}}function ArrayElementMove(a,b,c){a.splice(c,0,a.splice(b,1)[0])}function ObjectToStringEx(e,a){var d="";if(e!=0&&(!e||e==null)){return"(Null)"}if(e instanceof Array){for(var b in e){d+="<br />"+gap(a)+"Item #"+b+": "+ObjectToStringEx(e[b],a+1)}}else{if(e instanceof Object){for(var b in e){d+="<br />"+gap(a)+b+" = "+ObjectToStringEx(e[b],a+1)}}else{d+=EscapeHtml(e)}}return d}function ObjectToStringEx2(e,a){var d="";if(e!=0&&(!e||e==null)){return"(Null)"}if(e instanceof Array){for(var b in e){d+="\r\n"+gap2(a)+"Item #"+b+": "+ObjectToStringEx2(e[b],a+1)}}else{if(e instanceof Object){for(var b in e){d+="\r\n"+gap2(a)+b+" = "+ObjectToStringEx2(e[b],a+1)}}else{d+=EscapeHtml(e)}}return d}function gap(a){var d="";for(var b=0;b<(a*4);b++){d+="&nbsp;"}return d}function gap2(a){var d="";for(var b=0;b<(a*4);b++){d+=" "}return d}function ObjectToString(a){return ObjectToStringEx(a,0)}function ObjectToString2(a){return ObjectToStringEx2(a,0)}function hex2rstr(a){if(typeof a!="string"||a.length==0){return""}var c="",b=(""+a).match(/../g),e;while(e=b.shift()){c+=String.fromCharCode("0x"+e)}return c}function char2hex(a){return(a+256).toString(16).substr(-2).toUpperCase()}function rstr2hex(b){var c="",a;for(a=0;a<b.length;a++){c+=char2hex(b.charCodeAt(a))}return c}function encode_utf8(a){return unescape(encodeURIComponent(a))}function decode_utf8(a){return decodeURIComponent(escape(a))}function data2blob(c){var b=new Array(c.length);for(var d=0;d<c.length;d++){b[d]=c.charCodeAt(d)}var a=new Blob([new Uint8Array(b)]);return a}function random(a){return Math.floor(Math.random()*a)}function trademarks(a){return a.replace(/\(R\)/g,"&reg;").replace(/\(TM\)/g,"&trade;")}var MeshServerCreateControl=function(b,a){var c={};c.State=0;c.connectstate=0;c.pingTimer=null;c.authCookie=a;c.trace=false;c.xxStateChange=function(e,d){if(c.State==e){return}var g=c.State;c.State=e;if(c.onStateChanged){c.onStateChanged(c,c.State,g,d)}};c.Start=function(){if(c.connectstate!=0){return}c.connectstate=0;var d=window.location.protocol.replace("http","ws")+"//"+window.location.host+b+"control.ashx";if(c.authCookie&&(c.authCookie!="")){d+="?auth="+c.authCookie}c.socket=new WebSocket(d);c.socket.onopen=function(g){c.connectstate=1};c.socket.onmessage=c.xxOnMessage;c.socket.onclose=function(g){c.Stop(g.code)};c.xxStateChange(1,0);if(c.pingTimer!=null){clearInterval(c.pingTimer)}c.pingTimer=setInterval(function(){c.send({action:"ping"})},29000)};c.Stop=function(d){c.connectstate=0;if(c.socket){c.socket.close();delete c.socket}if(c.pingTimer!=null){clearInterval(c.pingTimer);c.pingTimer=null}c.xxStateChange(0,d)};c.xxOnMessage=function(d){if(c.State==1){c.xxStateChange(2)}var g;try{g=JSON.parse(d.data)}catch(d){return}if((typeof g!="object")||(g.action=="pong")){return}if(g.action=="close"){if(g.msg){console.log(g.msg)}c.Stop(g.cause);return}if(c.trace){console.log("RECV",g)}if(c.onMessage){c.onMessage(c,g)}};c.send=function(d){if(c.socket!=null&&c.connectstate==1){if(c.trace){console.log("SEND",d)}c.socket.send(JSON.stringify(d))}};return c};function AmtStackCreateService(t){var s=new Object();s.wsman=t;s.pfx=["http://intel.com/wbem/wscim/1/amt-schema/1/","http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/","http://intel.com/wbem/wscim/1/ips-schema/1/"];s.PendingEnums=[];s.PendingBatchOperations=0;s.ActiveEnumsCount=0;s.MaxActiveEnumsCount=1;s.onProcessChanged=null;var n=0;var m=0;s.GetPendingActions=function(){return(s.PendingEnums.length*2)+(s.ActiveEnumsCount)+s.wsman.comm.PendingAjax.length+s.wsman.comm.ActiveAjaxCount+s.PendingBatchOperations};function r(){var u=s.GetPendingActions();if(n<u){n=u}if(s.onProcessChanged!=null&&m!=u){m=u;s.onProcessChanged(u,n)}if(u==0){n=0}}s.Subscribe=function(w,v,C,u,B,z,A,x,D,y){s.wsman.ExecSubscribe(s.CompleteName(w),v,C,function(G,F,E,H){r();u(s,w,E,H,B)},0,z,A,x,D,y);r()};s.UnSubscribe=function(v,u,y,w,x){s.wsman.ExecUnSubscribe(s.CompleteName(v),function(B,A,z,C){r();u(s,v,z,C,y)},0,w,x);r()};s.Get=function(v,u,x,w){s.wsman.ExecGet(s.CompleteName(v),function(A,z,y,B){r();u(s,v,y,B,x)},0,w);r()};s.Put=function(v,x,u,z,w,y){s.wsman.ExecPut(s.CompleteName(v),x,function(C,B,A,D){r();u(s,v,A,D,z)},0,w,y);r()};s.Create=function(v,x,u,y,w){s.wsman.ExecCreate(s.CompleteName(v),x,function(B,A,z,C){r();u(s,v,z,C,y)},0,w);r()};s.Delete=function(v,x,u,y,w){s.wsman.ExecDelete(s.CompleteName(v),x,function(B,A,z,C){r();u(s,v,z,C,y)},0,w);r()};s.Exec=function(x,w,u,v,A,y,z){s.wsman.ExecMethod(s.CompleteName(x),w,u,function(D,C,B,E){r();v(s,x,s.CompleteExecResponse(B),E,A)},0,y,z);r()};s.ExecWithXml=function(x,w,u,v,A,y,z){s.wsman.ExecMethodXml(s.CompleteName(x),w,execArgumentsToXml(u),function(D,C,B,E){r();v(s,x,s.CompleteExecResponse(B),E,A)},0,y,z);r()};s.Enum=function(v,u,x,w){if(s.ActiveEnumsCount<s.MaxActiveEnumsCount){s.ActiveEnumsCount++;s.wsman.ExecEnum(s.CompleteName(v),function(B,z,y,C,A){r();d(v,y,u,z,C,A)},x,w)}else{s.PendingEnums.push([v,u,x,w])}r()};function d(w,y,u,z,A,B,x){if(A!=200){u(s,w,null,A,B);c(1);return}if(y==null||y.Header.Method!="EnumerateResponse"||!y.Body.EnumerationContext){u(s,w,null,603,B);c(1);return}var v=y.Body.EnumerationContext;s.wsman.ExecPull(z,v,function(E,D,C,F){b(w,C,u,D,[],F,B,x)})}function b(z,B,u,C,x,D,E,A){if(D!=200){u(s,z,null,D,E);c(1);return}if(B==null||B.Header.Method!="PullResponse"){u(s,z,null,604,E);c(1);return}for(var w in B.Body.Items){if(B.Body.Items[w] instanceof Array){for(var y in B.Body.Items[w]){x.push(B.Body.Items[w][y])}}else{x.push(B.Body.Items[w])}}if(B.Body.EnumerationContext){var v=B.Body.EnumerationContext;s.wsman.ExecPull(C,v,function(H,G,F,I){b(z,F,u,G,x,I,E,1)})}else{c(1);u(s,z,x,D,E);r()}}function c(u){s.ActiveEnumsCount-=u;if(s.ActiveEnumsCount>=s.MaxActiveEnumsCount||s.PendingEnums.length==0){return}var v=s.PendingEnums.shift();s.Enum(v[0],v[1],v[2]);c(0)}s.BatchEnum=function(u,x,v,z,w,y){s.PendingBatchOperations+=(x.length*2);a(u,Clone(x),v,z,{},w,y);r()};function a(u,z,v,C,B,w,A){s.PendingBatchOperations-=2;var y=z.shift(),x=s.Enum;if(y[0]=="*"){x=s.Get;y=y.substring(1)}x(y,function(F,D,E,G,H){H[2][D]={response:(E==null?null:E.Body),responses:E,status:G};if(H[1].length==0||G==401||(w!=true&&G!=200&&G!=400)){s.PendingBatchOperations-=(z.length*2);r();v(s,u,H[2],G,C)}else{r();a(u,z,v,C,H[2],A)}},[u,z,B],A);r()}s.BatchGet=function(u,w,v,y,x){h({name:u,names:w,callback:v,current:0,responses:{},tag:y,pri:x});r()};function h(u){if(u.names.length<=u.current){u.callback(s,u.name,u.responses,200,u.tag)}else{s.wsman.ExecGet(s.CompleteName(u.names[u.current]),function(x,w,v,y){g(u,v,y)},u.pri);u.current++}r()}function g(u,v,w){if(v==null||w!=200){u.callback(s,u.name,null,w,u.tag)}else{u.responses[v.Header.Method]=v;h(u)}}s.CompleteName=function(u){if(u.indexOf("AMT_")==0){return s.pfx[0]+u}if(u.indexOf("CIM_")==0){return s.pfx[1]+u}if(u.indexOf("IPS_")==0){return s.pfx[2]+u}};s.CompleteExecResponse=function(u){if(u&&u!=null&&u.Body&&u.Body.ReturnValue){u.Body.ReturnValueStr=s.AmtStatusToStr(u.Body.ReturnValue)}return u};s.RequestPowerStateChange=function(v,u){s.CIM_PowerManagementService_RequestPowerStateChange(v,'<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="CreationClassName">CIM_ComputerSystem</Selector><Selector Name="Name">ManagedSystem</Selector></SelectorSet></ReferenceParameters>',null,null,u)};s.SetBootConfigRole=function(v,u){s.CIM_BootService_SetBootConfigRole('<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">Intel(r) AMT: Boot Configuration 0</Selector></SelectorSet></ReferenceParameters>',v,u)};s.CancelAllQueries=function(u){s.wsman.CancelAllQueries(u)};s.AMT_AgentPresenceWatchdog_RegisterAgent=function(u){s.Exec("AMT_AgentPresenceWatchdog","RegisterAgent",{},u)};s.AMT_AgentPresenceWatchdog_AssertPresence=function(v,u){s.Exec("AMT_AgentPresenceWatchdog","AssertPresence",{SequenceNumber:v},u)};s.AMT_AgentPresenceWatchdog_AssertShutdown=function(v,u){s.Exec("AMT_AgentPresenceWatchdog","AssertShutdown",{SequenceNumber:v},u)};s.AMT_AgentPresenceWatchdog_AddAction=function(z,y,x,v,u,w,C,A,B){s.Exec("AMT_AgentPresenceWatchdog","AddAction",{OldState:z,NewState:y,EventOnTransition:x,ActionSd:v,ActionEac:u},w,C,A,B)};s.AMT_AgentPresenceWatchdog_DeleteAllActions=function(u,x,v,w){s.Exec("AMT_AgentPresenceWatchdog","DeleteAllActions",{},u,x,v,w)};s.AMT_AgentPresenceWatchdogAction_GetActionEac=function(u){s.Exec("AMT_AgentPresenceWatchdogAction","GetActionEac",{},u)};s.AMT_AgentPresenceWatchdogVA_RegisterAgent=function(u){s.Exec("AMT_AgentPresenceWatchdogVA","RegisterAgent",{},u)};s.AMT_AgentPresenceWatchdogVA_AssertPresence=function(v,u){s.Exec("AMT_AgentPresenceWatchdogVA","AssertPresence",{SequenceNumber:v},u)};s.AMT_AgentPresenceWatchdogVA_AssertShutdown=function(v,u){s.Exec("AMT_AgentPresenceWatchdogVA","AssertShutdown",{SequenceNumber:v},u)};s.AMT_AgentPresenceWatchdogVA_AddAction=function(z,y,x,v,u,w){s.Exec("AMT_AgentPresenceWatchdogVA","AddAction",{OldState:z,NewState:y,EventOnTransition:x,ActionSd:v,ActionEac:u},w)};s.AMT_AgentPresenceWatchdogVA_DeleteAllActions=function(u,v){s.Exec("AMT_AgentPresenceWatchdogVA","DeleteAllActions",{_method_dummy:u},v)};s.AMT_AuditLog_ClearLog=function(u){s.Exec("AMT_AuditLog","ClearLog",{},u)};s.AMT_AuditLog_RequestStateChange=function(v,w,u){s.Exec("AMT_AuditLog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_AuditLog_ReadRecords=function(v,u,w){s.Exec("AMT_AuditLog","ReadRecords",{StartIndex:v},u,w)};s.AMT_AuditLog_SetAuditLock=function(x,v,w,u){s.Exec("AMT_AuditLog","SetAuditLock",{LockTimeoutInSeconds:x,Flag:v,Handle:w},u)};s.AMT_AuditLog_ExportAuditLogSignature=function(v,u){s.Exec("AMT_AuditLog","ExportAuditLogSignature",{SigningMechanism:v},u)};s.AMT_AuditLog_SetSigningKeyMaterial=function(y,x,w,v,u){s.Exec("AMT_AuditLog","SetSigningKeyMaterial",{SigningMechanismType:y,SigningKey:x,LengthOfCertificates:w,Certificates:v},u)};s.AMT_AuditPolicyRule_SetAuditPolicy=function(w,u,x,y,v){s.Exec("AMT_AuditPolicyRule","SetAuditPolicy",{Enable:w,AuditedAppID:u,EventID:x,PolicyType:y},v)};s.AMT_AuditPolicyRule_SetAuditPolicyBulk=function(w,u,x,y,v){s.Exec("AMT_AuditPolicyRule","SetAuditPolicyBulk",{Enable:w,AuditedAppID:u,EventID:x,PolicyType:y},v)};s.AMT_AuthorizationService_AddUserAclEntryEx=function(x,w,y,u,z,v){s.Exec("AMT_AuthorizationService","AddUserAclEntryEx",{DigestUsername:x,DigestPassword:w,KerberosUserSid:y,AccessPermission:u,Realms:z},v)};s.AMT_AuthorizationService_EnumerateUserAclEntries=function(v,u){s.Exec("AMT_AuthorizationService","EnumerateUserAclEntries",{StartIndex:v},u)};s.AMT_AuthorizationService_GetUserAclEntryEx=function(v,u,w){s.Exec("AMT_AuthorizationService","GetUserAclEntryEx",{Handle:v},u,w)};s.AMT_AuthorizationService_UpdateUserAclEntryEx=function(y,x,w,z,u,A,v){s.Exec("AMT_AuthorizationService","UpdateUserAclEntryEx",{Handle:y,DigestUsername:x,DigestPassword:w,KerberosUserSid:z,AccessPermission:u,Realms:A},v)};s.AMT_AuthorizationService_RemoveUserAclEntry=function(v,u){s.Exec("AMT_AuthorizationService","RemoveUserAclEntry",{Handle:v},u)};s.AMT_AuthorizationService_SetAdminAclEntryEx=function(w,v,u){s.Exec("AMT_AuthorizationService","SetAdminAclEntryEx",{Username:w,DigestPassword:v},u)};s.AMT_AuthorizationService_GetAdminAclEntry=function(u){s.Exec("AMT_AuthorizationService","GetAdminAclEntry",{},u)};s.AMT_AuthorizationService_GetAdminAclEntryStatus=function(u){s.Exec("AMT_AuthorizationService","GetAdminAclEntryStatus",{},u)};s.AMT_AuthorizationService_GetAdminNetAclEntryStatus=function(u){s.Exec("AMT_AuthorizationService","GetAdminNetAclEntryStatus",{},u)};s.AMT_AuthorizationService_SetAclEnabledState=function(w,v,u,x){s.Exec("AMT_AuthorizationService","SetAclEnabledState",{Handle:w,Enabled:v},u,x)};s.AMT_AuthorizationService_GetAclEnabledState=function(v,u,w){s.Exec("AMT_AuthorizationService","GetAclEnabledState",{Handle:v},u,w)};s.AMT_EndpointAccessControlService_RequestStateChange=function(v,w,u){s.Exec("AMT_EndpointAccessControlService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_EndpointAccessControlService_GetPosture=function(v,u){s.Exec("AMT_EndpointAccessControlService","GetPosture",{PostureType:v},u)};s.AMT_EndpointAccessControlService_GetPostureHash=function(v,u){s.Exec("AMT_EndpointAccessControlService","GetPostureHash",{PostureType:v},u)};s.AMT_EndpointAccessControlService_UpdatePostureState=function(v,u){s.Exec("AMT_EndpointAccessControlService","UpdatePostureState",{UpdateType:v},u)};s.AMT_EndpointAccessControlService_GetEacOptions=function(u){s.Exec("AMT_EndpointAccessControlService","GetEacOptions",{},u)};s.AMT_EndpointAccessControlService_SetEacOptions=function(v,w,u){s.Exec("AMT_EndpointAccessControlService","SetEacOptions",{EacVendors:v,PostureHashAlgorithm:w},u)};s.AMT_EnvironmentDetectionSettingData_SetSystemDefensePolicy=function(v,u){s.Exec("AMT_EnvironmentDetectionSettingData","SetSystemDefensePolicy",{Policy:v},u)};s.AMT_EnvironmentDetectionSettingData_EnableVpnRouting=function(v,u){s.Exec("AMT_EnvironmentDetectionSettingData","EnableVpnRouting",{Enable:v},u)};s.AMT_EthernetPortSettings_SetLinkPreference=function(v,w,u){s.Exec("AMT_EthernetPortSettings","SetLinkPreference",{LinkPreference:v,Timeout:w},u)};s.AMT_HeuristicPacketFilterStatistics_ResetSelectedStats=function(v,u){s.Exec("AMT_HeuristicPacketFilterStatistics","ResetSelectedStats",{SelectedStatistics:v},u)};s.AMT_KerberosSettingData_GetCredentialCacheState=function(u){s.Exec("AMT_KerberosSettingData","GetCredentialCacheState",{},u)};s.AMT_KerberosSettingData_SetCredentialCacheState=function(v,u){s.Exec("AMT_KerberosSettingData","SetCredentialCacheState",{Enable:v},u)};s.AMT_MessageLog_CancelIteration=function(v,u){s.Exec("AMT_MessageLog","CancelIteration",{IterationIdentifier:v},u)};s.AMT_MessageLog_RequestStateChange=function(v,w,u){s.Exec("AMT_MessageLog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_MessageLog_ClearLog=function(u){s.Exec("AMT_MessageLog","ClearLog",{},u)};s.AMT_MessageLog_GetRecords=function(v,w,u,x){s.Exec("AMT_MessageLog","GetRecords",{IterationIdentifier:v,MaxReadRecords:w},u,x)};s.AMT_MessageLog_GetRecord=function(v,w,u){s.Exec("AMT_MessageLog","GetRecord",{IterationIdentifier:v,PositionToNext:w},u)};s.AMT_MessageLog_PositionAtRecord=function(v,w,x,u){s.Exec("AMT_MessageLog","PositionAtRecord",{IterationIdentifier:v,MoveAbsolute:w,RecordNumber:x},u)};s.AMT_MessageLog_PositionToFirstRecord=function(u,v){s.Exec("AMT_MessageLog","PositionToFirstRecord",{},u,v)};s.AMT_MessageLog_FreezeLog=function(v,u){s.Exec("AMT_MessageLog","FreezeLog",{Freeze:v},u)};s.AMT_PublicKeyManagementService_AddCRL=function(w,v,u){s.Exec("AMT_PublicKeyManagementService","AddCRL",{Url:w,SerialNumbers:v},u)};s.AMT_PublicKeyManagementService_ResetCRLList=function(u,v){s.Exec("AMT_PublicKeyManagementService","ResetCRLList",{_method_dummy:u},v)};s.AMT_PublicKeyManagementService_AddCertificate=function(v,u){s.Exec("AMT_PublicKeyManagementService","AddCertificate",{CertificateBlob:v},u)};s.AMT_PublicKeyManagementService_AddTrustedRootCertificate=function(v,u){s.Exec("AMT_PublicKeyManagementService","AddTrustedRootCertificate",{CertificateBlob:v},u)};s.AMT_PublicKeyManagementService_AddKey=function(v,u){s.Exec("AMT_PublicKeyManagementService","AddKey",{KeyBlob:v},u)};s.AMT_PublicKeyManagementService_GeneratePKCS10Request=function(w,v,x,u){s.Exec("AMT_PublicKeyManagementService","GeneratePKCS10Request",{KeyPair:w,DNName:v,Usage:x},u)};s.AMT_PublicKeyManagementService_GeneratePKCS10RequestEx=function(v,x,w,u){s.Exec("AMT_PublicKeyManagementService","GeneratePKCS10RequestEx",{KeyPair:v,SigningAlgorithm:x,NullSignedCertificateRequest:w},u)};s.AMT_PublicKeyManagementService_GenerateKeyPair=function(v,w,u){s.Exec("AMT_PublicKeyManagementService","GenerateKeyPair",{KeyAlgorithm:v,KeyLength:w},u)};s.AMT_RedirectionService_RequestStateChange=function(v,u){s.Exec("AMT_RedirectionService","RequestStateChange",{RequestedState:v},u)};s.AMT_RedirectionService_TerminateSession=function(v,u){s.Exec("AMT_RedirectionService","TerminateSession",{SessionType:v},u)};s.AMT_RemoteAccessService_AddMpServer=function(u,z,B,v,x,C,A,y,w){s.Exec("AMT_RemoteAccessService","AddMpServer",{AccessInfo:u,InfoFormat:z,Port:B,AuthMethod:v,Certificate:x,Username:C,Password:A,CN:y},w)};s.AMT_RemoteAccessService_AddRemoteAccessPolicyRule=function(x,y,v,w,u){s.Exec("AMT_RemoteAccessService","AddRemoteAccessPolicyRule",{Trigger:x,TunnelLifeTime:y,ExtendedData:v,MpServer:w},u)};s.AMT_RemoteAccessService_CloseRemoteAccessConnection=function(u,v){s.Exec("AMT_RemoteAccessService","CloseRemoteAccessConnection",{_method_dummy:u},v)};s.AMT_SetupAndConfigurationService_CommitChanges=function(u,v){s.Exec("AMT_SetupAndConfigurationService","CommitChanges",{_method_dummy:u},v)};s.AMT_SetupAndConfigurationService_Unprovision=function(v,u){s.Exec("AMT_SetupAndConfigurationService","Unprovision",{ProvisioningMode:v},u)};s.AMT_SetupAndConfigurationService_PartialUnprovision=function(u,v){s.Exec("AMT_SetupAndConfigurationService","PartialUnprovision",{_method_dummy:u},v)};s.AMT_SetupAndConfigurationService_ResetFlashWearOutProtection=function(u,v){s.Exec("AMT_SetupAndConfigurationService","ResetFlashWearOutProtection",{_method_dummy:u},v)};s.AMT_SetupAndConfigurationService_ExtendProvisioningPeriod=function(v,u){s.Exec("AMT_SetupAndConfigurationService","ExtendProvisioningPeriod",{Duration:v},u)};s.AMT_SetupAndConfigurationService_SetMEBxPassword=function(v,u){s.Exec("AMT_SetupAndConfigurationService","SetMEBxPassword",{Password:v},u)};s.AMT_SetupAndConfigurationService_SetTLSPSK=function(v,w,u){s.Exec("AMT_SetupAndConfigurationService","SetTLSPSK",{PID:v,PPS:w},u)};s.AMT_SetupAndConfigurationService_GetProvisioningAuditRecord=function(u){s.Exec("AMT_SetupAndConfigurationService","GetProvisioningAuditRecord",{},u)};s.AMT_SetupAndConfigurationService_GetUuid=function(u){s.Exec("AMT_SetupAndConfigurationService","GetUuid",{},u)};s.AMT_SetupAndConfigurationService_GetUnprovisionBlockingComponents=function(u){s.Exec("AMT_SetupAndConfigurationService","GetUnprovisionBlockingComponents",{},u)};s.AMT_SetupAndConfigurationService_GetProvisioningAuditRecordV2=function(u){s.Exec("AMT_SetupAndConfigurationService","GetProvisioningAuditRecordV2",{},u)};s.AMT_SystemDefensePolicy_GetTimeout=function(u){s.Exec("AMT_SystemDefensePolicy","GetTimeout",{},u)};s.AMT_SystemDefensePolicy_SetTimeout=function(v,u){s.Exec("AMT_SystemDefensePolicy","SetTimeout",{Timeout:v},u)};s.AMT_SystemDefensePolicy_UpdateStatistics=function(v,x,u,z,w,y){s.Exec("AMT_SystemDefensePolicy","UpdateStatistics",{NetworkInterface:v,ResetOnRead:x},u,z,w,y)};s.AMT_SystemPowerScheme_SetPowerScheme=function(u,v,w){s.Exec("AMT_SystemPowerScheme","SetPowerScheme",{},u,w,0,{InstanceID:v})};s.AMT_TimeSynchronizationService_GetLowAccuracyTimeSynch=function(u,v){s.Exec("AMT_TimeSynchronizationService","GetLowAccuracyTimeSynch",{},u,v)};s.AMT_TimeSynchronizationService_SetHighAccuracyTimeSynch=function(v,x,y,u,w){s.Exec("AMT_TimeSynchronizationService","SetHighAccuracyTimeSynch",{Ta0:v,Tm1:x,Tm2:y},u,w)};s.AMT_UserInitiatedConnectionService_RequestStateChange=function(v,w,u){s.Exec("AMT_UserInitiatedConnectionService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_WebUIService_RequestStateChange=function(v,w,u){s.Exec("AMT_WebUIService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AMT_WiFiPortConfigurationService_AddWiFiSettings=function(y,z,x,w,u,v){s.ExecWithXml("AMT_WiFiPortConfigurationService","AddWiFiSettings",{WiFiEndpoint:y,WiFiEndpointSettingsInput:z,IEEE8021xSettingsInput:x,ClientCredential:w,CACredential:u},v)};s.AMT_WiFiPortConfigurationService_UpdateWiFiSettings=function(y,z,x,w,u,v){s.ExecWithXml("AMT_WiFiPortConfigurationService","UpdateWiFiSettings",{WiFiEndpointSettings:y,WiFiEndpointSettingsInput:z,IEEE8021xSettingsInput:x,ClientCredential:w,CACredential:u},v)};s.AMT_WiFiPortConfigurationService_DeleteAllITProfiles=function(u,v){s.Exec("AMT_WiFiPortConfigurationService","DeleteAllITProfiles",{_method_dummy:u},v)};s.AMT_WiFiPortConfigurationService_DeleteAllUserProfiles=function(u,v){s.Exec("AMT_WiFiPortConfigurationService","DeleteAllUserProfiles",{_method_dummy:u},v)};s.CIM_Account_RequestStateChange=function(v,w,u){s.Exec("CIM_Account","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_AccountManagementService_CreateAccount=function(w,u,v){s.Exec("CIM_AccountManagementService","CreateAccount",{System:w,AccountTemplate:u},v)};s.CIM_BootConfigSetting_ChangeBootOrder=function(v,u){s.Exec("CIM_BootConfigSetting","ChangeBootOrder",{Source:v},u)};s.CIM_BootService_SetBootConfigRole=function(u,w,v){s.Exec("CIM_BootService","SetBootConfigRole",{BootConfigSetting:u,Role:w},v,0,1)};s.CIM_Card_ConnectorPower=function(v,w,u){s.Exec("CIM_Card","ConnectorPower",{Connector:v,PoweredOn:w},u)};s.CIM_Card_IsCompatible=function(v,u){s.Exec("CIM_Card","IsCompatible",{ElementToCheck:v},u)};s.CIM_Chassis_IsCompatible=function(v,u){s.Exec("CIM_Chassis","IsCompatible",{ElementToCheck:v},u)};s.CIM_Fan_SetSpeed=function(v,u){s.Exec("CIM_Fan","SetSpeed",{DesiredSpeed:v},u)};s.CIM_KVMRedirectionSAP_RequestStateChange=function(v,w,u){s.Exec("CIM_KVMRedirectionSAP","RequestStateChange",{RequestedState:v},u)};s.CIM_MediaAccessDevice_LockMedia=function(v,u){s.Exec("CIM_MediaAccessDevice","LockMedia",{Lock:v},u)};s.CIM_MediaAccessDevice_SetPowerState=function(v,w,u){s.Exec("CIM_MediaAccessDevice","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_MediaAccessDevice_Reset=function(u){s.Exec("CIM_MediaAccessDevice","Reset",{},u)};s.CIM_MediaAccessDevice_EnableDevice=function(v,u){s.Exec("CIM_MediaAccessDevice","EnableDevice",{Enabled:v},u)};s.CIM_MediaAccessDevice_OnlineDevice=function(v,u){s.Exec("CIM_MediaAccessDevice","OnlineDevice",{Online:v},u)};s.CIM_MediaAccessDevice_QuiesceDevice=function(v,u){s.Exec("CIM_MediaAccessDevice","QuiesceDevice",{Quiesce:v},u)};s.CIM_MediaAccessDevice_SaveProperties=function(u){s.Exec("CIM_MediaAccessDevice","SaveProperties",{},u)};s.CIM_MediaAccessDevice_RestoreProperties=function(u){s.Exec("CIM_MediaAccessDevice","RestoreProperties",{},u)};s.CIM_MediaAccessDevice_RequestStateChange=function(v,w,u){s.Exec("CIM_MediaAccessDevice","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_PhysicalFrame_IsCompatible=function(v,u){s.Exec("CIM_PhysicalFrame","IsCompatible",{ElementToCheck:v},u)};s.CIM_PhysicalPackage_IsCompatible=function(v,u){s.Exec("CIM_PhysicalPackage","IsCompatible",{ElementToCheck:v},u)};s.CIM_PowerManagementService_RequestPowerStateChange=function(w,v,x,y,u){s.Exec("CIM_PowerManagementService","RequestPowerStateChange",{PowerState:w,ManagedElement:v,Time:x,TimeoutPeriod:y},u,0,1)};s.CIM_PowerSupply_SetPowerState=function(v,w,u){s.Exec("CIM_PowerSupply","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_PowerSupply_Reset=function(u){s.Exec("CIM_PowerSupply","Reset",{},u)};s.CIM_PowerSupply_EnableDevice=function(v,u){s.Exec("CIM_PowerSupply","EnableDevice",{Enabled:v},u)};s.CIM_PowerSupply_OnlineDevice=function(v,u){s.Exec("CIM_PowerSupply","OnlineDevice",{Online:v},u)};s.CIM_PowerSupply_QuiesceDevice=function(v,u){s.Exec("CIM_PowerSupply","QuiesceDevice",{Quiesce:v},u)};s.CIM_PowerSupply_SaveProperties=function(u){s.Exec("CIM_PowerSupply","SaveProperties",{},u)};s.CIM_PowerSupply_RestoreProperties=function(u){s.Exec("CIM_PowerSupply","RestoreProperties",{},u)};s.CIM_PowerSupply_RequestStateChange=function(v,w,u){s.Exec("CIM_PowerSupply","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_Processor_SetPowerState=function(v,w,u){s.Exec("CIM_Processor","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_Processor_Reset=function(u){s.Exec("CIM_Processor","Reset",{},u)};s.CIM_Processor_EnableDevice=function(v,u){s.Exec("CIM_Processor","EnableDevice",{Enabled:v},u)};s.CIM_Processor_OnlineDevice=function(v,u){s.Exec("CIM_Processor","OnlineDevice",{Online:v},u)};s.CIM_Processor_QuiesceDevice=function(v,u){s.Exec("CIM_Processor","QuiesceDevice",{Quiesce:v},u)};s.CIM_Processor_SaveProperties=function(u){s.Exec("CIM_Processor","SaveProperties",{},u)};s.CIM_Processor_RestoreProperties=function(u){s.Exec("CIM_Processor","RestoreProperties",{},u)};s.CIM_Processor_RequestStateChange=function(v,w,u){s.Exec("CIM_Processor","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_RecordLog_ClearLog=function(u){s.Exec("CIM_RecordLog","ClearLog",{},u)};s.CIM_RecordLog_RequestStateChange=function(v,w,u){s.Exec("CIM_RecordLog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_RedirectionService_RequestStateChange=function(v,w,u){s.Exec("CIM_RedirectionService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_Sensor_SetPowerState=function(v,w,u){s.Exec("CIM_Sensor","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_Sensor_Reset=function(u){s.Exec("CIM_Sensor","Reset",{},u)};s.CIM_Sensor_EnableDevice=function(v,u){s.Exec("CIM_Sensor","EnableDevice",{Enabled:v},u)};s.CIM_Sensor_OnlineDevice=function(v,u){s.Exec("CIM_Sensor","OnlineDevice",{Online:v},u)};s.CIM_Sensor_QuiesceDevice=function(v,u){s.Exec("CIM_Sensor","QuiesceDevice",{Quiesce:v},u)};s.CIM_Sensor_SaveProperties=function(u){s.Exec("CIM_Sensor","SaveProperties",{},u)};s.CIM_Sensor_RestoreProperties=function(u){s.Exec("CIM_Sensor","RestoreProperties",{},u)};s.CIM_Sensor_RequestStateChange=function(v,w,u){s.Exec("CIM_Sensor","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_StatisticalData_ResetSelectedStats=function(v,u){s.Exec("CIM_StatisticalData","ResetSelectedStats",{SelectedStatistics:v},u)};s.CIM_Watchdog_KeepAlive=function(u){s.Exec("CIM_Watchdog","KeepAlive",{},u)};s.CIM_Watchdog_SetPowerState=function(v,w,u){s.Exec("CIM_Watchdog","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_Watchdog_Reset=function(u){s.Exec("CIM_Watchdog","Reset",{},u)};s.CIM_Watchdog_EnableDevice=function(v,u){s.Exec("CIM_Watchdog","EnableDevice",{Enabled:v},u)};s.CIM_Watchdog_OnlineDevice=function(v,u){s.Exec("CIM_Watchdog","OnlineDevice",{Online:v},u)};s.CIM_Watchdog_QuiesceDevice=function(v,u){s.Exec("CIM_Watchdog","QuiesceDevice",{Quiesce:v},u)};s.CIM_Watchdog_SaveProperties=function(u){s.Exec("CIM_Watchdog","SaveProperties",{},u)};s.CIM_Watchdog_RestoreProperties=function(u){s.Exec("CIM_Watchdog","RestoreProperties",{},u)};s.CIM_Watchdog_RequestStateChange=function(v,w,u){s.Exec("CIM_Watchdog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.CIM_WiFiPort_SetPowerState=function(v,w,u){s.Exec("CIM_WiFiPort","SetPowerState",{PowerState:v,Time:w},u)};s.CIM_WiFiPort_Reset=function(u){s.Exec("CIM_WiFiPort","Reset",{},u)};s.CIM_WiFiPort_EnableDevice=function(v,u){s.Exec("CIM_WiFiPort","EnableDevice",{Enabled:v},u)};s.CIM_WiFiPort_OnlineDevice=function(v,u){s.Exec("CIM_WiFiPort","OnlineDevice",{Online:v},u)};s.CIM_WiFiPort_QuiesceDevice=function(v,u){s.Exec("CIM_WiFiPort","QuiesceDevice",{Quiesce:v},u)};s.CIM_WiFiPort_SaveProperties=function(u){s.Exec("CIM_WiFiPort","SaveProperties",{},u)};s.CIM_WiFiPort_RestoreProperties=function(u){s.Exec("CIM_WiFiPort","RestoreProperties",{},u)};s.CIM_WiFiPort_RequestStateChange=function(v,w,u){s.Exec("CIM_WiFiPort","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.IPS_HostBasedSetupService_Setup=function(y,z,x,v,A,w,u){s.Exec("IPS_HostBasedSetupService","Setup",{NetAdminPassEncryptionType:y,NetworkAdminPassword:z,McNonce:x,Certificate:v,SigningAlgorithm:A,DigitalSignature:w},u)};s.IPS_HostBasedSetupService_AddNextCertInChain=function(x,v,w,u){s.Exec("IPS_HostBasedSetupService","AddNextCertInChain",{NextCertificate:x,IsLeafCertificate:v,IsRootCertificate:w},u)};s.IPS_HostBasedSetupService_AdminSetup=function(x,y,w,z,v,u){s.Exec("IPS_HostBasedSetupService","AdminSetup",{NetAdminPassEncryptionType:x,NetworkAdminPassword:y,McNonce:w,SigningAlgorithm:z,DigitalSignature:v},u)};s.IPS_HostBasedSetupService_UpgradeClientToAdmin=function(w,x,v,u){s.Exec("IPS_HostBasedSetupService","UpgradeClientToAdmin",{McNonce:w,SigningAlgorithm:x,DigitalSignature:v},u)};s.IPS_HostBasedSetupService_DisableClientControlMode=function(u,v){s.Exec("IPS_HostBasedSetupService","DisableClientControlMode",{_method_dummy:u},v)};s.IPS_KVMRedirectionSettingData_TerminateSession=function(u){s.Exec("IPS_KVMRedirectionSettingData","TerminateSession",{},u)};s.IPS_OptInService_StartOptIn=function(u){s.Exec("IPS_OptInService","StartOptIn",{},u)};s.IPS_OptInService_CancelOptIn=function(u){s.Exec("IPS_OptInService","CancelOptIn",{},u)};s.IPS_OptInService_SendOptInCode=function(v,u){s.Exec("IPS_OptInService","SendOptInCode",{OptInCode:v},u)};s.IPS_OptInService_StartService=function(u){s.Exec("IPS_OptInService","StartService",{},u)};s.IPS_OptInService_StopService=function(u){s.Exec("IPS_OptInService","StopService",{},u)};s.IPS_OptInService_RequestStateChange=function(v,w,u){s.Exec("IPS_OptInService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.IPS_ProvisioningRecordLog_RequestStateChange=function(v,w,u){s.Exec("IPS_ProvisioningRecordLog","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.IPS_ProvisioningRecordLog_ClearLog=function(u,v){s.Exec("IPS_ProvisioningRecordLog","ClearLog",{_method_dummy:u},v)};s.IPS_SecIOService_RequestStateChange=function(v,w,u){s.Exec("IPS_SecIOService","RequestStateChange",{RequestedState:v,TimeoutPeriod:w},u)};s.AmtStatusToStr=function(u){if(s.AmtStatusCodes[u]){return s.AmtStatusCodes[u]}else{return"UNKNOWN_ERROR"}};s.AmtStatusCodes={0:"SUCCESS",1:"INTERNAL_ERROR",2:"NOT_READY",3:"INVALID_PT_MODE",4:"INVALID_MESSAGE_LENGTH",5:"TABLE_FINGERPRINT_NOT_AVAILABLE",6:"INTEGRITY_CHECK_FAILED",7:"UNSUPPORTED_ISVS_VERSION",8:"APPLICATION_NOT_REGISTERED",9:"INVALID_REGISTRATION_DATA",10:"APPLICATION_DOES_NOT_EXIST",11:"NOT_ENOUGH_STORAGE",12:"INVALID_NAME",13:"BLOCK_DOES_NOT_EXIST",14:"INVALID_BYTE_OFFSET",15:"INVALID_BYTE_COUNT",16:"NOT_PERMITTED",17:"NOT_OWNER",18:"BLOCK_LOCKED_BY_OTHER",19:"BLOCK_NOT_LOCKED",20:"INVALID_GROUP_PERMISSIONS",21:"GROUP_DOES_NOT_EXIST",22:"INVALID_MEMBER_COUNT",23:"MAX_LIMIT_REACHED",24:"INVALID_AUTH_TYPE",25:"AUTHENTICATION_FAILED",26:"INVALID_DHCP_MODE",27:"INVALID_IP_ADDRESS",28:"INVALID_DOMAIN_NAME",29:"UNSUPPORTED_VERSION",30:"REQUEST_UNEXPECTED",31:"INVALID_TABLE_TYPE",32:"INVALID_PROVISIONING_STATE",33:"UNSUPPORTED_OBJECT",34:"INVALID_TIME",35:"INVALID_INDEX",36:"INVALID_PARAMETER",37:"INVALID_NETMASK",38:"FLASH_WRITE_LIMIT_EXCEEDED",39:"INVALID_IMAGE_LENGTH",40:"INVALID_IMAGE_SIGNATURE",41:"PROPOSE_ANOTHER_VERSION",42:"INVALID_PID_FORMAT",43:"INVALID_PPS_FORMAT",44:"BIST_COMMAND_BLOCKED",45:"CONNECTION_FAILED",46:"CONNECTION_TOO_MANY",47:"RNG_GENERATION_IN_PROGRESS",48:"RNG_NOT_READY",49:"CERTIFICATE_NOT_READY",1024:"DISABLED_BY_POLICY",2048:"NETWORK_IF_ERROR_BASE",2049:"UNSUPPORTED_OEM_NUMBER",2050:"UNSUPPORTED_BOOT_OPTION",2051:"INVALID_COMMAND",2052:"INVALID_SPECIAL_COMMAND",2053:"INVALID_HANDLE",2054:"INVALID_PASSWORD",2055:"INVALID_REALM",2056:"STORAGE_ACL_ENTRY_IN_USE",2057:"DATA_MISSING",2058:"DUPLICATE",2059:"EVENTLOG_FROZEN",2060:"PKI_MISSING_KEYS",2061:"PKI_GENERATING_KEYS",2062:"INVALID_KEY",2063:"INVALID_CERT",2064:"CERT_KEY_NOT_MATCH",2065:"MAX_KERB_DOMAIN_REACHED",2066:"UNSUPPORTED",2067:"INVALID_PRIORITY",2068:"NOT_FOUND",2069:"INVALID_CREDENTIALS",2070:"INVALID_PASSPHRASE",2072:"NO_ASSOCIATION",2075:"AUDIT_FAIL",2076:"BLOCKING_COMPONENT",2081:"USER_CONSENT_REQUIRED",4096:"APP_INTERNAL_ERROR",4097:"NOT_INITIALIZED",4098:"LIB_VERSION_UNSUPPORTED",4099:"INVALID_PARAM",4100:"RESOURCES",4101:"HARDWARE_ACCESS_ERROR",4102:"REQUESTOR_NOT_REGISTERED",4103:"NETWORK_ERROR",4104:"PARAM_BUFFER_TOO_SHORT",4105:"COM_NOT_INITIALIZED_IN_THREAD",4106:"URL_REQUIRED"};s.GetMessageLog=function(u,v){s.AMT_MessageLog_PositionToFirstRecord(k,[u,v,[]])};function k(w,u,v,x,y){if(x!=200||v.Body.ReturnValue!="0"){y[0](s,null,y[2]);return}s.AMT_MessageLog_GetRecords(v.Body.IterationIdentifier,390,l,y)}function l(D,A,C,E,G){if(E!=200||C.Body.ReturnValue!="0"){G[0](s,null,G[2]);return}var y,z,I,v,u=G[2],F=new Date(),H,B=C.Body.RecordArray;if(typeof B==="string"){C.Body.RecordArray=[C.Body.RecordArray]}for(y in B){v=null;try{v=window.atob(B[y])}catch(w){}if(v!=null){H=ReadIntX(v,0);if((H>0)&&(H<4294967295)){I={DeviceAddress:v.charCodeAt(4),EventSensorType:v.charCodeAt(5),EventType:v.charCodeAt(6),EventOffset:v.charCodeAt(7),EventSourceType:v.charCodeAt(8),EventSeverity:v.charCodeAt(9),SensorNumber:v.charCodeAt(10),Entity:v.charCodeAt(11),EntityInstance:v.charCodeAt(12),EventData:[],Time:new Date((H+(F.getTimezoneOffset()*60))*1000)};for(z=13;z<21;z++){I.EventData.push(v.charCodeAt(z))}I.EntityStr=o[I.Entity];I.Desc=j(I.EventSensorType,I.EventOffset,I.EventData,I.Entity);if(!I.EntityStr){I.EntityStr="Unknown"}u.push(I)}}}if(C.Body.NoMoreRecords!=true){s.AMT_MessageLog_GetRecords(C.Body.IterationIdentifier,390,l,[G[0],u,G[2]])}else{G[0](s,u,G[2])}}var e="Platform firmware (e.g. BIOS)|SMI handler|ISV system management software|Alert ASIC|IPMI|BIOS vendor|System board set vendor|System integrator|Third party add-in|OSV|NIC|System management card".split("|");var p="Unspecified.|No system memory is physically installed in the system.|No usable system memory, all installed memory has experienced an unrecoverable failure.|Unrecoverable hard-disk/ATAPI/IDE device failure.|Unrecoverable system-board failure.|Unrecoverable diskette subsystem failure.|Unrecoverable hard-disk controller failure.|Unrecoverable PS/2 or USB keyboard failure.|Removable boot media not found.|Unrecoverable video controller failure.|No video device detected.|Firmware (BIOS) ROM corruption detected.|CPU voltage mismatch (processors that share same supply have mismatched voltage requirements)|CPU speed matching failure".split("|");var q="Unspecified.|Memory initialization.|Starting hard-disk initialization and test|Secondary processor(s) initialization|User authentication|User-initiated system setup|USB resource configuration|PCI resource configuration|Option ROM initialization|Video initialization|Cache initialization|SM Bus initialization|Keyboard controller initialization|Embedded controller/management controller initialization|Docking station attachment|Enabling docking station|Docking station ejection|Disabling docking station|Calling operating system wake-up vector|Starting operating system boot process|Baseboard or motherboard initialization|reserved|Floppy initialization|Keyboard test|Pointing device test|Primary processor initialization".split("|");var o="Unspecified|Other|Unknown|Processor|Disk|Peripheral|System management module|System board|Memory module|Processor module|Power supply|Add in card|Front panel board|Back panel board|Power system board|Drive backplane|System internal expansion board|Other system board|Processor board|Power unit|Power module|Power management board|Chassis back panel board|System chassis|Sub chassis|Other chassis board|Disk drive bay|Peripheral bay|Device bay|Fan cooling|Cooling unit|Cable interconnect|Memory device|System management software|BIOS|Intel(r) ME|System bus|Group|Intel(r) ME|External environment|Battery|Processing blade|Connectivity switch|Processor/memory module|I/O module|Processor I/O module|Management controller firmware|IPMI channel|PCI bus|PCI express bus|SCSI bus|SATA/SAS bus|Processor front side bus".split("|");s.RealmNames="||Redirection|PT Administration|Hardware Asset|Remote Control|Storage|Event Manager|Storage Admin|Agent Presence Local|Agent Presence Remote|Circuit Breaker|Network Time|General Information|Firmware Update|EIT|LocalUN|Endpoint Access Control|Endpoint Access Control Admin|Event Log Reader|Audit Log|ACL Realm|||Local System".split("|");s.WatchdogCurrentStates={1:"Not Started",2:"Stopped",4:"Running",8:"Expired",16:"Suspended"};function j(x,w,v,u){if(x==15){if(v[0]==235){return"Invalid Data"}if(w==0){return p[v[1]]}return q[v[1]]}if(x==18&&v[0]==170){return"Agent watchdog "+char2hex(v[4])+char2hex(v[3])+char2hex(v[2])+char2hex(v[1])+"-"+char2hex(v[6])+char2hex(v[5])+"-... changed to "+s.WatchdogCurrentStates[v[7]]}if(x==6){return"Authentication failed "+(v[1]+(v[2]<<8))+" times. The system may be under attack."}if(x==30){return"No bootable media"}if(x==32){return"Operating system lockup or power interrupt"}if(x==35){return"System boot failure"}if(x==37){return"System firmware started (at least one CPU is properly executing)."}return"Unknown Sensor Type #"+x}return s}var md5_k=[];for(var i=0;i<64;){md5_k[i]=0|(Math.abs(Math.sin(++i))*4294967296)}function hex_md5(p){var g,k,l,o,r=[],q=unescape(encodeURI(p)),e=q.length,m=[g=1732584193,k=-271733879,~g,~k],n=0;for(;n<=e;){r[n>>2]|=(q.charCodeAt(n)||128)<<8*(n++%4)}r[p=(e+8>>6)*16+14]=e*8;n=0;for(;n<p;n+=16){e=m;o=0;for(;o<64;){e=[l=e[3],((g=e[1]|0)+((l=((e[0]+[g&(k=e[2])|~g&l,l&g|~l&k,g^k^l,k^(g|~l)][e=o>>4])+(md5_k[o]+(r[[o,5*o+1,3*o+5,7*o][e]%16+n]|0))))<<(e=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*e+o++%4])|l>>>32-e)),g,k]}for(o=4;o;){m[--o]=m[o]+e[o]}}p="";for(;o<32;){p+=((m[o>>3]>>((1^o++&7)*4))&15).toString(16)}return p}function rstr_md5(a){return hex2rstr(hex_md5(a))}function execArgumentsToXml(c){if(c===undefined||c===null){return null}var d="";for(var b in c){var a=c[b];if(!a){continue}if(a.__parameterType==="reference"){d+=referenceToXml(b,a)}else{d+=instanceToXml(b,a)}}return d}function instanceToXml(d,c){if(c===undefined||c===null){return null}var b=!!c.__namespace;var j=b?"<q:":"<";var a=b?"</q:":"</";var e=b?(' xmlns:q="'+c.__namespace+'"'):"";var h="<r:"+d+e+">";for(var g in c){if(!c.hasOwnProperty(g)||g.indexOf("__")===0){continue}if(typeof c[g]==="function"||Array.isArray(c[g])){continue}if(typeof c[g]==="object"){console.error("only convert one level down...")}else{h+=j+g+">"+c[g].toString()+a+g+">"}}h+="</r:"+d+">";return h}function referenceToXml(b,a){if(a===undefined||a===null){return null}var c="<r:"+b+"><a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>"+a.__resourceUri+"</w:ResourceURI><w:SelectorSet>";for(var d in a){if(!a.hasOwnProperty(d)||d.indexOf("__")===0){continue}if(typeof a[d]==="function"||typeof a[d]==="object"||Array.isArray(a[d])){continue}c+='<w:Selector Name="'+d+'">'+a[d].toString()+"</w:Selector>"}c+="</w:SelectorSet></a:ReferenceParameters></r:"+b+">";return c}function GetSidString(c){var b="S-"+c.charCodeAt(0)+"-"+c.charCodeAt(7);for(var a=2;a<(c.length/4);a++){b+="-"+ReadIntX(c,a*4)}return b}function GetSidByteArray(d){if(!d||d==null){return null}var c=d.split("-");if(c.length<4||(c[0]!="s"&&c[0]!="S")){return null}for(var a=1;a<c.length;a++){var e=parseInt(c[a]);if(e!=c[a]){return null}c[a]=e}var b=String.fromCharCode(c[1])+String.fromCharCode(c.length-3)+ShortToStr(Math.floor(c[2]/Math.pow(2,32)))+IntToStr((c[2])&65535);for(var a=3;a<c.length;a++){b+=IntToStrX(c[a])}return b}var WsmanStackCreateService=function(h,l,n,k,m,g){var j={};j.NextMessageId=1;j.Address="/wsman";j.comm=CreateWsmanComm(h,l,n,k,m,g);j.PerformAjax=function(q,o,s,r,p){if(p==undefined){p=""}j.comm.PerformAjax('<?xml version="1.0" encoding="utf-8"?><Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns="http://www.w3.org/2003/05/soap-envelope" '+p+"><Header><a:Action>"+q,function(t,u,v){if(u!=200){o(j,null,{Header:{HttpError:u}},u,v);return}var w=j.ParseWsman(t);if(!w||w==null){o(j,null,{Header:{HttpError:u}},601,v)}else{o(j,w.Header.ResourceURI,w,200,v)}},s,r)};j.CancelAllQueries=function(o){j.comm.CancelAllQueries(o)};j.GetNameFromUrl=function(o){var p=o.lastIndexOf("/");return(p==-1)?o:o.substring(p+1)};j.ExecSubscribe=function(w,q,z,o,y,v,x,t,A,u){var r="",s="";if(A!=undefined&&u!=undefined){r="<t:IssuedTokens><t:RequestSecurityTokenResponse><t:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</t:TokenType><t:RequestedSecurityToken><se:UsernameToken><se:Username>"+A+'</se:Username><se:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#PasswordText">'+u+"</se:Password></se:UsernameToken></t:RequestedSecurityToken></t:RequestSecurityTokenResponse></t:IssuedTokens>";s='<Auth Profile="http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/secprofile/http/digest"/>'}if(t!=undefined&&t!=null){t="<a:ReferenceParameters>"+t+"</a:ReferenceParameters>"}else{t=""}var p="http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+w+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"+d(x)+r+'</Header><Body><e:Subscribe><e:Delivery Mode="http://schemas.dmtf.org/wbem/wsman/1/wsman/'+q+'"><e:NotifyTo><a:Address>'+z+"</a:Address></e:NotifyTo>"+s+"</e:Delivery><e:Expires>PT0.000000S</e:Expires></e:Subscribe>";j.PerformAjax(p+"</Body></Envelope>",o,y,v,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:m="http://x.com"')};j.ExecUnSubscribe=function(r,o,t,q,s){var p="http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+r+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"+d(s)+"</Header><Body><e:Unsubscribe/>";j.PerformAjax(p+"</Body></Envelope>",o,t,q,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"')};j.ExecPut=function(s,r,o,u,q,t){var p="http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+s+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout>"+d(t)+"</Header><Body>"+c(s,r);j.PerformAjax(p+"</Body></Envelope>",o,u,q)};j.ExecCreate=function(u,t,o,w,s,v){var r=j.GetNameFromUrl(u);var p="http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+u+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+d(v)+"</Header><Body><g:"+r+' xmlns:g="'+u+'">';for(var q in t){p+="<g:"+q+">"+t[q]+"</g:"+q+">"}j.PerformAjax(p+"</g:"+r+"></Body></Envelope>",o,w,s)};j.ExecCreateXml=function(s,o,p,u,r){var q=j.GetNameFromUrl(s),t="";j.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+s+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout></Header><Body><r:"+q+' xmlns:r="'+s+'">'+o+"</r:"+q+"></Body></Envelope>",p,u,r)};j.ExecDelete=function(s,r,o,t,q){var p="http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+s+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+d(r)+"</Header><Body /></Envelope>";j.PerformAjax(p,o,t,q)};j.ExecGet=function(q,o,r,p){j.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+q+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body /></Envelope>",o,r,p)};j.ExecMethod=function(u,s,o,q,w,t,v){var p="";for(var r in o){if(o[r]!=null){if(Array.isArray(o[r])){for(var y in o[r]){p+="<r:"+r+">"+o[r][y]+"</r:"+r+">"}}else{p+="<r:"+r+">"+o[r]+"</r:"+r+">"}}}j.ExecMethodXml(u,s,p,q,w,t,v)};j.ExecMethodXml=function(s,q,o,p,u,r,t){j.PerformAjax(s+"/"+q+"</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+s+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+d(t)+"</Header><Body><r:"+q+'_INPUT xmlns:r="'+s+'">'+o+"</r:"+q+"_INPUT></Body></Envelope>",p,u,r)};j.ExecEnum=function(q,o,r,p){j.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+q+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+'</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Enumerate xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration" /></Body></Envelope>',o,r,p)};j.ExecPull=function(r,p,o,s,q){j.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>"+j.Address+"</a:To><w:ResourceURI>"+r+"</w:ResourceURI><a:MessageID>"+(j.NextMessageId++)+'</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration"><EnumerationContext>'+p+"</EnumerationContext><MaxElements>999</MaxElements><MaxCharacters>99999</MaxCharacters></Pull></Body></Envelope>",o,s,q)};j.ParseWsman=function(x){try{if(!x.childNodes){x=e(x)}var v={Header:{}},s=x.getElementsByTagName("Header")[0],w;if(!s){s=x.getElementsByTagName("a:Header")[0]}if(!s){return null}for(var u=0;u<s.childNodes.length;u++){var p=s.childNodes[u];v.Header[p.localName]=p.textContent}var o=x.getElementsByTagName("Body")[0];if(!o){o=x.getElementsByTagName("a:Body")[0]}if(!o){return null}if(o.childNodes.length>0){w=o.childNodes[0].localName;if(w.indexOf("_OUTPUT")==w.length-7){w=w.substring(0,w.length-7)}v.Header.Method=w;v.Body=b(o.childNodes[0])}return v}catch(q){console.log("Unable to parse XML: "+x);return null}};function b(u){var q,v={};for(var s=0;s<u.childNodes.length;s++){var o=u.childNodes[s];if(o.childElementCount==0){q=o.textContent}else{q=b(o)}if(q=="true"){q=true}if(q=="false"){q=false}var p=q;if(o.attributes.length>0){p={Value:q};for(var t=0;t<o.attributes.length;t++){p["@"+o.attributes[t].name]=o.attributes[t].value}}if(v[o.localName] instanceof Array){v[o.localName].push(p)}else{if(v[o.localName]==undefined){v[o.localName]=p}else{v[o.localName]=[v[o.localName],p]}}}return v}function c(t,r){if(!t||r===undefined||r===null){return""}var p=j.GetNameFromUrl(t);var s="<r:"+p+' xmlns:r="'+t+'">';for(var q in r){if(!r.hasOwnProperty(q)||q.indexOf("__")===0||q.indexOf("@")===0){continue}if(r[q]===undefined||r[q]===null||typeof r[q]==="function"){continue}if(typeof r[q]==="object"&&r[q]["ReferenceParameters"]){s+="<r:"+q+"><a:Address>"+r[q].Address+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+r[q]["ReferenceParameters"]["ResourceURI"]+"</w:ResourceURI><w:SelectorSet>";var u=r[q]["ReferenceParameters"]["SelectorSet"]["Selector"];if(Array.isArray(u)){for(var o=0;o<u.length;o++){s+="<w:Selector"+a(u[o])+">"+u[o]["Value"]+"</w:Selector>"}}else{s+="<w:Selector"+a(u)+">"+u.Value+"</w:Selector>"}s+="</w:SelectorSet></a:ReferenceParameters></r:"+q+">"}else{if(Array.isArray(r[q])){for(var o=0;o<r[q].length;o++){s+="<r:"+q+">"+r[q][o].toString()+"</r:"+q+">"}}else{s+="<r:"+q+">"+r[q].toString()+"</r:"+q+">"}}}s+="</r:"+p+">";return s}function a(o){if(!o){return""}var q=" ";for(var p in o){if(!o.hasOwnProperty(p)||p.indexOf("@")!==0){continue}q+=p.substring(1)+'="'+o[p]+'" '}return q}function d(s){if(!s){return""}if(typeof s=="string"){return s}if(s.InstanceID){return'<w:SelectorSet><w:Selector Name="InstanceID">'+s.InstanceID+"</w:Selector></w:SelectorSet>"}var q="<w:SelectorSet>";for(var p in s){if(!s.hasOwnProperty(p)){continue}q+='<w:Selector Name="'+p+'">';if(s[p]["ReferenceParameters"]){q+="<a:EndpointReference>";q+="<a:Address>"+s[p]["Address"]+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+s[p]["ReferenceParameters"]["ResourceURI"]+"</w:ResourceURI><w:SelectorSet>";var r=s[p]["ReferenceParameters"]["SelectorSet"]["Selector"];if(Array.isArray(r)){for(var o=0;o<r.length;o++){q+="<w:Selector"+a(r[o])+">"+r[o]["Value"]+"</w:Selector>"}}else{q+="<w:Selector"+a(r)+">"+r.Value+"</w:Selector>"}q+="</w:SelectorSet></a:ReferenceParameters></a:EndpointReference>"}else{q+=s[p]}q+="</w:Selector>"}q+="</w:SelectorSet>";return q}function e(o){if(window.DOMParser){return new DOMParser().parseFromString(o,"text/xml")}else{var p=new ActiveXObject("Microsoft.XMLDOM");p.async=false;p.loadXML(o);return p}}return j};var CreateAmtRemoteDesktop=function(p,s){var r={};r.canvasid=p;r.CanvasId=Q(p);r.scrolldiv=s;r.canvas=Q(p).getContext("2d");r.protocol=2;r.state=0;r.acc="";r.ScreenWidth=960;r.ScreenHeight=700;r.width=0;r.height=0;r.rwidth=0;r.rheight=0;r.bpp=2;r.useZRLE=true;r.showmouse=true;r.buttonmask=0;r.localKeyMap=true;r.spare=null;r.sparew=0;r.spareh=0;r.sparew2=0;r.spareh2=0;r.sparecache={};r.ZRLEfirst=1;r.onScreenSizeChange=null;r.frameRateDelay=0;r.kvmDataSupported=false;r.onKvmData=null;r.onKvmDataPending=[];r.onKvmDataAck=-1;r.holding=false;r.lastKeepAlive=Date.now();r.mNagleTimer=null;r.mx=0;r.my=0;r.Debug=function(t){console.log(t)};r.xxStateChange=function(t){if(t==0){r.canvas.fillStyle="#000000";r.canvas.fillRect(0,0,r.width,r.height);r.canvas.canvas.width=r.rwidth=r.width=640;r.canvas.canvas.height=r.rheight=r.height=400;QS(r.canvasid).cursor="default"}else{QS(r.canvasid).cursor=r.showmouse?"default":"none"}};r.ProcessData=function(v){if(!v){return}r.acc+=v;while(r.acc.length>0){var t=0;if(r.state==0&&r.acc.length>=12){t=12;r.state=1;r.send("RFB 003.008\n")}else{if(r.state==1&&r.acc.length>=1){t=r.acc.charCodeAt(0)+1;r.send(String.fromCharCode(1));r.state=2}else{if(r.state==2&&r.acc.length>=4){t=4;if(ReadInt(r.acc,0)!=0){return r.Stop()}r.send(String.fromCharCode(1));r.state=3}else{if(r.state==3&&r.acc.length>=24){var G=ReadInt(r.acc,20);if(r.acc.length<24+G){return}t=24+G;r.canvas.canvas.width=r.rwidth=r.width=r.ScreenWidth=ReadShort(r.acc,0);r.canvas.canvas.height=r.rheight=r.height=r.ScreenHeight=ReadShort(r.acc,2);var J="";if(r.useZRLE){J+=IntToStr(16)}J+=IntToStr(0);J+=IntToStr(1092);r.send(String.fromCharCode(2,0)+ShortToStr((J.length/4)+1)+J+IntToStr(-223));if(r.bpp==1){r.send(String.fromCharCode(0,0,0,0,8,8,0,1)+ShortToStr(7)+ShortToStr(7)+ShortToStr(3)+String.fromCharCode(5,2,0,0,0,0))}r.state=4;r.parent.xxStateChange(3);h();if(r.onScreenSizeChange!=null){r.onScreenSizeChange(r,r.ScreenWidth,r.ScreenHeight)}}else{if(r.state==4){switch(r.acc.charCodeAt(0)){case 0:if(r.acc.length<4){return}r.state=100+ReadShort(r.acc,2);t=4;break;case 2:t=1;break;case 3:if(r.acc.length<8){return}var F=ReadInt(r.acc,4)+8;if(r.acc.length<F){return}t=q(r.acc);break}}else{if(r.state>100&&r.acc.length>=12){var L=ReadShort(r.acc,0),N=ReadShort(r.acc,2),K=ReadShort(r.acc,4),C=ReadShort(r.acc,6),I=K*C,B=ReadInt(r.acc,8);if(B<17){if(K<1||K>64||C<1||C>64){console.log("Invalid tile size ("+K+","+C+"), disconnecting.");return r.Stop()}if(r.sparew!=K||r.spareh!=C){r.sparew=r.sparew2=K;r.spareh=r.spareh2=C;var M=r.sparew2+"x"+r.spareh2;r.spare=r.sparecache[M];if(!r.spare){r.sparecache[M]=r.spare=r.canvas.createImageData(r.sparew2,r.spareh2);var E=(r.sparew2*r.spareh2)<<2;for(var D=3;D<E;D+=4){r.spare.data[D]=255}}}}if(B==4294967073){r.canvas.canvas.width=r.rwidth=r.width=K;r.canvas.canvas.height=r.rheight=r.height=C;r.send(String.fromCharCode(3,0,0,0,0,0)+ShortToStr(r.width)+ShortToStr(r.height));t=12;if(r.onScreenSizeChange!=null){r.onScreenSizeChange(r,r.ScreenWidth,r.ScreenHeight)}}else{if(B==0){var H=12,u=12+(I*r.bpp);if(r.acc.length<u){return}t=u;if(r.bpp==2){for(var D=0;D<I;D++){j(r.acc.charCodeAt(H++)+(r.acc.charCodeAt(H++)<<8),D)}}else{for(var D=0;D<I;D++){l(r.acc.charCodeAt(H++),D)}}g(r.spare,L,N)}else{if(B==16){if(r.acc.length<16){return}var w=ReadInt(r.acc,12);if(r.acc.length<(16+w)){return}var H=16,z=5,A=0;if(w>5&&r.acc.charCodeAt(H)==0&&ReadShortX(r.acc,H+1)==(w-z)){a(r.acc,H+5,L,N,K,C,I,w)}t=16+w}else{r.Debug("Unknown Encoding: "+B);return r.Stop()}}}if(--r.state==100){r.state=4;if(r.frameRateDelay==0){h()}else{setTimeout(h,r.frameRateDelay)}}}}}}}}if(t==0){return}r.acc=r.acc.substring(t)}};function a(w,E,M,N,L,A,I,z){var J=w.charCodeAt(E++),C,K,H,D={},F=0,G=0,B;if(J==0){if(r.bpp==2){for(B=0;B<I;B++){j(w.charCodeAt(E++)+(w.charCodeAt(E++)<<8),B)}}else{for(B=0;B<I;B++){l(w.charCodeAt(E++),B)}}g(r.spare,M,N)}else{if(J==1){K=w.charCodeAt(E++)+((r.bpp==2)?(w.charCodeAt(E++)<<8):0);r.canvas.fillStyle="rgb("+((r.bpp==1)?((K&224)+","+((K&28)<<3)+","+b((K&3)<<6)):(((K>>8)&248)+","+((K>>3)&252)+","+((K&31)<<3)))+")";r.canvas.fillRect(M,N,L,A)}else{if(J>1&&J<17){var u=4,t=15;if(r.bpp==2){for(B=0;B<J;B++){D[B]=w.charCodeAt(E++)+(w.charCodeAt(E++)<<8)}if(J==2){u=1;t=1}else{if(J<=4){u=2;t=3}}while(F<I&&E<w.length){K=w.charCodeAt(E++);for(B=(8-u);B>=0;B-=u){j(D[(K>>B)&t],F++)}}}else{for(B=0;B<J;B++){D[B]=w.charCodeAt(E++)}if(J==2){u=1;t=1}else{if(J<=4){u=2;t=3}}while(F<I&&E<w.length){K=w.charCodeAt(E++);for(B=(8-u);B>=0;B-=u){l(D[(K>>B)&t],F++)}}}g(r.spare,M,N)}else{if(J==128){if(r.bpp==2){while(F<I&&E<w.length){K=w.charCodeAt(E++)+(w.charCodeAt(E++)<<8);G=1;do{G+=(H=w.charCodeAt(E++))}while(H==255);if(r.rotation==0){k(K,F,G);F+=G}else{while(--G>=0){j(K,F++)}}}}else{while(F<I&&E<w.length){K=w.charCodeAt(E++);G=1;do{G+=(H=w.charCodeAt(E++))}while(H==255);if(r.rotation==0){m(K,F,G);F+=G}else{while(--G>=0){l(K,F++)}}}}g(r.spare,M,N)}else{if(J>129){if(r.bpp==2){for(B=0;B<(J-128);B++){D[B]=w.charCodeAt(E++)+(w.charCodeAt(E++)<<8)}}else{for(B=0;B<(J-128);B++){D[B]=w.charCodeAt(E++)}}while(F<I&&E<w.length){G=1;C=w.charCodeAt(E++);K=D[C%128];if(C>127){do{G+=(H=w.charCodeAt(E++))}while(H==255)}if(r.rotation==0){if(r.bpp==2){k(K,F,G);F+=G}else{m(K,F,G);F+=G}}else{if(r.bpp==2){while(--G>=0){j(K,F++)}}else{while(--G>=0){l(K,F++)}}}}g(r.spare,M,N)}}}}}}r.hold=function(t){if(r.holding==t){return}r.holding=t;r.canvas.fillStyle="#000000";r.canvas.fillRect(0,0,r.width,r.height);if(r.holding==false){if((r.canvas.canvas.width!=r.width)||(r.canvas.canvas.height!=r.height)){r.canvas.canvas.width=r.width;r.canvas.canvas.height=r.height;if(r.onScreenSizeChange!=null){r.onScreenSizeChange(r,r.ScreenWidth,r.ScreenHeight)}}r.Send(String.fromCharCode(3,0,0,0,0,0)+ShortToStr(r.width)+ShortToStr(r.height))}else{r.UnGrabMouseInput();r.UnGrabKeyInput()}};function g(t,u,v){if(r.holding==true){return}r.canvas.putImageData(t,u,v)}function l(w,t){var u=t<<2;r.spare.data[u]=w&224;r.spare.data[u+1]=(w&28)<<3;r.spare.data[u+2]=b((w&3)<<6)}function j(w,t){var u=t<<2;r.spare.data[u]=(w>>8)&248;r.spare.data[u+1]=(w>>3)&252;r.spare.data[u+2]=(w&31)<<3}function m(A,w,z){var x=(w<<2),y=(A&224),u=((A&28)<<3),t=(b((A&3)<<6));while(--z>=0){r.spare.data[x]=y;r.spare.data[x+1]=u;r.spare.data[x+2]=t;x+=4}}function k(A,w,z){var x=(w<<2),y=((A>>8)&248),u=((A>>3)&252),t=((A&31)<<3);while(--z>=0){r.spare.data[x]=y;r.spare.data[x+1]=u;r.spare.data[x+2]=t;x+=4}}function b(t){return(t>127)?(t+32):t}function h(){if(r.holding==true){return}r.send(String.fromCharCode(3,1,0,0,0,0)+ShortToStr(r.rwidth)+ShortToStr(r.rheight))}r.Start=function(){r.state=0;r.acc="";r.ZRLEfirst=1;r.onKvmDataPending=[];r.onKvmDataAck=-1;r.kvmDataSupported=false;for(var t in r.sparecache){delete r.sparecache[t]}};r.Stop=function(){r.UnGrabMouseInput();r.UnGrabKeyInput();r.parent.Stop()};r.send=function(t){r.parent.send(t)};var o={Pause:19,CapsLock:20,Space:32,Quote:39,Minus:45,NumpadMultiply:42,NumpadAdd:43,PrintScreen:44,Comma:44,NumpadSubtract:45,NumpadDecimal:46,Period:46,Slash:47,NumpadDivide:47,Semicolon:59,Equal:61,OSLeft:91,BracketLeft:91,OSRight:91,Backslash:92,BracketRight:93,ContextMenu:93,Backquote:96,NumLock:144,ScrollLock:145,Backspace:65288,Tab:65289,Enter:65293,NumpadEnter:65293,Escape:65307,Delete:65535,Home:65360,PageUp:65365,PageDown:65366,ArrowLeft:65361,ArrowUp:65362,ArrowRight:65363,ArrowDown:65364,End:65367,Insert:65379,F1:65470,F2:65471,F3:65472,F4:65473,F5:65474,F6:65475,F7:65476,F8:65477,F9:65478,F10:65479,F11:65480,F12:65481,ShiftLeft:65505,ShiftRight:65506,ControlLeft:65507,ControlRight:65508,AltLeft:65513,AltRight:65514,MetaLeft:65511,MetaRight:65512};function n(t){if(t.code.startsWith("Key")&&t.code.length==4){return t.code.charCodeAt(3)+((t.shiftKey==false)?32:0)}if(t.code.startsWith("Digit")&&t.code.length==6){return t.code.charCodeAt(5)}if(t.code.startsWith("Numpad")&&t.code.length==7){return t.code.charCodeAt(6)}return o[t.code]}function c(t,u){if(!u){u=window.event}if(u.code&&(r.localKeyMap==false)){var v=n(u);if(v!=null){r.sendkey(v,t)}}else{var v=u.keyCode,w=v;if(u.shiftKey==false&&v>=65&&v<=90){w=v+32}if(v>=112&&v<=124){w=v+65358}if(v==8){w=65288}if(v==9){w=65289}if(v==13){w=65293}if(v==16){w=65505}if(v==17){w=65507}if(v==18){w=65513}if(v==27){w=65307}if(v==33){w=65365}if(v==34){w=65366}if(v==35){w=65367}if(v==36){w=65360}if(v==37){w=65361}if(v==38){w=65362}if(v==39){w=65363}if(v==40){w=65364}if(v==45){w=65379}if(v==46){w=65535}if(v>=96&&v<=105){w=v-48}if(v==106){w=42}if(v==107){w=43}if(v==109){w=45}if(v==110){w=46}if(v==111){w=47}if(v==186){w=59}if(v==187){w=61}if(v==188){w=44}if(v==189){w=45}if(v==190){w=46}if(v==191){w=47}if(v==192){w=96}if(v==219){w=91}if(v==220){w=92}if(v==221){w=93}if(v==222){w=39}r.sendkey(w,t)}return r.haltEvent(u)}r.sendkey=function(v,t){if(typeof v=="object"){for(var u in v){r.sendkey(v[u][0],v[u][1])}}else{r.send(String.fromCharCode(4,t,0,0)+IntToStr(v))}};function q(t){if(t.length<8){return 0}var v=ReadInt(r.acc,4)+8;if(t.length<v){return 0}if(r.onKvmData!=null){var u=t.substring(8,v);if((u.length>=16)&&(u.substring(0,15)=="\0KvmDataChannel")){if(r.kvmDataSupported==false){r.kvmDataSupported=true;console.log("KVM Data Channel Supported.")}if(((r.onKvmDataAck==-1)&&(u.length==16))||(u.charCodeAt(15)!=0)){r.onKvmDataAck=true}if(u.length>=16){r.onKvmData(u.substring(16))}if((r.onKvmDataAck==true)&&(r.onKvmDataPending.length>0)){r.sendKvmData(r.onKvmDataPending.shift())}}}return v}r.sendKvmData=function(t){if(r.onKvmDataAck!==true){r.onKvmDataPending.push(t)}else{t="\0KvmDataChannel\0"+t;r.send(String.fromCharCode(6,0,0,0)+IntToStr(t.length)+t);r.onKvmDataAck=false}};r.sendKeepAlive=function(){if(r.lastKeepAlive<Date.now()-5000){r.lastKeepAlive=Date.now();r.send(String.fromCharCode(6,0,0,0)+IntToStr(16)+"\0KvmDataChannel\0")}};r.SendCtrlAltDelMsg=function(){r.sendcad()};r.sendcad=function(){r.sendkey([[65507,1],[65513,1],[65535,1],[65535,0],[65513,0],[65507,0]])};var e=false;var d=false;r.GrabMouseInput=function(){if(e==true){return}var t=r.canvas.canvas;t.onmouseup=r.mouseup;t.onmousedown=r.mousedown;t.onmousemove=r.mousemove;e=true};r.UnGrabMouseInput=function(){if(e==false){return}var t=r.canvas.canvas;t.onmousemove=null;t.onmouseup=null;t.onmousedown=null;e=false};r.GrabKeyInput=function(){if(d==true){return}document.onkeyup=r.handleKeyUp;document.onkeydown=r.handleKeyDown;document.onkeypress=r.handleKeys;d=true};r.UnGrabKeyInput=function(){if(d==false){return}document.onkeyup=null;document.onkeydown=null;document.onkeypress=null;d=false};r.handleKeys=function(t){return r.haltEvent(t)};r.handleKeyUp=function(t){return c(0,t)};r.handleKeyDown=function(t){return c(1,t)};r.haltEvent=function(t){if(t.preventDefault){t.preventDefault()}if(t.stopPropagation){t.stopPropagation()}return false};r.mousedblclick=function(t){};r.mousedown=function(t){r.buttonmask|=(1<<t.button);return r.mousemove(t,1)};r.mouseup=function(t){r.buttonmask&=(65535-(1<<t.button));return r.mousemove(t,1)};r.mousemove=function(t,u){if(r.state<4){return true}var w=(r.canvas.canvas.height/Q(r.canvasid).offsetHeight);var x=(r.canvas.canvas.width/Q(r.canvasid).offsetWidth);var v=r.getPositionOfControl(Q(r.canvasid));r.mx=((event.pageX-v[0])*x);r.my=((event.pageY-v[1])*w);if(event.addx){r.mx+=event.addx}if(event.addy){r.my+=event.addy}if(u==1){r.send(String.fromCharCode(5,r.buttonmask)+ShortToStr(r.mx)+ShortToStr(r.my));if(r.mNagleTimer!=null){clearTimeout(r.mNagleTimer);r.mNagleTimer=null}}else{if(r.mNagleTimer==null){r.mNagleTimer=setTimeout(function(){r.send(String.fromCharCode(5,r.buttonmask)+ShortToStr(r.mx)+ShortToStr(r.my));r.mNagleTimer=null},50)}}return r.haltEvent(t)};r.getPositionOfControl=function(t){var u=Array(2);u[0]=u[1]=0;while(t){u[0]+=t.offsetLeft;u[1]+=t.offsetTop;t=t.offsetParent}return u};return r};var CreateAmtRemoteTerminal=function(J,L){var K={};K.DivId=J;K.DivElement=document.getElementById(J);K.protocol=1;if(L.protocol){K.protocol=L.protocol}K.fxEmulation=0;K.lineFeed="\r\n";K.debugmode=0;K.width=80;K.height=25;K.heightLock=0;var x=21;var y=13;var s=["000000","BB0000","00BB00","BBBB00","0000BB","BB00BB","00BBBB","BBBBBB","555555","FF5555","55FF55","FFFF55","5555FF","FF55FF","55FFFF","FFFFFF"];var v=0;var u=7;var t=0;var z=true;var E=0;var F=0;var B=0;var C=0;var D=0;var h=[];var k=0;var j=0;var q=[];var G=[];var I=1;var H=2;var b=false;var c=true;var r;var a=false;var M=[];K.title=null;K.onTitleChange=null;K.Start=function(){};K.Init=function(O,N){K.width=O?O:80;K.height=N?N:25;for(var R=0;R<K.height;R++){G[R]=[];q[R]=[];for(var P=0;P<K.width;P++){G[R][P]=" ";q[R][P]=(7<<6)}}K.TermInit();K.TermDraw()};K.xxStateChange=function(N){if((N==3)&&(L!=null)&&(L.xterm==true)){K.TermSendKeys("stty rows "+K.height+" cols "+K.width+"\nclear\n")}};K.ProcessData=function(N){if(K.debugmode==2){console.log("TRecv("+N.length+"): "+rstr2hex(N))}if(K.capture!=null){K.capture+=N}o(N);K.TermDraw()};function o(O){for(var N=0;N<O.length;N++){n(String.fromCharCode(O.charCodeAt(N)),O.charCodeAt(N))}}function n(N,P){switch(D){case 0:switch(P){case 27:D=1;h=[];k=0;j=0;break;default:m(N);break}break;case 1:switch(N){case"[":D=2;break;case"(":D=4;break;case")":D=5;break;case"]":D=6;break;case"=":a=true;D=0;break;case">":a=false;D=0;break;case"7":B=E;C=F;D=0;break;case"8":E=B;F=C;D=0;break;case"M":var R=1;for(var S=r[1];S>=r[0]+R;S--){for(var T=0;T<K.width;T++){G[S][T]=G[S-R][T];q[S][T]=q[S-R][T]}}for(var S=r[0]+R-1;S>r[0]-1;S--){for(var T=0;T<K.width;T++){G[S][T]=" ";q[S][T]=(7<<6)}}D=0;break;default:console.log("unknown terminal short code",N);D=0;break}break;case 2:if(N>="0"&&N<="9"){if(!h[k]){h[k]=(N-"0")}else{h[k]=((h[k]*10)+(N-"0"))}break}else{if(N==";"){k++;break}else{if(N=="?"){j=1;break}else{if(!h[0]){h[0]=0}l(N,h,k+1,j);D=0}}}break;case 4:D=0;break;case 5:D=0;break;case 6:var O=N.charCodeAt(0);if(N==";"){k++}else{if(O==7){p(h);D=0}else{if(!h[k]){h[k]=N}else{h[k]+=N}}}break}}function p(N){if(N.length==0){return}var O=parseInt(N[0]);if((O==0||O==2)&&(N.length>1)&&(N[1]!="?")){if(K.onTitleChange){K.onTitleChange(K,K.title=N[1])}}}function l(R,N,O,U){if(U==1){switch(R){case"l":if(N[0]==25){c=false}break;case"h":if(N[0]==25){c=true}break}}else{if(U==0){var S;switch(R){case"c":K.TermResetScreen();break;case"A":if(O==1){if(N[0]==0){F--}else{F-=N[0]}if(F<0){F=0}}break;case"B":if(O==1){if(N[0]==0){F++}else{F+=N[0]}if(F>K.height){F=K.height}}break;case"C":if(O==1){if(N[0]==0){E++}else{E+=N[0]}if(E>K.width){E=K.width}}break;case"D":if(O==1){if(N[0]==0){E--}else{E-=N[0]}if(E<0){E=0}}break;case"d":if(O==1){F=N[0]-1;if(F>K.height){F=K.height}if(F<0){F=0}}break;case"G":if(O==1){E=N[0]-1;if(E<0){E=0}if(E>(K.width-1)){E=(K.width-1)}}break;case"P":var V=1;if(O==1){V=N[0]}for(S=E;S<K.width-V;S++){G[F][S]=G[F][S+V];q[F][S]=q[F][S+V]}for(S=(K.width-V);S<K.width;S++){G[F][S]=" ";q[F][S]=(7<<6)}break;case"L":var T=1;if(O==1){T=N[0]}if(T==0){T=1}for(W=r[1];W>=F+T;W--){G[W]=G[W-T];q[W]=q[W-T]}for(W=F;W<F+T;W++){G[W]=[];q[W]=[];for(V=0;V<K.width;V++){G[W][V]=" ";q[W][V]=(7<<6)}}break;case"J":if(O==1&&N[0]==2){K.TermClear((t<<12)+(u<<6));E=0;F=0;M=[]}else{if(O==0||O==1&&N[0]==0){e();for(S=F+1;S<K.height;S++){g(S)}}else{if(O==1&&N[0]==1){e();for(S=0;S<F-1;S++){g(S)}}}}break;case"H":if(O==2){if(N[0]<1){N[0]=1}if(N[1]<1){N[1]=1}if(N[0]>K.height){N[0]=K.height}if(N[1]>K.width){N[1]=K.width}F=N[0]-1;E=N[1]-1}else{F=0;E=0}break;case"m":for(S=0;S<O;S++){if(!N[S]||N[S]==0){t=0;u=7;v=0}else{if(N[S]==1){if(u<8){u+=8}}else{if(N[S]==2||N[S]==22){if(u>=8){u-=8}}else{if(N[S]==7){v=2}else{if(N[S]==27){v=0}else{if(N[S]>=30&&N[S]<=37){var P=(u>=8);u=(N[S]-30);if(P&&u<=8){u+=8}}else{if(N[S]>=40&&N[S]<=47){t=(N[S]-40)}else{if(N[S]>=90&&N[S]<=99){u=(N[S]-82)}else{if(N[S]>=100&&N[S]<=109){t=(N[S]-92)}}}}}}}}}}break;case"K":if(O==0||(O==1&&(!N[0]||N[0]==0))){e()}else{if(O==1){if(N[0]==1){d()}else{if(N[0]==2){g(F)}}}}break;case"h":z=true;break;case"l":z=false;break;case"r":if(O==2){r=[N[0]-1,N[1]-1]}if(r[0]<0){r[0]=0}if(r[0]>(K.height-1)){r[0]=(K.height-1)}if(r[1]<0){r[1]=0}if(r[1]>(K.height-1)){r[1]=(K.height-1)}if(r[0]>r[1]){r[0]=r[1]}break;case"S":var V=1;if(O==1){V=N[0]}for(var W=r[0];W<=r[1]-V;W++){for(var X=0;X<K.width;X++){G[W][X]=G[W+V][X];q[W][X]=q[W+V][X]}}for(var W=r[1]-V+1;W<r[1];W++){for(var X=0;X<K.width;X++){G[W][X]=" ";q[W][X]=(7<<6)}}break;case"M":var V=1;if(O==1){V=N[0]}for(var W=F;W<=r[1]-V;W++){for(var X=0;X<K.width;X++){G[W][X]=G[W+V][X];q[W][X]=q[W+V][X]}}for(var W=r[1]-V+1;W<r[1];W++){for(var X=0;X<K.width;X++){G[W][X]=" ";q[W][X]=(7<<6)}}break;case"T":var V=1;if(O==1){V=N[0]}for(var W=r[1];W>r[0]+V;W--){for(var X=0;X<K.width;X++){G[W][X]=G[W-V][X];q[W][X]=q[W-V][X]}}for(var W=r[0]+V;W>r[0];W--){for(var X=0;X<K.width;X++){G[W][X]=" ";q[W][X]=(7<<6)}}break;case"X":var V=1;if(O==1){V=N[0]}while((V>0)&&(E>0)){G[F][E]=" ";E--;V--}break;default:console.log("unknown terminal code",R,N,U);break}}}}K.ProcessVt100String=function(O){for(var N=0;N<O.length;N++){m(String.fromCharCode(O.charCodeAt(N)))}};function m(N){if(N=="\0"||N.charCodeAt()==7){return}var O=N.charCodeAt();switch(O){case 16:N=" ";break;case 24:N="?";break;case 25:N="?";break}if(E>K.width){E=K.width}if(F>(K.height-1)){F=(K.height-1)}switch(N){case"\b":if(E>0){E--;if(b){w(" ")}}break;case"\t":var P=8-(E%8);for(var R=0;R<P;R++){m(" ")}break;case"\n":F++;if(F>r[1]){K.recordLineTobackBuffer(0);A(1);F=r[1]}if(K.lineFeed="\r"){E=0}break;case"\r":E=0;break;default:if(E>=K.width){E=0;if(z){F++}if(F>=(K.height-1)){A(1);F=(K.height-1)}}w(N);E++;break}}function w(N){G[F][E]=N;q[F][E]=(u<<6)+(t<<12)+v}K.TermClear=function(N){for(var P=0;P<K.height;P++){for(var O=0;O<K.width;O++){G[P][O]=" ";q[P][O]=N}}M=[]};K.TermResetScreen=function(){v=0;u=7;t=0;z=c=true;E=F=0;b=false;r=[0,(K.height-1)];a=false;K.TermClear(7<<6)};function e(){var N=(u<<6)+(t<<12)+v;for(var O=E;O<K.width;O++){G[F][O]=" ";q[F][O]=N}}function d(){var N=(u<<6)+(t<<12)+v;for(var O=0;O<E;O++){G[F][O]=" ";q[F][O]=N}}function g(N){var O=(u<<6)+(t<<12)+v;for(var P=0;P<K.width;P++){G[N][P]=" ";q[N][P]=O}}K.TermSendKeys=function(N){if(K.debugmode==2){console.log("TSend("+N.length+"): "+rstr2hex(N),N)}K.parent.send(N)};K.TermSendKey=function(N){if(K.debugmode==2){console.log("TSend(1): "+rstr2hex(String.fromCharCode(N)),N)}K.parent.send(String.fromCharCode(N))};function A(N){var O,P;for(P=r[0];P<=r[1]-N;P++){G[P]=G[P+N];q[P]=q[P+N]}for(P=r[1]-N+1;P<=r[1];P++){G[P]=[];q[P]=[];for(O=0;O<K.width;O++){G[P][O]=" ";q[P][O]=(7<<6)}}}K.TermHandleKeys=function(N){if(!N.ctrlKey){if(N.which==127){K.TermSendKey(8)}else{if(N.which==13){K.TermSendKeys(K.lineFeed)}else{if(N.which!=0){K.TermSendKey(N.which)}}}return false}if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}};K.TermHandleKeyUp=function(N){if((N.which!=8)&&(N.which!=32)&&(N.which!=9)){return true}if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}return false};K.TermHandleKeyDown=function(N){if((N.which>=65)&&(N.which<=90)&&(N.ctrlKey==true)){K.TermSendKey(N.which-64);if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}return}if(N.which==27){K.TermSendKeys(String.fromCharCode(27));return true}if(a==true){if(N.which==37){K.TermSendKeys(String.fromCharCode(27,79,68));return true}if(N.which==38){K.TermSendKeys(String.fromCharCode(27,79,65));return true}if(N.which==39){K.TermSendKeys(String.fromCharCode(27,79,67));return true}if(N.which==40){K.TermSendKeys(String.fromCharCode(27,79,66));return true}}else{if(N.which==37){K.TermSendKeys(String.fromCharCode(27,91,68));return true}if(N.which==38){K.TermSendKeys(String.fromCharCode(27,91,65));return true}if(N.which==39){K.TermSendKeys(String.fromCharCode(27,91,67));return true}if(N.which==40){K.TermSendKeys(String.fromCharCode(27,91,66));return true}}if(N.which==33){K.TermSendKeys(String.fromCharCode(27,91,53,126));return true}if(N.which==34){K.TermSendKeys(String.fromCharCode(27,91,54,126));return true}if(N.which==35){K.TermSendKeys(String.fromCharCode(27,91,70));return true}if(N.which==36){K.TermSendKeys(String.fromCharCode(27,91,72));return true}if(N.which==45){K.TermSendKeys(String.fromCharCode(27,91,50,126));return true}if(N.which==46){K.TermSendKeys(String.fromCharCode(27,91,51,126));return true}if(N.which==9){K.TermSendKeys("\t");if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}return true}if(N.which!=8&&N.which!=32&&N.which!=9){return true}K.TermSendKey(N.which);if(N.preventDefault){N.preventDefault()}if(N.stopPropagation){N.stopPropagation()}return false};K.recordLineTobackBuffer=function(R){var O="",N="";var P=K.TermDrawLine(N,R,O);N=P[0];O=P[1];M.push(N+O+"<br>")};K.TermDrawLine=function(N,W,P){var R,O,S=1,U,V;for(var T=0;T<K.width;++T){R=q[W][T];if(E==T&&F==W&&c){R|=H}if(R!=S){N+=P;P="";U=6;V=12;if(R&H){U=12;V=6}N+='<span style="color:#'+s[(R>>U)&63]+";background-color:#"+s[(R>>V)&63];if(R&I){N+=";text-decoration:underline"}N+=';">';P="</span>"+P;S=R}O=G[W][T];switch(O){case"&":N+="&amp;";break;case"<":N+="&lt;";break;case">":N+="&gt;";break;case" ":N+="&nbsp;";break;default:N+=O;break}}return[N,P]};K.TermDraw=function(){var P="",O="";for(var S=0;S<K.height;++S){var R=K.TermDrawLine(O,S,P);O=R[0];P=R[1];if(S!=(K.height-1)){O+="<br>"}}if(M.length>800){M=M.slice(M.length-800)}var N=M.join("");K.DivElement.innerHTML="<font size='4'><b>"+N+O+P+"</b></font>";K.DivElement.scrollTop=K.DivElement.scrollHeight;if(K.heightLock==0){setTimeout(K.TermLockHeight,10)}};K.TermLockHeight=function(){K.heightLock=K.DivElement.clientHeight;K.DivElement.style.height=K.DivElement.parentNode.style.height=K.heightLock+"px";K.DivElement.style["overflow-y"]="scroll"};K.TermInit=function(){K.TermResetScreen()};K.heightLock=0;K.DivElement.style.height="";if((L!=null)&&(L.width!=null)&&(L.height!=null)){K.Init(L.width,L.height)}else{K.Init()}return K};var ZLIB=(ZLIB||{});if(typeof ZLIB.common_initialized==="undefined"){ZLIB.Z_NO_FLUSH=0;ZLIB.Z_PARTIAL_FLUSH=1;ZLIB.Z_SYNC_FLUSH=2;ZLIB.Z_FULL_FLUSH=3;ZLIB.Z_FINISH=4;ZLIB.Z_BLOCK=5;ZLIB.Z_TREES=6;ZLIB.Z_OK=0;ZLIB.Z_STREAM_END=1;ZLIB.Z_NEED_DICT=2;ZLIB.Z_ERRNO=(-1);ZLIB.Z_STREAM_ERROR=(-2);ZLIB.Z_DATA_ERROR=(-3);ZLIB.Z_MEM_ERROR=(-4);ZLIB.Z_BUF_ERROR=(-5);ZLIB.Z_VERSION_ERROR=(-6);ZLIB.Z_DEFLATED=8;ZLIB.z_stream=function(){this.next_in=0;this.avail_in=0;this.total_in=0;this.next_out=0;this.avail_out=0;this.total_out=0;this.msg=null;this.state=null;this.data_type=0;this.adler=0;this.input_data="";this.output_data="";this.error=0;this.checksum_function=null};ZLIB.gz_header=function(){this.text=0;this.time=0;this.xflags=0;this.os=255;this.extra=null;this.extra_len=0;this.extra_max=0;this.name=null;this.name_max=0;this.comment=null;this.comm_max=0;this.hcrc=0;this.done=0};ZLIB.common_initialized=true}if(typeof ZLIB==="undefined"){alert("ZLIB is not defined. SRC zlib.js before zlib-inflate.js")}(function(){var o=15;var G=0;var D=1;var am=2;var af=3;var A=4;var B=5;var ac=6;var j=7;var F=8;var q=9;var p=10;var an=11;var ao=12;var aj=13;var l=14;var k=15;var al=16;var W=17;var g=18;var S=19;var R=20;var T=21;var r=22;var s=23;var aa=24;var Y=25;var d=26;var V=27;var v=28;var a=29;var ab=30;var ak=31;var z=852;var y=592;var x=(z+y);var h=0;var X=1;var u=2;var N=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0];var O=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,203,69];var L=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0];var M=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];ZLIB.inflate_copyright=" inflate 1.2.6 Copyright 1995-2012 Mark Adler ";function K(aR,aV){var aM=15;var aU=aR.next;var at=(aV==u?aR.distbits:aR.lenbits);var aX=aR.work;var aH=aR.lens;var aI=(aV==u?aR.nlen:0);var aS=aR.codes;var au;if(aV==X){au=aR.nlen}else{if(aV==u){au=aR.ndist}else{au=19}}var aG;var aT;var aN,aL;var aQ;var aw;var ax;var aF;var aW;var aD;var aE;var aB;var aJ;var aK;var aC;var aO;var aq;var ar;var az;var aA;var ay;var av=new Array(aM+1);var aP=new Array(aM+1);for(aG=0;aG<=aM;aG++){av[aG]=0}for(aT=0;aT<au;aT++){av[aH[aI+aT]]++}aQ=at;for(aL=aM;aL>=1;aL--){if(av[aL]!=0){break}}if(aQ>aL){aQ=aL}if(aL==0){aC={op:64,bits:1,val:0};aS[aU++]=aC;aS[aU++]=aC;if(aV==u){aR.distbits=1}else{aR.lenbits=1}aR.next=aU;return 0}for(aN=1;aN<aL;aN++){if(av[aN]!=0){break}}if(aQ<aN){aQ=aN}aF=1;for(aG=1;aG<=aM;aG++){aF<<=1;aF-=av[aG];if(aF<0){return -1}}if(aF>0&&(aV==h||aL!=1)){aR.next=aU;return -1}aP[1]=0;for(aG=1;aG<aM;aG++){aP[aG+1]=aP[aG]+av[aG]}for(aT=0;aT<au;aT++){if(aH[aI+aT]!=0){aX[aP[aH[aI+aT]]++]=aT}}switch(aV){case h:aq=az=aX;ar=0;aA=0;ay=19;break;case X:aq=N;ar=-257;az=O;aA=-257;ay=256;break;default:aq=L;az=M;ar=0;aA=0;ay=-1}aD=0;aT=0;aG=aN;aO=aU;aw=aQ;ax=0;aJ=-1;aW=1<<aQ;aK=aW-1;if((aV==X&&aW>=z)||(aV==u&&aW>=y)){aR.next=aU;return 1}for(;;){aC={op:0,bits:aG-ax,val:0};if(aX[aT]<ay){aC.val=aX[aT]}else{if(aX[aT]>ay){aC.op=az[aA+aX[aT]];aC.val=aq[ar+aX[aT]]}else{aC.op=32+64}}aE=1<<(aG-ax);aB=1<<aw;aN=aB;do{aB-=aE;aS[aO+(aD>>>ax)+aB]=aC}while(aB!=0);aE=1<<(aG-1);while(aD&aE){aE>>>=1}if(aE!=0){aD&=aE-1;aD+=aE}else{aD=0}aT++;if(--(av[aG])==0){if(aG==aL){break}aG=aH[aI+aX[aT]]}if(aG>aQ&&(aD&aK)!=aJ){if(ax==0){ax=aQ}aO+=aN;aw=aG-ax;aF=(1<<aw);while(aw+ax<aL){aF-=av[aw+ax];if(aF<=0){break}aw++;aF<<=1}aW+=1<<aw;if((aV==X&&aW>=z)||(aV==u&&aW>=y)){aR.next=aU;return 1}aJ=aD&aK;aS[aU+aJ]={op:aw,bits:aQ,val:aO-aU}}}if(aD!=0){aS[aO+aD]={op:64,bits:aG-ax,val:0}}aR.next=aU+aW;if(aV==u){aR.distbits=aQ}else{aR.lenbits=aQ}return 0}function H(aN,aL){var aM;var aC;var aI;var aD;var aK;var aq;var ax;var aR;var aO;var aQ;var aP;var aB;var ar;var at;var aE;var au;var aH;var aw;var aA;var aJ;var aF;var av;var az=-1;var ay=-1;aM=aN.state;aC=aN.input_data;aI=aN.next_in;aD=aI+aN.avail_in-5;aK=aN.next_out;aq=aK-(aL-aN.avail_out);ax=aK+(aN.avail_out-257);aR=aM.wsize;aO=aM.whave;aQ=aM.wnext;aP=aM.window;aB=aM.hold;ar=aM.bits;at=aM.codes;aE=aM.lencode;au=aM.distcode;aH=(1<<aM.lenbits)-1;aw=(1<<aM.distbits)-1;loop:do{if(ar<15){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8;aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8}aA=at[aE+(aB&aH)];dolen:while(true){aJ=aA.bits;aB>>>=aJ;ar-=aJ;aJ=aA.op;if(aJ==0){aN.output_data+=String.fromCharCode(aA.val);aK++}else{if(aJ&16){aF=aA.val;aJ&=15;if(aJ){if(ar<aJ){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8}aF+=aB&((1<<aJ)-1);aB>>>=aJ;ar-=aJ}if(ar<15){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8;aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8}aA=at[au+(aB&aw)];dodist:while(true){aJ=aA.bits;aB>>>=aJ;ar-=aJ;aJ=aA.op;if(aJ&16){av=aA.val;aJ&=15;if(ar<aJ){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8;if(ar<aJ){aB+=(aC.charCodeAt(aI++)&255)<<ar;ar+=8}}av+=aB&((1<<aJ)-1);aB>>>=aJ;ar-=aJ;aJ=aK-aq;if(av>aJ){aJ=av-aJ;if(aJ>aO){if(aM.sane){aN.msg="invalid distance too far back";aM.mode=a;break loop}}az=0;ay=-1;if(aQ==0){az+=aR-aJ;if(aJ<aF){aF-=aJ;aN.output_data+=aP.substring(az,az+aJ);aK+=aJ;aJ=0;az=-1;ay=aK-av}}else{az+=aQ-aJ;if(aJ<aF){aF-=aJ;aN.output_data+=aP.substring(az,az+aJ);aK+=aJ;az=-1;ay=aK-av}}}else{az=-1;ay=aK-av}if(az>=0){aN.output_data+=aP.substring(az,az+aF);aK+=aF;az+=aF}else{var aG=aF;if(aG>aK-ay){aG=aK-ay}aN.output_data+=aN.output_data.substring(ay,ay+aG);aK+=aG;aF-=aG;ay+=aG;aK+=aF;while(aF>2){aN.output_data+=aN.output_data.charAt(ay++);aN.output_data+=aN.output_data.charAt(ay++);aN.output_data+=aN.output_data.charAt(ay++);aF-=3}if(aF){aN.output_data+=aN.output_data.charAt(ay++);if(aF>1){aN.output_data+=aN.output_data.charAt(ay++)}}}}else{if((aJ&64)==0){aA=at[au+(aA.val+(aB&((1<<aJ)-1)))];continue dodist}else{aN.msg="invalid distance code";aM.mode=a;break loop}}break dodist}}else{if((aJ&64)==0){aA=at[aE+(aA.val+(aB&((1<<aJ)-1)))];continue dolen}else{if(aJ&32){aM.mode=an;break loop}else{aN.msg="invalid literal/length code";aM.mode=a;break loop}}}}break dolen}}while(aI<aD&&aK<ax);aF=ar>>>3;aI-=aF;ar-=aF<<3;aB&=(1<<ar)-1;aN.next_in=aI;aN.next_out=aK;aN.avail_in=(aI<aD?5+(aD-aI):5-(aI-aD));aN.avail_out=(aK<ax?257+(ax-aK):257-(aK-ax));aM.hold=aB;aM.bits=ar}function ae(at){var ar;var aq=new Array(at);for(ar=0;ar<at;ar++){aq[ar]=0}return aq}function E(at,ar,aq){return(at&&(ar in at))?at[ar]:aq}function e(){return 0}function J(){var ar;this.mode=0;this.last=0;this.wrap=0;this.havedict=0;this.flags=0;this.dmax=0;this.check=0;this.total=0;this.head=null;this.wbits=0;this.wsize=0;this.whave=0;this.wnext=0;this.window=null;this.hold=0;this.bits=0;this.length=0;this.offset=0;this.extra=0;this.lencode=0;this.distcode=0;this.lenbits=0;this.distbits=0;this.ncode=0;this.nlen=0;this.ndist=0;this.have=0;this.next=0;this.lens=ae(320);this.work=ae(288);this.codes=new Array(x);var aq={op:0,bits:0,val:0};for(ar=0;ar<x;ar++){this.codes[ar]=aq}this.sane=0;this.back=0;this.was=0}ZLIB.inflateResetKeep=function(ar){var aq;if(!ar||!ar.state){return ZLIB.Z_STREAM_ERROR}aq=ar.state;ar.total_in=ar.total_out=aq.total=0;ar.msg=null;if(aq.wrap){ar.adler=aq.wrap&1}aq.mode=G;aq.last=0;aq.havedict=0;aq.dmax=32768;aq.head=null;aq.hold=0;aq.bits=0;aq.lencode=0;aq.distcode=0;aq.next=0;aq.sane=1;aq.back=-1;return ZLIB.Z_OK};ZLIB.inflateReset=function(ar,at){var au;var aq;if(!ar||!ar.state){return ZLIB.Z_STREAM_ERROR}aq=ar.state;if(typeof at==="undefined"){at=o}if(at<0){au=0;at=-at}else{au=(at>>>4)+1;if(at<48){at&=15}}if(au==1&&(typeof ZLIB.adler32==="function")){ar.checksum_function=ZLIB.adler32}else{if(au==2&&(typeof ZLIB.crc32==="function")){ar.checksum_function=ZLIB.crc32}else{ar.checksum_function=e}}if(at&&(at<8||at>15)){return ZLIB.Z_STREAM_ERROR}if(aq.window&&aq.wbits!=at){aq.window=null}aq.wrap=au;aq.wbits=at;aq.wsize=0;aq.whave=0;aq.wnext=0;return ZLIB.inflateResetKeep(ar)};ZLIB.inflateInit=function(ar){var aq=new ZLIB.z_stream();aq.state=new J();ZLIB.inflateReset(aq,ar);return aq};ZLIB.inflatePrime=function(at,aq,au){var ar;if(!at||!at.state){return ZLIB.Z_STREAM_ERROR}ar=at.state;if(aq<0){ar.hold=0;ar.bits=0;return ZLIB.Z_OK}if(aq>16||ar.bits+aq>32){return ZLIB.Z_STREAM_ERROR}au&=(1<<aq)-1;ar.hold+=au<<ar.bits;ar.bits+=aq;return ZLIB.Z_OK};var U=null;var t=null;function C(ar){var aq;if(!U){U=[{op:96,bits:7,val:0},{op:0,bits:8,val:80},{op:0,bits:8,val:16},{op:20,bits:8,val:115},{op:18,bits:7,val:31},{op:0,bits:8,val:112},{op:0,bits:8,val:48},{op:0,bits:9,val:192},{op:16,bits:7,val:10},{op:0,bits:8,val:96},{op:0,bits:8,val:32},{op:0,bits:9,val:160},{op:0,bits:8,val:0},{op:0,bits:8,val:128},{op:0,bits:8,val:64},{op:0,bits:9,val:224},{op:16,bits:7,val:6},{op:0,bits:8,val:88},{op:0,bits:8,val:24},{op:0,bits:9,val:144},{op:19,bits:7,val:59},{op:0,bits:8,val:120},{op:0,bits:8,val:56},{op:0,bits:9,val:208},{op:17,bits:7,val:17},{op:0,bits:8,val:104},{op:0,bits:8,val:40},{op:0,bits:9,val:176},{op:0,bits:8,val:8},{op:0,bits:8,val:136},{op:0,bits:8,val:72},{op:0,bits:9,val:240},{op:16,bits:7,val:4},{op:0,bits:8,val:84},{op:0,bits:8,val:20},{op:21,bits:8,val:227},{op:19,bits:7,val:43},{op:0,bits:8,val:116},{op:0,bits:8,val:52},{op:0,bits:9,val:200},{op:17,bits:7,val:13},{op:0,bits:8,val:100},{op:0,bits:8,val:36},{op:0,bits:9,val:168},{op:0,bits:8,val:4},{op:0,bits:8,val:132},{op:0,bits:8,val:68},{op:0,bits:9,val:232},{op:16,bits:7,val:8},{op:0,bits:8,val:92},{op:0,bits:8,val:28},{op:0,bits:9,val:152},{op:20,bits:7,val:83},{op:0,bits:8,val:124},{op:0,bits:8,val:60},{op:0,bits:9,val:216},{op:18,bits:7,val:23},{op:0,bits:8,val:108},{op:0,bits:8,val:44},{op:0,bits:9,val:184},{op:0,bits:8,val:12},{op:0,bits:8,val:140},{op:0,bits:8,val:76},{op:0,bits:9,val:248},{op:16,bits:7,val:3},{op:0,bits:8,val:82},{op:0,bits:8,val:18},{op:21,bits:8,val:163},{op:19,bits:7,val:35},{op:0,bits:8,val:114},{op:0,bits:8,val:50},{op:0,bits:9,val:196},{op:17,bits:7,val:11},{op:0,bits:8,val:98},{op:0,bits:8,val:34},{op:0,bits:9,val:164},{op:0,bits:8,val:2},{op:0,bits:8,val:130},{op:0,bits:8,val:66},{op:0,bits:9,val:228},{op:16,bits:7,val:7},{op:0,bits:8,val:90},{op:0,bits:8,val:26},{op:0,bits:9,val:148},{op:20,bits:7,val:67},{op:0,bits:8,val:122},{op:0,bits:8,val:58},{op:0,bits:9,val:212},{op:18,bits:7,val:19},{op:0,bits:8,val:106},{op:0,bits:8,val:42},{op:0,bits:9,val:180},{op:0,bits:8,val:10},{op:0,bits:8,val:138},{op:0,bits:8,val:74},{op:0,bits:9,val:244},{op:16,bits:7,val:5},{op:0,bits:8,val:86},{op:0,bits:8,val:22},{op:64,bits:8,val:0},{op:19,bits:7,val:51},{op:0,bits:8,val:118},{op:0,bits:8,val:54},{op:0,bits:9,val:204},{op:17,bits:7,val:15},{op:0,bits:8,val:102},{op:0,bits:8,val:38},{op:0,bits:9,val:172},{op:0,bits:8,val:6},{op:0,bits:8,val:134},{op:0,bits:8,val:70},{op:0,bits:9,val:236},{op:16,bits:7,val:9},{op:0,bits:8,val:94},{op:0,bits:8,val:30},{op:0,bits:9,val:156},{op:20,bits:7,val:99},{op:0,bits:8,val:126},{op:0,bits:8,val:62},{op:0,bits:9,val:220},{op:18,bits:7,val:27},{op:0,bits:8,val:110},{op:0,bits:8,val:46},{op:0,bits:9,val:188},{op:0,bits:8,val:14},{op:0,bits:8,val:142},{op:0,bits:8,val:78},{op:0,bits:9,val:252},{op:96,bits:7,val:0},{op:0,bits:8,val:81},{op:0,bits:8,val:17},{op:21,bits:8,val:131},{op:18,bits:7,val:31},{op:0,bits:8,val:113},{op:0,bits:8,val:49},{op:0,bits:9,val:194},{op:16,bits:7,val:10},{op:0,bits:8,val:97},{op:0,bits:8,val:33},{op:0,bits:9,val:162},{op:0,bits:8,val:1},{op:0,bits:8,val:129},{op:0,bits:8,val:65},{op:0,bits:9,val:226},{op:16,bits:7,val:6},{op:0,bits:8,val:89},{op:0,bits:8,val:25},{op:0,bits:9,val:146},{op:19,bits:7,val:59},{op:0,bits:8,val:121},{op:0,bits:8,val:57},{op:0,bits:9,val:210},{op:17,bits:7,val:17},{op:0,bits:8,val:105},{op:0,bits:8,val:41},{op:0,bits:9,val:178},{op:0,bits:8,val:9},{op:0,bits:8,val:137},{op:0,bits:8,val:73},{op:0,bits:9,val:242},{op:16,bits:7,val:4},{op:0,bits:8,val:85},{op:0,bits:8,val:21},{op:16,bits:8,val:258},{op:19,bits:7,val:43},{op:0,bits:8,val:117},{op:0,bits:8,val:53},{op:0,bits:9,val:202},{op:17,bits:7,val:13},{op:0,bits:8,val:101},{op:0,bits:8,val:37},{op:0,bits:9,val:170},{op:0,bits:8,val:5},{op:0,bits:8,val:133},{op:0,bits:8,val:69},{op:0,bits:9,val:234},{op:16,bits:7,val:8},{op:0,bits:8,val:93},{op:0,bits:8,val:29},{op:0,bits:9,val:154},{op:20,bits:7,val:83},{op:0,bits:8,val:125},{op:0,bits:8,val:61},{op:0,bits:9,val:218},{op:18,bits:7,val:23},{op:0,bits:8,val:109},{op:0,bits:8,val:45},{op:0,bits:9,val:186},{op:0,bits:8,val:13},{op:0,bits:8,val:141},{op:0,bits:8,val:77},{op:0,bits:9,val:250},{op:16,bits:7,val:3},{op:0,bits:8,val:83},{op:0,bits:8,val:19},{op:21,bits:8,val:195},{op:19,bits:7,val:35},{op:0,bits:8,val:115},{op:0,bits:8,val:51},{op:0,bits:9,val:198},{op:17,bits:7,val:11},{op:0,bits:8,val:99},{op:0,bits:8,val:35},{op:0,bits:9,val:166},{op:0,bits:8,val:3},{op:0,bits:8,val:131},{op:0,bits:8,val:67},{op:0,bits:9,val:230},{op:16,bits:7,val:7},{op:0,bits:8,val:91},{op:0,bits:8,val:27},{op:0,bits:9,val:150},{op:20,bits:7,val:67},{op:0,bits:8,val:123},{op:0,bits:8,val:59},{op:0,bits:9,val:214},{op:18,bits:7,val:19},{op:0,bits:8,val:107},{op:0,bits:8,val:43},{op:0,bits:9,val:182},{op:0,bits:8,val:11},{op:0,bits:8,val:139},{op:0,bits:8,val:75},{op:0,bits:9,val:246},{op:16,bits:7,val:5},{op:0,bits:8,val:87},{op:0,bits:8,val:23},{op:64,bits:8,val:0},{op:19,bits:7,val:51},{op:0,bits:8,val:119},{op:0,bits:8,val:55},{op:0,bits:9,val:206},{op:17,bits:7,val:15},{op:0,bits:8,val:103},{op:0,bits:8,val:39},{op:0,bits:9,val:174},{op:0,bits:8,val:7},{op:0,bits:8,val:135},{op:0,bits:8,val:71},{op:0,bits:9,val:238},{op:16,bits:7,val:9},{op:0,bits:8,val:95},{op:0,bits:8,val:31},{op:0,bits:9,val:158},{op:20,bits:7,val:99},{op:0,bits:8,val:127},{op:0,bits:8,val:63},{op:0,bits:9,val:222},{op:18,bits:7,val:27},{op:0,bits:8,val:111},{op:0,bits:8,val:47},{op:0,bits:9,val:190},{op:0,bits:8,val:15},{op:0,bits:8,val:143},{op:0,bits:8,val:79},{op:0,bits:9,val:254},{op:96,bits:7,val:0},{op:0,bits:8,val:80},{op:0,bits:8,val:16},{op:20,bits:8,val:115},{op:18,bits:7,val:31},{op:0,bits:8,val:112},{op:0,bits:8,val:48},{op:0,bits:9,val:193},{op:16,bits:7,val:10},{op:0,bits:8,val:96},{op:0,bits:8,val:32},{op:0,bits:9,val:161},{op:0,bits:8,val:0},{op:0,bits:8,val:128},{op:0,bits:8,val:64},{op:0,bits:9,val:225},{op:16,bits:7,val:6},{op:0,bits:8,val:88},{op:0,bits:8,val:24},{op:0,bits:9,val:145},{op:19,bits:7,val:59},{op:0,bits:8,val:120},{op:0,bits:8,val:56},{op:0,bits:9,val:209},{op:17,bits:7,val:17},{op:0,bits:8,val:104},{op:0,bits:8,val:40},{op:0,bits:9,val:177},{op:0,bits:8,val:8},{op:0,bits:8,val:136},{op:0,bits:8,val:72},{op:0,bits:9,val:241},{op:16,bits:7,val:4},{op:0,bits:8,val:84},{op:0,bits:8,val:20},{op:21,bits:8,val:227},{op:19,bits:7,val:43},{op:0,bits:8,val:116},{op:0,bits:8,val:52},{op:0,bits:9,val:201},{op:17,bits:7,val:13},{op:0,bits:8,val:100},{op:0,bits:8,val:36},{op:0,bits:9,val:169},{op:0,bits:8,val:4},{op:0,bits:8,val:132},{op:0,bits:8,val:68},{op:0,bits:9,val:233},{op:16,bits:7,val:8},{op:0,bits:8,val:92},{op:0,bits:8,val:28},{op:0,bits:9,val:153},{op:20,bits:7,val:83},{op:0,bits:8,val:124},{op:0,bits:8,val:60},{op:0,bits:9,val:217},{op:18,bits:7,val:23},{op:0,bits:8,val:108},{op:0,bits:8,val:44},{op:0,bits:9,val:185},{op:0,bits:8,val:12},{op:0,bits:8,val:140},{op:0,bits:8,val:76},{op:0,bits:9,val:249},{op:16,bits:7,val:3},{op:0,bits:8,val:82},{op:0,bits:8,val:18},{op:21,bits:8,val:163},{op:19,bits:7,val:35},{op:0,bits:8,val:114},{op:0,bits:8,val:50},{op:0,bits:9,val:197},{op:17,bits:7,val:11},{op:0,bits:8,val:98},{op:0,bits:8,val:34},{op:0,bits:9,val:165},{op:0,bits:8,val:2},{op:0,bits:8,val:130},{op:0,bits:8,val:66},{op:0,bits:9,val:229},{op:16,bits:7,val:7},{op:0,bits:8,val:90},{op:0,bits:8,val:26},{op:0,bits:9,val:149},{op:20,bits:7,val:67},{op:0,bits:8,val:122},{op:0,bits:8,val:58},{op:0,bits:9,val:213},{op:18,bits:7,val:19},{op:0,bits:8,val:106},{op:0,bits:8,val:42},{op:0,bits:9,val:181},{op:0,bits:8,val:10},{op:0,bits:8,val:138},{op:0,bits:8,val:74},{op:0,bits:9,val:245},{op:16,bits:7,val:5},{op:0,bits:8,val:86},{op:0,bits:8,val:22},{op:64,bits:8,val:0},{op:19,bits:7,val:51},{op:0,bits:8,val:118},{op:0,bits:8,val:54},{op:0,bits:9,val:205},{op:17,bits:7,val:15},{op:0,bits:8,val:102},{op:0,bits:8,val:38},{op:0,bits:9,val:173},{op:0,bits:8,val:6},{op:0,bits:8,val:134},{op:0,bits:8,val:70},{op:0,bits:9,val:237},{op:16,bits:7,val:9},{op:0,bits:8,val:94},{op:0,bits:8,val:30},{op:0,bits:9,val:157},{op:20,bits:7,val:99},{op:0,bits:8,val:126},{op:0,bits:8,val:62},{op:0,bits:9,val:221},{op:18,bits:7,val:27},{op:0,bits:8,val:110},{op:0,bits:8,val:46},{op:0,bits:9,val:189},{op:0,bits:8,val:14},{op:0,bits:8,val:142},{op:0,bits:8,val:78},{op:0,bits:9,val:253},{op:96,bits:7,val:0},{op:0,bits:8,val:81},{op:0,bits:8,val:17},{op:21,bits:8,val:131},{op:18,bits:7,val:31},{op:0,bits:8,val:113},{op:0,bits:8,val:49},{op:0,bits:9,val:195},{op:16,bits:7,val:10},{op:0,bits:8,val:97},{op:0,bits:8,val:33},{op:0,bits:9,val:163},{op:0,bits:8,val:1},{op:0,bits:8,val:129},{op:0,bits:8,val:65},{op:0,bits:9,val:227},{op:16,bits:7,val:6},{op:0,bits:8,val:89},{op:0,bits:8,val:25},{op:0,bits:9,val:147},{op:19,bits:7,val:59},{op:0,bits:8,val:121},{op:0,bits:8,val:57},{op:0,bits:9,val:211},{op:17,bits:7,val:17},{op:0,bits:8,val:105},{op:0,bits:8,val:41},{op:0,bits:9,val:179},{op:0,bits:8,val:9},{op:0,bits:8,val:137},{op:0,bits:8,val:73},{op:0,bits:9,val:243},{op:16,bits:7,val:4},{op:0,bits:8,val:85},{op:0,bits:8,val:21},{op:16,bits:8,val:258},{op:19,bits:7,val:43},{op:0,bits:8,val:117},{op:0,bits:8,val:53},{op:0,bits:9,val:203},{op:17,bits:7,val:13},{op:0,bits:8,val:101},{op:0,bits:8,val:37},{op:0,bits:9,val:171},{op:0,bits:8,val:5},{op:0,bits:8,val:133},{op:0,bits:8,val:69},{op:0,bits:9,val:235},{op:16,bits:7,val:8},{op:0,bits:8,val:93},{op:0,bits:8,val:29},{op:0,bits:9,val:155},{op:20,bits:7,val:83},{op:0,bits:8,val:125},{op:0,bits:8,val:61},{op:0,bits:9,val:219},{op:18,bits:7,val:23},{op:0,bits:8,val:109},{op:0,bits:8,val:45},{op:0,bits:9,val:187},{op:0,bits:8,val:13},{op:0,bits:8,val:141},{op:0,bits:8,val:77},{op:0,bits:9,val:251},{op:16,bits:7,val:3},{op:0,bits:8,val:83},{op:0,bits:8,val:19},{op:21,bits:8,val:195},{op:19,bits:7,val:35},{op:0,bits:8,val:115},{op:0,bits:8,val:51},{op:0,bits:9,val:199},{op:17,bits:7,val:11},{op:0,bits:8,val:99},{op:0,bits:8,val:35},{op:0,bits:9,val:167},{op:0,bits:8,val:3},{op:0,bits:8,val:131},{op:0,bits:8,val:67},{op:0,bits:9,val:231},{op:16,bits:7,val:7},{op:0,bits:8,val:91},{op:0,bits:8,val:27},{op:0,bits:9,val:151},{op:20,bits:7,val:67},{op:0,bits:8,val:123},{op:0,bits:8,val:59},{op:0,bits:9,val:215},{op:18,bits:7,val:19},{op:0,bits:8,val:107},{op:0,bits:8,val:43},{op:0,bits:9,val:183},{op:0,bits:8,val:11},{op:0,bits:8,val:139},{op:0,bits:8,val:75},{op:0,bits:9,val:247},{op:16,bits:7,val:5},{op:0,bits:8,val:87},{op:0,bits:8,val:23},{op:64,bits:8,val:0},{op:19,bits:7,val:51},{op:0,bits:8,val:119},{op:0,bits:8,val:55},{op:0,bits:9,val:207},{op:17,bits:7,val:15},{op:0,bits:8,val:103},{op:0,bits:8,val:39},{op:0,bits:9,val:175},{op:0,bits:8,val:7},{op:0,bits:8,val:135},{op:0,bits:8,val:71},{op:0,bits:9,val:239},{op:16,bits:7,val:9},{op:0,bits:8,val:95},{op:0,bits:8,val:31},{op:0,bits:9,val:159},{op:20,bits:7,val:99},{op:0,bits:8,val:127},{op:0,bits:8,val:63},{op:0,bits:9,val:223},{op:18,bits:7,val:27},{op:0,bits:8,val:111},{op:0,bits:8,val:47},{op:0,bits:9,val:191},{op:0,bits:8,val:15},{op:0,bits:8,val:143},{op:0,bits:8,val:79},{op:0,bits:9,val:255}]}if(!t){t=[{op:16,bits:5,val:1},{op:23,bits:5,val:257},{op:19,bits:5,val:17},{op:27,bits:5,val:4097},{op:17,bits:5,val:5},{op:25,bits:5,val:1025},{op:21,bits:5,val:65},{op:29,bits:5,val:16385},{op:16,bits:5,val:3},{op:24,bits:5,val:513},{op:20,bits:5,val:33},{op:28,bits:5,val:8193},{op:18,bits:5,val:9},{op:26,bits:5,val:2049},{op:22,bits:5,val:129},{op:64,bits:5,val:0},{op:16,bits:5,val:2},{op:23,bits:5,val:385},{op:19,bits:5,val:25},{op:27,bits:5,val:6145},{op:17,bits:5,val:7},{op:25,bits:5,val:1537},{op:21,bits:5,val:97},{op:29,bits:5,val:24577},{op:16,bits:5,val:4},{op:24,bits:5,val:769},{op:20,bits:5,val:49},{op:28,bits:5,val:12289},{op:18,bits:5,val:13},{op:26,bits:5,val:3073},{op:22,bits:5,val:193},{op:64,bits:5,val:0}]}ar.lencode=0;ar.distcode=512;for(aq=0;aq<512;aq++){ar.codes[aq]=U[aq]}for(aq=0;aq<32;aq++){ar.codes[aq+512]=t[aq]}ar.lenbits=9;ar.distbits=5}function ap(at){var ar=at.state;var aq=at.output_data.length;if(ar.window===null){ar.window=""}if(ar.wsize==0){ar.wsize=1<<ar.wbits}if(aq>=ar.wsize){ar.window=at.output_data.substring(aq-ar.wsize)}else{if(ar.whave+aq<ar.wsize){ar.window+=at.output_data}else{ar.window=ar.window.substring(ar.whave-(ar.wsize-aq))+at.output_data}}ar.whave=ar.window.length;if(ar.whave<ar.wsize){ar.wnext=ar.whave}else{ar.wnext=0}return 0}function m(ar,at){var aq=[at&255,(at>>>8)&255];ar.state.check=ar.checksum_function(ar.state.check,aq,0,2)}function n(ar,at){var aq=[at&255,(at>>>8)&255,(at>>>16)&255,(at>>>24)&255];ar.state.check=ar.checksum_function(ar.state.check,aq,0,4)}function Z(ar,aq){aq.strm=ar;aq.left=ar.avail_out;aq.next=ar.next_in;aq.have=ar.avail_in;aq.hold=ar.state.hold;aq.bits=ar.state.bits;return aq}function ah(aq){var ar=aq.strm;ar.next_in=aq.next;ar.avail_out=aq.left;ar.avail_in=aq.have;ar.state.hold=aq.hold;ar.state.bits=aq.bits}function P(aq){aq.hold=0;aq.bits=0}function ag(aq){if(aq.have==0){return false}aq.have--;aq.hold+=(aq.strm.input_data.charCodeAt(aq.next++)&255)<<aq.bits;aq.bits+=8;return true}function ad(ar,aq){while(ar.bits<aq){if(!ag(ar)){return false}}return true}function b(ar,aq){return ar.hold&((1<<aq)-1)}function w(ar,aq){ar.hold>>>=aq;ar.bits-=aq}function c(aq){aq.hold>>>=aq.bits&7;aq.bits-=aq.bits&7}function ai(aq){return((aq>>>24)&255)+((aq>>>8)&65280)+((aq&65280)<<8)+((aq&255)<<24)}var I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];ZLIB.inflate=function(aD,at){var aC;var aB;var aq,az;var ar;var av=-1;var au=-1;var aw;var ax;var ay;var aA;if(!aD||!aD.state||(!aD.input_data&&aD.avail_in!=0)){return ZLIB.Z_STREAM_ERROR}aC=aD.state;if(aC.mode==an){aC.mode=ao}aB={};Z(aD,aB);aq=aB.have;az=aB.left;aA=ZLIB.Z_OK;inf_leave:for(;;){switch(aC.mode){case G:if(aC.wrap==0){aC.mode=ao;break}if(!ad(aB,16)){break inf_leave}if((aC.wrap&2)&&aB.hold==35615){aC.check=aD.checksum_function(0,null,0,0);m(aD,aB.hold);P(aB);aC.mode=D;break}aC.flags=0;if(aC.head!==null){aC.head.done=-1}if(!(aC.wrap&1)||((b(aB,8)<<8)+(aB.hold>>>8))%31){aD.msg="incorrect header check";aC.mode=a;break}if(b(aB,4)!=ZLIB.Z_DEFLATED){aD.msg="unknown compression method";aC.mode=a;break}w(aB,4);ay=b(aB,4)+8;if(aC.wbits==0){aC.wbits=ay}else{if(ay>aC.wbits){aD.msg="invalid window size";aC.mode=a;break}}aC.dmax=1<<ay;aD.adler=aC.check=aD.checksum_function(0,null,0,0);aC.mode=aB.hold&512?q:an;P(aB);break;case D:if(!ad(aB,16)){break inf_leave}aC.flags=aB.hold;if((aC.flags&255)!=ZLIB.Z_DEFLATED){aD.msg="unknown compression method";aC.mode=a;break}if(aC.flags&57344){aD.msg="unknown header flags set";aC.mode=a;break}if(aC.head!==null){aC.head.text=(aB.hold>>>8)&1}if(aC.flags&512){m(aD,aB.hold)}P(aB);aC.mode=am;case am:if(!ad(aB,32)){break inf_leave}if(aC.head!==null){aC.head.time=aB.hold}if(aC.flags&512){n(aD,aB.hold)}P(aB);aC.mode=af;case af:if(!ad(aB,16)){break inf_leave}if(aC.head!==null){aC.head.xflags=aB.hold&255;aC.head.os=aB.hold>>>8}if(aC.flags&512){m(aD,aB.hold)}P(aB);aC.mode=A;case A:if(aC.flags&1024){if(!ad(aB,16)){break inf_leave}aC.length=aB.hold;if(aC.head!==null){aC.head.extra_len=aB.hold}if(aC.flags&512){m(aD,aB.hold)}P(aB);aC.head.extra=""}else{if(aC.head!==null){aC.head.extra=null}}aC.mode=B;case B:if(aC.flags&1024){ar=aC.length;if(ar>aB.have){ar=aB.have}if(ar){if(aC.head!==null&&aC.head.extra!==null){ay=aC.head.extra_len-aC.length;aC.head.extra+=aD.input_data.substring(aB.next,aB.next+(ay+ar>aC.head.extra_max?aC.head.extra_max-ay:ar))}if(aC.flags&512){aC.check=aD.checksum_function(aC.check,aD.input_data,aB.next,ar)}aB.have-=ar;aB.next+=ar;aC.length-=ar}if(aC.length){break inf_leave}}aC.length=0;aC.mode=ac;case ac:if(aC.flags&2048){if(aB.have==0){break inf_leave}if(aC.head!==null&&aC.head.name===null){aC.head.name=""}ar=0;do{ay=aD.input_data.charAt(aB.next+ar);ar++;if(ay==="\0"){break}if(aC.head!==null&&aC.length<aC.head.name_max){aC.head.name+=ay;aC.length++}}while(ar<aB.have);if(aC.flags&512){aC.check=aD.checksum_function(aC.check,aD.input_data,aB.next,ar)}aB.have-=ar;aB.next+=ar;if(ay!=="\0"){break inf_leave}}else{if(aC.head!==null){aC.head.name=null}}aC.length=0;aC.mode=j;case j:if(aC.flags&4096){if(aB.have==0){break inf_leave}ar=0;if(aC.head!==null&&aC.head.comment===null){aC.head.comment=""}do{ay=aD.input_data.charAt(aB.next+ar);ar++;if(ay==="\0"){break}if(aC.head!==null&&aC.length<aC.head.comm_max){aC.head.comment+=ay;aC.length++}}while(ar<aB.have);if(aC.flags&512){aC.check=aD.checksum_function(aC.check,aD.input_data,aB.next,ar)}aB.have-=ar;aB.next+=ar;if(ay!=="\0"){break inf_leave}}else{if(aC.head!==null){aC.head.comment=null}}aC.mode=F;case F:if(aC.flags&512){if(!ad(aB,16)){break inf_leave}if(aB.hold!=(aC.check&65535)){aD.msg="header crc mismatch";aC.mode=a;break}P(aB)}if(aC.head!==null){aC.head.hcrc=(aC.flags>>>9)&1;aC.head.done=1}aD.adler=aC.check=aD.checksum_function(0,null,0,0);aC.mode=an;break;case q:if(!ad(aB,32)){break inf_leave}aD.adler=aC.check=ai(aB.hold);P(aB);aC.mode=p;case p:if(aC.havedict==0){ah(aB);return ZLIB.Z_NEED_DICT}aD.adler=aC.check=aD.checksum_function(0,null,0,0);aC.mode=an;case an:if(at==ZLIB.Z_BLOCK||at==ZLIB.Z_TREES){break inf_leave}case ao:if(aC.last){c(aB);aC.mode=d;break}if(!ad(aB,3)){break inf_leave}aC.last=b(aB,1);w(aB,1);switch(b(aB,2)){case 0:aC.mode=aj;break;case 1:C(aC);aC.mode=S;if(at==ZLIB.Z_TREES){w(aB,2);break inf_leave}break;case 2:aC.mode=al;break;case 3:aD.msg="invalid block type";aC.mode=a}w(aB,2);break;case aj:c(aB);if(!ad(aB,32)){break inf_leave}if((aB.hold&65535)!=(((aB.hold>>>16)&65535)^65535)){aD.msg="invalid stored block lengths";aC.mode=a;break}aC.length=aB.hold&65535;P(aB);aC.mode=l;if(at==ZLIB.Z_TREES){break inf_leave}case l:aC.mode=k;case k:ar=aC.length;if(ar){if(ar>aB.have){ar=aB.have}if(ar>aB.left){ar=aB.left}if(ar==0){break inf_leave}aD.output_data+=aD.input_data.substring(aB.next,aB.next+ar);aD.next_out+=ar;aB.have-=ar;aB.next+=ar;aB.left-=ar;aC.length-=ar;break}aC.mode=an;break;case al:if(!ad(aB,14)){break inf_leave}aC.nlen=b(aB,5)+257;w(aB,5);aC.ndist=b(aB,5)+1;w(aB,5);aC.ncode=b(aB,4)+4;w(aB,4);if(aC.nlen>286||aC.ndist>30){aD.msg="too many length or distance symbols";aC.mode=a;break}aC.have=0;aC.mode=W;case W:while(aC.have<aC.ncode){if(!ad(aB,3)){break inf_leave}var aE=b(aB,3);aC.lens[I[aC.have++]]=aE;w(aB,3)}while(aC.have<19){aC.lens[I[aC.have++]]=0}aC.next=0;aC.lencode=0;aC.lenbits=7;aA=K(aC,h);if(aA){aD.msg="invalid code lengths set";aC.mode=a;break}aC.have=0;aC.mode=g;case g:while(aC.have<aC.nlen+aC.ndist){for(;;){aw=aC.codes[aC.lencode+b(aB,aC.lenbits)];if(aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}if(aw.val<16){w(aB,aw.bits);aC.lens[aC.have++]=aw.val}else{if(aw.val==16){if(!ad(aB,aw.bits+2)){break inf_leave}w(aB,aw.bits);if(aC.have==0){aD.msg="invalid bit length repeat";aC.mode=a;break}ay=aC.lens[aC.have-1];ar=3+b(aB,2);w(aB,2)}else{if(aw.val==17){if(!ad(aB,aw.bits+3)){break inf_leave}w(aB,aw.bits);ay=0;ar=3+b(aB,3);w(aB,3)}else{if(!ad(aB,aw.bits+7)){break inf_leave}w(aB,aw.bits);ay=0;ar=11+b(aB,7);w(aB,7)}}if(aC.have+ar>aC.nlen+aC.ndist){aD.msg="invalid bit length repeat";aC.mode=a;break}while(ar--){aC.lens[aC.have++]=ay}}}if(aC.mode==a){break}if(aC.lens[256]==0){aD.msg="invalid code -- missing end-of-block";aC.mode=a;break}aC.next=0;aC.lencode=aC.next;aC.lenbits=9;aA=K(aC,X);if(aA){aD.msg="invalid literal/lengths set";aC.mode=a;break}aC.distcode=aC.next;aC.distbits=6;aA=K(aC,u);if(aA){aD.msg="invalid distances set";aC.mode=a;break}aC.mode=S;if(at==ZLIB.Z_TREES){break inf_leave}case S:aC.mode=R;case R:if(aB.have>=6&&aB.left>=258){ah(aB);H(aD,az);Z(aD,aB);if(aC.mode==an){aC.back=-1}break}aC.back=0;for(;;){aw=aC.codes[aC.lencode+b(aB,aC.lenbits)];if(aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}if(aw.op&&(aw.op&240)==0){ax=aw;for(;;){aw=aC.codes[aC.lencode+ax.val+(b(aB,ax.bits+ax.op)>>>ax.bits)];if(ax.bits+aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}w(aB,ax.bits);aC.back+=ax.bits}w(aB,aw.bits);aC.back+=aw.bits;aC.length=aw.val;if(aw.op==0){aC.mode=Y;break}if(aw.op&32){aC.back=-1;aC.mode=an;break}if(aw.op&64){aD.msg="invalid literal/length code";aC.mode=a;break}aC.extra=aw.op&15;aC.mode=T;case T:if(aC.extra){if(!ad(aB,aC.extra)){break inf_leave}aC.length+=b(aB,aC.extra);w(aB,aC.extra);aC.back+=aC.extra}aC.was=aC.length;aC.mode=r;case r:for(;;){aw=aC.codes[aC.distcode+b(aB,aC.distbits)];if(aw.bits<=aB.bits){break}if(!ag(aB)){break inf_leave}}if((aw.op&240)==0){ax=aw;for(;;){aw=aC.codes[aC.distcode+ax.val+(b(aB,ax.bits+ax.op)>>>ax.bits)];if((ax.bits+aw.bits)<=aB.bits){break}if(!ag(aB)){break inf_leave}}w(aB,ax.bits);aC.back+=ax.bits}w(aB,aw.bits);aC.back+=aw.bits;if(aw.op&64){aD.msg="invalid distance code";aC.mode=a;break}aC.offset=aw.val;aC.extra=aw.op&15;aC.mode=s;case s:if(aC.extra){if(!ad(aB,aC.extra)){break inf_leave}aC.offset+=b(aB,aC.extra);w(aB,aC.extra);aC.back+=aC.extra}aC.mode=aa;case aa:if(aB.left==0){break inf_leave}ar=az-aB.left;if(aC.offset>ar){ar=aC.offset-ar;if(ar>aC.whave){if(aC.sane){aD.msg="invalid distance too far back";aC.mode=a;break}}if(ar>aC.wnext){ar-=aC.wnext;av=aC.wsize-ar;au=-1}else{av=aC.wnext-ar;au=-1}if(ar>aC.length){ar=aC.length}}else{av=-1;au=aD.next_out-aC.offset;ar=aC.length}if(ar>aB.left){ar=aB.left}aB.left-=ar;aC.length-=ar;if(av>=0){aD.output_data+=aC.window.substring(av,av+ar);aD.next_out+=ar;ar=0}else{aD.next_out+=ar;do{aD.output_data+=aD.output_data.charAt(au++)}while(--ar)}if(aC.length==0){aC.mode=R}break;case Y:if(aB.left==0){break inf_leave}aD.output_data+=String.fromCharCode(aC.length);aD.next_out++;aB.left--;aC.mode=R;break;case d:if(aC.wrap){if(!ad(aB,32)){break inf_leave}az-=aB.left;aD.total_out+=az;aC.total+=az;if(az){aD.adler=aC.check=aD.checksum_function(aC.check,aD.output_data,aD.output_data.length-az,az)}az=aB.left;if((aC.flags?aB.hold:ai(aB.hold))!=aC.check){aD.msg="incorrect data check";aC.mode=a;break}P(aB)}aC.mode=V;case V:if(aC.wrap&&aC.flags){if(!ad(aB,32)){break inf_leave}if(aB.hold!=(aC.total&4294967295)){aD.msg="incorrect length check";aC.mode=a;break}P(aB)}aC.mode=v;case v:aA=ZLIB.Z_STREAM_END;break inf_leave;case a:aA=ZLIB.Z_DATA_ERROR;break inf_leave;case ab:return ZLIB.Z_MEM_ERROR;case ak:default:return ZLIB.Z_STREAM_ERROR}}inf_leave:ah(aB);if(aC.wsize||(az!=aD.avail_out&&aC.mode<a&&(aC.mode<d||at!=ZLIB.Z_FINISH))){if(ap(aD)){aC.mode=ab;return ZLIB.Z_MEM_ERROR}}aq-=aD.avail_in;az-=aD.avail_out;aD.total_in+=aq;aD.total_out+=az;aC.total+=az;if(aC.wrap&&az){aD.adler=aC.check=aD.checksum_function(aC.check,aD.output_data,0,aD.output_data.length)}aD.data_type=aC.bits+(aC.last?64:0)+(aC.mode==an?128:0)+(aC.mode==S||aC.mode==l?256:0);if(((aq==0&&az==0)||at==ZLIB.Z_FINISH)&&aA==ZLIB.Z_OK){aA=ZLIB.Z_BUF_ERROR}return aA};ZLIB.inflateEnd=function(ar){var aq;if(!ar||!ar.state){return ZLIB.Z_STREAM_ERROR}aq=ar.state;aq.window=null;ar.state=null;return ZLIB.Z_OK};ZLIB.z_stream.prototype.inflate=function(au,av){var at;var aq;var ar=16384;this.input_data=au;this.next_in=E(av,"next_in",0);this.avail_in=E(av,"avail_in",au.length-this.next_in);at=E(av,"flush",ZLIB.Z_SYNC_FLUSH);aq=E(av,"avail_out",-1);var aw="";do{this.avail_out=(aq>=0?aq:ar);this.output_data="";this.next_out=0;this.error=ZLIB.inflate(this,at);if(aq>=0){return this.output_data}aw+=this.output_data;if(this.avail_out>0){break}}while(this.error==ZLIB.Z_OK);return aw};ZLIB.z_stream.prototype.inflateReset=function(aq){return ZLIB.inflateReset(this,aq)}}());if(typeof ZLIB==="undefined"){alert("ZLIB is not defined. SRC zlib.js before zlib-adler32.js")}(function(){var c=65521;var d=5552;function b(e,g,k,h){var l;var j;l=(e>>>16)&65535;e&=65535;if(h==1){e+=g.charCodeAt(k)&255;if(e>=c){e-=c}l+=e;if(l>=c){l-=c}return e|(l<<16)}if(g===null){return 1}if(h<16){while(h--){e+=g.charCodeAt(k++)&255;l+=e}if(e>=c){e-=c}l%=c;return e|(l<<16)}while(h>=d){h-=d;j=d>>4;do{e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e}while(--j);e%=c;l%=c}if(h){while(h>=16){h-=16;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e;e+=g.charCodeAt(k++)&255;l+=e}while(h--){e+=g.charCodeAt(k++)&255;l+=e}e%=c;l%=c}return e|(l<<16)}function a(e,g,k,h){var l;var j;l=(e>>>16)&65535;e&=65535;if(h==1){e+=g[k];if(e>=c){e-=c}l+=e;if(l>=c){l-=c}return e|(l<<16)}if(g===null){return 1}if(h<16){while(h--){e+=g[k++];l+=e}if(e>=c){e-=c}l%=c;return e|(l<<16)}while(h>=d){h-=d;j=d>>4;do{e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e}while(--j);e%=c;l%=c}if(h){while(h>=16){h-=16;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e;e+=g[k++];l+=e}while(h--){e+=g[k++];l+=e}e%=c;l%=c}return e|(l<<16)}ZLIB.adler32=function(e,g,j,h){if(typeof g==="string"){return b(e,g,j,h)}else{return a(e,g,j,h)}};ZLIB.adler32_combine=function(e,g,h){var k;var l;var j;if(h<0){return 4294967295}h%=c;j=h;k=e&65535;l=j*k;l%=c;k+=(g&65535)+c-1;l+=((e>>16)&65535)+((g>>16)&65535)+c-j;if(k>=c){k-=c}if(k>=c){k-=c}if(l>=(c<<1)){l-=(c<<1)}if(l>=c){l-=c}return k|(l<<16)}}());if(typeof ZLIB==="undefined"){alert("ZLIB is not defined. SRC zlib.js before zlib-crc32.js")}(function(){var a=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918000,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];function c(j,h,l,k){if(h==null){return 0}j=j^4294967295;while(k>=8){j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);j=a[(j^h.charCodeAt(l++))&255]^(j>>>8);k-=8}if(k){do{j=a[(j^h.charCodeAt(l++))&255]^(j>>>8)}while(--k)}return j^4294967295}function b(j,h,l,k){if(h==null){return 0}j=j^4294967295;while(k>=8){j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);j=a[(j^h[l++])&255]^(j>>>8);k-=8}if(k){do{j=a[(j^h[l++])&255]^(j>>>8)}while(--k)}return j^4294967295}ZLIB.crc32=function(j,h,l,k){if(typeof h==="string"){return c(j,h,l,k)}else{return b(j,h,l,k)}};var d=32;function g(h,l){var k;var j=0;k=0;while(l){if(l&1){k^=h[j]}l>>=1;j++}return k}function e(k,h){var j;for(j=0;j<d;j++){k[j]=g(h,h[j])}}ZLIB.crc32_combine=function(h,j,l){var m;var p;var k;var o;if(l<=0){return h}k=new Array(d);o=new Array(d);o[0]=3988292384;p=1;for(m=1;m<d;m++){o[m]=p;p<<=1}e(k,o);e(o,k);do{e(k,o);if(l&1){h=g(k,h)}l>>=1;if(l==0){break}e(o,k);if(l&1){h=g(o,h)}l>>=1}while(l!=0);h^=j;return h}}());var CreateAmtRedirect=function(e,a){var g={};g.m=e;e.parent=g;g.authCookie=a;g.State=0;g.socket=null;g.host=null;g.port=0;g.user=null;g.pass=null;g.authuri="/RedirectionService";g.tlsv1only=0;g.inDataCount=0;g.connectstate=0;g.protocol=e.protocol;g.debugmode=0;g.amtaccumulator="";g.amtsequence=1;g.amtkeepalivetimer=null;g.onStateChanged=null;g.Start=function(h,k,n,j,l){g.host=h;g.port=k;g.user=n;g.pass=j;g.connectstate=0;g.inDataCount=0;var m=window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=2&host="+h+"&port="+k+"&tls="+l+((n=="*")?"&serverauth=1":"")+((typeof j==="undefined")?("&serverauth=1&user="+n):"");if((a!=null)&&(a!="")){m+="&auth="+a}g.socket=new WebSocket(m);g.socket.onopen=g.xxOnSocketConnected;g.socket.onmessage=g.xxOnMessage;g.socket.onclose=g.xxOnSocketClosed;g.xxStateChange(1)};g.xxOnSocketConnected=function(){if(g.debugmode==1){console.log("onSocketConnected")}g.xxStateChange(2);if(g.protocol==1){g.xxSend(g.RedirectStartSol)}if(g.protocol==2){g.xxSend(g.RedirectStartKvm)}if(g.protocol==3){g.xxSend(g.RedirectStartIder)}};var b=new FileReader();var d=false,c=[];if(b.readAsBinaryString){b.onload=function(h){g.xxOnSocketData(h.target.result);if(c.length==0){d=false}else{b.readAsBinaryString(new Blob([c.shift()]))}}}else{if(b.readAsArrayBuffer){b.onloadend=function(h){g.xxOnSocketData(h.target.result);if(c.length==0){d=false}else{b.readAsArrayBuffer(c.shift())}}}}g.xxOnMessage=function(k){g.inDataCount++;if(typeof k.data=="object"){if(d==true){c.push(k.data);return}if(b.readAsBinaryString){d=true;b.readAsBinaryString(new Blob([k.data]))}else{if(b.readAsArrayBuffer){d=true;b.readAsArrayBuffer(k.data)}else{var h="",j=new Uint8Array(k.data),m=j.byteLength;for(var l=0;l<m;l++){h+=String.fromCharCode(j[l])}g.xxOnSocketData(h)}}}else{g.xxOnSocketData(k.data)}};g.xxOnSocketData=function(t){if(!t||g.connectstate==-1){return}if(typeof t==="object"){var m="";var o=new Uint8Array(t);var y=o.byteLength;for(var x=0;x<y;x++){m+=String.fromCharCode(o[x])}t=m}else{if(typeof t!=="string"){return}}if((g.protocol==2||g.protocol==3)&&g.connectstate==1){return g.m.ProcessData(t)}g.amtaccumulator+=t;while(g.amtaccumulator.length>=1){var p=0;switch(g.amtaccumulator.charCodeAt(0)){case 17:if(g.amtaccumulator.length<4){return}var L=g.amtaccumulator.charCodeAt(1);switch(L){case 0:if(g.amtaccumulator.length<13){return}var C=g.amtaccumulator.charCodeAt(12);if(g.amtaccumulator.length<13+C){return}g.xxSend(String.fromCharCode(19,0,0,0,0,0,0,0,0));p=(13+C);break;default:g.Stop(1);break}break;case 20:if(g.amtaccumulator.length<9){return}var k=ReadIntX(g.amtaccumulator,5);if(g.amtaccumulator.length<9+k){return}var K=g.amtaccumulator.charCodeAt(1);var l=g.amtaccumulator.charCodeAt(4);var h=[];for(x=0;x<k;x++){h.push(g.amtaccumulator.charCodeAt(9+x))}var j=g.amtaccumulator.substring(9,9+k);p=9+k;if(l==0){if(h.indexOf(4)>=0){g.xxSend(String.fromCharCode(19,0,0,0,4)+IntToStrX(g.user.length+g.authuri.length+8)+String.fromCharCode(g.user.length)+g.user+String.fromCharCode(0,0)+String.fromCharCode(g.authuri.length)+g.authuri+String.fromCharCode(0,0,0,0))}else{if(h.indexOf(3)>=0){g.xxSend(String.fromCharCode(19,0,0,0,3)+IntToStrX(g.user.length+g.authuri.length+7)+String.fromCharCode(g.user.length)+g.user+String.fromCharCode(0,0)+String.fromCharCode(g.authuri.length)+g.authuri+String.fromCharCode(0,0,0))}else{if(h.indexOf(1)>=0){g.xxSend(String.fromCharCode(19,0,0,0,1)+IntToStrX(g.user.length+g.pass.length+2)+String.fromCharCode(g.user.length)+g.user+String.fromCharCode(g.pass.length)+g.pass)}else{g.Stop(2)}}}}else{if((l==3||l==4)&&K==1){var s=0;var G=j.charCodeAt(s);var F=j.substring(s+1,s+1+G);s+=(G+1);var B=j.charCodeAt(s);var A=j.substring(s+1,s+1+B);s+=(B+1);var E=0;var D=null;var q=g.xxRandomNonce(32);var J="00000002";var v="";if(l==4){E=j.charCodeAt(s);D=j.substring(s+1,s+1+E);s+=(E+1);v=J+":"+q+":"+D+":"}var u=hex_md5(hex_md5(g.user+":"+F+":"+g.pass)+":"+A+":"+v+hex_md5("POST:"+g.authuri));var M=g.user.length+F.length+A.length+g.authuri.length+q.length+J.length+u.length+7;if(l==4){M+=(D.length+1)}var n=String.fromCharCode(19,0,0,0,l)+IntToStrX(M)+String.fromCharCode(g.user.length)+g.user+String.fromCharCode(F.length)+F+String.fromCharCode(A.length)+A+String.fromCharCode(g.authuri.length)+g.authuri+String.fromCharCode(q.length)+q+String.fromCharCode(J.length)+J+String.fromCharCode(u.length)+u;if(l==4){n+=(String.fromCharCode(D.length)+D)}g.xxSend(n)}else{if(K==0){if(g.protocol==1){var z=10000;var O=100;var N=0;var I=10000;var H=100;var w=0;g.xxSend(String.fromCharCode(32,0,0,0)+IntToStrX(g.amtsequence++)+ShortToStrX(z)+ShortToStrX(O)+ShortToStrX(N)+ShortToStrX(I)+ShortToStrX(H)+ShortToStrX(w)+IntToStrX(0))}if(g.protocol==2){g.xxSend(String.fromCharCode(64,0,0,0,0,0,0,0))}if(g.protocol==3){g.connectstate=1;g.xxStateChange(3)}}else{g.Stop(3)}}}break;case 33:if(g.amtaccumulator.length<23){break}p=23;g.xxSend(String.fromCharCode(39,0,0,0)+IntToStrX(g.amtsequence++)+String.fromCharCode(0,0,27,0,0,0));if(g.protocol==1){g.amtkeepalivetimer=setInterval(g.xxSendAmtKeepAlive,2000)}g.connectstate=1;g.xxStateChange(3);break;case 41:if(g.amtaccumulator.length<10){break}p=10;break;case 42:if(g.amtaccumulator.length<10){break}var r=(10+((g.amtaccumulator.charCodeAt(9)&255)<<8)+(g.amtaccumulator.charCodeAt(8)&255));if(g.amtaccumulator.length<r){break}g.m.ProcessData(g.amtaccumulator.substring(10,r));p=r;break;case 43:if(g.amtaccumulator.length<8){break}p=8;break;case 65:if(g.amtaccumulator.length<8){break}g.connectstate=1;g.m.Start();if(g.amtaccumulator.length>8){g.m.ProcessData(g.amtaccumulator.substring(8))}p=g.amtaccumulator.length;break;default:console.log("Unknown Intel AMT command: "+g.amtaccumulator.charCodeAt(0)+" acclen="+g.amtaccumulator.length);g.Stop(4);return}if(p==0){return}g.amtaccumulator=g.amtaccumulator.substring(p)}};g.xxSend=function(l){if(g.socket!=null&&g.socket.readyState==WebSocket.OPEN){if(g.debugmode==1){console.log("Send",l)}var h=new Uint8Array(l.length);for(var k=0;k<l.length;++k){h[k]=l.charCodeAt(k)}try{g.socket.send(h.buffer)}catch(j){}}};g.send=function(h){if(g.socket==null||g.connectstate!=1){return}if(g.protocol==1){g.xxSend(String.fromCharCode(40,0,0,0)+IntToStrX(g.amtsequence++)+ShortToStrX(h.length)+h)}else{g.xxSend(h)}};g.xxSendAmtKeepAlive=function(){if(g.socket==null){return}g.xxSend(String.fromCharCode(43,0,0,0)+IntToStrX(g.amtsequence++))};g.xxRandomNonceX="abcdef0123456789";g.xxRandomNonce=function(j){var k="";for(var h=0;h<j;h++){k+=g.xxRandomNonceX.charAt(Math.floor(Math.random()*g.xxRandomNonceX.length))}return k};g.xxOnSocketClosed=function(){if(g.debugmode==1){console.log("onSocketClosed")}if((g.inDataCount==0)&&(g.tlsv1only==0)){g.tlsv1only=1;g.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=2&host="+g.host+"&port="+g.port+"&tls="+g.tls+"&tls1only=1"+((g.user=="*")?"&serverauth=1":"")+((typeof pass==="undefined")?("&serverauth=1&user="+g.user):""));g.socket.onopen=g.xxOnSocketConnected;g.socket.onmessage=g.xxOnMessage;g.socket.onclose=g.xxOnSocketClosed}else{g.Stop(5)}};g.xxStateChange=function(h){if(g.State==h){return}g.State=h;g.m.xxStateChange(g.State);if(g.onStateChanged!=null){g.onStateChanged(g,g.State)}};g.Stop=function(h){if(g.debugmode==1){console.log("onSocketStop",h)}g.xxStateChange(0);g.connectstate=-1;g.amtaccumulator="";if(g.socket!=null){g.socket.close();g.socket=null}if(g.amtkeepalivetimer!=null){clearInterval(g.amtkeepalivetimer);g.amtkeepalivetimer=null}};g.RedirectStartSol=String.fromCharCode(16,0,0,0,83,79,76,32);g.RedirectStartKvm=String.fromCharCode(16,1,0,0,75,86,77,82);g.RedirectStartIder=String.fromCharCode(16,0,0,0,73,68,69,82);return g};var CreateWsmanComm=function(l,o,q,n,p){var m={};m.PendingAjax=[];m.ActiveAjaxCount=0;m.MaxActiveAjaxCount=1;m.FailAllError=0;m.challengeParams=null;m.noncecounter=1;m.authcounter=0;m.socket=null;m.socketState=0;m.host=l;m.port=o;m.user=q;m.pass=n;m.tls=p;m.tlsv1only=1;m.cnonce=Math.random().toString(36).substring(7);m.PerformAjax=function(t,s,v,u,w,r){if(m.ActiveAjaxCount<m.MaxActiveAjaxCount&&m.PendingAjax.length==0){m.PerformAjaxEx(t,s,v,w,r)}else{if(u==1){m.PendingAjax.unshift([t,s,v,w,r])}else{m.PendingAjax.push([t,s,v,w,r])}}};m.PerformNextAjax=function(){if(m.ActiveAjaxCount>=m.MaxActiveAjaxCount||m.PendingAjax.length==0){return}var r=m.PendingAjax.shift();m.PerformAjaxEx(r[0],r[1],r[2],r[3],r[4]);m.PerformNextAjax()};m.PerformAjaxEx=function(t,s,u,v,r){if(m.FailAllError!=0){m.gotNextMessagesError({status:m.FailAllError},"error",null,[t,s,u,v,r]);return}if(!t){t=""}m.ActiveAjaxCount++;return m.PerformAjaxExNodeJS(t,s,u,v,r)};m.pendingAjaxCall=[];m.PerformAjaxExNodeJS=function(t,s,u,v,r){m.PerformAjaxExNodeJS2(t,s,u,v,r,3)};m.PerformAjaxExNodeJS2=function(t,s,v,w,r,u){if(u<=0||m.FailAllError!=0){m.ActiveAjaxCount--;if(m.FailAllError!=999){m.gotNextMessages(null,"error",{status:((m.FailAllError==0)?408:m.FailAllError)},[t,s,v,w,r])}m.PerformNextAjax();return}m.pendingAjaxCall.push([t,s,v,w,r,u]);if(m.socketState==0){m.xxConnectHttpSocket()}else{if(m.socketState==2){m.sendRequest(t,w,r)}}};m.sendRequest=function(t,v,r){v=v?v:"/wsman";r=r?r:"POST";var s=r+" "+v+" HTTP/1.1\r\n";if(m.challengeParams!=null){var u=hex_md5(hex_md5(m.user+":"+m.challengeParams.realm+":"+m.pass)+":"+m.challengeParams.nonce+":"+m.noncecounter+":"+m.cnonce+":"+m.challengeParams.qop+":"+hex_md5(r+":"+v));s+="Authorization: "+m.renderDigest({username:m.user,realm:m.challengeParams.realm,nonce:m.challengeParams.nonce,uri:v,qop:m.challengeParams.qop,response:u,nc:m.noncecounter++,cnonce:m.cnonce})+"\r\n"}s+="Host: "+m.host+":"+m.port+"\r\nTransfer-Encoding: chunked\r\n\r\n"+t.length.toString(16).toUpperCase()+"\r\n"+t+"\r\n0\r\n\r\n";g(s)};m.parseDigest=function(r){var s=r.substring(7).split(",");for(i in s){s[i]=s[i].trim()}return s.reduce(function(t,v){var u=v.split("=");t[u[0]]=u[1].replace(/"/g,"");return t},{})};m.renderDigest=function(r){var s=[];for(i in r){s.push(i)}return"Digest "+s.reduce(function(u,t){return u+","+t+'="'+r[t]+'"'},"").substring(1)};m.xxConnectHttpSocket=function(){m.socketParseState=0;m.socketAccumulator="";m.socketHeader=null;m.socketData="";m.socketState=1;console.log(m.tlsv1only);m.socket=new WebSocket(window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/webrelay.ashx?p=1&host="+m.host+"&port="+m.port+"&tls="+m.tls+"&tlsv1only="+m.tlsv1only+((q=="*")?"&serverauth=1":"")+((typeof n==="undefined")?("&serverauth=1&user="+q):""));m.socket.onopen=c;m.socket.onmessage=a;m.socket.onclose=b};function c(){m.socketState=2;for(i in m.pendingAjaxCall){m.sendRequest(m.pendingAjaxCall[i][0],m.pendingAjaxCall[i][3],m.pendingAjaxCall[i][4])}}var h=new FileReader();var k=false,j=[];if(h.readAsBinaryString){h.onload=function(r){d(r.target.result);if(j.length==0){k=false}else{h.readAsBinaryString(new Blob([j.shift()]))}}}else{if(h.readAsArrayBuffer){h.onloadend=function(r){d(r.target.result);if(j.length==0){k=false}else{h.readAsArrayBuffer(j.shift())}}}}function a(t){if(typeof t.data=="object"){if(k==true){j.push(t.data);return}if(h.readAsBinaryString){k=true;h.readAsBinaryString(new Blob([t.data]))}else{if(h.readAsArrayBuffer){k=true;h.readAsArrayBuffer(t.data)}else{var r="",s=new Uint8Array(t.data),v=s.byteLength;for(var u=0;u<v;u++){r+=String.fromCharCode(s[u])}d(r)}}}else{d(t.data)}}function d(v){if(typeof v==="object"){var r="",s=new Uint8Array(v),y=s.byteLength;for(var x=0;x<y;x++){r+=String.fromCharCode(s[x])}v=r}else{if(typeof v!=="string"){return}}m.socketAccumulator+=v;while(true){if(m.socketParseState==0){var w=m.socketAccumulator.indexOf("\r\n\r\n");if(w<0){return}m.socketHeader=m.socketAccumulator.substring(0,w).split("\r\n");m.socketAccumulator=m.socketAccumulator.substring(w+4);m.socketParseState=1;m.socketData="";m.socketXHeader={Directive:m.socketHeader[0].split(" ")};for(x in m.socketHeader){if(x!=0){var z=m.socketHeader[x].indexOf(":");m.socketXHeader[m.socketHeader[x].substring(0,z).toLowerCase()]=m.socketHeader[x].substring(z+2)}}}if(m.socketParseState==1){var u=-1;if((m.socketXHeader.connection!=undefined)&&(m.socketXHeader.connection.toLowerCase()=="close")&&((m.socketXHeader["transfer-encoding"]==undefined)||(m.socketXHeader["transfer-encoding"].toLowerCase()!="chunked"))){u=0}else{if(m.socketXHeader["content-length"]!=undefined){u=parseInt(m.socketXHeader["content-length"]);if(m.socketAccumulator.length<u){return}var v=m.socketAccumulator.substring(0,u);m.socketAccumulator=m.socketAccumulator.substring(u);m.socketData=v;u=0}else{var t=m.socketAccumulator.indexOf("\r\n");if(t<0){return}u=parseInt(m.socketAccumulator.substring(0,t),16);if(isNaN(u)){if(m.websocket){m.websocket.close()}return}if(m.socketAccumulator.length<t+2+u+2){return}var v=m.socketAccumulator.substring(t+2,t+2+u);m.socketAccumulator=m.socketAccumulator.substring(t+2+u+2);m.socketData+=v}}if(u==0){e(m.socketXHeader,m.socketData);m.socketParseState=0;m.socketHeader=null}}}}function e(u,t){var w=parseInt(u.Directive[1]);if(isNaN(w)){w=602}if(w==401&&++(m.authcounter)<3){m.challengeParams=m.parseDigest(u["www-authenticate"])}else{var v=m.pendingAjaxCall.shift();m.authcounter=0;m.ActiveAjaxCount--;m.gotNextMessages(t,"success",{status:w},v);m.PerformNextAjax()}}function b(s){m.socketState=0;if(m.socket!=null){m.socket.close();m.socket=null}if(m.pendingAjaxCall.length>0){var t=m.pendingAjaxCall.shift();var u=t[5];m.PerformAjaxExNodeJS2(t[0],t[1],t[2],t[3],t[4],--u)}}function g(u){if(m.socketState==2&&m.socket!=null&&m.socket.readyState==WebSocket.OPEN){var r=new Uint8Array(u.length);for(var t=0;t<u.length;++t){r[t]=u.charCodeAt(t)}try{m.socket.send(r.buffer)}catch(s){}}}m.gotNextMessages=function(s,u,t,r){if(m.FailAllError==999){return}if(m.FailAllError!=0){r[1](null,m.FailAllError,r[2]);return}if(t.status!=200){r[1](null,t.status,r[2]);return}r[1](s,200,r[2])};m.gotNextMessagesError=function(t,u,s,r){if(m.FailAllError==999){return}if(m.FailAllError!=0){r[1](null,m.FailAllError,r[2]);return}r[1](m,null,{Header:{HttpError:t.status}},t.status,r[2])};m.CancelAllQueries=function(r){while(m.PendingAjax.length>0){var t=m.PendingAjax.shift();t[1](null,r,t[2])}if(m.websocket!=null){m.websocket.close();m.websocket=null;m.socketState=0}};return m};var CreateAgentRedirect=function(g,h,l,a,b){var j={};j.m=h;h.parent=j;j.meshserver=g;j.authCookie=a;j.State=0;j.nodeid=null;j.socket=null;j.connectstate=-1;j.tunnelid=Math.random().toString(36).substring(2);j.protocol=h.protocol;j.onStateChanged=null;j.ctrlMsgAllowed=true;j.attemptWebRTC=false;j.webRtcActive=false;j.webSwitchOk=false;j.webchannel=null;j.webrtc=null;j.debugmode=0;if(b==null){b="/"}j.consoleMessage=null;j.onConsoleMessageChange=null;j.Start=function(m){var o,n=window.location.protocol.replace("http","ws")+"//"+window.location.host+window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/meshrelay.ashx?id="+j.tunnelid;if((a!=null)&&(a!="")){n+="&auth="+a}j.nodeid=m;j.connectstate=0;j.socket=new WebSocket(n);j.socket.onopen=j.xxOnSocketConnected;j.socket.onmessage=j.xxOnMessage;j.socket.onerror=function(p){};j.socket.onclose=j.xxOnSocketClosed;j.xxStateChange(1);j.meshserver.send({action:"msg",type:"tunnel",nodeid:j.nodeid,value:"*"+b+"meshrelay.ashx?id="+j.tunnelid,usage:j.protocol})};j.xxOnSocketConnected=function(){if(j.debugmode==1){console.log("onSocketConnected")}j.xxStateChange(2)};j.xxOnControlCommand=function(o){var m;try{m=JSON.parse(o)}catch(n){return}if(m.ctrlChannel!="102938"){j.xxOnSocketData(o);return}if(m.type=="console"){j.consoleMessage=m.msg;if(j.onConsoleMessageChange){j.onConsoleMessageChange(j,j.consoleMessage)}}else{if(j.webrtc!=null){if(m.type=="answer"){j.webrtc.setRemoteDescription(new RTCSessionDescription(m),function(){},j.xxCloseWebRTC)}else{if(m.type=="webrtc0"){j.webSwitchOk=true;k()}else{if(m.type=="webrtc1"){j.sendCtrlMsg('{"ctrlChannel":"102938","type":"webrtc2"}')}else{if(m.type=="webrtc2"){}}}}}}};j.sendCtrlMsg=function(n){if(j.ctrlMsgAllowed==true){if((typeof args!="undefined")&&args.redirtrace){console.log("RedirSend",typeof n,n)}try{j.socket.send(n)}catch(m){}}};function k(){if((j.webSwitchOk==true)&&(j.webRtcActive==true)){j.sendCtrlMsg('{"ctrlChannel":"102938","type":"webrtc0"}');j.sendCtrlMsg('{"ctrlChannel":"102938","type":"webrtc1"}');if(j.onStateChanged!=null){j.onStateChanged(j,j.State)}}}j.xxOnMessage=function(p){if(j.State<3){if(p.data=="c"){try{j.socket.send(j.protocol)}catch(q){}j.xxStateChange(3);if(j.attemptWebRTC==true){var o=null;if(typeof RTCPeerConnection!=="undefined"){j.webrtc=new RTCPeerConnection(o)}else{if(typeof webkitRTCPeerConnection!=="undefined"){j.webrtc=new webkitRTCPeerConnection(o)}}if(j.webrtc!=null){j.webchannel=j.webrtc.createDataChannel("DataChannel",{});j.webchannel.onmessage=j.xxOnMessage;j.webchannel.onopen=function(){j.webRtcActive=true;k()};j.webchannel.onclose=function(t){if(j.webRtcActive){j.Stop()}};j.webrtc.onicecandidate=function(t){if(t.candidate==null){try{j.socket.send(JSON.stringify(j.webrtcoffer))}catch(u){}}else{j.webrtcoffer.sdp+=("a="+t.candidate.candidate+"\r\n")}};j.webrtc.oniceconnectionstatechange=function(){if(j.webrtc!=null){if(j.webrtc.iceConnectionState=="disconnected"){if(j.webRtcActive==true){j.Stop()}else{j.xxCloseWebRTC()}}else{if(j.webrtc.iceConnectionState=="failed"){j.xxCloseWebRTC()}}}};j.webrtc.createOffer(function(t){j.webrtcoffer=t;j.webrtc.setLocalDescription(t,function(){},j.xxCloseWebRTC)},j.xxCloseWebRTC,{mandatory:{OfferToReceiveAudio:false,OfferToReceiveVideo:false}})}}return}}if(typeof p.data=="string"){j.xxOnControlCommand(p.data);return}if(typeof p.data=="object"){if(e==true){d.push(p.data);return}if(c.readAsBinaryString){e=true;c.readAsBinaryString(new Blob([p.data]))}else{if(c.readAsArrayBuffer){e=true;c.readAsArrayBuffer(p.data)}else{var m="",n=new Uint8Array(p.data),s=n.byteLength;for(var r=0;r<s;r++){m+=String.fromCharCode(n[r])}j.xxOnSocketData(m)}}}else{j.xxOnSocketData(p.data)}};var c=new FileReader();var e=false,d=[];if(c.readAsBinaryString){c.onload=function(m){j.xxOnSocketData(m.target.result);if(d.length==0){e=false}else{c.readAsBinaryString(new Blob([d.shift()]))}}}else{if(c.readAsArrayBuffer){c.onloadend=function(m){j.xxOnSocketData(m.target.result);if(d.length==0){e=false}else{c.readAsArrayBuffer(d.shift())}}}}j.xxOnSocketData=function(o){if(!o||j.connectstate==-1){return}if(typeof o==="object"){var m="",n=new Uint8Array(o),q=n.byteLength;for(var p=0;p<q;p++){m+=String.fromCharCode(n[p])}o=m}else{if(typeof o!=="string"){return}}if((typeof args!="undefined")&&args.redirtrace){console.log("RedirRecv",typeof o,o.length,o)}return j.m.ProcessData(o)};j.sendText=function(m){if(typeof m!="string"){m=JSON.stringify(m)}j.send(encode_utf8(m))};j.send=function(q){if((typeof args!="undefined")&&args.redirtrace){console.log("RedirSend",typeof q,q.length,q)}try{if(j.socket!=null&&j.socket.readyState==WebSocket.OPEN){if(typeof q=="string"){if(j.debugmode==1){var m=new Uint8Array(q.length),n=[];for(var p=0;p<q.length;++p){m[p]=q.charCodeAt(p);n.push(q.charCodeAt(p))}if(j.webRtcActive==true){j.webchannel.send(m.buffer)}else{j.socket.send(m.buffer)}}else{var m=new Uint8Array(q.length);for(var p=0;p<q.length;++p){m[p]=q.charCodeAt(p)}if(j.webRtcActive==true){j.webchannel.send(m.buffer)}else{j.socket.send(m.buffer)}}}else{if(j.webRtcActive==true){j.webchannel.send(q)}else{j.socket.send(q)}}}}catch(o){}};j.xxOnSocketClosed=function(){j.Stop(1)};j.xxStateChange=function(m){if(j.State==m){return}j.State=m;j.m.xxStateChange(j.State);if(j.onStateChanged!=null){j.onStateChanged(j,j.State)}};j.xxCloseWebRTC=function(){if(j.webchannel!=null){try{j.webchannel.close()}catch(m){}j.webchannel=null}if(j.webrtc!=null){try{j.webrtc.close()}catch(m){}j.webrtc=null}j.webRtcActive=false};j.Stop=function(n){if(j.debugmode==1){console.log("stop",n)}j.xxCloseWebRTC();j.connectstate=-1;if(j.socket!=null){try{if(j.socket.readyState==1){j.sendCtrlMsg('{"ctrlChannel":"102938","type":"close"}');j.socket.close()}}catch(m){}j.socket=null}j.xxStateChange(0)};return j};var CreateKvmDataChannel=function(h,e,d){var g={};g.m=e;e.parent=g;g.webchannel=h;g.State=0;g.protocol=e.protocol;g.onStateChanged=null;g.onControlMsg=null;g.debugmode=0;g.keepalive=d;g.rtcKeepAlive=null;g.Start=function(){if(g.debugmode==1){console.log("start")}g.xxStateChange(3);g.webchannel.onmessage=g.xxOnMessage;g.rtcKeepAlive=setInterval(g.xxSendRtcKeepAlive,30000)};var a=new FileReader();var c=false,b=[];if(a.readAsBinaryString){a.onload=function(j){g.xxOnSocketData(j.target.result);if(b.length==0){c=false}else{a.readAsBinaryString(new Blob([b.shift()]))}}}else{if(a.readAsArrayBuffer){a.onloadend=function(j){g.xxOnSocketData(j.target.result);if(b.length==0){c=false}else{a.readAsArrayBuffer(b.shift())}}}}g.xxOnMessage=function(l){if(typeof l.data=="string"){if(g.onControlMsg!=null){g.onControlMsg(l.data)}return}if(typeof l.data=="object"){if(c==true){b.push(l.data);return}if(a.readAsBinaryString){c=true;a.readAsBinaryString(new Blob([l.data]))}else{if(f.readAsArrayBuffer){c=true;a.readAsArrayBuffer(l.data)}else{var j="",k=new Uint8Array(l.data),n=k.byteLength;for(var m=0;m<n;m++){j+=String.fromCharCode(k[m])}g.xxOnSocketData(j)}}}else{g.xxOnSocketData(l.data)}};g.xxOnSocketData=function(l){if(!l){return}if(typeof l==="object"){var j="",k=new Uint8Array(l),n=k.byteLength;for(var m=0;m<n;m++){j+=String.fromCharCode(k[m])}l=j}else{if(typeof l!=="string"){return}}return g.m.ProcessData(l)};g.sendCtrlMsg=function(j){if(typeof j=="string"){g.webchannel.send(j);if(g.keepalive!=null){g.keepalive.sendKeepAlive()}}};g.send=function(l){if(typeof l=="string"){var j=new Uint8Array(l.length);for(var k=0;k<l.length;++k){j[k]=l.charCodeAt(k)}l=j}g.webchannel.send(l)};g.xxStateChange=function(j){if(g.State==j){return}g.State=j;g.m.xxStateChange(g.State);if(g.onStateChanged!=null){g.onStateChanged(g,g.State)}};g.Stop=function(){if(g.debugmode==1){console.log("stop")}if(g.rtcKeepAlive!=null){clearInterval(g.rtcKeepAlive);g.rtcKeepAlive=null}g.xxStateChange(0)};g.xxSendRtcKeepAlive=function(){g.sendCtrlMsg(JSON.stringify({action:"ping"}))};return g};var CreateAgentRemoteDesktop=function(a,e){var d={};d.CanvasId=a;if(typeof a==="string"){d.CanvasId=Q(a)}d.Canvas=d.CanvasId.getContext("2d");d.scrolldiv=e;d.State=0;d.PendingOperations=[];d.tilesReceived=0;d.TilesDrawn=0;d.KillDraw=0;d.ipad=false;d.tabletKeyboardVisible=false;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=false;d.localKeyMap=true;d.altPressed=false;d.ctrlPressed=false;d.shiftPressed=false;d.sessionid=0;d.username;d.oldie=false;d.CompressionLevel=50;d.ScalingLevel=1024;d.FrameRateTimer=50;d.FirstDraw=false;d.ScreenWidth=960;d.ScreenHeight=700;d.width=960;d.height=960;d.onScreenSizeChange=null;d.onMessage=null;d.onConnectCountChanged=null;d.onDebugMessage=null;d.onTouchEnabledChanged=null;d.onDisplayinfo=null;d.accumulator=null;d.Start=function(){d.State=0;d.accumulator=null};d.Stop=function(){d.setRotation(0);d.UnGrabKeyInput();d.UnGrabMouseInput();d.touchenabled=0;if(d.onScreenSizeChange!=null){d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)}d.Canvas.clearRect(0,0,d.CanvasId.width,d.CanvasId.height)};d.xxStateChange=function(g){if(d.State==g){return}d.State=g;d.CanvasId.style.cursor="default";switch(g){case 0:d.Stop();break;case 3:break}};d.send=function(g){if(d.debugmode>1){console.log("KSend("+g.length+"): "+rstr2hex(g))}d.parent.send(g)};d.ProcessPictureMsg=function(h,k,l){var j=new Image();j.xcount=d.tilesReceived++;var g=d.tilesReceived;j.src="data:image/jpeg;base64,"+btoa(h.substring(4,h.length));j.onload=function(){if(d.Canvas!=null&&d.KillDraw<g&&d.State!=0){d.PendingOperations.push([g,2,j,k,l]);while(d.DoPendingOperations()){}}};j.error=function(){console.log("DecodeTileError")}};d.DoPendingOperations=function(){if(d.PendingOperations.length==0){return false}for(var g=0;g<d.PendingOperations.length;g++){var h=d.PendingOperations[g];if(h[0]==(d.TilesDrawn+1)){if(h[1]==1){d.ProcessCopyRectMsg(h[2])}else{if(h[1]==2){d.Canvas.drawImage(h[2],d.rotX(h[3],h[4]),d.rotY(h[3],h[4]));delete h[2]}}d.PendingOperations.splice(g,1);delete h;d.TilesDrawn++;if(d.TilesDrawn==d.tilesReceived&&d.KillDraw<d.TilesDrawn){d.KillDraw=d.TilesDrawn=d.tilesReceived=0}return true}}if(d.oldie&&d.PendingOperations.length>0){d.TilesDrawn++}return false};d.ProcessCopyRectMsg=function(k){var l=((k.charCodeAt(0)&255)<<8)+(k.charCodeAt(1)&255);var m=((k.charCodeAt(2)&255)<<8)+(k.charCodeAt(3)&255);var g=((k.charCodeAt(4)&255)<<8)+(k.charCodeAt(5)&255);var h=((k.charCodeAt(6)&255)<<8)+(k.charCodeAt(7)&255);var n=((k.charCodeAt(8)&255)<<8)+(k.charCodeAt(9)&255);var j=((k.charCodeAt(10)&255)<<8)+(k.charCodeAt(11)&255);d.Canvas.drawImage(Canvas.canvas,l,m,n,j,g,h,n,j)};d.SendUnPause=function(){d.send(String.fromCharCode(0,8,0,5,0))};d.SendPause=function(){d.send(String.fromCharCode(0,8,0,5,1))};d.SendCompressionLevel=function(k,h,j,g){if(h){d.CompressionLevel=h}if(j){d.ScalingLevel=j}if(g){d.FrameRateTimer=g}d.send(String.fromCharCode(0,5,0,10,k,d.CompressionLevel)+d.shortToStr(d.ScalingLevel)+d.shortToStr(d.FrameRateTimer))};d.SendRefresh=function(){d.send(String.fromCharCode(0,6,0,4))};d.ProcessScreenMsg=function(h,g){if(d.debugmode>0){console.log("ScreenSize: "+h+" x "+g)}d.Canvas.setTransform(1,0,0,1,0,0);d.rotation=0;d.FirstDraw=true;d.ScreenWidth=d.width=h;d.ScreenHeight=d.height=g;d.KillDraw=d.tilesReceived;while(d.PendingOperations.length>0){d.PendingOperations.shift()}d.SendCompressionLevel(1);d.SendUnPause();if(d.onScreenSizeChange!=null){d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)}};d.ProcessData=function(h){var g=0;while(g<h.length){g+=d.ProcessDataEx(h.substring(g))}};d.ProcessDataEx=function(q){if(d.accumulator!=null){q=d.accumulator+q;d.accumulator=null}if(d.debugmode>1){console.log("KRecv("+q.length+"): "+rstr2hex(q.substring(0,Math.min(q.length,40))))}if(q.length<4){return}var g=null,r=0,s=0,j=ReadShort(q,0),h=ReadShort(q,2),o=0;if((j==27)&&(h==8)){if(q.length<12){return}j=ReadShort(q,8);h=ReadInt(q,4);if((h+8)>q.length){d.accumulator=q;return}q=q.substring(8);o=8}if((h!=q.length)&&(d.debugmode>0)){console.log(h,q.length,h==q.length)}if((j>=18)&&(j!=65)){console.error("Invalid KVM command "+j+" of size "+h);console.log("Invalid KVM data",q.length,rstr2hex(q.substring(0,40))+"...");return}if(h>q.length){d.accumulator=q;return}if(j==3||j==4||j==7){g=q.substring(4,h);r=((g.charCodeAt(0)&255)<<8)+(g.charCodeAt(1)&255);s=((g.charCodeAt(2)&255)<<8)+(g.charCodeAt(3)&255);if(d.debugmode>0){console.log("CMD"+j+" at X="+r+" Y="+s)}}switch(j){case 3:if(d.FirstDraw){d.onResize()}d.ProcessPictureMsg(g,r,s);break;case 4:if(d.FirstDraw){d.onResize()}if(d.TilesDrawn==d.tilesReceived){d.ProcessCopyRectMsg(g)}else{d.PendingOperations.push([++tilesReceived,1,g])}break;case 7:d.ProcessScreenMsg(r,s);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 p=0,m={},k=((q.charCodeAt(4)&255)<<8)+(q.charCodeAt(5)&255);if(k>0){p=((q.charCodeAt(6+(k*2))&255)<<8)+(q.charCodeAt(7+(k*2))&255);for(var n=0;n<k;n++){var l=((q.charCodeAt(6+(n*2))&255)<<8)+(q.charCodeAt(7+(n*2))&255);if(l==65535){m[l]="All Displays"}else{m[l]="Display "+l}}}if(d.onDisplayinfo!=null){d.onDisplayinfo(d,m,p)}break;case 12:break;case 14:d.touchenabled=1;d.TouchArray={};if(d.onTouchEnabledChanged!=null){d.onTouchEnabledChanged(d.touchenabled)}break;case 15:d.TouchArray={};break;case 16:d.connectioncount=ReadInt(q,4);if(d.onConnectCountChanged!=null){d.onConnectCountChanged(d.connectioncount,d)}break;case 17:if(d.onMessage!=null){d.onMessage(q.substring(4,h),d)}break;case 65:q=q.substring(4);if(q[0]!="."){console.log(q);d.parent.consoleMessage=q;if(d.parent.onConsoleMessageChange){d.parent.onConsoleMessageChange(d.parent,q)}}else{console.log("KVM: "+q.substring(1))}break}return h+o};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};d.Alternate=0;var c={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 b(g){if(g.code.startsWith("Key")&&g.code.length==4){return g.code.charCodeAt(3)}if(g.code.startsWith("Digit")&&g.code.length==6){return g.code.charCodeAt(5)}if(g.code.startsWith("Numpad")&&g.code.length==7){return g.code.charCodeAt(6)+48}return c[g.code]}d.SendKeyMsg=function(g,h){if(g==null){return}if(!h){h=window.event}if(h.code&&(d.localKeyMap==false)){var j=b(h);if(j!=null){d.SendKeyMsgKC(g,j)}}else{var j=h.keyCode;if(j==59){j=186}else{if(j==173){j=189}else{if(j==61){j=187}}}d.SendKeyMsgKC(g,j)}};d.SendMessage=function(g){if(d.State==3){d.send(String.fromCharCode(0,17)+d.shortToStr(4+g.length)+g)}};d.SendKeyMsgKC=function(g,j){if(d.State!=3){return}if(typeof g=="object"){for(var h in g){d.SendKeyMsgKC(g[h][0],g[h][1])}}else{d.send(String.fromCharCode(0,d.InputType.KEY,0,6,(g-1),j))}};d.sendcad=function(){d.SendCtrlAltDelMsg()};d.SendCtrlAltDelMsg=function(){if(d.State==3){d.send(String.fromCharCode(0,d.InputType.CTRLALTDEL,0,4))}};d.SendEscKey=function(){if(d.State==3){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(h,g,j,k){if(d.State==3){d.send(String.fromCharCode(0,d.InputType.TOUCH)+d.shortToStr(14)+String.fromCharCode(1,h)+d.intToStr(g)+d.shortToStr(j)+d.shortToStr(k))}};d.SendTouchMsg2=function(j,g){var m="";var h;var n="TOUCHSEND: ";for(var l in d.TouchArray){if(l==j){h=g}else{if(d.TouchArray[l].f==1){h=65536|2|4;d.TouchArray[l].f=3;n+="START"+l}else{if(d.TouchArray[l].f==2){h=262144;n+="STOP"+l}else{h=2|4|131072}}}m+=String.fromCharCode(l)+d.intToStr(h)+d.shortToStr(d.TouchArray[l].x)+d.shortToStr(d.TouchArray[l].y);if(d.TouchArray[l].f==2){delete d.TouchArray[l]}}if(d.State==3){d.send(String.fromCharCode(0,d.InputType.TOUCH)+d.shortToStr(5+m.length)+String.fromCharCode(2)+m)}if(Object.keys(d.TouchArray).length==0&&d.touchtimer!=null){clearInterval(d.touchtimer);d.touchtimer=null}};d.SendMouseMsg=function(g,k){if(d.State!=3){return}if(g!=null&&d.Canvas!=null){if(!k){var k=window.event}var n=(d.Canvas.canvas.height/d.CanvasId.clientHeight);var o=(d.Canvas.canvas.width/d.CanvasId.clientWidth);var m=d.GetPositionOfControl(d.Canvas.canvas);var p=((k.pageX-m[0])*o);var q=((k.pageY-m[1])*n);if(k.addx){p+=k.addx}if(k.addy){q+=k.addy}if(p>=0&&p<=d.Canvas.canvas.width&&q>=0&&q<=d.Canvas.canvas.height){var h=0;var j=0;if(g==d.KeyAction.UP||g==d.KeyAction.DOWN){if(k.which){((k.which==1)?(h=d.MouseButton.LEFT):((k.which==2)?(h=d.MouseButton.MIDDLE):(h=d.MouseButton.RIGHT)))}else{if(k.button){((k.button==0)?(h=d.MouseButton.LEFT):((k.button==1)?(h=d.MouseButton.MIDDLE):(h=d.MouseButton.RIGHT)))}}}else{if(g==d.KeyAction.SCROLL){if(k.detail){j=(-1*(k.detail*120))}else{if(k.wheelDelta){j=(k.wheelDelta*3)}}}}var l="";if(g==d.KeyAction.DBLCLICK){l=String.fromCharCode(0,d.InputType.MOUSE,0,10,0,136,((p/256)&255),(p&255),((q/256)&255),(q&255))}else{if(g==d.KeyAction.SCROLL){l=String.fromCharCode(0,d.InputType.MOUSE,0,12,0,0,((p/256)&255),(p&255),((q/256)&255),(q&255),((j/256)&255),(j&255))}else{l=String.fromCharCode(0,d.InputType.MOUSE,0,10,0,((g==d.KeyAction.DOWN)?h:((h*2)&255)),((p/256)&255),(p&255),((q/256)&255),(q&255))}}if(d.Action==d.KeyAction.NONE){if(d.Alternate==0||d.ipad){d.send(l);d.Alternate=1}else{d.Alternate=0}}else{d.send(l)}}}};d.GetDisplayNumbers=function(){d.send(String.fromCharCode(0,11,0,4))};d.SetDisplay=function(g){console.log("Set display",g);d.send(String.fromCharCode(0,12,0,6,g>>8,g&255))};d.intToStr=function(g){return String.fromCharCode((g>>24)&255,(g>>16)&255,(g>>8)&255,g&255)};d.shortToStr=function(g){return String.fromCharCode((g>>8)&255,g&255)};d.onResize=function(){if(d.ScreenWidth==0||d.ScreenHeight==0){return}if(d.Canvas.canvas.width==d.ScreenWidth&&d.Canvas.canvas.height==d.ScreenHeight){return}if(d.FirstDraw){d.Canvas.canvas.width=d.ScreenWidth;d.Canvas.canvas.height=d.ScreenHeight;d.Canvas.fillRect(0,0,d.ScreenWidth,d.ScreenHeight);if(d.onScreenSizeChange!=null){d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)}}d.FirstDraw=false};d.xxMouseInputGrab=false;d.xxKeyInputGrab=false;d.xxMouseMove=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.NONE,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxMouseUp=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.UP,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxMouseDown=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.DOWN,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxMouseDblClick=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.DBLCLICK,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxDOMMouseScroll=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.SCROLL,g);return false}return true};d.xxMouseWheel=function(g){if(d.State==3){d.SendMouseMsg(d.KeyAction.SCROLL,g);return false}return true};d.xxKeyUp=function(g){if(d.State==3){d.SendKeyMsg(d.KeyAction.UP,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxKeyDown=function(g){if(d.State==3){d.SendKeyMsg(d.KeyAction.DOWN,g)}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.xxKeyPress=function(g){if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};d.handleKeys=function(g){if(d.stopInput==true||desktop.State!=3){return false}return d.xxKeyPress(g)};d.handleKeyUp=function(g){if(d.stopInput==true||desktop.State!=3){return false}if(d.firstUpKeys.length<5){d.firstUpKeys.push(g.keyCode);if((d.firstUpKeys.length==5)){var h=d.firstUpKeys.join(",");if((h=="16,17,91,91,16")||(h=="16,17,18,91,92")){d.stopInput=true}}}if(g.keyCode==16){d.shiftPressed=false}if(g.keyCode==17){d.ctrlPressed=false}if(g.keyCode==18){d.altPressed=false}return d.xxKeyUp(g)};d.handleKeyDown=function(g){if(d.stopInput==true||desktop.State!=3){return false}if(g.keyCode==16){d.shiftPressed=true}if(g.keyCode==17){d.ctrlPressed=true}if(g.keyCode==18){d.altPressed=true}return d.xxKeyDown(g)};d.handleReleaseKeys=function(){if(d.shiftPressed){d.SendKeyMsgKC(d.KeyAction.UP,16)}if(d.ctrlPressed){d.SendKeyMsgKC(d.KeyAction.UP,17)}if(d.altPressed){d.SendKeyMsgKC(d.KeyAction.UP,18)}d.shiftPressed=d.ctrlPressed=d.altPressed=false};d.mousedblclick=function(g){if(d.stopInput==true){return false}return d.xxMouseDblClick(g)};d.mousedown=function(g){if(d.stopInput==true){return false}return d.xxMouseDown(g)};d.mouseup=function(g){if(d.stopInput==true){return false}return d.xxMouseUp(g)};d.mousemove=function(g){if(d.stopInput==true){return false}return d.xxMouseMove(g)};d.mousewheel=function(g){if(d.stopInput==true){return false}return d.xxMouseWheel(g)};d.xxMsTouchEvent=function(g){if(g.originalEvent.pointerType==4){return}if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}if(g.type=="MSPointerDown"||g.type=="MSPointerMove"||g.type=="MSPointerUp"){var h=0;var j=g.originalEvent.pointerId%256;var k=g.offsetX*(Canvas.canvas.width/d.CanvasId.clientWidth);var l=g.offsetY*(Canvas.canvas.height/d.CanvasId.clientHeight);if(g.type=="MSPointerDown"){h=65536|2|4}else{if(g.type=="MSPointerMove"){h=131072|2|4}else{if(g.type=="MSPointerUp"){h=262144}}}if(!d.TouchArray[j]){d.TouchArray[j]={x:k,y:l}}d.SendTouchMsg2(j,h);if(g.type=="MSPointerUp"){delete d.TouchArray[j]}}else{alert(g.type)}return true};d.xxTouchStart=function(g){if(d.State!=3){return}if(g.preventDefault){g.preventDefault()}if(d.touchenabled==0||d.touchenabled==1){if(g.originalEvent.touches.length>1){return}var l=g.originalEvent.touches[0];g.which=1;d.LastX=g.pageX=l.pageX;d.LastY=g.pageY=l.pageY;d.SendMouseMsg(KeyAction.DOWN,g)}else{var k=d.GetPositionOfControl(Canvas.canvas);for(var h in g.originalEvent.changedTouches){if(!g.originalEvent.changedTouches[h].identifier){continue}var j=g.originalEvent.changedTouches[h].identifier%256;if(!d.TouchArray[j]){d.TouchArray[j]={x:(g.originalEvent.touches[h].pageX-k[0])*(Canvas.canvas.width/d.CanvasId.clientWidth),y:(g.originalEvent.touches[h].pageY-k[1])*(Canvas.canvas.height/d.CanvasId.clientHeight),f:1}}}if(Object.keys(d.TouchArray).length>0&&touchtimer==null){d.touchtimer=setInterval(function(){d.SendTouchMsg2(256,0)},50)}}};d.xxTouchMove=function(g){if(d.State!=3){return}if(g.preventDefault){g.preventDefault()}if(d.touchenabled==0||d.touchenabled==1){if(g.originalEvent.touches.length>1){return}var l=g.originalEvent.touches[0];g.which=1;d.LastX=g.pageX=l.pageX;d.LastY=g.pageY=l.pageY;d.SendMouseMsg(d.KeyAction.NONE,g)}else{var k=d.GetPositionOfControl(Canvas.canvas);for(var h in g.originalEvent.changedTouches){if(!g.originalEvent.changedTouches[h].identifier){continue}var j=g.originalEvent.changedTouches[h].identifier%256;if(d.TouchArray[j]){d.TouchArray[j].x=(g.originalEvent.touches[h].pageX-k[0])*(d.Canvas.canvas.width/d.CanvasId.clientWidth);d.TouchArray[j].y=(g.originalEvent.touches[h].pageY-k[1])*(d.Canvas.canvas.height/d.CanvasId.clientHeight)}}}};d.xxTouchEnd=function(g){if(d.State!=3){return}if(g.preventDefault){g.preventDefault()}if(d.touchenabled==0||d.touchenabled==1){if(g.originalEvent.touches.length>1){return}g.which=1;g.pageX=LastX;g.pageY=LastY;d.SendMouseMsg(KeyAction.UP,g)}else{for(var h in g.originalEvent.changedTouches){if(!g.originalEvent.changedTouches[h].identifier){continue}var j=g.originalEvent.changedTouches[h].identifier%256;if(d.TouchArray[j]){d.TouchArray[j].f=2}}}};d.GrabMouseInput=function(){if(d.xxMouseInputGrab==true){return}var g=d.CanvasId;g.onmousemove=d.xxMouseMove;g.onmouseup=d.xxMouseUp;g.onmousedown=d.xxMouseDown;g.touchstart=d.xxTouchStart;g.touchmove=d.xxTouchMove;g.touchend=d.xxTouchEnd;g.MSPointerDown=d.xxMsTouchEvent;g.MSPointerMove=d.xxMsTouchEvent;g.MSPointerUp=d.xxMsTouchEvent;if(navigator.userAgent.match(/mozilla/i)){g.DOMMouseScroll=d.xxDOMMouseScroll}else{g.onmousewheel=d.xxMouseWheel}d.xxMouseInputGrab=true};d.UnGrabMouseInput=function(){if(d.xxMouseInputGrab==false){return}var g=d.CanvasId;g.onmousemove=null;g.onmouseup=null;g.onmousedown=null;g.touchstart=null;g.touchmove=null;g.touchend=null;g.MSPointerDown=null;g.MSPointerMove=null;g.MSPointerUp=null;if(navigator.userAgent.match(/mozilla/i)){g.DOMMouseScroll=null}else{g.onmousewheel=null}d.xxMouseInputGrab=false};d.GrabKeyInput=function(){if(d.xxKeyInputGrab==true){return}document.onkeyup=d.xxKeyUp;document.onkeydown=d.xxKeyDown;document.onkeypress=d.xxKeyPress;d.xxKeyInputGrab=true};d.UnGrabKeyInput=function(){if(d.xxKeyInputGrab==false){return}document.onkeyup=null;document.onkeydown=null;document.onkeypress=null;d.xxKeyInputGrab=false};d.GetPositionOfControl=function(g){var h=Array(2);h[0]=h[1]=0;while(g){h[0]+=g.offsetLeft;h[1]+=g.offsetTop;g=g.offsetParent}return h};d.crotX=function(g,h){if(d.rotation==0){return g}if(d.rotation==1){return h}if(d.rotation==2){return d.Canvas.canvas.width-g}if(d.rotation==3){return d.Canvas.canvas.height-h}};d.crotY=function(g,h){if(d.rotation==0){return h}if(d.rotation==1){return d.Canvas.canvas.width-g}if(d.rotation==2){return d.Canvas.canvas.height-h}if(d.rotation==3){return g}};d.rotX=function(g,h){if(d.rotation==0||d.rotation==1){return g}if(d.rotation==2){return g-d.Canvas.canvas.width}if(d.rotation==3){return g-d.Canvas.canvas.height}};d.rotY=function(g,h){if(d.rotation==0||d.rotation==3){return h}if(d.rotation==1){return h-d.Canvas.canvas.width}if(d.rotation==2){return h-d.Canvas.canvas.height}};d.tcanvas=null;d.setRotation=function(l){while(l<0){l+=4}var g=l%4;if(g==d.rotation){return true}var j=d.Canvas.canvas.width;var h=d.Canvas.canvas.height;if(d.rotation==1||d.rotation==3){j=d.Canvas.canvas.height;h=d.Canvas.canvas.width}if(d.tcanvas==null){d.tcanvas=document.createElement("canvas")}var k=d.tcanvas.getContext("2d");k.setTransform(1,0,0,1,0,0);k.canvas.width=j;k.canvas.height=h;k.rotate((d.rotation*-90)*Math.PI/180);if(d.rotation==0){k.drawImage(d.Canvas.canvas,0,0)}if(d.rotation==1){k.drawImage(d.Canvas.canvas,-d.Canvas.canvas.width,0)}if(d.rotation==2){k.drawImage(d.Canvas.canvas,-d.Canvas.canvas.width,-d.Canvas.canvas.height)}if(d.rotation==3){k.drawImage(d.Canvas.canvas,0,-d.Canvas.canvas.height)}if(d.rotation==0||d.rotation==2){d.Canvas.canvas.height=j;d.Canvas.canvas.width=h}if(d.rotation==1||d.rotation==3){d.Canvas.canvas.height=h;d.Canvas.canvas.width=j}d.Canvas.setTransform(1,0,0,1,0,0);d.Canvas.rotate((g*90)*Math.PI/180);d.rotation=g;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;if(d.onScreenSizeChange!=null){d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)}return true};d.MuchTheSame=function(g,h){return(Math.abs(g-h)<4)};d.Debug=function(g){console.log(g)};d.getIEVersion=function(){var g=-1;if(navigator.appName=="Microsoft Internet Explorer"){var j=navigator.userAgent;var h=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");if(h.exec(j)!=null){g=parseFloat(RegExp.$1)}}return g};d.haltEvent=function(g){if(g.preventDefault){g.preventDefault()}if(g.stopPropagation){g.stopPropagation()}return false};return d};var QRCode;!function(){function t(c){this.mode=v.MODE_8BIT_BYTE,this.data=c,this.parsedData=[];for(var g=[],h=0,j=this.data.length;j>h;h++){var k=this.data.charCodeAt(h);k>65536?(g[0]=240|(1835008&k)>>>18,g[1]=128|(258048&k)>>>12,g[2]=128|(4032&k)>>>6,g[3]=128|63&k):k>2048?(g[0]=224|(61440&k)>>>12,g[1]=128|(4032&k)>>>6,g[2]=128|63&k):k>128?(g[0]=192|(1984&k)>>>6,g[1]=128|63&k):g[0]=k,this.parsedData=this.parsedData.concat(g)}this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function u(c,d){this.typeNumber=c,this.errorCorrectLevel=d,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function B(e,g){if(void 0==e.length){throw new Error(e.length+"/"+g)}for(var h=0;h<e.length&&0==e[h];){h++}this.num=new Array(e.length-h+g);for(var j=0;j<e.length-h;j++){this.num[j]=e[j+h]}}function C(c,d){this.totalCount=c,this.dataCount=d}function D(){this.buffer=[],this.length=0}function F(){return"undefined"!=typeof CanvasRenderingContext2D}function G(){var c=!1,d=navigator.userAgent;return/android/i.test(d)&&(c=!0,aMat=d.toString().match(/android ([0-9]\.[0-9])/i),aMat&&aMat[1]&&(c=parseFloat(aMat[1]))),c}function K(d,j){for(var k=1,l=L(d),m=0,n=E.length;n>=m;m++){var o=0;switch(j){case w.L:o=E[m][0];break;case w.M:o=E[m][1];break;case w.Q:o=E[m][2];break;case w.H:o=E[m][3]}if(o>=l){break}k++}if(k>E.length){throw new Error("Too long data")}return k}function L(c){var d=encodeURI(c).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return d.length+(d.length!=c?3:0)}t.prototype={getLength:function(){return this.parsedData.length},write:function(d){for(var e=0,g=this.parsedData.length;g>e;e++){d.put(this.parsedData[e],8)}}},u.prototype={addData:function(a){var d=new t(a);this.dataList.push(d),this.dataCache=null},isDark:function(c,d){if(0>c||this.moduleCount<=c||0>d||this.moduleCount<=d){throw new Error(c+","+d)}return this.modules[c][d]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(b,g){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var h=0;h<this.moduleCount;h++){this.modules[h]=new Array(this.moduleCount);for(var j=0;j<this.moduleCount;j++){this.modules[h][j]=null}}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(b,g),this.typeNumber>=7&&this.setupTypeNumber(b),null==this.dataCache&&(this.dataCache=u.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,g)},setupPositionProbePattern:function(e,g){for(var h=-1;7>=h;h++){if(!(-1>=e+h||this.moduleCount<=e+h)){for(var j=-1;7>=j;j++){-1>=g+j||this.moduleCount<=g+j||(this.modules[e+h][g+j]=h>=0&&6>=h&&(0==j||6==j)||j>=0&&6>=j&&(0==h||6==h)||h>=2&&4>=h&&j>=2&&4>=j?!0:!1)}}}},getBestMaskPattern:function(){for(var e=0,g=0,h=0;8>h;h++){this.makeImpl(!0,h);var j=y.getLostPoint(this);(0==h||e>j)&&(e=j,g=h)}return g},createMovieClip:function(k,l,m){var n=k.createEmptyMovieClip(l,m),o=1;this.make();for(var p=0;p<this.modules.length;p++){for(var q=p*o,r=0;r<this.modules[p].length;r++){var s=r*o,M=this.modules[p][r];M&&(n.beginFill(0,100),n.moveTo(s,q),n.lineTo(s+o,q),n.lineTo(s+o,q+o),n.lineTo(s,q+o),n.endFill())}}return n},setupTimingPattern:function(){for(var c=8;c<this.moduleCount-8;c++){null==this.modules[c][6]&&(this.modules[c][6]=0==c%2)}for(var d=8;d<this.moduleCount-8;d++){null==this.modules[6][d]&&(this.modules[6][d]=0==d%2)}},setupPositionAdjustPattern:function(){for(var j=y.getPatternPosition(this.typeNumber),k=0;k<j.length;k++){for(var l=0;l<j.length;l++){var m=j[k],n=j[l];if(null==this.modules[m][n]){for(var o=-2;2>=o;o++){for(var p=-2;2>=p;p++){this.modules[m+o][n+p]=-2==o||2==o||-2==p||2==p||0==o&&0==p?!0:!1}}}}}},setupTypeNumber:function(e){for(var g=y.getBCHTypeNumber(this.typeNumber),h=0;18>h;h++){var j=!e&&1==(1&g>>h);this.modules[Math.floor(h/3)][h%3+this.moduleCount-8-3]=j}for(var h=0;18>h;h++){var j=!e&&1==(1&g>>h);this.modules[h%3+this.moduleCount-8-3][Math.floor(h/3)]=j}},setupTypeInfo:function(h,j){for(var k=this.errorCorrectLevel<<3|j,l=y.getBCHTypeInfo(k),m=0;15>m;m++){var n=!h&&1==(1&l>>m);6>m?this.modules[m][8]=n:8>m?this.modules[m+1][8]=n:this.modules[this.moduleCount-15+m][8]=n}for(var m=0;15>m;m++){var n=!h&&1==(1&l>>m);8>m?this.modules[8][this.moduleCount-m-1]=n:9>m?this.modules[8][15-m-1+1]=n:this.modules[8][15-m-1]=n}this.modules[this.moduleCount-8][8]=!h},mapData:function(l,m){for(var n=-1,o=this.moduleCount-1,p=7,q=0,r=this.moduleCount-1;r>0;r-=2){for(6==r&&r--;;){for(var s=0;2>s;s++){if(null==this.modules[o][r-s]){var M=!1;q<l.length&&(M=1==(1&l[q]>>>p));var N=y.getMask(m,o,r-s);N&&(M=!M),this.modules[o][r-s]=M,p--,-1==p&&(q++,p=7)}}if(o+=n,0>o||this.moduleCount<=o){o-=n,n=-n;break}}}}},u.PAD0=236,u.PAD1=17,u.createData=function(b,j,k){for(var m=C.getRSBlocks(b,j),n=new D,o=0;o<k.length;o++){var p=k[o];n.put(p.mode,4),n.put(p.getLength(),y.getLengthInBits(p.mode,b)),p.write(n)}for(var q=0,o=0;o<m.length;o++){q+=m[o].dataCount}if(n.getLengthInBits()>8*q){throw new Error("code length overflow. ("+n.getLengthInBits()+">"+8*q+")")}for(n.getLengthInBits()+4<=8*q&&n.put(0,4);0!=n.getLengthInBits()%8;){n.putBit(!1)}for(;;){if(n.getLengthInBits()>=8*q){break}if(n.put(u.PAD0,8),n.getLengthInBits()>=8*q){break}n.put(u.PAD1,8)}return u.createBytes(n,m)},u.createBytes=function(M,N){for(var O=0,P=0,R=0,S=new Array(N.length),T=new Array(N.length),U=0;U<N.length;U++){var V=N[U].dataCount,W=N[U].totalCount-V;P=Math.max(P,V),R=Math.max(R,W),S[U]=new Array(V);for(var X=0;X<S[U].length;X++){S[U][X]=255&M.buffer[X+O]}O+=V;var Y=y.getErrorCorrectPolynomial(W),Z=new B(S[U],Y.getLength()-1),aa=Z.mod(Y);T[U]=new Array(Y.getLength()-1);for(var X=0;X<T[U].length;X++){var ab=X+aa.getLength()-T[U].length;T[U][X]=ab>=0?aa.get(ab):0}}for(var ac=0,X=0;X<N.length;X++){ac+=N[X].totalCount}for(var ad=new Array(ac),ae=0,X=0;P>X;X++){for(var U=0;U<N.length;U++){X<S[U].length&&(ad[ae++]=S[U][X])}}for(var X=0;R>X;X++){for(var U=0;U<N.length;U++){X<T[U].length&&(ad[ae++]=T[U][X])}}return ad};for(var v={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},w={L:1,M:0,Q:3,H:2},x={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},y={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(c){for(var d=c<<10;y.getBCHDigit(d)-y.getBCHDigit(y.G15)>=0;){d^=y.G15<<y.getBCHDigit(d)-y.getBCHDigit(y.G15)}return(c<<10|d)^y.G15_MASK},getBCHTypeNumber:function(c){for(var d=c<<12;y.getBCHDigit(d)-y.getBCHDigit(y.G18)>=0;){d^=y.G18<<y.getBCHDigit(d)-y.getBCHDigit(y.G18)}return c<<12|d},getBCHDigit:function(c){for(var d=0;0!=c;){d++,c>>>=1}return d},getPatternPosition:function(b){return y.PATTERN_POSITION_TABLE[b-1]},getMask:function(d,e,g){switch(d){case x.PATTERN000:return 0==(e+g)%2;case x.PATTERN001:return 0==e%2;case x.PATTERN010:return 0==g%3;case x.PATTERN011:return 0==(e+g)%3;case x.PATTERN100:return 0==(Math.floor(e/2)+Math.floor(g/3))%2;case x.PATTERN101:return 0==e*g%2+e*g%3;case x.PATTERN110:return 0==(e*g%2+e*g%3)%2;case x.PATTERN111:return 0==(e*g%3+(e+g)%2)%2;default:throw new Error("bad maskPattern:"+d)}},getErrorCorrectPolynomial:function(d){for(var e=new B([1],0),g=0;d>g;g++){e=e.multiply(new B([1,z.gexp(g)],0))}return e},getLengthInBits:function(c,d){if(d>=1&&10>d){switch(c){case v.MODE_NUMBER:return 10;case v.MODE_ALPHA_NUM:return 9;case v.MODE_8BIT_BYTE:return 8;case v.MODE_KANJI:return 8;default:throw new Error("mode:"+c)}}else{if(27>d){switch(c){case v.MODE_NUMBER:return 12;case v.MODE_ALPHA_NUM:return 11;case v.MODE_8BIT_BYTE:return 16;case v.MODE_KANJI:return 10;default:throw new Error("mode:"+c)}}else{if(!(41>d)){throw new Error("type:"+d)}switch(c){case v.MODE_NUMBER:return 14;case v.MODE_ALPHA_NUM:return 13;case v.MODE_8BIT_BYTE:return 16;case v.MODE_KANJI:return 12;default:throw new Error("mode:"+c)}}}},getLostPoint:function(m){for(var n=m.getModuleCount(),o=0,p=0;n>p;p++){for(var q=0;n>q;q++){for(var r=0,s=m.isDark(p,q),M=-1;1>=M;M++){if(!(0>p+M||p+M>=n)){for(var N=-1;1>=N;N++){0>q+N||q+N>=n||(0!=M||0!=N)&&s==m.isDark(p+M,q+N)&&r++}}}r>5&&(o+=3+r-5)}}for(var p=0;n-1>p;p++){for(var q=0;n-1>q;q++){var O=0;m.isDark(p,q)&&O++,m.isDark(p+1,q)&&O++,m.isDark(p,q+1)&&O++,m.isDark(p+1,q+1)&&O++,(0==O||4==O)&&(o+=3)}}for(var p=0;n>p;p++){for(var q=0;n-6>q;q++){m.isDark(p,q)&&!m.isDark(p,q+1)&&m.isDark(p,q+2)&&m.isDark(p,q+3)&&m.isDark(p,q+4)&&!m.isDark(p,q+5)&&m.isDark(p,q+6)&&(o+=40)}}for(var q=0;n>q;q++){for(var p=0;n-6>p;p++){m.isDark(p,q)&&!m.isDark(p+1,q)&&m.isDark(p+2,q)&&m.isDark(p+3,q)&&m.isDark(p+4,q)&&!m.isDark(p+5,q)&&m.isDark(p+6,q)&&(o+=40)}}for(var P=0,q=0;n>q;q++){for(var p=0;n>p;p++){m.isDark(p,q)&&P++}}var R=Math.abs(100*P/n/n-50)/5;return o+=10*R}},z={glog:function(b){if(1>b){throw new Error("glog("+b+")")}return z.LOG_TABLE[b]},gexp:function(b){for(;0>b;){b+=255}for(;b>=256;){b-=255}return z.EXP_TABLE[b]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},A=0;8>A;A++){z.EXP_TABLE[A]=1<<A}for(var A=8;256>A;A++){z.EXP_TABLE[A]=z.EXP_TABLE[A-4]^z.EXP_TABLE[A-5]^z.EXP_TABLE[A-6]^z.EXP_TABLE[A-8]}for(var A=0;255>A;A++){z.LOG_TABLE[z.EXP_TABLE[A]]=A}B.prototype={get:function(b){return this.num[b]},getLength:function(){return this.num.length},multiply:function(e){for(var g=new Array(this.getLength()+e.getLength()-1),h=0;h<this.getLength();h++){for(var j=0;j<e.getLength();j++){g[h+j]^=z.gexp(z.glog(this.get(h))+z.glog(e.get(j)))}}return new B(g,0)},mod:function(e){if(this.getLength()-e.getLength()<0){return this}for(var g=z.glog(this.get(0))-z.glog(e.get(0)),h=new Array(this.getLength()),j=0;j<this.getLength();j++){h[j]=this.get(j)}for(var j=0;j<e.getLength();j++){h[j]^=z.gexp(z.glog(e.get(j))+g)}return new B(h,0).mod(e)}},C.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],C.getRSBlocks=function(j,l){var m=C.getRsBlockTable(j,l);if(void 0==m){throw new Error("bad rs block @ typeNumber:"+j+"/errorCorrectLevel:"+l)}for(var n=m.length/3,o=[],p=0;n>p;p++){for(var q=m[3*p+0],r=m[3*p+1],s=m[3*p+2],M=0;q>M;M++){o.push(new C(r,s))}}return o},C.getRsBlockTable=function(c,d){switch(d){case w.L:return C.RS_BLOCK_TABLE[4*(c-1)+0];case w.M:return C.RS_BLOCK_TABLE[4*(c-1)+1];case w.Q:return C.RS_BLOCK_TABLE[4*(c-1)+2];case w.H:return C.RS_BLOCK_TABLE[4*(c-1)+3];default:return void 0}},D.prototype={get:function(c){var d=Math.floor(c/8);return 1==(1&this.buffer[d]>>>7-c%8)},put:function(d,e){for(var g=0;e>g;g++){this.putBit(1==(1&d>>>e-g-1))}},getLengthInBits:function(){return this.length},putBit:function(c){var d=Math.floor(this.length/8);this.buffer.length<=d&&this.buffer.push(0),c&&(this.buffer[d]|=128>>>this.length%8),this.length++}};var E=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]],H=function(){var b=function(c,d){this._el=c,this._htOption=d};return b.prototype.draw=function(e){function o(g,h){var j=document.createElementNS("http://www.w3.org/2000/svg",g);for(var k in h){h.hasOwnProperty(k)&&j.setAttribute(k,h[k])}return j}var l=this._htOption,m=this._el,n=e.getModuleCount();Math.floor(l.width/n),Math.floor(l.height/n),this.clear();var p=o("svg",{viewBox:"0 0 "+String(n)+" "+String(n),width:"100%",height:"100%",fill:l.colorLight});p.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),m.appendChild(p),p.appendChild(o("rect",{fill:l.colorDark,width:"1",height:"1",id:"template"}));for(var q=0;n>q;q++){for(var r=0;n>r;r++){if(e.isDark(q,r)){var s=o("use",{x:String(q),y:String(r)});s.setAttributeNS("http://www.w3.org/1999/xlink","href","#template"),p.appendChild(s)}}}},b.prototype.clear=function(){for(;this._el.hasChildNodes();){this._el.removeChild(this._el.lastChild)}},b}(),I="svg"===document.documentElement.tagName.toLowerCase(),J=I?H:F()?function(){function g(){this._elImage.src=this._elCanvas.toDataURL("image/png"),this._elImage.style.display="block",this._elCanvas.style.display="none"}function k(m,n){var o=this;if(o._fFail=n,o._fSuccess=m,null===o._bSupportDataURI){var p=document.createElement("img"),q=function(){o._bSupportDataURI=!1,o._fFail&&_fFail.call(o)},r=function(){o._bSupportDataURI=!0,o._fSuccess&&o._fSuccess.call(o)};return p.onabort=q,p.onerror=q,p.onload=r,p.src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",void 0}o._bSupportDataURI===!0&&o._fSuccess?o._fSuccess.call(o):o._bSupportDataURI===!1&&o._fFail&&o._fFail.call(o)}if(this._android&&this._android<=2.1){var h=1/window.devicePixelRatio,j=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(b,c,m,n,o,p,q,r){if("nodeName" in b&&/img/i.test(b.nodeName)){for(var s=arguments.length-1;s>=1;s--){arguments[s]=arguments[s]*h}}else{"undefined"==typeof r&&(arguments[1]*=h,arguments[2]*=h,arguments[3]*=h,arguments[4]*=h)}j.apply(this,arguments)}}var l=function(c,d){this._bIsPainted=!1,this._android=G(),this._htOption=d,this._elCanvas=document.createElement("canvas"),this._elCanvas.width=d.width,this._elCanvas.height=d.height,c.appendChild(this._elCanvas),this._el=c,this._oContext=this._elCanvas.getContext("2d"),this._bIsPainted=!1,this._elImage=document.createElement("img"),this._elImage.style.display="none",this._el.appendChild(this._elImage),this._bSupportDataURI=null};return l.prototype.draw=function(o){var p=this._elImage,q=this._oContext,r=this._htOption,s=o.getModuleCount(),M=r.width/s,N=r.height/s,O=Math.round(M),P=Math.round(N);p.style.display="none",this.clear();for(var R=0;s>R;R++){for(var S=0;s>S;S++){var T=o.isDark(R,S),U=S*M,V=R*N;q.strokeStyle=T?r.colorDark:r.colorLight,q.lineWidth=1,q.fillStyle=T?r.colorDark:r.colorLight,q.fillRect(U,V,M,N),q.strokeRect(Math.floor(U)+0.5,Math.floor(V)+0.5,O,P),q.strokeRect(Math.ceil(U)-0.5,Math.ceil(V)-0.5,O,P)}}this._bIsPainted=!0},l.prototype.makeImage=function(){this._bIsPainted&&k.call(this,g)},l.prototype.isPainted=function(){return this._bIsPainted},l.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height),this._bIsPainted=!1},l.prototype.round=function(b){return b?Math.floor(1000*b)/1000:b},l}():function(){var b=function(c,d){this._el=c,this._htOption=d};return b.prototype.draw=function(m){for(var n=this._htOption,o=this._el,p=m.getModuleCount(),q=Math.floor(n.width/p),r=Math.floor(n.height/p),s=['<table style="border:0;border-collapse:collapse;">'],M=0;p>M;M++){s.push("<tr>");for(var N=0;p>N;N++){s.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:'+q+"px;height:"+r+"px;background-color:"+(m.isDark(M,N)?n.colorDark:n.colorLight)+';"></td>')}s.push("</tr>")}s.push("</table>"),o.innerHTML=s.join("");var O=o.childNodes[0],P=(n.width-O.offsetWidth)/2,R=(n.height-O.offsetHeight)/2;P>0&&R>0&&(O.style.margin=R+"px "+P+"px")},b.prototype.clear=function(){this._el.innerHTML=""},b}();QRCode=function(d,e){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:w.H},"string"==typeof e&&(e={text:e}),e){for(var g in e){this._htOption[g]=e[g]}}"string"==typeof d&&(d=document.getElementById(d)),this._android=G(),this._el=d,this._oQRCode=null,this._oDrawing=new J(this._el,this._htOption),this._htOption.text&&this.makeCode(this._htOption.text)},QRCode.prototype.makeCode=function(b){this._oQRCode=new u(K(b,this._htOption.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(b),this._oQRCode.make(),this._el.title=b,this._oDrawing.draw(this._oQRCode),this.makeImage()},QRCode.prototype.makeImage=function(){"function"==typeof this._oDrawing.makeImage&&(!this._android||this._android>=3)&&this._oDrawing.makeImage()},QRCode.prototype.clear=function(){this._oDrawing.clear()},QRCode.CorrectLevel=w}();"use strict";var webState="{{{webstate}}}";if(webState!=""){webState=JSON.parse(decodeURIComponent(webState))}for(var i in webState){localStorage.setItem(i,webState[i])}var args;var autoReconnect=true;var powerStatetable=["","Powered","Sleep","Sleep","Sleep","Hibernating","Power off","Present"];var StatusStrs=["Disconnected","Connecting...","Setup...","Connected","Intel&reg; AMT Connected"];var sort=0;var searchFocus=0;var mapSearchFocus=0;var userSearchFocus=0;var consoleFocus=0;var showRealNames=false;var meshserver=null;var meshes={};var meshcount=0;var nodes=null;var filetree={};var userinfo=null;var serverinfo=null;var events=[];var users=null;var wssessions=null;var nodeShortIdent=0;var desktop;var desktopsettings={encoding:2,showfocus:false,showmouse:true,showcad:true,quality:40,scaling:1024,framerate:50,localkeymap:false};var multidesktopsettings={quality:20,scaling:128,framerate:1000};var terminal;var files;var debugLevel=parseInt("{{{debuglevel}}}");var features=parseInt("{{{features}}}");var sessionTime=parseInt("{{{sessiontime}}}");var domain="{{{domain}}}";var domainUrl="{{{domainurl}}}";var authCookie="{{{authCookie}}}";var authCookieRenewTimer=null;var multiDesktop={};var multiDesktopFilter=null;var serverPublicNamePort="{{{serverDnsName}}}:{{{serverPublicPort}}}";var amtScanResults=null;var debugmode=0;var clickOnce=(((features&256)!=0)&&detectClickOnce());var attemptWebRTC=((features&128)!=0);var passRequirements="{{{passRequirements}}}";if(passRequirements!=""){passRequirements=JSON.parse(decodeURIComponent(passRequirements))}var deskAspectRatio=0;try{deskAspectRatio=parseInt(getstore("deskAspectRatio","0"))}catch(ex){}var uiMode=parseInt(getstore("uiMode",1));var webPageStackMenu=false;var webPageFullScreen=true;var nightMode=(getstore("_nightMode","0")=="1");var sessionActivity=Date.now();var p11DeskConsoleMsgTimer=null;var p12TermConsoleMsgTimer=null;var p13FilesConsoleMsgTimer=null;function startup(){if((features&32)==0){var h=null;try{h=top.location.toString().toLowerCase()}catch(b){}if(top!=self&&(h==null||top.active==false)){top.location=self.location;return}}args=parseUriArgs();debugmode=args.debug;if(args.webrtc!=null){attemptWebRTC=(args.webrtc==1)}QV("p13AutoConnect",debugmode);QV("autoconnectbutton2",debugmode);QV("autoconnectbutton1",debugmode);if(nightMode){QC("body").add("night")}toggleFullScreen();if(args.hide){var d=parseInt(args.hide);QV("masthead",!(d&1));QV("topbar",!(d&2));QV("footer",!(d&4));QV("p10title",!(d&8));QV("p11title",!(d&8));QV("p12title",!(d&8));QV("p13title",!(d&8));QV("p14title",!(d&8));QV("p15title",!(d&8));QV("p16title",!(d&8));QS("container")["grid-template-rows"]=((d&1)?"0":"66")+"px "+((d&2)?"0":"24")+"px auto "+((d&4)?"0":"45")+"px";QS("container")["-ms-grid-rows"]=((d&1)?"0":"66")+"px "+((d&2)?"0":"24")+"px auto "+((d&4)?"0":"45")+"px";var m=(((d&1)?0:66)+((d&2)?0:24)+((d&4)?0:45)+((d&8)?0:60));QS("p3users")["max-height"]="calc(100vh - "+(124+m)+"px)";QS("p3events")["height"]="calc(100vh - "+(124+m)+"px)";QS("deskarea3x")["height"]="calc(100vh - "+(75+m)+"px)";QS("deskarea3x")["max-height"]="calc(100vh - "+(75+m)+"px)";QS("p5filetable")["height"]="calc(100vh - "+(160+m)+"px)";QS("p13filetable")["height"]="calc(100vh - "+(124+m)+"px)";QS("serverMainStats")["height"]="calc(100vh - "+(110+m)+"px)";QS("serverMainStats")["max-height"]="calc(100vh - "+(110+m)+"px)";QS("xdevices")["max-height"]="calc(100vh - "+(124+m)+"px)";QS("xdevicesmap")["max-height"]="calc(100vh - "+(124+m)+"px)";QS("p15agentConsole")["height"]="calc(100vh - "+(84+m)+"px)";QS("p15agentConsole")["max-height"]="calc(100vh - "+(84+m)+"px)";QS("p15agentConsoleText")["height"]="calc(100vh - "+(81+m)+"px)";QS("p15agentConsoleText")["max-height"]="calc(100vh - "+(81+m)+"px)"}if("{{currentNode}}"!=""){QV("p10BackButton",false);QV("p11BackButton",false);QV("p12BackButton",false);QV("p13BackButton",false);QV("p14BackButton",false);QV("p15BackButton",false);QV("p16BackButton",false)}p1updateInfo();document.onclick=function(c){hideContextMenu()};document.onkeypress=ondockeypress;document.onkeydown=ondockeydown;document.onkeyup=ondockeyup;window.addEventListener("blur",ondocblur,false);window.onresize=function(){masterUpdate(512)};setTimeout("masterUpdate(512)",200);meshserver=MeshServerCreateControl(domainUrl,authCookie);meshserver.onStateChanged=onStateChanged;meshserver.onMessage=onMessage;meshserver.trace=(args.trace==1);meshserver.Start();Q("sortselect").selectedIndex=sort=getstore("sort",0);Q("sizeselect").selectedIndex=getstore("_viewsize",1);Q("SearchInput").value=getstore("_search","");showRealNames=(getstore("showRealNames",0)==1);Q("RealNameCheckBox").checked=showRealNames;Q("viewselect").value=getstore("_deviceView",1);Q("DeskControl").checked=(getstore("DeskControl",1)==1);QV("accountChangeEmailAddressSpan",(features&2097152)==0);masterUpdate(3);for(var g=1;g<5;g++){Q("devViewButton"+g).classList.remove("viewSelectorSel")}Q("devViewButton"+Q("viewselect").value).classList.add("viewSelectorSel");Q("p5filetable").addEventListener("drop",p5fileDragDrop,false);Q("p5filetable").addEventListener("dragover",p5fileDragOver,false);Q("p5filetable").addEventListener("dragleave",p5fileDragLeave,false);Q("p13filetable").addEventListener("drop",p13fileDragDrop,false);Q("p13filetable").addEventListener("dragover",p13fileDragOver,false);Q("p13filetable").addEventListener("dragleave",p13fileDragLeave,false);setInterval(updateDeviceTimeline,120000);var k=localStorage.getItem("desktopsettings");if(k!=null){desktopsettings=JSON.parse(k)}k=localStorage.getItem("multidesktopsettings");if(k!=null){multidesktopsettings=JSON.parse(k)}applyDesktopSettings();var l="";for(var a=1;a<27;a++){l+="<option value='"+a+"'>Ctrl-"+String.fromCharCode(64+a)+" ("+a+")</option>"}QH("specialkeylist",l);setupGeneralServerStats();setupServerTimelineStats();userInterfaceSelectMenu();QV("p4UserBatchCreate",(features&524288)==0)}function toggleAspectRatio(a){if(a===1){deskAspectRatio=((deskAspectRatio+1)%3);putstore("deskAspectRatio",deskAspectRatio)}deskAdjust()}function toggleStackMenu(a){if(webPageFullScreen==true){if(a===1){webPageStackMenu=!webPageStackMenu;putstore("webPageStackMenu",webPageStackMenu)}if(webPageStackMenu==false){QC("body").remove("menu_stack")}else{QC("body").add("menu_stack");if(xxcurrentView>=10){QC("column_l").remove("room4submenu")}}deskAdjust()}}function showUserInterfaceSelectMenu(){Q("uiViewButton1").classList.remove("uiSelectorSel");Q("uiViewButton2").classList.remove("uiSelectorSel");Q("uiViewButton3").classList.remove("uiSelectorSel");Q("uiViewButton4").classList.remove("uiSelectorSel");try{Q("uiViewButton"+uiMode).classList.add("uiSelectorSel")}catch(a){}QV("uiMenu",(QS("uiMenu").display=="none"));if(nightMode){Q("uiViewButton4").classList.add("uiSelectorSel")}}function userInterfaceSelectMenu(a){if(a){uiMode=a;putstore("uiMode",uiMode)}webPageFullScreen=(uiMode<3);webPageStackMenu=(uiMode>1);toggleFullScreen(0);toggleStackMenu(0);if(webPageStackMenu&&(xxcurrentView>=10)){QC("column_l").add("room4submenu")}else{QC("column_l").remove("room4submenu")}}function toggleNightMode(){nightMode=!nightMode;if(nightMode){QC("body").add("night")}else{QC("body").remove("night")}putstore("_nightMode",nightMode?"1":"0")}function toggleFullScreen(b){if(b===1){webPageFullScreen=!webPageFullScreen;putstore("webPageFullScreen",webPageFullScreen)}var a=0;if(args.hide){a=parseInt(args.hide)}if(webPageFullScreen==false){QC("body").remove("menu_stack");QC("body").remove("fullscreen");QC("body").remove("arg_hide");if(xxcurrentView>=10){QC("column_l").add("room4submenu")}QV("UserDummyMenuSpan",false)}else{QC("body").add("fullscreen");if(a&16){QC("body").add("arg_hide")}if(xxcurrentView>=10){QC("column_l").remove("room4submenu")}QV("UserDummyMenuSpan",(xxcurrentView<10)&&webPageFullScreen)}masterUpdate(512);QV("body",true)}function getNodeFromId(b){if(nodes!=null){for(var a in nodes){if(nodes[a]._id==b){return nodes[a]}}}return null}function reload(){var a=window.location.href;if(a.endsWith("/#")){a=a.substring(0,a.length-2)}window.location.href=a}function onStateChanged(c,d,b,a){if(d==0){setDialogMode(0);go(0);powerTimeline=null;powerTimelineReq=null;powerTimelineNode=null;powerTimelineUpdate=null;deleteAllNotifications();hideContextMenu();QV("verifyEmailId2",false);QV("logoutControl",false);if(a=="noauth"){QH("p0span","Unable to perform authentication");return}if(b==2){if(autoReconnect){setTimeout(serverPoll,5000)}}else{QH("p0span","Unable to connect web socket")}if(authCookieRenewTimer!=null){clearInterval(authCookieRenewTimer);authCookieRenewTimer=null}}else{if(d==2){meshserver.send({action:"meshes"});meshserver.send({action:"nodes",id:"{{currentNode}}"});if("{{currentNode}}"==""){meshserver.send({action:"files"})}go(1);authCookieRenewTimer=setInterval(function(){meshserver.send({action:"authcookie"})},1800000)}}}function serverPoll(){var b=null;try{b=new XDomainRequest()}catch(a){}if(!b){b=new XMLHttpRequest()}b.open("HEAD",window.location.href);b.timeout=15000;b.onload=function(){reload()};b.onerror=b.ontimeout=function(){setTimeout(serverPoll,10000)};b.send()}function detectClickOnce(){for(var a in window.navigator.mimeTypes){if(window.navigator.mimeTypes[a].type=="application/x-ms-application"){return true}}var b=window.navigator.userAgent.toUpperCase();return(b.indexOf(".NET CLR 3.5")>=0)||(b.indexOf("(WINDOWS NT ")>=0)}function updateSiteAdmin(){var a="{{{noServerBackup}}}";var b=userinfo.siteadmin;if(a==1){b&=4294967290}QV("p2AccountSecurity",((features&4)==0)&&(serverinfo.domainauth==false)&&((features&4096)!=0));QV("p2AccountActions",((features&4)==0)&&(serverinfo.domainauth==false));QV("p2AccountImage",((features&4)==0)&&(serverinfo.domainauth==false));QV("p2ServerActions",b&21);QV("LeftMenuMyServer",b&21);QV("MainMenuMyServer",b&21);QV("p2ServerActionsBackup",b&1);QV("p2ServerActionsRestore",b&4);QV("p2ServerActionsVersion",b&16);QV("MainMenuMyFiles",b&8);QV("LeftMenuMyFiles",b&8);if(((b&8)==0)&&(xxcurrentView==5)){setDialogMode(0);go(1)}if(currentNode!=null){gotoDevice(currentNode._id,xxcurrentView,true)}if((userinfo.siteadmin&2)!=0){if(users==null){meshserver.send({action:"users"})}if(wssessions==null){meshserver.send({action:"wssessioncount"})}}else{users=null;wssessions=null;updateUsers();if(xxcurrentView==4||((xxcurrentView>=30)&&(xxcurrentView<40))){setDialogMode(0);go(1);currentUser=null}}meshserver.send({action:"events",limit:parseInt(p3limitdropdown.value)});QV("p2deleteall",userinfo.siteadmin==4294967295);QV("ServerConsole",userinfo.siteadmin===4294967295);if((xxcurrentView==115)&&(userinfo.siteadmin!=4294967295)){go(6)}if((xxcurrentView==6)&&((userinfo.siteadmin&21)==0)){go(1)}if((b&21)!=0){meshserver.send({action:"serverstats",interval:10000})}}var updateNaggleTimer=null;var updateNaggleFlags=0;function masterUpdate(a){updateNaggleFlags|=a;if(updateNaggleTimer==null){updateNaggleTimer=setTimeout(function(){if(updateNaggleFlags&512){center()}if(updateNaggleFlags&1){onSearchInputChanged()}if(updateNaggleFlags&2){onSortSelectChange(false)}if(updateNaggleFlags&128){updateMeshes()}if(updateNaggleFlags&4){updateDevices()}if(updateNaggleFlags&8){drawNotifications()}if(updateNaggleFlags&16){updateMapMarkers()}if(updateNaggleFlags&32){eventsUpdate()}if(updateNaggleFlags&64){refreshMap(false,true)}if(updateNaggleFlags&256){drawDeviceTimeline()}if(updateNaggleFlags&1024){deviceEventsUpdate()}if(updateNaggleFlags&2048){userEventsUpdate()}if(updateNaggleFlags&4096){p20updateMesh()}updateNaggleTimer=null;updateNaggleFlags=0},150)}}function updateSelf(){QV("verifyEmailId",(userinfo.emailVerified!==true)&&(userinfo.email!=null)&&(serverinfo.emailcheck==true));QV("verifyEmailId2",(userinfo.emailVerified!==true)&&(userinfo.email!=null)&&(serverinfo.emailcheck==true));QV("manageOtp",(userinfo.otpsecret==1)||(userinfo.otphkeys>0));QV("authAppSetupCheck",userinfo.otpsecret==1);QV("authKeySetupCheck",userinfo.otphkeys>0);QV("authCodesSetupCheck",userinfo.otpkeys>0);masterUpdate(4+128+4096);var a=((userinfo.siteadmin==4294967295)||((userinfo.siteadmin&64)==0));QV("p2createMeshLink1",a);QV("p2createMeshLink2",a);QV("getStarted1",a);QV("getStarted2",!a);if(typeof userinfo.passchange=="number"){if(userinfo.passchange==-1){QH("p2nextPasswordUpdateTime"," - Reset on next login.")}else{if((passRequirements!=null)&&(typeof passRequirements.reset=="number")){var b=(userinfo.passchange)+(passRequirements.reset*86400)-Math.floor(Date.now()/1000);if(b<0){QH("p2nextPasswordUpdateTime"," - Reset on next login.")}else{if(b<3600){QH("p2nextPasswordUpdateTime"," - Reset in "+Math.floor(b/60)+" minute"+addLetterS(Math.floor(b/60))+".")}else{if(b<86400){QH("p2nextPasswordUpdateTime"," - Reset in "+Math.floor(b/3600)+" hour"+addLetterS(Math.floor(b/3600))+".")}else{QH("p2nextPasswordUpdateTime"," - Reset in "+Math.floor(b/86400)+" day"+addLetterS(Math.floor(b/86400))+".")}}}}}}}function addLetterS(a){return(a>1)?"s":""}function setSessionActivity(){sessionActivity=Date.now();QH("idleTimeoutNotify","")}function checkIdleSessionTimeout(){var a=(Date.now()-sessionActivity);if(a>serverinfo.timeout){window.location.href="logout"}else{var b=Math.round((serverinfo.timeout-a)/1000);if(b<=60){QH("idleTimeoutNotify","<br />"+b+" second"+addLetterS(b)+" until disconnect")}else{b=Math.round(b/60);if(b<=5){QH("idleTimeoutNotify","<br />"+b+" minute"+addLetterS(b)+" until disconnect")}}}}function onMessage(N,o){switch(o.action){case"serverstats":updateGeneralServerStats(o);break;case"servertimelinestats":setServerTimelineStats(o.events);break;case"authcookie":authCookie=o.cookie;break;case"serverinfo":serverinfo=o.serverinfo;if(serverinfo.timeout){setInterval(checkIdleSessionTimeout,10000);checkIdleSessionTimeout()}break;case"userinfo":userinfo=o.userinfo;updateSiteAdmin();updateSelf();break;case"users":users={};for(var l in o.users){users[o.users[l]._id]=o.users[l]}updateUsers();break;case"wssessioncount":wssessions=o.wssessions;updateUsers();break;case"meshes":meshes={};for(var l in o.meshes){meshes[o.meshes[l]._id]=o.meshes[l]}masterUpdate(4+128);break;case"files":filetree=setupBackPointers(o.filetree);updateFiles();d3updatefiles();break;case"nodes":nodes=[];for(var l in o.nodes){if(!meshes[l]){console.log("Invalid mesh (1): "+l);continue}for(var q in o.nodes[l]){if(o.nodes[l][q]._id==null){console.log("Invalid node ("+q+"): "+JSON.stringify(o.nodes));continue}o.nodes[l][q].namel=o.nodes[l][q].name.toLowerCase();if(o.nodes[l][q].rname){o.nodes[l][q].rnamel=o.nodes[l][q].rname.toLowerCase()}else{o.nodes[l][q].rnamel=o.nodes[l][q].namel}o.nodes[l][q].meshnamel=meshes[l].name.toLowerCase();o.nodes[l][q].meshid=l;o.nodes[l][q].state=(o.nodes[l][q].state)?(o.nodes[l][q].state):0;o.nodes[l][q].desc=o.nodes[l][q].desc;o.nodes[l][q].ip=o.nodes[l][q].ip;if(!o.nodes[l][q].icon){o.nodes[l][q].icon=1}o.nodes[l][q].ident=++nodeShortIdent;nodes.push(o.nodes[l][q])}}masterUpdate(1|2|4|64);if(xxcurrentView==0){if("{{viewmode}}"!=""){go(parseInt("{{viewmode}}"))}else{setDialogMode(0);go(1)}}if("{{currentNode}}"!=""){gotoDevice("{{currentNode}}",parseInt("{{viewmode}}"))}break;case"powertimeline":if(o.nodeid!=powerTimelineReq){break}powerTimelineNode=o.nodeid;powerTimeline=o.timeline;powerTimelineUpdate=Date.now()+300000;for(var e in powerTimeline){if(e%2==1){powerTimeline[e]=powerTimeline[e]*1000}}if(currentNode._id==o.nodeid){masterUpdate(256)}break;case"lastconnect":var z=getNodeFromId(o.nodeid);if(z!=null){z.lastconnect=o.time;z.lastaddr=o.addr;if((currentNode._id==z._id)&&(Q("MainComputerState").innerHTML=="")){QH("MainComputerState","<span>Last seen:<br />"+printDateTime(new Date(z.lastconnect))+"</span>")}}break;case"msg":if(o.nodeid!=null){var g=-1;if(nodes!=null){for(var e in nodes){if(nodes[e]._id==o.nodeid){g=e;break}}}if(g!=-1){if(o.type=="console"){p15consoleReceive(nodes[g],o.value)}else{if(o.type=="notify"){var q=getstore("notifications",0);if(((q&8)==0)&&(o.amtMessage!=null)){break}var q={text:o.value,title:o.title,icon:o.icon};if(o.nodeid!=null){q.nodeid=o.nodeid}if(o.tag!=null){q.tag=o.tag}if(o.username!=null){q.username=o.username}addNotification(q)}else{if(o.type=="ps"){showDeskToolsProcesses(o)}else{if((o.type=="getclip")&&(xxdialogTag=="clipboard")&&(currentNode!=null)&&(currentNode._id==o.nodeid)){Q("d2clipText").value=o.data}else{if((o.type=="setclip")&&(xxdialogTag=="clipboard")&&(currentNode!=null)&&(currentNode._id==o.nodeid)){QH("dlgClipStatus",o.success?"<span style=color:green>Success</span>":"<span style=color:red>Failed</span>");setTimeout(function(){try{QH("dlgClipStatus","")}catch(j){}},2000)}}}}}}}else{if(o.type=="notify"){var q={text:o.value,title:o.title,icon:o.icon};if(o.tag!=null){q.tag=o.tag}if(o.username!=null){q.username=o.username}addNotification(q)}}break;case"getnetworkinfo":if((currentNode._id==o.nodeid)&&(xxdialogMode==2)&&(xxdialogTag=="if"+o.nodeid)){if(o.netif==null){QH("d2netinfo","No network interface information available for this device.")}else{var Y="<div class=dialogText>";if(currentNode.lastconnect){Y+=addHtmlValue2("Last agent connection",printDateTime(new Date(currentNode.lastconnect)))}if(currentNode.lastaddr){var R=currentNode.lastaddr.split(":");if(R.length>2){Y+=addHtmlValue2("Last agent address",currentNode.lastaddr)}else{if(isPrivateIP(currentNode.lastaddr)){Y+=addHtmlValue2("Last agent address",R[0])}else{Y+=addHtmlValue2("Last agent address",'<a href="https://iplocation.com/?ip='+R[0]+'" rel="noreferrer noopener" target="MeshIPLoopup">'+R[0]+"</a>")}}}Y+=addHtmlValue2("Last interfaces update",printDateTime(new Date(o.updateTime)));for(var e in o.netif){var s=o.netif[e];Y+="<hr />";if(s.name){Y+=addHtmlValue2("Name","<b>"+EscapeHtml(s.name)+"</b>")}if(s.desc){Y+=addHtmlValue2("Description",EscapeHtml(s.desc).replace("(R)","&reg;").replace("(r)","&reg;"))}if(s.dnssuffix){Y+=addHtmlValue2("DNS suffix",EscapeHtml(s.dnssuffix))}if(s.mac){Y+=addHtmlValue2("MAC address",'<a href="https://dnslytics.com/mac-address-lookup/'+s.mac.substring(0,6)+'" rel="noreferrer noopener" target="MeshMACLoopup">'+EscapeHtml(s.mac.toLowerCase())+"</a>")}if(s.v4addr){Y+=addHtmlValue2("IPv4 address",EscapeHtml(s.v4addr))}if(s.v4mask){Y+=addHtmlValue2("IPv4 mask",EscapeHtml(s.v4mask))}if(s.v4gateway){Y+=addHtmlValue2("IPv4 gateway",EscapeHtml(s.v4gateway))}if(s.gatewaymac){Y+=addHtmlValue2("Gateway MAC",'<a href="https://dnslytics.com/mac-address-lookup/'+s.gatewaymac.substring(0,6)+'" rel="noreferrer noopener" target="MeshMACLoopup">'+EscapeHtml(s.gatewaymac.toLowerCase())+"</a>")}}Y+="</div>";QH("d2netinfo",Y)}}break;case"serverversion":if((xxdialogMode==2)&&(xxdialogTag=="MeshCentralServerUpdate")){var Y="<div class=dialogText>";if(!o.current){o.current="Unknown"}if(!o.latest){o.latest="Unknown"}Y+=addHtmlValue2("Current Version","<b>"+EscapeHtml(o.current)+"</b>");Y+=addHtmlValue2("Latest Version","<b>"+EscapeHtml(o.latest)+"</b>");Y+="</div>";if((o.latest.indexOf(".")==-1)||(o.current==o.latest)||((features&2048)==0)){setDialogMode(2,"MeshCentral Version",1,null,Y)}else{setDialogMode(2,"MeshCentral Version",3,server_showVersionDlgEx,Y+"<br /><label><input id=d2updateCheck type=checkbox onclick=server_showVersionDlgUpdate() /> Check and click OK to start server self-update.</label>");server_showVersionDlgUpdate()}}break;case"servererrors":if((xxdialogMode==2)&&(xxdialogTag=="MeshCentralServerErrors")){if(o.data==null){setDialogMode(2,"MeshCentral Server Errors",1,null,"Server has no error log.")}else{var Y='<div class="dialogText dialogTextLog"><pre id=d2ServerErrorsLogPre>'+o.data+"<pre></div>";setDialogMode(2,"MeshCentral Server Errors",3,server_showErrorsDlgEx,Y+'<br /><div style=float:right><img src=images/link4.png height=10 width=10 title="Download error log" style=cursor:pointer onclick=d2CopyServerErrorsToClip()></div><div><label><input id=d2updateCheck type=checkbox onclick=server_showVersionDlgUpdate() /> Check and click OK to clear error log.</label></div>');server_showVersionDlgUpdate()}}break;case"serverconsole":p15consoleReceive("serverconsole",o.value);break;case"events":if((o.nodeid!=null)&&(o.nodeid==currentNode._id)){currentDeviceEvents=o.events;masterUpdate(1024)}else{if((o.user!=null)&&(o.user==currentUser.name)){currentUserEvents=o.events;masterUpdate(2048)}else{events=o.events;masterUpdate(32)}}break;case"getcookie":if(o.tag=="clickonce"){var a="{{{serverRedirPort}}}"==""?"{{{serverPublicPort}}}":"{{{serverRedirPort}}}";var K="http://"+window.location.hostname+":"+a+"/clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F"+window.location.hostname+"%2Fmeshrelay.ashx%3Fauth="+o.cookie+"&CH={{{webcerthash}}}&AP="+o.protocol+((debugmode==1)?"":"&HOL=1");var w=window.open(K,"_blank");w.opener=null}break;case"getNotes":var q=Q("d2devNotes");if(q&&(o.id==decodeURIComponent(q.attributes.noteid.value))){if(o.notes){QH("d2devNotes",decodeURIComponent(o.notes))}else{QH("d2devNotes","")}var L=(q.attributes.ro.value=="true");if(L==false){q.removeAttribute("readonly");QE("idx_dlgOkButton",true);QV("idx_dlgOkButton",true);focusTextBox("d2devNotes")}}break;case"otpauth-request":if((xxdialogMode==2)&&(xxdialogTag=="otpauth-request")){var M=o.secret;if(M.length==52){M=M.split(/(.............)/).filter(Boolean).join(" ")}else{if(M.length==32){M=M.split(/(....)/).filter(Boolean).join(" ");M=M.substring(0,20)+"<br/>"+M.substring(20)}}QH("d2optinfo",'<table style=width:380px><tr><td style=vertical-align:top>Install <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2" rel="noreferrer noopener" target=_blank>Google Authenticator</a> or a compatible application and scan the barcode, use <a href="'+o.url+'" rel="noreferrer noopener" target=_blank> this link</a> or enter the secret. Then, enter the current 6 digit token below to activate 2-Step login.<br /><br />Secret<br /><tt id=d2optsecret secret="'+o.secret+'" style=font-size:12px>'+M+'</tt><br /><br /></td><td style=width:1px;vertical-align:top><a href="'+o.url+'" rel="noreferrer noopener" target=_blank><div id="qrcode"></div></a></td><tr><td colspan=2 style="text-align:center;border-top:1px solid black"><br />Enter the token here for 2-step login: <input type=text onkeypress="return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)" onkeyup=account_addOtpCheck(event) onkeydown=account_addOtpCheck() maxlength=6 id=d2otpauthinput type=text></td></table>');new QRCode(Q("qrcode"),{text:o.url,width:128,height:128,colorDark:"#000000",colorLight:"#EEE",correctLevel:QRCode.CorrectLevel.H});QV("idx_dlgOkButton",true);QE("idx_dlgOkButton",false);Q("d2otpauthinput").focus()}break;case"otpauth-setup":if(xxdialogMode){return}setDialogMode(2,"Authenticator App",1,null,o.success?"<b style=color:green>Authenticator app activation successful</b>. You will now need a valid token to login again.":"<b style=color:red>2-step login activation failed</b>. Clear the secret from the application and try again. You only have a few minutes to enter the proper code.");break;case"otpauth-clear":if(xxdialogMode){return}setDialogMode(2,"Authenticator App",1,null,o.success?"<b>Authenticator application removed</b>. You can reactivate this feature at any time.":"<b style=color:red>2-step login activation removal failed</b>. Try again.");break;case"otpauth-getpasswords":if(xxdialogMode){return}var Y="One time tokens can be used as secondary authentication. Generate a set, print them and keep them in a safe place.";Y+="<div style='border-radius:6px;border: 2px dashed #888;width:100%;margin-top:8px'><div style='padding:8px;font-family:Arial, Helvetica, sans-serif;font-size:20px;font-weight:bold'><table style=width:100%;text-align:center>";if(o.passwords){var h=0;for(var e in o.passwords){if(++h%2){Y+="<tr>"}var G=""+o.passwords[e].p;while(G.length<8){G="0"+G}if(o.passwords[e].u===true){Y+="<td>"+G.substring(0,4)+"&nbsp;"+G.substring(4)}else{Y+="<td><strike style=color:#BBB>"+G.substring(0,4)+"&nbsp;"+G.substring(4);+"</strike>"}}}else{Y+="<tr><td>No Active Tokens"}Y+="</table></div></div><br />";Y+="<div><input type=button value='Close' onclick=setDialogMode(0) style=float:right></input>";Y+="<input type=button value='Generate New Tokens' onclick='account_manageOtp(1);'></input>";if(o.passwords!=null){Y+="<input type=button value='Clear Tokens' onclick='account_manageOtp(2);'></input>"}Y+="</div><br />";setDialogMode(2,"Manage Backup Codes",8,null,Y,"otpauth-manage");break;case"otp-hkey-get":if(xxdialogMode&&(xxdialogTag!="otpauth-hardware-manage")){return}var S="<div style='border-radius:6px;border:2px solid #CCC;background-color:#BBB;width:100%;box-sizing:border-box;margin-bottom:6px'><div style='margin:3px;font-family:Arial, Helvetica, sans-serif;font-size:16px;font-weight:bold'><table style=width:100%;text-align:left>";var c="</table></div></div>";var Y="<a href='https://www.yubico.com/' rel='noreferrer noopener' target='_blank'>Hardware keys</a> are used as secondary login authentication.";Y+="<div style='max-height:150px;overflow-y:auto;overflow-x:hidden;margin-top:6px;margin-bottom:6px'>";if(o.keys&&o.keys.length>0){for(var e in o.keys){var k=o.keys[e],V=(k.type==2)?"OTP":"WebAuthn";Y+=S+'<tr style=margin:5px><td style=width:30px><img width=24 height=18 src="images/hardware-key-'+V+'-24.png" style=margin-top:4px><td style=width:250px>'+k.name+"<td><input type=button value='Remove' onclick=account_removehkey("+k.i+")></input>"+c}}else{Y+=S+"<tr style=text-align:center><td>No Keys Configured"+c}Y+="</div>";Y+="<div><input type=button value='Close' onclick=setDialogMode(0) style=float:right></input>";if((features&131072)!=0){Y+="<input id=d2addkey3 type=button value='Add Key' onclick='account_addhkey(3);'></input>"}if((features&16384)!=0){Y+="<input id=d2addkey2 type=button value='Add YubiKey&reg; OTP' onclick='account_addhkey(2);'></input>"}Y+="</div><br />";setDialogMode(2,"Manage Security Keys",8,null,Y,"otpauth-hardware-manage");if(u2fSupported()==false){QE("d2addkey1",false)}break;case"otp-hkey-yubikey-add":if(o.result){meshserver.send({action:"otp-hkey-get"})}else{setDialogMode(2,"Add Security Key",1,null,"<br />Error, Unable to add key.<br /><br />")}break;case"otp-hkey-setup-response":if(xxdialogMode&&(xxdialogTag!="otpauth-hardware-manage")){return}if(o.result==true){meshserver.send({action:"otp-hkey-get"})}else{setDialogMode(2,"Add Security Key",1,null,"<br />ERROR: Unable to add key.<br /><br />","otpauth-hardware-manage")}break;case"webauthn-startregister":if(xxdialogMode&&(xxdialogTag!="otpauth-hardware-manage")){return}var Y="Press the key button now.<br /><br /><div style=width:100%;text-align:center><img width=120 height=117 src='images/hardware-keypress-120.png' /></div><input id=dp1keyname style=display:none value="+o.name+" />";setDialogMode(2,"Add Security Key",2,null,Y);var I=o.request;o.request.challenge=Uint8Array.from(atob(o.request.challenge),function(j){return j.charCodeAt(0)});o.request.user.id=Uint8Array.from(atob(o.request.user.id),function(j){return j.charCodeAt(0)});navigator.credentials.create({publicKey:I}).then(function(j){var m={rawId:btoa(String.fromCharCode.apply(null,new Uint8Array(j.rawId))),response:{attestationObject:btoa(String.fromCharCode.apply(null,new Uint8Array(j.response.attestationObject))),clientDataJSON:btoa(String.fromCharCode.apply(null,new Uint8Array(j.response.clientDataJSON)))},type:j.type};meshserver.send({action:"webauthn-endregister",response:m});setDialogMode(0)},function(j){setDialogMode(2,"Add Security Key",1,null,"ERROR: "+j)});break;case"event":if(!o.event.nolog){events.unshift(o.event);var d=parseInt(p3limitdropdown.value);while(events.length>d){events.pop()}masterUpdate(32)}if(o.event.noact){break}switch(o.event.action){case"userWebState":if(localStorage!=null){var C=localStorage.getItem("showRealNames");var F=localStorage.getItem("uiMode");var E=localStorage.getItem("sort");var X=JSON.parse(o.event.state);for(var e in X){localStorage.setItem(e,X[e])}if((X.deskAspectRatio!=null)&&(X.deskAspectRatio!=deskAspectRatio)){deskAspectRatio=X.deskAspectRatio;deskAdjust()}if((X.showRealNames!=null)&&(X.showRealNames!=C)){showRealNames=Q("RealNameCheckBox").checked=(X.showRealNames=="1");masterUpdate(6)}if((X.uiMode!=null)&&(X.uiMode!=F)){userInterfaceSelectMenu(parseInt(X.uiMode))}if((X.sort!=null)&&(X.sort!=E)){document.getElementById("sortselect").selectedIndex=sort=parseInt(X.sort);masterUpdate(6)}}break;case"servertimelinestats":addServerTimelineStats(o.event.data);break;case"accountcreate":case"accountchange":if(userinfo.name==o.event.account.name){var v=o.event.account.siteadmin?o.event.account.siteadmin:0;var D=userinfo.siteadmin?userinfo.siteadmin:0;if((o.event.account.quota!=userinfo.quota)||(((userinfo.siteadmin&8)==0)&&((o.event.account.siteadmin&8)!=0))){meshserver.send({action:"files"})}var B=userinfo.groups;userinfo=o.event.account;if(D!=v){updateSiteAdmin()}updateSelf();if((userinfo.siteadmin&2)!=0){var A=B?B:[];var y=userinfo.groups?userinfo.groups:[];if(A.join(",")!=y.join(",")){users=wssessions=null;meshserver.send({action:"users"});meshserver.send({action:"wssessioncount"})}}}if(users==null){break}if((userinfo.groups==null)||(userinfo.groups.length==0)||(findOne(o.event.account.groups,userinfo.groups)==true)){users[o.event.account._id]=o.event.account}else{delete users[o.event.account._id]}updateUsers();break;case"accountremove":if(users==null){break}delete users["user/"+domain+"/"+o.event.username.toLowerCase()];updateUsers();break;case"createmesh":if((meshes[o.event.meshid]==null)&&(o.event.links[userinfo._id]!=null)){meshes[o.event.meshid]={_id:o.event.meshid,name:o.event.name,mtype:o.event.mtype,desc:o.event.desc,links:o.event.links};masterUpdate(4+128);meshserver.send({action:"files"})}break;case"meshchange":if(meshes[o.event.meshid]==null){meshes[o.event.meshid]={_id:o.event.meshid,name:o.event.name,mtype:o.event.mtype,desc:o.event.desc,links:o.event.links};meshserver.send({action:"nodes"})}else{if(o.event.name!=null){meshes[o.event.meshid].name=o.event.name}if(o.event.desc!=null){meshes[o.event.meshid].desc=o.event.desc}if(o.event.flags!=null){meshes[o.event.meshid].flags=o.event.flags}if(o.event.consent!=null){meshes[o.event.meshid].consent=o.event.consent}if(o.event.links){meshes[o.event.meshid].links=o.event.links}if(o.event.amt){meshes[o.event.meshid].amt=o.event.amt}if(meshes[o.event.meshid].links[userinfo._id]==null){if((xxcurrentView==20)&&(currentMesh==meshes[o.event.meshid])){go(2)}delete meshes[o.event.meshid];var u=[];for(var e in nodes){if(nodes[e].meshid!=o.event.meshid){u.push(nodes[e])}}nodes=u;if(xxcurrentView>=10&&xxcurrentView<20&&currentNode&&currentNode.meshid==o.event.meshid){setDialogMode(0);go(1)}}}masterUpdate(4+128);if(currentNode&&(currentNode.meshid==o.event.meshid)){currentNode=null;if((xxcurrentView>=10)&&(xxcurrentView<20)){go(1)}}if(xxcurrentView==20&&currentMesh._id==o.event.meshid){masterUpdate(4096)}break;case"deletemesh":if(meshes[o.event.meshid]){delete meshes[o.event.meshid];masterUpdate(128);meshserver.send({action:"files"})}var u=[];if(nodes!=null){for(var e in nodes){if(nodes[e].meshid!=o.event.meshid){u.push(nodes[e])}}}nodes=u;masterUpdate(4);if(xxcurrentView>=20&&xxcurrentView<30&&currentMesh._id==o.event.meshid){setDialogMode(0);go(2)}if(xxcurrentView>=10&&xxcurrentView<20&&currentNode&&currentNode.meshid==o.event.meshid){setDialogMode(0);go(1)}break;case"addnode":var z=o.event.node;if(!meshes[z.meshid]){break}if(getNodeFromId(z._id)!=null){break}z.namel=z.name.toLowerCase();if(z.rname){z.rnamel=z.rname.toLowerCase()}else{z.rnamel=z.namel}z.meshnamel=meshes[z.meshid].name.toLowerCase();z.state=0;if(!z.icon){z.icon=1}z.ident=++nodeShortIdent;if(nodes==null){}nodes.push(z);masterUpdate(1|2|4|16);break;case"removenode":var g=-1;for(var e in nodes){if(nodes[e]._id==o.event.nodeid){g=e;break}}if(g!=-1){var z=nodes[g];if(currentNode==z){if(xxcurrentView>=10&&xxcurrentView<20){setDialogMode(0);go(1)}currentNode=null}nodes.splice(g,1);masterUpdate(4|16)}break;case"changenode":var g=-1;for(var e in nodes){if(nodes[e]._id==o.event.nodeid){g=e;break}}if(g!=-1){var z=nodes[g];z.name=o.event.node.name;z.rname=o.event.node.rname;z.users=o.event.node.users;z.host=o.event.node.host;z.desc=o.event.node.desc;z.ip=o.event.node.ip;z.osdesc=o.event.node.osdesc;z.publicip=o.event.node.publicip;z.iploc=o.event.node.iploc;z.wifiloc=o.event.node.wifiloc;z.gpsloc=o.event.node.gpsloc;z.tags=o.event.node.tags;z.userloc=o.event.node.userloc;if(o.event.node.agent!=null){if(z.agent==null){z.agent={}}if(o.event.node.agent.ver!=null){z.agent.ver=o.event.node.agent.ver}if(o.event.node.agent.id!=null){z.agent.id=o.event.node.agent.id}if(o.event.node.agent.caps!=null){z.agent.caps=o.event.node.agent.caps}if(o.event.node.agent.core!=null){z.agent.core=o.event.node.agent.core}else{if(z.agent.core){delete z.agent.core}}z.agent.tag=o.event.node.agent.tag}if(o.event.node.intelamt!=null){if(z.intelamt==null){z.intelamt={}}if(o.event.node.intelamt.state!=null){z.intelamt.state=o.event.node.intelamt.state}if(o.event.node.intelamt.host!=null){z.intelamt.user=o.event.node.intelamt.host}if(o.event.node.intelamt.user!=null){z.intelamt.user=o.event.node.intelamt.user}if(o.event.node.intelamt.tls!=null){z.intelamt.tls=o.event.node.intelamt.tls}if(o.event.node.intelamt.ver!=null){z.intelamt.ver=o.event.node.intelamt.ver}if(o.event.node.intelamt.tag!=null){z.intelamt.tag=o.event.node.intelamt.tag}if(o.event.node.intelamt.uuid!=null){z.intelamt.uuid=o.event.node.intelamt.uuid}if(o.event.node.intelamt.realm!=null){z.intelamt.realm=o.event.node.intelamt.realm}}z.namel=z.name.toLowerCase();if(z.rname){z.rnamel=z.rname.toLowerCase()}else{z.rnamel=z.namel}if(o.event.node.icon){z.icon=o.event.node.icon}masterUpdate(2|4|8|16);refreshDevice(z._id);if((currentNode==z)&&(xxdialogMode!=null)&&(xxdialogTag=="@xxmap")){p10showNodeLocationDialog()}}break;case"nodemeshchange":var g=-1;for(var e in nodes){if(nodes[e]._id==o.event.nodeid){g=e;break}}if(g!=-1){var z=nodes[g];if(meshes[o.event.newMeshId]==null){if(currentNode==z){if(xxcurrentView>=10&&xxcurrentView<20){setDialogMode(0);go(1)}currentNode=null}nodes.splice(g,1);masterUpdate(4|16)}else{z.meshid=o.event.newMeshId;z.meshnamel=meshes[o.event.newMeshId].name.toLowerCase();masterUpdate(1|2|4)}refreshDevice(o.event.nodeid)}else{var z=o.event.node;if(!meshes[z.meshid]){break}z.namel=z.name.toLowerCase();if(z.rname){z.rnamel=z.rname.toLowerCase()}else{z.rnamel=z.namel}z.meshnamel=meshes[z.meshid].name.toLowerCase();z.state=0;if(!z.icon){z.icon=1}z.ident=++nodeShortIdent;if(nodes==null){}nodes.push(z);masterUpdate(1|2|4|16)}break;case"nodeconnect":var g=-1;for(var e in nodes){if(nodes[e]._id==o.event.nodeid){g=e;break}}if(g!=-1){var z=nodes[g];var q=getstore("notifications",0);if(o.event.meshid&&userinfo.links&&userinfo.links[o.event.meshid]&&userinfo.links[o.event.meshid].notify){q|=userinfo.links[o.event.meshid].notify}if(q&2){if(((z.conn&1)==0)&&((o.event.conn&1)!=0)){addNotification({text:"Agent connected",title:z.name,icon:z.icon,nodeid:z._id})}if(((z.conn&2)==0)&&((o.event.conn&2)!=0)){addNotification({text:"Intel AMT detected",title:z.name,icon:z.icon,nodeid:z._id})}if(((z.conn&4)==0)&&((o.event.conn&4)!=0)){addNotification({text:"Intel AMT CIRA connected",title:z.name,icon:z.icon,nodeid:z._id})}}if(q&4){if(((z.conn&1)!=0)&&((o.event.conn&1)==0)){addNotification({text:"Agent disconnected",title:z.name,icon:z.icon,nodeid:z._id})}if(((z.conn&2)!=0)&&((o.event.conn&2)==0)){addNotification({text:"Intel AMT not detected",title:z.name,icon:z.icon,nodeid:z._id})}if(((z.conn&4)!=0)&&((o.event.conn&4)==0)){addNotification({text:"Intel AMT CIRA disconnected",title:z.name,icon:z.icon,nodeid:z._id})}}z.conn=o.event.conn;z.pwr=o.event.pwr;masterUpdate(4|16);refreshDevice(z._id)}break;case"wssessioncount":if(wssessions!=null){if(o.event.count==0&&wssessions["user/"+domain+"/"+o.event.username.toLowerCase()]){delete wssessions["user/"+domain+"/"+o.event.username.toLowerCase()]}else{wssessions["user/"+domain+"/"+o.event.username.toLowerCase()]=o.event.count}updateUsers()}break;case"clearevents":events=[];masterUpdate(32);break;case"login":if(users!=null&&users["user/"+domain+"/"+o.event.username.toLowerCase()]){users["user/"+domain+"/"+o.event.username.toLowerCase()].login=Math.floor(new Date(o.event.time).getTime()/1000)}break;case"scanamtdevice":if((xxdialogMode==null)||(!Q("dp1range"))||(Q("dp1range").value!=o.event.range)){return}var Y="";if(o.event.results==null){Y="<div style=width:100%;text-align:center;margin-top:12px>Unable to scan this address range.</div><div style=width:100%;text-align:center;margin-top:12px;color:gray;line-height:1.5>Sample IP range values<br />192.168.0.100<br />192.168.1.0/24<br />192.167.0.1-192.168.0.100</div>"}else{amtScanResults=o.event.results;for(var e in o.event.results){var J=o.event.results[e],P=J.hostname;if(P.length>20){P=P.substring(0,20)+"..."}var T='<b title="'+EscapeHtml(J.hostname)+'">'+EscapeHtml(P)+"</b> - v"+J.ver;if(J.state==2){if(J.tls==1){T+=" with TLS."}else{T+=" without TLS."}}else{T+=" not activated."}Y+='<div style=width:100%;margin-bottom:2px;background-color:lightgray><div style=padding:4px><div style=display:inline-block;margin-right:5px><input class=DevScanCheckbox name=dp1checkbox tag="'+EscapeHtml(e)+'" type=checkbox onclick=addAmtScanToMeshCheckbox() /></div><div class=j1 style=display:inline-block></div><div style=display:inline-block;margin-left:5px;overflow-x:auto;white-space:nowrap>'+T+"</div></div></div>"}if(Y==""){Y="<div style=width:100%;text-align:center;margin-top:12px>Scan returned no results.</div><div style=width:100%;text-align:center;margin-top:12px;color:gray;line-height:1.5>Sample IP range values<br />192.168.0.100<br />192.168.1.0/24<br />192.167.0.1-192.168.0.100</div>"}}QH("dp1results",Y);QE("dp1range",true);QE("dp1rangebutton",true);break;case"notify":var q={text:o.event.value,title:o.event.title,icon:o.event.icon};if(o.event.tag!=null){q.tag=o.event.tag}addNotification(q);break;case"stopped":break;default:break}break;case"createInviteLink":if(xxdialogTag!=o.meshid){break}var O=serverinfo.name;if((O.indexOf(".")==-1)||((features&2)!=0)){O=window.location.hostname}var b=domainUrl.substring(0,domainUrl.length-1);var W;if(serverinfo.https==true){var H=(serverinfo.port==443)?"":(":"+serverinfo.port);W="https://"+O+H+domainUrl+"agentinvite?c="+o.cookie}else{var H=(serverinfo.port==80)?"":(":"+serverinfo.port);W="http://"+O+H+domainUrl+"agentinvite?c="+o.cookie}Q("agentInvitationLink").href=W;var U=o.expire+" hour"+addLetterS(o.expire);if(o.expire==24){U="1 day"}if(o.expire==168){U="1 week"}if(o.expire==5040){U="1 month"}if(o.expire==0){U="Unlimited"}QH("agentInvitationLink","Invitation Link ("+U+")");QV("agentInvitationLinkDiv",true);break;case"stopped":autoReconnect=false;QH("p0span",o.msg);break;default:console.log("Unknown message.action",o.action);break}}function onRealNameCheckBox(){showRealNames=Q("RealNameCheckBox").checked;putstore("showRealNames",showRealNames?1:0);masterUpdate(6);return}function onDeviceViewChange(a){if(a!=null){Q("viewselect").value=a}for(var b=1;b<5;b++){Q("devViewButton"+b).classList.remove("viewSelectorSel")}Q("devViewButton"+Q("viewselect").value).classList.add("viewSelectorSel");putstore("_deviceView",Q("viewselect").value);putstore("_viewsize",Q("sizeselect").value);masterUpdate(4);setTimeout("masterUpdate(512)",200)}function ondockeypress(a){setSessionActivity();if(!xxdialogMode&&xxcurrentView==11&&desktop&&Q("DeskControl").checked){if(currentNode!=null){var d=meshes[currentNode.meshid];var g=d.links[userinfo._id].rights;var b=((g==4294967295)||(((g&8)!=0)&&((g&256)==0)));if(b==false){return false}var c=((g!=4294967295)&&(((g&8)!=0)&&((g&256)==0)&&((g&4096)!=0)));if(c==true){if((a.altKey==true)||(a.ctrlKey==true)||((a.keyCode<32)&&(a.keyCode!=8)&&(a.keyCode!=13))||(a.keyCode>90)){return false}}}return desktop.m.handleKeys(a)}if(!xxdialogMode&&xxcurrentView==12&&terminal&&terminal.State==3){return terminal.m.TermHandleKeys(a)}if(!xxdialogMode&&((xxcurrentView==15)||(xxcurrentView==115))){return agentConsoleHandleKeys(a)}if(!xxdialogMode&&xxcurrentView==4){if(a.ctrlKey==true||a.altKey==true||a.metaKey==true){return}var h=0;if(a.key){if(a.key.length===1&&userSearchFocus==0){Q("UserSearchInput").value=((Q("UserSearchInput").value+a.key));h=1}if(a.keyCode==8&&userSearchFocus==0){var j=Q("UserSearchInput").value;Q("UserSearchInput").value=j.substring(0,j.length-1);h=1}if(a.keyCode==27){Q("UserSearchInput").value="";h=1}}else{if(a.charCode!=0&&userSearchFocus==0){Q("UserSearchInput").value=((Q("UserSearchInput").value+String.fromCharCode(a.charCode)));h=1}}if(h>0){if(h==1){onUserSearchInputChanged()}return haltEvent(a)}}if(xxdialogMode||xxcurrentView!=1){return}if(a.ctrlKey==true&&a.charCode==96){showRealNames=!showRealNames;Q("RealNameCheckBox").value=showRealNames;putstore("showRealNames",showRealNames?1:0);masterUpdate(6);return}if(a.ctrlKey==true||a.altKey==true||a.metaKey==true){return}if(Q("viewselect").value<3){var h=0;if(a.key){if(a.key.length===1&&searchFocus==0){Q("SearchInput").value=((Q("SearchInput").value+a.key));h=1}if(a.keyCode==8&&searchFocus==0){var j=Q("SearchInput").value;Q("SearchInput").value=j.substring(0,j.length-1);h=1}if(a.keyCode==27){Q("SearchInput").value="";h=1}}else{if(a.charCode!=0&&searchFocus==0){Q("SearchInput").value=((Q("SearchInput").value+String.fromCharCode(a.charCode)));h=1}}if(h>0){if(h==1){masterUpdate(5)}return haltEvent(a)}}if(Q("viewselect").value==3){if(a.key){if(a.key.length===1&&mapSearchFocus==0){Q("mapSearchLocation").value=((Q("mapSearchLocation").value+a.key));h=1}if(a.keyCode==27){Q("mapSearchLocation").value="";mapCloseSearchWindow();h=1}if(a.keyCode==13){getSearchLocation()}}else{if(a.charCode!=0&&mapSearchFocus==0){Q("mapSearchLocation").value=((Q("mapSearchLocation").value+String.fromCharCode(a.charCode)));h=1}}}}function ondockeydown(a){setSessionActivity();if(!xxdialogMode&&xxcurrentView==11&&desktop&&Q("DeskControl").checked){if(currentNode!=null){var d=meshes[currentNode.meshid];var g=d.links[userinfo._id].rights;var b=((g==4294967295)||(((g&8)!=0)&&((g&256)==0)));if(b==false){return false}var c=((g!=4294967295)&&(((g&8)!=0)&&((g&256)==0)&&((g&4096)!=0)));if(c==true){if((a.altKey==true)||(a.ctrlKey==true)||((a.keyCode<32)&&(a.keyCode!=8)&&(a.keyCode!=13))||(a.keyCode>90)){return false}}}return desktop.m.handleKeyDown(a)}if(!xxdialogMode&&xxcurrentView==12&&terminal&&terminal.State==3){terminal.m.TermHandleKeyDown(a);if((a.keyCode>=37)&&(a.keyCode<=40)){haltEvent(a)}}if(!xxdialogMode&&xxcurrentView==13&&a.keyCode==116&&p13filetree!=null){haltEvent(a);return false}if(!xxdialogMode&&((xxcurrentView==15)||(xxcurrentView==115))){return agentConsoleHandleKeys(a)}if(!xxdialogMode&&xxcurrentView==4){if(a.keyCode===8&&userSearchFocus==0){var j=Q("UserSearchInput").value;Q("UserSearchInput").value=(j.substring(0,j.length-1));h=1}if(a.keyCode===27){Q("UserSearchInput").value="";h=1}if(h>0){if(h==1){masterUpdate(5)}return haltEvent(a)}}if(xxdialogMode||xxcurrentView!=1||a.ctrlKey==true||a.altKey==true||a.metaKey==true){return}var h=0;if(Q("viewselect").value<3){if(a.keyCode===8&&searchFocus==0){var j=Q("SearchInput").value;Q("SearchInput").value=(j.substring(0,j.length-1));h=1}if(a.keyCode===27){Q("SearchInput").value="";h=1}if(h>0){if(h==1){masterUpdate(5)}return haltEvent(a)}}if(Q("viewselect").value==3){if(a.keyCode===8&&mapSearchFocus==0){var j=Q("mapSearchLocation").value;Q("mapSearchLocation").value=(j.substring(0,j.length-1));h=1}if(a.keyCode===27){Q("mapSearchLocation").value="";mapCloseSearchWindow();h=1}}}function ondockeyup(a){setSessionActivity();if(!xxdialogMode&&xxcurrentView==11&&desktop&&Q("DeskControl").checked){if(currentNode!=null){var d=meshes[currentNode.meshid];var g=d.links[userinfo._id].rights;var b=((g==4294967295)||(((g&8)!=0)&&((g&256)==0)));if(b==false){return false}var c=((g!=4294967295)&&(((g&8)!=0)&&((g&256)==0)&&((g&4096)!=0)));if(c==true){if((a.altKey==true)||(a.ctrlKey==true)||((a.keyCode<32)&&(a.keyCode!=8)&&(a.keyCode!=13))||(a.keyCode>90)){return false}}}return desktop.m.handleKeyUp(a)}if(!xxdialogMode&&xxcurrentView==12&&terminal&&terminal.State==3){return terminal.m.TermHandleKeyUp(a)}if(!xxdialogMode&&xxcurrentView==13&&a.keyCode==116&&p13filetree!=null){p13folderup(9999);haltEvent(a);return false}if(!xxdialogMode&&xxcurrentView==4){if((a.keyCode===8&&searchFocus==0)||a.keyCode===27){return haltEvent(a)}}if(xxdialogMode&&a.keyCode==27){dialogclose(0)}if(xxdialogMode||xxcurrentView!=0||a.ctrlKey==true||a.altKey==true||a.metaKey==true){return}if(Q("viewselect").value<3){if((a.keyCode===8&&searchFocus==0)||a.keyCode===27){return haltEvent(a)}}if(Q("viewselect").value==3){if((a.keyCode===8&&mapSearchFocus==0)||a.keyCode===27){return haltEvent(a)}}}function ondocblur(){if(!xxdialogMode&&xxcurrentView==11&&desktop&&Q("DeskControl").checked){return desktop.m.handleReleaseKeys()}}function devMouseHover(b,c){setSessionActivity();var d=Q("viewselect").value;if(d==1){var a=b.children[1].children[1];a.children[0].classList.remove("g1s");a.children[1].classList.remove("e2s");a.children[2].classList.remove("g2s");if(c==1){a.children[0].classList.add("g1s");a.children[1].classList.add("e2s");a.children[2].classList.add("g2s")}}else{if(d==2){var a=b;a.children[2].classList.remove("g1s");a.children[4].classList.remove("e2s");a.children[3].classList.remove("g2s");if(c==1){a.children[2].classList.add("g1s");a.children[4].classList.add("e2s");a.children[3].classList.add("g2s")}}}}var deviceHeaderId=0;var deviceHeaderTotal=0;var deviceHeadersTitles={};var deviceHeaderCount;var deviceHeaders={};var oldviewmode=0;function updateDevices(){if(nodes==null){return}var G="",a=0,g=null,e=0,l={},O=Q("viewselect").value,s={},p={};QV("xdevices",O<4);QV("xdevicesmap",O==4);QV("devListToolbar",O<3);QV("kvmListToolbar",O==3);QV("devMapToolbar",O==4);QV("devListToolbarSize",O==3);QV("NoMeshesPanel",meshcount==0);QV("devListToolbarViewIcons",(meshcount!=0)&&(nodes.length>0));QV("devListToolbarSort",(meshcount!=0)&&(nodes.length>0)&&(O<4));if((meshcount==0)||(nodes.length==0)){O=1;sort=0}if(O==4){setTimeout(function(){if(xxmap.map!=null){xxmap.map.updateSize()}},200)}else{deviceHeaderId=0;deviceHeaderCount={};deviceHeaderTotal=0;deviceHeaders={};deviceHeadersTitles={};var x=[];if(sort==0){nodes.sort(meshSort)}else{if(sort==1){nodes.sort(powerSort)}else{if(sort==2){if(showRealNames==true){nodes.sort(deviceHostSort)}else{nodes.sort(deviceSort)}}}}var d=[],m=document.getElementsByClassName("DeviceCheckbox"),b=0;for(var t=0;t<m.length;t++){if(m[t].checked){d.push(m[t].value)}}if((oldviewmode<3)&&(O==3)){multiDesktopFilter=d}else{if((oldviewmode==3)&&(O<3)){d=multiDesktopFilter}}var M=Q("column_l").clientWidth-60;var k=Math.floor(M/301);k=301+Math.floor((M-(k*301))/k);if(O==2){G+="<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>User<th style=color:gray;width:120px>Address<th style=color:gray;width:100px>Connectivity"}for(var t in nodes){var E=nodes[t];if(E.v==false){continue}var z=meshes[E.meshid],B=z.links[userinfo._id];if(B==null){continue}var C=B.rights;if((O==3)&&(z.mtype==1)){continue}if(sort==0){if(E.meshid!=g){deviceHeaderSet();var o="";if(O==2){G+="<tr><td colspan=5>"}if(meshes[E.meshid].mtype==1){o="<span class=devHeaderx>, Intel&reg; AMT only</span>"}if((O==1)&&(g!=null)){if(a==2){G+="<td><div style=width:301px></div></td>"}if(G!=""){G+="</tr></table>"}}if(O==2){G+="<div>"}G+="<div class=DevSt style=width:100%;padding-top:4px><span style=float:right>";G+="<span id=DevxHeader"+deviceHeaderId+" class=devHeaderx></span>"+o;G+='</span><span id=MxMESH tabindex=0 style=cursor:pointer onclick=gotoMesh("'+E.meshid+"\") onkeypress=\"if (event.key=='Enter') gotoMesh('"+E.meshid+"')\">"+EscapeHtml(meshes[E.meshid].name)+"</span>"+getMeshActions(z,C)+"</div>";if(O==2){G+="</div>"}g=E.meshid;l[g]=1;a=0}}else{if(sort==1){var F=E.pwr?E.pwr:0;if(F!==g){deviceHeaderSet();if((O==1)&&(g!==null)){if(a==2){G+="<td><div style=width:301px></div></td>"}if(G!=""){G+="</tr></table>"}}G+="<div class=DevSt style=width:100%;padding-top:4px><span id=DevxHeader"+deviceHeaderId+" class=devHeaderx style=float:right></span><span>"+PowerStateStr2(E.pwr)+"</span></div>";g=F;a=0}}else{if(sort==2){if(g==null){g="1"}}}}e++;var L=EscapeHtml(E.name);if(L.length==0){L="<i>None</i>"}if((E.rname!=null)&&(E.rname.length>0)){L+=" / "+EscapeHtml(E.rname)}var D=EscapeHtml(E.name);if(showRealNames==true&&E.rname!=null){D=EscapeHtml(E.rname)}if(D.length==0){D="<i>None</i>"}var u=E.icon;if((!E.conn)||(E.conn==0)){u+=" gray"}if(O==1){G+="<div id=devs onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=display:inline-block;width:"+k+'px;height:50px;padding-top:1px;padding-bottom:1px><div style=width:22px;height:50%;float:left;padding-top:12px><input class="'+E.meshid+' DeviceCheckbox" onclick=p1updateInfo() value=devid_'+E._id+" type=checkbox></div><div style=height:100%;cursor:pointer tabindex=0 onclick=gotoDevice('"+E._id+"',null,null,event) onkeypress=\"if (event.key=='Enter') gotoDevice('"+E._id+'\',null,null,event)"><div class="i'+u+'" style=width:50px;float:left></div><div style=height:100%><div class=g1></div><div class=e2><div class=e1 style=width:'+(k-100)+'px title="'+L+'">'+D+"</div><div>"+NodeStateStr(E)+"</div></div><div class=g2></div></div></div></div>"}else{if(O==2){var J=[];if(E.conn){if((E.conn&1)!=0){J.push('<span title="Mesh agent is connected and ready for use.">Agent</span>')}if((E.conn&2)!=0){J.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">CIRA</span>')}else{if((E.conn&4)!=0){J.push('<span title="Intel&reg; AMT is routable.">AMT</span>')}}if((E.conn&8)!=0){J.push('<span title="Mesh agent is reachable using another agent as relay.">Relay</span>')}}G+="<tr><td><div id=devs class=bar18 tabindex=0 onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=height:18px;width:100%;font-size:medium onkeypress=\"if (event.key=='Enter') gotoDevice('"+E._id+"',null,null,event)\">";G+='<div class=deviceBarCheckbox><input class="'+E.meshid+' DeviceCheckbox" onclick=p1updateInfo() value=devid_'+E._id+" type=checkbox></div>";G+="<div class=deviceBarIcon onclick=gotoDevice('"+E._id+"',null,null,event)><div class=\"j"+u+'" style=width:16px;margin-top:1px;margin-left:2px;height:16px></div></div>';G+="<div class=g1 style=height:18px;float:left></div><div class=g2 style=height:18px;float:right></div>";G+='<div style=cursor:pointer;font-size:14px title="'+L+"\" onclick=gotoDevice('"+E._id+"',null,null,event)><span style=width:300px>"+D+"</span></div></div></td>";G+="<td style=text-align:center>"+getUserShortStr(E);G+="<td style=text-align:center>"+(E.ip!=null?E.ip:"");G+="<td style=text-align:center>"+J.join("&nbsp;+&nbsp;");G+="</tr>"}else{if((O==3)&&(E.conn&1)&&(((C&8)||(C&256))!=0)&&((E.agent.caps&1)!=0)){if((multiDesktopFilter.length==0)||(multiDesktopFilter.indexOf("devid_"+E._id)>=0)){G+="<div id=devs style=display:inline-block;margin:1px;background-color:lightgray;border-radius:5px;position:relative><div tabindex=0 style=padding:3px;cursor:pointer onclick=gotoDevice('"+E._id+"',11,null,event) onkeypress=\"if (event.key=='Enter') gotoDevice('"+E._id+"',11,null,event)\">";G+='<div class="j'+u+'" style=width:16px;float:left></div>&nbsp;'+D+"</div>";G+="<span onclick=gotoDevice('"+E._id+"',null,null,event)></span><div id=xkvmid_"+E._id.split("/")[2]+"><div id=skvmid_"+E._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(\''+E._id+"') onkeypress=\"if (event.key=='Enter') toggleKvmDevice('"+E._id+"')\">Disconnected</div></div>";G+="</div>";x.push(E._id)}}}}if((sort==3)&&(G!="")){if(E.tags){for(var w in E.tags){var K=E.tags[w];if(s[K]==null){s[K]=G;p[K]=1}else{s[K]+=G;p[K]+=1}if(O==3){break}}}G=""}deviceHeaderTotal++;if(typeof deviceHeaderCount[E.state]=="undefined"){deviceHeaderCount[E.state]=1}else{deviceHeaderCount[E.state]++}}if(sort==3){var q=[];for(var t in s){q.push(t)}q.sort(function(c,j){return c.toLowerCase().localeCompare(j.toLowerCase())});for(var w in q){var t=q[w];G+="<div class=DevSt style=width:100%;padding-top:4px><span class=devHeaderx style=float:right>"+p[t]+" node"+((p[t]>1)?"s":"")+"</span><span>"+t+"</span></div>"+s[t]}}if((G=="")&&(meshcount>0)&&(Q("SearchInput").value!="")){if(sort==3){G='<div style="margin:30px">No devices are included in any groups, click on a device\'s "Groups" to add to a group.</div>'}else{G='<div style="margin:30px">No devices matching this search.</div>'}}if((O==1)&&(a==2)){G+="<td><div style=width:301px></div></td>"}if((sort==0)&&(Q("SearchInput").value=="")&&(O<3)){for(var t in meshes){var y=meshes[t],A=y.links[userinfo._id];if(A!=null){var C=A.rights;if(l[y._id]==null){if((g!="")&&(G!="")){G+="</tr></table>"}G+='<table style=width:100%;padding-top:4px cellpadding=0 cellspacing=0><tr><td colspan=3 class=DevSt><span id=MxMESH style=cursor:pointer onclick=gotoMesh("'+y._id+'")>'+EscapeHtml(y.name)+"</span><span>";G+=getMeshActions(y,C);G+="</span></td></tr><tr>";if(y.mtype==1){G+="<td><div style=padding:10px><i>No Intel&reg; AMT devices in this mesh";if((C&4)!=0){G+=", <a href=# style=cursor:pointer onclick='return addDeviceToMesh(\""+y._id+"\"')>add one</a>"}}if(y.mtype==2){G+="<td><div style=padding:10px><i>No devices in this mesh";if((C&4)!=0){G+=", <a href=# style=cursor:pointer onclick='return addAgentToMesh(\""+y._id+"\")'>add one</a>"}}G+=".</i></div></td>";g=y._id;e++}}}}G+="</tr></table><div style=height:1px></div>";G+="<div style=border-top-style:solid;border-top-width:1px;border-top-color:#DDDDDD;cursor:pointer;font-size:10px>";if((O<3)&&(sort==0)&&(meshcount>0)&&((userinfo.siteadmin==4294967295)||((userinfo.siteadmin&64)==0))){G+='<a href=# onclick="return account_createMesh()" title="Create a new group of devices." style=cursor:pointer>Add Device Group</a>&nbsp'}if((userinfo.siteadmin==4294967295)||((userinfo.siteadmin&128)==0)){G+="<a href=# onclick='return p10showMeshCmdDialog(0)' style=cursor:pointer title=\"Download MeshCmd, a command line tool that performs many functions.\">MeshCmd</a>&nbsp";if(navigator.platform.toLowerCase()=="win32"){G+="<a href=# onclick='return p10showMeshRouterDialog()' style=cursor:pointer title=\"Download MeshCentral Router, a TCP port mapping tool.\">Router</a>&nbsp"}}G+="</div><br/>";QH("xdevices",G);deviceHeaderSet();var m=document.getElementsByClassName("DeviceCheckbox"),b=0;for(var t=0;t<m.length;t++){m[t].checked=(d.indexOf(m[t].value)>=0)}for(var t in deviceHeaders){QH(t,deviceHeaders[t])}for(var t in deviceHeadersTitles){Q(t).title=deviceHeadersTitles[t]}p1updateInfo();if(O==3){var P=[{x:180,y:101},{x:302,y:169},{x:454,y:255}][Q("sizeselect").selectedIndex];var H=P.x+2,N=M-5,R=Math.floor(N/H);R=H+Math.floor((N-(R*H))/R);P.y=P.y*(R/P.x);P.x=R;for(var t in multiDesktop){multiDesktop[t].xxdelete=true}for(var t in x){var v=x[t],I=v.split("/")[2],h=multiDesktop[v];if(h!=null){h.m.CanvasId.setAttribute("style","background-color:black;width:"+P.x+"px;height:"+P.y+"px");Q("xkvmid_"+I).appendChild(h.m.CanvasId);delete h.xxdelete;QH("skvmid_"+I,["Disconnected","Connecting...","Setup...","",""][((h.m.State==null)?h.m.state:h.m.State)])}else{var E=getNodeFromId(v);if((desktopNode==E)&&(desktop!=null)){var a=desktop.m.CanvasId;a.setAttribute("id","kvmid_"+I);a.setAttribute("style","background-color:black;width:"+P.x+"px;height:"+P.y+"px");a.setAttribute("onclick","toggleKvmDevice('"+v+"')");a.removeAttribute("onmousedown");a.removeAttribute("onmouseup");a.removeAttribute("onmousemove");Q("xkvmid_"+I).appendChild(a);QH("skvmid_"+I,["Disconnected","Connecting...","Setup...","",""][((desktop.m.State==null)?desktop.m.state:desktop.m.State)]);if(desktop.m.SendCompressionLevel){desktop.m.SendCompressionLevel(1,multidesktopsettings.quality,multidesktopsettings.scaling,multidesktopsettings.framerate)}desktop.shortid=I;desktop.onStateChanged=onMultiDesktopStateChange;multiDesktop[v]=desktop;desktop=desktopNode=currentNode=null;QH("DeskParent",'<canvas id="Desk" oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>')}else{var a=document.createElement("canvas");a.setAttribute("id","kvmid_"+I);a.setAttribute("width",640);a.setAttribute("height",480);a.setAttribute("oncontextmenu","return false");a.setAttribute("style","background-color:black;width:"+P.x+"px;height:"+P.y+"px");a.setAttribute("onclick","toggleKvmDevice('"+v+"')");try{Q("xkvmid_"+I).appendChild(a)}catch(n){}if(Q("autoConnectDesktopCheckbox").checked==true){setTimeout(function(){connectMultiDesktop(E,1)},100)}}}}for(var t in multiDesktop){if(multiDesktop[t].xxdelete==true){multiDesktop[t].Stop();delete multiDesktop[t]}else{if(debugmode&&multiDesktop[t].m&&multiDesktop[t].m.onScreenSizeChange){mdeskAdjust(multiDesktop[t].m,multiDesktop[t].m.ScreenWidth,multiDesktop[t].m.ScreenHeight,multiDesktop[t].m.CanvasId)}}}deskAdjust()}else{disconnectAllKvmFunction();Q("autoConnectDesktopCheckbox").checked=false}}oldviewmode=O}function toggleKvmDevice(d){var c=getNodeFromId(d),a=meshes[c.meshid],b=a.links[userinfo._id].rights;if((b&8)||(b&256)){if(c.conn&1){connectMultiDesktop(c,1)}}}function getUserShortStr(b){if(b==null||b.users==null||b.users.length==0){return""}if(b.users.length>1){return'<span title="'+EscapeHtml(b.users.join(", "))+'">'+b.users.length+"&nbsp;users</span>"}var d=b.users[0],c=d,a=d.indexOf("\\");if(a>0){c=d.substring(a+1)}c=EscapeHtml(c);if(c.length>15){c=c.substring(0,14)+"&#8230;"}return'<span title="'+EscapeHtml(d)+'">'+c+"</span>"}function autoConnectDesktops(){if(Q("autoConnectDesktopCheckbox").checked==true){connectAllKvmFunction()}}function connectAllKvmFunction(){for(var a in nodes){if(multiDesktop[nodes[a]._id]==null){toggleKvmDevice(nodes[a]._id)}}}function disconnectAllKvmFunction(){for(var a in multiDesktop){multiDesktop[a].Stop()}multiDesktop={}}function onMultiDesktopStateChange(a,c){try{QH("skvmid_"+a.shortid,["Disconnected","Connecting...","Setup...","",""][c])}catch(b){}}function showMultiDesktopSettings(){QV("d7amtkvm",false);QV("d7meshkvm",true);d7bitmapquality.value=multidesktopsettings.quality;d7bitmapscaling.value=multidesktopsettings.scaling;if(multidesktopsettings.framerate){d7framelimiter.value=multidesktopsettings.framerate}else{d7framelimiter.value=1000}setDialogMode(7,"Remote Desktop Settings",3,showMultiDesktopSettingsChanged)}function showMultiDesktopSettingsChanged(){multidesktopsettings.quality=d7bitmapquality.value;multidesktopsettings.scaling=d7bitmapscaling.value;multidesktopsettings.framerate=d7framelimiter.value;localStorage.setItem("multidesktopsettings",JSON.stringify(multidesktopsettings));for(var a in multiDesktop){multiDesktop[a].m.SendCompressionLevel(1,multidesktopsettings.quality,multidesktopsettings.scaling,multidesktopsettings.framerate)}}function connectMultiDesktop(c,a){var d=c._id,e=d.split("/")[2];var b=multiDesktop[d];if(b==null){if(Q("kvmid_"+e)==null){return}if(a==2){if((c.intelamt.user==null)||(c.intelamt.user=="")){return}b=CreateAmtRedirect(CreateAmtRemoteDesktop("kvmid_"+e),authCookie);b.shortid=e;b.onStateChanged=onMultiDesktopStateChange;b.m.bpp=1;b.m.useZRLE=true;b.m.showmouse=true;b.m.onKvmData=function(g){console.log("KVM Data received in multi-desktop mode, this is not supported.")};if(debugmode>0){b.m.onScreenSizeChange=mdeskAdjust}b.Start(d,16994,"*","*",0);b.contype=2;multiDesktop[d]=b}else{if(a==1){b=CreateAgentRedirect(meshserver,CreateAgentRemoteDesktop("kvmid_"+e),serverPublicNamePort,authCookie,domainUrl);b.shortid=e;b.attemptWebRTC=attemptWebRTC;b.onStateChanged=onMultiDesktopStateChange;b.m.CompressionLevel=multidesktopsettings.quality;b.m.ScalingLevel=multidesktopsettings.scaling;b.m.FrameRateTimer=multidesktopsettings.framerate;if(debugmode>0){b.m.onScreenSizeChange=mdeskAdjust}b.Start(d);b.contype=1;multiDesktop[d]=b}}}else{b.Stop();delete multiDesktop[d]}}function getMeshActions(a,b){if((b&4)==0){return""}var c="";if((features&1024)==0){c+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer that is located on the internet." onclick=\'return addCiraDeviceToMesh("'+a._id+"\")'>Add CIRA</a>"}if(a.mtype==1){if((features&1)==0){c+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer that is located on the local network." onclick=\'return addDeviceToMesh("'+a._id+"\")'>Add Local</a>";c+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer by scanning the local network." onclick=\'return addAmtScanToMesh("'+a._id+"\")'>Scan Network</a>"}if(a.amt&&(a.amt.type==2)){c+=' <a href=# style=cursor:pointer;font-size:10px title="Perform Intel AMT client control mode (CCM) activation." onclick=\'return showCcmActivation("'+a._id+"\")'>Activation</a>"}else{if(a.amt&&(a.amt.type==3)&&((features&1048576)!=0)){c+=' <a href=# style=cursor:pointer;font-size:10px title="Perform Intel AMT admin control mode (ACM) activation." onclick=\'return showAcmActivation("'+a._id+"\")'>Activation</a>"}}}if(a.mtype==2){c+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new computer to this mesh by installing the mesh agent." onclick=\'return addAgentToMesh("'+a._id+"\")'>Add Agent</a>";c+=' <a href=# style=cursor:pointer;font-size:10px title="Invite someone to install the mesh agent on this mesh." onclick=\'return inviteAgentToMesh("'+a._id+"\")'>Invite</a>"}return c}function addDeviceToMesh(b){if(xxdialogMode){return false}var a=meshes[b];var c='Add a new Intel&reg; AMT device to device group "'+EscapeHtml(a.name)+'".<br /><br />';c+=addHtmlValue("Device Name","<input id=dp1devicename style=width:230px maxlength=32 autocomplete=off onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />");c+=addHtmlValue("Hostname",'<input id=dp1hostname style=width:230px maxlength=32 autocomplete=off placeholder="Same as device name" onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />');c+=addHtmlValue("Username",'<input id=dp1username style=width:230px maxlength=32 autocomplete=off placeholder="admin" onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />');c+=addHtmlValue("Password","<input id=dp1password type=password style=width:230px autocomplete=off maxlength=32 onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />");c+=addHtmlValue("Security","<select id=dp1tls style=width:236px><option value=0>No TLS security</option><option value=1>TLS security required</option></select>");setDialogMode(2,"Add Intel&reg; AMT device",3,addDeviceToMeshEx,c,b);validateDeviceToMesh();Q("dp1devicename").focus();return false}function showCcmActivation(c){if(xxdialogMode){return false}var e=serverinfo.name,b=meshes[c];if((e.indexOf(".")==-1)||((features&2)!=0)){e=window.location.hostname}var g,a=domainUrl.substring(0,domainUrl.length-1);if(serverinfo.https==true){var d=(serverinfo.port==443)?"":(":"+serverinfo.port);g="wss://"+e+d+domainUrl}else{var d=(serverinfo.port==80)?"":(":"+serverinfo.port);g="ws://"+e+d+domainUrl}var h='Perform Intel AMT client control mode (CCM) activation to group "'+EscapeHtml(b.name)+'" by downloading the MeshCMD tool and running it like this:<br /><br />';h+="<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtccm --url "+g+"amtactivate?id="+c.split("/")[2]+" --serverhttpshash "+serverinfo.tlshash+"</textarea>";setDialogMode(2,"Intel&reg; AMT activation",9,null,h);Q("idx_dlgOkButton").focus();return false}function showAcmActivation(c){if(xxdialogMode){return false}var e=serverinfo.name,b=meshes[c];if((e.indexOf(".")==-1)||((features&2)!=0)){e=window.location.hostname}var g,a=domainUrl.substring(0,domainUrl.length-1);if(serverinfo.https==true){var d=(serverinfo.port==443)?"":(":"+serverinfo.port);g="wss://"+e+d+domainUrl}else{var d=(serverinfo.port==80)?"":(":"+serverinfo.port);g="ws://"+e+d+domainUrl}var h='Perform Intel AMT admin control mode (ACM) activation to group "'+EscapeHtml(b.name)+'" by downloading the MeshCMD tool and running it like this:<br /><br />';h+="<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtacm --url "+g+"amtactivate?id="+c.split("/")[2]+" --serverhttpshash "+serverinfo.tlshash+"</textarea>";if(serverinfo.amtAcmFqdn!=null){h+="<div style=margin-top:8px>Intel AMT will need to be set with a Trusted FQDN in MEBx or have a wired LAN on the network: <b>"+serverinfo.amtAcmFqdn.join(", ")+"</b></div>"}setDialogMode(2,"Intel&reg; AMT activation",9,null,h);Q("idx_dlgOkButton").focus();return false}function addAmtScanToMesh(a){if(xxdialogMode){return false}var b="Enter a range of IP addresses to scan for Intel AMT devices.<br /><br />";b+=addHtmlValue("IP Range",'<input id=dp1range style=width:184px value="192.168.1.0/24" onkeyup=addAmtScanToMeshKeyUp(event) /><input id=dp1rangebutton type=button value=Scan onclick=addAmtScanToMeshButton()></input>');b+='<div id=dp1results style="width:100%;height:200px;background-color:white;border:1px gray solid;overflow-y:scroll"></div>';setDialogMode(2,"Scan for Intel&reg; AMT devices",3,addAmtScanToMeshEx,b,a);QE("idx_dlgOkButton",false);QH("dp1results","<div style=width:100%;text-align:center;margin-top:12px;color:gray;line-height:1.5>Sample IP range values<br />192.168.0.100<br />192.168.1.0/24<br />192.167.0.1-192.168.0.100</div>");focusTextBox("dp1range");return false}function addAmtScanToMeshKeyUp(a){if(a.keyCode==13){haltEvent(a);addAmtScanToMeshButton()}}function addAmtScanToMeshEx(b,h){var d=document.getElementsByClassName("DevScanCheckbox"),c=0;for(var e=0;e<d.length;e++){if(d[e].checked){var g=d[e].getAttribute("tag");var a=amtScanResults[g];meshserver.send({action:"addamtdevice",meshid:h,devicename:g,hostname:a.hostname,amtusername:"",amtpassword:"",amttls:a.tls})}}}function addAmtScanToMeshButton(){QE("dp1range",false);QE("dp1rangebutton",false);QH("dp1results","<div style=width:100%;text-align:center;margin-top:12px>Scanning...</div>");meshserver.send({action:"scanamtdevice",range:Q("dp1range").value})}function addAmtScanToMeshCheckbox(){var b=document.getElementsByClassName("DevScanCheckbox"),a=0;for(var c=0;c<b.length;c++){if(b[c].checked){a++}}QE("idx_dlgOkButton",a>0)}function addCiraDeviceToMesh(b){if(xxdialogMode){return false}var a=meshes[b];var c=b.split("/")[2].replace(/\@/g,"X").replace(/\$/g,"X");var e="<select id=dlgAddCiraSel onclick=dlgAddCiraSelClick() style=width:230px><option value=0>MeshCommander Script</option><option value=1>Manual Username/Password</option>";if((features&16)==0){e+="<option value=2>Manual Certificate</option></select>"}var d="";d+=addHtmlValue("Setup Method",e);d+="<hr>";d+='<div id=dlgAddCira0>To add a new Intel&reg; AMT device to device group "'+EscapeHtml(a.name)+"\" with CIRA, download the following script files and use <a href='http://meshcommander.com' rel='noreferrer noopener' target='_blank'>MeshCommander</a> to run the script to configure computers.<br /><br />";d+=addHtmlValue("Setup CIRA",'<a href="mescript.ashx?type=1&meshid='+c.substring(0,16)+'" download>cira_setup.mescript</a>');d+=addHtmlValue("Cleanup CIRA",'<a href="mescript.ashx?type=2" download>cira_clean.mescript</a>');d+="</div>";d+='<div id=dlgAddCira1 style=display:none>To add a new Intel&reg; AMT device to device group "'+EscapeHtml(a.name)+'" with CIRA, load the following certificate as trusted root within Intel AMT';if(serverinfo.mpspass){d+=" and authenticate to the server using this username and password.<br /><br />"}else{d+=" and authenticate to the server using this username and any password.<br /><br />"}d+=addHtmlValue("Root Certificate",'<a href="MeshServerRootCert.cer" download>Root Certificate File</a>');d+=addHtmlValue("Username",'<input style=width:230px readonly value="'+c.substring(0,16)+'" />');if(serverinfo.mpspass){d+=addHtmlValue("Password",'<input style=width:230px readonly value="'+EscapeHtml(serverinfo.mpspass)+'" />')}if(serverinfo!=null){d+=addHtmlValue("MPS Server",'<input style=width:230px readonly value="'+EscapeHtml(serverinfo.mpsname)+":"+serverinfo.mpsport+'" />')}d+="</div>";if((features&16)==0){d+='<div id=dlgAddCira2 style=display:none>To add a new Intel&reg; AMT device to device group "'+EscapeHtml(a.name)+'" with CIRA, load the following certificate as trusted root within Intel AMT, authenticate using a client certificate with the following common name and connect to the following server.<br /><br />';d+=addHtmlValue("Root Certificate",'<a href="MeshServerRootCert.cer" download>Root Certificate File</a>');d+=addHtmlValue("Organization",'<input style=width:230px readonly value="'+c+'" />');if(serverinfo!=null){d+=addHtmlValue("MPS Server",'<input style=width:230px readonly value="'+EscapeHtml(serverinfo.mpsname)+":"+serverinfo.mpsport+'" />')}d+="</div>"}setDialogMode(2,"Add Intel&reg; AMT CIRA device",2,null,d,"fileDownload");Q("dlgAddCiraSel").focus();return false}function dlgAddCiraSelClick(){var a=Q("dlgAddCiraSel").value;QV("dlgAddCira0",a==0);QV("dlgAddCira1",a==1);QV("dlgAddCira2",a==2)}function checkEmail(c){var d=c.split("@");var b=((d.length==2)&&(d[0].length>0)&&(d[1].split(".").length>1)&&(d[1].length>2));if(b==true){var e=d[1].split(".");for(var a in e){if(e[a].length==0){b=false}}}return b}function inviteAgentToMesh(b){if(xxdialogMode){return false}var c="",a=meshes[b];if(features&64){c+=addHtmlValue("Invitation Type","<select id=d2InviteType onchange=d2ChangedInviteType() style=width:236px><option value=0>Link invitation</option><option value=1>Email invitation</option></select>")+"<hr />";c+='<div id=emailInviteDiv style=display:none>Invite someone to install the mesh agent. An email with be sent with the link to the mesh agent installation for the "'+EscapeHtml(a.name)+'" device group.<br /><br />';c+=addHtmlValue("Name (optional)",'<input id=agentInviteName value="" style=width:230px maxlength=64 />');c+=addHtmlValue("Email",'<input id=agentInviteEmail style=width:230px placeholder="example@email.com" onkeyup=validateAgentInvite()></input>');c+=addHtmlValue("Operating System","<select id=agentInviteNameOs onchange=d2ChangedInviteType() style=width:236px><option value=4>Send installation link</option><option value=0 selected>Any supported</option><option value=1>Windows only</option><option value=3>Apple MacOS only</option><option value=2>Linux only</option></select>");c+="<div id=d2agentexpirediv>";c+=addHtmlValue("Link Expiration","<select id=agentInviteExpire style=width:236px><option value=1>1 hour</option><option value=8>8 hours</option><option value=24>1 day</option><option value=168>1 week</option><option value=5040>1 month</option><option value=0>Unlimited</option></select>");c+="</div>";c+=addHtmlValue("Installation Type","<select id=agentInviteType style=width:236px><option value=0>Background and interactive</option><option value=2>Background only</option><option value=1>Interactive only</option></select>");c+=addHtmlValue("Message<br />(optional)",'<textarea id=agentInviteMessage value="" style=width:230px;height:100px;resize:none maxlength=1024 /></textarea>');c+="</div>"}c+='<div id=urlInviteDiv>Invite someone to install the mesh agent by sharing an invitation link. This link points the user to installation instructions for the "'+EscapeHtml(a.name)+'" device group. The link is public and no account for this server is needed.<br /><br />';c+=addHtmlValue("Link Expiration","<select id=d2inviteExpire style=width:236px onchange=d2RequestInvitationLink()><option value=1>1 hour</option><option value=8>8 hours</option><option value=24>1 day</option><option value=168>1 week</option><option value=5040>1 month</option><option value=0>Unlimited</option></select>");c+='<div id=agentInvitationLinkDiv style="text-align:center;font-size:large;margin:16px;display:none"><a href=# id=agentInvitationLink target="_blank" style=cursor:pointer></a> <img src=images/link4.png height=10 width=10 title="Copy link to clipboard" style=cursor:pointer onclick=d2CopyInviteToClip()></div></div>';setDialogMode(2,"Invite",3,performAgentInvite,c,b);if(features&64){Q("d2InviteType").focus();d2ChangedInviteType()}else{Q("d2inviteExpire").focus();validateAgentInvite()}d2RequestInvitationLink();return false}function d2RequestInvitationLink(){meshserver.send({action:"createInviteLink",meshid:xxdialogTag,expire:parseInt(Q("d2inviteExpire").value),flags:0})}function d2ChangedInviteType(){QV("urlInviteDiv",Q("d2InviteType").value==0);QV("d2agentexpirediv",Q("agentInviteNameOs").value==4);QV("emailInviteDiv",Q("d2InviteType").value==1);validateAgentInvite()}function d2CopyInviteToClip(){copyTextToClip(Q("agentInvitationLink").href)}function validateAgentInvite(){if((features&64)&&(Q("d2InviteType").value==1)){QE("idx_dlgOkButton",checkEmail(Q("agentInviteEmail").value));QV("idx_dlgCancelButton",true)}else{QE("idx_dlgOkButton",true);QV("idx_dlgCancelButton",false)}}function performAgentInvite(a,b){if((features&64)&&(Q("d2InviteType").value==1)){meshserver.send({action:"inviteAgent",meshid:b,email:Q("agentInviteEmail").value,name:Q("agentInviteName").value,os:Q("agentInviteNameOs").value,flags:Q("agentInviteType").value,msg:Q("agentInviteMessage").value,expire:parseInt(Q("agentInviteExpire").value)})}}function addAgentToMesh(e){if(xxdialogMode){return false}var c=meshes[e],j="",b=0;j+=addHtmlValue("Operating System","<select id=aginsSelect onchange=addAgentToMeshClick() style=width:236px><option value=0>Windows</option><option value=1>Linux / BSD</option><option value=2>Apple MacOS</option><option value=3>Windows (UnInstall)</option><option value=4>Linux / BSD (UnInstall)</option></select>");j+="<div id=aginsTypeDiv>";j+=addHtmlValue("Installation Type","<select id=aginsType onchange=addAgentToMeshClick() style=width:236px><option value=0>Background & interactive</option><option value=2>Background only</option><option value=1>Interactive only</option></select>");j+="</div><hr>";var d=c.name;d=d.split("\\").join("").split("/").join("").split(":").join("").split("*").join("").split("?").join("").split('"').join("").split("<").join("").split(">").join("").split("|").join("").split(" ").join("").split("'").join("");j+='<div id=agins_windows>To add a new computer to device group "'+EscapeHtml(c.name)+'", download the mesh agent and install it the computer to manage. This agent has server and device group information embedded within it.<br /><br />';j+=addHtmlValue("Mesh Agent",'<a id=aginsw32lnk href="meshagents?id=3&meshid='+e.split("/")[2]+'&installflags=0" download onclick="setDialogMode(0)" title="32bit version of the MeshAgent">Windows (.exe)</a> <img src=images/link4.png height=10 width=10 title="Copy Windows 32bit agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshagents?id=3&meshid='+e.split("/")[2]+'&installflags=",1)>');j+=addHtmlValue("Mesh Agent",'<a id=aginsw64lnk href="meshagents?id=4&meshid='+e.split("/")[2]+'&installflags=0" download onclick="setDialogMode(0)" title="64bit version of the MeshAgent">Windows x64 (.exe)</a> <img src=images/link4.png height=10 width=10 title="Copy Windows 64bit agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshagents?id=4&meshid='+e.split("/")[2]+'&installflags=",1)>');if(debugmode>0){j+=addHtmlValue("Settings File",'<a id=aginswmshlnk href="meshsettings?id='+e.split("/")[2]+'&installflags=0" rel="noreferrer noopener" target="_blank">'+EscapeHtml(c.name)+" settings (.msh)</a>")}j+="</div>";j+="<div id=agins_linux style=display:none>To add a computer to "+EscapeHtml(c.name)+" run the following command. Root credentials will be needed.<br />";j+="<textarea id=agins_linux_area rows=2 cols=20 readonly=readonly style=width:100%;resize:none;height:120px;overflow:scroll;font-size:12px readonly></textarea>";j+="<div style='font-size:x-small'>* For BSD, run \"pkg install wget sudo bash\" first.</div></div>";j+='<div id=agins_osx style=display:none>To add a new computer to device group "'+EscapeHtml(c.name)+'", download the mesh agent and install it the computer to manage. This agent installer has server and device group information embedded within it.<br /><br />';j+=addHtmlValue("Mesh Agent",'<a href="meshosxagent?id=16&meshid='+e.split("/")[2]+'" rel="noreferrer noopener" target="_blank" title="64bit version of MacOS Mesh Agent">MacOS Agent (64bit)</a> <img src=images/link4.png height=10 width=10 title="Copy MacOS agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshosxagent?id=16&meshid='+e.split("/")[2]+'",0)>');j+="</div>";j+='<div id=agins_windows_un style=display:none>To remove a mesh agent, download the file below, run it and click "uninstall".<br /><br />';j+=addHtmlValue("Mesh Agent",'<a href="meshagents?id=3" download onclick="setDialogMode(0)" title="32bit version of the MeshAgent">Windows (.exe)</a>');j+=addHtmlValue("Mesh Agent",'<a href="meshagents?id=4" download onclick="setDialogMode(0)" title="64bit version of the MeshAgent">Windows x64 (.exe)</a>');j+="</div>";j+="<div id=agins_linux_un style=display:none>To remove a mesh agent, run the following command. Root credentials will be needed.<br />";j+="<textarea id=agins_linux_area_un rows=2 cols=20 readonly=readonly style=width:100%;resize:none;height:120px;overflow:scroll;font-size:12px readonly></textarea>";j+="</div>";setDialogMode(2,"Add Mesh Agent",2,null,j,"fileDownload");var h=serverinfo.name;if((h.indexOf(".")==-1)||((features&2)!=0)){h=window.location.hostname}var a=domainUrl.substring(0,domainUrl.length-1);if(serverinfo.https==true){var g=(serverinfo.port==443)?"":(":"+serverinfo.port);if((features&8192)==0){Q("agins_linux_area").value="(wget https://"+h+g+domainUrl+"meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://"+h+g+domainUrl+"meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://"+h+g+a+" '"+e.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="(wget https://"+h+g+domainUrl+"meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://"+h+g+domainUrl+"meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}else{Q("agins_linux_area").value="wget https://"+h+g+domainUrl+"meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://"+h+g+a+" '"+e.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="wget https://"+h+g+domainUrl+"meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}}else{var g=(serverinfo.port==80)?"":(":"+serverinfo.port);if((features&8192)==0){Q("agins_linux_area").value="(wget http://"+h+g+domainUrl+"meshagents?script=1 -O ./meshinstall.sh || wget http://"+h+g+domainUrl+"meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://"+h+g+a+" '"+e.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="(wget http://"+h+g+domainUrl+"meshagents?script=1 -O ./meshinstall.sh || wget http://"+h+g+domainUrl+"meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}else{Q("agins_linux_area").value="wget http://"+h+g+domainUrl+"meshagents?script=1 --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://"+h+g+a+" '"+e.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="wget http://"+h+g+domainUrl+"meshagents?script=1 --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}}Q("aginsSelect").focus();addAgentToMeshClick();return false}function copyAgentUrl(h,a){var g=serverinfo.name;if((g.indexOf(".")==-1)||((features&2)!=0)){g=window.location.hostname}var d=domainUrl.substring(0,domainUrl.length-1);var e=(serverinfo.port==443)?"":(":"+serverinfo.port);var b="https://"+g+e+domainUrl+h;if(a==1){b+=Q("aginsType").value}copyTextToClip(b)}function addAgentToMeshClick(){var a=Q("aginsSelect").value;QV("agins_windows",a==0);QV("agins_linux",a==1);QV("agins_osx",a==2);QV("agins_windows_un",a==3);QV("agins_linux_un",a==4);QV("aginsTypeDiv",a==0);Q("aginsw32lnk").href=(Q("aginsw32lnk").href.split("installflags=")[0])+"installflags="+Q("aginsType").value;Q("aginsw64lnk").href=(Q("aginsw64lnk").href.split("installflags=")[0])+"installflags="+Q("aginsType").value;if(debugmode>0){Q("aginswmshlnk").href=(Q("aginswmshlnk").href.split("installflags=")[0])+"installflags="+Q("aginsType").value}}function validateDeviceToMesh(){QE("idx_dlgOkButton",(Q("dp1devicename").value.length>0)&&(passwordcheck(Q("dp1password").value)))}function addDeviceToMeshEx(b,d){var a=Q("dp1username").value;if(a==""){a="admin"}var c=Q("dp1hostname").value;if(c==""){c=Q("dp1devicename").value}meshserver.send({action:"addamtdevice",meshid:d,devicename:Q("dp1devicename").value,hostname:c,amtusername:a,amtpassword:Q("dp1password").value,amttls:Q("dp1tls").value})}function deviceHeaderSet(){if(deviceHeaderId==0){deviceHeaderId=1;return}deviceHeaders["DevxHeader"+deviceHeaderId]=deviceHeaderTotal+((deviceHeaderTotal==1)?" node":" nodes");deviceHeaderId++;deviceHeaderCount={};deviceHeaderTotal=0}var powerStateStrings=["",'<span title="Device is powered on.">Powered</span>','<span title="Device is in sleep state (S1).">Sleeping</span>','<span title="Device is in sleep state (S2).">Sleeping</span>','<span title="Device is in deep sleep state (S3).">Deep Sleep</span>','<span title="Device is in hibernating state (S4).">Hibernating</span>','<span title="Device is in powered off state (S5).">Soft-Off</span>','<span title="Device is detected but power state could not be obtained.">Present</span>'];var powerStateStrings2=["","Device is powered","Device is in sleep state (S1)","Device is in sleep state (S2)","Device is in deep sleep state (S3)","Device is hibernating (S4)","Device is in soft-off state (S5)","Device is present, but power state cannot be determined"];var powerColorTable=["pwsTransparent","pwsBlack","pwsBlue","pwsBlue2","pwsLightblue","pwsBlueviolet","pwsDarkgreen","pwsLightseagreen","pwsLightseagreen2"];function NodeStateStr(a){var b=[];if(a.state>0&&a.state<powerStatetable.length){state.push(powerStatetable[a.state])}if(a.conn){if((a.conn&1)!=0){b.push('<span title="Mesh agent is connected and ready for use.">Agent</span>')}if((a.conn&2)!=0){b.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">CIRA</span>')}else{if((a.conn&4)!=0){b.push('<span title="Intel&reg; AMT is routable.">Intel&reg; AMT</span>')}}if((a.conn&8)!=0){b.push('<span title="Mesh agent is reachable using another agent as relay.">Relay</span>')}}if((a.pwr!=null)&&(a.pwr!=0)){b.push(powerStateStrings[a.pwr])}return b.join(", ")}function PowerStateStr(a){if(a<powerStatetable.length){return powerStatetable[a]}return""}function PowerStateStr2(a){if((a!=0)&&(a<powerStatetable.length)){return powerStatetable[a]}return"Unknown"}function selectallButtonFunction(){var b=document.getElementsByClassName("DeviceCheckbox"),a=0;for(var c=0;c<b.length;c++){if(b[c].checked===true){a++}}for(var c=0;c<b.length;c++){b[c].checked=(a==0)}p1updateInfo()}function p1updateInfo(){var b=document.getElementsByClassName("DeviceCheckbox"),a=0;for(var c=0;c<b.length;c++){if(b[c].checked===true){a++}}if(a>0){QE("GroupActionButton",true);Q("SelectAllButton").value="Select None";QV("cxmgroupsplit",true);QV("cxmdesktop",true)}else{QE("GroupActionButton",false);Q("SelectAllButton").value="Select All";QV("cxmgroupsplit",false);QV("cxmdesktop",false)}}function groupActionFunction(){var a="Select an operation to perform on all selected devices. Actions will be performed only with proper rights.<br /><br />";a+=addHtmlValue("Operation","<select id=d2groupop><option value=100>Wake-up devices</option><option value=4>Sleep devices</option><option value=3>Reset devices</option><option value=2>Power off devices</option><option value=102>Move to device group</option><option value=101>Delete devices</option></select>");setDialogMode(2,"Group Action",3,groupActionFunctionEx,a)}function getCheckedDevices(){var e=[],b=document.getElementsByClassName("DeviceCheckbox"),a=0;for(var c=0;c<b.length;c++){if(b[c].checked){if(b[c].value){var d=b[c].value.substring(6);if(e.indexOf(d)==-1){e.push(d)}}}}return e}function groupActionFunctionEx(){var a=Q("d2groupop").value;if(a==100){meshserver.send({action:"wakedevices",nodeids:getCheckedDevices()})}else{if(a==101){var b="Confirm delete selected devices(s)?<br /><br />";b+="<label><input id=d2check type=checkbox onchange=d2groupActionFunctionDelEx() />Confirm</label>";setDialogMode(2,"Delete Nodes",3,groupActionFunctionDelEx,b);QE("idx_dlgOkButton",false)}else{if(a==102){p10showChangeGroupDialog(getCheckedDevices())}else{meshserver.send({action:"poweraction",nodeids:getCheckedDevices(),actiontype:a})}}}}function d2groupActionFunctionDelEx(){QE("idx_dlgOkButton",Q("d2check").checked)}function groupActionFunctionDelEx(){meshserver.send({action:"removedevices",nodeids:getCheckedDevices()})}function onSortSelectChange(a){sort=document.getElementById("sortselect").selectedIndex;if(!a){putstore("sort",sort)}}function meshSort(c,d){if(c.meshnamel>d.meshnamel){return 1}if(c.meshnamel<d.meshnamel){return -1}if(c.meshid==d.meshid){if(showRealNames==true){if(c.rnamel>d.rnamel){return 1}if(c.rnamel<d.rnamel){return -1}return 0}else{if(c.namel>d.namel){return 1}if(c.namel<d.namel){return -1}return 0}}return 0}function powerSort(c,e){var d=c.pwr?c.pwr:0;var g=e.pwr?e.pwr:0;if(d>g){return -1}if(d<g){return 1}if(d==g){if(showRealNames==true){if(c.rnamel>e.rnamel){return 1}if(c.rnamel<e.rnamel){return -1}return 0}else{if(c.namel>e.namel){return 1}if(c.namel<e.namel){return -1}return 0}}return 0}function deviceSort(c,d){if(c.namel>d.namel){return 1}if(c.namel<d.namel){return -1}return 0}function deviceHostSort(c,d){if(c.rnamel>d.rnamel){return 1}if(c.rnamel<d.rnamel){return -1}return 0}function onSearchFocus(a){searchFocus=a}function onMapSearchFocus(a){mapSearchFocus=a}function onUserSearchFocus(a){userSearchFocus=a}function onConsoleFocus(a){consoleFocus=a}function onSearchInputChanged(){var m=Q("SearchInput").value.toLowerCase().trim();putstore("_search",m);var l=null,g=null,c=null;if(m.startsWith("user:")){l=m.substring(5)}else{if(m.startsWith("u:")){l=m.substring(2)}else{if(m.startsWith("ip:")){g=m.substring(3)}else{if(m.startsWith("group:")){c=m.substring(6)}else{if(m.startsWith("g:")){c=m.substring(2)}}}}}if(m==""){for(var a in nodes){nodes[a].v=true}}else{if(g!=null){for(var a in nodes){nodes[a].v=((nodes[a].ip!=null)&&(nodes[a].ip.indexOf(g)>=0))}}else{if(c!=null){for(var a in nodes){nodes[a].v=(meshes[nodes[a].meshid].name.toLowerCase().indexOf(c)>=0)}}else{if(l!=null){for(var a in nodes){nodes[a].v=false;if(nodes[a].users&&nodes[a].users.length>0){for(var e in nodes[a].users){if(nodes[a].users[e].toLowerCase().indexOf(l)>=0){nodes[a].v=true}}}}}else{try{var h=m.split(/\s+/).join("|"),j=new RegExp(h);for(var a in nodes){nodes[a].v=(j.test(nodes[a].name.toLowerCase()))||(nodes[a].rnamel!=null&&j.test(nodes[a].rnamel.toLowerCase()));if((nodes[a].v==false)&&nodes[a].tags){for(var k in nodes[a].tags){if(j.test(nodes[a].tags[k].toLowerCase())){nodes[a].v=true;break}else{nodes[a].v=false}}}}}catch(b){for(var a in nodes){nodes[a].v=true}}}}}}}var contextelement=null;function handleContextMenu(d){hideContextMenu();var m=(window.pageXOffset!==null)?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft;var n=(window.pageYOffset!==null)?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;var c=document.elementFromPoint(d.pageX-m,d.pageY-n);if(c&&c!=null&&c.id=="connectbutton2"&&currentNode&&currentNode.agent&&(currentNode.agent.id>0)&&(currentNode.agent.id<5)){contextelement=c;var b=document.getElementById("termShellContextMenu");b.style.left=d.pageX+"px";b.style.top=d.pageY+"px";b.style.display="block"}else{if(c&&c!=null&&c.id=="MxMESH"){contextelement=c;var b=document.getElementById("meshContextMenu");b.style.left=d.pageX+"px";b.style.top=d.pageY+"px";b.style.display="block"}else{while(c&&c!=null&&c.id!="devs"){c=c.parentElement}if(!c||c==null){return true}contextelement=c;var b=document.getElementById("contextMenu");b.style.left=d.pageX+"px";b.style.top=d.pageY+"px";b.style.display="block";var l=contextelement.children[1].attributes.onclick.value;var k=getNodeFromId(l.substring(12,l.length-18));var g=meshes[k.meshid];var h=g.links[userinfo._id];var j=h.rights;var a=((j&16)!=0);var o=((j==4294967295)||((j&512)==0));var e=((j==4294967295)||((j&1024)==0));QV("cxdesktop",((g.mtype==1)||(k.agent==null)||(k.agent.caps==null)||((k.agent.caps&1)!=0)||(k.intelamt&&(k.intelamt.state==2)))&&((j&8)||(j&256)));QV("cxterminal",((g.mtype==1)||(k.agent==null)||(k.agent.caps==null)||((k.agent.caps&2)!=0)||(k.intelamt&&(k.intelamt.state==2)))&&(j&8)&&o);QV("cxfiles",((g.mtype==2)&&((k.agent==null)||(k.agent.caps==null)||((k.agent.caps&4)!=0)))&&(j&8)&&e);QV("cxevents",(k.intelamt!=null)&&((k.intelamt.state==2)||(k.conn&2))&&(j&8));QV("cxconsole",(a&&(g.mtype==2)&&((k.agent==null)||(k.agent.caps==null)||((k.agent.caps&8)!=0)))&&(j&8))}}return haltEvent(d)}function cmaction(a,b){var d=contextelement.children[1].attributes.onclick.value;d=d.substring(12,d.length-18);if(a==7){Q("viewselect").value=3;Q("viewselect").onchange();Q("autoConnectDesktopCheckbox").checked=true;Q("autoConnectDesktopCheckbox").onclick()}if((a>0)&&(a<7)){var e=[0,10,12,11,13,16,15][a];if(b&&(b.shiftKey==true)){window.open(window.location.origin+"?node="+d.split("/")[2]+"&viewmode="+e+"&hide=16","meshcentral:"+d)}else{gotoDevice(d,e);var c=meshes[currentNode.meshid];if((currentNode.conn&1)&&(c.mtype==2)){if((e==11)&&(desktop==null)&&(currentNode.agent.caps&1)){connectDesktop(null,1)}if((e==12)&&(terminal==null)&&(currentNode.agent.caps&2)){connectTerminal(null,1)}if((e==13)&&(files==null)){connectFiles(null)}}}}}function cmmeshaction(a){var d=contextelement.attributes.onclick.value.substring(10,contextelement.attributes.onclick.value.length-2);var b=document.getElementsByClassName("DeviceCheckbox");if((a==1)||(a==2)){for(var c=0;c<b.length;c++){if((b[c].attributes)&&(b[c].attributes["class"]["value"].split(" ")[0]==d)){b[c].checked=(a==1)}}}p1updateInfo()}function cmtermaction(a){connectTerminal(null,1,{powershell:(a==2)})}function hideContextMenu(){QV("contextMenu",false);QV("meshContextMenu",false);QV("termShellContextMenu",false);contextelement=null}var xxmap={map:null,contextmenu:null,activeInteractions:[],showindex:0,markersSource:null,markersLayer:null,mapLayer:null,mapView:null,};function updateMapMarkers(j){if((xxmap!=null)&&(xxmap.map==null)){try{loadmap()}catch(b){console.error("loadmap() exception",b)}}if(xxmap==null){return}var a=null;for(var d in nodes){try{var g=map_parseNodeLoc(nodes[d]),c=xxmap.markersSource.getFeatureById(nodes[d]._id);if((g!=null)&&((nodes[d].meshid==j)||(j==null))){var e=g[0],h=g[1],k=g[2];if(a==null){a=[e,h,e,h,0]}else{if(e<a[0]){a[0]=e}if(h<a[1]){a[1]=h}if(e>a[2]){a[2]=e}if(h>a[3]){a[3]=h}}if(c==null){addFeature(nodes[d]);a[4]=1}else{updateFeature(nodes[d],c);c.setStyle(markerStyle(nodes[d],g[2]))}}else{if(c){xxmap.markersSource.removeFeature(c)}}}catch(b){console.error("updateMapMarkers() exception",b,JSON.stringify(nodes[d]))}}return a}var map_cm_popup=new ol.Overlay({element:Q("xmap-info-window"),positioning:"bottom-center",stopEvent:false});var map_cm_editMarker={text:"Modify node location",callback:function(a){modifyMarkerloc(a.data)}};var map_cm_clearMarker={text:"Remove node location",callback:function(a){meshserver.send({action:"changedevice",nodeid:a.data.a,userloc:[]})}};var map_cm_saveMarker={text:"Save node location",callback:function(a){saveMarkerloc(a.data)}};var map_cm_nodemenu_items=[{text:"General information",callback:function(a){if(a.data!=null){gotoDevice(a.data,10)}}},{text:"Desktop",callback:function(a){if(a.data!=null){gotoDevice(a.data,11)}}},{text:"Terminal",callback:function(a){if(a.data!=null){gotoDevice(a.data,12)}}},{text:"Intel&reg; AMT",callback:function(a){if(a.data!=null){gotoDevice(a.data,14)}}},"-",{text:"Zoom-in to extent",callback:function(b){var a=b.data.getGeometry().getCoordinates();zoomToLocation(a,19)}},{text:"Zoom-out to extent",callback:function(b){var a=b.data.getGeometry().getCoordinates();zoomToLocation(a,2)}}];var contextmenu_items=[{text:"Refresh",callback:function(){refreshMap(true,true)}},{text:"Zoom to fit extent",callback:function(){zoomToFitExtent()}},{text:"Center map here",callback:function(a){xxmap.mapView.animate({center:a.coordinate})}},{text:"Place node here",callback:function(a){placeNode(a.coordinate)}}];function stringToIntHash(c){var a=0,b;for(b=0;b<c.length;b++){a=((a<<5)-a)+c.charCodeAt(b);a|=0}return a}function map_parseNodeLoc(b){var a=null,c=0;if(b.iploc){a=b.iploc;c=1}if(b.wifiloc){a=b.wifiloc;c=2}if(b.gpsloc){a=b.gpsloc;c=3}if(b.userloc){a=b.userloc;c=4}if((a==null)||(typeof a!="string")){return null}a=a.split(",");if(c==1){return[parseFloat(a[0])+(stringToIntHash(b._id.substring(0,20))/100000000000),parseFloat(a[1])+(stringToIntHash(b._id.substring(20))/100000000000),c]}else{return[parseFloat(a[0]),parseFloat(a[1]),c]}}function loadmap(){if(xxmap==null){return}if((features&32768)==0){QV("viewselectmapoption",false);QV("devViewButton4",false);xxmap=null;return}try{xxmap.markersSource=new ol.source.Vector();xxmap.markersLayer=new ol.layer.Vector({source:xxmap.markersSource});xxmap.mapLayer=new ol.layer.Tile({source:new ol.source.OSM()});xxmap.mapView=new ol.View({center:ol.proj.transform([0,0],"EPSG:4326","EPSG:3857"),zoom:2,minZoom:2,maxZoom:20,extent:ol.proj.transformExtent([-100000,-69.55,100000,69.55],"EPSG:4326","EPSG:3857")});xxmap.map=new ol.Map({target:"xdevicesmap",layers:[xxmap.mapLayer,xxmap.markersLayer],view:xxmap.mapView});xxmap.map.addOverlay(map_cm_popup);xxmap.map.on("click",function(c){var d=xxmap.map.forEachFeatureAtPixel(c.pixel,function(h,j){return h});if(d){var g=d.getId();if(g!=null){gotoDevice(g,10)}else{var e=getCorrespondingFeature(d);gotoDevice(e.getId(),10)}}});xxmap.map.on("pointermove",function(d){var g=xxmap.map.forEachFeatureAtPixel(d.pixel,function(j,k){return j});if(g){xxmap.map.getTargetElement().style.cursor="pointer";var c=g.getGeometry().getCoordinates();map_cm_popup.setPosition(c);var e=g.getId();if(e){QH("xmap-info-window",g.get("name"))}else{var h=getCorrespondingFeature(g);QH("xmap-info-window",h.get("name"))}}else{xxmap.map.getTargetElement().style.cursor="";QH("xmap-info-window","")}});var a=new ContextMenu({width:160,defaultItems:false,items:contextmenu_items});a.on("open",function(c){var e=xxmap.map.forEachFeatureAtPixel(c.pixel,function(h,j){return h});xxmap.contextmenu.clear();if(e){var d=e.getId();if(d){addContextMenuItems(e)}else{var g=getCorrespondingFeature(e);if(g){addContextMenuItems(g)}else{xxmap.contextmenu.extend(contextmenu_items)}}}else{xxmap.contextmenu.extend(contextmenu_items)}});if(xxmap.contextmenu==null){xxmap.contextmenu=a}xxmap.map.addControl(xxmap.contextmenu)}catch(b){console.log(b);QV("viewselectmapoption",false);QV("devViewButton4",false);xxmap=null}}function addFeature(g,c,e){var a=getModifiedFeature(g._id);if(a){xxmap.markersSource.addFeature(a)}else{if(!c&&!e){var d=map_parseNodeLoc(g);c=d[0];e=d[1]}if(e>180){e=180-e;meshserver.send({action:"changedevice",nodeid:g._id,userloc:[c,e]})}if((c<90)&&(c>-90)&&(e<180)&&(e>-180)){var b=new ol.Feature({geometry:new ol.geom.Point(ol.proj.transform([e,c],"EPSG:4326","EPSG:3857")),name:g.name,status:g.conn,lat:c,lon:e});b.setId(g._id);b.setStyle(markerStyle(g));xxmap.markersSource.addFeature(b)}}}function removeFeature(b){var a=xxmap.markersSource.getFeatureById(b._id);if(a){xxmap.markersSource.removeFeature(a)}}function updateFeature(g,a){if(g.conn!=a.get("status")){a.set("status",g.conn);a.setStyle(markerStyle(g))}var c=map_parseNodeLoc(g);if(c!=null){var b=c[0],d=c[1];if((b!=a.get("lat"))||(d!=a.get("lon"))){a.set("lat",b);a.set("lon",d);var e=ol.proj.transform([parseFloat(d),parseFloat(b)],"EPSG:4326","EPSG:3857");a.getGeometry().setCoordinates(e)}}if(g.name!=a.get("name")){a.set("name",g.name)}}function modifyMarkerloc(c){var b=c.getId();if(b){c.setStyle(markerStyle(getNodeFromId(c.a),4));if(!getActiveInteractions(c)){var a=new ol.interaction.Modify({features:new ol.Collection([c]),pixelTolerance:10});xxmap.activeInteractions.push({featureid:b,feature:c,interaction:a});xxmap.map.addInteraction(a)}}}function saveMarkerloc(d){var c=d.getId();if(c){var a=getActiveInteractions(d);if(a){xxmap.map.removeInteraction(a);removeInteraction(c);var b=d.getGeometry().getCoordinates();var e=ol.proj.transform(b,"EPSG:3857","EPSG:4326");if(e[0]>180){e[0]=180-e[0]}var g=[e[1],e[0]];meshserver.send({action:"changedevice",nodeid:c,userloc:g})}}}function markerStyle(b,d){if(d==null){d=0;if(b.iploc){d=1}if(b.wifiloc){d=2}if(b.gpsloc){d=3}if(b.userloc){d=4}}var e=["","-ip","-wifi","-gps","-user"];var a=connStateColor(b);var c=new ol.style.Style({image:new ol.style.Icon({color:a,anchor:[0.5,1],src:"images/mapmarker"+e[d]+".png"})});return[c]}function connStateColor(a){if(a.conn==1||a.conn==3||a.conn==5){return"#00ffdd"}return"#C70039"}function addContextMenuItems(a){if(getActiveInteractions(a)){map_cm_saveMarker.data=a;xxmap.contextmenu.push(map_cm_saveMarker)}else{map_cm_editMarker.data=a;xxmap.contextmenu.push(map_cm_editMarker);var b=getNodeFromId(a.a);if(b.userloc){map_cm_clearMarker.data=a;xxmap.contextmenu.push(map_cm_clearMarker)}}map_cm_nodemenu_items.forEach(function(c){if(c.text=="Zoom-in to extent"||c.text=="Zoom-out to extent"){c.data=a}else{if(c!="-"){c.data=a.getId()}}});xxmap.contextmenu.extend(map_cm_nodemenu_items)}function getActiveInteractions(b){var a=b.getId();for(var c=0;c<xxmap.activeInteractions.length;c++){if(xxmap.activeInteractions[c].featureid==a){return xxmap.activeInteractions[c].interaction}}return false}function getModifiedFeature(a){if(a){for(var b=0;b<xxmap.activeInteractions.length;b++){if(xxmap.activeInteractions[b].featureid==a){return xxmap.activeInteractions[b].feature}}}return null}function removeInteraction(a){var c=-1;for(var b=0;b<xxmap.activeInteractions.length;b++){if(xxmap.activeInteractions[b].featureid===a){c=b;break}}if(c>=0){xxmap.activeInteractions.splice(c,1)}}function getCorrespondingFeature(e){var d=e.getGeometry().getCoordinates();for(var b=0;b<xxmap.activeInteractions.length;b++){var c=xxmap.activeInteractions[b].feature;var a=c.getGeometry().getCoordinates();if(a[0].toFixed(5)==d[0].toFixed(5)&&a[1].toFixed(5)==d[1].toFixed(5)){return c}}return null}function refreshMap(k,h){if(k){xxmap.map.setTarget(null);xxmap.map=null;xxmap.markersSource=null;xxmap.mapView=null;xxmap.mapLayer=null;xxmap.activeInteractions=[]}var a=updateMapMarkers();if((a!=null)&&(h||(a[4]==1))){var b=(a[0]+a[2])/2;var c=(a[1]+a[3])/2;var d=Math.max(Math.abs(a[0]-a[2]),Math.abs(a[1]-a[3]));var l=xxmap.map.getView();l.setCenter(ol.proj.transform([c,b],"EPSG:4326","EPSG:3857"));var e=360,g=-2;while(e>d){g++;e=e/2}l.setZoom(g)}}function placeNode(a){if(xxdialogMode){return}var c='<div style=margin-bottom:6px><label for=selectnode-search>Search</label>&nbsp&nbsp<input type=text placeholder="Device name" id="selectnode-search" onchange=onPlaceNodeInputChange() onkeyup=onPlaceNodeInputChange() autocomplete=off style=width:120px></div><div id=placenode style="height:254px;overflow-y:auto;width:100%;margin:12px 1px 4px 1px;"><div id=noNodesMapPlace style=text-align:center;width:100%;display:none>No devices found.</div>';for(var b in nodes){c+="<div class=noselect id="+nodes[b]._id+"-rowid onclick=selectNodeToPlace(event,'"+nodes[b]._id+"') style=background-color:lightgray;margin-bottom:4px;border-radius:2px><input name=PlaceMapDeviceCheckbox id="+nodes[b]._id+"-checkid type=checkbox style=width:16px;display:inline />";c+="<div class=j"+nodes[b].icon+" style=width:16px;height:16px;margin-top:2px;margin-right:4px;display:inline-block></div><div style=width:16px;display:inline>"+nodes[b].name+"</div></div>"}setDialogMode(2,"Select a node to place",3,placeNodeEx,c+"</div>",a);onPlaceNodeInputChange()}function placeNodeEx(b,c){var d=document.getElementsByName("PlaceMapDeviceCheckbox");for(var g in d){if(d[g].checked){var h=getNodeFromId(d[g].id.substring(0,d[g].id.length-8));if(h){var e=xxmap.markersSource.getFeatureById(g);var j=ol.proj.transform(c,"EPSG:3857","EPSG:4326");var k=[j[1],j[0]];if(e){e.getGeometry().setCoordinates(c);var a=getActiveInteractions(e);if(a){saveMarkerloc(e)}else{meshserver.send({action:"changedevice",nodeid:h._id,userloc:k})}}else{meshserver.send({action:"changedevice",nodeid:h._id,userloc:k})}}}}}function onPlaceNodeInputChange(){updatePlaceNodeTable(Q("selectnode-search").value.trim().toLowerCase())}function updatePlaceNodeTable(d){var b=document.getElementsByName("PlaceMapDeviceCheckbox"),a=0;for(var c in nodes){var e=((nodes[c].namel.indexOf(d)>=0||d=="")||(nodes[c].rnamel!=null&&nodes[c].rnamel.indexOf(d)>=0));if(e){a++}QV(nodes[c]._id+"-rowid",e)}QV("noNodesMapPlace",a==0)}function selectNodeToPlace(b,g){if(b.target.name!="PlaceMapDeviceCheckbox"){var h=Q(g+"-checkid");h.checked=!h.checked}var c=document.getElementsByName("PlaceMapDeviceCheckbox"),a=0;for(var d in c){if(c[d].checked){a++}}QE("idx_dlgOkButton",a>0)}function addMeshOptions(a,b){}function meshOptionRmvMod(a,b){}function meshExists(){for(var a in meshes){if(meshes[a]){return true}}return false}function setMeshView(a){var c=Q("select-mesh");var b=c.selectedIndex;if(c[b].value==a){c[0].selected=true;onSelectMeshChange()}}function clearMeshOptions(){}function getSearchLocation(){try{var b=Q("mapSearchLocation").value.trim();if(b.length>0){var c=new XMLHttpRequest();c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){formatSearchData(c.responseText)}};c.open("GET","https://nominatim.openstreetmap.org/search?q="+b+"&format=json",true);c.send()}}catch(a){}}function formatSearchData(b){try{QH("xmapSearchResults","");var c=JSON.parse(b),a=0,k='<div class="xmapItem">';for(var h=0;h<c.length;h++){if(c[h].display_name&&c[h].boundingbox[0]&&c[h].boundingbox[1]&&c[h].boundingbox[2]&&c[h].boundingbox[3]){a++;var j=(h%2==0)?"xmapItemSel1":"xmapItemSel1";k+='<div class="'+j+'" onclick=mapGotoSelectedLocation(this)><div>'+c[h].display_name+"</div><div style=display:none>"+c[h].boundingbox[0]+"!#!"+c[h].boundingbox[1]+"!#!"+c[h].boundingbox[2]+"!#!"+c[h].boundingbox[3]+"</div></div>"}}k+="</div>";if(a==1){var g=[parseFloat(c[0].boundingbox[2]),parseFloat(c[0].boundingbox[0]),parseFloat(c[0].boundingbox[3]),parseFloat(c[0].boundingbox[1])];zoomToExtent(g)}else{if(a==0){k="<div style=width:200px>No location found.<div>"}QV("xmapSearchResultsDlg",true)}QH("xmapSearchResults",k)}catch(d){}}function mapGotoSelectedLocation(c){var d=c.children;var a=d[1].innerHTML.split("!#!");var b=[parseFloat(a[2]),parseFloat(a[0]),parseFloat(a[3]),parseFloat(a[1])];zoomToExtent(b);mapCloseSearchWindow()}function mapCloseSearchWindow(){QH("xmapSearchResults","");QV("xmapSearchResultsDlg",false)}function zoomToLocation(a,c){var b=xxmap.map.getView();b.setCenter(a);b.setZoom(c)}function zoomToFitExtent(){var b=xxmap.markersSource.getFeatures();if(b.length>0){var a=xxmap.markersSource.getExtent();xxmap.map.getView().fit(a,xxmap.map.getSize())}}function zoomToExtent(b){var a=ol.proj.transformExtent(b,ol.proj.get("EPSG:4326"),ol.proj.get("EPSG:3857"));xxmap.map.getView().fit(a,xxmap.map.getSize())}function refreshDevice(a){if(!currentNode||currentNode._id!=a){return}gotoDevice(a,xxcurrentView,true)}function getNodeRights(c){var b=getNodeFromId(c),a=meshes[b.meshid];return a.links[userinfo._id].rights}var currentNode;var powerTimelineNode=null;var powerTimelineReq=null;var powerTimelineUpdate=null;var powerTimeline=null;function getCurrentNode(){return currentNode}function gotoDevice(r,t,w,j){if((userinfo.emailVerified!==true)&&(serverinfo.emailcheck==true)&&(userinfo.siteadmin!=4294967295)){setDialogMode(2,"Account Security",1,null,'Unable to access a device until a email address is verified. This is required for password recovery. Go to the "My Account" tab to change and verify an email address.');return}if((features&262144)&&!((userinfo.otpsecret==1)||(userinfo.otphkeys>0)||(userinfo.otpkeys>0))){setDialogMode(2,"Account Security",1,null,'Unable to access a device until two-factor authentication is enabled. This is required for extra security. Go to the "My Account" tab and look at the "Account Security" section.');return}if(j&&(j.shiftKey==true)){window.open(window.location.origin+"?node="+r.split("/")[2]+"&viewmode=10&hide=16","meshcentral:"+r);return}var q=getNodeFromId(r);var n=meshes[q.meshid];var o=n.links[userinfo._id].rights;if(!currentNode||currentNode._id!=q._id||w==true){currentNode=q;var p=EscapeHtml(q.name);if(p.length==0){p="<i>None</i>"}if(((o&4)!=0)&&((!n.flags)||((n.flags&2)==0))){p='<span tabindex=0 title="Click here to edit the server-side device name" onclick=showEditNodeValueDialog(0) onkeyup="if (event.key == \'Enter\') showEditNodeValueDialog(0)" style=cursor:pointer>'+p+' <img class=hoverButton src="images/link5.png" /></span>'}QH("p10deviceName",p);QH("p11deviceName",p);QH("p12deviceName",p);QH("p13deviceName",p);QH("p14deviceName",p);QH("p15deviceName","Console - "+p);QH("p16deviceName",p);var B="<table style=width:100%>";B+=addDeviceAttribute('<span title="The name of the device group this computer belong to.">Group</span>','<a href=# title="The name of the device group this computer belong to" onclick=gotoMesh("'+q.meshid+'") style=cursor:pointer>'+EscapeHtml(meshes[q.meshid].name)+"</a>");if((q.rname!=null)&&(q.name!=q.rname)){B+=addDeviceAttribute('<span title="The name of this computer as set in the operating system">Name</span>','<span title="The name of this computer as set in the operating system">'+EscapeHtml(q.rname)+"</span>")}if((features&1)==0){if((o&4)!=0){if(q.host){B+=addDeviceAttribute("Hostname","<span onclick=showEditNodeValueDialog(1) style=cursor:pointer>"+EscapeHtml(q.host)+"</span>")}else{B+=addDeviceAttribute("Hostname","<span onclick=showEditNodeValueDialog(1) style=cursor:pointer><i>None</i></span>")}}else{B+=addDeviceAttribute("Hostname",EscapeHtml(q.host))}}var h=q.desc?EscapeHtml(q.desc):"<i>None</i>";if((o&4)!=0){B+=addDeviceAttribute("Description","<span onclick=showEditNodeValueDialog(2) style=cursor:pointer>"+h+' <img class=hoverButton src="images/link5.png" /></span>')}else{B+=addDeviceAttribute("Description",h)}var a=["Unknown","Windows 32bit console","Windows 64bit console","Windows 32bit service","Windows 64bit service","Linux 32bit","Linux 64bit","MIPS","XENx86","Android ARM","Linux ARM","MacOS 32bit","Android x86","PogoPlug ARM","Android APK","Linux Poky x86-32bit","MacOS 64bit","ChromeOS","Linux Poky x86-64bit","Linux NoKVM x86-32bit","Linux NoKVM x86-64bit","Windows MinCore console","Windows MinCore service","NodeJS","ARM-Linaro","ARMv6l / ARMv7l","ARMv8 64bit","ARMv6l / ARMv7l / NoKVM","Unknown","Unknown","FreeBSD x86-64"];if((q.agent!=null)&&(q.agent.id!=null)&&(q.agent.ver!=null)){var y="";if(q.agent.id<=a.length){y=a[q.agent.id]}else{y=a[0]}if(q.agent.ver!=0){y+=" v"+q.agent.ver}B+=addDeviceAttribute("Mesh Agent",y)}if(q.intelamt!=null){var y="";var v={0:"Not Activated (Pre)",1:"Not Activated (In)",2:"Activated"};if(q.intelamt.ver!=null&&q.intelamt.state==null){y+="<i>Unknown State</i>, v"+q.intelamt.ver}else{if((q.intelamt.ver==null)&&(q.intelamt.state==2)){y+="<i>Activated</i>"}else{if((q.intelamt.ver==null)||(q.intelamt.state==null)){y+="<i>Unknown Version & State</i>"}else{y+=v[q.intelamt.state];if((q.intelamt.state==2)&&q.intelamt.flags){if(q.intelamt.flags&2){y+=' <span title="Intel AMT is activated in Client Control Mode">CCM</span>'}else{if(q.intelamt.flags&4){y+=' <span title="Intel AMT is activated in Admin Control Mode">ACM</span>'}}}y+=(", v"+q.intelamt.ver)}}}if(q.intelamt.tls==1){y+=', <span title="Intel AMT is setup with TLS network security">TLS</span>'}if(q.intelamt.state==2){if(q.intelamt.user==null||q.intelamt.user==""){if((o&4)!=0){y+=', <i style=color:#FF0000;cursor:pointer title="Edit Intel&reg; AMT credentials" onclick=editDeviceAmtSettings("'+q._id+'")>No Credentials</i>'}else{y+=", <i style=color:#FF0000>No Credentials</i>"}}y+=" ";if((o&4)!=0){y+='<img src=images/link4.png height=10 width=10 title="Edit Intel&reg; AMT credentials" style=cursor:pointer onclick=editDeviceAmtSettings("'+q._id+'")>'}}B+=addDeviceAttribute("Intel&reg; AMT",y)}if(n.mtype==2){if((q.agent!=null)&&(q.agent.tag!=null)){var z=EscapeHtml(q.agent.tag);if(z.startsWith("mailto:")){z='<a href="'+z+'">'+z.substring(7)+"</a>"}B+=addDeviceAttribute("Agent Tag",z)}}else{if((q.intelamt!=null)&&(q.intelamt.tag!=null)){var z=EscapeHtml(q.intelamt.tag);if(z.startsWith("mailto:")){z='<a href="'+z+'">'+z.substring(7)+"</a>"}B+=addDeviceAttribute("Intel&reg; AMT Tag",z)}}if(q.osdesc){B+=addDeviceAttribute("Operating System",q.osdesc)}if(q.users&&q.conn&&(q.users.length>0)&&(q.conn&1)){B+=addDeviceAttribute("Active User"+((q.users.length>1)?"s":""),q.users.join(", "))}var d=q.conn;if(d&&d>1){var g=[];if((q.conn&1)!=0){g.push('<span title="Mesh agent is connected and ready for use.">Mesh Agent</span>')}if((q.conn&2)!=0){g.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">Intel&reg; AMT CIRA</span>')}else{if((q.conn&4)!=0){g.push('<span title="Intel&reg; AMT is routable and ready for use.">Intel&reg; AMT</span>')}}if((q.conn&8)!=0){g.push('<span title="Mesh agent is reachable using another agent as relay.">Mesh Relay</span>')}B+=addDeviceAttribute("Connectivity",g.join(", "))}var l="<i>None</i>";if(q.tags!=null){l="";for(var m in q.tags){l+='<span class="tagSpan">'+q.tags[m]+"</span>"}}if((o&4)!=0){B+=addDeviceAttribute("Tags","<span onclick=showEditNodeValueDialog(3) style=cursor:pointer>"+l+' <img class=hoverButton src="images/link5.png" /></span>')}else{B+=addDeviceAttribute("Tags",l)}B+="</table><br />";if((o&76)!=0){B+='<input type=button value=Actions title="Perform power actions on the device" onclick=deviceActionFunction() />'}B+='<input type=button value=Notes title="View notes about this device" onclick=showNotes('+((o&128)==0)+',"'+encodeURIComponent(q._id)+'") />';QH("p10html",B);masterUpdate(256);B='<div class="p10html3right">';if((o&4)!=0){B+='&nbsp;<a href=# onclick=p10showChangeGroupDialog(["'+q._id+'"]) title="Move this device to a different device group">Change Group</a>';B+='&nbsp;<a href=# onclick=p10showDeleteNodeDialog("'+q._id+'") title="Remove this device">Delete Device</a>'}B+='</div><div class="p10html3left">';if(n.mtype==2){B+='<a href=# onclick=p10showNodeNetInfoDialog("'+q._id+'") title="Show device network interface information">Interfaces</a>&nbsp;'}if(xxmap!=null){B+='<a href=# onclick=p10showNodeLocationDialog("'+q._id+'") title="Show device locations information">Location</a>&nbsp;'}if(((o&8)!=0)&&(n.mtype==2)){B+='<a href=# onclick=p10showMeshCmdDialog(1,"'+q._id+'") title="Traffic router used to connect to a device thru this server.">Router</a>&nbsp;'}if(((d&1)!=0)&&(clickOnce==true)&&(n.mtype==2)&&((o&8)!=0)){if((q.agent.id>0)&&(q.agent.id<5)){B+='<a href=# onclick=p10clickOnce("'+q._id+'","RDP2",3389) title="Requires Microsoft ClickOnce support in your browser.">RDP</a>&nbsp;'}if(q.agent.id>4){B+='<a href=# onclick=p10clickOnce("'+q._id+'","PSSH",22) title="Requires Microsoft ClickOnce support in your browser.">Putty</a>&nbsp;';B+='<a href=# onclick=p10clickOnce("'+q._id+'","WSCP",22) title="Requires Microsoft ClickOnce support in your browser.">WinSCP</a>&nbsp;'}}B+="</div><br>";QH("p10html3",B);var u=PowerStateStr(q.state);if((d&1)!=0){if(u.length>0){u+="<br/>"}u+='<span style=font-size:12px title="Agent connected">Agent connected</span>'}if((d&2)!=0){if(u.length>0){u+="<br/>"}u+='<span style=font-size:12px title="Intel&reg; AMT connected">Intel&reg; AMT connected</span>'}else{if((d&4)!=0){if(u.length>0){u+="<br/>"}u+='<span style=font-size:12px title="Intel&reg; AMT detected">Intel&reg; AMT detected</span>'}}if((u=="")&&q.lastconnect){u="<span style=font-size:12px>Last seen:<br />"+printDateTime(new Date(q.lastconnect))+"</span>"}QH("MainComputerState",u);Q("MainComputerImage").setAttribute("src","images/icons256-"+q.icon+"-1.png");Q("MainComputerImage").className=((!q.conn)||(q.conn==0)?"gray":"");var A=((o==4294967295)||((o&512)==0));var k=((o==4294967295)||((o&1024)==0));var b=((o==4294967295)||((o&2048)==0));if(A){setupTerminal()}if(k){setupFiles()}var e=((o&16)!=0);if(e){setupConsole()}else{if(t==15){t=10}}QV("MainDevDesktop",((n.mtype==1)||(q.agent==null)||(q.agent.caps==null)||((q.agent.caps&1)!=0)||(q.intelamt&&(q.intelamt.state==2)))&&((o&8)||(o&256)));QV("MainDevTerminal",((n.mtype==1)||(q.agent==null)||(q.agent.caps==null)||((q.agent.caps&2)!=0)||(q.intelamt&&(q.intelamt.state==2)))&&(o&8)&&A);QV("MainDevFiles",((n.mtype==2)&&((q.agent==null)||(q.agent.caps==null)||((q.agent.caps&4)!=0)))&&(o&8)&&k);QV("MainDevAmt",(q.intelamt!=null)&&((q.intelamt.state==2)||(q.conn&2))&&(o&8)&&b);QV("MainDevConsole",(e&&(n.mtype==2)&&((q.agent==null)||(q.agent.caps==null)||((q.agent.caps&8)!=0)))&&(o&8));QV("p15uploadCore",(q.agent!=null)&&(q.agent.caps!=null)&&((q.agent.caps&16)!=0));QH("p15coreName",((q.agent!=null)&&(q.agent.core!=null))?q.agent.core:"");var c=Q("p14iframe").contentWindow.getCurrentMeshNode();if((c!=null)&&(c._id!=currentNode._id)){Q("p14iframe").contentWindow.disconnect()}var s=((q.conn&6)!=0)?true:false;Q("p14iframe").contentWindow.setConnectionState(s);Q("p14iframe").contentWindow.setFrameHeight("650px");Q("p14iframe").contentWindow.setAuthCallback(updateAmtCredentials);QV("deskActionsBtn",(o&72)!=0);QV("termActionsBtn",(o&72)!=0);QV("filesActionsBtn",(o&72)!=0);if((powerTimelineNode!=currentNode._id)&&(powerTimelineReq!=currentNode._id)){QH("p10html2","");powerTimelineReq=currentNode._id;meshserver.send({action:"powertimeline",nodeid:currentNode._id});meshserver.send({action:"lastconnect",nodeid:currentNode._id})}QV("DeskTools",false);showDeskToolsProcesses();refreshDeviceEvents();if((currentNode)&&(xxcurrentView>=10)&&(xxcurrentView<20)){document.title=decodeURIComponent("{{{extitle}}}")+" - "+currentNode.name}else{document.title=decodeURIComponent("{{{extitle}}}")}p11clearConsoleMsg();p12clearConsoleMsg();p13clearConsoleMsg()}setupDesktop();if(!t){t=10}go(t)}function showNotes(b,a){if(xxdialogMode){return}setDialogMode(2,"Notes",2,showNotesEx,"<textarea id=d2devNotes ro="+b+" noteid="+a+" readonly style=background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:scroll></textarea><span style=font-size:10px>Device group notes can be viewed and changed by other device group administrators.<span>",a);meshserver.send({action:"getNotes",id:decodeURIComponent(a)})}function showNotesEx(a,b){meshserver.send({action:"setNotes",id:decodeURIComponent(b),notes:encodeURIComponent(Q("d2devNotes").value)})}function deviceChat(){if(xxdialogMode){return}var a="/messenger?id=meshmessenger/"+encodeURIComponent(currentNode._id)+"/"+encodeURIComponent(userinfo._id)+"&title="+currentNode.name;if((authCookie!=null)&&(authCookie!="")){a+="&auth="+authCookie}window.open(a,"meshmessenger:"+currentNode._id);meshserver.send({action:"meshmessenger",nodeid:decodeURIComponent(currentNode._id)})}function deviceUrlFunction(){if(xxdialogMode){return}setDialogMode(2,"Open Page on Device",3,deviceUrlFunctionEx,'<input id=d2devurl placeholder="http://server.com" style=width:100%;overflow-y:scroll></input>')}function deviceUrlFunctionEx(){meshserver.send({action:"msg",type:"openUrl",nodeid:currentNode._id,url:Q("d2devurl").value})}function deviceToastFunction(){if(xxdialogMode){return}setDialogMode(2,"Device Notification",3,deviceToastFunctionEx,"<textarea id=d2devToast style=width:100%;height:80px;resize:none;overflow-y:scroll></textarea>")}function deviceToastFunctionEx(){meshserver.send({action:"toast",nodeids:[currentNode._id],title:"MeshCentral",msg:Q("d2devToast").value})}function deviceActionFunction(){if(xxdialogMode){return}var a=meshes[currentNode.meshid].links[userinfo._id].rights;var b="Select an operation to perform on this device.<br /><br />";var c="<select id=d2deviceop style=float:right;width:250px>";if((a&64)!=0){c+="<option value=100>Wake-up</option>"}if((a&8)!=0){c+="<option value=4>Sleep</option><option value=3>Reset</option><option value=2>Power off</option>"}c+="</select>";b+=addHtmlValue("Operation",c);setDialogMode(2,"Device Action",3,deviceActionFunctionEx,b)}function deviceActionFunctionEx(){var a=Q("d2deviceop").value;if(a==100){meshserver.send({action:"wakedevices",nodeids:[currentNode._id]})}else{meshserver.send({action:"poweraction",nodeids:[currentNode._id],actiontype:a})}}function updateAmtCredentials(a){var b=getNodeFromId(currentNode._id);if((a==true)||(b.intelamt.user==null)||(b.intelamt.user=="")){editDeviceAmtSettings(currentNode._id,updateAmtCredentialsEx)}else{Q("p14iframe").contentWindow.connectButtonfunctionEx()}}function updateAmtCredentialsEx(a,b){Q("p14iframe").contentWindow.connectButtonfunctionEx()}function updateDeviceTimeline(){if((meshserver.State!=2)||(powerTimelineNode==null)||(powerTimelineUpdate==null)||(currentNode==null)){return}if((powerTimelineNode==powerTimelineReq)&&(currentNode._id==powerTimelineNode)&&(powerTimelineUpdate<Date.now())){powerTimelineUpdate=null;meshserver.send({action:"powertimeline",nodeid:currentNode._id});meshserver.send({action:"lastconnect",nodeid:currentNode._id})}}function drawDeviceTimeline(){if((currentNode==null)||(xxcurrentView<10)||(xxcurrentView>19)){return}var s=null,o=Date.now();if(currentNode._id==powerTimelineNode){s=powerTimeline}var e=new Date();e.setHours(0,0,0,0);e=new Date(e.getTime()-(1000*60*60*24*6));var u=e.getTime();var t=[];if(s!=null&&s.length>1){t.push([0,s[1],s[0]]);var c=s[1];for(var m=2;m<s.length;m+=2){var p=s[m],k=o;if(s.length>(m+1)){k=s[m+1]}t.push([c,c+k,p]);c=c+k}}var A="",b=1,h=new Date();var w=Q("masthead").offsetWidth-(160+9+9+14);h.setHours(0,0,0,0);for(var m=0;m<7;m++){var g="",q=h.getTime(),l=q+(1000*60*60*24);for(var n in t){var a=t[n];if(isTimeBlockInside(q,l,a[0],a[1])==true){var y=Math.max(q,a[0]);var r=Math.min(Math.min(l,a[1]),o);var z=Math.round(((r-y)*w)/86400000);if(z>0){var v=powerStateStrings2[a[2]]+" from "+printTime(new Date(y))+" to "+printTime(new Date(r))+".";g+='<div class="pwState '+powerColor(a[2])+'" title="'+v+'" style="width:'+z+'px;"></div>'}}}A+="<tr class="+(((b%2)==0)?"altBack":"")+"><td><div>&nbsp;"+printDate(h)+"<div></div></div></td><td><div>"+g+"</div></td></tr>";++b;h=new Date(h.getTime()-(1000*60*60*24))}QH("p10html2",'<table cellpadding=2 cellspacing=0><thead><tr style=><th scope=col style=text-align:center;width:150px>Day</th><th scope=col style=text-align:center><a download href="devicepowerevents.ashx?id='+currentNode._id+'" onclick="setDialogMode(0)"><img title="Download power events" src="images/link4.png" /></a>7 Day Power State</th></tr></thead><tbody>'+A+"</tbody></table>")}function powerColor(a){if(a<powerColorTable.length){return powerColorTable[a]}return"pwsYellow"}function isTimeBlockInside(d,c,b,a){if((b<d)&&(a>c)){return true}if((b>d)&&(b<c)){return true}if((a>d)&&(a<c)){return true}return false}function addDeviceAttribute(a,b){return"<tr><td class=style7>"+a+"</td><td class=style9>"+b+"</td></tr>"}function editDeviceAmtSettings(g,c,a){if(xxdialogMode){return}var h="",e=getNodeFromId(g),b=3,d=getNodeRights(g);if((d&4)==0){return}h+=addHtmlValue("Username",'<input id=dp10username style=width:230px maxlength=32 autocomplete=nope placeholder="admin" onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />');h+=addHtmlValue("Password","<input id=dp10password type=password style=width:230px autocomplete=nope maxlength=32 onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />");h+=addHtmlValue("Security","<select id=dp10tls style=width:236px><option value=0>No TLS security</option><option value=1>TLS security required</option></select>");if((e.intelamt.user!=null)&&(e.intelamt.user!="")){b=7}setDialogMode(2,"Edit Intel&reg; AMT credentials",b,editDeviceAmtSettingsEx,h,{node:e,func:c,arg:a});if((e.intelamt.user!=null)&&(e.intelamt.user!="")){Q("dp10username").value=e.intelamt.user}else{Q("dp10username").value="admin"}Q("dp10tls").value=e.intelamt.tls;validateDeviceAmtSettings()}function validateDeviceAmtSettings(){QE("idx_dlgOkButton",passwordcheck(Q("dp10password").value))}function editDeviceAmtSettingsEx(c,d){if(c==2){meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:"",pass:""}})}else{var b=Q("dp10username").value;if(b==""){b="admin"}var a=Q("dp10password").value;if(a==""){b=""}meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:b,pass:a,tls:Q("dp10tls").value}});d.node.intelamt.user=b;d.node.intelamt.tls=Q("dp10tls").value;if(d.func){setTimeout(function(){d.func(null,d.arg)},300)}}}function p10showChangeGroupDialog(e){if(xxdialogMode){return false}var g=null;if(e.length==1){try{g=meshes[getNodeFromId(e[0])]._id}catch(b){}}var j="<select id=p10newGroup style=width:236px>",a=0;for(var c in meshes){var d=meshes[c].links[userinfo._id].rights;if((meshes[c]._id!=g)&&(d&4)){a++;j+="<option value='"+meshes[c]._id+"'>"+meshes[c].name+"</option>"}}j+="</select>";if(a>0){var h=(e.length==1)?"Select a new group for this device<br /><br />":"Select a new group for selected devices<br /><br />";h+=addHtmlValue("New Device Group",j);setDialogMode(2,"Change Group",3,p10showChangeGroupDialogEx,h,e)}else{setDialogMode(2,"Change Group",1,null,"No other device group of same type exists.")}return false}function p10showChangeGroupDialogEx(a,c){meshserver.send({action:"changeDeviceMesh",nodeids:c,meshid:Q("p10newGroup").value})}function p10showDeleteNodeDialog(a){if(xxdialogMode){return false}var b='Are you sure you want to delete node "'+EscapeHtml(currentNode.name)+'"?<br /><br />';b+="<label><input id=p10check type=checkbox onchange=p10validateDeleteNodeDialog() />Confirm</label>";setDialogMode(2,"Delete Node",3,p10showDeleteNodeDialogEx,b,a);p10validateDeleteNodeDialog();return false}function p10validateDeleteNodeDialog(){QE("idx_dlgOkButton",Q("p10check").checked)}function p10showDeleteNodeDialogEx(a,b){meshserver.send({action:"removedevices",nodeids:[b]})}function p10clickOnce(a,c,b){meshserver.send({action:"getcookie",nodeid:a,tcpport:b,tag:"clickonce",protocol:c});return false}var d2map=null;function p10showNodeLocationDialog(){if((xxdialogMode!=null)&&(xxdialogTag=="@xxmap")){setDialogMode(0)}else{if(xxdialogMode){return false}}var m=[],n=["iploc","wifiloc","gpsloc","userloc"],a=null;for(var k in n){if(currentNode[n[k]]!=null){var j=currentNode[n[k]].split(","),h=parseFloat(j[0]),l=parseFloat(j[1]);if((h<90)&&(h>-90)&&(l<180)&&(l>-180)){var e=new ol.Feature({geometry:new ol.geom.Point(ol.proj.fromLonLat([l,h]))});e.setStyle(markerStyle(currentNode,parseInt(k)+1));m.push(e);if(a==null){a=[h,l,h,l,0]}else{if(h<a[0]){a[0]=h}if(l<a[1]){a[1]=l}if(h>a[2]){a[2]=h}if(l>a[3]){a[3]=l}}}}}var p=new ol.source.Vector({features:m});var o=new ol.layer.Vector({source:p});var q="<div id=d2map style=width:100%;height:300px></div>";setDialogMode(2,"Device Location",1,null,q,"@xxmap");var c=0,b=0,r=8;if(a!=null){var b=(a[0]+a[2])/2;var c=(a[1]+a[3])/2;var d=Math.max(Math.abs(a[0]-a[2]),Math.abs(a[1]-a[3]));var g=360,r=-2;while(g>d){r++;g=g/2}}if(m.length==1){r=8}d2map=new ol.Map({target:"d2map",interactions:ol.interaction.defaults({dragPan:false,mouseWheelZoom:false}),layers:[new ol.layer.Tile({source:new ol.source.OSM()}),o],view:new ol.View({center:ol.proj.fromLonLat([c,b]),zoom:r})});return false}function p10showNodeNetInfoDialog(){if(xxdialogMode){return false}setDialogMode(2,"Network Interfaces",1,null,"<div id=d2netinfo>Loading...</div>","if"+currentNode._id);meshserver.send({action:"getnetworkinfo",nodeid:currentNode._id});return false}function p10showMeshRouterDialog(){if(xxdialogMode){return}var a="<div>MeshCentral Router is a Windows tool for TCP port mapping. You can, for example, RDP into a remote device thru this server.</div><br />";a+=addHtmlValue("Win32 Executable",'<a style=cursor:pointer download href="meshagents?meshaction=winrouter" onclick="setDialogMode(0)">MeshCentralRouter.exe</a>');setDialogMode(2,"MeshCentral Router",1,null,a,"fileDownload")}function p10showMeshCmdDialog(a,b){if(xxdialogMode){return}var d="<select id=aginsSelect onclick=meshCmdOsClick() style=width:236px>";d+="<option value=3>Windows (32bit)</option>";d+="<option value=4>Windows (64bit)</option>";d+="<option value=5>Linux x86 (32bit)</option>";d+="<option value=6>Linux x86 (64bit)</option>";d+="<option value=16>MacOS (64bit)</option>";d+="<option value=25>Linux ARM, Raspberry Pi (32bit)</option>";d+="</select>";var c="";if(a==0){c+="<div>MeshCmd is a command line tool that performs lots of different operations. The action file can optionally be downloaded and edited to provide server information and credentials.<br /><br />"}if(a==1){c+='<div>Download "meshcmd" with an action file to route traffic thru this server to this device. Make sure to edit meshaction.txt and add your account password or make any changes needed.<br /><br />'}c+=addHtmlValue("Operating System",d);c+=addHtmlValue("MeshCmd",'<a id=meshcmddownloadid href="meshagents?meshcmd=3" download></a>');if(a==0){c+=addHtmlValue("Action File",'<a href="meshagents?meshaction=generic" download>MeshAction (.txt)</a>')}if(a==1){c+=addHtmlValue("Action File",'<a href="meshagents?meshaction=route&nodeid='+b+'" download>MeshAction (.txt)</a>')}c+="</div>";setDialogMode(2,["Download MeshCmd","Network Router"][a],9,null,c,"fileDownload");meshCmdOsClick()}function meshCmdOsClick(){var a=Q("aginsSelect").value,b="",c="";if(a==3){b="MeshCmd (Win32 executable)"}if(a==4){b="MeshCmd (Win64 executable)"}if(a==5){b="MeshCmd (Linux x86, 32bit)"}if(a==6){b="MeshCmd (Linux x86, 64bit)"}if(a==16){b="MeshCmd (MacOS, 64bit)"}if(a==25){b="MeshCmd (Linux ARM, 32bit)"}QH("meshcmddownloadid",b);Q("meshcmddownloadid").setAttribute("href","meshagents?meshcmd="+a)}function p10showiconselector(){if(xxdialogMode){return}var a=meshes[currentNode.meshid];var b=a.links[userinfo._id].rights;if((b&4)==0){return}var c="<br><div style=display:inline-block;width:40px></div>";c+="<div tabindex=0 style=display:inline-block class=i1 onclick=p10setIcon(1) onkeypress=\"if (event.key=='Enter') p10setIcon(1)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i2 onclick=p10setIcon(2) onkeypress=\"if (event.key=='Enter') p10setIcon(2)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i3 onclick=p10setIcon(3) onkeypress=\"if (event.key=='Enter') p10setIcon(3)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i4 onclick=p10setIcon(4) onkeypress=\"if (event.key=='Enter') p10setIcon(4)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i5 onclick=p10setIcon(5) onkeypress=\"if (event.key=='Enter') p10setIcon(5)\"></div>";c+="<div tabindex=0 style=display:inline-block class=i6 onclick=p10setIcon(6) onkeypress=\"if (event.key=='Enter') p10setIcon(6)\"></div><br><br>";setDialogMode(2,"Icon Selection",0,null,c);QV("id_dialogclose",true)}function p10setIcon(a){setDialogMode(0);meshserver.send({action:"changedevice",nodeid:currentNode._id,icon:a})}var showEditNodeValueDialog_modes=["Device Name","Hostname","Description","Tags"];var showEditNodeValueDialog_modes2=["name","host","desc","tags"];var showEditNodeValueDialog_modes3=["","","","Tag1, Tag2, Tag3"];function showEditNodeValueDialog(a){if(xxdialogMode){return}var c=addHtmlValue(showEditNodeValueDialog_modes[a],'<input id=dp10devicevalue maxlength=64 placeholder="'+showEditNodeValueDialog_modes3[a]+'" onchange=p10editdevicevalueValidate('+a+",event) onkeyup=p10editdevicevalueValidate("+a+",event) />");setDialogMode(2,"Edit Device",3,showEditNodeValueDialogEx,c,a);var b=currentNode[showEditNodeValueDialog_modes2[a]];if(b==null){b=""}if(Array.isArray(b)){b=b.join(", ")}Q("dp10devicevalue").value=b;p10editdevicevalueValidate();Q("dp10devicevalue").focus()}function showEditNodeValueDialogEx(a,b){var c={action:"changedevice",nodeid:currentNode._id};c[showEditNodeValueDialog_modes2[b]]=Q("dp10devicevalue").value;meshserver.send(c)}function p10editdevicevalueValidate(b,a){var c=((b>1)||(Q("dp10devicevalue").value.length>0));QE("idx_dlgOkButton",c);if((a!=null)&&(c==true)&&(a.keyCode==13)){dialogclose(1)}}var desktopNode;function setupDesktop(){if((desktopNode!=currentNode)&&(desktop!=null)){desktop.Stop();desktopNode=null;desktop=null}if((desktopNode!=currentNode)||(desktop==null)){var b=multiDesktop[currentNode._id];if(b!=null){QH("DeskParent","");var a=b.m.CanvasId;a.setAttribute("id","Desk");a.setAttribute("onmousedown","dmousedown(event)");a.setAttribute("onmouseup","dmouseup(event)");a.setAttribute("onmousemove","dmousemove(event)");a.removeAttribute("onclick");Q("DeskParent").appendChild(a);desktop=b;if(desktop.m.SendCompressionLevel){desktop.m.SendCompressionLevel(1,desktopsettings.quality,desktopsettings.scaling,desktopsettings.framerate)}desktop.onStateChanged=onDesktopStateChange;desktopNode=currentNode;onDesktopStateChange(desktop,desktop.State);delete multiDesktop[currentNode._id]}else{QH("DeskParent",'<canvas id=Desk oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>');desktopNode=currentNode}Q("Desk").addEventListener("DOMMouseScroll",function(c){return dmousewheel(c)});Q("Desk").addEventListener("mousewheel",function(c){return dmousewheel(c)})}desktopNode=currentNode;updateDesktopButtons();deskAdjust();if(!Q("Desk")["toBlob"]){QV("deskSaveBtn",false)}}function updateDesktopButtons(){var d=meshes[currentNode.meshid];var a=0;if(desktop!=null){a=desktop.State}var e=d.links[userinfo._id].rights;QV("disconnectbutton1span",(a!=0));QV("connectbutton1span",(a==0)&&((e&8)||(e&256))&&(d.mtype==2)&&(currentNode.agent.caps&1));QV("connectbutton1hspan",(a==0)&&(e&8)&&((currentNode.intelamt!=null)&&(d.mtype==1||currentNode.intelamt.state==2)&&((currentNode.intelamt.ver!=null)||(d.mtype==1))));QV("d7amtkvm",(currentNode.intelamt!=null&&((currentNode.intelamt.ver!=null)||(d.mtype==1)))&&((a==0)||(desktop.contype==2)));QV("d7meshkvm",(webRtcDesktop)||((d.mtype==2)&&(currentNode.agent.caps&1)&&((a==false)||(desktop.contype==1))));var c=(e==4294967295)||(((e&8)!=0)&&((e&256)==0)&&((e&4096)==0));var g=((currentNode.conn&1)!=0);QE("connectbutton1",g);var b=((currentNode.conn&6)!=0);QE("connectbutton1h",b);QE("deskSaveBtn",a==3);QV("deskFocusBtn",(desktop!=null)&&(desktop.contype==2)&&(a!=0)&&(desktopsettings.showfocus));QV("DeskClip",(currentNode.agent)&&(currentNode.agent.id!=11)&&(currentNode.agent.id!=16)&&((desktop==null)||(desktop.contype!=2)));QE("DeskClip",a==3);QV("DeskWD",(currentNode.agent)&&(currentNode.agent.id<5)&&c);QE("DeskWD",a==3);QV("deskkeys",(currentNode.agent)&&(currentNode.agent.id<5)&&c);QE("deskkeys",a==3);QV("DeskToolsButton",(c)&&(d.mtype==2)&&g);QV("DeskChatButton",(browserfullscreen==false)&&(c)&&(d.mtype==2)&&g);QV("DeskNotifyButton",(browserfullscreen==false)&&(currentNode.agent)&&(currentNode.agent.id<5)&&(c)&&(d.mtype==2)&&g);QV("DeskOpenWebButton",(browserfullscreen==false)&&(c)&&(d.mtype==2)&&g);QV("DeskControlSpan",c);QV("deskActionsBtn",(browserfullscreen==false));QV("deskActionsSettings",(browserfullscreen==false));if(e&8){Q("DeskControl").checked=(getstore("DeskControl",1)==1)}else{Q("DeskControl").checked=false}if(g==false){QV("DeskTools",false)}}var autoConnectDesktopTimer=null;function autoConnectDesktop(a){if(autoConnectDesktopTimer==null){autoConnectDesktopTimer=setInterval(connectDesktop,100)}else{clearInterval(autoConnectDesktopTimer);autoConnectDesktopTimer=null}}function connectDesktop(b,a){p11clearConsoleMsg();if(desktop==null){desktopNode=currentNode;if(a==2){if((desktopNode.intelamt.user==null)||(desktopNode.intelamt.user=="")){editDeviceAmtSettings(desktopNode._id,connectDesktop,2);return}desktop=CreateAmtRedirect(CreateAmtRemoteDesktop("Desk"),authCookie);desktop.debugmode=debugmode;desktop.onStateChanged=onDesktopStateChange;desktop.m.bpp=(desktopsettings.encoding==1||desktopsettings.encoding==3)?1:2;desktop.m.useZRLE=(desktopsettings.encoding<3);desktop.m.localKeyMap=desktopsettings.localkeymap;desktop.m.showmouse=desktopsettings.showmouse;desktop.m.onScreenSizeChange=deskAdjust;desktop.m.onKvmData=function(h){if(h.length==0){if(!desktop.m._sentPresence){desktop.m._sentPresence=true;desktop.m.sendKvmData(JSON.stringify({action:"present",ver:1}))}return}var d=null;try{d=JSON.parse(h)}catch(g){}if((d!=null)&&(d.action!=null)){if(d.action=="restart"){webRtcDesktopReset();desktop.m.sendKvmData(JSON.stringify({action:"present",ver:1}))}else{if((d.action=="present")&&(webRtcDesktop==null)){webRtcDesktop={platform:d.platform};var c=null;if(typeof RTCPeerConnection!=="undefined"){webRtcDesktop.webrtc=new RTCPeerConnection(c)}else{if(typeof webkitRTCPeerConnection!=="undefined"){webRtcDesktop.webrtc=new webkitRTCPeerConnection(c)}}webRtcDesktop.webchannel=webRtcDesktop.webrtc.createDataChannel("DataChannel",{});webRtcDesktop.webchannel.onopen=function(){console.log("WebRTC Data Channel Open");Q("deskstatus").textContent=StatusStrs[desktop.State]+", Soft-KVM";desktop.m.hold(true);webRtcDesktop.webRtcActive=true;webRtcDesktop.softdesktop=CreateKvmDataChannel(webRtcDesktop.webchannel,CreateAgentRemoteDesktop("Desk",Q("id_mainarea")),desktop.m);webRtcDesktop.softdesktop.m.setRotation(desktop.m.rotation);webRtcDesktop.softdesktop.m.onScreenSizeChange=deskAdjust;if(desktopsettings.quality){webRtcDesktop.softdesktop.m.CompressionLevel=desktopsettings.quality}if(desktopsettings.scaling){webRtcDesktop.softdesktop.m.ScalingLevel=desktopsettings.scaling}webRtcDesktop.softdesktop.Start()};webRtcDesktop.webchannel.onclose=function(e){console.log("WebRTC Data Channel Closed");webRtcDesktopReset()};webRtcDesktop.webrtc.onicecandidate=function(j){if(j.candidate==null){desktop.m.sendKvmData(JSON.stringify({action:"offer",ver:1,sdp:webRtcDesktop.webrtcoffer.sdp}))}else{webRtcDesktop.webrtcoffer.sdp+=("a="+j.candidate.candidate+"\r\n")}};webRtcDesktop.webrtc.oniceconnectionstatechange=function(){if((webRtcDesktop!=null)&&(webRtcDesktop.webrtc!=null)&&((webRtcDesktop.webrtc.iceConnectionState=="disconnected")||(webRtcDesktop.webrtc.iceConnectionState=="failed"))){webRtcDesktopReset()}};webRtcDesktop.webrtc.createOffer(function(e){webRtcDesktop.webrtcoffer=e;webRtcDesktop.webrtc.setLocalDescription(e,function(){},webRtcDesktopReset)},webRtcDesktopReset,{mandatory:{OfferToReceiveAudio:false,OfferToReceiveVideo:false}})}else{if((d.action=="answer")&&(webRtcDesktop!=null)){webRtcDesktop.webrtc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:d.sdp}),function(){},webRtcDesktopReset)}}}}};desktop.Start(desktopNode._id,16994,"*","*",0);desktop.contype=2}else{desktop=CreateAgentRedirect(meshserver,CreateAgentRemoteDesktop("Desk"),serverPublicNamePort,authCookie,domainUrl);desktop.debugmode=debugmode;desktop.m.debugmode=debugmode;desktop.attemptWebRTC=attemptWebRTC;desktop.onStateChanged=onDesktopStateChange;desktop.onConsoleMessageChange=function(){p11clearConsoleMsg();if(desktop.consoleMessage){QH("p11DeskConsoleMsg",EscapeHtml(desktop.consoleMessage).split("\n").join("<br />"));QV("p11DeskConsoleMsg",true);p11DeskConsoleMsgTimer=setTimeout(p11clearConsoleMsg,8000)}};desktop.m.CompressionLevel=desktopsettings.quality;desktop.m.ScalingLevel=desktopsettings.scaling;desktop.m.FrameRateTimer=desktopsettings.framerate;desktop.m.onDisplayinfo=deskDisplayInfo;desktop.m.onScreenSizeChange=deskAdjust;desktop.Start(desktopNode._id);desktop.contype=1}}else{desktop.Stop();webRtcDesktopReset();desktopNode=desktop=null}}function p11clearConsoleMsg(){QV("p11DeskConsoleMsg",false);if(p11DeskConsoleMsgTimer){clearTimeout(p11DeskConsoleMsgTimer);p11DeskConsoleMsgTimer=null}}function p12clearConsoleMsg(){QV("p12TermConsoleMsg",false);if(p12TermConsoleMsgTimer){clearTimeout(p12TermConsoleMsgTimer);p12TermConsoleMsgTimer=null}}function p13clearConsoleMsg(){QV("p13FilesConsoleMsg",false);if(p13FilesConsoleMsgTimer){clearTimeout(p13FilesConsoleMsgTimer);p13FilesConsoleMsgTimer=null}}var webRtcDesktop=null;function webRtcDesktopReset(){if(webRtcDesktop==null){return}if(webRtcDesktop.softdesktop!=null){webRtcDesktop.softdesktop.Stop();webRtcDesktop.softdesktop=null}if(webRtcDesktop.webchannel!=null){try{webRtcDesktop.webchannel.close()}catch(a){}webRtcDesktop.webchannel=null}if(webRtcDesktop.webrtc!=null){try{webRtcDesktop.webrtc.close()}catch(a){}webRtcDesktop.webrtc=null}webRtcDesktop=null;if(desktop&&desktop.m){desktop.m.hold(false);Q("deskstatus").textContent=StatusStrs[desktop.State]}}function onDesktopStateChange(c,a){var d=a;if((d==3)&&(c.contype==2)){d++}var b=StatusStrs[d];if((desktop!=null)&&(desktop.webRtcActive==true)){b+=", WebRTC"}QH("deskstatus",b);switch(a){case 0:desktop.Stop();desktopNode=desktop=null;QV("DeskFocus",false);QV("termdisplays",false);deskFocusBtn.value="All Focus";if(fullscreen==true){deskToggleFull()}webRtcDesktopReset();deskPreferedStickyDisplay=0;break;case 2:break;default:break}updateDesktopButtons();deskAdjust();setTimeout(deskAdjust,50)}function showDesktopSettings(){if(xxdialogMode){return}applyDesktopSettings();updateDesktopButtons();setDialogMode(7,"Remote Desktop Settings",3,showDesktopSettingsChanged)}function showDesktopSettingsChanged(){desktopsettings.encoding=d7desktopmode.value;desktopsettings.showfocus=d7showfocus.checked;desktopsettings.showmouse=d7showcursor.checked;desktopsettings.quality=d7bitmapquality.value;desktopsettings.scaling=d7bitmapscaling.value;desktopsettings.framerate=d7framelimiter.value;desktopsettings.localkeymap=d7localKeyMap.checked;localStorage.setItem("desktopsettings",JSON.stringify(desktopsettings));applyDesktopSettings();if(desktop){if(desktop.contype==1){if(desktop.State!=0){desktop.m.SendCompressionLevel(1,desktopsettings.quality,desktopsettings.scaling,desktopsettings.framerate)}}if(desktop.contype==2){if(desktopsettings.showfocus==false){desktop.m.focusmode=0;deskFocusBtn.value="All Focus"}if(desktop.State!=0){desktop.Stop();setTimeout(function(){connectDesktop(null,2)},50)}}}}function applyDesktopSettings(){var c="",b=(features&512)?[90,80,70,60,50,40,30,20,10,5,1]:[60,50,40,30,20,10,5,1];for(var a in b){c+="<option value="+b[a]+">"+b[a]+"%</option>"}QH("d7bitmapquality",c);d7desktopmode.value=desktopsettings.encoding;d7showfocus.checked=desktopsettings.showfocus;d7showcursor.checked=desktopsettings.showmouse;d7bitmapquality.value=40;if(b.indexOf(parseInt(desktopsettings.quality))>=0){d7bitmapquality.value=desktopsettings.quality}d7bitmapscaling.value=desktopsettings.scaling;if(desktopsettings.framerate){d7framelimiter.value=desktopsettings.framerate}if(desktopsettings.localkeymap){d7localKeyMap.checked=desktopsettings.localkeymap}QV("deskFocusBtn",(desktop!=null)&&(desktop.contype==2)&&(desktop.state!=0)&&(desktopsettings.showfocus))}function enterBrowserFullscreen(a){if(a.requestFullscreen){a.requestFullscreen()}else{if(a.msRequestFullscreen){a.msRequestFullscreen()}else{if(a.mozRequestFullScreen){a.mozRequestFullScreen()}else{if(a.webkitRequestFullscreen){a.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}}}}}function exitBrowserFullscreen(){if(document.exitFullscreen){document.exitFullscreen()}else{if(document.msExitFullscreen){document.msExitFullscreen()}else{if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else{if(document.webkitExitFullscreen){document.webkitExitFullscreen()}}}}}function isBrowserFullscreen(){if(!document.fullscreenElement&&!document.mozFullScreenElement&&!document.webkitFullscreenElement&&!document.msFullscreenElement){return false}else{return true}}var fullscreen=false;var browserfullscreen=false;function deskToggleFull(a){fullscreen=!fullscreen;if(fullscreen){QC("body").add("fulldesk");if(a.shiftKey==true){enterBrowserFullscreen(Q("deskarea0"));browserfullscreen=true}}else{QC("body").remove("fulldesk");exitBrowserFullscreen();browserfullscreen=false;toggleFullScreen()}deskAdjust();updateDesktopButtons()}function deskToggleFocus(){desktop.m.focusmode=(desktop.m.focusmode+64)%192;Q("deskFocusBtn").value=["All Focus","Small Focus","Large Focus"][desktop.m.focusmode/64]}function deskAdjust(){var d=Q("DeskParent").clientHeight,e=Q("DeskParent").clientWidth;var a=Q("Desk").height,b=Q("Desk").width;if(deskAspectRatio==2){QS("Desk")["margin-top"]=null;QS("Desk").height="100%";QS("Desk").width="100%";QS("DeskParent").overflow="hidden"}else{if(deskAspectRatio==1){QS("Desk")["margin-top"]="0px";QS("Desk").height=a+"px";QS("Desk").width=b+"px";QS("DeskParent").overflow="scroll"}else{if((d/e)>(a/b)){var c=((a*e)/b)+"px";QS("Desk").height=c;QS("Desk").width="100%"}else{var g=((b*d)/a)+"px";if(webPageFullScreen||fullscreen){QS("Desk").height=null}else{QS("Desk").height="100%"}QS("Desk").width=g}QS("Desk")["margin-top"]=null;QS("DeskParent").overflow="hidden"}}}function mdeskAdjust(c,h,g,a){if(!c||!h||!g||!a){return}if(a.id=="Desk"){deskAdjust();return}var k=[{x:180,y:101},{x:302,y:169},{x:454,y:255}][Q("sizeselect").selectedIndex];var e=k.x+2,j=Q("xdevices").clientWidth-30,l=Math.floor(j/e);l=e+Math.floor((j-(l*e))/l);k.y=k.y*(l/k.x);k.x=l;var b=k.y,d=k.x;if(c.State!=0){b=k.y;d=(h/g)*k.y}QS(a.id)["max-height"]=b+"px";QS(a.id)["max-width"]=d+"px";QS(a.id)["margin-top"]="0";QS(a.id)["margin-bottom"]="0"}function deskSendKeys(){if(xxdialogMode||desktop==null||desktop.State!=3){return}var a=Q("deskkeys").value;if(a==0){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[65364,1],[65364,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,40],[desktop.m.KeyAction.UP,40],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==1){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[65362,1],[65362,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,38],[desktop.m.KeyAction.UP,38],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==2){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[108,1],[108,0],[65511,0]])}else{desktop.sendCtrlMsg('{"action":"lock"}')}}else{if(a==3){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[109,1],[109,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==4){if(desktop.contype==2){desktop.m.sendkey([[65505,1],[65511,1],[109,1],[109,0],[65511,0],[65505,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.DOWN,16],[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,91],[desktop.m.KeyAction.UP,16]])}}else{if(a==5){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==6){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[114,1],[114,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,82],[desktop.m.KeyAction.UP,82],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==7){if(desktop.contype==2){desktop.m.sendkey([[65513,1],[65473,1],[65473,0],[65513,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,18],[desktop.m.KeyAction.DOWN,115],[desktop.m.KeyAction.UP,115],[desktop.m.KeyAction.EXUP,18]])}}else{if(a==8){if(desktop.contype==2){desktop.m.sendkey([[65507,1],[119,1],[119,0],[65507,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,17],[desktop.m.KeyAction.DOWN,87],[desktop.m.KeyAction.UP,87],[desktop.m.KeyAction.EXUP,17]])}}else{if(a==9){if(desktop.contype==2){desktop.m.sendkey([[65513,1],[65289,1],[65289,0],[65513,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,18],[desktop.m.KeyAction.DOWN,9],[desktop.m.KeyAction.UP,9],[desktop.m.KeyAction.EXUP,18]])}}else{if(a==10){desktop.m.sendcad()}}}}}}}}}}}}function showDeskClip(){if(xxdialogMode||desktop==null||desktop.State!=3){return}Q("DeskClip").blur();var a="";a+='<input id=dlgClipGet type=button value="Get Clipboard" style=width:120px onclick=showDeskClipGet()>';a+='<input id=dlgClipSet type=button value="Set Clipboard" style=width:120px onclick=showDeskClipSet()>';a+='<div id=dlgClipStatus style="display:inline-block;margin-left:8px" ></div>';a+='<textarea id=d2clipText style="width:100%;height:184px;resize:none" maxlength=65535></textarea>';a+='<input type=button value="Close" style=width:80px;float:right onclick=dialogclose(0)><div style=height:26px;margin-top:3px><span id=linuxClipWarn style=display:none>Remote clipboard is valid for 60 seconds.</span>&nbsp;</div><div></div>';setDialogMode(2,"Remote Clipboard",8,null,a,"clipboard");Q("d2clipText").focus()}function showDeskClipGet(){if(desktop==null||desktop.State!=3){return}meshserver.send({action:"msg",type:"getclip",nodeid:currentNode._id})}function showDeskClipSet(){if(desktop==null||desktop.State!=3){return}meshserver.send({action:"msg",type:"setclip",nodeid:currentNode._id,data:Q("d2clipText").value});QV("linuxClipWarn",currentNode&&currentNode.agent&&(currentNode.agent.id>4)&&(currentNode.agent.id!=21)&&(currentNode.agent.id!=22))}function sendCAD(){if(xxdialogMode||desktop==null||desktop.State!=3){return}desktop.m.sendcad()}function toggleDeskTools(){if(xxdialogMode){return}if(QS("DeskTools").display=="none"){QV("DeskTools",true);Q("DeskTools").nodeid=currentNode._id;refreshDeskTools()}else{QV("DeskTools",false)}}function refreshDeskTools(){QV("DeskToolsRefreshButton",false);setTimeout(refreshDeskToolsEx,500);meshserver.send({action:"msg",type:"ps",nodeid:currentNode._id})}function refreshDeskToolsEx(){QV("DeskToolsRefreshButton",true)}var deskTools={sort:1,msg:null};function sortProcess(a){deskTools.sort=a;showDeskToolsProcesses(deskTools.msg)}function sortProcessPid(c,d){if(c.p>d.p){return 1}if(c.p<d.p){return(-1)}return 0}function sortProcessName(c,d){if(c.d>d.d){return 1}if(c.d<d.d){return(-1)}return 0}function showDeskToolsProcesses(c){deskTools.msg=c;if(c==null){QH("DeskToolsProcesses","");return}if(Q("DeskTools").nodeid!=c.nodeid){return}var d=[],h=null;try{h=JSON.parse(c.value)}catch(a){}if(h!=null){for(var g in h){d.push({p:parseInt(g),c:h[g].cmd,d:h[g].cmd.toLowerCase(),u:h[g].user})}if(deskTools.sort==0){d.sort(sortProcessPid)}else{if(deskTools.sort==1){d.sort(sortProcessName)}}var j="";for(var b in d){if(d[b].p!=0){j+="<div class=deskToolsBar><div style=width:50px;float:left;text-align:right;padding-right:5px>"+d[b].p+'</div><a href=# style=float:right;padding-right:5px;cursor:pointer title="Stop process" onclick=\'return stopProcess('+d[b].p+',"'+d[b].c+'")\'><img width=10 height=10 src="images/trash.png"></a><div style=float:right;padding-right:5px>'+(d[b].u?d[b].u:"")+"</div><div>"+d[b].c+"</div></div>"}}QH("DeskToolsProcesses",j)}}function toggleKvmControl(){putstore("DeskControl",(Q("DeskControl").checked?1:0))}function deskSaveImage(){if(xxdialogMode||desktop==null||desktop.State!=3){return}var a=new Date(),b="Desktop-"+currentNode.name+"-"+a.getFullYear()+"-"+("0"+(a.getMonth()+1)).slice(-2)+"-"+("0"+a.getDate()).slice(-2)+"-"+("0"+a.getHours()).slice(-2)+"-"+("0"+a.getMinutes()).slice(-2);Q("Desk")["toBlob"](function(c){saveAs(c,b+".jpg")})}function deskDisplayInfo(g,b,e){var a=0,c="";for(var d in b){a++;c+="<option"+((e==d)?" selected":"")+" value="+d+">"+b[d]+"</option>";if((deskPreferedStickyDisplay==d)&&(e!=deskPreferedStickyDisplay)){desktop.m.SetDisplay(d)}}QH("termdisplays",c);QV("termdisplays",a>1)}function deskGetDisplayNumbers(a){desktop.m.GetDisplayNumbers()}var deskPreferedStickyDisplay=0;function deskSetDisplay(a){desktop.m.SetDisplay(deskPreferedStickyDisplay=parseInt(Q("termdisplays").value));Q("termdisplays").blur()}var dblClickDetectArgs={t:0,x:0,y:0};function dblClickDetect(a){if(a.buttons!=1){return}var b=Date.now();if(((b-dblClickDetectArgs.t)<250)&&(Math.abs(a.clientX-dblClickDetectArgs.x)<2)&&(Math.abs(a.clientY-dblClickDetectArgs.y)<2)){if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousedblclick(a);desktop.m.sendKeepAlive()}else{desktop.m.mousedblclick(a)}}}dblClickDetectArgs.t=b;dblClickDetectArgs.x=a.clientX;dblClickDetectArgs.y=a.clientY}function dmousedown(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousedown(a);desktop.m.sendKeepAlive()}else{desktop.m.mousedown(a)}}dblClickDetect(a)}function dmouseup(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mouseup(a);desktop.m.sendKeepAlive()}else{desktop.m.mouseup(a)}}}function dmousemove(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousemove(a);desktop.m.sendKeepAlive()}else{desktop.m.mousemove(a)}}}function dmousewheel(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousewheel(a);desktop.m.sendKeepAlive()}else{if(desktop.m.mousewheel){desktop.m.mousewheel(a)}}haltEvent(a);return true}return false}function drotate(a){if(!xxdialogMode&&desktop!=null){desktop.m.setRotation(desktop.m.rotation+a);deskAdjust();deskAdjust()}}function stopProcess(a,b){setDialogMode(2,"Process Control",3,stopProcessEx,"Stop process #"+a+' "'+b+'"?',a);return false}function stopProcessEx(a,b){meshserver.send({action:"msg",type:"pskill",nodeid:currentNode._id,value:b});setTimeout(refreshDeskTools,300)}var terminalNode;function setupTerminal(){if((terminalNode!=currentNode)&&(terminal!=null)){terminal.Stop();terminal=null}terminalNode=currentNode;updateTerminalButtons()}function updateTerminalButtons(){var b=meshes[terminalNode.meshid];var d=((terminal!=null)&&(terminal.state!=0));QV("disconnectbutton2span",(d==true));QV("connectbutton2span",(d==false)&&(b.mtype==2)&&(currentNode.agent.caps&2));QV("connectbutton2hspan",(d==false)&&((terminalNode.intelamt!=null)&&(b.mtype==1||terminalNode.intelamt.state==2)&&((terminalNode.intelamt.ver!=null)||(b.mtype==1))));var c=((terminalNode.conn&1)!=0);QE("connectbutton2",c);var a=((terminalNode.conn&6)!=0);QE("connectbutton2h",a);QE("ctrlcbutton",d);QE("ctrlxbutton",d);QE("escbutton",d);QE("bsbutton",d);QE("pastebutton",d);QE("specialkeylist",d);QE("specialkeylistinput",d);QV("terminalSettingsButtons",(terminal)&&(terminal.contype==2));if(terminal){Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation];Q("id_tfxkeysbutton").value=fxEmulations[terminal.m.fxEmulation];Q("id_tcrbutton").value=(terminal.m.lineFeed=="\r\n")?"CR+LF":"LF"}}function onTerminalStateChange(d,a){var c=a;if((c==3)&&(d.contype==2)){c++}var b=StatusStrs[c];if(terminal.webRtcActive==true){b+=", WebRTC"}QH("termstatus",b);switch(a){case 0:QE("termSizeList",true);QH("termtitle","");d.m.TermResetScreen();d.m.TermDraw();if(terminal!=null){terminal.Stop();terminal=null}break;case 3:QE("termSizeList",false);break;default:QE("termSizeList",false);break}updateTerminalButtons()}var autoConnectTerminalTimer=null;function autoConnectTerminal(a){if(autoConnectTerminalTimer==null){autoConnectTerminalTimer=setInterval(connectTerminal,100)}else{clearInterval(autoConnectTerminalTimer);autoConnectTerminalTimer=null}}function connectTerminal(b,a,c){p12clearConsoleMsg();if(!terminal){if(a==2){if((terminalNode.intelamt.user==null)||(terminalNode.intelamt.user=="")){editDeviceAmtSettings(terminalNode._id,connectTerminal,2);return}var d={};if(Q("termSizeList").value==2){d.width=100;d.height=30}terminal=CreateAmtRedirect(CreateAmtRemoteTerminal("Term",d),authCookie);terminal.debugmode=debugmode;terminal.m.debugmode=debugmode;terminal.m.onTitleChange=function(e,g){QH("termtitle"," - "+EscapeHtml(g))};terminal.onStateChanged=onTerminalStateChange;terminal.Start(terminalNode._id,16994,"*","*",0);terminal.contype=2;Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation]}else{var d={};if([1,2,3,4,21,22].indexOf(currentNode.agent.id)==-1){if(Q("termSizeList").value==2){d.width=100;d.height=30;d.xterm=true}if(Q("termSizeList").value==3){d.width=Math.floor((Q("column_l").clientWidth-60)/10);d.height=Math.floor((Q("column_l").clientHeight-120)/20);d.xterm=true}}if((b&&(b.shiftKey==true))||(c&&(c.powershell))){d.protocol=6}terminal=CreateAgentRedirect(meshserver,CreateAmtRemoteTerminal("Term",d),serverPublicNamePort,authCookie,domainUrl);terminal.debugmode=debugmode;terminal.m.debugmode=debugmode;terminal.m.onTitleChange=function(e,g){QH("termtitle"," - "+EscapeHtml(g))};terminal.m.lineFeed=([1,2,3,4,21,22].indexOf(currentNode.agent.id)>=0)?"\r\n":"\r";terminal.attemptWebRTC=attemptWebRTC;terminal.onStateChanged=onTerminalStateChange;terminal.onConsoleMessageChange=function(){p12clearConsoleMsg();if(terminal.consoleMessage){QH("p12TermConsoleMsg",EscapeHtml(terminal.consoleMessage).split("\n").join("<br />"));QV("p12TermConsoleMsg",true);p12TermConsoleMsgTimer=setTimeout(p12clearConsoleMsg,8000)}};terminal.Start(terminalNode._id);terminal.contype=1;terminal.m.terminalEmulation=0;terminal.m.fxEmulation=0;Q("id_ttypebutton").value=terminalEmulations[0]}}else{terminal.Stop();terminal=null}Q("connectbutton2").blur()}var terminalEmulations=["UTF8 Terminal","Extended ASCII","Intel ASCII"];function termToggleType(){if(!terminal||xxdialogMode){return}terminal.m.terminalEmulation=(terminal.m.terminalEmulation+1)%3;Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation];Q("id_ttypebutton").blur()}var fxEmulations=["Intel (F10 = ESC+[OM)","Alternate (F10 = ESC+0)","VT100+ (F10 = ESC+[OY)"];function termToggleFx(){if(!terminal||xxdialogMode){return}terminal.m.fxEmulation=(terminal.m.fxEmulation+1)%3;Q("id_tfxkeysbutton").value=fxEmulations[terminal.m.fxEmulation];Q("id_tfxkeysbutton").blur()}function termToggleCr(){if(!terminal||xxdialogMode){return}if(terminal.m.lineFeed=="\n"){terminal.m.lineFeed="\r\n"}else{terminal.m.lineFeed="\n"}Q("id_tcrbutton").value=(terminal.m.lineFeed=="\r\n")?"CR+LF":"LF"}function termSendKey(b,a){if(!terminal||xxdialogMode){return}terminal.m.TermSendKey(b);Q(a).blur()}function showTermPasteDialog(){if(!terminal||xxdialogMode){return}Q("pastebutton").blur();setDialogMode(2,"Paste",3,showTermPasteDialogEx,'<textarea id=d2pasteText style="width:100%;height:184px;resize:none"></textarea>');Q("d2pasteText").focus()}function showTermPasteDialogEx(){if(!terminal){return}terminal.m.TermSendKeys(Q("d2pasteText").value)}function sendSpecialKey(){terminal.m.TermSendKey(Q("specialkeylist").value);Q("specialkeylist").blur();Q("specialkeylistinput").blur()}var filesNode;function setupFiles(){var b=(filesNode==currentNode);filesNode=currentNode;var a=((filesNode.conn&1)!=0)?true:false;QE("p13Connect",a);if(((b==false)||(a==false))&&files){files.Stop();files=null}}function onFilesStateChange(c,a){p13Connect.value=(a==0)?"Connect":"Disconnect";var b=StatusStrs[a];if(files.webRtcActive==true){b+=", WebRTC"}Q("p13Status").textContent=b;switch(a){case 0:QH("p13files","");p13filetree=null;p13filetreelocation=[];QH("p13currentpath","");QE("p13FolderUp",false);p13setActions();if(files!=null){files.Stop();files=null}break;case 3:p13targetpath="";files.sendText({action:"ls",reqid:1,path:""});break;default:break}}function CreateRemoteFiles(b){var a={protocol:5};a.onFileUpdate=b;a.xxStateChange=function(c){};a.ProcessData=function(c){a.onFileUpdate(c)};return a}var autoConnectFilesTimer=null;function autoConnectFiles(a){if(autoConnectFilesTimer==null){autoConnectFilesTimer=setInterval(connectFiles,100)}else{clearInterval(autoConnectFilesTimer);autoConnectFilesTimer=null}}function connectFiles(a){p13clearConsoleMsg();if(!files){files=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotFiles),serverPublicNamePort,authCookie,domainUrl);files.attemptWebRTC=attemptWebRTC;files.onStateChanged=onFilesStateChange;files.onConsoleMessageChange=function(){p13clearConsoleMsg();if(files.consoleMessage){QH("p13FilesConsoleMsg",EscapeHtml(files.consoleMessage).split("\n").join("<br />"));QV("p13FilesConsoleMsg",true);p13FilesConsoleMsgTimer=setTimeout(p13clearConsoleMsg,8000)}};files.Start(filesNode._id)}else{files.Stop();files=null}p13clipboard=p13clipboardFolder=null;p13clipboardCut=0;p13updateClipview()}var p13filetree=null;var p13targetpath=null;var p13filetreelocation=[];function p13gotFiles(b){if((b.length>0)&&(b.charCodeAt(0)!=123)){p13gotDownloadBinaryData(b);return}b=JSON.parse(decode_utf8(b));if(b.action=="download"){p13gotDownloadCommand(b);return}b.path=b.path.replace(/\//g,"\\");if((p13filetree!=null)&&(b.path==p13filetree.path)){var a=p13getCheckedNames();p13filetree=b;p13updateFiles(a)}else{var c=b.path.replace(/\//g,"\\"),d=p13targetpath.replace(/\//g,"\\");while((c.length>0)&&(c[0]=="\\")){c=c.substring(1)}while((d.length>0)&&(d[0]=="\\")){d=d.substring(1)}if((c==d)||((b.path=="\\")&&(p13targetpath==""))){p13filetree=b;p13updateFiles()}}}function p13getCheckedNames(){var b=[],a=document.getElementsByName("fd");for(var c=0;c<a.length;c++){if(a[c].checked){b.push(p13filetree.dir[a[c].value].n)}}return b}function p13updateFiles(b){var n="",o="",c='<a href=# style=cursor:pointer onclick="return p13folderup(0)">Root</a>',l="Root";var w=p13filetree.path.split("\\");p13filetreelocation=[];for(var p in w){if(w[p]!=""){p13filetreelocation.push(w[p])}}for(var p in p13filetreelocation){c+=' / <a href=# style=cursor:pointer onclick="return p13folderup('+(parseInt(p)+1)+')">'+p13filetreelocation[p]+"</a>"}var s=p13filetreelocation.join("/");var j=p13sort_files(p13filetree.dir);for(var p in j){var d=j[p],r=d.n,u;u=r;if(r.length>70){u='<span title="'+EscapeHtml(r)+'">'+EscapeHtml(r.substring(0,70))+"...</span>"}else{u=EscapeHtml(r)}r=EscapeHtml(r);var g="";if(d.d!=null){var e=new Date(d.d),g=printDateTime(e)+"&nbsp;"}var k="";if(d.s!=null){k=getFileSizeStr(d.s)}var m="";if(d.t<3){var t="",v="";m="<div class=filelist file=999><input file=999 style=float:left name=fd class=fcb type=checkbox onchange=p13setActions() value='"+d.nx+"'>&nbsp;<span style=float:right title=\""+v+'">'+t+"</span><span><div class=fileIcon"+d.t+' onclick=p13folderset("'+encodeURIComponent(d.nx)+'")></div><a href=# style=cursor:pointer onclick=\'return p13folderset("'+encodeURIComponent(d.nx)+"\")'>"+u+"</a></span></div>"}else{var q=u;if(d.s>0){q='<a hrf=# rel="noreferrer noopener" target="_blank" style=cursor:pointer onclick="return p13downloadfile(\''+encodeURIComponent(s+"/"+r)+"','"+encodeURIComponent(r)+"',"+d.s+')">'+u+"</a>"}m="<div class=filelist file=3><input file=3 style=float:left name=fd class=fcb type=checkbox onchange=p13setActions() value='"+d.nx+"'>&nbsp;<span class=fsize>"+g+"</span><span style=float:right>"+k+"</span><span><div class=fileIcon"+d.t+"></div>"+q+"</span></div>"}if(d.t<3){n+=m}else{o+=m}}QH("p13files",n+o);QH("p13currentpath",c);QE("p13FolderUp",p13filetreelocation.length!=0);if(b!=null){var a=document.getElementsByName("fd");for(var p=0;p<a.length;p++){if(b.indexOf(p13filetree.dir[a[p].value].n)>=0){a[p].checked=true}}}p13setActions()}function p13folderset(a){p13targetpath=joinPaths(p13filetree.path,p13filetree.dir[a].n).split("\\").join("/");files.sendText({action:"ls",reqid:1,path:p13targetpath})}function p13folderup(a){if(a==null){p13filetreelocation.pop()}else{while(p13filetreelocation.length>a){p13filetreelocation.pop()}}p13targetpath=p13filetreelocation.join("/");files.sendText({action:"ls",reqid:1,path:p13targetpath});return false}var p13sortorder;function p13sort_filename(c,d){if(c.ln>d.ln){return(1*p13sortorder)}if(c.ln<d.ln){return(-1*p13sortorder)}return 0}function p13sort_timestamp(c,d){if(c.d>d.d){return(1*p13sortorder)}if(c.d<d.d){return(-1*p13sortorder)}return 0}function p13sort_bysize(c,d){if(c.s==d.s){return p13sort_filename(c,d)}return(((c.s-d.s))*p13sortorder)}function p13sort_files(a){var c=[],d=Q("p13sortdropdown").value;for(var b in a){a[b].nx=b;if(a[b].s==null){a[b].s=0}if(a[b].n==null){a[b].n=b}a[b].ln=a[b].n.toLowerCase();c.push(a[b])}p13sortorder=1;if(d>3){p13sortorder=-1;d-=3}if(d==1){c.sort(p13sort_filename)}else{if(d==2){c.sort(p13sort_bysize)}else{if(d==3){c.sort(p13sort_timestamp)}}}return c}function p13setActions(){if(p13filetree==null){QE("p13DeleteFileButton",false);QE("p13NewFolderButton",false);QE("p13UploadButton",false);QE("p13RenameFileButton",false);QE("p13SelectAllButton",false);Q("p13SelectAllButton").value="Select All";QE("p13RefreshButton",false);QE("p13CutButton",false);QE("p13CopyButton",false);QE("p13PasteButton",false)}else{var a=p13getFileSelCount(),c=p13getFileCount(),b=p13getFileSelCount(false);var d=((currentNode.agent.id>0)&&(currentNode.agent.id<5));QE("p13DeleteFileButton",(a>0)&&((p13filetreelocation.length>0)||(d==false)));QE("p13NewFolderButton",((p13filetreelocation.length>0)||(d==false)));QE("p13UploadButton",((p13filetreelocation.length>0)||(d==false)));QE("p13RenameFileButton",(a==1)&&((p13filetreelocation.length>0)||(d==false)));QE("p13SelectAllButton",c>0);Q("p13SelectAllButton").value=(a>0?"Select None":"Select All");QE("p13RefreshButton",true);QE("p13CutButton",(a>0)&&(a==b)&&((p13filetreelocation.length>0)||(d==false)));QE("p13CopyButton",(a>0)&&(a==b)&&((p13filetreelocation.length>0)||(d==false)));QE("p13PasteButton",((p13filetreelocation.length>0)||(d==false))&&((p13clipboard!=null)&&(p13clipboard.length>0)))}}function p13getFileSelCount(d){var a=0;var b=document.getElementsByName("fd");for(var c=0;c<b.length;c++){if((b[c].checked)&&((d!=false)||(b[c].attributes.file.value=="3"))){a++}}return a}function p13getFileSelDirCount(){var a=0,b=document.getElementsByName("fd");for(var c=0;c<b.length;c++){if((b[c].checked)&&(b[c].attributes.file.value=="999")){a++}}return a}function p13getFileCount(){var a=0;var b=document.getElementsByName("fd");return b.length}function p13selectallfile(){var c=(p13getFileSelCount()==0),a=document.getElementsByName("fd");for(var b=0;b<a.length;b++){a[b].checked=c}p13setActions()}function p13createfolder(){setDialogMode(2,"New Folder",3,p13createfolderEx,"<input type=text id=p13renameinput maxlength=64 onkeyup=p13fileNameCheck(event) style=width:100% />");focusTextBox("p13renameinput");p13fileNameCheck()}function p13createfolderEx(){files.sendText({action:"mkdir",reqid:1,path:p13filetreelocation.join("/")+"/"+Q("p13renameinput").value});p13folderup(999)}function p13deletefile(){var a=p13getFileSelCount(),b=(p13getFileSelDirCount()>0)?"<br /><br /><label><input type=checkbox id=p13recdeleteinput>Recursive delete</label><br>":"<input type=checkbox id=p13recdeleteinput style='display:none'>";setDialogMode(2,"Delete",3,p13deletefileEx,(a>1)?("Delete "+a+" selected items?"+b):("Delete selected item?"+b))}function p13deletefileEx(){var b=[],a=document.getElementsByName("fd");for(var c=0;c<a.length;c++){if(a[c].checked){b.push(p13filetree.dir[a[c].value].n)}}files.sendText({action:"rm",reqid:1,path:p13filetreelocation.join("/"),delfiles:b,rec:Q("p13recdeleteinput").checked});p13folderup(999)}function p13renamefile(){var c,a=document.getElementsByName("fd");for(var b=0;b<a.length;b++){if(a[b].checked){c=p13filetree.dir[a[b].value].n}}setDialogMode(2,"Rename",3,p13renamefileEx,'<input type=text id=p13renameinput maxlength=64 onkeyup=p13fileNameCheck(event) style=width:100% value="'+c+'" />',{action:"rename",path:p13filetreelocation.join("/"),oldname:c});focusTextBox("p13renameinput");p13fileNameCheck()}function p13renamefileEx(a,c){c.newname=Q("p13renameinput").value;files.sendText(c);p13folderup(999)}function p13fileNameCheck(a){var b=isFilenameValid(Q("p13renameinput").value);QE("idx_dlgOkButton",b);if((b==true)&&(a!=null)&&(a.keyCode==13)){dialogclose(1)}}function p13uploadFile(){setDialogMode(2,"Upload File",3,p13uploadFileEx,"<input type=file name=files id=p13uploadinput style=width:100% multiple=multiple onchange=\"updateUploadDialogOk('p13uploadinput')\" />");updateUploadDialogOk("p13uploadinput")}function p13uploadFileEx(){p13doUploadFiles(Q("p13uploadinput").files)}var p13clipboard=null,p13clipboardFolder=null,p13clipboardCut=0;function p13copyFile(b){var a=document.getElementsByName("fd");p13clipboard=[];p13clipboardCut=b,p13clipboardFolder=p13targetpath;for(var c=0;c<a.length;c++){if((a[c].checked)&&(a[c].attributes.file.value=="3")){p13clipboard.push(p13filetree.dir[a[c].value].n)}}p13updateClipview()}function p13pasteFile(){var a="";if((p13clipboard!=null)&&(p13clipboard.length>0)){a="Confim "+(p13clipboardCut==0?"copy":"move")+" of "+p13clipboard.length+" entrie"+((p13clipboard.length>1)?"s":"")+" to this location?"}setDialogMode(2,"Paste",3,p13pasteFileEx,a)}function p13pasteFileEx(){files.sendText({action:(p13clipboardCut==0?"copy":"move"),reqid:1,scpath:p13clipboardFolder,dspath:p13targetpath,names:p13clipboard});p13folderup(999);if(p13clipboardCut==1){p13clipboard=null,p13clipboardFolder=null,p13clipboardCut=0;p13updateClipview()}}function p13updateClipview(){var a="";if((p13clipboard!=null)&&(p13clipboard.length>0)){a="Holding "+p13clipboard.length+" entrie"+((p13clipboard.length>1)?"s":"")+" for "+(p13clipboardCut==0?"copy":"move")+', <a href=# onclick="return p13clearClip()" style=cursor:pointer>Clear</a>.'}QH("p13bottomstatus",a);p13setActions()}function p13clearClip(){p13clipboard=null;p13clipboardFolder=null;p13clipboardCut=0;p13updateClipview();return false}function p13fileDragDrop(a){haltEvent(a);QV("p13bigfail",false);QV("p13bigok",false);if(a.dataTransfer==null||a.dataTransfer.files.length==0||p13filetree==null){return}p13doUploadFiles(a.dataTransfer.files)}var p13dragtimer=null;function p13fileDragOver(b){haltEvent(b);if(p13dragtimer!=null){clearTimeout(p13dragtimer);p13dragtimer=null}var a=(p13filetree!=null);QV("p13bigok",a);QV("p13bigfail",!a)}function p13fileDragLeave(a){haltEvent(a);if(a.target.id!="p13filetable"){QV("p13bigfail",false);QV("p13bigok",false)}else{p13dragtimer=setTimeout(function(){QV("p13bigfail",false);QV("p13bigok",false);p13dragtimer=null},10)}}var downloadFile;function p13downloadfile(a,b,c){if(xxdialogMode||downloadFile||!files){return}downloadFile={path:decodeURIComponent(a),file:decodeURIComponent(b),size:c,tsize:0,data:"",state:0,id:Math.random()};files.sendText({action:"download",sub:"start",id:downloadFile.id,path:downloadFile.path});setDialogMode(2,"Download File",10,p13downloadFileCancel,"<div>"+downloadFile.file+"</div><br /><progress id=d2progressBar style=width:100% value=0 max="+c+" />")}function p13downloadFileCancel(){setDialogMode(0);files.sendText({action:"download",sub:"cancel",id:downloadFile.id});downloadFile=null}function p13gotDownloadCommand(a){if((downloadFile==null)||(a.id!=downloadFile.id)){return}if(a.sub=="start"){downloadFile.state=1;files.sendText({action:"download",sub:"startack",id:downloadFile.id})}else{if(a.sub=="cancel"){downloadFile=null;setDialogMode(0)}}}function p13gotDownloadBinaryData(a){if(!downloadFile||downloadFile.state==0){return}if(a.length>4){downloadFile.tsize+=(a.length-4);downloadFile.data+=a.substring(4);Q("d2progressBar").value=downloadFile.tsize}if((ReadInt(a,0)&1)!=0){saveAs(data2blob(downloadFile.data),downloadFile.file);downloadFile=null;setDialogMode(0)}else{files.sendText({action:"download",sub:"ack",id:downloadFile.id})}}var uploadFile;function p13doUploadFiles(a){if(xxdialogMode){return}uploadFile={};uploadFile.xpath=p13filetreelocation.join("/");uploadFile.xfiles=a;uploadFile.xfilePtr=-1;setDialogMode(2,"Upload File",10,p13uploadFileCancel,"<div id=p13dfileName>Connecting...</div><br /><progress id=d2progressBar style=width:100% value=0 max=0 />");p13uploadReconnect()}function onFileUploadStateChange(b,a){switch(a){case 0:p13folderup(9999);break;case 3:p13uploadNextFile();break;default:break}}function p13uploadReconnect(){uploadFile.ws=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotUploadData),serverPublicNamePort,authCookie,domainUrl);uploadFile.ws.attemptWebRTC=false;uploadFile.ws.ctrlMsgAllowed=false;uploadFile.ws.onStateChanged=onFileUploadStateChange;uploadFile.ws.Start(filesNode._id)}function p13uploadNextFile(){uploadFile.xfilePtr++;if(uploadFile.xfiles.length>uploadFile.xfilePtr){uploadFile.xptr=0;var a=uploadFile.xfiles[uploadFile.xfilePtr];QH("p13dfileName",a.name);Q("d2progressBar").max=a.size;Q("d2progressBar").value=0;uploadFile.xreader=new FileReader();uploadFile.xreader.onload=function(){uploadFile.xdata=uploadFile.xreader.result;uploadFile.ws.sendText(JSON.stringify({action:"upload",reqid:uploadFile.xfilePtr,path:uploadFile.xpath,name:a.name,size:uploadFile.xdata.byteLength}))};uploadFile.xreader.readAsArrayBuffer(a)}else{p13uploadFileCancel()}}function p13uploadFileCancel(a,b){if(uploadFile!=null){if(uploadFile.ws!=null){uploadFile.ws.Stop();uploadFile.ws=null}uploadFile=null}setDialogMode(0)}function p13gotUploadData(b){var a=JSON.parse(b);if((uploadFile==null)||(parseInt(uploadFile.xfilePtr)!=parseInt(a.reqid))){return}if(a.action=="uploadstart"){p13uploadNextPart(false);for(var c=0;c<8;c++){p13uploadNextPart(true)}}else{if(a.action=="uploadack"){p13uploadNextPart(false)}else{if(a.action=="uploaderror"){p13uploadFileCancel()}}}}function p13uploadNextPart(c){var a=uploadFile.xdata;var e=uploadFile.xptr;var d=uploadFile.xptr+4096;if(d>a.byteLength){if(c==true){return}d=a.byteLength}if(e==a.byteLength){if(uploadFile.ws!=null){uploadFile.ws.Stop();uploadFile.ws=null}if(uploadFile.xfiles.length>uploadFile.xfilePtr+1){p13uploadReconnect()}else{p13uploadFileCancel()}}else{var b=a.slice(e,d);uploadFile.ws.send(b);uploadFile.xptr=d;Q("d2progressBar").value=d}}var currentDeviceEvents=null;function deviceEventsUpdate(){var h="",a=null;for(var c in currentDeviceEvents){var b=currentDeviceEvents[c];var g=new Date(b.time);if(printDate(g)!=a){if(a!=null){h+="</table>"}a=printDate(g);h+="<table style=width:100% cellpadding=0 cellspacing=0><tr><td class=DevSt colspan=4>"+a+"</td></tr>"}var d="si3";if(b.etype=="user"){d="m2"}if(b.etype=="server"){d="si3"}var e=b.msg.split("(R)").join("&reg;");h+="<tr><td style=width:18px><div class="+d+"></div></td><td class=g1 style=float:none>&nbsp;</td><td style=background-color:#C9C9C9>"+printTime(g)+" - "+e+"</td><td class=g2 style=float:none>&nbsp;</td></tr><tr style=height:2px></tr>"}if(a!=null){h+="</table>"}if(h==""){h="<br><i>No Events Found</i><br><br>"}QH("p16events",h)}function refreshDeviceEvents(){meshserver.send({action:"events",nodeid:currentNode._id,limit:parseInt(p16limitdropdown.value)})}function agentConsoleHandleKeys(b){if((b.ctrlKey)||(b.altKey)){return true}var d=0,a=Q("p15consoleText");if(b.key){if(b.keyCode==13&&consoleFocus==0){p15consoleSend(b);d=1}else{if(b.keyCode==8&&consoleFocus==0){var g=a.value;a.value=g.substring(0,g.length-1);d=1}else{if(b.keyCode==27){a.value="";d=1}else{if((b.keyCode==38)||(b.keyCode==40)){var c=consoleHistory.indexOf(a.value);if((b.keyCode==38)&&((consoleHistory.length-1)>c)){a.value=consoleHistory[c+1]}else{if((b.keyCode==40)&&(c>0)){a.value=consoleHistory[c-1]}else{if((b.keyCode==40)&&(c==0)){a.value=""}}}d=1}else{if(b.key.length===1){insertTextAtCursor(a,b.key);d=1}}}}}}else{if(b.charCode!=0&&consoleFocus==0){a.value=((a.value+String.fromCharCode(b.charCode)));d=1}}if(d>0){return haltEvent(b)}}function insertTextAtCursor(a,d){if(document.selection){a.focus();sel=document.selection.createRange();sel.text=d}else{if(a.selectionStart||a.selectionStart=="0"){var c=a.selectionStart,b=a.selectionEnd;a.value=a.value.substring(0,c)+d+a.value.substring(b,a.value.length);a.setSelectionRange(b+1,b+1)}else{a.value+=myValue}}}var consoleNode;var consoleServerText="";function setupConsole(){if(xxcurrentView==115){var d=(consoleNode=="server");consoleNode="server";QH("p15deviceName","My Server Console");QE("p15consoleText",true);QH("p15statetext","");QH("p15coreName","");if(d==false){QH("p15agentConsoleText",consoleServerText);Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight}}else{var d=(consoleNode==currentNode);consoleNode=currentNode;var a=meshes[consoleNode.meshid];var b=a.links[userinfo._id].rights;if((b&16)!=0){if(consoleNode.consoleText==null){consoleNode.consoleText=""}if(d==false){QH("p15agentConsoleText",consoleNode.consoleText);Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight}var c=((consoleNode.conn&1)!=0)?true:false;QH("p15statetext",c?"Agent is online":"Agent is offline");QE("p15consoleText",c);QE("p15uploadCore",c)}else{QH("p15statetext","Access Denied");QE("p15consoleText",false);QE("p15uploadCore",false)}}}function p15consoleClear(){QH("p15agentConsoleText","");Q("id_p15consoleClear").blur();if(xxcurrentView==115){consoleServerText=""}else{consoleNode.consoleText=""}}var consoleHistory=[];function p15consoleSend(a){if(a&&a.keyCode!=13){return}var d=Q("p15consoleText").value,c="<div style=color:green>&gt; "+EscapeHtml(Q("p15consoleText").value)+"<br/></div>";Q("p15agentConsoleText").innerHTML+=c;Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight;Q("p15consoleText").value="";if(xxcurrentView==115){consoleServerText+=c;meshserver.send({action:"serverconsole",value:d})}else{consoleNode.consoleText+=c;meshserver.send({action:"msg",type:"console",nodeid:consoleNode._id,value:d})}if(d.length>0){var b=consoleHistory.indexOf(d);if(b>=0){consoleHistory.splice(b,1)}consoleHistory.unshift(d);consoleHistory.splice(10)}}function p15consoleReceive(b,a){a="<div>"+a+"</div>";if(b==="serverconsole"){consoleServerText+=a;if(consoleNode=="server"){Q("p15agentConsoleText").innerHTML+=a;Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight}}else{if(b.consoleText==null){b.consoleText=a}else{b.consoleText+=a}if(consoleNode==b){Q("p15agentConsoleText").innerHTML+=a;Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight}}}function p15downloadConsoleText(){saveAs(new Blob([Q("p15agentConsoleText").innerText],{type:"application/octet-stream"}),"console.txt")}function p15uploadCore(a){if(xxdialogMode){return}if(a.shiftKey==true){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"default"})}else{if(a.altKey==true){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"clear"})}else{if(a.ctrlKey==true){p15uploadCore2()}else{setDialogMode(2,"Perform Agent Action",3,p15uploadCoreEx,addHtmlValue("Action","<select id=d3coreMode style=width:230px><option value=1>Upload default server core</option><option value=2>Clear the core</option><option value=6>Upload recovery core</option><option value=3>Upload a core file</option><option value=4>Soft disconnect agent</option><option value=5>Hard disconnect agent</option></select>"))}}}}function p15uploadCoreEx(){if(Q("d3coreMode").value==1){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"default"})}else{if(Q("d3coreMode").value==2){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"clear"})}else{if(Q("d3coreMode").value==3){p15uploadCore2()}else{if(Q("d3coreMode").value==4){meshserver.send({action:"agentdisconnect",nodeid:consoleNode._id,disconnectMode:1})}else{if(Q("d3coreMode").value==5){meshserver.send({action:"agentdisconnect",nodeid:consoleNode._id,disconnectMode:2})}else{if(Q("d3coreMode").value==6){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"recovery"})}}}}}}}function p15uploadCore2(){if(xxdialogMode){return}Q("d3localmodeform").action="uploadmeshcorefile.ashx";Q("d3attrib").value=currentNode._id;setDialogMode(3,"Upload Mesh Agent Core",3,p15uploadCoreEx2);d3init()}function p15uploadCoreEx2(){var b=Q("d3uploadMode").value;if(b==1){Q("d3submit").click()}else{var a=d3getFileSel();if(a.length==1){meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"custom",path:d3filetreelocation.join("/")+"/"+a[0]})}}}function account_manageAuthApp(){if(xxdialogMode||((features&4096)==0)){return}if(userinfo.otpsecret==1){account_removeOtp()}else{account_addOtp()}return false}function account_addOtp(){if(xxdialogMode||(userinfo.otpsecret==1)||((features&4096)==0)){return}setDialogMode(2,"Authenticator App",2,function(){meshserver.send({action:"otpauth-setup",secret:Q("d2optsecret").attributes.secret.value,token:Q("d2otpauthinput").value})},"<div id=d2optinfo>Loading...</div>","otpauth-request");meshserver.send({action:"otpauth-request"})}function account_addOtpCheck(a){var b=(Q("d2otpauthinput").value.length==6);QE("idx_dlgOkButton",b);if(a&&(a.keyCode==13)&&b){dialogclose(1)}}function account_removeOtp(){if(xxdialogMode||(userinfo.otpsecret!=1)||((features&4096)==0)){return}setDialogMode(2,"Authenticator App",3,function(){meshserver.send({action:"otpauth-clear"})},"Confirm removal of authenticator application 2-step login?")}function account_manageOtp(a){if((xxdialogMode==2)&&(xxdialogTag=="otpauth-manage")){dialogclose(0)}if(xxdialogMode||((features&4096)==0)){return false}if((userinfo.otpsecret==1)||(userinfo.otphkeys>0)){meshserver.send({action:"otpauth-getpasswords",subaction:a})}return false}function account_manageHardwareOtp(){if((xxdialogMode==2)&&(xxdialogTag=="otpauth-hardware-manage")){dialogclose(0)}if(xxdialogMode||((features&4096)==0)){return false}meshserver.send({action:"otp-hkey-get"});return false}function account_addhkey(a){if(a==3){var b="Type in the name of the key to add.<br /><br />";b+=addHtmlValue("Key Name",'<input id=dp1keyname style=width:230px maxlength=20 autocomplete=off placeholder="MyKey" onkeyup=account_addhkeyValidate(event,2) />')}else{if(a==2){var b="Type in a key name, select the OTP box and press the button on the YubiKey&trade;.<br /><br />";b+=addHtmlValue("Key Name",'<input id=dp1keyname style=width:230px maxlength=20 autocomplete=off placeholder="MyKey" onkeyup=account_addhkeyValidate(event,1) />');b+=addHtmlValue("YubiKey&trade; OTP","<input id=dp1key style=width:230px autocomplete=off onkeyup=account_addhkeyValidate(event,2) />")}}setDialogMode(2,"Add Security Key",3,account_addhkeyEx,b,a);Q("dp1keyname").focus()}function account_addhkeyValidate(b,a){if((b!=null)&&(b.keyCode==13)){if(a==2){dialogclose(1)}else{Q("dp1key").focus()}}}function account_addhkeyEx(a,c){var b=Q("dp1keyname").value;if(b==""){b="MyKey"}if(c==2){meshserver.send({action:"otp-hkey-yubikey-add",name:b,otp:Q("dp1key").value});setDialogMode(2,"Add Security Key",0,null,"<br />Checking...<br /><br /><br />","otpauth-hardware-manage")}else{if(c==3){meshserver.send({action:"webauthn-startregister",name:b})}}}function account_removehkey(a){meshserver.send({action:"otp-hkey-remove",index:a});meshserver.send({action:"otp-hkey-get"})}function account_enableNotifications(){if(Notification){Notification.requestPermission().then(function(a){QV("accountEnableNotificationsSpan",a!="granted")})}return false}function account_showAccountNotifySettings(){if(xxdialogMode){return false}var b="";b+="<div><label><input id=p2notifyPlayNotifySound type=checkbox />Notification sound.</label></div>";b+="<div><label><input id=p2notifyIntelDeviceConnect type=checkbox />Device connections.</label></div>";b+="<div><label><input id=p2notifyIntelDeviceDisconnect type=checkbox />Device disconnections.</label></div>";b+="<div><label><input id=p2notifyIntelAmtKvmActions type=checkbox />Intel&reg; AMT desktop and serial events.</label></div>";setDialogMode(2,"Notification Settings",3,account_showAccountNotifySettingsEx,b);var a=getstore("notifications",0);Q("p2notifyPlayNotifySound").checked=(a&1);Q("p2notifyIntelDeviceConnect").checked=(a&2);Q("p2notifyIntelDeviceDisconnect").checked=(a&4);Q("p2notifyIntelAmtKvmActions").checked=(a&8);return false}function account_showAccountNotifySettingsEx(){var a=0;a+=Q("p2notifyPlayNotifySound").checked?1:0;a+=Q("p2notifyIntelDeviceConnect").checked?2:0;a+=Q("p2notifyIntelDeviceDisconnect").checked?4:0;a+=Q("p2notifyIntelAmtKvmActions").checked?8:0;putstore("notifications",a)}function account_showVerifyEmail(){if(xxdialogMode||(userinfo.emailVerified==true)||(serverinfo.emailcheck!=true)){return false}var a="Click ok to send a verification mail to:<br /><div style=padding:8px><b>"+EscapeHtml(userinfo.email)+"</b></div>Please wait a few minute to receive the verification.";setDialogMode(2,"Email Verification",3,account_showVerifyEmailEx,a);return false}function account_showVerifyEmailEx(){meshserver.send({action:"verifyemail",email:userinfo.email})}function account_showChangeEmail(){if(xxdialogMode){return false}var a="Change your account email address here.<br /><br />";a+=addHtmlValue("Email","<input id=dp2email style=width:230px maxlength=256 onchange=account_validateEmail() onkeyup=account_validateEmail(event) />");setDialogMode(2,"Email Address Change",3,account_changeEmail,a);if(userinfo.email!=null){Q("dp2email").value=userinfo.email}account_validateEmail();Q("dp2email").focus();return false}function account_validateEmail(a,b){QE("idx_dlgOkButton",validateEmail(Q("dp2email").value)&&(Q("dp2email").value!=userinfo.email));if((a!=null)&&(a.keyCode==13)){dialogclose(1)}}function account_changeEmail(){meshserver.send({action:"changeemail",email:Q("dp2email").value})}function account_showDeleteAccount(){if(xxdialogMode){return false}var a="To delete this account, type in the account password in both boxes below and hit ok.<br /><br />";a+="<form action='"+domainUrl+"deleteaccount' method=post><table style=margin-left:80px><tr>";a+="<td align=right>Password:</td><td><input id=apassword1 type=password name=apassword1 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>";a+="</tr><tr><td align=right>Password:</td><td><input id=apassword2 type=password name=apassword2 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>";a+="</tr></table><br /><div style=padding:10px;margin-bottom:4px>";a+="<input id=account_dlgCancelButton type=button value=Cancel style=float:right;width:80px;margin-left:5px onclick=dialogclose(0)>";a+='<input id=account_dlgOkButton type=submit value=OK style="float:right;width:80px" onclick=dialogclose(1)>';a+="</div><br /></form>";setDialogMode(2,"Delete Account",0,null,a);account_validateDeleteAccount();Q("apassword1").focus();return false}function account_showChangePassword(){if(xxdialogMode){return false}var d="Change your account password by entering the old password and new password twice in the boxes below.";if(features&65536){" Password hint can be used but is not recommanded."}d+="<br /><br />";d+="<table style=margin-left:60px>";d+="<tr><td align=right>Old password:</td><td><input id=apassword0 type=password name=apassword0 autocomplete=off onchange=account_validateNewPassword() onkeyup=account_validateNewPassword() onkeydown=account_validateNewPassword() /> <b></b></td></tr>";d+="<tr><td align=right>New password:</td><td><input id=apassword1 type=password name=apassword1 autocomplete=off onchange=account_validateNewPassword() onkeyup=account_validateNewPassword() onkeydown=account_validateNewPassword() /> <b><span id=dxPassWarn></span></b></td></tr>";d+="<tr><td align=right>New password:</td><td><input id=apassword2 type=password name=apassword2 autocomplete=off onchange=account_validateNewPassword() onkeyup=account_validateNewPassword() onkeydown=account_validateNewPassword() /></td></tr>";if(features&65536){d+="<tr><td align=right>Password hint:</td><td><input id=apasswordhint name=apasswordhint maxlength=250 type=text autocomplete=off onchange=account_validateNewPassword() onkeyup=account_validateNewPassword() onkeydown=account_validateNewPassword() /></td></tr>"}d+="</table>";if(passRequirements){var b=[],c=0;for(var a in passRequirements){if((a!="reset")&&(a!="hint")){b.push(a+":"+passRequirements[a]);c++}}if(c>0){d+="<br /><span style=font-size:x-small>Requirements: "+b.join(", ")+".</span>"}}d+="<br />";setDialogMode(2,"Change Password",3,account_showChangePasswordEx,d);Q("apassword0").focus();account_validateNewPassword();return false}function account_showChangePasswordEx(){if(Q("apassword1").value==Q("apassword2").value){var a={action:"changepassword",oldpass:Q("apassword0").value,newpass:Q("apassword1").value};if(features&65536){a.hint=Q("apasswordhint").value}meshserver.send(a)}}function account_createMesh(){if(xxdialogMode){return false}if((userinfo.siteadmin!=4294967295)&&((userinfo.siteadmin&64)!=0)){setDialogMode(2,"New Device Group",1,null,"This account does not have the rights to create a new device group.");return false}if((userinfo.emailVerified!==true)&&(serverinfo.emailcheck==true)&&(userinfo.siteadmin!=4294967295)){setDialogMode(2,"Account Security",1,null,'Unable to access a device until a email address is verified. This is required for password recovery. Go to the "My Account" tab to change and verify an email address.');return false}if((features&262144)&&!((userinfo.otpsecret==1)||(userinfo.otphkeys>0)||(userinfo.otpkeys>0))){setDialogMode(2,"Account Security",1,null,'Unable to access a device until two-factor authentication is enabled. This is required for extra security. Go to the "My Account" tab and look at the "Account Security" section.');return false}var a="Create a new device group using the options below.<br /><br />";a+=addHtmlValue("Name","<input id=dp2meshname style=width:230px maxlength=64 onchange=account_validateMeshCreate() onkeyup=account_validateMeshCreate(event,1) />");a+=addHtmlValue("Type","<div style=width:230px;margin:0;padding:0><select id=dp2meshtype style=width:100% onchange=account_validateMeshCreate() onkeyup=account_validateMeshCreate(event,2) ><option value=2>Manage using a software agent</option><option value=1>Intel&reg; AMT only, no agent</option></select></div>");a+=addHtmlValue("Description","<div style=width:230px;margin:0;padding:0><textarea id=dp2meshdesc maxlength=1024 style=width:100%;resize:none></textarea></div>");setDialogMode(2,"New Device Group",3,account_createMeshEx,a);account_validateMeshCreate();Q("dp2meshname").focus();return false}function account_validateMeshCreate(a,b){if((b==1)&&(a!=null)&&(a.key=="Enter")&&(Q("dp2meshname").value.length>0)){Q("dp2meshtype").focus()}if((b==2)&&(a!=null)&&(a.key=="Enter")){Q("dp2meshdesc").focus()}QE("idx_dlgOkButton",Q("dp2meshname").value.length>0)}function account_createMeshEx(a,b){meshserver.send({action:"createmesh",meshname:Q("dp2meshname").value,meshtype:Q("dp2meshtype").value,desc:Q("dp2meshdesc").value})}function account_validateDeleteAccount(){QE("account_dlgOkButton",(Q("apassword1").value.length>0)&&(Q("apassword1").value==Q("apassword2").value))}function account_validateNewPassword(){var d="",a=(Q("apassword0").value.length>0)&&(Q("apassword1").value.length>0)&&(Q("apassword1").value==Q("apassword2").value)&&(Q("apassword0").value!=Q("apassword1").value);if((features&65536)&&(Q("apasswordhint").value==Q("apassword1").value)){a=false}if(Q("apassword1").value!=""){if(passRequirements==null||passRequirements==""){var c=checkPasswordStrength(Q("apassword1").value);if(c>=80){d="<span style=color:green>Strong<span>"}else{if(c>=60){d="<span style=color:blue>Good<span>"}else{d="<span style=color:red>Weak<span>"}}}else{var b=checkPasswordRequirements(Q("apassword1").value,passRequirements);if(b==false){a=false;d="<span style=color:red>Policy<span>"}}}QH("dxPassWarn",d);QE("idx_dlgOkButton",a)}function checkPasswordStrength(e){var g=0,d={},h=0,j={digits:/\d/.test(e),lower:/[a-z]/.test(e),upper:/[A-Z]/.test(e),nonWords:/\W/.test(e)};if(!e){return 0}for(var b=0;b<e.length;b++){d[e[b]]=(d[e[b]]||0)+1;g+=5/d[e[b]]}for(var a in j){h+=(j[a]==true)?1:0}return parseInt(g+(h-1)*10)}function checkPasswordRequirements(e,g){if((g==null)||(g=="")||(typeof g!="object")){return true}if(g.min){if(e.length<g.min){return false}}if(g.max){if(e.length>g.max){return false}}var d=0,b=0,h=0,c=0;for(var a=0;a<e.length;a++){if(/\d/.test(e[a])){d++}if(/[a-z]/.test(e[a])){b++}if(/[A-Z]/.test(e[a])){h++}if(/\W/.test(e[a])){c++}}if(g.num&&(d<g.num)){return false}if(g.lower&&(b<g.lower)){return false}if(g.upper&&(h<g.upper)){return false}if(g.nonalpha&&(c<g.nonalpha)){return false}return true}function updateMeshes(){var e="";var a=0,b=0;for(i in meshes){if(a>1){e+="</tr><tr>";a=0}a++;b++;var d=0;if(meshes[i].links[userinfo._id]){d=meshes[i].links[userinfo._id].rights}var g="Partial Rights";if(d==4294967295){g="Full Administrator"}else{if(d==0){g="No Rights"}}e+="<div onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=display:inline-block;width:431px;height:50px;padding-top:1px;padding-bottom:1px;float:left><div style=float:left;width:30px;height:100%></div><div tabindex=0 style=height:100%;cursor:pointer onclick=gotoMesh('"+i+"') onkeypress=\"if (event.key=='Enter') gotoMesh('"+i+"')\"><div class=mi style=float:left;width:50px;height:50px></div><div style=height:100%><div class=g1></div><div class=e2 style=width:300px><div class=e1>"+EscapeHtml(meshes[i].name)+"</div><div>"+g+"</div></div><div class=g2 style=float:left></div></div></div></div>"}meshcount=b;QH("p2meshes",e);QV("p2noMeshFound",b==0)}function gotoMesh(a){currentMesh=meshes[a];p20updateMesh();go(20);return false}function server_showRestoreDlg(){if(xxdialogMode){return false}var a="Restore the server using a backup, <span style=color:red>this will delete the existing server data</span>. Only do this if you know what you are doing.<br /><br />";a+='<form action="/restoreserver.ashx" enctype="multipart/form-data" method="post"><div>';a+='<input id=account_dlgFileInput type=file name=datafile style=width:100% accept=".zip,application/octet-stream,application/zip,application/x-zip,application/x-zip-compressed" onchange=account_validateServerRestore()>';a+="<input id=account_dlgCancelButton type=button value=Cancel style=float:right;width:80px;margin-left:5px onclick=dialogclose(0)>";a+="<input id=account_dlgOkButton type=submit value=OK style=float:right;width:80px onclick=dialogclose(1)>";a+="</div><br /><br /></form>";setDialogMode(2,"Restore Server",0,null,a);account_validateServerRestore();return false}function account_validateServerRestore(){QE("account_dlgOkButton",Q("account_dlgFileInput").files.length==1)}function server_showVersionDlg(){if(xxdialogMode){return false}setDialogMode(2,"MeshCentral Version",1,null,"Loading...","MeshCentralServerUpdate");meshserver.send({action:"serverversion"});return false}function server_showVersionDlgUpdate(){QE("idx_dlgOkButton",Q("d2updateCheck").checked)}function server_showVersionDlgEx(){meshserver.send({action:"serverupdate"})}function server_showErrorsDlg(){if(xxdialogMode){return false}setDialogMode(2,"MeshCentral Errors",1,null,"Loading...","MeshCentralServerErrors");meshserver.send({action:"servererrors"});return false}function server_showErrorsDlgUpdate(){QE("idx_dlgOkButton",Q("d2updateCheck").checked)}function server_showErrorsDlgEx(){meshserver.send({action:"serverclearerrorlog"})}function d2CopyServerErrorsToClip(){saveAs(new Blob([Q("d2ServerErrorsLogPre").innerText],{type:"application/octet-stream"}),"servererrors.txt")}var currentMesh;function p20updateMesh(){if(currentMesh==null){return}QH("p20meshName",EscapeHtml(currentMesh.name));var m="Unknown #"+currentMesh.mtype;var l=0;try{l=currentMesh.links[userinfo._id].rights}catch(d){}if(currentMesh.mtype==1){m="Intel&reg; AMT only, no agent"}if(currentMesh.mtype==2){m="Managed using a software agent"}var t="";t+=addHtmlValue("Name",addLinkConditional(EscapeHtml(currentMesh.name),"p20editmesh(1)",(l&1)!=0));t+=addHtmlValue("Description",addLinkConditional(((currentMesh.desc&&currentMesh.desc!="")?EscapeHtml(currentMesh.desc):"<i>None</i>"),"p20editmesh(2)",(l&1)!=0));t+=addHtmlValue("Type",m);if(currentMesh.mtype==2){var h=[];if(currentMesh.flags){if(currentMesh.flags&1){h.push("Auto-Remove")}if(currentMesh.flags&2){h.push("Hostname Sync")}}h=h.join(", ");if(h==""){h="<i>None</i>"}t+=addHtmlValue("Features",addLinkConditional(h,"p20editmeshfeatures()",l&1))}if(currentMesh.mtype==2){h=[];var a=0;if(currentMesh.consent){a=currentMesh.consent}if(serverinfo.consent){a|=serverinfo.consent}if(a&8){h.push("Desktop Prompt")}else{if(a&1){h.push("Desktop Notify")}}if(a&16){h.push("Terminal Prompt")}else{if(a&2){h.push("Terminal Notify")}}if(a&32){h.push("Files Prompt")}else{if(a&4){h.push("Files Notify")}}if(a==7){h=["Always Notify"]}if((a&56)==56){h=["Always Prompt"]}h=h.join(", ");if(h==""){h="<i>None</i>"}t+=addHtmlValue("User Consent",addLinkConditional(h,"p20editmeshconsent()",l&1))}var j=0,k=[];if(userinfo.links&&userinfo.links[currentMesh._id]&&userinfo.links[currentMesh._id].notify){j=userinfo.links[currentMesh._id].notify}if(j&2){k.push("Connect")}if(j&4){k.push("Disconnect")}if(j&8){k.push("Intel&reg; AMT")}if(k.length==0){k.push("None")}t+=addHtmlValue("Notifications",addLink(k.join(", "),"p20editMeshNotify()"));var g="No Policy";if(currentMesh.amt){if(currentMesh.amt.type==1){g="Deactivate Client Control Mode (CCM)"}else{if(currentMesh.amt.type==2){g="Simple Client Control Mode (CCM)";if(currentMesh.amt.cirasetup==2){g+=" + CIRA"}}else{if(currentMesh.amt.type==3){g="Simple Admin Control Mode (ACM)";if(currentMesh.amt.cirasetup==2){g+=" + CIRA"}}}}}t+=addHtmlValue("Intel&reg; AMT",addLinkConditional(g,"p20editMeshAmt()",l&1));if(l&1){t+='<br><input type=button value=Notes title="View notes about this device group" onclick=showNotes(false,"'+encodeURIComponent(currentMesh._id)+'") />'}t+="<br style=clear:both><br>";var c=currentMesh.links[userinfo._id];if(c&&((c.rights&2)!=0)){t+='<a href=# onclick="return p20showAddMeshUserDialog()" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add Users</a>'}if((l&4)!=0){if(currentMesh.mtype==1){t+="<a href=# onclick='return addCiraDeviceToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Add a new Intel&reg; AMT computer that is located on the internet."><img src=images/icon-installmesh.png border=0 height=12 width=12> Install CIRA</a>';t+="<a href=# onclick='return addDeviceToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Add a new Intel&reg; AMT computer that is located on the local network."><img src=images/icon-installmesh.png border=0 height=12 width=12> Install local</a>';if(currentMesh.amt&&(currentMesh.amt.type==2)){t+="<a href=# onclick='return showCcmActivation(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Perform Intel AMT client control mode (CCM) activation."><img src=images/icon-installmesh.png border=0 height=12 width=12> Activation</a>'}else{if(currentMesh.amt&&(currentMesh.amt.type==3)&&((features&1048576)!=0)){t+="<a href=# onclick='return showAcmActivation(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Perform Intel AMT admin control mode (ACM) activation."><img src=images/icon-installmesh.png border=0 height=12 width=12> Activation</a>'}}}if(currentMesh.mtype==2){t+="<a href=# onclick='return addAgentToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Add a new computer to this mesh by installing the mesh agent."><img src=images/icon-addnew.png border=0 height=12 width=12> Install</a>';t+="<a href=# onclick='return inviteAgentToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Invite someone to install the mesh agent on this mesh."><img src=images/icon-addnew.png border=0 height=12 width=12> Invite</a>'}}t+='<table style="color:black;background-color:#EEE;border-color:#AAA;border-width:1px;border-style:solid;border-collapse:collapse" border=0 cellpadding=2 cellspacing=0 width=100%><tbody><tr style=background-color:#AAAAAA;font-weight:bold><th scope=col style=text-align:left;width:430px>User Authorizations</th><th scope=col style=text-align:left></th></tr>';var b=1,p=[];for(var e in currentMesh.links){var s=e.split("/")[2];if(currentMesh.links[e].name){s=currentMesh.links[e].name}if(e==userinfo._id){s=userinfo.name}p.push({id:e,name:s,rights:currentMesh.links[e].rights})}p.sort(function(r,u){if(r.name>u.name){return 1}if(r.name<u.name){return -1}return 0});for(var e in p){var q="",o="Partial Rights",n=p[e].rights;if(n==4294967295){o="Full Administrator"}else{if(n==0){o="No Rights"}}if((p[e].id!=userinfo._id)&&(l==4294967295||(((l&2)!=0)))){q="<a href=# onclick='return p20deleteUser(event,\""+encodeURIComponent(p[e].id)+'")\' title="Remote user rights to this mesh" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>'}t+='<tr tabindex=0 onclick=p20viewuser("'+encodeURIComponent(p[e].id)+"\") onkeypress=\"if (event.key=='Enter') p20viewuser('"+encodeURIComponent(p[e].id)+"')\" style=cursor:pointer"+(((b%2)==0)?";background-color:#DDD":"")+'><td><div title="User" class=m2></div><div>&nbsp;'+EscapeHtml(decodeURIComponent(p[e].name))+"<div></div></div></td><td><div style=float:right>"+q+"</div><div>"+o+"</div></td></tr>";++b}t+="</tbody></table>";if(l==4294967295){t+="<div style=font-size:x-small;text-align:right><span><a href=# onclick=p20showDeleteMeshDialog() style=cursor:pointer>Delete Group</a></span></div>"}QH("p20info",t)}function p20editMeshAmt(){if(xxdialogMode){return}var b="",a="";if((features&1048576)!=0){a="<option value=3>Simple Admin Control Mode (ACM)</option>"}if(currentMesh.mtype==1){b+=addHtmlValue("Type","<select id=dp20amtpolicy style=width:230px onchange=p20editMeshAmtChange()><option value=0>No Policy</option><option value=2>Simple Client Control Mode (CCM)</option>"+a+"</select>")}else{b+=addHtmlValue("Type","<select id=dp20amtpolicy style=width:230px onchange=p20editMeshAmtChange()><option value=0>No Policy</option><option value=1>Deactivate Client Control Mode (CCM)</option><option value=2>Simple Client Control Mode (CCM)</option>"+a+"</select>")}b+="<div id=dp20amtpolicydiv></div>";setDialogMode(2,"Intel&reg; AMT Policy",3,p20editMeshAmtEx,b);if(currentMesh.amt){Q("dp20amtpolicy").value=currentMesh.amt.type}p20editMeshAmtChange();if(currentMesh.amt&&(currentMesh.amt.type==2)||(currentMesh.amt.type==3)){Q("dp20amtpolicypass").value=currentMesh.amt.password;if((currentMesh.amt.type==2)&&(currentMesh.amt.badpass!=null)){Q("dp20amtbadpass").value=currentMesh.amt.badpass}if((features&1024)==0){Q("dp20amtcira").value=currentMesh.amt.cirasetup}}dp20amtValidatePolicy()}function p20editMeshAmtChange(){var a=Q("dp20amtpolicy").value,b="";if(a>=2){b=addHtmlValue("Password*","<input id=dp20amtpolicypass type=password style=width:230px maxlength=32 onchange=dp20amtValidatePolicy() onkeyup=dp20amtValidatePolicy() autocomplete=off />");b+=addHtmlValue("Password*","<input id=dp20amtpolicypass2 type=password style=width:230px maxlength=32 onchange=dp20amtValidatePolicy() onkeyup=dp20amtValidatePolicy() autocomplete=off />");if((a==2)&&(currentMesh.mtype==2)){b+=addHtmlValue("Password mismatch","<select id=dp20amtbadpass style=width:230px><option value=0>Do nothing</option><option value=1>Reactivate Intel&reg; AMT</option></select>")}if((features&1024)==0){if(a==2){b+=addHtmlValue('<span title="Client Initiated Remote Access">CIRA</span>',"<select id=dp20amtcira style=width:230px><option value=0>Don't configure</option><option value=1>Don't connect to server</option><option value=2>Connect to server</option></select>")}else{b+=addHtmlValue('<span title="Client Initiated Remote Access">CIRA</span>',"<select id=dp20amtcira style=width:230px><option value=0>Don't configure</option><option value=2>Connect to server</option></select>")}}b+='<br/><span style="font-size:10px">* Leave blank to assign a random password to each device.</span><br/>';if(currentMesh.mtype==2){if(a==2){b+='<span style="font-size:10px">This policy will not impact devices with Intel&reg; AMT in ACM mode.</span><br/>';b+='<span style="font-size:10px">This is not a secure policy as agents will be performing activation.</span>'}else{b+='<span style="font-size:10px">During activation, the agent will have access to admin password infomation.</span>'}}}QH("dp20amtpolicydiv",b);setTimeout(dp20amtValidatePolicy,1)}function dp20amtValidatePolicy(){var a=true,d=Q("dp20amtpolicy").value;if((d==2)||(d==3)){var b=Q("dp20amtpolicypass").value,c=Q("dp20amtpolicypass2").value;a=((b===c)&&((b==="")?true:passwordcheck(b)))}QE("idx_dlgOkButton",a)}function p20editMeshAmtEx(){var b=parseInt(Q("dp20amtpolicy").value),a={type:b};if(b==2){a={type:b,password:Q("dp20amtpolicypass").value};if(currentMesh.mtype==2){a.badpass=parseInt(Q("dp20amtbadpass").value)}if((features&1024)==0){a.cirasetup=parseInt(Q("dp20amtcira").value)}else{a.cirasetup=1}}else{if(b==3){a={type:b,password:Q("dp20amtpolicypass").value};if((features&1024)==0){a.cirasetup=parseInt(Q("dp20amtcira").value)}else{a.cirasetup=1}}}meshserver.send({action:"meshamtpolicy",meshid:currentMesh._id,amtpolicy:a})}function p20showDeleteMeshDialog(){if(xxdialogMode){return false}var a='Are you sure you want to delete group "'+EscapeHtml(currentMesh.name)+'"? Deleting the device group will also delete all information about devices within this group.<br /><br />';a+="<label><input id=p20check type=checkbox onchange=p20validateDeleteMeshDialog() />Confirm</label>";setDialogMode(2,"Delete Group",3,p20showDeleteMeshDialogEx,a);p20validateDeleteMeshDialog();return false}function p20validateDeleteMeshDialog(){QE("idx_dlgOkButton",Q("p20check").checked)}function p20showDeleteMeshDialogEx(a,b){meshserver.send({action:"deletemesh",meshid:currentMesh._id,meshname:currentMesh.name})}function p20editmesh(a){if(xxdialogMode){return}var b=addHtmlValue("Name","<input id=dp20meshname style=width:230px maxlength=32 onchange=p20editmeshValidate() onkeyup=p20editmeshValidate(event) />");b+=addHtmlValue("Description","<div style=width:230px;margin:0;padding:0><textarea id=dp20meshdesc maxlength=1024 style=width:100%;resize:none></textarea></div>");setDialogMode(2,"Edit Device Group",3,p20editmeshEx,b);Q("dp20meshname").value=currentMesh.name;if(currentMesh.desc){Q("dp20meshdesc").value=currentMesh.desc}p20editmeshValidate();if(a==2){Q("dp20meshdesc").focus()}else{Q("dp20meshname").focus()}}function p20editmeshEx(){meshserver.send({action:"editmesh",meshid:currentMesh._id,meshname:Q("dp20meshname").value,desc:Q("dp20meshdesc").value})}function p20editmeshValidate(a){QE("idx_dlgOkButton",Q("dp20meshname").value.length>0);if(a&&a.key=="Enter"){Q("dp20meshdesc").focus()}}function p20editmeshconsent(){if(xxdialogMode){return}var b="",a=(currentMesh.consent)?currentMesh.consent:0;b+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px"><b>Desktop</b></div>';b+="<div><label><input type=checkbox id=d20flag1 "+((a&1)?"checked":"")+">Notify user</label></div>";b+="<div><label><input type=checkbox id=d20flag2 "+((a&8)?"checked":"")+">Prompt for user consent</label></div>";b+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:8px"><b>Terminal</b></div>';b+="<div><label><input type=checkbox id=d20flag3 "+((a&2)?"checked":"")+">Notify user</label></div>";b+="<div><label><input type=checkbox id=d20flag4 "+((a&16)?"checked":"")+">Prompt for user consent</label></div>";b+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:8px"><b>Files</b></div>';b+="<div><label><input type=checkbox id=d20flag5 "+((a&4)?"checked":"")+">Notify user</label></div>";b+="<div><label><input type=checkbox id=d20flag6 "+((a&32)?"checked":"")+">Prompt for user consent</label></div>";setDialogMode(2,"Edit Device Group User Consent",3,p20editmeshconsentEx,b);if(serverinfo.consent){if(serverinfo.consent&1){Q("d20flag1").checked=true}if(serverinfo.consent&8){Q("d20flag2").checked=true}if(serverinfo.consent&2){Q("d20flag3").checked=true}if(serverinfo.consent&16){Q("d20flag4").checked=true}if(serverinfo.consent&4){Q("d20flag5").checked=true}if(serverinfo.consent&32){Q("d20flag6").checked=true}QE("d20flag1",!(serverinfo.consent&1));QE("d20flag2",!(serverinfo.consent&8));QE("d20flag3",!(serverinfo.consent&2));QE("d20flag4",!(serverinfo.consent&16));QE("d20flag5",!(serverinfo.consent&4));QE("d20flag6",!(serverinfo.consent&32))}}function p20editmeshconsentEx(){var a=0;if(Q("d20flag1").checked){a+=1}if(Q("d20flag2").checked){a+=8}if(Q("d20flag3").checked){a+=2}if(Q("d20flag4").checked){a+=16}if(Q("d20flag5").checked){a+=4}if(Q("d20flag6").checked){a+=32}meshserver.send({action:"editmesh",meshid:currentMesh._id,consent:a})}function p20editmeshfeatures(){if(xxdialogMode){return}var a=(currentMesh.flags)?currentMesh.flags:0;var b="<div><label><input type=checkbox id=d20flag1 "+((a&1)?"checked":"")+">Remove device on disconnect</label><br></div>";b+="<div><label><input type=checkbox id=d20flag2 "+((a&2)?"checked":"")+">Sync server device name to hostname</label><br></div>";setDialogMode(2,"Edit Device Group Features",3,p20editmeshfeaturesEx,b)}function p20editmeshfeaturesEx(){var a=0;if(Q("d20flag1").checked){a+=1}if(Q("d20flag2").checked){a+=2}meshserver.send({action:"editmesh",meshid:currentMesh._id,flags:a})}function p20showAddMeshUserDialog(d){if(xxdialogMode){return false}var e="";if(d==null){e+="Allow users to manage this device group and devices in this group.";if(features&524288){e+=" Users need to login to this server once before they can be added to a device group."}e+="<br /><br /><div style='position:relative'>";e+=addHtmlValue("User Names",'<input id=dp20username style=width:230px maxlength=32 onchange=p20validateAddMeshUserDialog() onkeyup=p20validateAddMeshUserDialog() placeholder="user1, user2, user3" />');e+="<div id=dp20usersuggest class=suggestionBox style='top:30px;left:130px;display:none'></div>";e+="</div><br>"}else{d=decodeURIComponent(d);var c=d.split("/")[2];if(users&&users[d]){c=users[d].name}if(userinfo._id==d){c=userinfo.name}e+="Group permissions for user "+c+".<br /><br />"}e+='<div style="height:120px;overflow-y:scroll;border:1px solid gray">';e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20fulladmin>Full Administrator</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editmesh>Edit Device Group</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20manageusers>Manage Device Group Users</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20managecomputers>Manage Device Group Computers</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remotecontrol>Remote Control</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remoteview style=margin-left:12px>Remote View Only</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remotelimitedinput style=margin-left:12px>Limited Input Only</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20noterminal style=margin-left:12px>No Terminal Access</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20nofiles style=margin-left:12px>No File Access</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20noamt style=margin-left:12px>No Intel&reg; AMT</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20meshagentconsole>Mesh Agent Console</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20meshserverfiles>Server Files</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20wakedevices>Wake Devices</label><br>";e+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editnotes>Edit Device Notes</label><br>";e+="</div>";if(d==null){setDialogMode(2,"Add Users to Device Group",3,p20showAddMeshUserDialogEx,e);Q("dp20username").focus()}else{setDialogMode(2,"Edit User Device Group Permissions",7,p20showAddMeshUserDialogEx,e,d);var a=currentMesh.links[userinfo._id].rights,b=currentMesh.links[d].rights;if(b==4294967295){Q("p20fulladmin").checked=true}else{if(b&1){Q("p20editmesh").checked=true}if(b&2){Q("p20manageusers").checked=true}if(b&4){Q("p20managecomputers").checked=true}if(b&8){Q("p20remotecontrol").checked=true;if(b&256){Q("p20remoteview").checked=true}if(b&512){Q("p20remotelimitedinput").checked=true}if(b&1024){Q("p20noterminal").checked=true}if(b&2048){Q("p20nofiles").checked=true}if(b&4096){Q("p20noamt").checked=true}}if(b&16){Q("p20meshagentconsole").checked=true}if(b&32){Q("p20meshserverfiles").checked=true}if(b&64){Q("p20wakedevices").checked=true}if(b&128){Q("p20editnotes").checked=true}}}p20validateAddMeshUserDialog();return false}function p20setname(b){b=decodeURIComponent(b);var c=Q("dp20username").value.split(",");for(var a in c){c[a]=c[a].trim()}c[c.length-1]=b;Q("dp20username").value=c.join(", ");p20validateAddMeshUserDialog();return false}function p20validateAddMeshUserDialog(){var g=currentMesh.links[userinfo._id].rights;var h=true,m=null;if(Q("dp20username")){Q("dp20username").value.split(",");for(var b in m){var l=m[b]=m[b].trim();if(l.length==0){h=false}else{if(l.indexOf('"')>=0){h=false}}}var j=false,a=false;if(users!=null){var c=m[m.length-1].trim(),d=c.toLowerCase(),e=[];if(c.length>0){for(var b in users){if(users[b].name===c){a=true;break}if(users[b].name.toLowerCase().indexOf(d)>=0){e.push(users[b].name);if(e.length>=8){break}}}if((a==false)&&(e.length>0)){var k="";for(var b in e){k+="<a href=# onclick='p20setname(\""+encodeURIComponent(e[b])+"\")'>"+e[b]+"</a><br />"}QH("dp20usersuggest",k);j=true}}}QV("dp20usersuggest",j)}QE("idx_dlgOkButton",h);QE("p20fulladmin",g==4294967295);QE("p20editmesh",(!Q("p20fulladmin").checked)&&(g==4294967295));QE("p20manageusers",!Q("p20fulladmin").checked);QE("p20managecomputers",!Q("p20fulladmin").checked);QE("p20remotecontrol",!Q("p20fulladmin").checked);QE("p20meshagentconsole",!Q("p20fulladmin").checked);QE("p20meshserverfiles",!Q("p20fulladmin").checked);QE("p20wakedevices",!Q("p20fulladmin").checked);QE("p20editnotes",!Q("p20fulladmin").checked);QE("p20remoteview",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20remotelimitedinput",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked&&!Q("p20remoteview").checked);QE("p20noterminal",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20nofiles",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20noamt",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked)}function p20showAddMeshUserDialogEx(a,e){if(a==2){p20viewuserEx(a,e)}else{var d=0;if(Q("p20fulladmin").checked==true){d=4294967295}else{if(Q("p20editmesh").checked==true){d+=1}if(Q("p20manageusers").checked==true){d+=2}if(Q("p20managecomputers").checked==true){d+=4}if(Q("p20remotecontrol").checked==true){d+=8}if(Q("p20meshagentconsole").checked==true){d+=16}if(Q("p20meshserverfiles").checked==true){d+=32}if(Q("p20wakedevices").checked==true){d+=64}if(Q("p20editnotes").checked==true){d+=128}if(Q("p20remoteview").checked==true){d+=256}if(Q("p20noterminal").checked==true){d+=512}if(Q("p20nofiles").checked==true){d+=1024}if(Q("p20noamt").checked==true){d+=2048}if(Q("p20remotelimitedinput").checked==true){d+=4096}}if(e==null){var g=Q("dp20username").value.split(","),h=[];for(var c in g){h.push(g[c].trim())}meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,usernames:h,meshadmin:d})}else{meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,usernames:[e.split("/")[2]],meshadmin:d})}}}function p20viewuser(g){if(xxdialogMode){return}var j=decodeURIComponent(g);var b=currentMesh.links[userinfo._id].rights,c=currentMesh.links[j].rights;if(((userinfo._id)!=j)&&(b==4294967295||(((b&2)!=0)&&(c!=4294967295)))){p20showAddMeshUserDialog(g)}else{var d="";if(c==4294967295){d=", Full Administrator (all rights)"}else{if((c&1)!=0){d+=", Edit Device Group"}if((c&2)!=0){d+=", Manage Device Group Users"}if((c&4)!=0){d+=", Manage Device Group Computers"}if((c&8)!=0){d+=", Remote Control"}if((c&16)!=0){d+=", Agent Console"}if((c&32)!=0){d+=", Server Files"}if((c&64)!=0){d+=", Wake Devices"}if((c&128)!=0){d+=", Edit Notes"}if(((c&8)!=0)&&(c&256)!=0){d+=", Remote View Only"}if(((c&8)!=0)&&(c&512)!=0){d+=", No Terminal"}if(((c&8)!=0)&&(c&1024)!=0){d+=", No Files"}if(((c&8)!=0)&&(c&2048)!=0){d+=", No Intel&reg; AMT"}if(((c&8)!=0)&&((c&4096)!=0)&&((c&256)==0)){d+=", Limited Input"}}d=d.substring(2);if(d==""){d="No Rights"}var e=j.split("/")[2];if(users&&users[j]){e=users[j].name}if(userinfo._id==j){e=userinfo.name}var a=1,h=addHtmlValue("User Name",EscapeHtml(decodeURIComponent(e)));if(j.split("/")[2]!=e){h+=addHtmlValue("User Identifier",EscapeHtml(j.split("/")[2]))}h+=addHtmlValue("Permissions",d);if(((userinfo._id)!=j)&&(b==4294967295||(((b&2)!=0)&&(c!=4294967295)))){a+=4}setDialogMode(2,"Device Group User",a,p20viewuserEx,h,j)}}function p20viewuserEx(a,c){if(a!=2){return}var b=c.split("/")[2];if(users&&users[c]){b=users[c].name}if(userinfo._id==c){b=userinfo.name}setDialogMode(2,"Remote Mesh User",3,p20viewuserEx2,"Confirm removal of user "+EscapeHtml(decodeURIComponent(b))+"?",c)}function p20deleteUser(a,b){haltEvent(a);p20viewuserEx(2,decodeURIComponent(b));return false}function p20viewuserEx2(a,b){meshserver.send({action:"removemeshuser",meshid:currentMesh._id,meshname:currentMesh.name,userid:b})}function p20editMeshNotify(){if(xxdialogMode){return false}var a=0;if(userinfo.links&&userinfo.links[currentMesh._id]&&userinfo.links[currentMesh._id].notify){a=userinfo.links[currentMesh._id].notify}var b="";b+="<div><label><input id=p20notifyIntelDeviceConnect type=checkbox />Device connections.</label></div>";b+="<div><label><input id=p20notifyIntelDeviceDisconnect type=checkbox />Device disconnections.</label></div>";b+="<div><label><input id=p20notifyIntelAmtKvmActions type=checkbox />Intel&reg; AMT desktop and serial events.</label></div>";setDialogMode(2,"Notification Settings",3,p20editMeshNotifyEx,b);Q("p20notifyIntelDeviceConnect").checked=(a&2);Q("p20notifyIntelDeviceDisconnect").checked=(a&4);Q("p20notifyIntelAmtKvmActions").checked=(a&8);return false}function p20editMeshNotifyEx(){var a=0;a+=Q("p20notifyIntelDeviceConnect").checked?2:0;a+=Q("p20notifyIntelDeviceDisconnect").checked?4:0;a+=Q("p20notifyIntelAmtKvmActions").checked?8:0;meshserver.send({action:"changemeshnotify",meshid:currentMesh._id,notify:a})}var filetreelinkpath;var filetreelocation=[];function updateFiles(){QV("MainMenuMyFiles",((features&8)==0));if((features&8)!=0){return}var q="",r="",c='<a href=# style=cursor:pointer onclick="return p5folderup(0)">Root</a>',o="Root",y,k=filetree,m=1;var j=[],v=filetreelinkpath,b=[],a=document.getElementsByName("fc");for(var s=0;s<a.length;s++){if(a[s].checked){b.push(a[s].value)}}filetreelinkpath="";for(var s in filetreelocation){if((k.f!=null)&&(k.f[filetreelocation[s]]!=null)){j.push(filetreelocation[s]);o+=" / "+filetreelocation[s];if((m==1)){var B=filetreelocation[s].split("/");y=window.location+B[0]+"files/"+B[2];filetreelinkpath+=filetreelocation[s]}else{if(filetreelinkpath!=""){filetreelinkpath+="/"+filetreelocation[s];if(m>2){y+="/"+filetreelocation[s]}}}k=k.f[filetreelocation[s]];c+=' / <a href=# style=cursor:pointer onclick="return p5folderup('+m+')">'+(k.n!=null?k.n:filetreelocation[s])+"</a>";m++}else{break}}filetreelocation=j;var w=o.toLowerCase().startsWith("root / "+userinfo._id+" / public");var l=p5sort_files(k.f);for(var s in l){var d=l[s],u=d.n,A;A=u;if(u.length>70){A='<span title="'+EscapeHtml(u)+'">'+EscapeHtml(u.substring(0,70))+"...</span>"}else{A=EscapeHtml(u)}u=EscapeHtml(u);var g="";if(d.d!=null){var e=new Date(d.d),g=printDateTime(e)+"&nbsp;"}var n="";if(d.s!=null){n=getFileSizeStr(d.s)}var p="";if(d.t<3||d.t==4){var z=(d.t==1||d.t==4)?p5getQuotabar(d):"",C="";p="<div class=filelist file=999><input file=999 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value='"+u+"'>&nbsp;<span style=float:right title=\""+C+'">'+z+"</span><span><div class=fileIcon"+d.t+' onclick=p5folderset("'+encodeURIComponent(d.nx)+'")></div><a href=# style=cursor:pointer onclick=\'return p5folderset("'+encodeURIComponent(d.nx)+"\")'>"+A+"</a></span></div>"}else{var t=A;var x="";if(w){x=' (<a href=# style=cursor:pointer title="Display public link" onclick=\'return p5showPublicLink("'+y+"/"+d.nx+"\")'>Link</a>)"}if(d.s>0){t='<a rel="noreferrer noopener" target="_blank" href="downloadfile.ashx?link='+encodeURIComponent(filetreelinkpath+"/"+d.nx)+'">'+A+"</a>"+x}p="<div class=filelist file=3><input file=3 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value='"+d.nx+"'>&nbsp;<span class=fsize>"+g+"</span><span style=float:right>"+n+"</span><span><div class=fileIcon"+d.t+"></div>"+t+"</span></div>"}if(d.t<3){q+=p}else{r+=p}}QH("p5rightOfButtons",p5getQuotabar(k));QH("p5files",q+r);QH("p5currentpath",c);QE("p5FolderUp",filetreelocation.length!=0);QV("p5PublicShare",w);if(v==filetreelinkpath){a=document.getElementsByName("fc");for(var s=0;s<a.length;s++){a[s].checked=(b.indexOf(a[s].value)>=0)}}p5setActions()}function getNiceSize(a){if(a<=0){return"Storage limit exceed"}if(a<2048){return a+" bytes remaining"}if(a<2097152){return Math.round(a/1024)+" kilobytes remaining"}if(a<2147483648){return Math.round(a/1024/1024)+" megabytes remaining"}return Math.round(a/1024/1024/1024)+" gigabytes remaining"}function getNiceSize2(a){if(a<=0){return"None"}if(a<2048){return a+" b"}if(a<2097152){return Math.round(a/1024)+" Kb"}if(a<2147483648){return Math.round(a/1024/1024)+" Mb"}return Math.round(a/1024/1024/1024)+" Gb"}function p5getQuotabar(a){while(a.t>1&&a.t!=4){a=a.parent}if((a.t!=1&&a.t!=4)||(a.maxbytes==null)){return""}var b=Math.floor(a.s/1024),c=(a.maxbytes-a.s);return'<span title="'+b+"k in "+a.c+" file"+(a.c>1?"s":"")+". "+(Math.floor(a.maxbytes/1024/1024))+'k maxinum">'+getNiceSize(c)+" <progress style=height:10px;width:100px value="+a.s+" max="+a.maxbytes+" /></span>"}function p5showPublicLink(a){setDialogMode(2,"Public Link",1,null,'<input type=text style=width:100% value="'+a+'" readonly />')}var sortorder;function p5sort_filename(c,d){if(c.ln>d.ln){return(1*sortorder)}if(c.ln<d.ln){return(-1*sortorder)}return 0}function p5sort_timestamp(c,d){if(c.d>d.d){return(1*sortorder)}if(c.d<d.d){return(-1*sortorder)}return 0}function p5sort_bysize(c,d){if(c.s==d.s){return p5sort_filename(c,d)}return(((c.s-d.s))*sortorder)}function p5sort_files(a){var c=[],d=Q("p5sortdropdown").value;for(var b in a){a[b].nx=b;if(a[b].n==null){a[b].n=b}a[b].ln=a[b].n.toLowerCase();c.push(a[b])}sortorder=1;if(d>3){sortorder=-1;d-=3}if(d==1){c.sort(p5sort_filename)}else{if(d==2){c.sort(p5sort_bysize)}else{if(d==3){c.sort(p5sort_timestamp)}}}return c}function p5setActions(){var a=getFileSelCount(),c=getFileCount(),b=getFileSelCount(false);QE("p5DeleteFileButton",(a>0)&&(filetreelocation.length>0));QE("p5NewFolderButton",filetreelocation.length>0);QE("p5UploadButton",filetreelocation.length>0);QE("p5RenameFileButton",(a==1)&&(filetreelocation.length>0));QE("p5SelectAllButton",c>0);Q("p5SelectAllButton").value=(a>0?"Select None":"Select All");QE("p5CutButton",(b>0)&&(a==b));QE("p5CopyButton",(b>0)&&(a==b));QE("p5PasteButton",(p5clipboard!=null)&&(p5clipboard.length>0)&&(filetreelocation.length>0))}function getFileSelCount(d){var a=0,b=document.getElementsByName("fc");for(var c=0;c<b.length;c++){if((b[c].checked)&&((d!=false)||(b[c].attributes.file.value=="3"))){a++}}return a}function getFileSelDirCount(){var a=0,b=document.getElementsByName("fc");for(var c=0;c<b.length;c++){if((b[c].checked)&&(b[c].attributes.file.value=="999")){a++}}return a}function getFileCount(){var a=0;var b=document.getElementsByName("fc");return b.length}function p5selectallfile(){var c=(getFileSelCount()==0),a=document.getElementsByName("fc");for(var b=0;b<a.length;b++){a[b].checked=c}p5setActions()}function setupBackPointers(d){if(d.f!=null){var b=0,a=0;for(var c in d.f){setupBackPointers(d.f[c]);d.f[c].parent=d;if(d.f[c].s){b+=d.f[c].s}if(d.f[c].c){a+=d.f[c].c}if(d.f[c].t==3){a++}}d.s=b;d.c=a}return d}function getFileSizeStr(a){if(a==1){return"1 byte"}return""+a+" bytes"}function p5folderup(a){if(a==null){filetreelocation.pop()}else{while(filetreelocation.length>a){filetreelocation.pop()}}updateFiles();return false}function p5folderset(a){filetreelocation.push(decodeURIComponent(a));updateFiles()}function p5createfolder(){setDialogMode(2,"New Folder",3,p5createfolderEx,"<input type=text id=p5renameinput maxlength=64 onkeyup=p5fileNameCheck(event) style=width:100% />");focusTextBox("p5renameinput");p5fileNameCheck()}function p5createfolderEx(){meshserver.send({action:"fileoperation",fileop:"createfolder",path:filetreelocation,newfolder:Q("p5renameinput").value})}function p5deletefile(){var a=getFileSelCount(),b=(getFileSelDirCount()>0)?"<br /><br /><label><input type=checkbox id=p5recdeleteinput>Recursive delete</label><br>":"<input type=checkbox id=p5recdeleteinput style='display:none'>";setDialogMode(2,"Delete",3,p5deletefileEx,(a>1)?("Delete "+a+" selected items?"+b):("Delete selected item?"+b))}function p5deletefileEx(){var b=[],a=document.getElementsByName("fc");for(var c=0;c<a.length;c++){if(a[c].checked){b.push(a[c].value)}}meshserver.send({action:"fileoperation",fileop:"delete",path:filetreelocation,delfiles:b,rec:Q("p5recdeleteinput").checked})}function p5renamefile(){var c,a=document.getElementsByName("fc");for(var b=0;b<a.length;b++){if(a[b].checked){c=a[b].value}}setDialogMode(2,"Rename",3,p5renamefileEx,'<input type=text id=p5renameinput maxlength=64 onkeyup=p5fileNameCheck(event) style=width:100% value="'+c+'" />',{action:"fileoperation",fileop:"rename",path:filetreelocation,oldname:c});focusTextBox("p5renameinput");p5fileNameCheck()}function p5renamefileEx(a,c){c.newname=Q("p5renameinput").value;meshserver.send(c)}function p5fileNameCheck(a){var b=isFilenameValid(Q("p5renameinput").value);QE("idx_dlgOkButton",b);if((b==true)&&(a&&a.keyCode==13)){dialogclose(1)}}var isFilenameValid=(function(){var b=/^[^\\/:\*\?"<>\|]+$/,c=/^\./,d=/^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i;return function a(e){return b.test(e)&&!c.test(e)&&!d.test(e)&&(e[0]!=".")}})();function p5uploadFile(){setDialogMode(2,"Upload File",3,p5uploadFileEx,'<form method=post enctype=multipart/form-data action=uploadfile.ashx target=fileUploadFrame><input type=text name=link style=display:none id=p5uploadpath value="'+encodeURIComponent(filetreelinkpath)+'" /><input type=file name=files id=p5uploadinput style=width:100% multiple=multiple onchange="updateUploadDialogOk(\'p5uploadinput\')" /><input type=submit id=p5loginSubmit style=display:none /></form>');updateUploadDialogOk("p5uploadinput")}function p5uploadFileEx(){Q("p5loginSubmit").click()}function updateUploadDialogOk(a){QE("idx_dlgOkButton",Q(a).value!="")}var p5clipboard=null,p5clipboardFolder=null,p5clipboardCut=0;function p5copyFile(b){var a=document.getElementsByName("fc");p5clipboard=[];p5clipboardCut=b,p5clipboardFolder=Clone(filetreelocation);for(var c=0;c<a.length;c++){if((a[c].checked)&&(a[c].attributes.file.value=="3")){p5clipboard.push(a[c].value)}}p5updateClipview()}function p5pasteFile(){var a="";if((p5clipboard!=null)&&(p5clipboard.length>0)){a="Confim "+(p5clipboardCut==0?"copy":"move")+" of "+p5clipboard.length+" entrie"+((p5clipboard.length>1)?"s":"")+" to this location?"}setDialogMode(2,"Paste",3,p5pasteFileEx,a)}function p5pasteFileEx(){meshserver.send({action:"fileoperation",fileop:(p5clipboardCut==0?"copy":"move"),scpath:p5clipboardFolder,path:filetreelocation,names:p5clipboard});p5folderup(999);if(p5clipboardCut==1){p5clipboard=null,p5clipboardFolder=null,p5clipboardCut=0;p5updateClipview()}}function p5updateClipview(){var a="";if((p5clipboard!=null)&&(p5clipboard.length>0)){a="Holding "+p5clipboard.length+" entrie"+((p5clipboard.length>1)?"s":"")+" for "+(p5clipboardCut==0?"copy":"move")+', <a href=# onclick="return p5clearClip()" style=cursor:pointer>Clear</a>.'}QH("p5bottomstatus",a);p5setActions()}function p5clearClip(){p5clipboard=null;p5clipboardFolder=null;p5clipboardCut=0;p5updateClipview();return false}function p5fileDragDrop(b){if(xxdialogMode){return}haltEvent(b);QV("bigfail",false);QV("bigok",false);var c=0;p5uploadFile();try{Q("p5uploadinput").files=b.dataTransfer.files}catch(d){c=1}if(c==0){p5uploadFileEx()}setDialogMode(0);if(c==1){if(b.dataTransfer==null||b.dataTransfer.files.length==0||filetreelocation.length==0){return}var j=[],m=[],o=[],a=[],l=b.dataTransfer.files.length,n=0;for(var h=0;h<b.dataTransfer.files.length;h++){n+=b.dataTransfer.files[h].size}if(n>1300000){p5uploadFile();return}for(var h=0;h<b.dataTransfer.files.length;h++){var k=new FileReader(),g=b.dataTransfer.files[h];j.push(g.name);m.push(g.size);o.push(g.type);k.onload=function(e){a.push(e.target.result);if(--l==0){Q("p5fileDragName").value=j.join("*");Q("p5fileDragSize").value=m.join("*");Q("p5fileDragType").value=o.join("*");Q("p5fileDragData").value=a.join("*");Q("p5fileDragLink").value=encodeURIComponent(filetreelinkpath);Q("p5loginSubmit2").click()}};k.readAsDataURL(g)}}}var p5dragtimer=null;function p5fileDragOver(b){if(xxdialogMode){return}haltEvent(b);if(p5dragtimer!=null){clearTimeout(p5dragtimer);p5dragtimer=null}var a=true;if(filetreelocation.length==0){a=false}QV("bigok",a);QV("bigfail",!a)}function p5fileDragLeave(a){if(xxdialogMode){return}haltEvent(a);if(a.target.id!="p5filetable"){QV("bigfail",false);QV("bigok",false)}else{p5dragtimer=setTimeout(function(){QV("bigfail",false);QV("bigok",false);p5dragtimer=null},10)}}function eventMouseHover(a,b){a.children[1].classList.remove("g1s");a.children[2].style["background-color"]=((b==0)?"#c9c9c9":"#b9b9b9");a.children[3].classList.remove("g2s");if(b==1){a.children[1].classList.add("g1s");a.children[3].classList.add("g2s")}}function eventsUpdate(){var h="",a=null;for(var c in events){var b=events[c],g=new Date(b.time);if(b.msg){if(printDate(g)!=a){if(a!=null){h+="</table>"}a=printDate(g);h+="<table class=p3eventsTable cellpadding=0 cellspacing=0><tr><td colspan=4 class=DevSt>"+a+"</td></tr>"}var d="si3";if(b.etype=="user"){d="m2"}if(b.etype=="server"){d="si3"}var e=b.msg.split("(R)").join("&reg;");if(b.username&&b.username!=userinfo.name){e+=": "+b.username}h+="<tr onmouseover=eventMouseHover(this,1) onmouseout=eventMouseHover(this,0) style=cursor:pointer><td style=width:18px><div class="+d+"></div></td><td class=g1>&nbsp;</td><td class=style10>"+printTime(g)+" - "+e+"</td><td class=g2>&nbsp;</td></tr><tr style=height:2px></tr>"}}if(a!=null){h+="</table>"}if(h==""){h="<br><i>No Events Found</i><br><br>"}QH("p3events",h)}function showDeleteAllEventsDialog(){if(xxdialogMode){return}var a="Delete all events in the server event log?<br /><br />";a+="<label><input id=p3check type=checkbox onchange=validateDeleteAllEventsDialog() />Confirm</label>";setDialogMode(2,"Delete All Events",3,showDeleteAllEventsDialogEx,a);validateDeleteAllEventsDialog()}function validateDeleteAllEventsDialog(){QE("idx_dlgOkButton",Q("p3check").checked)}function showDeleteAllEventsDialogEx(a,b){meshserver.send({action:"clearevents"})}function refreshEvents(){meshserver.send({action:"events",limit:parseInt(p3limitdropdown.value)})}function p3showDownloadEventsDialog(){if(xxdialogMode){return}var a="Download the list of events with one of the file formats below.<br /><br />";a+=addHtmlValue("CSV Format",'<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogCSV()">eventslist.csv</a>');a+=addHtmlValue("JSON Format",'<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogJSON()">eventslist.json</a>');setDialogMode(2,"Event List Export",1,null,a)}function p3downloadEventsDialogCSV(){var a="time, type, action, user, message\r\n";for(var b in events){a+='"'+events[b].time+'","'+events[b].etype+'","'+((events[b].action!=null)?events[b].action:"")+'","'+((events[b].username!=null)?events[b].username:"")+'","'+((events[b].msg!=null)?events[b].msg:"")+'"\r\n'}saveAs(new Blob([a],{type:"application/octet-stream"}),"eventslist.csv");return false}function p3downloadEventsDialogJSON(){var b=[];for(var a in events){b.push(events[a])}saveAs(new Blob([JSON.stringify(b)],{type:"application/octet-stream"}),"eventslist.json");return false}function updateUsers(){QV("MainMenuMyUsers",(users!=null)&&((features&4)==0));QV("LeftMenuMyUsers",(users!=null)&&((features&4)==0));QV("UserNewAccountButton",((features&4)==0)&&(serverinfo.domainauth==false));if((users==null)||((features&4)!=0)){QH("p3users","");return}var h=[],e=100,c=0;for(var d in users){h.push(d)}h.sort();var k=Q("UserSearchInput").value.toLowerCase();var b=k;if(k.startsWith("email:")){k=null;b=b.substring(6)}else{if(k.startsWith("name:")){b=null;k=k.substring(5)}else{if(k.startsWith("e:")){k=null;b=b.substring(2)}else{if(k.startsWith("n:")){b=null;k=k.substring(2)}}}}var l="<table class=p3usersTable cellpadding=0 cellspacing=0>",a=true;l+="<th>Name<th style=width:80px>Groups<th style=width:120px>Last&nbsp;Access<th style=width:120px>Permissions";for(var d in h){var j=users[h[d]],g=null;if(wssessions!=null){g=wssessions[j._id]}if((g!=null)&&((k!=null)&&((k=="")||(j.name.toLowerCase().indexOf(k)>=0))||((b!=null)&&((j.email!=null)&&(j.email.toLowerCase().indexOf(b)>=0))))){if(e>0){if(a){l+="<tr><td class=userTableHeader colspan=4>Online Users";a=false}l+=addUserHtml(j,g);e--}else{c++}}}a=true;for(var d in h){var j=users[h[d]],g=null;if(wssessions!=null){g=wssessions[j._id]}if((g==null)&&((k!=null)&&((k=="")||(j.name.toLowerCase().indexOf(k)>=0))||((b!=null)&&((j.email!=null)&&(j.email.toLowerCase().indexOf(b)>=0))))){if(e>0){if(a){l+="<tr><td class=userTableHeader colspan=4>Offline Users";a=false}l+=addUserHtml(j,g);e--}else{c++}}}l+="</table>";if(c==1){l+="<br />1 more user not shown, use search box to look for users...<br />"}else{if(c>1){l+="<br />"+c+" more users not shown, use search box to look for users...<br />"}}if(e==100){l+="<br />No users found.<br />"}QH("p3users",l);if((currentUser!=null)&&(xxcurrentView==30)){gotoUser(encodeURIComponent(currentUser._id),true)}}function addUserHtml(n,l){var p="",b=" gray",e="m2",h="",k=(n.name!=userinfo.name),g="",j="";if(l!=null){b="";if(k){h='<span style=float:right;margin-top:1px;margin-right:4px title=Chat><a href=# onclick=userChat(event,"'+encodeURIComponent(n._id)+'","'+encodeURIComponent(n.name)+"\")><img src='images/icon-chat.png' height=16 width=16 style=padding-top:2px /></a></span>";h+="<span style=float:right;margin-top:1px;margin-left:4px;margin-right:4px title=Notify><a href=# onclick='return showUserAlertDialog(event,\""+encodeURIComponent(n._id)+"\")'><img src='images/icon-notify.png' height=16 width=16 style=padding-top:2px /></a></span>"}if(l==1){g+="1&nbsp;session"}else{g+=l+"&nbsp;sessions"}}else{if(n.login){g+='<span title="Last login: '+printDateTime(new Date(n.login*1000))+'">'+printDate(new Date(n.login*1000))+"</span>"}}if(k){j+="<a href=# style=cursor:pointer onclick='return showUserAdminDialog(event,\""+encodeURIComponent(n._id)+"\")'>"}if((n.siteadmin!=null)&&((n.siteadmin&32)!=0)&&(n.siteadmin!=4294967295)){j+="Locked,&nbsp;"}j+="<span title='Server Permissions'>";var m=n.siteadmin&(4294967295-224);if((n.siteadmin==null)||(m==0)){j+="User"}else{if(m==8){j+="User + Files"}else{if(n.siteadmin==4294967295){j+="Administrator"}else{if((m&2)!=0){j+="Manager"}else{j+="Partial"}}}}if((n.siteadmin!=null)&&(n.siteadmin!=4294967295)&&((n.siteadmin&(64+128))!=0)){j+="*"}j+="</span>";if(k){j+="</a>"}var c=0;if(n.links){for(var d in n.links){c++}}var o=EscapeHtml(n.name),a="";if(serverinfo.emailcheck==true){a=((n.emailVerified!=true)?' <b style=color:red title="Email is not verified">&#x2717;</b>':' <b style=color:green title="Email is verified">&#x2713</b>')}if(n.email!=null){if(((features&2097152)==0)||(n.email.toLowerCase()!=n.name.toLowerCase())){o+=", <a href=# onclick='return doemail(event,\""+n.email+"\")'>"+n.email+"</a>"+a}else{o+=" <a href=# onclick='return doemail(event,\""+n.email+'")\'><img src="images/mail12.png" height=9 width=12 title="Send email to user" style="margin-top:2px" /></a>'+a}}if((n.otpsecret>0)||(n.otphkeys>0)){o+=' <img src="images/key12.png" height=12 width=11 title="2nd factor authentication enabled" style="margin-top:2px" />'}if((n.siteadmin!=null)&&((n.siteadmin&32)!=0)&&(n.siteadmin!=4294967295)){o+=' <img src="images/padlock12.png" height=12 width=8 title="Account is locked" style="margin-top:2px" />'}p+="<tr tabindex=0 onmouseover=userMouseHover(this,1) onmouseout=userMouseHover(this,0) onkeypress=\"if (event.key=='Enter') gotoUser('"+encodeURIComponent(n._id)+'\')"><td style=cursor:pointer onclick=gotoUser("'+encodeURIComponent(n._id)+'")>';p+="<div class=bar>";p+='<div class=baricon><div class="'+e+b+'"></div></div>';p+="<div class=g1></div><div class=g2></div>";p+="<div><span>"+o+"</span>"+h+"</div></div><td style=text-align:center>"+c+"<td style=text-align:center>"+g+"<td style=text-align:center>"+j;return p}function userMouseHover(b,c){var a=b.children[0].children[0];a.children[1].classList.remove("g1s");a.children[2].classList.remove("g2s");if(c==1){a.children[1].classList.add("g1s");a.children[2].classList.add("g2s")}b.children[0].children[0].style["background-color"]=((c==0)?"#c9c9c9":"#b9b9b9")}function userChat(a,d,b){haltEvent(a);var c="/messenger?id=meshmessenger/"+d+"/"+encodeURIComponent(userinfo._id)+"&title="+b;if((authCookie!=null)&&(authCookie!="")){c+="&auth="+authCookie}window.open(c,"meshmessenger:"+d);meshserver.send({action:"meshmessenger",userid:decodeURIComponent(d)});return false}function showUserAlertDialog(a,b){if(xxdialogMode){return}haltEvent(a);setDialogMode(2,"Notify "+EscapeHtml(users[decodeURIComponent(b)].name),3,showUserAlertDialogEx,'Send a text notification to this user.<textarea id=d2notifyText maxlength=2048 style="width:100%;height:184px;resize:none"></textarea>',b);Q("d2notifyText").focus();return false}function showUserAlertDialogEx(a,b){meshserver.send({action:"notifyuser",userid:decodeURIComponent(b),msg:Q("d2notifyText").value})}function doemail(b,a){if(xxdialogMode){return false}haltEvent(b);window.open("mailto:"+a);return false}function p4batchAccountCreate(){if(xxdialogMode){return}var a='Create many accounts at once by importing a JSON file with the following format:<br /><pre>[\r\n {"user":"x1","pass":"x","email":"x1@x"},\r\n {"user":"x2","pass":"x","resetNextLogin":true}\r\n]</pre><input style=width:370px type=file id=d4importFile accept=".json" onchange=p4batchAccountCreateValidate() />';setDialogMode(2,"User Account Import",3,p4batchAccountCreateEx,a);QE("idx_dlgOkButton",false)}function p4batchAccountCreateValidate(){QE("idx_dlgOkButton",Q("d4importFile").value!=null)}function p4batchAccountCreateEx(){var a=new FileReader();a.onload=function(g){var d=null;try{d=JSON.parse(g.target.result)}catch(b){setDialogMode(2,"User Account Import",1,null,"Invalid JSON file: "+b+".");return}if((d!=null)&&(Array.isArray(d))){var e=true;for(var c in d){if((typeof d[c].user!="string")||(d[c].user.length<1)||(d[c].user.length>64)){e=false}if((typeof d[c].pass!="string")||(d[c].pass.length<1)||(d[c].pass.length>256)){e=false}if(checkPasswordRequirements(d[c].pass,passRequirements)==false){e=false}if((d[c].email!=null)&&((typeof d[c].email!="string")||(d[c].email.length<1)||(d[c].email.length>128))){e=false}}if(e==false){setDialogMode(2,"User Account Import",1,null,"Invalid JSON file format.")}else{meshserver.send({action:"adduserbatch",users:d})}}else{setDialogMode(2,"User Account Import",1,null,"Invalid JSON file format.")}};a.readAsText(Q("d4importFile").files[0])}function p4downloadUserInfo(){if(xxdialogMode){return}var a="Download the list of users with one of the file formats below.<br /><br />";a+=addHtmlValue("CSV Format","<a href=# style=cursor:pointer onclick='return p4downloadUserInfoCSV()'>userlist.csv</a>");a+=addHtmlValue("JSON Format","<a href=# style=cursor:pointer onclick='return p4downloadUserInfoJSON()'>userlist.json</a>");setDialogMode(2,"User List Export",1,null,a)}function p4downloadUserInfoCSV(){var a="id, name, email, creation, lastlogin, groups, authfactors\r\n";for(var c in users){var d=false,b=[];if((users[c].otpsecret>0)||(users[c].otphkeys>0)){d=true;if(users[c].otpsecret>0){b.push("AuthApp")}if(users[c].otphkeys>0){b.push("SecurityKey")}if(users[c].otpkeys>0){b.push("BackupCodes")}}a+='"'+users[c]._id+'","'+users[c].name+'","'+(users[c].email?users[c].email:"")+'","'+(users[c].creation?new Date(users[c].creation*1000):"")+'","'+(users[c].login?new Date(users[c].login*1000):"")+'","'+(users[c].groups?users[c].groups.join(","):"")+'","'+(d?b.join(","):"")+'"\r\n'}saveAs(new Blob([a],{type:"application/octet-stream"}),"userlist.csv");return false}function p4downloadUserInfoJSON(){var b=[];for(var a in users){b.push(users[a])}saveAs(new Blob([JSON.stringify(b)],{type:"application/octet-stream"}),"userlist.json");return false}function showUserBroadcastDialog(){if(xxdialogMode){return}var a='Broadcast a message to all connected users.<textarea id=broadcastMessage value="" maxlength="256"/></textarea>';setDialogMode(2,"Broadcast Message",3,showUserBroadcastDialogEx,a);Q("broadcastMessage").focus()}function showUserBroadcastDialogEx(){meshserver.send({action:"userbroadcast",msg:Q("broadcastMessage").value})}function showCreateNewAccountDialog(){if(xxdialogMode){return}var d="";if((features&2097152)==0){d+=addHtmlValue("Name","<input id=p4name maxlength=64 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />")}d+=addHtmlValue("Email","<input id=p4email maxlength=256 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />");d+=addHtmlValue("Password","<input id=p4pass1 type=password maxlength=256 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />");d+=addHtmlValue("Password","<input id=p4pass2 type=password maxlength=256 onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />");d+="<div><label><input id=p4randomPassword onchange=showCreateNewAccountDialogValidate() type=checkbox />Randomize the password.</label></div>";d+="<div><label><input id=p4resetNextLogin onchange=showCreateNewAccountDialogValidate() type=checkbox />Force password reset on next login.</label></div>";if(serverinfo.emailcheck){d+="<div><label><input id=p4verifiedEmail onchange=showCreateNewAccountDialogValidate() type=checkbox />Email is verified.</label></div>";d+="<div><label><input id=p4invitationEmail type=checkbox />Send invitation email.</label></div>"}if(passRequirements){var b=[],c=0;for(var a in passRequirements){if((a!="reset")&&(a!="hint")){b.push(a+":"+passRequirements[a]);c++}}if(c>0){d+="<div style=font-size:x-small;padding:6px>Requirements: "+b.join(", ")+".</div>"}}setDialogMode(2,"Create Account",3,showCreateNewAccountDialogEx,d);showCreateNewAccountDialogValidate();if((features&2097152)==0){Q("p4name").focus()}else{Q("p4email").focus()}}function showCreateNewAccountDialogValidate(c){var b=validateEmail(Q("p4email").value);if(serverinfo.emailcheck){QE("p4verifiedEmail",b);QE("p4invitationEmail",b&&Q("p4resetNextLogin").checked&&Q("p4verifiedEmail").checked);if(b==false){Q("p4verifiedEmail").checked=false}if((Q("p4resetNextLogin").checked==false)||(Q("p4verifiedEmail").checked==false)){Q("p4invitationEmail").checked=false}}QE("p4pass1",!Q("p4randomPassword").checked);QE("p4pass2",!Q("p4randomPassword").checked);if((c==null)&&(Q("p4email").value.length>0)&&(b==false)){QE("idx_dlgOkButton",false);return}var a=true;if((features&2097152)==0){a&=(!Q("p4name")||((Q("p4name").value.length>0)&&(Q("p4name").value.indexOf(" ")==-1)))}if(Q("p4randomPassword").checked==false){a&=(Q("p4pass1").value.length>0&&Q("p4pass1").value==Q("p4pass2").value&&checkPasswordRequirements(Q("p4pass1").value,passRequirements))}if(a&&passRequirements){if(checkPasswordRequirements(Q("p4pass1").value,passRequirements)==false){a=false}}QE("idx_dlgOkButton",a)}function showCreateNewAccountDialogEx(){var a=((features&2097152)==0)?Q("p4name").value:Q("p4email").value;var b={action:"adduser",username:a,email:Q("p4email").value,pass:Q("p4pass1").value,resetNextLogin:Q("p4resetNextLogin").checked,randomPassword:Q("p4randomPassword").checked};if(serverinfo.emailcheck){b.emailVerified=Q("p4verifiedEmail").checked;b.emailInvitation=Q("p4invitationEmail").checked}meshserver.send(b)}function showUserGroupDialog(a,d){if(xxdialogMode){return}haltEvent(a);d=decodeURIComponent(d);var c=users[d.toLowerCase()],b="";if(c.groups!=null){b=c.groups.join(", ")}var g="Enter a comma seperate list of groups.<br /><br />";g+=addHtmlValue("Groups",'<input id=dp4usergroups style=width:230px value="'+b+'" placeholder="Group1, Group2, Group3" maxlength=256 onchange=p4validateUserGroups() onkeyup=p4validateUserGroups() />');setDialogMode(2,"User Groups",3,showUserGroupDialogEx,g,c);focusTextBox("dp4usergroups");p4validateUserGroups();return false}function p4validateUserGroups(){var b=Q("dp4usergroups").value;var e=0,c=b.indexOf('"')+b.indexOf("/")+b.indexOf(">")+b.indexOf("<")+b.indexOf("'");var a=b.split(",");for(var d in a){if(a[d].trim().length==0){e++}}QE("idx_dlgOkButton",(b=="")||((c==-5)&&(e<1)))}function showUserGroupDialogEx(a,h){var d=Q("dp4usergroups").value,b=d.split(","),c=[];for(var e in b){var k=b[e].trim();if(k.length>0){c.push(k)}}meshserver.send({action:"edituser",id:h._id,groups:c})}function showUserAdminDialog(a,c){if(xxdialogMode){return}haltEvent(a);c=decodeURIComponent(c);var d="<div><div id=d2AdminPermissions>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_fileaccess>Server Files</label>, <input type=number onchange=showUserAdminDialogValidate() maxlength=10 id=ua_fileaccessquota>k max, blank for default<br><hr/>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_fulladmin>Full Administrator</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverbackup>Server Backup</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverrestore>Server Restore</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverupdate>Server Updates</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_manageusers>Manage Users</label><br>";d+="<hr/></div><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_lockedaccount>Lock Account</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nonewgroups>No New Device Groups</label><br>";d+="<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nomeshcmd>No Tools (MeshCmd/Router)</label><br>";d+="</div>";var b=users[c.toLowerCase()];setDialogMode(2,"Server Permissions",3,showUserAdminDialogEx,d,b);if(b.siteadmin&&b.siteadmin!=0){Q("ua_fulladmin").checked=(b.siteadmin==4294967295);Q("ua_serverbackup").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&1)!=0));Q("ua_manageusers").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&2)!=0));Q("ua_serverrestore").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&4)!=0));Q("ua_fileaccess").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&8)!=0));Q("ua_serverupdate").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&16)!=0));Q("ua_lockedaccount").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&32)!=0));Q("ua_nonewgroups").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&64)!=0));Q("ua_nomeshcmd").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&128)!=0))}QE("ua_fulladmin",userinfo.siteadmin==4294967295);QE("ua_serverbackup",userinfo.siteadmin==4294967295);QE("ua_manageusers",userinfo.siteadmin==4294967295);QE("ua_serverrestore",userinfo.siteadmin==4294967295);QE("ua_fileaccess",userinfo.siteadmin==4294967295);QE("ua_fileaccessquota",userinfo.siteadmin==4294967295);QE("ua_serverupdate",userinfo.siteadmin==4294967295);QV("d2AdminPermissions",userinfo.siteadmin==4294967295);QE("ua_lockedaccount",(userinfo.siteadmin&2)&&(b.siteadmin!=4294967295)&&(userinfo._id!=b._id));QE("ua_nonewgroups",(userinfo.siteadmin&2)&&(b.siteadmin!=4294967295)&&(userinfo._id!=b._id));QE("ua_nomeshcmd",(userinfo.siteadmin&2)&&(b.siteadmin!=4294967295)&&(userinfo._id!=b._id));Q("ua_fileaccessquota").value=(b.quota!=null)?(b.quota/1024):"";showUserAdminDialogValidate();return false}function showUserAdminDialogValidate(){if(userinfo.siteadmin==4294967295){QE("ua_serverbackup",!Q("ua_fulladmin").checked);QE("ua_manageusers",!Q("ua_fulladmin").checked);QE("ua_serverrestore",!Q("ua_fulladmin").checked);QE("ua_fileaccess",!Q("ua_fulladmin").checked);QE("ua_serverupdate",!Q("ua_fulladmin").checked);QE("ua_lockedaccount",!Q("ua_fulladmin").checked);QE("ua_nonewgroups",!Q("ua_fulladmin").checked);QE("ua_nomeshcmd",!Q("ua_fulladmin").checked);QE("ua_fileaccessquota",Q("ua_fileaccess").checked&&!Q("ua_fulladmin").checked)}}function showUserAdminDialogEx(a,d){var c=0,b=parseInt(Q("ua_fileaccessquota").value);if(Q("ua_fulladmin").checked==true){c=4294967295}else{if(Q("ua_serverbackup").checked==true){c+=1}if(Q("ua_manageusers").checked==true){c+=2}if(Q("ua_serverrestore").checked==true){c+=4}if(Q("ua_fileaccess").checked==true){c+=8}if(Q("ua_serverupdate").checked==true){c+=16}if(Q("ua_lockedaccount").checked==true){c+=32}if(Q("ua_nonewgroups").checked==true){c+=64}if(Q("ua_nomeshcmd").checked==true){c+=128}}var e={action:"edituser",id:d._id,siteadmin:c};if(isNaN(b)==false){e.quota=(b*1024)}meshserver.send(e)}function onUserSearchInputChanged(){updateUsers()}var currentUser=null;function gotoUser(r,g){if(xxdialogMode&&!g){return}var p=currentUser=users[decodeURIComponent(r)];if(p==null){setDialogMode(0);go(4);return}QH("p30userName",p.name);QH("p31userName",p.name);var o=(p.name==userinfo.name),a=0;if(wssessions!=null&&wssessions[p._id]){a=wssessions[p._id]}Q("MainUserImage").classList.remove("gray");if(a==0){Q("MainUserImage").classList.add("gray")}var l=[],n="";if((p.siteadmin!=null)&&((p.siteadmin&32)!=0)&&(p.siteadmin!=4294967295)){n='<img src="images/padlock12.png" height=12 width=8 title="Account is locked" style="margin-top:2px" /> ';l.push("Locked account")}if((p.siteadmin==null)||((p.siteadmin&(4294967295-224))==0)){l.push("No server rights")}else{if(p.siteadmin==8){l.push("Access to server files")}else{if(p.siteadmin==4294967295){l.push("Full administrator")}else{l.push("Partial rights")}}}if((p.siteadmin!=null)&&(p.siteadmin!=4294967295)&&((p.siteadmin&(64+128))!=0)){l.push("Restrictions")}var s="<div style=min-height:80px><table style=width:100%>";var c=p.email?EscapeHtml(p.email):"<i>Not set</i>",d="";if(serverinfo.emailcheck){d=((p.emailVerified==true)?'<b style=color:green;cursor:pointer title="Email is verified">&#x2713</b> ':'<b style=color:red;cursor:pointer title="Email not verified">&#x2717;</b> ')}if(p.name.toLowerCase()!=p._id.split("/")[2]){s+=addDeviceAttribute("User Identifier",p._id.split("/")[2])}if(((features&2097152)==0)&&((p.siteadmin!=4294967295)||(userinfo.siteadmin==4294967295))){s+=addDeviceAttribute("Email",d+'<a href=# style=cursor:pointer onclick=p30showUserEmailChangeDialog(event,"'+r+'")>'+c+"</a> <a href=# style=cursor:pointer onclick='return doemail(event,\""+p.email+'")\'><img class=hoverButton src="images/link1.png" /></a>')}else{s+=addDeviceAttribute("Email",d+c+" <a href=# style=cursor:pointer onclick='return doemail(event,\""+p.email+'")\'><img class=hoverButton src="images/link1.png" /></a>')}s+=addDeviceAttribute("Server Rights",n+"<a href=# style=cursor:pointer onclick='return showUserAdminDialog(event,\""+r+"\")'>"+l.join(", ")+"</a>");if(p.quota){s+=addDeviceAttribute("Server Quota",EscapeHtml(parseInt(p.quota)/1024)+" k")}s+=addDeviceAttribute("Creation",printDateTime(new Date(p.creation*1000)));if(p.login){s+=addDeviceAttribute("Last Login",printDateTime(new Date(p.login*1000)))}if(p.passchange==-1){s+=addDeviceAttribute("Password","Will be changed on next login.")}else{if(p.passchange){s+=addDeviceAttribute("Password","Last changed: "+printDateTime(new Date(p.passchange*1000)))}}var j=0,k="<i>None<i>";if(p.links){for(var h in p.links){j++}if(j==1){k="1 group"}else{if(j>1){k=j+" groups"}}}s+=addDeviceAttribute("Device Groups",k);var q="<i>None</i>";if(p.groups){q="";for(var h in p.groups){q+='<span class="tagSpan">'+p.groups[h]+"</span>"}}s+=addDeviceAttribute("User Groups",addLinkConditional(q,'showUserGroupDialog(event,"'+r+'")',(userinfo.siteadmin==4294967295)||((userinfo.groups==null)&&(userinfo.siteadmin&2)&&(userinfo._id!=p._id)&&(p._id!=4294967295))));var m=0;if((p.otpsecret>0)||(p.otphkeys>0)){m=1;var e=[];if(p.otpsecret>0){e.push("Authentication App")}if(p.otphkeys>0){e.push("Security Key")}if(p.otpkeys>0){e.push("Backup Codes")}s+=addDeviceAttribute("Security",'<img src="images/key12.png" height=12 width=11 title="2nd factor authentication enabled" style="margin-top:2px" /> '+e.join(", "))}s+="</table></div><br />";s+='<input type=button value=Notes title="View notes about this user" onclick=showNotes(false,"'+r+'") />';if(!o&&(a>0)){s+='<input type=button value=Notify title="Send user notification" onclick=showUserAlertDialog(event,"'+r+'") />'}QH("p30html",s);drawUserTimeline();var b=true;if(p._id==userinfo._id){b=false}if(p.siteadmin&&p.siteadmin>0&&userinfo.siteadmin!=4294967295){b=false}s="<div style=float:right;font-size:x-small>";if(b){s+="<a href=# style=cursor:pointer onclick='return p30showDeleteUserDialog()' title=\"Remove this user\">Delete User</a>"}s+="</div><div style=font-size:x-small>";if(userinfo.siteadmin==4294967295){s+="<a href=# style=cursor:pointer onclick='return p30showUserChangePassDialog("+m+')\' title="Change the password for this user">Change Password</a>'}s+="</div><br>";QH("p30html3",s);s="";if(a==1){s="1 active session"}else{if(a>1){s=a+" active sessions"}}QH("MainUserState",s);go(30);QH("p31events","");refreshUsersEvents()}function p30showUserEmailChangeDialog(a){if(xxdialogMode){return false}var b="";b+=addHtmlValue("Email","<input id=dp30email style=width:230px maxlength=32 onchange=p30validateEmail() onkeyup=p30validateEmail() />");if(serverinfo.emailcheck){b+=addHtmlValue("Status","<select id=dp30verified style=width:230px onchange=p30validateEmail()><option value=0>Not verified</option><option value=1>Verified</option></select>")}setDialogMode(2,"Change Email for "+EscapeHtml(currentUser.name),3,p30showUserEmailChangeDialogEx,b);Q("dp30email").focus();Q("dp30email").value=(currentUser.email?currentUser.email:"");if(serverinfo.emailcheck){Q("dp30verified").value=currentUser.emailVerified?1:0}p30validateEmail();return false}function p30validateEmail(){var a=Q("dp30email").value,b=a.split("@");b=(b.length==2)&&(b[0].length>0)&&(b[1].split(".").length>1)&&(b[1].length>2)&&(a.length<1024)&&((a!=userinfo.email)||((serverinfo.emailcheck==true)&&(Q("dp30verified").value!=(userinfo.emailVerified?1:0))));QE("idx_dlgOkButton",b)}function p30showUserEmailChangeDialogEx(){var a={action:"edituser",id:currentUser._id,email:Q("dp30email").value};if(serverinfo.emailcheck){a.emailVerified=(Q("dp30verified").value==1)}meshserver.send(a)}function p30showUserChangePassDialog(b){if(xxdialogMode){return}var e="";e+=addHtmlValue("Password","<input id=p4pass1 type=password style=width:230px maxlength=256 onchange=showCreateNewAccountDialogValidate(1) onkeyup=p30showUserChangePassDialogValidate(1)></input>");e+=addHtmlValue("Password","<input id=p4pass2 type=password style=width:230px maxlength=256 onchange=showCreateNewAccountDialogValidate(1) onkeyup=p30showUserChangePassDialogValidate(1)></input>");if(features&65536){e+=addHtmlValue("Password hint","<input id=p4hint type=text style=width:230px maxlength=256></input>")}if(passRequirements){var c=[],d=0;for(var a in passRequirements){if((a!="reset")&&(a!="hint")){c.push(a+":"+passRequirements[a]);d++}}if(d>0){e+="<div style=font-size:x-small;padding:6px>Requirements: "+c.join(", ")+".</div>"}}e+="<div><label><input id=p4resetNextLogin type=checkbox />Force password reset on next login.</label></div>";if(b==1){e+="<div><label><input id=p4twoFactorRemove type=checkbox />Remove all 2nd factor authentication.</label></div>"}setDialogMode(2,"Change Password for "+EscapeHtml(currentUser.name),3,p30showUserChangePassDialogEx,e,b);p30showUserChangePassDialogValidate();Q("p4pass1").focus();if(currentUser.passchange==-1){Q("p4resetNextLogin").checked=true}}function p30showUserChangePassDialogValidate(){var a=true;if((Q("p4pass1").value!="")||(Q("p4pass2").value!="")){if(Q("p4pass1").value!=Q("p4pass2").value){a=false}else{if(passRequirements){if(checkPasswordRequirements(Q("p4pass1").value,passRequirements)==false){a=false}}}}QE("idx_dlgOkButton",a)}function p30showUserChangePassDialogEx(a,e){var d=false;if((e==1)&&(Q("p4twoFactorRemove").checked==true)){d=true}if(Q("p4pass1").value==Q("p4pass2").value){var c={action:"changeuserpass",userid:currentUser._id,pass:Q("p4pass1").value,removeMultiFactor:d,resetNextLogin:Q("p4resetNextLogin").checked};if(features&65536){c.hint=Q("p4hint").value}meshserver.send(c)}}function p30showDeleteUserDialog(){if(xxdialogMode){return}setDialogMode(2,"Delete User "+EscapeHtml(currentUser.name),3,p30showDeleteUserDialogEx,"Confirm deletion of user "+EscapeHtml(currentUser.name)+"?")}function p30showDeleteUserDialogEx(){meshserver.send({action:"deleteuser",userid:currentUser._id,username:currentUser.name})}function drawUserTimeline(){var s=null,o=Date.now();s=[];var e=new Date();e.setHours(0,0,0,0);e=new Date(e.getTime()-(1000*60*60*24*6));var u=e.getTime();var t=[];if(s!=null&&s.length>1){t.push([0,s[1],s[0]]);var c=s[1];for(var m=2;m<s.length;m+=2){var p=s[m],k=o;if(s.length>(m+1)){k=s[m+1]}t.push([c,c+k,p]);c=c+k}}var z="",b=1,h=new Date();h.setHours(0,0,0,0);for(var m=0;m<7;m++){var g="",q=h.getTime(),l=q+(1000*60*60*24);for(var n in t){var a=t[n];if(isTimeBlockInside(q,l,a[0],a[1])==true){var w=Math.max(q,a[0]);var r=Math.min(Math.min(l,a[1]),o);var y=Math.round((r-w)/112794);if(y>0){var v=powerStateStrings2[a[2]]+" from "+printTime(new Date(w))+" to "+printTime(new Date(r))+".";g+='<div title="'+v+'" style=display:table-cell;width:'+y+"px;background-color:"+powerColor(a[2])+";height:16px></div>"}}}z+="<tr style="+(((b%2)==0)?"background-color:#DDD":"")+"><td><div>&nbsp;"+printDate(h)+"<div></div></div></td><td><div>"+g+"</div></td></tr>";++b;h=new Date(h.getTime()-(1000*60*60*24))}QH("p30html2",'<table style="color:black;background-color:#EEE;border-color:#AAA;border-width:1px;border-style:solid;border-collapse:collapse" border=0 cellpadding=2 cellspacing=0 width=100%><tbody><tr style=background-color:#AAAAAA;font-weight:bold><th scope=col style=text-align:center;width:150px>Day</th><th scope=col style=text-align:center>7 Day Login State</th></tr>'+z+"</tbody></table>")}var currentUserEvents=null;function userEventsUpdate(){var h="",a=null;for(var c in currentUserEvents){var b=currentUserEvents[c];var g=new Date(b.time);if(printDate(g)!=a){if(a!=null){h+="</table>"}a=printDate(g);h+="<table style=width:100% cellpadding=0 cellspacing=0><tr><td class=DevSt>"+a+"</td></tr>"}var d="si3";if(b.etype=="user"){d="m2"}if(b.etype=="server"){d="si3"}var e=b.msg.split("(R)").join("&reg;");if(b.username&&b.username!=userinfo.name){e+=": "+b.username}h+="<tr><td><div class=bar18 style=height:18px;width:100%;font-size:medium>";h+="<div style=float:left;height:18px;width:18px;background-color:white><div class="+d+" style=width:16px;margin-top:1px;margin-left:2px;height:16px></div></div>";h+="<div class=g1 style=height:18px;float:left></div><div class=g2 style=height:18px;float:right></div>";h+="<div style=font-size:14px><span style=width:300px>"+printTime(g)+" - "+e+"</span></div></div></td></tr>"}if(a!=null){h+="</table>"}if(h==""){h="<br><i>No Events Found</i><br><br>"}QH("p31events",h)}function refreshUsersEvents(){meshserver.send({action:"events",limit:parseInt(p31limitdropdown.value),user:currentUser.name})}function d3init(){Q("d3localFile").value="";d3modechange()}function d3modechange(){var a=Q("d3uploadMode").value;QV("d3localmode",a==1);QV("d3servermode",a==2);if(a==1){d3setActions()}else{d3updatefiles()}}var d3filetreelinkpath;var d3filetreelocation=[];function d3updatefiles(){if(Q("d3uploadMode").value==1){return}var m="",n="",e=filetree,j=1;var c=[],r=d3filetreelinkpath,b=[],a=document.getElementsByName("fc");for(var o=0;o<a.length;o++){if(a[o].checked){b.push(a[o].value)}}d3filetreelinkpath="";for(var o in d3filetreelocation){if((e.f!=null)&&(e.f[d3filetreelocation[o]]!=null)){c.push(d3filetreelocation[o]);if((j==1)){var t=d3filetreelocation[o].split("/");publicPath=window.location+t[0]+"files/"+t[2];if(d3filetreelocation[o]===userinfo._id){d3filetreelinkpath+="self"}else{d3filetreelinkpath+=(t[0]+"/"+t[2])}}else{if(d3filetreelinkpath!=""){d3filetreelinkpath+="/"+d3filetreelocation[o];if(j>2){publicPath+="/"+d3filetreelocation[o]}}}e=e.f[d3filetreelocation[o]];j++}else{break}}d3filetreelocation=c;var g=p5sort_files(e.f);for(var o in g){var d=g[o],q=d.n,s;s=q;if(q.length>70){s='<span title="'+EscapeHtml(q)+'">'+EscapeHtml(q.substring(0,70))+"...</span>"}else{s=EscapeHtml(q)}q=EscapeHtml(q);var k="";if(d.s!=null){k=getFileSizeStr(d.s)}var l="";if(d.t<3){var u="";l='<div class=filelist file=999><span style=float:right title="'+u+'"></span><span><div class=fileIcon'+d.t+' onclick=d3folderset("'+encodeURIComponent(d.nx)+'")></div>&nbsp;<a href=# style=cursor:pointer onclick=\'return d3folderset("'+encodeURIComponent(d.nx)+"\")'>"+s+"</a></span></div>"}else{var p=s;l="<div class=filelist file=3><input style=float:left name=fcx class=fcb type=checkbox onchange=d3setActions() value='"+d.nx+"'>&nbsp;<span style=float:right>"+k+"</span><span><div class=fileIcon"+d.t+"></div>"+p+"</span></div>"}if(d.t<3){m+=l}else{n+=l}}QH("d3serverfiles",m+n);QE("p3FolderUp",d3filetreelocation.length>0);d3setActions()}function d3folderset(a){d3filetreelocation.push(decodeURIComponent(a));d3updatefiles();return false}function d3folderup(a){if(a==null){d3filetreelocation.pop()}else{while(d3filetreelocation.length>a){d3filetreelocation.pop()}}d3updatefiles()}function d3getFileSel(){var a=[];var b=document.getElementsByName("fcx");for(var c=0;c<b.length;c++){if(b[c].checked){a.push(b[c].value)}}return a}function d3setActions(){var a=Q("d3uploadMode").value;if(a==1){QE("idx_dlgOkButton",Q("d3localFile").value.length>0)}else{QE("idx_dlgOkButton",d3getFileSel().length==1)}}var notifications=[];function clickNotificationIcon(a){if(a==true){QV("notifiyBox",true)}else{if(a==false){QV("notifiyBox",false)}else{QV("notifiyBox",QS("notifiyBox")["display"]=="none")}}drawNotifications()}function setNotificationCount(a){if(parseInt(Q("notificationCount").innerHTML)==a){return}QH("notificationCount",a);QS("notificationCount")["background-color"]=(a==0)?"lightblue":"orange";QV("notificationCount",a>0)}function drawNotifications(){var j="";if(notifications.length==0){j="<div style=margin:5px>There are currently no notifications</div>"}else{for(var c in notifications){var g=notifications[c];var k="";if(g.title!=null){k="<b>"+g.title+"</b>: "}var a=new Date(g.time);var e=0;if(g.nodeid!=null){var h=getNodeFromId(g.nodeid);if(h!=null){e=h.icon;k="<b>"+h.name+"</b>: "}}j+='<div title="Occured at '+printDateTime(a)+'" id="notifyx'+g.id+'" class=notification style="cursor:pointer;border-top:1px solid '+((j=="")?"transparent":"orange")+'">';if(e){j+="<div class=j"+e+' onclick="notificationSelected('+g.id+')" style=margin:5px;float:left></div>'}j+='<div onclick="notificationDelete('+g.id+')" class=unselectable title="Clear this notification" style=margin:5px;float:right;color:orange><b>X</b></div><div onclick="notificationSelected('+g.id+')" style=margin:5px>'+k+g.text+"</div></div>"}}var b="";if(notifications.length>1){b='<div id="notifyRemoveAll" onclick="deleteAllNotifications()" style="cursor:pointer;border-top:1px solid orange;margin:5px;color:orange;text-align:right;padding-right:3px">Clear all</div>'}QH("notifiyBox",'<div class=customScroll style="max-height:170px;overflow-y:auto;margin:5px">'+j+"</div>"+b)}function notificationSelected(c,a){var d=-1;for(var b in notifications){if(notifications[b].id==c){d=b}}if(d!=-1){notificationSelectedEx(notifications[d],c);if(a&&notifications[d]){if(notifications[d].notification){notifications[d].notification.close();delete notifications[d].notification}notificationDelete(c)}}}function notificationSelectedEx(b,a){if(b.nodeid!=null){if(b.tag=="desktop"){gotoDevice(b.nodeid,12)}else{if(b.tag=="terminal"){gotoDevice(b.nodeid,11)}else{if(b.tag=="files"){gotoDevice(b.nodeid,13)}else{if(b.tag=="intelamt"){gotoDevice(b.nodeid,14)}else{if(b.tag=="console"){gotoDevice(b.nodeid,15)}else{gotoDevice(b.nodeid,10)}}}}}}else{if((b.tag!=null)&&b.tag.startsWith("meshmessenger/")){window.open("/messenger?id="+b.tag+"&title="+encodeURIComponent(b.username),b.tag.split("/")[2]);notificationDelete(a)}}}function notificationDelete(c){var d=-1,a=Q("notifyx"+c);if(a!=null){for(var b in notifications){if(notifications[b].id==c){d=b}}if(d!=-1){if(notifications[d].notification){notifications[d].notification.close();delete notifications[d].notification}notifications.splice(d,1);a.parentNode.removeChild(a);setNotificationCount(notifications.length);if(notifications.length==0){QV("notifiyBox",false)}if(notifications.length==1){QV("notifyRemoveAll",false)}if((notifications.length>0)&&(d==0)){var g=notifications[0];QS("notifyx"+g.id)["border-top"]="1px solid transparent"}}}}function addNotification(a){if(a.time==null){a.time=Date.now()}if(a.id==null){a.id=Math.random()}notifications.unshift(a);setNotificationCount(notifications.length);clickNotificationIcon(true);var d=getstore("notifications",0);if(d&1){Q("chimes").play()}var c=null;if(Notification&&(Notification.permission=="granted")){var e=a.text.split("&reg;").join("").split("<b>").join("").split("</b>").join("").split("<br />").join("\r\n");if(a.nodeid){var b=getNodeFromId(a.nodeid);if(b){c=new Notification("{{{title}}} - "+b.name,{tag:a.tag,body:e,icon:"/images/notify/icons128-"+b.icon+".png"})}}else{if(a.icon==null){a.icon=0}var g=a.title;if(g==null){g=""}else{g=" - "+a.title}c=new Notification("{{{title}}}"+g,{tag:a.tag,body:e,icon:"/images/notify/icons128-"+a.icon+".png"})}c.id=a.id;c.xtag=a.tag;c.nodeid=a.nodeid;c.username=a.username;c.onclick=function(h){notificationSelected(h.target.id,true)};a.notification=c}}function deleteAllNotifications(){notifications=[];setNotificationCount(0);drawNotifications();QV("notifiyBox",false)}function setupGeneralServerStats(){window.serverStatCpu=new Chart(document.getElementById("serverCpuChart").getContext("2d"),{type:"doughnut",data:{datasets:[{data:[0,0],backgroundColor:["#AAAAAA","#00AA00"]}],labels:["Used","Free"]},options:{responsive:true,legend:{position:"none",},animation:{animateScale:true,animateRotate:true},width:"60px"}});window.serverStatMemory=new Chart(document.getElementById("serverMemoryChart").getContext("2d"),{type:"doughnut",data:{datasets:[{data:[0,0],backgroundColor:["#AAAAAA","#00AA00"]}],labels:["Used","Free"]},options:{responsive:true,legend:{position:"none",},animation:{animateScale:true,animateRotate:true},width:"60px"}})}var lastServerStats=null;function updateGeneralServerStats(d){if(d!=null){lastServerStats=d}else{d=lastServerStats}if(d==null){return}if(typeof d.cpuavg=="object"){var c=Math.min(d.cpuavg[0],1);window.serverStatCpu.config.data.datasets[0].data=[c,1-c];QH("serverCpuChartText",'<div style=margin-bottom:5px>CPU Load</div><div><b title="CPU load in the last minute">'+(Math.round(d.cpuavg[0]*100)/100)+'</b>, <b title="CPU load in the last 5 minutes">'+(Math.round(d.cpuavg[1]*100)/100)+'</b>, <b title="CPU load in the 15 minutes">'+(Math.round(d.cpuavg[2]*100)/100)+"</b></div>");QS("serverCpuChartView")["display"]="inline-block";window.serverStatCpu.update()}if((typeof d.totalmem=="number")&&(typeof d.freemem=="number")){window.serverStatMemory.config.data.datasets[0].data=[d.totalmem-d.freemem,d.freemem];QH("serverMemoryChartText","<div style=margin-bottom:5px>Memory</div><div><b>"+getNiceSize2(d.freemem)+"</b> free, <b>"+getNiceSize2(d.totalmem)+"</b> total</div>");QS("serverMemoryChartView")["display"]="inline-block";window.serverStatMemory.update()}var e="<div style=width:100% cellpadding=0 cellspacing=0>";if(typeof d.values=="object"){for(var a in d.values){e+="<div class=userTableHeader style=margin-bottom:4px;width:200px>"+a+"</div>";for(var b in d.values[a]){e+="<div style=display:inline-block><table class=serverStateTableCell><tr><td class=h1></td><td><span>"+b+"</span><span style=float:right>"+d.values[a][b]+"</span></td><td class=h2></td></tr></table></div>"}}}e+="</div>";QH("serverStatsTable",e)}var serverTimelineStats=null;var serverTimelineConfig={type:"line",data:{labels:[],datasets:[{label:"",backgroundColor:"rgba(255, 99, 132, .5)",borderColor:"rgb(255, 99, 132)",data:[],fill:true}]},options:{responsive:true,maintainAspectRatio:false,elements:{line:{cubicInterpolationMode:"monotone"}},scales:{xAxes:[{type:"time",time:{tooltipFormat:"ll HH:mm"},display:true,scaleLabel:{display:false,labelString:""}}],yAxes:[{type:"linear",display:true,scaleLabel:{display:true,labelString:""}}]}}};function refreshServerTimelineStats(a){meshserver.send({action:"servertimelinestats",hours:24*30})}function pastDate(a){var b=new Date();b.setTime(b.getTime()-(60*60*1000*a));return b}function setServerTimelineStats(a){serverTimelineStats=a;updateServerTimelineStats()}function addServerTimelineStats(b){if(serverTimelineStats==null){return}serverTimelineStats.push(b);var a=Q("p40type").value;if(a==0){serverTimelineConfig.data.datasets[0].data.push({x:b.time,y:b.conn.ca});serverTimelineConfig.data.datasets[1].data.push({x:b.time,y:b.conn.cu});serverTimelineConfig.data.datasets[2].data.push({x:b.time,y:b.conn.us});serverTimelineConfig.data.datasets[3].data.push({x:b.time,y:b.conn.rs});if(b.conn.am!=null){serverTimelineConfig.data.datasets[4].data.push({x:b.time,y:b.conn.am})}}else{if(a==1){serverTimelineConfig.data.datasets[0].data.push({x:b.time,y:b.mem.external/(1024*1024)});serverTimelineConfig.data.datasets[1].data.push({x:b.time,y:b.mem.heapUsed/(1024*1024)});serverTimelineConfig.data.datasets[2].data.push({x:b.time,y:b.mem.heapTotal/(1024*1024)});serverTimelineConfig.data.datasets[3].data.push({x:b.time,y:b.mem.rss/(1024*1024)})}}updateServerTimelineHours()}function updateServerTimelineHours(){serverTimelineConfig.options.scales.yAxes[0].type=(Q("p40log").checked?"logarithmic":"linear");serverTimelineConfig.options.scales.xAxes[0].time={min:pastDate(Q("p40time").value)};window.serverMainStats.update()}function setupServerTimelineStats(){window.serverMainStats=new Chart(document.getElementById("serverMainStats").getContext("2d"),serverTimelineConfig)}function updateServerTimelineStats(){var b,a=Q("p40type").value,e=pastDate(Q("p40time").value);serverTimelineConfig.options.scales.xAxes[0].time={min:e};if(a==0){serverTimelineConfig.options.scales.yAxes[0].scaleLabel.labelString="Connection Count";b={labels:[pastDate(0),e],datasets:[{label:"Agents",data:[],backgroundColor:"rgba(158, 151, 16, .1)",borderColor:"rgb(158, 151, 16)",fill:true},{label:"Users",data:[],backgroundColor:"rgba(16, 84, 158, .1)",borderColor:"rgb(16, 84, 158)",fill:true},{label:"User Sessions",data:[],backgroundColor:"rgba(255, 99, 132, .1)",borderColor:"rgb(255, 99, 132)",fill:true},{label:"Relay Sessions",data:[],backgroundColor:"rgba(39, 158, 16, .1)",borderColor:"rgb(39, 158, 16)",fill:true},{label:"Intel AMT",data:[],backgroundColor:"rgba(134, 16, 158, .1)",borderColor:"rgb(134, 16, 158)",fill:true}]};for(var c=0;c<serverTimelineStats.length;c++){var d=new Date(serverTimelineStats[c].time);if(serverTimelineStats[c].conn){b.datasets[0].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.ca});b.datasets[1].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.cu});b.datasets[2].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.us});b.datasets[3].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.rs});if(serverTimelineStats[c].conn.am!=null){b.datasets[4].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].conn.am})}}}}else{if(a==1){serverTimelineConfig.options.scales.yAxes[0].scaleLabel.labelString="Megabytes";b={labels:[pastDate(0),e],datasets:[{label:"External",data:[],backgroundColor:"rgba(158, 151, 16, .1)",borderColor:"rgb(158, 151, 16)",fill:true},{label:"Heap Used",data:[],backgroundColor:"rgba(16, 84, 158, .1)",borderColor:"rgb(16, 84, 158)",fill:true},{label:"Heap Total",data:[],backgroundColor:"rgba(255, 99, 132, .1)",borderColor:"rgb(255, 99, 132)",fill:true},{label:"RSS",data:[],backgroundColor:"rgba(39, 158, 16, .1)",borderColor:"rgb(39, 158, 16)",fill:true}]};for(var c=0;c<serverTimelineStats.length;c++){b.datasets[0].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].mem.external/(1024*1024)});b.datasets[1].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].mem.heapUsed/(1024*1024)});b.datasets[2].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].mem.heapTotal/(1024*1024)});b.datasets[3].data.push({x:serverTimelineStats[c].time,y:serverTimelineStats[c].mem.rss/(1024*1024)})}}}serverTimelineConfig.data=b;window.serverMainStats.update()}function p40downloadEvents(){var a="time, conn.agent, conn.users, conn.usersessions, conn.relaysession, conn.intelamt, mem.external, mem.heapused, mem.heaptotal, mem.rss\r\n";for(var b=0;b<serverTimelineStats.length;b++){if(serverTimelineStats[b].conn&&serverTimelineStats[b].mem){a+=new Date(serverTimelineStats[b].time)+", "+serverTimelineStats[b].conn.ca+", "+serverTimelineStats[b].conn.cu+", "+serverTimelineStats[b].conn.us+", "+serverTimelineStats[b].conn.rs+", "+(serverTimelineStats[b].conn.am?serverTimelineStats[b].conn.am:"")+", "+serverTimelineStats[b].mem.external+", "+serverTimelineStats[b].mem.heapUsed+", "+serverTimelineStats[b].mem.heapTotal+", "+serverTimelineStats[b].mem.rss+"\r\n"}}saveAs(new Blob([a],{type:"application/octet-stream"}),"ServerStats.csv")}var xxdialogMode;var xxdialogFunc;var xxdialogButtons;var xxdialogTag;var xxcurrentView=-1;function setDialogMode(j,k,a,e,d,h){setSessionActivity();QV("uiMenu",false);xxdialogMode=j;xxdialogFunc=e;xxdialogButtons=a;xxdialogTag=h;QE("idx_dlgOkButton",true);QV("idx_dlgOkButton",a&1);QV("idx_dlgCancelButton",a&2);QV("id_dialogclose",(a&2)||(a&8));QV("idx_dlgDeleteButton",a&4);QV("idx_dlgButtonBar",a&7);if(k){QH("id_dialogtitle",k)}for(var g=1;g<24;g++){QV("dialog"+g,g==j)}QV("dialog",j);if(d){if(j==2){QH("id_dialogOptions",d)}else{QH("id_dialogMessage",d)}}}function dialogclose(e){setSessionActivity();var c=xxdialogFunc,a=xxdialogButtons,d=xxdialogTag;setDialogMode();if(((a&8)||e)&&c){c(e,d)}}function center(){setSessionActivity();if(xxcurrentView==11){deskAdjust()}else{if(xxcurrentView==10){masterUpdate(256)}else{if(xxcurrentView==1){masterUpdate(4)}}}}function messagebox(b,a){setSessionActivity();QH("id_dialogMessage",a);setDialogMode(1,b,1)}function statusbox(b,a){setSessionActivity();QH("id_dialogMessage",a);setDialogMode(1,b)}function goBack(){setSessionActivity();if(xxdialogMode){return}if(fullscreen){deskToggleFull()}if((xxcurrentView>=10)&&(xxcurrentView<20)){go(1)}if((xxcurrentView>=20)&&(xxcurrentView<30)){go(2)}if((xxcurrentView>=30)&&(xxcurrentView<40)){go(4)}}function go(h){setSessionActivity();if(xxdialogMode||xxcurrentView==h){return}QV("uiMenu",false);for(var a=0;a<41;a++){QV("p"+a,a==h)}xxcurrentView=h;var d=["MainMenuMyDevices","MainMenuMyAccount","MainMenuMyEvents","MainMenuMyFiles","MainMenuMyUsers","MainMenuMyServer"];for(var a in d){QC(d[a]).remove("fullselect");QC(d[a]).remove("semiselect")}var b=["LeftMenuMyDevices","LeftMenuMyAccount","LeftMenuMyEvents","LeftMenuMyFiles","LeftMenuMyUsers","LeftMenuMyServer"];for(var a in b){QC(b[a]).remove("lbbuttonsel");QC(b[a]).remove("lbbuttonsel2")}var e=(h<9?"fullselect":"semiselect");var c=(h<9?"lbbuttonsel2":"lbbuttonsel");if(h==1||(h>=10&&h<20)){QC("MainMenuMyDevices").add(e)}if(h==1||(h>=10&&h<20)){QC("LeftMenuMyDevices").add(c)}if(h==2||(h>=20&&h<30)){QC("MainMenuMyAccount").add(e)}if(h==2||(h>=20&&h<30)){QC("LeftMenuMyAccount").add(c)}if(h==3){QC("MainMenuMyEvents").add(e)}if(h==3){QC("LeftMenuMyEvents").add(c)}if(h==4||(h>=30&&h<40)){QC("MainMenuMyUsers").add(e)}if(h==4||(h>=30&&h<40)){QC("LeftMenuMyUsers").add(c)}if(h==5){QC("MainMenuMyFiles").add(e)}if(h==5){QC("LeftMenuMyFiles").add(c)}if((h==6)||(h==115)){QC("MainMenuMyServer").add(e)}if((h==6)||(h==115)||(h==40)){QC("LeftMenuMyServer").add(c)}if(webPageStackMenu&&(h>=10)){QC("column_l").add("room4submenu")}else{QC("column_l").remove("room4submenu")}QV("topbar",h!=0);if((h==0)&&(webPageFullScreen)){QC("body").add("arg_hide")}QV("MainSubMenuSpan",h>=10&&h<20);QV("UserDummyMenuSpan",(h<10)&&(h!=6)&&webPageFullScreen);QV("MeshSubMenuSpan",h>=20&&h<30);QV("UserSubMenuSpan",h>=30&&h<40);QV("ServerSubMenuSpan",h==6||h==115||h==40);var g={10:"MainDev",11:"MainDevDesktop",12:"MainDevTerminal",13:"MainDevFiles",14:"MainDevAmt",15:"MainDevConsole",16:"MainDevEvents",20:"MeshGeneral",30:"UserGeneral",31:"UserEvents",6:"ServerGeneral",40:"ServerStats",115:"ServerConsole"};for(var a in g){QC(g[a]).remove("style3x");QC(g[a]).remove("style3sel");QC(g[a]).add((h==a)?"style3sel":"style3x")}if(h==11){deskAdjust()}if(h==115){QV("p15",true)}QV("p15uploadCore",h!=115);QV("p15BackButton",h!=115);if((h==15)||(h==115)){setupConsole()}if(h==1){masterUpdate(4)}if((h==2)&&Notification){QV("accountEnableNotificationsSpan",Notification.permission!="granted")}if((h==40)&&(serverTimelineStats==null)){refreshServerTimelineStats()}if((currentNode)&&(h>=10)&&(h<20)){document.title=decodeURIComponent("{{{extitle}}}")+" - "+currentNode.name}else{document.title=decodeURIComponent("{{{extitle}}}")}}function joinPaths(){var c=[];for(var a in arguments){var b=arguments[a];if((b!=null)&&(b!="")){while(b.endsWith("/")||b.endsWith("\\")){b=b.substring(0,b.length-1)}while(b.startsWith("/")||b.startsWith("\\")){b=b.substring(1)}c.push(b)}}return c.join("/")}function putstore(g,j){try{if((typeof(localStorage)==="undefined")||(localStorage.getItem(g)==j)){return}localStorage.setItem(g,j)}catch(a){}if(g[0]!="_"){var h={};for(var b=0,d=localStorage.length;b<d;++b){var c=localStorage.key(b);if(c[0]!="_"){h[c]=localStorage.getItem(c)}}meshserver.send({action:"userWebState",state:JSON.stringify(h)})}}function getstore(b,d){try{if(typeof(localStorage)==="undefined"){return d}var c=localStorage.getItem(b);if((c==null)||(c==null)){return d}return c}catch(a){return d}}function addLink(b,a){return"<span tabindex=0 style=cursor:pointer;text-decoration:none onclick='"+a+"' onkeypress=\"if (event.key=='Enter') {"+a+'} ">'+b+" <img class=hoverButton src=images/link5.png></span>"}function addLinkConditional(d,b,a){if(a){return addLink(d,b)}return d}function haltEvent(a){if(a.preventDefault){a.preventDefault()}if(a.stopPropagation){a.stopPropagation()}return false}function addOption(c,d,a){var b=document.createElement("option");b.text=d;b.value=a;Q(c).add(b)}function passwordcheck(a){return(a.length>7)&&(/\d/.test(a))&&(/[a-z]/.test(a))&&(/[A-Z]/.test(a))&&(/\W/.test(a))}function methodcheck(a){if(a&&a!=null&&a.Body&&a.Body.ReturnValueStr!="SUCCESS"){messagebox("Call Error",a.Header.Method+": "+a.Body.ReturnValueStr.replace("_"," "));return true}return false}function TableStart(){return"<table cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px><tr><td width=200px><p><td>"}function TableStart2(){return"<table cellpadding=0 cellspacing=0 style=width:100%;border-radius:8px><tr><td><p><td>"}function TableEntry(a,b){return"<tr><td><p>"+a+"<td>"+b}function FullTable(c,a){var b=TableStart();for(i in c){if(i&&c[i]){b+=TableEntry(i,c[i])}}return b+TableEnd(a)}function TableEnd(a){return"<tr><td colspan=2><p>"+(a?a:"")+"</table>"}function AddButton(b,a){return"<input type=button value='"+b+"' onclick='"+a+"' style=margin:4px>"}function AddButton2(b,a){return"<input type=button value='"+b+"' onclick='"+a+"'>"}function AddRefreshButton(a){return"<input type=button name=refreshbtn value=Refresh onclick='refreshButtons(false);"+a+"' style=margin:4px "+(refreshButtonsState==false?"disabled":"")+">"}function MoreStart(){return'<a href=# style=cursor:pointer;color:blue id=morexxx1 onclick=QV("morexxx1",false);QV("morexxx2",true)>&#x25BC; More</a><div id=morexxx2 style=display:none><br><hr>'}function MoreEnd(){return'<a href=# style=cursor:pointer;color:blue onclick=QV("morexxx2",false);QV("morexxx1",true)>&#x25B2; Less</a></div>'}function getSelectedOptions(e){var d=[],c;for(var a=0,b=e.options.length;a<b;a++){c=e.options[a];if(c.selected){d.push(c.value)}}return d}function getInstance(b,c){for(var a in b){if(b[a]["InstanceID"]==c){return b[a]}}return null}function getItem(b,c,d){for(var a in b){if(b[a][c]==d){return b[a]}}return null}function guidToStr(a){return a.substring(6,8)+a.substring(4,6)+a.substring(2,4)+a.substring(0,2)+"-"+a.substring(10,12)+a.substring(8,10)+"-"+a.substring(14,16)+a.substring(12,14)+"-"+a.substring(16,20)+"-"+a.substring(20)}function getUrlVars(){var d,a,e=[],b=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(var c=0;c<b.length;c++){d=b[c].indexOf("=");if(d>0){e[b[c].substring(0,d)]=b[c].substring(d+1,b[c].length)}}return e}function addHtmlValue(a,b){return"<table><td style=width:120px>"+a+"<td><b>"+b+"</b></table>"}function addHtmlValue2(a,b){return"<div><div style=display:inline-block;float:right>"+b+"</div><div style=display:inline-block>"+a+"</div></div>"}function parseUriArgs(){var a,c={},b=window.document.location.href.split(/[\?&|\=]/);b.splice(0,1);for(d in b){switch(d%2){case 0:a=decodeURIComponent(b[d]);break;case 1:c[a]=decodeURIComponent(b[d]);var d=parseInt(c[a]);if(d==c[a]){c[a]=d}break;default:break}}return c}function focusTextBox(a){setTimeout(function(){Q(a).selectionStart=Q(a).selectionEnd=65535;Q(a).focus()},0)}function validateEmail(b){var a=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return a.test(b)}function isPrivateIP(b){return(b.startsWith("10.")||b.startsWith("172.16.")||b.startsWith("192.168."))}function u2fSupported(){return(window.u2f&&((navigator.userAgent.indexOf("Chrome/")>0)||(navigator.userAgent.indexOf("Firefox/")>0)||(navigator.userAgent.indexOf("Opera/")>0)||(navigator.userAgent.indexOf("Safari/")>0)))}function findOne(a,b){if((a==null)||(b==null)){return false}return b.some(function(c){return a.indexOf(c)>=0})}function copyTextToClip(c){function b(d){if(document.selection){var g=document.body.createTextRange();g.moveToElementText(d);g.select()}else{if(window.getSelection){var g=document.createRange();g.selectNode(d);window.getSelection().removeAllRanges();window.getSelection().addRange(g)}}}var a=document.createElement("DIV");a.textContent=c;document.body.appendChild(a);b(a);document.execCommand("copy");a.remove()}function printDate(a){return a.toLocaleDateString(args.locale)}function printTime(a){return a.toLocaleTimeString(args.locale)}function printDateTime(a){return a.toLocaleString(args.locale)};</script></body></html>
\ No newline at end of file
views/default-old.handlebars new
+8433
@@ -0,0 +1,8433 @@
1 +<!DOCTYPE html>
2 +<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
3 +<head>
4 + <meta http-equiv="X-UA-Compatible" content="IE=edge" />
5 + <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
6 + <meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" />
7 + <meta name="apple-mobile-web-app-capable" content="yes" />
8 + <meta name="format-detection" content="telephone=no" />
9 + <link rel="shortcut icon" type="image/x-icon" href="{{{domainurl}}}favicon.ico" />
10 + <link keeplink=1 type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS" />
11 + <link type="text/css" href="styles/ol.css" media="screen" rel="stylesheet" title="CSS" />
12 + <link type="text/css" href="styles/ol3-contextmenu.min.css" media="screen" rel="stylesheet" title="CSS" />
13 + <script type="text/javascript" src="scripts/common-0.0.1.js"></script>
14 + <script type="text/javascript" src="scripts/meshcentral.js"></script>
15 + <script type="text/javascript" src="scripts/amt-0.2.0.js"></script>
16 + <script type="text/javascript" src="scripts/amt-wsman-0.2.0.js"></script>
17 + <script type="text/javascript" src="scripts/amt-desktop-0.0.2.js"></script>
18 + <script type="text/javascript" src="scripts/amt-terminal-0.0.2.js"></script>
19 + <script type="text/javascript" src="scripts/zlib.js"></script>
20 + <script type="text/javascript" src="scripts/zlib-inflate.js"></script>
21 + <script type="text/javascript" src="scripts/zlib-adler32.js"></script>
22 + <script type="text/javascript" src="scripts/zlib-crc32.js"></script>
23 + <script type="text/javascript" src="scripts/amt-redir-ws-0.1.0.js"></script>
24 + <script type="text/javascript" src="scripts/amt-wsman-ws-0.2.0.js"></script>
25 + <script type="text/javascript" src="scripts/agent-redir-ws-0.1.0.js"></script>
26 + <script type="text/javascript" src="scripts/agent-redir-rtc-0.1.0.js"></script>
27 + <script type="text/javascript" src="scripts/agent-desktop-0.0.2.js"></script>
28 + <script type="text/javascript" src="scripts/qrcode.min.js"></script>
29 + <script keeplink=1 type="text/javascript" src="scripts/u2f-api.js"></script>
30 + <script keeplink=1 type="text/javascript" src="scripts/charts.js"></script>
31 + <script keeplink=1 type="text/javascript" src="scripts/filesaver.js"></script>
32 + <script keeplink=1 type="text/javascript" src="scripts/ol.js"></script>
33 + <script keeplink=1 type="text/javascript" src="scripts/ol3-contextmenu.js"></script>
34 + <title>{{{title}}}</title>
35 +</head>
36 +<body id="body" onload="if (typeof(startup) !== 'undefined') startup();" oncontextmenu="handleContextMenu(event)" style="display:none;min-width:495px">
37 + <!-- right click menu -->
38 + <div id="contextMenu" class="contextMenu noselect" style="display:none">
39 + <div id="cxinfo" class="cmtext" onclick="cmaction(1,event)"><b>Information</b></div>
40 + <div id="cxdesktop" class="cmtext" onclick="cmaction(3,event)">Desktop</div>
41 + <div id="cxterminal" class="cmtext" onclick="cmaction(2,event)">Terminal</div>
42 + <div id="cxfiles" class="cmtext" onclick="cmaction(4,event)">Files</div>
43 + <div id="cxevents" class="cmtext" onclick="cmaction(5,event)">Events</div>
44 + <div id="cxconsole" class="cmtext" onclick="cmaction(6,event)">Console</div>
45 + <hr id="cxmgroupsplit" />
46 + <div id="cxmdesktop" class="cmtext" onclick="cmaction(7,event)" style="display:none">Multi-Desktop</div>
47 + </div>
48 + <div id="meshContextMenu" class="contextMenu,noselect" style="display: none; min-width: 0px">
49 + <div id="cxselectall" class="cmtext" onclick="cmmeshaction(1,event)">Select All</div>
50 + <div id="cxselectnone" class="cmtext" onclick="cmmeshaction(2,event)">Select None</div>
51 + <hr id="cxmgroupsplit2" style="display:none" />
52 + <div id="cxmmdesktop" class="cmtext" style="display:none" onclick="cmmeshaction(3,event)">Multi-Desktop</div>
53 + </div>
54 + <!-- main page -->
55 + <div id=container>
56 + <div id="notifiyBox" class="notifiyBox" style="display:none"></div>
57 + <div id=masthead class=noselect>
58 + <div class="title">{{{title}}}</div>
59 + <div class="title2">{{{title2}}}</div>
60 + <div style="float:right">
61 + <div id=notificationCount onclick="clickNotificationIcon()" class="unselectable" style="display: none;" title="Click to view current notifications">0</div>
62 + </div>
63 + <p id="logoutControl">{{{logoutControl}}}<span id=idleTimeoutNotify style="color:yellow"></span></p>
64 + </div>
65 + <div id="page_leftbar">
66 + <div style="height:16px"></div>
67 + <div id=LeftMenuMyDevices tabindex=0 class="lbbutton lbbuttonsel" title="My Devices" onclick=go(1) onkeypress="if (event.key=='Enter') { go(1); }">
68 + <div class="lb2"></div>
69 + </div>
70 + <div id=LeftMenuMyAccount tabindex=0 class="lbbutton" title="My Account" onclick=go(2) onkeypress="if (event.key=='Enter') { go(2); }">
71 + <div class="lb1"></div>
72 + </div>
73 + <div id=LeftMenuMyEvents tabindex=0 class="lbbutton" title="My Events" onclick=go(3) onkeypress="if (event.key=='Enter') { go(3); }">
74 + <div class="lb3"></div>
75 + </div>
76 + <div id=LeftMenuMyFiles tabindex=0 class="lbbutton" style="display:none" title="My Files" onclick=go(5) onkeypress="if (event.key=='Enter') { go(5); }">
77 + <div class="lb4"></div>
78 + </div>
79 + <div id=LeftMenuMyUsers tabindex=0 class="lbbutton" style="display:none" title="My Users" onclick=go(4) onkeypress="if (event.key=='Enter') { go(4); }">
80 + <div class="lb5"></div>
81 + </div>
82 + <div id=LeftMenuMyServer tabindex=0 class="lbbutton" style="display:none" title="My Server" onclick=go(6) onkeypress="if (event.key=='Enter') { go(6); }">
83 + <div class="lb6"></div>
84 + </div>
85 + </div>
86 + <div id=topbar class=noselect>
87 + <div>
88 + <div style="position:relative">
89 + <div tabindex=0 id=uiMenuButton title="User interface selection" onclick="showUserInterfaceSelectMenu()" onkeypress="if (event.key == 'Enter') showUserInterfaceSelectMenu()">&diams;
90 + <div id=uiMenu style="display:none">
91 + <div tabindex=0 id=uiViewButton1 class=uiSelector onclick=userInterfaceSelectMenu(1) title="Left bar interface" onkeypress="if (event.key == 'Enter') userInterfaceSelectMenu(1)"><div class="uiSelector1"></div></div>
92 + <div tabindex=0 id=uiViewButton2 class=uiSelector onclick=userInterfaceSelectMenu(2) title="Top bar interface" onkeypress="if (event.key == 'Enter') userInterfaceSelectMenu(2)"><div class="uiSelector2"></div></div>
93 + <div tabindex=0 id=uiViewButton3 class=uiSelector onclick=userInterfaceSelectMenu(3) title="Fixed width interface" onkeypress="if (event.key == 'Enter') userInterfaceSelectMenu(3)"><div class="uiSelector3"></div></div>
94 + <div tabindex=0 id=uiViewButton4 class=uiSelector onclick=toggleNightMode() title="Toggle night mode" onkeypress="if (event.key == 'Enter') toggleNightMode()"><div class="uiSelector4"></div></div>
95 + </div>
96 + </div>
97 + <table id=MainMenuSpan cellpadding=0 cellspacing=0 class=style1>
98 + <tr>
99 + <td tabindex=0 id=MainMenuMyDevices class="topbar_td style3x" onclick=go(1) onkeypress="if (event.key == 'Enter') go(1)">My Devices</td>
100 + <td tabindex=0 id=MainMenuMyAccount class="topbar_td style3x" onclick=go(2) onkeypress="if (event.key == 'Enter') go(2)">My Account</td>
101 + <td tabindex=0 id=MainMenuMyEvents class="topbar_td style3x" onclick=go(3) onkeypress="if (event.key == 'Enter') go(3)">My Events</td>
102 + <td tabindex=0 id=MainMenuMyFiles class="topbar_td style3x" onclick=go(5) onkeypress="if (event.key == 'Enter') go(5)">My Files</td>
103 + <td tabindex=0 id=MainMenuMyUsers class="topbar_td style3x" onclick=go(4) onkeypress="if (event.key == 'Enter') go(4)">My Users</td>
104 + <td tabindex=0 id=MainMenuMyServer class="topbar_td style3x" onclick=go(6) onkeypress="if (event.key == 'Enter') go(6)">My Server</td>
105 + <td class="topbar_td_end style3">&nbsp;</td>
106 + </tr>
107 + </table>
108 + <div id=MainSubMenuSpan style="display:none">
109 + <table id=MainSubMenu cellpadding=0 cellspacing=0 class=style1>
110 + <tr>
111 + <td tabindex=0 id=MainDev class="topbar_td style3x" onclick=go(10) onkeypress="if (event.key == 'Enter') go(10)">General</td>
112 + <td tabindex=0 id=MainDevDesktop class="topbar_td style3x" onclick=go(11) onkeypress="if (event.key == 'Enter') go(11)">Desktop</td>
113 + <td tabindex=0 id=MainDevTerminal class="topbar_td style3x" onclick=go(12) onkeypress="if (event.key == 'Enter') go(12)">Terminal</td>
114 + <td tabindex=0 id=MainDevFiles class="topbar_td style3x" onclick=go(13) onkeypress="if (event.key == 'Enter') go(13)">Files</td>
115 + <td tabindex=0 id=MainDevEvents class="topbar_td style3x" onclick=go(16) onkeypress="if (event.key == 'Enter') go(16)">Events</td>
116 + <td tabindex=0 id=MainDevAmt class="topbar_td style3x" onclick=go(14) onkeypress="if (event.key == 'Enter') go(14)">Intel&reg; AMT</td>
117 + <td tabindex=0 id=MainDevConsole class="topbar_td style3x" onclick=go(15) onkeypress="if (event.key == 'Enter') go(15)">Console</td>
118 + <td class="topbar_td_end style3">&nbsp;</td>
119 + </tr>
120 + </table>
121 + </div>
122 + <div id=MeshSubMenuSpan style="display:none">
123 + <table id=MeshSubMenu cellpadding=0 cellspacing=0 class=style1>
124 + <tr>
125 + <td tabindex=0 id=MeshGeneral class="topbar_td style3x" onclick=go(20) onkeypress="if (event.key == 'Enter') go(20)">General</td>
126 + <td class="topbar_td_end style3">&nbsp;</td>
127 + </tr>
128 + </table>
129 + </div>
130 + <div id=UserSubMenuSpan style="display:none">
131 + <table id=UserSubMenu cellpadding=0 cellspacing=0 class=style1>
132 + <tr>
133 + <td tabindex=0 id=UserGeneral class="topbar_td style3x" onclick=go(30) onkeypress="if (event.key == 'Enter') go(30)">General</td>
134 + <td tabindex=0 id=UserEvents class="topbar_td style3x" onclick=go(31) onkeypress="if (event.key == 'Enter') go(31)">Events</td>
135 + <td class="topbar_td_end style3">&nbsp;</td>
136 + </tr>
137 + </table>
138 + </div>
139 + <div id=ServerSubMenuSpan style="display:none">
140 + <table id=ServerSubMenu cellpadding=0 cellspacing=0 class=style1>
141 + <tr>
142 + <td tabindex=0 id=ServerGeneral class="topbar_td style3x" onclick=go(6) onkeypress="if (event.key == 'Enter') go(6)">General</td>
143 + <td tabindex=0 id=ServerStats class="topbar_td style3x" onclick=go(40) onkeypress="if (event.key == 'Enter') go(40)">Stats</td>
144 + <td tabindex=0 id=ServerConsole class="topbar_td style3x" onclick=go(115) onkeypress="if (event.key == 'Enter') go(115)">Console</td>
145 + <td class="topbar_td_end style3">&nbsp;</td>
146 + </tr>
147 + </table>
148 + </div>
149 + <div id=UserDummyMenuSpan>
150 + <table id=UserDummyMenu cellpadding=0 cellspacing=0 class=style1>
151 + <tr><td class=style3 style="">&nbsp;</td></tr>
152 + </table>
153 + </div>
154 + </div>
155 + </div>
156 + </div>
157 + <div id="column_l">
158 + <div id=p0 style="display:none">
159 + <div id=p0message><span id=p0span>Server disconnected</span>, <href onclick=reload() style=cursor:pointer><u>click to reconnect</u></href>.</div>
160 + </div>
161 + <div id=p1 style="display:none">
162 + <div style="display:none" id="devListToolbarViewIcons">
163 + <div tabindex=0 id=devViewButton1 class=viewSelector onclick=onDeviceViewChange(1) onkeypress="if (event.key=='Enter') { onDeviceViewChange(1); }" title="Columns"><div class="viewSelector2"></div></div>
164 + <div tabindex=0 id=devViewButton2 class=viewSelector onclick=onDeviceViewChange(2) onkeypress="if (event.key == 'Enter') { onDeviceViewChange(2); }" title="List"><div class="viewSelector1"></div></div>
165 + <div tabindex=0 id=devViewButton3 class=viewSelector onclick=onDeviceViewChange(3) onkeypress="if (event.key == 'Enter') { onDeviceViewChange(3); }" title="Desktops"><div class="viewSelector3"></div></div>
166 + <div tabindex=0 id=devViewButton4 class=viewSelector onclick=onDeviceViewChange(4) onkeypress="if (event.key == 'Enter') { onDeviceViewChange(4); }" title="Map"><div class="viewSelector4"></div></div>
167 + </div><div><h1>My Devices</h1></div>
168 + <table id="devListToolbarSpan" class="noselect">
169 + <tr>
170 + <td class=h1></td>
171 + <td id=devListToolbar class=style14 style="display:none">
172 + &nbsp;&nbsp;<input type="button" id="SelectAllButton" onclick="selectallButtonFunction();" value="Select All" />&nbsp;
173 + <input type=button id=GroupActionButton disabled="disabled" value="Group Action" onclick=groupActionFunction() />&nbsp;
174 + <input id=SearchInput type=text placeholder=Filter onchange=masterUpdate(5) onkeyup=masterUpdate(5) autocomplete=off onfocus=onSearchFocus(1) onblur=onSearchFocus(0) />&nbsp;
175 + <label><input type=checkbox id=RealNameCheckBox onclick=onRealNameCheckBox() /><span title="Show devices operating system name">OS Name</span></label>
176 + </td>
177 + <td id=kvmListToolbar class=style14 style="display:none">
178 + &nbsp;&nbsp;<input type="button" onclick="connectAllKvmFunction()" value="Connect All" />&nbsp;
179 + <input type="button" onclick="disconnectAllKvmFunction()" value="Disconnect All" />&nbsp;
180 + <label><input type="checkbox" id="autoConnectDesktopCheckbox" onclick="autoConnectDesktops(event)" title="Automatic connect" />Auto&nbsp;</label>
181 + <input type="button" onclick="showMultiDesktopSettings()" value="Settings" />&nbsp;
182 + </td>
183 + <td id=devMapToolbar class=style14 style="display:none">
184 + &nbsp;&nbsp;<input type=text id=mapSearchLocation placeholder="Search Location" onfocus=onMapSearchFocus(1) onblur=onMapSearchFocus(0) />
185 + <input type=button value=Search title="Search for location" onclick=getSearchLocation() />
186 + <input type=button id=refreshmap title="Reset map view" value=Reset onclick=refreshMap(false,true) />
187 + </td>
188 + <td class="auto-style1" style=height:100%>
189 + <div style="display:none" id=devListToolbarView>
190 + View
191 + <select id=viewselect onchange=onDeviceViewChange()>
192 + <option value=1>Columns</option>
193 + <option value=2>List</option>
194 + <option value=3>Desktops</option>
195 + <option id=viewselectmapoption value=4>Map</option>
196 + </select>
197 + </div>
198 + <div style="display:none" id=devListToolbarSort>
199 + Sort
200 + <select id=sortselect onchange=masterUpdate(6)>
201 + <option>Group</option>
202 + <option>Power</option>
203 + <option>Device</option>
204 + <option>Tags</option>
205 + </select>
206 + &nbsp;
207 + </div>
208 + <div style="display:none" id=devListToolbarSize>
209 + Size
210 + <select id=sizeselect onchange=onDeviceViewChange()>
211 + <option value=0>Small</option>
212 + <option value=1>Medium</option>
213 + <option value=2>Large</option>
214 + </select>
215 + &nbsp;
216 + </div>
217 + </td>
218 + <td class=h2></td>
219 + </tr>
220 + </table>
221 + <div id=NoMeshesPanel style="display:none">
222 + <table>
223 + <tr>
224 + <td valign="top" style="width: 50px">
225 + <img src="images/info.png" />
226 + </td>
227 + <td>
228 + <div id="getStarted1">To get started, <a href=# onclick="return account_createMesh()"><strong>click here to create a device group</strong></a>.</div>
229 + <div id="getStarted2">No device groups.</div>
230 + </td>
231 + </tr>
232 + </table>
233 + </div>
234 + <div id="xdevices" class="noselect" style="display:none"></div>
235 + <div id="xdevicesmap" style="display:none">
236 + <div id=xmapSearchResultsDlg style="display:none">
237 + <div id=xmapSearchResultsBck>
238 + <div id=xmapSearchClose onclick=mapCloseSearchWindow()><b>X</b></div>
239 + <div style=padding:5px>Location Results</div>
240 + <div style=width:100%;margin:6px></div>
241 + </div>
242 + <div id=xmapSearchResults style=margin:6px></div>
243 + </div>
244 + </div>
245 + <div id="xmap-info-window"></div>
246 + </div>
247 + <div id=p2 style="display:none">
248 + <h1>My Account</h1>
249 + <img id="p2AccountImage" alt="" src="images/clipboard-128.png"/>
250 + <div id="p2AccountSecurity" style="display:none">
251 + <p><strong>Account security</strong></p>
252 + <div style="margin-left:25px">
253 + <div id="manageAuthApp"><div class="p2AccountActions"><span id="authAppSetupCheck"><strong>&#x2713;</strong></span></div><span><a href=# onclick="return account_manageAuthApp()">Manage authenticator app</a><br /></span></div>
254 + <div id="manageHardwareOtp"><div class="p2AccountActions"><span id="authKeySetupCheck"><strong>&#x2713;</strong></span></div><span><a href=# onclick="return account_manageHardwareOtp(0)">Manage security keys</a><br /></span></div>
255 + <div id="manageOtp"><div class="p2AccountActions"><span id="authCodesSetupCheck"><strong>&#x2713;</strong></span></div><span><a href=# onclick="return account_manageOtp(0)">Manage backup codes</a><br /></span></div>
256 + </div>
257 + </div>
258 + <div id="p2AccountActions">
259 + <p><strong>Account actions</strong></p>
260 + <p class="mL">
261 + <span id="verifyEmailId" style="display:none"><a href=# onclick="return account_showVerifyEmail()">Verify email</a><br /></span>
262 + <span id="accountEnableNotificationsSpan" style="display:none"><a href=# onclick="return account_enableNotifications()">Enable web notifications</a><br /></span>
263 + <a href=# onclick="return account_showAccountNotifySettings()">Notification Settings</a><br />
264 + <span id="accountChangeEmailAddressSpan" style="display:none"><a href=# onclick="return account_showChangeEmail()">Change email address</a><br /></span>
265 + <a href=# onclick="return account_showChangePassword()">Change password</a><span id="p2nextPasswordUpdateTime"></span><br />
266 + <a href=# onclick="return account_showDeleteAccount()">Delete account</a><br />
267 + </p>
268 + <br style=clear:both />
269 + </div>
270 + <strong>Device Groups</strong>
271 + <span id="p2createMeshLink1">( <a href=# onclick="return account_createMesh()" class="newMeshBtn"> New</a> )</span>
272 + <br /><br />
273 + <div id=p2meshes></div>
274 + <div id=p2noMeshFound style="display:none">No device groups.<span id="p2createMeshLink2"> <a href=# onclick="return account_createMesh()"><strong>Get started here!</strong></a></span></div>
275 + <br style=clear:both />
276 + </div>
277 + <div id=p3 style="display:none">
278 + <h1>My Events</h1>
279 + <table class="pTable">
280 + <tr>
281 + <td class="h1"></td>
282 + <td>&nbsp;<input id="p2deleteall" type=button onclick=showDeleteAllEventsDialog() style="display:none" value="Delete All..." /></td>
283 + <td class="auto-style1">
284 + Show
285 + <select id=p3limitdropdown onchange=refreshEvents()>
286 + <option value=60>Last 60</option>
287 + <option value=120>Last 120</option>
288 + <option value=250>Last 250</option>
289 + <option value=500>Last 500</option>
290 + <option value=1000>Last 1000</option>
291 + </select>&nbsp;
292 + <a href=# onclick=p3showDownloadEventsDialog()><img src=images/link4.png height=10 width=10 title="Download Events" style=cursor:pointer></a>&nbsp;
293 + </td>
294 + <td class="h2"></td>
295 + </tr>
296 + </table>
297 + <div id=p3events style=""></div>
298 + </div>
299 + <div id=p4 style="display:none">
300 + <h1>My Users</h1>
301 + <table class="pTable">
302 + <tr>
303 + <td class="h1"></td>
304 + <td class="style14">
305 + <div style="float:right">
306 + <input type=button onclick=showUserBroadcastDialog() style=margin-right:6px value="Broadcast" />
307 + <a href=# onclick=p4downloadUserInfo()><img style="cursor:pointer" title="Download user information" src="images/link4.png" /></a>
308 + <a href=# onclick=p4batchAccountCreate()><img id=p4UserBatchCreate style="cursor:pointer;display:none" title="Batch create many user accounts" src="images/link6.png" /></a>
309 + </div>
310 + <div>
311 + <input id=UserNewAccountButton type=button style=margin-left:6px onclick=showCreateNewAccountDialog() value="New Account..." />
312 + <input id=UserSearchInput type=text style=width:120px;margin-left:6px placeholder=Filter onchange=onUserSearchInputChanged() onkeyup=onUserSearchInputChanged() autocomplete=off onfocus=onUserSearchFocus(1) onblur=onUserSearchFocus(0) />
313 + </div>
314 + </td>
315 + <td class="h2"></td>
316 + </tr>
317 + </table>
318 + <div id="p3users"></div>
319 + </div>
320 + <div id=p5 style="display:none">
321 + <h1>My Files</h1>
322 + <table id="p5toolbar" cellpadding="0" cellspacing="0">
323 + <tr>
324 + <td id="p5filehead" valign=bottom>
325 + <div id="p5rightOfButtons"></div>
326 + <div>
327 + <input type=button id=p5FolderUp disabled="disabled" onclick="return p5folderup();" value="Up" />&nbsp;
328 + <input type=button id=p5SelectAllButton disabled="disabled" onclick="p5selectallfile();" value="Select All" />&nbsp;
329 + <input type=button id=p5RenameFileButton disabled="disabled" value="Rename" onclick="p5renamefile();" />&nbsp;
330 + <input type=button id=p5DeleteFileButton disabled="disabled" value="Delete" onclick="p5deletefile();" />&nbsp;
331 + <input type=button id=p5NewFolderButton disabled="disabled" value="New Folder" onclick="p5createfolder();" />&nbsp;
332 + <input type=button id=p5UploadButton disabled="disabled" value="Upload" onclick="p5uploadFile()" />&nbsp;
333 + <input type=button id=p5CutButton disabled="disabled" value="Cut" onclick="p5copyFile(1)" />&nbsp;
334 + <input type=button id=p5CopyButton disabled="disabled" value="Copy" onclick="p5copyFile(0)" />&nbsp;
335 + <input type=button id=p5PasteButton disabled="disabled" value="Paste" onclick="p5pasteFile()" />&nbsp;
336 + </div>
337 + </td>
338 + </tr>
339 + <tr>
340 + <td id="p5filesubhead">
341 + <div style=float:right>
342 + <select id=p5sortdropdown onchange=updateFiles()>
343 + <option value="1" selected="selected">Sort by name</option>
344 + <option value="2">Sort by size</option>
345 + <option value="3">Sort by date</option>
346 + <option value="4">Descend by name</option>
347 + <option value="5">Descend by size</option>
348 + <option value="6">Descend by date</option>
349 + </select>
350 + </div>
351 + <div>&nbsp;&nbsp;<span id="p5currentpath"></span></div>
352 + </td>
353 + </tr>
354 + </table>
355 + <div id="p5filetable">
356 + <!--
357 + <form id=p5fileCatchAll method=post enctype=multipart/form-data action=uploadfile.ashx target=fileUploadFrame>
358 + <input type=file id=p5fileCatchAllInput name=files style="position:absolute;left:0;width:100%;top:0;bottom:0;opacity:0;display:none" onchange="p5fileCatchAllInputChanged(event)" />
359 + <input id=p5fileDragLink2 name="link" style="display:none" />
360 + <input type=submit id=p5fileCatchAllSubmit style="display:none" />
361 + </form>
362 + -->
363 + <div id="p5PublicShare" style=""><div>These files are shared publicly, click "link" to get public url.</div></div>
364 + <div id="bigok" style="display:none"><b>&checkmark;</b></div>
365 + <div id="bigfail" style="display:none"><b>&#10007;</b></div>
366 + <span id="p5files"></span>
367 + </div>
368 + <table id="p5toolbarBottom" style=width:100% cellpadding=0 cellspacing=0>
369 + <tr><td class=style6>&nbsp;<span id="p5bottomstatus"></span></td></tr>
370 + </table>
371 + </div>
372 + <div id=p6 style="display:none">
373 + <img id=MainMeshImage src="serverpic.ashx">
374 + <h1>My Server</h1>
375 + <div id="p2ServerActions">
376 + <p><strong>Server actions</strong></p>
377 + <div class="mL">
378 + <div id="p2ServerActionsBackup"><a href="{{{domainurl}}}backup.zip" rel="noreferrer noopener" target="_blank">Download server backup</a></div>
379 + <div id="p2ServerActionsRestore"><a href=# onclick="return server_showRestoreDlg()">Restore server with backup</a></div>
380 + <div id="p2ServerActionsVersion"><a href=# onclick="return server_showVersionDlg()">Check server version</a></div>
381 + <div id="p2ServerActionsErrors"><a href=# onclick="return server_showErrorsDlg()">Show server error log</a></div>
382 + </div>
383 + </div>
384 + <br /><strong>Server Statistics</strong><br /><br />
385 + <div id="serverStats">
386 + <div id="serverCpuChartView" style="display:none">
387 + <div class="chartViewCanvas"><canvas id="serverCpuChart"></canvas></div>
388 + <div class="chartViewText" id="serverCpuChartText"></div>
389 + </div>
390 + <div id="serverMemoryChartView" style="display:none">
391 + <div class="chartViewCanvas"><canvas id="serverMemoryChart"></canvas></div>
392 + <div class="chartViewText" id="serverMemoryChartText"></div>
393 + </div><br /><br />
394 + <div id="serverStatsTable"></div>
395 + </div>
396 + </div>
397 + <div id=p10 style="display:none">
398 + <table style="width:100%" cellpadding="0" cellspacing="0">
399 + <tr>
400 + <td style=width:auto valign=top>
401 + <div id=p10title>
402 + <div id="p10BackButton"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
403 + <h1>General - <span id=p10deviceName></span></h1>
404 + </div>
405 + <div id=p10html></div>
406 + </td>
407 + <td style=width:20px></td>
408 + <td style=width:200px>
409 + <a href=# onclick=p10showiconselector()><img id=MainComputerImage></a>
410 + <div id=MainComputerState></div>
411 + </td>
412 + </tr>
413 + </table><br>
414 + <div id=p10html2></div>
415 + <div id=p10html3></div>
416 + </div>
417 + <div id=p11 class="noselect" style="display:none">
418 + <div id="p11title">
419 + <div id=p11deviceNameHeader>
420 + <div id="p11BackButton"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
421 + <div id="devListToolbarViewIcons"><div class="viewSelector" onclick=deskToggleFull(event) title="Full Screen. Hold shift to browser full screen."><div class="viewSelector5"></div></div></div>
422 + <h1>Desktop - <span id=p11deviceName></span></h1>
423 + </div>
424 + </div>
425 + <div id="p11warning" onclick="showFeaturesDlg()">
426 + <div class="icon2"></div>
427 + <div class="warningbox">Intel&reg; AMT Redirection port or KVM feature is disabled<span id="p11warninga">, click here to enable it.</span></div>
428 + </div>
429 + <div id="p11warning2" onclick="showPowerActionDlg()">
430 + <div class="icon2"></div>
431 + <div class="warningbox">Remote computer is not powered on, click here to issue a power command.</div>
432 + </div>
433 + <div id=deskarea0 cellpadding=0 cellspacing=0>
434 + <div id=deskarea1 class="areaHead">
435 + <div class="toright2">
436 + <span id="p11power"></span>&nbsp;
437 + <div class='deskareaicon' title="Toggle View Mode" onclick="toggleAspectRatio(1)">&#8690;</div>
438 + <div class='deskareaicon' title="Rotate Left" onclick="drotate(-1)">&olarr;</div>
439 + <div class='deskareaicon' title="Rotate Right" onclick="drotate(1)">&orarr;</div>
440 + <input id="deskFocusBtn" type="button" title="Toggle focus mode, when active only the region around the mouse is updated" onkeypress="return false" onkeydown="return false" value="Focus All" onclick="deskToggleFocus()" style="margin-right:3px;display:none">
441 + <input id="deskSaveBtn" type="button" title="Save a screenshot of the remote desktop" onkeypress="return false" onkeydown="return false" value="Save..." onclick=deskSaveImage() class="mR">
442 + <input id="deskActionsBtn" type=button title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value=Actions onclick=deviceActionFunction() class="mR" />
443 + <input id="deskActionsSettings" type="button" value="Settings..." title="Edit remote desktop settings" onkeypress="return false" onkeydown="return false" onclick="showDesktopSettings()" class="mR">
444 + <input type="button" title="Change the power state of the remote machine" onkeypress="return false" onkeydown="return false" value="Power Actions..." onclick="showPowerActionDlg()" style="display:none">
445 + </div>
446 + <div>
447 + <div id="idx_deskFullBtn2" onclick=deskToggleFull(event)>&nbsp;&#x2716;</div>
448 + <input type="button" id="autoconnectbutton1" value="AutoConnect" onclick=autoConnectDesktop(event) onkeypress="return false" onkeydown="return false" style="display:none">
449 + <span id=connectbutton1span><input type=button id=connectbutton1 value="Connect" onclick=connectDesktop(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled"></span>
450 + <span id=connectbutton1hspan>&nbsp;<input type=button id=connectbutton1h value="HW Connect" onclick=connectDesktop(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled"></span>
451 + <span id=disconnectbutton1span>&nbsp;<input type=button id=disconnectbutton1 value="Disconnect" onclick=connectDesktop(event,0) onkeypress="return false" onkeydown="return false"></span>
452 + &nbsp;<span id="deskstatus">Disconnected</span>
453 + </div>
454 + </div>
455 + <div id=deskarea2 style="">
456 + <div class="areaProgress"><div id="progressbar" style=""></div></div>
457 + </div>
458 + <div id=deskarea3x>
459 + <div id=DeskFocus oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></div>
460 + <div id=DeskParent>
461 + <canvas id=Desk width=640 height=480 oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event) onmousewheel=dmousewheel(event)></canvas>
462 + </div>
463 + <div id=DeskTools>
464 + <a id=DeskToolsRefreshButton style="" onclick="refreshDeskTools()">Refresh</a>
465 + <div id=DeskToolsBar>Processes</div>
466 + <div id=deskToolsArea>
467 + <div id=deskToolsHeader>
468 + <a class="colmn1" title="Sort by process id" onclick=sortProcess(0)>PID</a>
469 + <a class="colmn2" title="Sort by name" onclick=sortProcess(1)>Name</a></div>
470 + <div id="DeskToolsProcesses" style=""></div>
471 + </div>
472 + </div>
473 + <div id=p11DeskConsoleMsg style="display:none;cursor:pointer;position:absolute;left:30px;top:17px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick=p11clearConsoleMsg()></div>
474 + </div>
475 + <div id=deskarea4 class="areaFoot">
476 + <div class="toright2">
477 + <select id=termdisplays style="display:none" onchange=deskSetDisplay(event) onkeypress="return false" onkeydown="return false"></select>&nbsp;
478 + <input id=DeskToolsButton type=button value=Tools title="Toggle tools view" onkeypress="return false" onkeydown="return false" onclick="toggleDeskTools()">&nbsp;
479 + <span id=DeskChatButton class="deskarea" title="Open chat window to this computer"><img src='images/icon-chat.png' onclick=deviceChat() height=16 width=16 style=padding-top:2px /></span>
480 + <span id=DeskNotifyButton title="Display a notification on the remote computer"><img src='images/icon-notify.png' onclick=deviceToastFunction() height=16 width=16 style=padding-top:2px /></span>
481 + <span id=DeskOpenWebButton title="Open a web address on remote computer"><img src='images/icon-url2.png' onclick=deviceUrlFunction() height=16 width=16 style=padding-top:2px /></span>
482 + </div>
483 + <div>
484 + <select id="deskkeys">
485 + <option value=10>Ctrl+Alt+Del</option>
486 + <option value=5>Win</option>
487 + <option value=0>Win+Down</option>
488 + <option value=1>Win+Up</option>
489 + <option value=2>Win+L</option>
490 + <option value=3>Win+M</option>
491 + <option value=4>Shift+Win+M</option>
492 + <option value=6>Win+R</option>
493 + <option value=7>Alt-F4</option>
494 + <option value=8>Ctrl-W</option>
495 + <option value=9>Alt-Tab</option>
496 + </select>
497 + <input id="DeskWD" type=button value="Send" onkeypress="return false" onkeydown="return false" onclick="deskSendKeys()">
498 + <input id="DeskClip" style="" type="button" value="Clipboard" onkeypress="return false" onkeydown="return false" onclick="showDeskClip()">
499 + <label><span id="DeskControlSpan" title="Toggle mouse and keyboard input"><input id="DeskControl" type="checkbox" onkeypress="return false" onkeydown="return false" onclick="toggleKvmControl()">Input</span></label>&nbsp;
500 + </div>
501 + </div>
502 + </div>
503 + </div>
504 + <div id=p12 style="display:none">
505 + <div id="p12title">
506 + <div id="p12BackButton"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
507 + <h1>Terminal - <span id=p12deviceName></span></h1>
508 + </div>
509 + <div id="p12warning" onclick=showFeaturesDlg()>
510 + <div class="icon2"></div>
511 + <div class="warningbox">Intel&reg; AMT Redirection port or KVM feature is disabled<span id="p12warninga">, click here to enable it.</span></div>
512 + </div>
513 + <div id="p12warning2" onclick=showPowerActionDlg()>
514 + <div class="icon2"></div>
515 + <div class="warningbox">Remote computer is not powered on, click here to issue a power command.</div>
516 + </div>
517 + <div id=termTable style="position:relative">
518 + <table style="width:100%" cellpadding=0 cellspacing=0>
519 + <tr>
520 + <td class="areaHead">
521 + <div class="toright2">
522 + <input id="termActionsBtn" type=button title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value=Actions onclick=deviceActionFunction()/>
523 + </div>
524 + <div>
525 + <input type="button" id="autoconnectbutton2" value="AutoConnect" onclick=autoConnectTerminal(event) onkeypress="return false" onkeydown="return false" style="display:none">
526 + <span id="connectbutton2span"><input type="button" id="connectbutton2" value="Connect" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled"></span>
527 + <span id="connectbutton2hspan">&nbsp;<input type="button" id="connectbutton2h" value="HW Connect" onclick=connectTerminal(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled"></span>
528 + <span id="disconnectbutton2span">&nbsp;<input type="button" id="disconnectbutton2" value="Disconnect" onclick=connectTerminal(event,0) onkeypress="return false" onkeydown="return false"></span>
529 + &nbsp;<span id="termstatus">Disconnected</span><span id="termtitle"></span>
530 + </div>
531 + </td>
532 + </tr>
533 + <tr>
534 + <td>
535 + <div class="areaProgress"><div id="termprogressbar" style=""></div></div>
536 + </td>
537 + </tr>
538 + <tr>
539 + <td id="termarea3x">
540 + <pre id="Term"></pre>
541 + </td>
542 + </tr>
543 + <tr>
544 + <td class="areaFoot">
545 + <div class="toright2">
546 + <span id="terminalSettingsButtons" style="display:none">
547 + <input id="id_tcrbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="CR+LF" title="Toggle what the return key will send" onclick="termToggleCr()">
548 + <input id="id_tfxkeysbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Intel (F10 = ESC+[OM)" title="Toggle F1 to F10 keys emulation type" onclick="termToggleFx()">
549 + <input id="id_ttypebutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Extended Ascii" title="Toggle terminal emulation type" onclick="termToggleType()">
550 + </span>
551 + <span id="terminalSizeDropDown">
552 + <select id="termSizeList" onkeypress="return false"><option value="1">80x25</option><option value="2">100x30</option><option value="3" selected>Auto</option></select>
553 + </span>
554 + <select id="specialkeylist" onkeypress="return false"></select>
555 + <input id="specialkeylistinput" type="button" onkeypress="return false" class="bottombutton" value="Send" title="Send the selected special key" onclick="sendSpecialKey()" />
556 + </div>
557 + <div>
558 + &nbsp;
559 + <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlcbutton" value="Ctl-C" onclick="termSendKey(3,'ctrlcbutton')" />
560 + <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlxbutton" value="Ctl-X" onclick="termSendKey(24,'ctrlxbutton')" />
561 + <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="escbutton" value="ESC" onclick="termSendKey(27,'escbutton')" />
562 + <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="bsbutton" value="Backspace" onclick="termSendKey(8,'bsbutton')" />
563 + <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="pastebutton" value="Paste" title="Paste text into the terminal" onclick="showTermPasteDialog()" />
564 + </div>
565 + </td>
566 + </tr>
567 + </table>
568 + <div id=p12TermConsoleMsg style="display:none;cursor:pointer;position:absolute;left:30px;top:45px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick=p12clearConsoleMsg()></div>
569 + </div>
570 + </div>
571 + <div id=p13 style="display:none">
572 + <div id="p13title">
573 + <div id="p13BackButton" style="float:left"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
574 + <h1>Files - <span id=p13deviceName></span></h1>
575 + </div>
576 + <table id="p13toolbar" cellpadding="0" cellspacing="0">
577 + <tr>
578 + <td class="areaHead">
579 + <div class="toright2">
580 + <input id="filesActionsBtn" type=button title="Perform power actions on the device" value=Actions onclick=deviceActionFunction() />
581 + </div>
582 + <div>
583 + <input id=p13AutoConnect value="AutoConnect" onclick=autoConnectFiles(event) type="button" style="display:none">
584 + <input id=p13Connect value="Connect" onclick=connectFiles(event) type="button">
585 + <span id=p13Status>Disconnected</span>
586 + </div>
587 + </td>
588 + </tr>
589 + <tr>
590 + <td class="areaHead2" valign=bottom>
591 + <div id="p13rightOfButtons" class="toright2"></div>
592 + <div>
593 + <input type=button id=p13FolderUp disabled="disabled" onclick="p13folderup()" value="Up" />&nbsp;
594 + <input type=button id=p13SelectAllButton disabled="disabled" onclick="p13selectallfile()" value="Select All" />&nbsp;
595 + <input type=button id=p13RenameFileButton disabled="disabled" value="Rename" onclick="p13renamefile()" />&nbsp;
596 + <input type=button id=p13DeleteFileButton disabled="disabled" value="Delete" onclick="p13deletefile()" />&nbsp;
597 + <input type=button id=p13NewFolderButton disabled="disabled" value="New Folder" onclick="p13createfolder()" />&nbsp;
598 + <input type=button id=p13UploadButton disabled="disabled" value="Upload" onclick="p13uploadFile()" />&nbsp;
599 + <input type=button id=p13CutButton disabled="disabled" value="Cut" onclick="p13copyFile(1)" />&nbsp;
600 + <input type=button id=p13CopyButton disabled="disabled" value="Copy" onclick="p13copyFile(0)" />&nbsp;
601 + <input type=button id=p13PasteButton disabled="disabled" value="Paste" onclick="p13pasteFile()" />&nbsp;
602 + <input type=button id=p13RefreshButton disabled="disabled" value="Refresh" onclick="p13folderup(9999)" />&nbsp;
603 + </div>
604 + </td>
605 + </tr>
606 + <tr>
607 + <td class="areaHead3">
608 + <div class="toright2">
609 + <select id=p13sortdropdown onchange=p13updateFiles()>
610 + <option value=1 selected="selected">Sort by name</option>
611 + <option value=2>Sort by size</option>
612 + <option value=3>Sort by date</option>
613 + <option value=4>Descend by name</option>
614 + <option value=5>Descend by size</option>
615 + <option value=6>Descend by date</option>
616 + </select>
617 + </div>
618 + <div>&nbsp;&nbsp;<span id="p13currentpath"></span></div>
619 + </td>
620 + </tr>
621 + </table>
622 + <div id=p13FilesConsoleMsg style="display:none;cursor:pointer;position:absolute;left:30px;top:165px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick=p13clearConsoleMsg()></div>
623 + <div id="p13filetable" style="">
624 + <div id="p13bigok" style="display:none"><b>&checkmark;</b></div>
625 + <div id="p13bigfail" style="display:none"><b>&#10007;</b></div>
626 + <span id="p13files"></span>
627 + </div>
628 + <table id="p13toolbarBottom" cellpadding=0 cellspacing=0>
629 + <tr><td class=style6>&nbsp;<span id="p13bottomstatus"></span></td></tr>
630 + </table>
631 + </div>
632 + <div id=p14 style="display:none">
633 + <div id="p14title">
634 + <div id="p14BackButton" style="float:left"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
635 + <div id="devListToolbarViewIcons"><div class="viewSelector" onclick=deskToggleFull(event) title="Full Screen. Hold shift to browser full screen."><div class="viewSelector5"></div></div></div>
636 + <h1>Intel&reg; AMT - <span id=p14deviceName></span></h1>
637 + </div>
638 + <iframe id=p14iframe src="{{{domainurl}}}commander.htm"></iframe>
639 + </div>
640 + <div id=p15 style="display:none">
641 + <div id="p15title">
642 + <div id="p15BackButton" style="float:left"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
643 + <h1><span id=p15deviceName></span></h1>
644 + </div>
645 + <table id="consoleTable" cellpadding=0 cellspacing=0>
646 + <tr>
647 + <td class="areaHead">
648 + <div class="toright2">
649 + <div id=p15coreName title="Information about current core running on this agent"></div>
650 + <input type=button id=p15uploadCore value="Agent Action" onclick=p15uploadCore(event) title="Change the agent Java Script code module" />
651 + <img onclick=p15downloadConsoleText() style="cursor:pointer;margin-top:6px" title="Download console text" src="images/link4.png" />
652 + </div>
653 + <div id="p15statetext"></div>
654 + </td>
655 + </tr>
656 + <tr>
657 + <td>
658 + <div class="areaProgress"><div id="consoleprogressbar" style=""></div></div>
659 + </td>
660 + </tr>
661 + <tr>
662 + <td id=p15agentConsole>
663 + <pre id=p15agentConsoleText></pre>
664 + </td>
665 + </tr>
666 + <tr>
667 + <td class="areaFoot">
668 + <table style="width:100%">
669 + <tr>
670 + <td style="width:99%">
671 + <input id=p15consoleText style=width:100% onkeyup=p15consoleSend(event) onfocus=onConsoleFocus(1) onblur=onConsoleFocus(0) />
672 + </td>
673 + <td>&nbsp;</td>
674 + <td style="width:1%"><input id="id_p15consoleClear" type="button" class="bottombutton" value="Clear" onclick="p15consoleClear()"></td>
675 + </tr>
676 + </table>
677 + </td>
678 + </tr>
679 + </table>
680 + </div>
681 + <div id=p16 style="display:none">
682 + <div id="p16title">
683 + <div id="p16BackButton" style="float:left"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
684 + <h1>Events - <span id=p16deviceName></span></h1>
685 + </div>
686 + <table class="pTable">
687 + <tr>
688 + <td class="h1"></td>
689 + <td>&nbsp;<input type=button onclick=refreshDeviceEvents() value="Refresh" /></td>
690 + <td class="auto-style1">
691 + Show
692 + <select id=p16limitdropdown onchange=refreshDeviceEvents()>
693 + <option value=60>Last 60</option>
694 + <option value=120>Last 120</option>
695 + <option value=250>Last 250</option>
696 + <option value=500>Last 500</option>
697 + <option value=1000>Last 1000</option>
698 + </select>
699 + </td>
700 + <td class="h2"></td>
701 + </tr>
702 + </table>
703 + <div id=p16events></div>
704 + </div>
705 + <div id=p20 style="display:none">
706 + <picture id=MainMeshImage style=border-width:0px;height:200px;width:200px;float:right>
707 + <source type="image/webp" width=200 height=200 srcset="images/webp/mesh-256.webp">
708 + <img alt="" width=200 height=200 src=images/mesh-256.png />
709 + </picture>
710 + <div style="float:left"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
711 + <h1>General - <span id=p20meshName></span></h1>
712 + <p id=p20info></p>
713 + </div>
714 + <div id=p30 style="display:none">
715 + <table style="width:100%" cellpadding="0" cellspacing="0">
716 + <tr>
717 + <td style=width:auto valign=top>
718 + <div id="p30title">
719 + <div style="float:left"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
720 + <h1>General - <span id=p30userName></span></h1>
721 + </div>
722 + <div id=p30html></div>
723 + </td>
724 + <td style=width:20px></td>
725 + <td style=width:200px>
726 + <picture id=MainUserImage style=border-width:0px;height:200px;width:200px;float:right>
727 + <source type="image/webp" width=200 height=200 srcset="images/webp/user-256.webp">
728 + <img alt="" width=200 height=200 src=images/user-256.png />
729 + </picture>
730 + <div style="width:100%;text-align:center"><strong><span id=MainUserState></span></strong></div>
731 + </td>
732 + </tr>
733 + </table><br>
734 + <div id=p30html2></div>
735 + <div id=p30html3></div>
736 + </div>
737 + <div id=p31 style="display:none">
738 + <div style="float:left"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
739 + <h1>Events - <span id=p31userName></span></h1>
740 + <table class="pTable">
741 + <tr>
742 + <td class="h1"></td>
743 + <td>&nbsp;<input type=button onclick=refreshUsersEvents() value="Refresh" /></td>
744 + <td class="auto-style1">
745 + Show
746 + <select id=p31limitdropdown onchange=refreshUsersEvents()>
747 + <option value=60>Last 60</option>
748 + <option value=120>Last 120</option>
749 + <option value=250>Last 250</option>
750 + <option value=500>Last 500</option>
751 + <option value=1000>Last 1000</option>
752 + </select>
753 + </td>
754 + <td class="h2"></td>
755 + </tr>
756 + </table>
757 + <div id=p31events></div>
758 + </div>
759 + <div id=p40 style="display:none;">
760 + <h1>My Server Stats</h1>
761 + <div class="areaHead">
762 + <div class="toright2">
763 + <select id=p40type onchange=updateServerTimelineStats()>
764 + <option value=0>Connections</option>
765 + <option value=1>Memory</option>
766 + </select>&nbsp;
767 + <select id=p40time onchange=updateServerTimelineHours()>
768 + <option value=3>Last 3 hours</option>
769 + <option value=8>Last 8 hours</option>
770 + <option value=24>Last day</option>
771 + <option value=168>Last week</option>
772 + <option value=720>Last 30 days</option>
773 + </select>&nbsp;
774 + <img src=images/link4.png height=10 width=10 title="Download data points (.csv)" style=cursor:pointer onclick=p40downloadEvents()>&nbsp;
775 + </div>
776 + <div>
777 + <input value="Refresh" type="button" onclick="refreshServerTimelineStats()" />
778 + &nbsp;<label><input id=p40log type="checkbox" onclick="updateServerTimelineHours()" />Log-X</label>
779 +</div>
780 + </div>
781 + <canvas id=serverMainStats style=""></canvas>
782 + </div>
783 + <br id="column_l_bottomgap" />
784 + </div>
785 + <div id="footer">
786 + <div class="footer1">{{{footer}}}</div>
787 + <div class="footer2">
788 + <a id="verifyEmailId2" style="display:none" href=# onclick="account_showVerifyEmail()">Verify Email</a>
789 + &nbsp;<a href=terms>Terms &amp; Privacy</a>
790 + </div>
791 + </div>
792 + <div id=dialog class="noselect" style="display:none">
793 + <div id=dialogHeader>
794 + <div tabindex=0 id=id_dialogclose onclick=setDialogMode() onkeypress="if (event.key == 'Enter') setDialogMode()">&#x2716;</div>
795 + <div id=id_dialogtitle></div>
796 + </div>
797 + <div id=dialogBody>
798 + <div id=dialog1>
799 + <div id=id_dialogMessage style=""></div>
800 + </div>
801 + <div id=dialog2 style="">
802 + <div id=id_dialogOptions></div>
803 + </div>
804 + <div id=dialog3 style="">
805 + <div id=d3upload>
806 + <div>File Selection</div>
807 + <select id=d3uploadMode onchange=d3modechange()>
808 + <option value=1>Local file upload</option>
809 + <option value=2>Server file selection</option>
810 + </select>
811 + </div>
812 + <div id=d3localmode style="display:none">
813 + <div>Upload File</div>
814 + <form id=d3localmodeform method=post enctype=multipart/form-data action=uploadfile.ashx target=fileUploadFrame>
815 + <input type=text id=d3attrib name=attrib style="display:none" />
816 + <input type=file id=d3localFile name=files onchange=d3setActions() />
817 + <input type=submit id=d3submit style="display:none" />
818 + </form>
819 + </div>
820 + <div id=d3servermode>
821 + <div id=d3serveraction valign=bottom>
822 + <input type=button id=p3FolderUp disabled="disabled" onclick=d3folderup() value="Up" />&nbsp;
823 + </div>
824 + <div id=d3serverfiles></div>
825 + </div>
826 + </div>
827 + <div id=dialog7 style="">
828 + <div id="d7meshkvm">
829 + <h4>Agent Remote Desktop</h4>
830 + <div>
831 + <div>Quality</div>
832 + <select id="d7bitmapquality" dir="rtl"></select>
833 + </div>
834 + <div>
835 + <div>Scaling</div>
836 + <select id="d7bitmapscaling" style="" dir="rtl">
837 + <option selected=selected value=1024>100%</option>
838 + <option value=896>87.5%</option>
839 + <option value=768>75%</option>
840 + <option value=640>62.5%</option>
841 + <option value=512>50%</option>
842 + <option value=384>37.5%</option>
843 + <option value=256>25%</option>
844 + <option value=128>12.5%</option>
845 + </select>
846 + </div>
847 + <div>
848 + <div>Frame rate</div>
849 + <select id="d7framelimiter" dir="rtl">
850 + <option selected=selected value=50>Fast</option>
851 + <option value=100>Medium</option>
852 + <option value=400>Slow</option>
853 + <option value=1000>Very slow</option>
854 + </select>
855 + </div>
856 + </div>
857 + <div id="d7amtkvm">
858 + <h4>Intel&reg; AMT Hardware KVM</h4>
859 + <div>
860 + <div>Image Encoding</div>
861 + <select id="d7desktopmode">
862 + <option value="1">RLE8, Fastest</option>
863 + <option value="2">RLE16, Recommended</option>
864 + <option value="3">RAW8, Slow</option>
865 + <option value="4">RAW16, Very Slow</option>
866 + </select>
867 + </div>
868 + <div>
869 + <div>Other Settings</div>
870 + <div id="d7otherset" style="display:block">
871 + <label style="display:block"><input type="checkbox" id="d7showfocus">Show Focus Tool</label>
872 + <label style="display:block"><input type="checkbox" id="d7showcursor">Show Local Mouse Cursor</label>
873 + <label style="display:block"><input type="checkbox" id="d7localKeyMap">Local Keyboard Map</label>
874 + </div>
875 + </div>
876 + </div>
877 + </div>
878 + </div>
879 + <div id="idx_dlgButtonBar">
880 + <input id="idx_dlgCancelButton" type="button" value="Cancel" style="" onclick="dialogclose(0)">
881 + <input id="idx_dlgOkButton" type="button" value="OK" style="" onclick="dialogclose(1)">
882 + <div><input id="idx_dlgDeleteButton" type="button" value="Delete" style="display:none" onclick="dialogclose(2)"></div>
883 + </div>
884 + </div>
885 + <iframe name="fileUploadFrame" style="display:none"></iframe>
886 + <form style="display:none" method=post action=uploadfile.ashx enctype=multipart/form-data target=fileUploadFrame><input id=p5fileDragName name="name"><input id=p5fileDragSize name="size"><input id=p5fileDragType name="type"><input id=p5fileDragData name="data"><input id=p5fileDragLink name="link"><input type=submit id=p5loginSubmit2 style="display:none" /></form>
887 + <form style="display:none" method=post action=uploadnodefile.ashx enctype=multipart/form-data target=fileUploadFrame><input id=p13fileDragName name="name"><input id=p13fileDragSize name="size"><input id=p13fileDragType name="type"><input id=p13fileDragData name="data"><input id=p13fileDragLink name="link"><input type=submit id=p13loginSubmit2 style="display:none" /></form>
888 + <audio id="chimes"><source src="sounds/chimes.mp3" type="audio/mp3"></audio>
889 + </div>
890 + <script type="text/javascript">
891 + 'use strict';
892 +
893 + // Process server-side web state
894 + var webState = "{{{webstate}}}";
895 + if (webState != "") { webState = JSON.parse(decodeURIComponent(webState)); }
896 + for (var i in webState) { localStorage.setItem(i, webState[i]); }
897 + //localStorage.clear();
898 +
899 + var args;
900 + var autoReconnect = true;
901 + var powerStatetable = ['', 'Powered', 'Sleep', 'Sleep', 'Sleep', 'Hibernating', 'Power off', 'Present'];
902 + var StatusStrs = ['Disconnected', 'Connecting...', 'Setup...', 'Connected', 'Intel&reg; AMT Connected'];
903 + var sort = 0;
904 + var searchFocus = 0;
905 + var mapSearchFocus = 0;
906 + var userSearchFocus = 0;
907 + var consoleFocus = 0;
908 + var showRealNames = false;
909 + var meshserver = null;
910 + var meshes = {};
911 + var meshcount = 0;
912 + var nodes = null;
913 + var filetree = {};
914 + var userinfo = null;
915 + var serverinfo = null;
916 + var events = [];
917 + var users = null;
918 + var wssessions = null;
919 + var nodeShortIdent = 0;
920 + var desktop;
921 + var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50, localkeymap: false };
922 + var multidesktopsettings = { quality: 20, scaling: 128, framerate: 1000 };
923 + var terminal;
924 + var files;
925 + var debugLevel = parseInt("{{{debuglevel}}}");
926 + var features = parseInt("{{{features}}}");
927 + var sessionTime = parseInt("{{{sessiontime}}}");
928 + var domain = "{{{domain}}}";
929 + var domainUrl = "{{{domainurl}}}";
930 + var authCookie = "{{{authCookie}}}";
931 + var authCookieRenewTimer = null;
932 + var multiDesktop = {};
933 + var multiDesktopFilter = null;
934 + var serverPublicNamePort = "{{{serverDnsName}}}:{{{serverPublicPort}}}";
935 + var amtScanResults = null;
936 + var debugmode = 0;
937 + var clickOnce = (((features & 256) != 0) && detectClickOnce());
938 + var attemptWebRTC = ((features & 128) != 0);
939 + var passRequirements = "{{{passRequirements}}}";
940 + if (passRequirements != "") { passRequirements = JSON.parse(decodeURIComponent(passRequirements)); }
941 + var deskAspectRatio = 0;
942 + try { deskAspectRatio = parseInt(getstore('deskAspectRatio', '0')); } catch (ex) { }
943 + var uiMode = parseInt(getstore('uiMode', 1));
944 + var webPageStackMenu = false;
945 + var webPageFullScreen = true;
946 + var nightMode = (getstore('_nightMode', '0') == '1');
947 + var sessionActivity = Date.now();
948 +
949 + // Console Message Display Timers
950 + var p11DeskConsoleMsgTimer = null;
951 + var p12TermConsoleMsgTimer = null;
952 + var p13FilesConsoleMsgTimer = null;
953 +
954 + function startup() {
955 + if ((features & 32) == 0) {
956 + // Guard against other site's top frames (web bugs).
957 + var loc = null;
958 + try { loc = top.location.toString().toLowerCase(); } catch (e) { }
959 + if (top != self && (loc == null || top.active == false)) { top.location = self.location; return; }
960 + }
961 +
962 + // Check if we are in debug mode
963 + args = parseUriArgs();
964 + debugmode = args.debug;
965 + if (args.webrtc != null) { attemptWebRTC = (args.webrtc == 1); }
966 + QV('p13AutoConnect', debugmode); // Files
967 + QV('autoconnectbutton2', debugmode); // Terminal
968 + QV('autoconnectbutton1', debugmode); // Desktop
969 + //QV('DeskClip', debugmode); // Clipboard feature, not completed so show in in debug mode only.
970 +
971 + if (nightMode) { QC('body').add('night'); }
972 + toggleFullScreen();
973 +
974 + // Setup page visuals
975 + if (args.hide) {
976 + var hide = parseInt(args.hide);
977 + QV('masthead', !(hide & 1));
978 + QV('topbar', !(hide & 2));
979 + QV('footer', !(hide & 4));
980 + QV('p10title', !(hide & 8));
981 + QV('p11title', !(hide & 8));
982 + QV('p12title', !(hide & 8));
983 + QV('p13title', !(hide & 8));
984 + QV('p14title', !(hide & 8));
985 + QV('p15title', !(hide & 8));
986 + QV('p16title', !(hide & 8));
987 + //if (hide & 16) {
988 + // QV('page_leftbar', false);
989 + // QS('page_content').left = '0px';
990 + //}
991 +
992 + // Fix the main grid to zero-height elements we want to hide.
993 + QS('container')['grid-template-rows'] = ((hide & 1) ? '0' : '66') + 'px ' + ((hide & 2) ? '0' : '24') + 'px auto ' + ((hide & 4) ? '0' : '45') + 'px';
994 + QS('container')['-ms-grid-rows'] = ((hide & 1) ? '0' : '66') + 'px ' + ((hide & 2) ? '0' : '24') + 'px auto ' + ((hide & 4) ? '0' : '45') + 'px';
995 +
996 + // Adjust height of remote desktop, files and Intel AMT
997 + var xh = (((hide & 1) ? 0 : 66) + ((hide & 2) ? 0 : 24) + ((hide & 4) ? 0 : 45) + ((hide & 8) ? 0 : 60)); // 0 to 195
998 + QS('p3users')['max-height'] = 'calc(100vh - ' + (124 + xh) + 'px)';
999 + QS('p3events')['height'] = 'calc(100vh - ' + (124 + xh) + 'px)';
1000 + QS('deskarea3x')['height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
1001 + QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
1002 + QS('p5filetable')['height'] = 'calc(100vh - ' + (160 + xh) + 'px)';
1003 + QS('p13filetable')['height'] = 'calc(100vh - ' + (124 + xh) + 'px)';
1004 + QS('serverMainStats')['height'] = 'calc(100vh - ' + (110 + xh) + 'px)';
1005 + QS('serverMainStats')['max-height'] = 'calc(100vh - ' + (110 + xh) + 'px)';
1006 + QS('xdevices')['max-height'] = 'calc(100vh - ' + (124 + xh) + 'px)';
1007 + QS('xdevicesmap')['max-height'] = 'calc(100vh - ' + (124 + xh) + 'px)';
1008 + QS('p15agentConsole')['height'] = 'calc(100vh - ' + (84 + xh) + 'px)';
1009 + QS('p15agentConsole')['max-height'] = 'calc(100vh - ' + (84 + xh) + 'px)';
1010 + QS('p15agentConsoleText')['height'] = 'calc(100vh - ' + (81 + xh) + 'px)';
1011 + QS('p15agentConsoleText')['max-height'] = 'calc(100vh - ' + (81 + xh) + 'px)';
1012 + }
1013 +
1014 + // We are looking at a single device, remove all the back buttons
1015 + if ('{{currentNode}}' != '') {
1016 + QV('p10BackButton', false);
1017 + QV('p11BackButton', false);
1018 + QV('p12BackButton', false);
1019 + QV('p13BackButton', false);
1020 + QV('p14BackButton', false);
1021 + QV('p15BackButton', false);
1022 + QV('p16BackButton', false);
1023 + }
1024 + p1updateInfo();
1025 +
1026 + // Setup the context menu
1027 + document.onclick = function (e) { hideContextMenu(); }
1028 + document.onkeypress = ondockeypress;
1029 + document.onkeydown = ondockeydown;
1030 + document.onkeyup = ondockeyup;
1031 + //window.addEventListener("focus", ondocfocus, false);
1032 + window.addEventListener("blur", ondocblur, false);
1033 + window.onresize = function () { masterUpdate(512); }
1034 + setTimeout("masterUpdate(512)", 200);
1035 +
1036 + // Connect to the mesh server
1037 + meshserver = MeshServerCreateControl(domainUrl, authCookie);
1038 + meshserver.onStateChanged = onStateChanged;
1039 + meshserver.onMessage = onMessage;
1040 + meshserver.trace = (args.trace == 1);
1041 + meshserver.Start();
1042 +
1043 + // Setup page controls
1044 + Q('sortselect').selectedIndex = sort = getstore("sort", 0);
1045 + Q('sizeselect').selectedIndex = getstore("_viewsize", 1);
1046 + Q('SearchInput').value = getstore("_search", "");
1047 + showRealNames = (getstore("showRealNames", 0) == 1);
1048 + Q('RealNameCheckBox').checked = showRealNames;
1049 + Q('viewselect').value = getstore("_deviceView", 1);
1050 + Q('DeskControl').checked = (getstore('DeskControl', 1) == 1);
1051 + QV('accountChangeEmailAddressSpan', (features & 0x200000) == 0);
1052 +
1053 + // Display the page devices
1054 + masterUpdate(3)
1055 + for (var j = 1; j < 5; j++) { Q('devViewButton' + j).classList.remove('viewSelectorSel'); }
1056 + Q('devViewButton' + Q('viewselect').value).classList.add('viewSelectorSel');
1057 +
1058 + // Setup upload drag & drop
1059 + Q('p5filetable').addEventListener("drop", p5fileDragDrop, false);
1060 + Q('p5filetable').addEventListener("dragover", p5fileDragOver, false);
1061 + Q('p5filetable').addEventListener("dragleave", p5fileDragLeave, false);
1062 + //Q('p5fileCatchAllInput').addEventListener("drop", p5fileDragDrop, false);
1063 + //Q('p5fileCatchAllInput').addEventListener("dragover", p5fileDragOver, false);
1064 + //Q('p5fileCatchAllInput').addEventListener("dragleave", p5fileDragLeave, false);
1065 +
1066 + // Setup upload drag & drop
1067 + Q('p13filetable').addEventListener("drop", p13fileDragDrop, false);
1068 + Q('p13filetable').addEventListener("dragover", p13fileDragOver, false);
1069 + Q('p13filetable').addEventListener("dragleave", p13fileDragLeave, false);
1070 +
1071 + // Timeline update interval
1072 + setInterval(updateDeviceTimeline, 120000); // Check every 2 minutes
1073 +
1074 + // Load desktop settings
1075 + var t = localStorage.getItem('desktopsettings');
1076 + if (t != null) { desktopsettings = JSON.parse(t); }
1077 + t = localStorage.getItem('multidesktopsettings');
1078 + if (t != null) { multidesktopsettings = JSON.parse(t); }
1079 + applyDesktopSettings();
1080 +
1081 + // Terminal special keys
1082 + var x = '';
1083 + for (var c = 1; c < 27; c++) x += "<option value='" + c + "'>Ctrl-" + String.fromCharCode(64 + c) + " (" + c + ")</option>";
1084 + QH('specialkeylist', x);
1085 +
1086 + // Setup server stats panels
1087 + setupGeneralServerStats();
1088 + setupServerTimelineStats();
1089 +
1090 + // Setup the user interface in the right mode
1091 + userInterfaceSelectMenu();
1092 +
1093 + // If SSPI or LDAP authentication not used, allow batch account creation.
1094 + QV('p4UserBatchCreate', (features & 0x00080000) == 0);
1095 + }
1096 +
1097 + // Toggle the web page to full screen
1098 + function toggleAspectRatio(toggle) {
1099 + if (toggle === 1) { deskAspectRatio = ((deskAspectRatio + 1) % 3); putstore('deskAspectRatio', deskAspectRatio); }
1100 + deskAdjust();
1101 + }
1102 +
1103 + // If FullScreen, toggle menu to be horisontal or vertical
1104 + function toggleStackMenu(toggle) {
1105 + if (webPageFullScreen == true) {
1106 + if (toggle === 1) {
1107 + webPageStackMenu = !webPageStackMenu;
1108 + putstore('webPageStackMenu', webPageStackMenu);
1109 + }
1110 + if (webPageStackMenu == false) {
1111 + QC('body').remove("menu_stack");
1112 + } else {
1113 + QC('body').add("menu_stack");
1114 + if (xxcurrentView >= 10) QC('column_l').remove('room4submenu');
1115 + }
1116 + deskAdjust();
1117 + }
1118 + }
1119 +
1120 + // Toggle user interface menu
1121 + function showUserInterfaceSelectMenu() {
1122 + Q('uiViewButton1').classList.remove('uiSelectorSel');
1123 + Q('uiViewButton2').classList.remove('uiSelectorSel');
1124 + Q('uiViewButton3').classList.remove('uiSelectorSel');
1125 + Q('uiViewButton4').classList.remove('uiSelectorSel');
1126 + try { Q('uiViewButton' + uiMode).classList.add('uiSelectorSel'); } catch (ex) { }
1127 + QV('uiMenu', (QS('uiMenu').display == 'none'));
1128 + //Q('uiViewButton1').focus();
1129 + if (nightMode) { Q('uiViewButton4').classList.add('uiSelectorSel'); }
1130 + }
1131 +
1132 + function userInterfaceSelectMenu(s) {
1133 + if (s) { uiMode = s; putstore('uiMode', uiMode); }
1134 + webPageFullScreen = (uiMode < 3);
1135 + webPageStackMenu = (uiMode > 1);
1136 + toggleFullScreen(0);
1137 + toggleStackMenu(0);
1138 + if (webPageStackMenu && (xxcurrentView >= 10)) { QC('column_l').add('room4submenu'); } else { QC('column_l').remove('room4submenu'); }
1139 + }
1140 +
1141 + function toggleNightMode() {
1142 + nightMode = !nightMode;
1143 + if (nightMode) { QC('body').add('night'); } else { QC('body').remove('night'); }
1144 + putstore('_nightMode', nightMode?'1':'0');
1145 + }
1146 +
1147 + // Toggle the web page to full screen
1148 + function toggleFullScreen(toggle) {
1149 + if (toggle === 1) { webPageFullScreen = !webPageFullScreen; putstore('webPageFullScreen', webPageFullScreen); }
1150 + var hide = 0;
1151 + if (args.hide) { hide = parseInt(args.hide); }
1152 + if (webPageFullScreen == false) {
1153 + QC('body').remove("menu_stack");
1154 + QC('body').remove("fullscreen");
1155 + QC('body').remove("arg_hide");
1156 + if (xxcurrentView >= 10) QC('column_l').add('room4submenu');
1157 + QV('UserDummyMenuSpan', false);
1158 + //QV('page_leftbar', false);
1159 + } else {
1160 + QC('body').add("fullscreen");
1161 + if (hide & 16) QC('body').add("arg_hide"); // This is replacement for QV('page_leftbar', !(hide & 16));
1162 + if (xxcurrentView >= 10) QC('column_l').remove('room4submenu');
1163 + QV('UserDummyMenuSpan', (xxcurrentView < 10) && webPageFullScreen);
1164 + }
1165 + masterUpdate(512);
1166 + QV('body', true);
1167 + }
1168 +
1169 + function getNodeFromId(id) { if (nodes != null) { for (var i in nodes) { if (nodes[i]._id == id) return nodes[i]; } } return null; }
1170 + function reload() {
1171 + var x = window.location.href;
1172 + if (x.endsWith('/#')) { x = x.substring(0, x.length - 2); }
1173 + window.location.href = x;
1174 + }
1175 +
1176 + function onStateChanged(server, state, prevState, errorCode) {
1177 + if (state == 0) {
1178 + // Control web socket disconnected
1179 + setDialogMode(0); // Close any dialog boxes if present
1180 + go(0); // Go to disconnection panel
1181 +
1182 + // Clean up
1183 + powerTimeline = null;
1184 + powerTimelineReq = null;
1185 + powerTimelineNode = null;
1186 + powerTimelineUpdate = null;
1187 + deleteAllNotifications(); // Close and clear notifications if present
1188 + hideContextMenu(); // Hide the context menu if present
1189 + QV('verifyEmailId2', false);
1190 + QV('logoutControl', false);
1191 + if (errorCode == 'noauth') { QH('p0span', 'Unable to perform authentication'); return; }
1192 + if (prevState == 2) { if (autoReconnect) { setTimeout(serverPoll, 5000); } } else { QH('p0span', 'Unable to connect web socket'); }
1193 + if (authCookieRenewTimer != null) { clearInterval(authCookieRenewTimer); authCookieRenewTimer = null; }
1194 + } else if (state == 2) {
1195 + // Fetch list of meshes, nodes, files
1196 + meshserver.send({ action: 'meshes' });
1197 + meshserver.send({ action: 'nodes', id: '{{currentNode}}' });
1198 + if ('{{currentNode}}' == '') { meshserver.send({ action: 'files' }); }
1199 + go(1);
1200 + authCookieRenewTimer = setInterval(function () { meshserver.send({ action: 'authcookie' }); }, 1800000); // Request a cookie refresh every 30 minutes.
1201 + }
1202 + }
1203 +
1204 + // Poll the server, if it responds, refresh the page.
1205 + function serverPoll() {
1206 + var xdr = null;
1207 + try { xdr = new XDomainRequest(); } catch (e) { }
1208 + if (!xdr) xdr = new XMLHttpRequest();
1209 + xdr.open("HEAD", window.location.href);
1210 + xdr.timeout = 15000;
1211 + xdr.onload = function () { reload(); };
1212 + xdr.onerror = xdr.ontimeout = function () { setTimeout(serverPoll, 10000); };
1213 + xdr.send();
1214 + }
1215 +
1216 + // Return true if this browser supports clickonce
1217 + function detectClickOnce() {
1218 + for (var i in window.navigator.mimeTypes) { if (window.navigator.mimeTypes[i].type == "application/x-ms-application") { return true; } }
1219 + var userAgent = window.navigator.userAgent.toUpperCase();
1220 + return (userAgent.indexOf('.NET CLR 3.5') >= 0) || (userAgent.indexOf('(WINDOWS NT ') >= 0);
1221 + }
1222 +
1223 + function updateSiteAdmin() {
1224 + var noServerBackup = "{{{noServerBackup}}}";
1225 + var siteRights = userinfo.siteadmin;
1226 + if (noServerBackup == 1) { siteRights &= 0xFFFFFFFA; } // If not server backups allowed, remove server backup and restore permissions
1227 +
1228 + // Update account actions
1229 + QV('p2AccountSecurity', ((features & 4) == 0) && (serverinfo.domainauth == false) && ((features & 4096) != 0)); // Hide Account Security if in single user mode, domain authentication to 2 factor auth not supported.
1230 + QV('p2AccountActions', ((features & 4) == 0) && (serverinfo.domainauth == false)); // Hide Account Actions if in single user mode or domain authentication
1231 + QV('p2AccountImage', ((features & 4) == 0) && (serverinfo.domainauth == false)); // If account actions are not visible, also remove the image on that panel
1232 + QV('p2ServerActions', siteRights & 21);
1233 + QV('LeftMenuMyServer', siteRights & 21); // 16 + 4 + 1
1234 + QV('MainMenuMyServer', siteRights & 21);
1235 + QV('p2ServerActionsBackup', siteRights & 1);
1236 + QV('p2ServerActionsRestore', siteRights & 4);
1237 + QV('p2ServerActionsVersion', siteRights & 16);
1238 + QV('MainMenuMyFiles', siteRights & 8);
1239 + QV('LeftMenuMyFiles', siteRights & 8);
1240 + if (((siteRights & 8) == 0) && (xxcurrentView == 5)) { setDialogMode(0); go(1); }
1241 + if (currentNode != null) { gotoDevice(currentNode._id, xxcurrentView, true); }
1242 +
1243 + // Update user management state
1244 + if ((userinfo.siteadmin & 2) != 0)
1245 + {
1246 + // We are user administrator
1247 + if (users == null) { meshserver.send({ action: 'users' }); }
1248 + if (wssessions == null) { meshserver.send({ action: 'wssessioncount' }); }
1249 + } else {
1250 + // We are not user administrator
1251 + users = null;
1252 + wssessions = null;
1253 + updateUsers();
1254 + if (xxcurrentView == 4 || ((xxcurrentView >= 30) && (xxcurrentView < 40))) { setDialogMode(0); go(1); currentUser = null; }
1255 + }
1256 + meshserver.send({ action: 'events', limit: parseInt(p3limitdropdown.value) });
1257 + QV('p2deleteall', userinfo.siteadmin == 0xFFFFFFFF);
1258 + QV('ServerConsole', userinfo.siteadmin === 0xFFFFFFFF);
1259 + if ((xxcurrentView == 115) && (userinfo.siteadmin != 0xFFFFFFFF)) { go(6); }
1260 + if ((xxcurrentView == 6) && ((userinfo.siteadmin & 21) == 0)) { go(1); }
1261 +
1262 + // If we are site administrator, register to get server statistics
1263 + if ((siteRights & 21) != 0) { meshserver.send({ action: 'serverstats', interval: 10000 }); }
1264 + }
1265 +
1266 + // To boost the speed of the web page when even floods occur, this method perform a delayed update on the web page.
1267 + var updateNaggleTimer = null;
1268 + var updateNaggleFlags = 0;
1269 + function masterUpdate(flags) {
1270 + updateNaggleFlags |= flags;
1271 + if (updateNaggleTimer == null) {
1272 + updateNaggleTimer = setTimeout(function () {
1273 + if (updateNaggleFlags & 512) { center(); }
1274 + if (updateNaggleFlags & 1) { onSearchInputChanged(); }
1275 + if (updateNaggleFlags & 2) { onSortSelectChange(false); }
1276 + if (updateNaggleFlags & 128) { updateMeshes(); }
1277 + if (updateNaggleFlags & 4) { updateDevices(); }
1278 + if (updateNaggleFlags & 8) { drawNotifications(); }
1279 + if (updateNaggleFlags & 16) { updateMapMarkers(); }
1280 + if (updateNaggleFlags & 32) { eventsUpdate(); }
1281 + if (updateNaggleFlags & 64) { refreshMap(false, true); }
1282 + if (updateNaggleFlags & 256) { drawDeviceTimeline(); }
1283 + if (updateNaggleFlags & 1024) { deviceEventsUpdate(); }
1284 + if (updateNaggleFlags & 2048) { userEventsUpdate(); }
1285 + if (updateNaggleFlags & 4096) { p20updateMesh(); }
1286 + updateNaggleTimer = null;
1287 + updateNaggleFlags = 0;
1288 + }, 150);
1289 + }
1290 + }
1291 +
1292 + function updateSelf() {
1293 + QV('verifyEmailId', (userinfo.emailVerified !== true) && (userinfo.email != null) && (serverinfo.emailcheck == true));
1294 + QV('verifyEmailId2', (userinfo.emailVerified !== true) && (userinfo.email != null) && (serverinfo.emailcheck == true));
1295 + QV('manageOtp', (userinfo.otpsecret == 1) || (userinfo.otphkeys > 0));
1296 + QV('authAppSetupCheck', userinfo.otpsecret == 1);
1297 + QV('authKeySetupCheck', userinfo.otphkeys > 0);
1298 + QV('authCodesSetupCheck', userinfo.otpkeys > 0);
1299 + masterUpdate(4 + 128 + 4096);
1300 +
1301 + // If we can't create new groups, hide all links that can do that.
1302 + var newGroupsAllowed = ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 64) == 0));
1303 + QV('p2createMeshLink1', newGroupsAllowed);
1304 + QV('p2createMeshLink2', newGroupsAllowed);
1305 + QV('getStarted1', newGroupsAllowed);
1306 + QV('getStarted2', !newGroupsAllowed);
1307 +
1308 + if (typeof userinfo.passchange == 'number') {
1309 + if (userinfo.passchange == -1) { QH('p2nextPasswordUpdateTime', ' - Reset on next login.'); }
1310 + else if ((passRequirements != null) && (typeof passRequirements.reset == 'number')) {
1311 + var seconds = (userinfo.passchange) + (passRequirements.reset * 86400) - Math.floor(Date.now() / 1000);
1312 + if (seconds < 0) { QH('p2nextPasswordUpdateTime', ' - Reset on next login.'); }
1313 + else if (seconds < 3600) { QH('p2nextPasswordUpdateTime', ' - Reset in ' + Math.floor(seconds / 60) + ' minute' + addLetterS(Math.floor(seconds / 60)) + '.'); }
1314 + else if (seconds < 86400) { QH('p2nextPasswordUpdateTime', ' - Reset in ' + Math.floor(seconds / 3600) + ' hour' + addLetterS(Math.floor(seconds / 3600)) + '.'); }
1315 + else { QH('p2nextPasswordUpdateTime', ' - Reset in ' + Math.floor(seconds / 86400) + ' day' + addLetterS(Math.floor(seconds / 86400)) + '.'); }
1316 + }
1317 + }
1318 + }
1319 +
1320 + function addLetterS(x) { return (x > 1) ? 's' : ''; }
1321 + function setSessionActivity() { sessionActivity = Date.now(); QH('idleTimeoutNotify', ''); }
1322 + function checkIdleSessionTimeout() {
1323 + var delta = (Date.now() - sessionActivity);
1324 + if (delta > serverinfo.timeout) { window.location.href = 'logout'; } else {
1325 + var ds = Math.round((serverinfo.timeout - delta) / 1000);
1326 + if (ds <= 60) {
1327 + QH('idleTimeoutNotify', '<br />' + ds + ' second' + addLetterS(ds) + ' until disconnect');
1328 + } else {
1329 + ds = Math.round(ds / 60);
1330 + if (ds <= 5) { QH('idleTimeoutNotify', '<br />' + ds + ' minute' + addLetterS(ds) + ' until disconnect'); }
1331 + }
1332 + }
1333 + }
1334 +
1335 + function onMessage(server, message) {
1336 + switch (message.action) {
1337 + case 'serverstats': {
1338 + updateGeneralServerStats(message);
1339 + break;
1340 + }
1341 + case 'servertimelinestats': {
1342 + setServerTimelineStats(message.events);
1343 + break;
1344 + }
1345 + case 'authcookie': {
1346 + // Got an authentication cookie refresh
1347 + authCookie = message.cookie;
1348 + break;
1349 + }
1350 + case 'serverinfo': {
1351 + serverinfo = message.serverinfo;
1352 + if (serverinfo.timeout) { setInterval(checkIdleSessionTimeout, 10000); checkIdleSessionTimeout(); }
1353 + break;
1354 + }
1355 + case 'userinfo': {
1356 + userinfo = message.userinfo;
1357 + updateSiteAdmin();
1358 + updateSelf();
1359 + break;
1360 + }
1361 + case 'users': {
1362 + users = {};
1363 + for (var m in message.users) { users[message.users[m]._id] = message.users[m]; }
1364 + updateUsers();
1365 + break;
1366 + }
1367 + case 'wssessioncount': {
1368 + wssessions = message.wssessions;
1369 + updateUsers();
1370 + break;
1371 + }
1372 + case 'meshes': {
1373 + meshes = {};
1374 + for (var m in message.meshes) { meshes[message.meshes[m]._id] = message.meshes[m]; }
1375 + masterUpdate(4 + 128);
1376 + break;
1377 + }
1378 + case 'files': {
1379 + filetree = setupBackPointers(message.filetree);
1380 + updateFiles();
1381 + d3updatefiles();
1382 + break;
1383 + }
1384 + case 'nodes': {
1385 + nodes = [];
1386 + for (var m in message.nodes) {
1387 + if (!meshes[m]) { console.log('Invalid mesh (1): ' + m); continue; }
1388 + for (var n in message.nodes[m]) {
1389 + if (message.nodes[m][n]._id == null) { console.log('Invalid node (' + n + '): ' + JSON.stringify(message.nodes)); continue; }
1390 + message.nodes[m][n].namel = message.nodes[m][n].name.toLowerCase();
1391 + if (message.nodes[m][n].rname) { message.nodes[m][n].rnamel = message.nodes[m][n].rname.toLowerCase(); } else { message.nodes[m][n].rnamel = message.nodes[m][n].namel; }
1392 + message.nodes[m][n].meshnamel = meshes[m].name.toLowerCase();
1393 + message.nodes[m][n].meshid = m;
1394 + message.nodes[m][n].state = (message.nodes[m][n].state)?(message.nodes[m][n].state):0;
1395 + message.nodes[m][n].desc = message.nodes[m][n].desc;
1396 + message.nodes[m][n].ip = message.nodes[m][n].ip;
1397 + if (!message.nodes[m][n].icon) message.nodes[m][n].icon = 1;
1398 + message.nodes[m][n].ident = ++nodeShortIdent;
1399 + nodes.push(message.nodes[m][n]);
1400 + }
1401 + }
1402 + masterUpdate(1 | 2 | 4 | 64);
1403 +
1404 + if (xxcurrentView == 0) { if ('{{viewmode}}' != '') { go(parseInt('{{viewmode}}')); } else { setDialogMode(0); go(1); } }
1405 + if ('{{currentNode}}' != '') { gotoDevice('{{currentNode}}',parseInt('{{viewmode}}'));}
1406 + break;
1407 + }
1408 + case 'powertimeline': {
1409 + if (message.nodeid != powerTimelineReq) break;
1410 + powerTimelineNode = message.nodeid;
1411 + powerTimeline = message.timeline;
1412 + powerTimelineUpdate = Date.now() + 300000; // Update every 5 minutes
1413 + for (var i in powerTimeline) { if (i % 2 == 1) { powerTimeline[i] = powerTimeline[i] * 1000; } } // Decompress time
1414 + if (currentNode._id == message.nodeid) { masterUpdate(256); }
1415 + break;
1416 + }
1417 + case 'lastconnect': {
1418 + var node = getNodeFromId(message.nodeid);
1419 + if (node != null) {
1420 + node.lastconnect = message.time;
1421 + node.lastaddr = message.addr;
1422 + if ((currentNode._id == node._id) && (Q('MainComputerState').innerHTML == '')) {
1423 + QH('MainComputerState', '<span>Last seen:<br />' + printDateTime(new Date(node.lastconnect)) + '</span>');
1424 + }
1425 + }
1426 + break;
1427 + }
1428 + case 'msg': {
1429 + // Check if this is a message from a node
1430 + if (message.nodeid != null) {
1431 + var index = -1;
1432 + if (nodes != null) { for (var i in nodes) { if (nodes[i]._id == message.nodeid) { index = i; break; } } }
1433 + if (index != -1) {
1434 + // Node was found, dispatch the message
1435 + if (message.type == 'console') { p15consoleReceive(nodes[index], message.value); } // This is a console message.
1436 + else if (message.type == 'notify') { // This is a notification message.
1437 + var n = getstore('notifications', 0);
1438 + if (((n & 8) == 0) && (message.amtMessage != null)) { break; } // Intel AMT desktop & terminal messages should be ignored.
1439 + var n = { text: message.value, title: message.title, icon: message.icon };
1440 + if (message.nodeid != null) { n.nodeid = message.nodeid; }
1441 + if (message.tag != null) { n.tag = message.tag; }
1442 + if (message.username != null) { n.username = message.username; }
1443 + addNotification(n);
1444 + } else if (message.type == 'ps') {
1445 + showDeskToolsProcesses(message);
1446 + } else if ((message.type == 'getclip') && (xxdialogTag == 'clipboard') && (currentNode != null) && (currentNode._id == message.nodeid)) {
1447 + Q('d2clipText').value = message.data;
1448 + } else if ((message.type == 'setclip') && (xxdialogTag == 'clipboard') && (currentNode != null) && (currentNode._id == message.nodeid)) {
1449 + // Display success/fail on the clipboard dialog box.
1450 + QH('dlgClipStatus', message.success ? '<span style=color:green>Success</span>' : '<span style=color:red>Failed</span>')
1451 + setTimeout(function () { try { QH('dlgClipStatus', ''); } catch (ex) { } }, 2000);
1452 + }
1453 + }
1454 + } else {
1455 + if (message.type == 'notify') { // This is a notification message.
1456 + var n = { text: message.value, title: message.title, icon: message.icon };
1457 + if (message.tag != null) { n.tag = message.tag; }
1458 + if (message.username != null) { n.username = message.username; }
1459 + addNotification(n);
1460 + }
1461 + }
1462 + break;
1463 + }
1464 + case 'getnetworkinfo': {
1465 + if ((currentNode._id == message.nodeid) && (xxdialogMode == 2) && (xxdialogTag == 'if' + message.nodeid)) {
1466 + if (message.netif == null) {
1467 + QH('d2netinfo', 'No network interface information available for this device.');
1468 + } else {
1469 + var x = '<div class=dialogText>';
1470 +
1471 + if (currentNode.lastconnect) { x += addHtmlValue2('Last agent connection', printDateTime(new Date(currentNode.lastconnect))); }
1472 + if (currentNode.lastaddr) {
1473 + var splitip = currentNode.lastaddr.split(':');
1474 + if (splitip.length > 2) {
1475 + // IPv6
1476 + x += addHtmlValue2('Last agent address', currentNode.lastaddr);
1477 + } else {
1478 + // IPv4
1479 + if (isPrivateIP(currentNode.lastaddr)) {
1480 + x += addHtmlValue2('Last agent address', splitip[0]);
1481 + } else {
1482 + x += addHtmlValue2('Last agent address', '<a href="https://iplocation.com/?ip=' + splitip[0] + '" rel="noreferrer noopener" target="MeshIPLoopup">' + splitip[0] + '</a>');
1483 + }
1484 + }
1485 + }
1486 +
1487 + x += addHtmlValue2('Last interfaces update', printDateTime(new Date(message.updateTime)));
1488 + for (var i in message.netif) {
1489 + var net = message.netif[i];
1490 + x += '<hr />'
1491 + if (net.name) { x += addHtmlValue2('Name', '<b>' + EscapeHtml(net.name) + '</b>'); }
1492 + if (net.desc) { x += addHtmlValue2('Description', EscapeHtml(net.desc).replace('(R)', '&reg;').replace('(r)', '&reg;')); }
1493 + if (net.dnssuffix) { x += addHtmlValue2('DNS suffix', EscapeHtml(net.dnssuffix)); }
1494 + if (net.mac) { x += addHtmlValue2('MAC address', '<a href="https://dnslytics.com/mac-address-lookup/' + net.mac.substring(0,6) + '" rel="noreferrer noopener" target="MeshMACLoopup">' + EscapeHtml(net.mac.toLowerCase()) + '</a>'); }
1495 + if (net.v4addr) { x += addHtmlValue2('IPv4 address', EscapeHtml(net.v4addr)); }
1496 + if (net.v4mask) { x += addHtmlValue2('IPv4 mask', EscapeHtml(net.v4mask)); }
1497 + if (net.v4gateway) { x += addHtmlValue2('IPv4 gateway', EscapeHtml(net.v4gateway)); }
1498 + if (net.gatewaymac) { x += addHtmlValue2('Gateway MAC', '<a href="https://dnslytics.com/mac-address-lookup/' + net.gatewaymac.substring(0, 6) + '" rel="noreferrer noopener" target="MeshMACLoopup">' + EscapeHtml(net.gatewaymac.toLowerCase()) + '</a>'); }
1499 + }
1500 + x += '</div>';
1501 + QH('d2netinfo', x);
1502 + }
1503 + }
1504 + break;
1505 + }
1506 + case 'serverversion': {
1507 + if ((xxdialogMode == 2) && (xxdialogTag == 'MeshCentralServerUpdate')) {
1508 + var x = '<div class=dialogText>';
1509 + if (!message.current) { message.current = 'Unknown'; }
1510 + if (!message.latest) { message.latest = 'Unknown'; }
1511 + x += addHtmlValue2('Current Version', '<b>' + EscapeHtml(message.current) + '</b>');
1512 + x += addHtmlValue2('Latest Version', '<b>' + EscapeHtml(message.latest) + '</b>');
1513 + x += '</div>';
1514 + if ((message.latest.indexOf('.') == -1) || (message.current == message.latest) || ((features & 2048) == 0)) {
1515 + setDialogMode(2, "MeshCentral Version", 1, null, x);
1516 + } else {
1517 + setDialogMode(2, "MeshCentral Version", 3, server_showVersionDlgEx, x + '<br /><label><input id=d2updateCheck type=checkbox onclick=server_showVersionDlgUpdate() /> Check and click OK to start server self-update.</label>');
1518 + server_showVersionDlgUpdate();
1519 + }
1520 + }
1521 + break;
1522 + }
1523 + case 'servererrors': {
1524 + if ((xxdialogMode == 2) && (xxdialogTag == 'MeshCentralServerErrors')) {
1525 + if (message.data == null) {
1526 + setDialogMode(2, "MeshCentral Server Errors", 1, null, 'Server has no error log.');
1527 + } else {
1528 + var x = '<div class="dialogText dialogTextLog"><pre id=d2ServerErrorsLogPre>' + message.data + '<pre></div>';
1529 + setDialogMode(2, "MeshCentral Server Errors", 3, server_showErrorsDlgEx, x + '<br /><div style=float:right><img src=images/link4.png height=10 width=10 title="Download error log" style=cursor:pointer onclick=d2CopyServerErrorsToClip()></div><div><label><input id=d2updateCheck type=checkbox onclick=server_showVersionDlgUpdate() /> Check and click OK to clear error log.</label></div>');
1530 + server_showVersionDlgUpdate();
1531 + }
1532 + }
1533 + break;
1534 + }
1535 + case 'serverconsole': {
1536 + p15consoleReceive('serverconsole', message.value);
1537 + break;
1538 + }
1539 + case 'events': {
1540 + if ((message.nodeid != null) && (message.nodeid == currentNode._id)) {
1541 + currentDeviceEvents = message.events;
1542 + masterUpdate(1024);
1543 + } else if ((message.user != null) && (message.user == currentUser.name)) {
1544 + currentUserEvents = message.events;
1545 + masterUpdate(2048);
1546 + } else {
1547 + events = message.events;
1548 + masterUpdate(32);
1549 + }
1550 + break;
1551 + }
1552 + case 'getcookie': {
1553 + if (message.tag == 'clickonce') {
1554 + var basicPort = "{{{serverRedirPort}}}" == "" ? "{{{serverPublicPort}}}" : "{{{serverRedirPort}}}";
1555 + var rdpurl = "http://" + window.location.hostname + ":" + basicPort + "/clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F" + window.location.hostname + "%2Fmeshrelay.ashx%3Fauth=" + message.cookie + "&CH={{{webcerthash}}}&AP=" + message.protocol + ((debugmode == 1) ? "" : "&HOL=1");
1556 + var newWindow = window.open(rdpurl, '_blank');
1557 + newWindow.opener = null;
1558 + }
1559 + break;
1560 + }
1561 + case 'getNotes': {
1562 + var n = Q('d2devNotes');
1563 + if (n && (message.id == decodeURIComponent(n.attributes['noteid'].value))) {
1564 + if (message.notes) { QH('d2devNotes', decodeURIComponent(message.notes)); } else { QH('d2devNotes', ''); }
1565 + var ro = (n.attributes['ro'].value == 'true');
1566 + if (ro == false) { // If we have permissions, set read/write on this note.
1567 + n.removeAttribute('readonly');
1568 + QE('idx_dlgOkButton', true);
1569 + QV('idx_dlgOkButton', true);
1570 + focusTextBox('d2devNotes');
1571 + }
1572 + }
1573 + break;
1574 + }
1575 + case 'otpauth-request': {
1576 + if ((xxdialogMode == 2) && (xxdialogTag == 'otpauth-request')) {
1577 + var secret = message.secret;
1578 + if (secret.length == 52) { secret = secret.split(/(.............)/).filter(Boolean).join(' '); }
1579 + else if (secret.length == 32) { secret = secret.split(/(....)/).filter(Boolean).join(' '); secret = secret.substring(0, 20) + '<br/>' + secret.substring(20) }
1580 + QH('d2optinfo', '<table style=width:380px><tr><td style=vertical-align:top>Install <a href=\"https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2\" rel=\"noreferrer noopener\" target=_blank>Google Authenticator</a> or a compatible application and scan the barcode, use <a href=\"' + message.url + '\" rel=\"noreferrer noopener\" target=_blank> this link</a> or enter the secret. Then, enter the current 6 digit token below to activate 2-Step login.<br /><br />Secret<br /><tt id=d2optsecret secret=\"' + message.secret + '\" style=font-size:12px>' + secret + '</tt><br /><br /></td><td style=width:1px;vertical-align:top><a href=\"' + message.url + '\" rel=\"noreferrer noopener\" target=_blank><div id="qrcode"></div></a></td><tr><td colspan=2 style="text-align:center;border-top:1px solid black"><br />Enter the token here for 2-step login: <input type=text onkeypress=\"return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)\" onkeyup=account_addOtpCheck(event) onkeydown=account_addOtpCheck() maxlength=6 id=d2otpauthinput type=text></td></table>');
1581 + new QRCode(Q("qrcode"), { text: message.url, width: 128, height: 128, colorDark: "#000000", colorLight: "#EEE", correctLevel: QRCode.CorrectLevel.H });
1582 + QV('idx_dlgOkButton', true);
1583 + QE('idx_dlgOkButton', false);
1584 + Q('d2otpauthinput').focus();
1585 + }
1586 + break;
1587 + }
1588 + case 'otpauth-setup': {
1589 + if (xxdialogMode) return;
1590 + setDialogMode(2, "Authenticator App", 1, null, message.success ? "<b style=color:green>Authenticator app activation successful</b>. You will now need a valid token to login again." : "<b style=color:red>2-step login activation failed</b>. Clear the secret from the application and try again. You only have a few minutes to enter the proper code.");
1591 + break;
1592 + }
1593 + case 'otpauth-clear': {
1594 + if (xxdialogMode) return;
1595 + setDialogMode(2, "Authenticator App", 1, null, message.success ? "<b>Authenticator application removed</b>. You can reactivate this feature at any time." : "<b style=color:red>2-step login activation removal failed</b>. Try again.");
1596 + break;
1597 + }
1598 + case 'otpauth-getpasswords': {
1599 + if (xxdialogMode) return;
1600 + var x = "One time tokens can be used as secondary authentication. Generate a set, print them and keep them in a safe place.";
1601 + x += "<div style='border-radius:6px;border: 2px dashed #888;width:100%;margin-top:8px'><div style='padding:8px;font-family:Arial, Helvetica, sans-serif;font-size:20px;font-weight:bold'><table style=width:100%;text-align:center>";
1602 + if (message.passwords) {
1603 + var j = 0;
1604 + for (var i in message.passwords) {
1605 + if (++j % 2) { x += '<tr>'; }
1606 + var p = '' + message.passwords[i].p;
1607 + while (p.length < 8) { p = '0' + p; }
1608 + if (message.passwords[i].u === true) { x += '<td>' + p.substring(0, 4) + '&nbsp;' + p.substring(4); } else { x += '<td><strike style=color:#BBB>' + p.substring(0, 4) + '&nbsp;' + p.substring(4); + '</strike>'; }
1609 + }
1610 + } else {
1611 + x += '<tr><td>No Active Tokens';
1612 + }
1613 + x += "</table></div></div><br />";
1614 + x += "<div><input type=button value='Close' onclick=setDialogMode(0) style=float:right></input>";
1615 + x += "<input type=button value='Generate New Tokens' onclick='account_manageOtp(1);'></input>";
1616 + if (message.passwords != null) { x += "<input type=button value='Clear Tokens' onclick='account_manageOtp(2);'></input>"; }
1617 + x += "</div><br />";
1618 + setDialogMode(2, "Manage Backup Codes", 8, null, x, 'otpauth-manage');
1619 + break;
1620 + }
1621 + case 'otp-hkey-get': {
1622 + if (xxdialogMode && (xxdialogTag != 'otpauth-hardware-manage')) return;
1623 + var start = "<div style='border-radius:6px;border:2px solid #CCC;background-color:#BBB;width:100%;box-sizing:border-box;margin-bottom:6px'><div style='margin:3px;font-family:Arial, Helvetica, sans-serif;font-size:16px;font-weight:bold'><table style=width:100%;text-align:left>";
1624 + var end = "</table></div></div>";
1625 + var x = "<a href='https://www.yubico.com/' rel='noreferrer noopener' target='_blank'>Hardware keys</a> are used as secondary login authentication.";
1626 + x += "<div style='max-height:150px;overflow-y:auto;overflow-x:hidden;margin-top:6px;margin-bottom:6px'>";
1627 + if (message.keys && message.keys.length > 0) {
1628 + for (var i in message.keys) {
1629 + var key = message.keys[i], type = (key.type == 2)?'OTP':'WebAuthn';
1630 + x += start + '<tr style=margin:5px><td style=width:30px><img width=24 height=18 src="images/hardware-key-' + type + '-24.png" style=margin-top:4px><td style=width:250px>' + key.name + "<td><input type=button value='Remove' onclick=account_removehkey(" + key.i + ")></input>" + end;
1631 + }
1632 + } else {
1633 + x += start + '<tr style=text-align:center><td>No Keys Configured' + end;
1634 + }
1635 + x += "</div>";
1636 + x += "<div><input type=button value='Close' onclick=setDialogMode(0) style=float:right></input>";
1637 + if ((features & 0x00020000) != 0) { x += "<input id=d2addkey3 type=button value='Add Key' onclick='account_addhkey(3);'></input>"; }
1638 + if ((features & 0x00004000) != 0) { x += "<input id=d2addkey2 type=button value='Add YubiKey&reg; OTP' onclick='account_addhkey(2);'></input>"; }
1639 + x += "</div><br />";
1640 + setDialogMode(2, "Manage Security Keys", 8, null, x, 'otpauth-hardware-manage');
1641 + if (u2fSupported() == false) { QE('d2addkey1', false); }
1642 + break;
1643 + }
1644 + case 'otp-hkey-yubikey-add': {
1645 + if (message.result) {
1646 + meshserver.send({ action: 'otp-hkey-get' }); // Success, ask for the full list of keys.
1647 + } else {
1648 + setDialogMode(2, "Add Security Key", 1, null, '<br />Error, Unable to add key.<br /><br />');
1649 + }
1650 + break;
1651 + }
1652 + case 'otp-hkey-setup-response': {
1653 + if (xxdialogMode && (xxdialogTag != 'otpauth-hardware-manage')) return;
1654 + if (message.result == true) {
1655 + meshserver.send({ action: 'otp-hkey-get' }); // Success, ask for the full list of keys.
1656 + } else {
1657 + setDialogMode(2, "Add Security Key", 1, null, '<br />ERROR: Unable to add key.<br /><br />', 'otpauth-hardware-manage');
1658 + }
1659 + break;
1660 + }
1661 + case 'webauthn-startregister': {
1662 + if (xxdialogMode && (xxdialogTag != 'otpauth-hardware-manage')) return;
1663 + var x = "Press the key button now.<br /><br /><div style=width:100%;text-align:center><img width=120 height=117 src='images/hardware-keypress-120.png' /></div><input id=dp1keyname style=display:none value=" + message.name + " />";
1664 + setDialogMode(2, "Add Security Key", 2, null, x);
1665 +
1666 + var publicKey = message.request;
1667 + message.request.challenge = Uint8Array.from(atob(message.request.challenge), function (c) { return c.charCodeAt(0) })
1668 + message.request.user.id = Uint8Array.from(atob(message.request.user.id), function (c) { return c.charCodeAt(0) })
1669 + navigator.credentials.create({ publicKey: publicKey })
1670 + .then(function(newCredentialInfo) {
1671 + // Public key credential
1672 + var r = { rawId: btoa(String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.rawId))), response: { attestationObject: btoa(String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.attestationObject))), clientDataJSON: btoa(String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON))) }, type: newCredentialInfo.type };
1673 + meshserver.send({ action: 'webauthn-endregister', response: r });
1674 + setDialogMode(0);
1675 + }, function(error) {
1676 + // Error
1677 + setDialogMode(2, "Add Security Key", 1, null, "ERROR: " + error);
1678 + });
1679 + break;
1680 + }
1681 + case 'event': {
1682 + if (!message.event.nolog) {
1683 + events.unshift(message.event);
1684 + var eventLimit = parseInt(p3limitdropdown.value);
1685 + while (events.length > eventLimit) { events.pop(); } // Remove element(s) at the end
1686 + masterUpdate(32);
1687 + }
1688 + if (message.event.noact) break; // Take no action on this event
1689 + switch (message.event.action) {
1690 + case 'userWebState': {
1691 + // New user web state, update the web page as needed
1692 + if (localStorage != null) {
1693 + var oldShowRealNames = localStorage.getItem('showRealNames');
1694 + var oldUiMode = localStorage.getItem('uiMode');
1695 + var oldSort = localStorage.getItem('sort');
1696 +
1697 + var webstate = JSON.parse(message.event.state);
1698 + for (var i in webstate) { localStorage.setItem(i, webstate[i]); }
1699 +
1700 + // Update the web page
1701 + if ((webstate.deskAspectRatio != null) && (webstate.deskAspectRatio != deskAspectRatio)) { deskAspectRatio = webstate.deskAspectRatio; deskAdjust(); }
1702 + if ((webstate.showRealNames != null) && (webstate.showRealNames != oldShowRealNames)) { showRealNames = Q('RealNameCheckBox').checked = (webstate.showRealNames == "1"); masterUpdate(6); }
1703 + if ((webstate.uiMode != null) && (webstate.uiMode != oldUiMode)) { userInterfaceSelectMenu(parseInt(webstate.uiMode)); }
1704 + if ((webstate.sort != null) && (webstate.sort != oldSort)) { document.getElementById("sortselect").selectedIndex = sort = parseInt(webstate.sort); masterUpdate(6); }
1705 + }
1706 + break;
1707 + }
1708 + case 'servertimelinestats': { addServerTimelineStats(message.event.data); break; }
1709 + case 'accountcreate':
1710 + case 'accountchange': {
1711 + // An account was created or changed
1712 + if (userinfo.name == message.event.account.name) {
1713 + var newsiteadmin = message.event.account.siteadmin?message.event.account.siteadmin:0;
1714 + var oldsiteadmin = userinfo.siteadmin?userinfo.siteadmin:0;
1715 + if ((message.event.account.quota != userinfo.quota) || (((userinfo.siteadmin & 8) == 0) && ((message.event.account.siteadmin & 8) != 0))) { meshserver.send({ action: 'files' }); }
1716 + var oldgroups = userinfo.groups;
1717 + userinfo = message.event.account;
1718 + if (oldsiteadmin != newsiteadmin) updateSiteAdmin();
1719 + updateSelf();
1720 +
1721 + if ((userinfo.siteadmin & 2) != 0) {
1722 + // Compare our groups
1723 + var og = oldgroups ? oldgroups : [];
1724 + var ng = userinfo.groups ? userinfo.groups : [];
1725 + if (og.join(',') != ng.join(',')) {
1726 + // Our groups have changed, re-ask for a list of users.
1727 + users = wssessions = null;
1728 + meshserver.send({ action: 'users' });
1729 + meshserver.send({ action: 'wssessioncount' });
1730 + }
1731 + }
1732 + }
1733 + if (users == null) break;
1734 +
1735 + // Check if the account is part of our user group
1736 + if ((userinfo.groups == null) || (userinfo.groups.length == 0) || (findOne(message.event.account.groups, userinfo.groups) == true)) {
1737 + users[message.event.account._id] = message.event.account; // Part of our groups, update this user.
1738 + } else {
1739 + delete users[message.event.account._id]; // No longer part of our groups, remove this user.
1740 + }
1741 +
1742 + updateUsers();
1743 + break;
1744 + }
1745 + case 'accountremove': {
1746 + // An account was removed
1747 + if (users == null) break;
1748 + delete users['user/' + domain + '/' + message.event.username.toLowerCase()];
1749 + updateUsers();
1750 + break;
1751 + }
1752 + case 'createmesh': {
1753 + // A new mesh was created
1754 + if ((meshes[message.event.meshid] == null) && (message.event.links[userinfo._id] != null)) { // Check if this is a mesh create for a mesh we own. If site administrator, we get all messages so need to ignore some.
1755 + meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links };
1756 + masterUpdate(4 + 128);
1757 + meshserver.send({ action: 'files' });
1758 + }
1759 + break;
1760 + }
1761 + case 'meshchange': {
1762 + // Update mesh information
1763 + if (meshes[message.event.meshid] == null) {
1764 + // This is a new mesh for us
1765 + meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links };
1766 + meshserver.send({ action: 'nodes' }); // Request a refresh of all nodes (TODO: We could optimize this to only request nodes for the new mesh).
1767 + } else {
1768 + // This is an existing mesh
1769 + if (message.event.name != null) { meshes[message.event.meshid].name = message.event.name; }
1770 + if (message.event.desc != null) { meshes[message.event.meshid].desc = message.event.desc; }
1771 + if (message.event.flags != null) { meshes[message.event.meshid].flags = message.event.flags; }
1772 + if (message.event.consent != null) { meshes[message.event.meshid].consent = message.event.consent; }
1773 + if (message.event.links) { meshes[message.event.meshid].links = message.event.links; }
1774 + if (message.event.amt) { meshes[message.event.meshid].amt = message.event.amt; }
1775 +
1776 + // Check if we lost rights to this mesh in this change.
1777 + if (meshes[message.event.meshid].links[userinfo._id] == null) {
1778 + if ((xxcurrentView == 20) && (currentMesh == meshes[message.event.meshid])) go(2);
1779 + delete meshes[message.event.meshid];
1780 +
1781 + // Delete all nodes in that mesh
1782 + var newnodes = [];
1783 + for (var i in nodes) { if (nodes[i].meshid != message.event.meshid) { newnodes.push(nodes[i]); } }
1784 + nodes = newnodes;
1785 +
1786 + // If we are looking at a node in the deleted mesh, move back to "My Devices"
1787 + if (xxcurrentView >= 10 && xxcurrentView < 20 && currentNode && currentNode.meshid == message.event.meshid) { setDialogMode(0); go(1); }
1788 + }
1789 + }
1790 + masterUpdate(4 + 128);
1791 + if (currentNode && (currentNode.meshid == message.event.meshid)) { currentNode = null; if ((xxcurrentView >= 10) && (xxcurrentView < 20)) { go(1); } }
1792 + //meshserver.send({ action: 'files' }); // TODO: Why do we need to do this??
1793 +
1794 + // If we are looking at a mesh that is now deleted, move back to "My Account"
1795 + if (xxcurrentView == 20 && currentMesh._id == message.event.meshid) { masterUpdate(4096); }
1796 + break;
1797 + }
1798 + case 'deletemesh': {
1799 + // Delete the mesh
1800 + if (meshes[message.event.meshid]) {
1801 + delete meshes[message.event.meshid];
1802 + masterUpdate(128);
1803 + meshserver.send({ action: 'files' });
1804 + }
1805 +
1806 + // Delete all nodes in that mesh
1807 + var newnodes = [];
1808 + if (nodes != null) { for (var i in nodes) { if (nodes[i].meshid != message.event.meshid) { newnodes.push(nodes[i]); } } }
1809 + nodes = newnodes;
1810 + masterUpdate(4);
1811 +
1812 + // If we are looking at a mesh that is now deleted, move back to "My Account"
1813 + if (xxcurrentView >= 20 && xxcurrentView < 30 && currentMesh._id == message.event.meshid) { setDialogMode(0); go(2); }
1814 + // If we are looking at a node in the deleted mesh, move back to "My Devices"
1815 + if (xxcurrentView >= 10 && xxcurrentView < 20 && currentNode && currentNode.meshid == message.event.meshid) { setDialogMode(0); go(1); }
1816 +
1817 + break;
1818 + }
1819 + case 'addnode': {
1820 + var node = message.event.node;
1821 + if (!meshes[node.meshid]) break; // This is a node for a mesh we don't know. Happens when we are site administrator, we get all messages.
1822 + if (getNodeFromId(node._id) != null) break; // This node is already known.
1823 + node.namel = node.name.toLowerCase();
1824 + if (node.rname) { node.rnamel = node.rname.toLowerCase(); } else { node.rnamel = node.namel; }
1825 + node.meshnamel = meshes[node.meshid].name.toLowerCase();
1826 + node.state = 0;
1827 + if (!node.icon) node.icon = 1;
1828 + node.ident = ++nodeShortIdent;
1829 + if (nodes == null) { }
1830 + nodes.push(node);
1831 +
1832 + // Web page update
1833 + masterUpdate(1 | 2 | 4 | 16);
1834 +
1835 + break;
1836 + }
1837 + case 'removenode': {
1838 + var index = -1;
1839 + for (var i in nodes) { if (nodes[i]._id == message.event.nodeid) { index = i; break; } }
1840 + if (index != -1) {
1841 + var node = nodes[index];
1842 + if (currentNode == node) {
1843 + if (xxcurrentView >= 10 && xxcurrentView < 20) { setDialogMode(0); go(1); }
1844 + currentNode = null;
1845 + // TODO: Correctly disconnect from this node (Desktop/Terminal/Files...)
1846 + }
1847 + nodes.splice(index, 1);
1848 +
1849 + // Web page update
1850 + masterUpdate(4 | 16);
1851 + }
1852 + break;
1853 + }
1854 + case 'changenode': {
1855 + var index = -1;
1856 + for (var i in nodes) { if (nodes[i]._id == message.event.nodeid) { index = i; break; } }
1857 + if (index != -1) {
1858 + var node = nodes[index];
1859 +
1860 + // Change the node
1861 + node.name = message.event.node.name;
1862 + node.rname = message.event.node.rname;
1863 + node.users = message.event.node.users;
1864 + node.host = message.event.node.host;
1865 + node.desc = message.event.node.desc;
1866 + node.ip = message.event.node.ip;
1867 + node.osdesc = message.event.node.osdesc;
1868 + node.publicip = message.event.node.publicip;
1869 + node.iploc = message.event.node.iploc;
1870 + node.wifiloc = message.event.node.wifiloc;
1871 + node.gpsloc = message.event.node.gpsloc;
1872 + node.tags = message.event.node.tags;
1873 + node.userloc = message.event.node.userloc;
1874 + if (message.event.node.agent != null) {
1875 + if (node.agent == null) node.agent = {};
1876 + if (message.event.node.agent.ver != null) { node.agent.ver = message.event.node.agent.ver; }
1877 + if (message.event.node.agent.id != null) { node.agent.id = message.event.node.agent.id; }
1878 + if (message.event.node.agent.caps != null) { node.agent.caps = message.event.node.agent.caps; }
1879 + if (message.event.node.agent.core != null) { node.agent.core = message.event.node.agent.core; } else { if (node.agent.core) { delete node.agent.core; } }
1880 + node.agent.tag = message.event.node.agent.tag;
1881 + }
1882 + if (message.event.node.intelamt != null) {
1883 + if (node.intelamt == null) node.intelamt = {};
1884 + if (message.event.node.intelamt.state != null) { node.intelamt.state = message.event.node.intelamt.state; }
1885 + if (message.event.node.intelamt.host != null) { node.intelamt.user = message.event.node.intelamt.host; }
1886 + if (message.event.node.intelamt.user != null) { node.intelamt.user = message.event.node.intelamt.user; }
1887 + if (message.event.node.intelamt.tls != null) { node.intelamt.tls = message.event.node.intelamt.tls; }
1888 + if (message.event.node.intelamt.ver != null) { node.intelamt.ver = message.event.node.intelamt.ver; }
1889 + if (message.event.node.intelamt.tag != null) { node.intelamt.tag = message.event.node.intelamt.tag; }
1890 + if (message.event.node.intelamt.uuid != null) { node.intelamt.uuid = message.event.node.intelamt.uuid; }
1891 + if (message.event.node.intelamt.realm != null) { node.intelamt.realm = message.event.node.intelamt.realm; }
1892 + }
1893 + node.namel = node.name.toLowerCase();
1894 + if (node.rname) { node.rnamel = node.rname.toLowerCase(); } else { node.rnamel = node.namel; }
1895 + if (message.event.node.icon) { node.icon = message.event.node.icon; }
1896 +
1897 + // Web page update
1898 + masterUpdate(2 | 4 | 8 | 16);
1899 + refreshDevice(node._id);
1900 +
1901 + if ((currentNode == node) && (xxdialogMode != null) && (xxdialogTag == '@xxmap')) { p10showNodeLocationDialog(); }
1902 + }
1903 + break;
1904 + }
1905 + case 'nodemeshchange': {
1906 + var index = -1;
1907 + for (var i in nodes) { if (nodes[i]._id == message.event.nodeid) { index = i; break; } }
1908 + if (index != -1) {
1909 + var node = nodes[index];
1910 + if (meshes[message.event.newMeshId] == null) {
1911 + // We don't see the new mesh, remove this device
1912 +
1913 + // TODO: Correctly disconnect from this node (Desktop/Terminal/Files...)
1914 + if (currentNode == node) { if (xxcurrentView >= 10 && xxcurrentView < 20) { setDialogMode(0); go(1); } currentNode = null; }
1915 + nodes.splice(index, 1);
1916 + masterUpdate(4 | 16);
1917 + } else {
1918 + // We see the new mesh, move this device
1919 + node.meshid = message.event.newMeshId;
1920 + node.meshnamel = meshes[message.event.newMeshId].name.toLowerCase();
1921 + masterUpdate(1 | 2 | 4);
1922 + }
1923 + refreshDevice(message.event.nodeid);
1924 + } else {
1925 + // This is a new device, add it.
1926 + var node = message.event.node;
1927 + if (!meshes[node.meshid]) break; // This is a node for a mesh we don't know. Happens when we are site administrator, we get all messages.
1928 + node.namel = node.name.toLowerCase();
1929 + if (node.rname) { node.rnamel = node.rname.toLowerCase(); } else { node.rnamel = node.namel; }
1930 + node.meshnamel = meshes[node.meshid].name.toLowerCase();
1931 + node.state = 0;
1932 + if (!node.icon) node.icon = 1;
1933 + node.ident = ++nodeShortIdent;
1934 + if (nodes == null) { }
1935 + nodes.push(node);
1936 +
1937 + // Web page update
1938 + masterUpdate(1 | 2 | 4 | 16);
1939 + }
1940 + break;
1941 + }
1942 + case 'nodeconnect': {
1943 + // Indicated a node has changed connectivity state
1944 + var index = -1;
1945 + for (var i in nodes) { if (nodes[i]._id == message.event.nodeid) { index = i; break; } }
1946 + if (index != -1) {
1947 + var node = nodes[index];
1948 +
1949 + // Event the connection change if needed
1950 + var n = getstore('notifications', 0); // Account notification settings
1951 +
1952 + // Per-group notification settings
1953 + if (message.event.meshid && userinfo.links && userinfo.links[message.event.meshid] && userinfo.links[message.event.meshid].notify) {
1954 + n |= userinfo.links[message.event.meshid].notify;
1955 + }
1956 +
1957 + // Show the notification
1958 + if (n & 2) {
1959 + if (((node.conn & 1) == 0) && ((message.event.conn & 1) != 0)) { addNotification({ text: 'Agent connected', title: node.name, icon: node.icon, nodeid: node._id }); }
1960 + if (((node.conn & 2) == 0) && ((message.event.conn & 2) != 0)) { addNotification({ text: 'Intel AMT detected', title: node.name, icon: node.icon, nodeid: node._id }); }
1961 + if (((node.conn & 4) == 0) && ((message.event.conn & 4) != 0)) { addNotification({ text: 'Intel AMT CIRA connected', title: node.name, icon: node.icon, nodeid: node._id }); }
1962 + }
1963 + if (n & 4) {
1964 + if (((node.conn & 1) != 0) && ((message.event.conn & 1) == 0)) { addNotification({ text: 'Agent disconnected', title: node.name, icon: node.icon, nodeid: node._id }); }
1965 + if (((node.conn & 2) != 0) && ((message.event.conn & 2) == 0)) { addNotification({ text: 'Intel AMT not detected', title: node.name, icon: node.icon, nodeid: node._id }); }
1966 + if (((node.conn & 4) != 0) && ((message.event.conn & 4) == 0)) { addNotification({ text: 'Intel AMT CIRA disconnected', title: node.name, icon: node.icon, nodeid: node._id }); }
1967 + }
1968 +
1969 + // Change the node connection state
1970 + node.conn = message.event.conn;
1971 + node.pwr = message.event.pwr;
1972 +
1973 + // Web page update
1974 + masterUpdate(4 | 16);
1975 + refreshDevice(node._id);
1976 + }
1977 + break;
1978 + }
1979 + case 'wssessioncount': {
1980 + // Update the active web socket session count for a user
1981 + if (wssessions != null) {
1982 + if (message.event.count == 0 && wssessions['user/' + domain + '/' + message.event.username.toLowerCase()]) {
1983 + delete wssessions['user/' + domain + '/' + message.event.username.toLowerCase()];
1984 + } else {
1985 + wssessions['user/' + domain + '/' + message.event.username.toLowerCase()] = message.event.count;
1986 + }
1987 + updateUsers();
1988 + }
1989 + break;
1990 + }
1991 + case 'clearevents': {
1992 + events = [];
1993 + masterUpdate(32);
1994 + break;
1995 + }
1996 + case 'login': {
1997 + // Update the last login time
1998 + if (users != null && users['user/' + domain + '/' + message.event.username.toLowerCase()]) {
1999 + users['user/' + domain + '/' + message.event.username.toLowerCase()].login = Math.floor(new Date(message.event.time).getTime() / 1000);
2000 + }
2001 + break;
2002 + }
2003 + case 'scanamtdevice': {
2004 + // Populate the Intel AMT scan dialog box with the result of the RMCP scan
2005 + if ((xxdialogMode == null) || (!Q('dp1range')) || (Q('dp1range').value != message.event.range)) return;
2006 + var x = '';
2007 + if (message.event.results == null) {
2008 + // The scan could not occur because of an error. Likely the user range was invalid.
2009 + x = '<div style=width:100%;text-align:center;margin-top:12px>Unable to scan this address range.</div><div style=width:100%;text-align:center;margin-top:12px;color:gray;line-height:1.5>Sample IP range values<br />192.168.0.100<br />192.168.1.0/24<br />192.167.0.1-192.168.0.100</div>';
2010 + } else {
2011 + // Go thru all the results and populate the dialog box
2012 + amtScanResults = message.event.results;
2013 + for (var i in message.event.results) {
2014 + var r = message.event.results[i], shortname = r.hostname;
2015 + if (shortname.length > 20) { shortname = shortname.substring(0, 20) + '...'; }
2016 + var str = '<b title="' + EscapeHtml(r.hostname) + '">' + EscapeHtml(shortname) + '</b> - v' + r.ver;
2017 + if (r.state == 2) { if (r.tls == 1) { str += ' with TLS.'; } else { str += ' without TLS.'; } } else { str += ' not activated.'; }
2018 + x += '<div style=width:100%;margin-bottom:2px;background-color:lightgray><div style=padding:4px><div style=display:inline-block;margin-right:5px><input class=DevScanCheckbox name=dp1checkbox tag="' + EscapeHtml(i) + '" type=checkbox onclick=addAmtScanToMeshCheckbox() /></div><div class=j1 style=display:inline-block></div><div style=display:inline-block;margin-left:5px;overflow-x:auto;white-space:nowrap>' + str + '</div></div></div>';
2019 + }
2020 + // If no results where found, display a nice message
2021 + if (x == '') { x = '<div style=width:100%;text-align:center;margin-top:12px>Scan returned no results.</div><div style=width:100%;text-align:center;margin-top:12px;color:gray;line-height:1.5>Sample IP range values<br />192.168.0.100<br />192.168.1.0/24<br />192.167.0.1-192.168.0.100</div>'; }
2022 + }
2023 + // Set the html in the dialog box and re-enable the scan button
2024 + QH('dp1results', x);
2025 + QE('dp1range', true);
2026 + QE('dp1rangebutton', true);
2027 + break;
2028 + }
2029 + case 'notify': {
2030 + var n = { text: message.event.value, title: message.event.title, icon: message.event.icon };
2031 + if (message.event.tag != null) { n.tag = message.event.tag; }
2032 + addNotification(n);
2033 + break;
2034 + }
2035 + case 'stopped': { // Server is stopping.
2036 + // Disconnect
2037 + //console.log(message.msg);
2038 + break;
2039 + }
2040 + default:
2041 + //console.log('Unknown message.event.action', message.event.action);
2042 + break;
2043 + }
2044 + break;
2045 + }
2046 + case 'createInviteLink': { // Agent installation invitation link
2047 + if (xxdialogTag != message.meshid) break;
2048 + var servername = serverinfo.name;
2049 + if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name.
2050 + var domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1);
2051 + var url;
2052 + if (serverinfo.https == true) {
2053 + var portStr = (serverinfo.port == 443) ? '' : (":" + serverinfo.port);
2054 + url = "https://" + servername + portStr + domainUrl + "agentinvite?c=" + message.cookie;
2055 + } else {
2056 + var portStr = (serverinfo.port == 80) ? '' : (":" + serverinfo.port);
2057 + url = "http://" + servername + portStr + domainUrl + "agentinvite?c=" + message.cookie;
2058 + }
2059 + Q('agentInvitationLink').href = url;
2060 + var t = message.expire + ' hour' + addLetterS(message.expire);
2061 + if (message.expire == 24) { t = '1 day'; }
2062 + if (message.expire == 168) { t = '1 week'; }
2063 + if (message.expire == 5040) { t = '1 month'; }
2064 + if (message.expire == 0) { t = 'Unlimited'; }
2065 + QH('agentInvitationLink', 'Invitation Link (' + t + ')');
2066 + QV('agentInvitationLinkDiv', true);
2067 + break;
2068 + }
2069 + case 'stopped': { // Server is stopping.
2070 + // Disconnect
2071 + autoReconnect = false;
2072 + QH('p0span', message.msg);
2073 + break;
2074 + }
2075 + default:
2076 + console.log('Unknown message.action', message.action);
2077 + break;
2078 + }
2079 + }
2080 +
2081 + //
2082 + // MY DEVICES
2083 + //
2084 +
2085 + function onRealNameCheckBox() {
2086 + showRealNames = Q('RealNameCheckBox').checked;
2087 + putstore("showRealNames", showRealNames ? 1 : 0);
2088 + masterUpdate(6);
2089 + return;
2090 + }
2091 +
2092 + function onDeviceViewChange(i) {
2093 + if (i != null) { Q('viewselect').value = i; }
2094 + for (var j = 1; j < 5; j++) { Q('devViewButton' + j).classList.remove('viewSelectorSel'); }
2095 + Q('devViewButton' + Q('viewselect').value).classList.add('viewSelectorSel');
2096 + putstore("_deviceView", Q('viewselect').value);
2097 + putstore("_viewsize", Q('sizeselect').value);
2098 + masterUpdate(4);
2099 + setTimeout("masterUpdate(512)", 200);
2100 + }
2101 +
2102 + function ondockeypress(e) {
2103 + setSessionActivity();
2104 + if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked) {
2105 + // Check what keys we are allows to send
2106 + if (currentNode != null) {
2107 + var mesh = meshes[currentNode.meshid];
2108 + var meshrights = mesh.links[userinfo._id].rights;
2109 + var inputAllowed = ((meshrights == 0xFFFFFFFF) || (((meshrights & 8) != 0) && ((meshrights & 256) == 0)));
2110 + if (inputAllowed == false) return false;
2111 + var limitedInputAllowed = ((meshrights != 0xFFFFFFFF) && (((meshrights & 8) != 0) && ((meshrights & 256) == 0) && ((meshrights & 4096) != 0)));
2112 + if (limitedInputAllowed == true) { if ((e.altKey == true) || (e.ctrlKey == true) || ((e.keyCode < 32) && (e.keyCode != 8) && (e.keyCode != 13)) || (e.keyCode > 90)) return false; }
2113 + }
2114 + return desktop.m.handleKeys(e);
2115 + }
2116 + if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3) { return terminal.m.TermHandleKeys(e); }
2117 + if (!xxdialogMode && ((xxcurrentView == 15) || (xxcurrentView == 115))) return agentConsoleHandleKeys(e);
2118 + if (!xxdialogMode && xxcurrentView == 4) {
2119 + if (e.ctrlKey == true || e.altKey == true || e.metaKey == true) return;
2120 + var processed = 0;
2121 + if (e.key) {
2122 + if (e.key.length === 1 && userSearchFocus == 0) { Q('UserSearchInput').value = ((Q('UserSearchInput').value + e.key)); processed = 1; }
2123 + if (e.keyCode == 8 && userSearchFocus == 0) { var x = Q('UserSearchInput').value; Q('UserSearchInput').value = x.substring(0, x.length - 1); processed = 1; }
2124 + if (e.keyCode == 27) { Q('UserSearchInput').value = ''; processed = 1; }
2125 + } else {
2126 + if (e.charCode != 0 && userSearchFocus == 0) { Q('UserSearchInput').value = ((Q('UserSearchInput').value + String.fromCharCode(e.charCode))); processed = 1; }
2127 + }
2128 + if (processed > 0) { if (processed == 1) { onUserSearchInputChanged(); } return haltEvent(e); }
2129 + }
2130 + if (xxdialogMode || xxcurrentView != 1) return;
2131 + if (e.ctrlKey == true && e.charCode == 96) {
2132 + showRealNames = !showRealNames;
2133 + Q('RealNameCheckBox').value = showRealNames;
2134 + putstore("showRealNames", showRealNames ? 1 : 0);
2135 + masterUpdate(6)
2136 + return;
2137 + }
2138 + if (e.ctrlKey == true || e.altKey == true || e.metaKey == true) return;
2139 + if (Q('viewselect').value < 3) {
2140 + var processed = 0;
2141 + if (e.key) {
2142 + if (e.key.length === 1 && searchFocus == 0) { Q('SearchInput').value = ((Q('SearchInput').value + e.key)); processed = 1; }
2143 + if (e.keyCode == 8 && searchFocus == 0) { var x = Q('SearchInput').value; Q('SearchInput').value = x.substring(0, x.length - 1); processed = 1; }
2144 + if (e.keyCode == 27) { Q('SearchInput').value = ''; processed = 1; }
2145 + } else {
2146 + if (e.charCode != 0 && searchFocus == 0) { Q('SearchInput').value = ((Q('SearchInput').value + String.fromCharCode(e.charCode))); processed = 1; }
2147 + }
2148 + if (processed > 0) { if (processed == 1) { masterUpdate(5); } return haltEvent(e); }
2149 + }
2150 + if (Q('viewselect').value == 3) {
2151 + if (e.key) {
2152 + if (e.key.length === 1 && mapSearchFocus == 0) { Q('mapSearchLocation').value = ((Q('mapSearchLocation').value + e.key)); processed = 1; }
2153 + //if (e.keyCode == 8 && mapSearchFocus == 0) { var x = Q('mapSearchLocation').value; Q('mapSearchLocation').value = x.substring(0, x.length - 1); processed = 1; }
2154 + if (e.keyCode == 27) { Q('mapSearchLocation').value = ''; mapCloseSearchWindow(); processed = 1; }
2155 + if (e.keyCode == 13) { getSearchLocation(); }
2156 + } else {
2157 + if (e.charCode != 0 && mapSearchFocus == 0) { Q('mapSearchLocation').value = ((Q('mapSearchLocation').value + String.fromCharCode(e.charCode))); processed = 1; }
2158 + }
2159 + }
2160 + }
2161 +
2162 + function ondockeydown(e) {
2163 + setSessionActivity();
2164 + if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked) {
2165 + // Check what keys we are allows to send
2166 + if (currentNode != null) {
2167 + var mesh = meshes[currentNode.meshid];
2168 + var meshrights = mesh.links[userinfo._id].rights;
2169 + var inputAllowed = ((meshrights == 0xFFFFFFFF) || (((meshrights & 8) != 0) && ((meshrights & 256) == 0)));
2170 + if (inputAllowed == false) return false;
2171 + var limitedInputAllowed = ((meshrights != 0xFFFFFFFF) && (((meshrights & 8) != 0) && ((meshrights & 256) == 0) && ((meshrights & 4096) != 0)));
2172 + if (limitedInputAllowed == true) { if ((e.altKey == true) || (e.ctrlKey == true) || ((e.keyCode < 32) && (e.keyCode != 8) && (e.keyCode != 13)) || (e.keyCode > 90)) return false; }
2173 + }
2174 + return desktop.m.handleKeyDown(e);
2175 + }
2176 + if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3) { terminal.m.TermHandleKeyDown(e); if ((e.keyCode >= 37) && (e.keyCode <= 40)) { haltEvent(e); } }
2177 + if (!xxdialogMode && xxcurrentView == 13 && e.keyCode == 116 && p13filetree != null) { haltEvent(e); return false; } // F5 Refresh on files
2178 + if (!xxdialogMode && ((xxcurrentView == 15) || (xxcurrentView == 115))) { return agentConsoleHandleKeys(e); }
2179 + if (!xxdialogMode && xxcurrentView == 4) {
2180 + if (e.keyCode === 8 && userSearchFocus == 0) { var x = Q('UserSearchInput').value; Q('UserSearchInput').value = (x.substring(0, x.length - 1)); processed = 1; }
2181 + if (e.keyCode === 27) { Q('UserSearchInput').value = ''; processed = 1; }
2182 + if (processed > 0) { if (processed == 1) { masterUpdate(5); } return haltEvent(e); }
2183 + }
2184 + if (xxdialogMode || xxcurrentView != 1 || e.ctrlKey == true || e.altKey == true || e.metaKey == true) return;
2185 + var processed = 0;
2186 + if (Q('viewselect').value < 3) {
2187 + if (e.keyCode === 8 && searchFocus == 0) { var x = Q('SearchInput').value; Q('SearchInput').value = (x.substring(0, x.length - 1)); processed = 1; }
2188 + if (e.keyCode === 27) { Q('SearchInput').value = ''; processed = 1; }
2189 + if (processed > 0) { if (processed == 1) { masterUpdate(5); } return haltEvent(e); }
2190 + }
2191 + if (Q('viewselect').value == 3) {
2192 + if (e.keyCode === 8 && mapSearchFocus == 0) { var x = Q('mapSearchLocation').value; Q('mapSearchLocation').value = (x.substring(0, x.length - 1)); processed = 1; }
2193 + if (e.keyCode === 27) { Q('mapSearchLocation').value = ''; mapCloseSearchWindow(); processed = 1; }
2194 + }
2195 + }
2196 +
2197 + function ondockeyup(e) {
2198 + setSessionActivity();
2199 + if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked) {
2200 + // Check what keys we are allows to send
2201 + if (currentNode != null) {
2202 + var mesh = meshes[currentNode.meshid];
2203 + var meshrights = mesh.links[userinfo._id].rights;
2204 + var inputAllowed = ((meshrights == 0xFFFFFFFF) || (((meshrights & 8) != 0) && ((meshrights & 256) == 0)));
2205 + if (inputAllowed == false) return false;
2206 + var limitedInputAllowed = ((meshrights != 0xFFFFFFFF) && (((meshrights & 8) != 0) && ((meshrights & 256) == 0) && ((meshrights & 4096) != 0)));
2207 + if (limitedInputAllowed == true) { if ((e.altKey == true) || (e.ctrlKey == true) || ((e.keyCode < 32) && (e.keyCode != 8) && (e.keyCode != 13)) || (e.keyCode > 90)) return false; }
2208 + }
2209 + return desktop.m.handleKeyUp(e);
2210 + }
2211 + if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3) { return terminal.m.TermHandleKeyUp(e); }
2212 + if (!xxdialogMode && xxcurrentView == 13 && e.keyCode == 116 && p13filetree != null) { p13folderup(9999); haltEvent(e); return false; } // F5 Refresh on files
2213 + if (!xxdialogMode && xxcurrentView == 4) { if ((e.keyCode === 8 && searchFocus == 0) || e.keyCode === 27) { return haltEvent(e); } }
2214 + if (xxdialogMode && e.keyCode == 27) { dialogclose(0); }
2215 + if (xxdialogMode || xxcurrentView != 0 || e.ctrlKey == true || e.altKey == true || e.metaKey == true) return;
2216 + if (Q('viewselect').value < 3) { if ((e.keyCode === 8 && searchFocus == 0) || e.keyCode === 27) { return haltEvent(e); } }
2217 + if (Q('viewselect').value == 3) { if ((e.keyCode === 8 && mapSearchFocus == 0) || e.keyCode === 27) { return haltEvent(e); } }
2218 + }
2219 +
2220 + //function ondocfocus() { }
2221 + function ondocblur() { if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked) { return desktop.m.handleReleaseKeys(); } }
2222 +
2223 + // Highlights the device being hovered
2224 + function devMouseHover(element, over) {
2225 + setSessionActivity();
2226 + var view = Q('viewselect').value;
2227 + if (view == 1) {
2228 + var e = element.children[1].children[1];
2229 + e.children[0].classList.remove('g1s');
2230 + e.children[1].classList.remove('e2s');
2231 + e.children[2].classList.remove('g2s');
2232 + if (over == 1) {
2233 + e.children[0].classList.add('g1s');
2234 + e.children[1].classList.add('e2s');
2235 + e.children[2].classList.add('g2s');
2236 + }
2237 + } else if (view == 2) {
2238 + var e = element;
2239 + e.children[2].classList.remove('g1s');
2240 + e.children[4].classList.remove('e2s');
2241 + e.children[3].classList.remove('g2s');
2242 + if (over == 1) {
2243 + e.children[2].classList.add('g1s');
2244 + e.children[4].classList.add('e2s');
2245 + e.children[3].classList.add('g2s');
2246 + }
2247 + }
2248 + }
2249 +
2250 + var deviceHeaderId = 0;
2251 + var deviceHeaderTotal = 0;
2252 + var deviceHeadersTitles = {};
2253 + var deviceHeaderCount;
2254 + var deviceHeaders = {};
2255 + var oldviewmode = 0;
2256 + function updateDevices() {
2257 + if (nodes == null) { return; }
2258 + var r = '', c = 0, current = null, count = 0, displayedMeshes = {}, view = Q('viewselect').value, groups = {}, groupCount = {};
2259 + QV('xdevices', view < 4);
2260 + QV('xdevicesmap', view == 4);
2261 + QV('devListToolbar', view < 3);
2262 + QV('kvmListToolbar', view == 3);
2263 + QV('devMapToolbar', view == 4);
2264 + QV('devListToolbarSize', view == 3);
2265 + QV('NoMeshesPanel', meshcount == 0);
2266 + //QV('devListToolbarView', (meshcount != 0) && (nodes.length > 0));
2267 + QV('devListToolbarViewIcons', (meshcount != 0) && (nodes.length > 0));
2268 + QV('devListToolbarSort', (meshcount != 0) && (nodes.length > 0) && (view < 4));
2269 + if ((meshcount == 0) || (nodes.length == 0)) { view = 1; sort = 0; }
2270 + if (view == 4) {
2271 + setTimeout( function() { if (xxmap.map != null) { xxmap.map.updateSize(); } }, 200);
2272 + // TODO
2273 + } else {
2274 + // 3 wide, list view or desktop view
2275 + deviceHeaderId = 0;
2276 + deviceHeaderCount = {};
2277 + deviceHeaderTotal = 0;
2278 + deviceHeaders = {};
2279 + deviceHeadersTitles = {};
2280 + var kvmDivs = [];
2281 +
2282 + // Perform node sort
2283 + if (sort == 0) { nodes.sort(meshSort); }
2284 + else if (sort == 1) { nodes.sort(powerSort); }
2285 + else if (sort == 2) { if (showRealNames == true) { nodes.sort(deviceHostSort); } else { nodes.sort(deviceSort); } }
2286 +
2287 + // Save the list of currently checked nodeid's
2288 + var checkedNodeids = [], elements = document.getElementsByClassName("DeviceCheckbox"), checkcount = 0;
2289 + for (var i=0;i<elements.length;i++) { if (elements[i].checked) { checkedNodeids.push(elements[i].value); } }
2290 + if ((oldviewmode < 3) && (view == 3)) { multiDesktopFilter = checkedNodeids; }
2291 + else if ((oldviewmode == 3) && (view < 3)) { checkedNodeids = multiDesktopFilter; }
2292 +
2293 + // Compute the width of the device view.
2294 + var totalDeviceViewWidth = Q('column_l').clientWidth - 60;
2295 + var deviceBoxWidth = Math.floor(totalDeviceViewWidth / 301);
2296 + deviceBoxWidth = 301 + Math.floor((totalDeviceViewWidth - (deviceBoxWidth * 301)) / deviceBoxWidth);
2297 +
2298 + if (view == 2) {
2299 + r += '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>User<th style=color:gray;width:120px>Address<th style=color:gray;width:100px>Connectivity'; //<th style=color:gray;width:100px>State';
2300 + }
2301 +
2302 + // Go thru the list of nodes and display them
2303 + for (var i in nodes) {
2304 + var node = nodes[i];
2305 + if (node.v == false) continue;
2306 + var mesh2 = meshes[node.meshid], meshlinks = mesh2.links[userinfo._id];
2307 + if (meshlinks == null) continue;
2308 + var meshrights = meshlinks.rights;
2309 + if ((view == 3) && (mesh2.mtype == 1)) continue;
2310 + if (sort == 0) {
2311 + // Mesh header
2312 + if (node.meshid != current) {
2313 + deviceHeaderSet();
2314 + var extra = '';
2315 + if (view == 2) { r += '<tr><td colspan=5>'; }
2316 + if (meshes[node.meshid].mtype == 1) { extra = '<span class=devHeaderx>, Intel&reg; AMT only</span>'; }
2317 + if ((view == 1) && (current != null)) { if (c == 2) { r += '<td><div style=width:301px></div></td>'; } if (r != '') { r += '</tr></table>'; } }
2318 + if (view == 2) { r += '<div>'; }
2319 + r += '<div class=DevSt style=width:100%;padding-top:4px><span style=float:right>';
2320 + r += '<span id=DevxHeader' + deviceHeaderId + ' class=devHeaderx></span>' + extra;
2321 + r += '</span><span id=MxMESH tabindex=0 style=cursor:pointer onclick=gotoMesh("' + node.meshid + '") onkeypress="if (event.key==\'Enter\') gotoMesh(\'' + node.meshid + '\')">' + EscapeHtml(meshes[node.meshid].name) + '</span>' + getMeshActions(mesh2, meshrights) + '</div>';
2322 + if (view == 2) { r += '</div>'; }
2323 + current = node.meshid;
2324 + displayedMeshes[current] = 1;
2325 + c = 0;
2326 + }
2327 + } else if (sort == 1) {
2328 + // Power header
2329 + var pwr = node.pwr?node.pwr:0;
2330 + if (pwr !== current) {
2331 + deviceHeaderSet();
2332 + if ((view == 1) && (current !== null)) { if (c == 2) { r += '<td><div style=width:301px></div></td>'; } if (r != '') { r += '</tr></table>'; } }
2333 + r += '<div class=DevSt style=width:100%;padding-top:4px><span id=DevxHeader' + deviceHeaderId + ' class=devHeaderx style=float:right></span><span>' + PowerStateStr2(node.pwr) + '</span></div>';
2334 + current = pwr;
2335 + c = 0;
2336 + }
2337 + } else if (sort == 2) {
2338 + // Device header
2339 + if (current == null) { current = '1'; }
2340 + }
2341 +
2342 + count++;
2343 + var title = EscapeHtml(node.name);
2344 + if (title.length == 0) { title = '<i>None</i>'; }
2345 + if ((node.rname != null) && (node.rname.length > 0)) { title += " / " + EscapeHtml(node.rname); }
2346 + var name = EscapeHtml(node.name);
2347 + if (showRealNames == true && node.rname != null) name = EscapeHtml(node.rname);
2348 + if (name.length == 0) { name = '<i>None</i>'; }
2349 +
2350 + // Node
2351 + var icon = node.icon;
2352 + if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; }
2353 + if (view == 1) {
2354 + r += '<div id=devs onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=display:inline-block;width:' + deviceBoxWidth + 'px;height:50px;padding-top:1px;padding-bottom:1px><div style=width:22px;height:50%;float:left;padding-top:12px><input class="' + node.meshid + ' DeviceCheckbox" onclick=p1updateInfo() value=devid_' + node._id + ' type=checkbox></div><div style=height:100%;cursor:pointer tabindex=0 onclick=gotoDevice(\'' + node._id + '\',null,null,event) onkeypress="if (event.key==\'Enter\') gotoDevice(\'' + node._id + '\',null,null,event)"><div class="i' + icon + '" style=width:50px;float:left></div><div style=height:100%><div class=g1></div><div class=e2><div class=e1 style=width:' + (deviceBoxWidth - 100) + 'px title="' + title + '">' + name + '</div><div>' + NodeStateStr(node) + '</div></div><div class=g2></div></div></div></div>';
2355 + } else if (view == 2) {
2356 + var states = [];
2357 + if (node.conn) {
2358 + if ((node.conn & 1) != 0) { states.push('<span title="Mesh agent is connected and ready for use.">Agent</span>'); }
2359 + if ((node.conn & 2) != 0) { states.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">CIRA</span>'); }
2360 + else if ((node.conn & 4) != 0) { states.push('<span title="Intel&reg; AMT is routable.">AMT</span>'); }
2361 + if ((node.conn & 8) != 0) { states.push('<span title="Mesh agent is reachable using another agent as relay.">Relay</span>'); }
2362 + }
2363 + r += '<tr><td><div id=devs class=bar18 tabindex=0 onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=height:18px;width:100%;font-size:medium onkeypress="if (event.key==\'Enter\') gotoDevice(\'' + node._id + '\',null,null,event)">';
2364 + r += '<div class=deviceBarCheckbox><input class="' + node.meshid + ' DeviceCheckbox" onclick=p1updateInfo() value=devid_' + node._id + ' type=checkbox></div>';
2365 + r += '<div class=deviceBarIcon onclick=gotoDevice(\'' + node._id + '\',null,null,event)><div class=\"j' + icon + '\" style=width:16px;margin-top:1px;margin-left:2px;height:16px></div></div>';
2366 + r += '<div class=g1 style=height:18px;float:left></div><div class=g2 style=height:18px;float:right></div>';
2367 + r += '<div style=cursor:pointer;font-size:14px title="' + title + '" onclick=gotoDevice(\'' + node._id + '\',null,null,event)><span style=width:300px>' + name + '</span></div></div></td>';
2368 + r += '<td style=text-align:center>' + getUserShortStr(node);
2369 + r += '<td style=text-align:center>' + (node.ip != null ? node.ip : '');
2370 + r += '<td style=text-align:center>' + states.join('&nbsp;+&nbsp;');
2371 + //r += '<td style=text-align:center>' + (node.pwr != null ? powerStateStrings[node.pwr] : '');
2372 + r += '</tr>';
2373 + } 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.
2374 + if ((multiDesktopFilter.length == 0) || (multiDesktopFilter.indexOf('devid_' + node._id) >= 0)) {
2375 + r += '<div id=devs style=display:inline-block;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)">';
2376 + //r += '<input class="' + node.meshid + ' DeviceCheckbox" onclick=p1updateInfo() value=devid_' + node._id + ' type=checkbox style=float:left>';
2377 + r += '<div class="j' + icon + '" style=width:16px;float:left></div>&nbsp;' + name + '</div>';
2378 + 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>';
2379 + r += '</div>';
2380 + kvmDivs.push(node._id);
2381 + }
2382 + }
2383 +
2384 + // If we are displaying devices by group, put the device in the right group.
2385 + if ((sort == 3) && (r != '')) {
2386 + if (node.tags) {
2387 + for (var j in node.tags) {
2388 + var tag = node.tags[j];
2389 + if (groups[tag] == null) { groups[tag] = r; groupCount[tag] = 1; } else { groups[tag] += r; groupCount[tag] += 1; }
2390 + if (view == 3) break;
2391 + }
2392 + }
2393 + r = '';
2394 + }
2395 +
2396 + deviceHeaderTotal++;
2397 + if (typeof deviceHeaderCount[node.state] == 'undefined') { deviceHeaderCount[node.state] = 1; } else { deviceHeaderCount[node.state]++; }
2398 + }
2399 +
2400 + // If displaying devices by groups, sort the group names and display the devices.
2401 + if (sort == 3) {
2402 + var groupNames = [];
2403 + for (var i in groups) { groupNames.push(i); }
2404 + groupNames.sort(function (a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); });
2405 + for (var j in groupNames) {
2406 + var i = groupNames[j]; r += '<div class=DevSt style=width:100%;padding-top:4px><span class=devHeaderx style=float:right>' + groupCount[i] + ' node' + ((groupCount[i] > 1) ? 's' : '') + '</span><span>' + i + '</span></div>' + groups[i];
2407 + }
2408 + }
2409 +
2410 + // If there is nothing to display, explain the problem
2411 + if ((r == '') && (meshcount > 0) && (Q('SearchInput').value != '')) {
2412 + if (sort == 3) {
2413 + r = '<div style="margin:30px">No devices are included in any groups, click on a device\'s \"Groups\" to add to a group.</div>';
2414 + } else {
2415 + r = '<div style="margin:30px">No devices matching this search.</div>';
2416 + }
2417 + }
2418 +
2419 + if ((view == 1) && (c == 2)) r += '<td><div style=width:301px></div></td>'; // Adds device padding
2420 +
2421 + // Display all empty device groups, we need to do this because users can add devices to these at any time.
2422 + if ((sort == 0) && (Q('SearchInput').value == '') && (view < 3)) {
2423 + for (var i in meshes) {
2424 + var mesh = meshes[i], meshlink = mesh.links[userinfo._id];
2425 + if (meshlink != null) {
2426 + var meshrights = meshlink.rights;
2427 + if (displayedMeshes[mesh._id] == null) {
2428 + if ((current != '') && (r != '')) { r += '</tr></table>'; }
2429 + r += '<table style=width:100%;padding-top:4px cellpadding=0 cellspacing=0><tr><td colspan=3 class=DevSt><span id=MxMESH style=cursor:pointer onclick=gotoMesh("' + mesh._id + '")>' + EscapeHtml(mesh.name) + '</span><span>';
2430 + r += getMeshActions(mesh, meshrights);
2431 + r += '</span></td></tr><tr>';
2432 + if (mesh.mtype == 1) {
2433 + r += '<td><div style=padding:10px><i>No Intel&reg; AMT devices in this mesh';
2434 + if ((meshrights & 4) != 0) { r += ', <a href=# style=cursor:pointer onclick=\'return addDeviceToMesh(\"' + mesh._id + '\"\')>add one</a>'; }
2435 + }
2436 + if (mesh.mtype == 2) {
2437 + r += '<td><div style=padding:10px><i>No devices in this mesh';
2438 + if ((meshrights & 4) != 0) { r += ', <a href=# style=cursor:pointer onclick=\'return addAgentToMesh(\"' + mesh._id + '\")\'>add one</a>'; }
2439 + }
2440 + r += '.</i></div></td>';
2441 + current = mesh._id;
2442 + count++;
2443 + }
2444 + }
2445 + }
2446 + }
2447 + r += '</tr></table><div style=height:1px></div>'; // This height of 1 div fixes a problem in Linux firefox browsers
2448 +
2449 + // Add a "Add Device Group" option
2450 + r += '<div style=border-top-style:solid;border-top-width:1px;border-top-color:#DDDDDD;cursor:pointer;font-size:10px>';
2451 + if ((view < 3) && (sort == 0) && (meshcount > 0) && ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 64) == 0))) {
2452 + r += '<a href=# onclick="return account_createMesh()" title="Create a new group of devices." style=cursor:pointer>Add Device Group</a>&nbsp';
2453 + }
2454 + if ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 128) == 0)) {
2455 + r += '<a href=# onclick=\'return p10showMeshCmdDialog(0)\' style=cursor:pointer title="Download MeshCmd, a command line tool that performs many functions.">MeshCmd</a>&nbsp';
2456 + if (navigator.platform.toLowerCase() == 'win32') { r += '<a href=# onclick=\'return p10showMeshRouterDialog()\' style=cursor:pointer title="Download MeshCentral Router, a TCP port mapping tool.">Router</a>&nbsp'; }
2457 + }
2458 + r += '</div><br/>';
2459 +
2460 + QH('xdevices', r);
2461 + deviceHeaderSet();
2462 +
2463 + // Re-check nodeid's
2464 + var elements = document.getElementsByClassName("DeviceCheckbox"), checkcount = 0;
2465 + for (var i=0;i<elements.length;i++) { elements[i].checked = (checkedNodeids.indexOf(elements[i].value) >= 0); }
2466 +
2467 + for (var i in deviceHeaders) { QH(i, deviceHeaders[i]); }
2468 + for (var i in deviceHeadersTitles) { Q(i).title = deviceHeadersTitles[i]; }
2469 + p1updateInfo();
2470 +
2471 + // Take care of KVM surfaces in desktop view mode
2472 + if (view == 3) {
2473 + // Figure out and adjust the size to fill the width of the div
2474 + var vsize = [{ x: 180, y: 101 }, { x: 302, y: 169 }, { x: 454, y: 255 }][Q('sizeselect').selectedIndex];
2475 + //var realw = vsize.x + 2, tw = Q('xdevices').clientWidth - 30, xw = Math.floor(tw / realw);
2476 + var realw = vsize.x + 2, tw = totalDeviceViewWidth - 5, xw = Math.floor(tw / realw);
2477 + xw = realw + Math.floor((tw - (xw * realw)) / xw);
2478 + vsize.y = vsize.y * (xw / vsize.x);
2479 + vsize.x = xw;
2480 +
2481 + for (var i in multiDesktop) { multiDesktop[i].xxdelete = true; }
2482 + for (var i in kvmDivs) {
2483 + var id = kvmDivs[i], shortid = id.split('/')[2], desk = multiDesktop[id];
2484 + if (desk != null) {
2485 + // This device already has a canvas, use it.
2486 + desk.m.CanvasId.setAttribute('style', 'background-color:black;width:' + vsize.x + 'px;height:' + vsize.y + 'px');
2487 + Q('xkvmid_' + shortid).appendChild(desk.m.CanvasId);
2488 + delete desk.xxdelete;
2489 + QH('skvmid_' + shortid, ['Disconnected', 'Connecting...', 'Setup...', '', ''][((desk.m.State == null)?desk.m.state:desk.m.State)]);
2490 + } else {
2491 + var node = getNodeFromId(id);
2492 + if ((desktopNode == node) && (desktop != null)) { // Check if the main desktop is this device, if it is, use that.
2493 + // This device already has a canvas, use it.
2494 + var c = desktop.m.CanvasId;
2495 + c.setAttribute('id', 'kvmid_' + shortid);
2496 + c.setAttribute('style', 'background-color:black;width:' + vsize.x + 'px;height:' + vsize.y + 'px');
2497 + c.setAttribute('onclick', 'toggleKvmDevice(\'' + id + '\')');
2498 + c.removeAttribute('onmousedown');
2499 + c.removeAttribute('onmouseup');
2500 + c.removeAttribute('onmousemove');
2501 + Q('xkvmid_' + shortid).appendChild(c);
2502 + QH('skvmid_' + shortid, ['Disconnected', 'Connecting...', 'Setup...', '', ''][((desktop.m.State == null)?desktop.m.state:desktop.m.State)]);
2503 + if (desktop.m.SendCompressionLevel) { desktop.m.SendCompressionLevel(1, multidesktopsettings.quality, multidesktopsettings.scaling, multidesktopsettings.framerate); }
2504 + desktop.shortid = shortid;
2505 + desktop.onStateChanged = onMultiDesktopStateChange;
2506 + multiDesktop[id] = desktop;
2507 + desktop = desktopNode = currentNode = null;
2508 + // Setup a replacement desktop
2509 + QH('DeskParent', '<canvas id="Desk" oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>');
2510 + } else {
2511 + // This is a new device, create a canvas for it.
2512 + var c = document.createElement('canvas');
2513 + c.setAttribute('id', 'kvmid_' + shortid);
2514 + c.setAttribute('width', 640);
2515 + c.setAttribute('height', 480);
2516 + c.setAttribute('oncontextmenu', 'return false');
2517 + c.setAttribute('style', 'background-color:black;width:' + vsize.x + 'px;height:' + vsize.y + 'px');
2518 + c.setAttribute('onclick', 'toggleKvmDevice(\'' + id + '\')');
2519 + try { Q('xkvmid_' + shortid).appendChild(c); } catch (ex) {}
2520 + // Check if we need to auto-connect
2521 + if (Q('autoConnectDesktopCheckbox').checked == true) { setTimeout(function() { connectMultiDesktop(node, 1); }, 100); }
2522 + }
2523 + }
2524 + }
2525 + for (var i in multiDesktop) {
2526 + // If a device is no longer viewed, disconnect it.
2527 + if (multiDesktop[i].xxdelete == true) { multiDesktop[i].Stop(); delete multiDesktop[i]; }
2528 + else if (debugmode && multiDesktop[i].m && multiDesktop[i].m.onScreenSizeChange) {
2529 + mdeskAdjust(multiDesktop[i].m, multiDesktop[i].m.ScreenWidth, multiDesktop[i].m.ScreenHeight, multiDesktop[i].m.CanvasId); // Adjust screen size change
2530 + }
2531 + }
2532 + deskAdjust();
2533 + } else {
2534 + disconnectAllKvmFunction();
2535 + Q('autoConnectDesktopCheckbox').checked = false;
2536 + }
2537 + }
2538 + oldviewmode = view;
2539 + }
2540 +
2541 + function toggleKvmDevice(nodeid) {
2542 + var node = getNodeFromId(nodeid), mesh = meshes[node.meshid], meshrights = mesh.links[userinfo._id].rights;
2543 + if ((meshrights & 8) || (meshrights & 256)) { // Requires remote control rights or desktop view only rights
2544 + //var conn = 0;
2545 + //if ((node.conn & 1) != 0) { conn = 1; } else if ((node.conn & 6) != 0) { conn = 2; } // Check what type of connect we can do (Agent vs AMT)
2546 + if (node.conn & 1) { connectMultiDesktop(node, 1); }
2547 + }
2548 + }
2549 +
2550 + function getUserShortStr(node) {
2551 + if (node == null || node.users == null || node.users.length == 0) return '';
2552 + if (node.users.length > 1) { return '<span title="' + EscapeHtml(node.users.join(', ')) + '">' + node.users.length + '&nbsp;users</span>'; }
2553 + var u = node.users[0], su = u, i = u.indexOf('\\');
2554 + if (i > 0) { su = u.substring(i + 1); }
2555 + su = EscapeHtml(su);
2556 + if (su.length > 15) { su = su.substring(0, 14) + '&#8230;'; }
2557 + return '<span title="' + EscapeHtml(u) + '">' + su + '</span>';
2558 + }
2559 +
2560 + function autoConnectDesktops() { if (Q('autoConnectDesktopCheckbox').checked == true) { connectAllKvmFunction(); } }
2561 + function connectAllKvmFunction() { for (var i in nodes) { if (multiDesktop[nodes[i]._id] == null) { toggleKvmDevice(nodes[i]._id); } } }
2562 + function disconnectAllKvmFunction() { for (var nodeid in multiDesktop) { multiDesktop[nodeid].Stop(); } multiDesktop = {}; }
2563 + function onMultiDesktopStateChange(desk, state) { try { QH('skvmid_' + desk.shortid, ['Disconnected', 'Connecting...', 'Setup...', '', ''][state]); } catch (ex) {} }
2564 +
2565 + function showMultiDesktopSettings() {
2566 + QV('d7amtkvm', false);
2567 + QV('d7meshkvm', true);
2568 + d7bitmapquality.value = multidesktopsettings.quality;
2569 + d7bitmapscaling.value = multidesktopsettings.scaling;
2570 + if (multidesktopsettings.framerate) { d7framelimiter.value = multidesktopsettings.framerate; } else { d7framelimiter.value = 1000; }
2571 + setDialogMode(7, "Remote Desktop Settings", 3, showMultiDesktopSettingsChanged);
2572 + }
2573 +
2574 + function showMultiDesktopSettingsChanged() {
2575 + multidesktopsettings.quality = d7bitmapquality.value;
2576 + multidesktopsettings.scaling = d7bitmapscaling.value;
2577 + multidesktopsettings.framerate = d7framelimiter.value;
2578 + localStorage.setItem('multidesktopsettings', JSON.stringify(multidesktopsettings));
2579 + // Make changes to all current connections
2580 + for (var i in multiDesktop) { multiDesktop[i].m.SendCompressionLevel(1, multidesktopsettings.quality, multidesktopsettings.scaling, multidesktopsettings.framerate); }
2581 + }
2582 +
2583 + function connectMultiDesktop(node, contype) {
2584 + var nodeid = node._id, shortid = nodeid.split('/')[2];
2585 + var desk = multiDesktop[nodeid];
2586 + if (desk == null) {
2587 + if (Q('kvmid_' + shortid) == null) return; // Check if this device is being displayed, if not, exit now.
2588 + if (contype == 2) {
2589 + // Setup the Intel AMT remote desktop
2590 + if ((node.intelamt.user == null) || (node.intelamt.user == '')) { return; }
2591 + desk = CreateAmtRedirect(CreateAmtRemoteDesktop('kvmid_' + shortid), authCookie);
2592 + desk.shortid = shortid;
2593 + //desk.debugmode = debugmode;
2594 + desk.onStateChanged = onMultiDesktopStateChange;
2595 + desk.m.bpp = 1;
2596 + desk.m.useZRLE = true;
2597 + desk.m.showmouse = true;
2598 + 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.
2599 + //desk.m.onScreenSizeChange = deskAdjust;
2600 + if (debugmode > 0) { desk.m.onScreenSizeChange = mdeskAdjust; } // Multi-Desktop Adjust
2601 + desk.Start(nodeid, 16994, '*', '*', 0);
2602 + desk.contype = 2;
2603 + multiDesktop[nodeid] = desk;
2604 + } else if (contype == 1) {
2605 + // Setup the Mesh Agent remote desktop
2606 + desk = CreateAgentRedirect(meshserver, CreateAgentRemoteDesktop('kvmid_' + shortid), serverPublicNamePort, authCookie, domainUrl);
2607 + desk.shortid = shortid;
2608 + desk.attemptWebRTC = attemptWebRTC;
2609 + desk.onStateChanged = onMultiDesktopStateChange;
2610 + //desk.onConsoleMessageChange = function () { console.log('CONSOLEMSG:', desk.consoleMessage); }
2611 + desk.m.CompressionLevel = multidesktopsettings.quality;
2612 + desk.m.ScalingLevel = multidesktopsettings.scaling;
2613 + desk.m.FrameRateTimer = multidesktopsettings.framerate;
2614 + //desk.m.onDisplayinfo = deskDisplayInfo;
2615 + //desk.m.onScreenSizeChange = deskAdjust;
2616 + if (debugmode > 0) { desk.m.onScreenSizeChange = mdeskAdjust; } // Multi-Desktop Adjust
2617 + desk.Start(nodeid);
2618 + desk.contype = 1;
2619 + multiDesktop[nodeid] = desk;
2620 + }
2621 + } else {
2622 + // Disconnect and clean up the remote desktop
2623 + desk.Stop();
2624 + delete multiDesktop[nodeid];
2625 + }
2626 + }
2627 +
2628 + function getMeshActions(mesh, meshrights) {
2629 + if ((meshrights & 4) == 0) return '';
2630 + var r = '';
2631 + if ((features & 1024) == 0) { // If CIRA is allowed
2632 + r += ' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer that is located on the internet." onclick=\'return addCiraDeviceToMesh(\"' + mesh._id + '\")\'>Add CIRA</a>';
2633 + }
2634 + if (mesh.mtype == 1) {
2635 + if ((features & 1) == 0) { // If not WAN-Only
2636 + r += ' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer that is located on the local network." onclick=\'return addDeviceToMesh(\"' + mesh._id + '\")\'>Add Local</a>';
2637 + r += ' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer by scanning the local network." onclick=\'return addAmtScanToMesh(\"' + mesh._id + '\")\'>Scan Network</a>';
2638 + }
2639 + if (mesh.amt && (mesh.amt.type == 2)) { // CCM activation
2640 + r += ' <a href=# style=cursor:pointer;font-size:10px title="Perform Intel AMT client control mode (CCM) activation." onclick=\'return showCcmActivation(\"' + mesh._id + '\")\'>Activation</a>';
2641 + } else if (mesh.amt && (mesh.amt.type == 3) && ((features & 0x00100000) != 0)) { // ACM activation
2642 + r += ' <a href=# style=cursor:pointer;font-size:10px title="Perform Intel AMT admin control mode (ACM) activation." onclick=\'return showAcmActivation(\"' + mesh._id + '\")\'>Activation</a>';
2643 + }
2644 + }
2645 + if (mesh.mtype == 2) {
2646 + r += ' <a href=# style=cursor:pointer;font-size:10px title="Add a new computer to this mesh by installing the mesh agent." onclick=\'return addAgentToMesh(\"' + mesh._id + '\")\'>Add Agent</a>';
2647 + r += ' <a href=# style=cursor:pointer;font-size:10px title="Invite someone to install the mesh agent on this mesh." onclick=\'return inviteAgentToMesh(\"' + mesh._id + '\")\'>Invite</a>';
2648 + }
2649 + return r;
2650 + }
2651 +
2652 + function addDeviceToMesh(meshid) {
2653 + if (xxdialogMode) return false;
2654 + var mesh = meshes[meshid];
2655 + var x = "Add a new Intel&reg; AMT device to device group \"" + EscapeHtml(mesh.name) + "\".<br /><br />";
2656 + x += addHtmlValue('Device Name', '<input id=dp1devicename style=width:230px maxlength=32 autocomplete=off onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />');
2657 + x += addHtmlValue('Hostname', '<input id=dp1hostname style=width:230px maxlength=32 autocomplete=off placeholder="Same as device name" onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />');
2658 + x += addHtmlValue('Username', '<input id=dp1username style=width:230px maxlength=32 autocomplete=off placeholder="admin" onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />');
2659 + x += addHtmlValue('Password', '<input id=dp1password type=password style=width:230px autocomplete=off maxlength=32 onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />');
2660 + x += addHtmlValue('Security', '<select id=dp1tls style=width:236px><option value=0>No TLS security</option><option value=1>TLS security required</option></select>');
2661 + setDialogMode(2, "Add Intel&reg; AMT device", 3, addDeviceToMeshEx, x, meshid);
2662 + validateDeviceToMesh();
2663 + Q('dp1devicename').focus();
2664 + return false;
2665 + }
2666 +
2667 + // Intel AMT CCM Activation
2668 + function showCcmActivation(meshid) {
2669 + if (xxdialogMode) return false;
2670 + var servername = serverinfo.name, mesh = meshes[meshid];
2671 + if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name.
2672 + var url, domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1);
2673 + if (serverinfo.https == true) {
2674 + var portStr = (serverinfo.port == 443) ? '' : (":" + serverinfo.port);
2675 + url = "wss://" + servername + portStr + domainUrl;
2676 + } else {
2677 + var portStr = (serverinfo.port == 80) ? '' : (":" + serverinfo.port);
2678 + url = "ws://" + servername + portStr + domainUrl;
2679 + }
2680 + var x = "Perform Intel AMT client control mode (CCM) activation to group \"" + EscapeHtml(mesh.name) + "\" by downloading the MeshCMD tool and running it like this:<br /><br />";
2681 + x += '<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtccm --url ' + url + 'amtactivate?id=' + meshid.split('/')[2] + ' --serverhttpshash ' + serverinfo.tlshash + '</textarea>';
2682 + setDialogMode(2, "Intel&reg; AMT activation", 9, null, x);
2683 + Q('idx_dlgOkButton').focus();
2684 + return false;
2685 + }
2686 +
2687 + // Intel AMT ACM Activation
2688 + function showAcmActivation(meshid) {
2689 + if (xxdialogMode) return false;
2690 + var servername = serverinfo.name, mesh = meshes[meshid];
2691 + if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name.
2692 + var url, domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1);
2693 + if (serverinfo.https == true) {
2694 + var portStr = (serverinfo.port == 443) ? '' : (":" + serverinfo.port);
2695 + url = "wss://" + servername + portStr + domainUrl;
2696 + } else {
2697 + var portStr = (serverinfo.port == 80) ? '' : (":" + serverinfo.port);
2698 + url = "ws://" + servername + portStr + domainUrl;
2699 + }
2700 + var x = "Perform Intel AMT admin control mode (ACM) activation to group \"" + EscapeHtml(mesh.name) + "\" by downloading the MeshCMD tool and running it like this:<br /><br />";
2701 + x += '<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtacm --url ' + url + 'amtactivate?id=' + meshid.split('/')[2] + ' --serverhttpshash ' + serverinfo.tlshash + '</textarea>';
2702 + if (serverinfo.amtAcmFqdn != null) {
2703 + x += '<div style=margin-top:8px>Intel AMT will need to be set with a Trusted FQDN in MEBx or have a wired LAN on the network: <b>' + serverinfo.amtAcmFqdn.join(', ') + '</b></div>';
2704 + }
2705 + setDialogMode(2, "Intel&reg; AMT activation", 9, null, x);
2706 + Q('idx_dlgOkButton').focus();
2707 + return false;
2708 + }
2709 +
2710 + // Display the Intel AMT scanning dialog box
2711 + function addAmtScanToMesh(meshid) {
2712 + if (xxdialogMode) return false;
2713 + var x = "Enter a range of IP addresses to scan for Intel AMT devices.<br /><br />";
2714 + x += addHtmlValue('IP Range', '<input id=dp1range style=width:184px value="192.168.1.0/24" onkeyup=addAmtScanToMeshKeyUp(event) /><input id=dp1rangebutton type=button value=Scan onclick=addAmtScanToMeshButton()></input>');
2715 + x += '<div id=dp1results style="width:100%;height:200px;background-color:white;border:1px gray solid;overflow-y:scroll"></div>';
2716 + setDialogMode(2, "Scan for Intel&reg; AMT devices", 3, addAmtScanToMeshEx, x, meshid);
2717 + QE('idx_dlgOkButton', false);
2718 + QH('dp1results', '<div style=width:100%;text-align:center;margin-top:12px;color:gray;line-height:1.5>Sample IP range values<br />192.168.0.100<br />192.168.1.0/24<br />192.167.0.1-192.168.0.100</div>');
2719 + focusTextBox('dp1range');
2720 + return false;
2721 + }
2722 +
2723 + function addAmtScanToMeshKeyUp(e) {
2724 + if (e.keyCode == 13) { haltEvent(e); addAmtScanToMeshButton(); }
2725 + }
2726 +
2727 + // Called when OK is pressed on the Intel AMT scanning box
2728 + function addAmtScanToMeshEx(button, meshid) {
2729 + var elements = document.getElementsByClassName("DevScanCheckbox"), checkcount = 0;
2730 + for (var i=0;i<elements.length;i++) {
2731 + if (elements[i].checked) {
2732 + var ipaddr = elements[i].getAttribute('tag');
2733 + var amtinfo = amtScanResults[ipaddr];
2734 + meshserver.send({ action: 'addamtdevice', meshid: meshid, devicename: ipaddr, hostname: amtinfo.hostname, amtusername: '', amtpassword: '', amttls: amtinfo.tls });
2735 + }
2736 + }
2737 + }
2738 +
2739 + // If the user presses the "Scan" button on the Intel AMT scanning dialog box, start a scan.
2740 + function addAmtScanToMeshButton() {
2741 + QE('dp1range', false);
2742 + QE('dp1rangebutton', false);
2743 + QH('dp1results', '<div style=width:100%;text-align:center;margin-top:12px>Scanning...</div>');
2744 + meshserver.send({ action: 'scanamtdevice', range: Q('dp1range').value });
2745 + }
2746 +
2747 + // Called when a scanned computer is checked or unchecked.
2748 + function addAmtScanToMeshCheckbox() {
2749 + var elements = document.getElementsByClassName("DevScanCheckbox"), checkcount = 0;
2750 + for (var i=0;i<elements.length;i++) { if (elements[i].checked) checkcount++; }
2751 + QE('idx_dlgOkButton', checkcount > 0);
2752 + }
2753 +
2754 + function addCiraDeviceToMesh(meshid) {
2755 + if (xxdialogMode) return false;
2756 + var mesh = meshes[meshid];
2757 +
2758 + // Replace non alphabetic characters (@ and $) with 'X' because MPS username cannot accept it.
2759 + var meshidx = meshid.split('/')[2].replace(/\@/g, 'X').replace(/\$/g, 'X');
2760 +
2761 + var y = '<select id=dlgAddCiraSel onclick=dlgAddCiraSelClick() style=width:230px><option value=0>MeshCommander Script</option><option value=1>Manual Username/Password</option>';
2762 + if ((features & 16) == 0) { y += '<option value=2>Manual Certificate</option></select>'; } // Only display this option if Intel AMT CIRA with Mutual-Auth is allowed.
2763 +
2764 + var x = '';
2765 + x += addHtmlValue('Setup Method', y);
2766 + x += '<hr>';
2767 +
2768 + // Setup CIRA using a MeshCommander script (Pretty Simple)
2769 + x += "<div id=dlgAddCira0>To add a new Intel&reg; AMT device to device group \"" + EscapeHtml(mesh.name) + "\" with CIRA, download the following script files and use <a href='http://meshcommander.com' rel='noreferrer noopener' target='_blank'>MeshCommander</a> to run the script to configure computers.<br /><br />";
2770 + x += addHtmlValue('Setup CIRA', '<a href="mescript.ashx?type=1&meshid=' + meshidx.substring(0, 16) + '" download>cira_setup.mescript</a>');
2771 + x += addHtmlValue('Cleanup CIRA', '<a href="mescript.ashx?type=2" download>cira_clean.mescript</a>');
2772 + x += "</div>";
2773 +
2774 + // Setup CIRA with user/pass authentication (Somewhat difficult)
2775 + x += "<div id=dlgAddCira1 style=display:none>To add a new Intel&reg; AMT device to device group \"" + EscapeHtml(mesh.name) + "\" with CIRA, load the following certificate as trusted root within Intel AMT";
2776 + if (serverinfo.mpspass) { x += " and authenticate to the server using this username and password.<br /><br />"; } else { x += " and authenticate to the server using this username and any password.<br /><br />"; }
2777 + x += addHtmlValue('Root Certificate', '<a href="MeshServerRootCert.cer" download>Root Certificate File</a>');
2778 + x += addHtmlValue('Username', '<input style=width:230px readonly value="' + meshidx.substring(0, 16) + '" />');
2779 + if (serverinfo.mpspass) { x += addHtmlValue('Password', '<input style=width:230px readonly value="' + EscapeHtml(serverinfo.mpspass) + '" />'); }
2780 + if (serverinfo != null) { x += addHtmlValue('MPS Server', '<input style=width:230px readonly value="' + EscapeHtml(serverinfo.mpsname) + ':' + serverinfo.mpsport + '" />'); }
2781 + x += "</div>";
2782 +
2783 + // Setup CIRA with certificate authentication (Really difficult, only if TLS offload is not used)
2784 + if ((features & 16) == 0) {
2785 + x += "<div id=dlgAddCira2 style=display:none>To add a new Intel&reg; AMT device to device group \"" + EscapeHtml(mesh.name) + "\" with CIRA, load the following certificate as trusted root within Intel AMT, authenticate using a client certificate with the following common name and connect to the following server.<br /><br />";
2786 + x += addHtmlValue('Root Certificate', '<a href="MeshServerRootCert.cer" download>Root Certificate File</a>');
2787 + x += addHtmlValue('Organization', '<input style=width:230px readonly value="' + meshidx + '" />');
2788 + if (serverinfo != null) { x += addHtmlValue('MPS Server', '<input style=width:230px readonly value="' + EscapeHtml(serverinfo.mpsname) + ':' + serverinfo.mpsport + '" />'); }
2789 + x += "</div>";
2790 + }
2791 +
2792 + setDialogMode(2, "Add Intel&reg; AMT CIRA device", 2, null, x, 'fileDownload');
2793 + Q('dlgAddCiraSel').focus();
2794 + return false;
2795 + }
2796 +
2797 + function dlgAddCiraSelClick() {
2798 + var val = Q('dlgAddCiraSel').value;
2799 + QV('dlgAddCira0', val == 0);
2800 + QV('dlgAddCira1', val == 1);
2801 + QV('dlgAddCira2', val == 2);
2802 + }
2803 +
2804 + // Return true is the input string looks like an email address
2805 + function checkEmail(str) {
2806 + var x = str.split('@');
2807 + var ok = ((x.length == 2) && (x[0].length > 0) && (x[1].split('.').length > 1) && (x[1].length > 2));
2808 + if (ok == true) { var y = x[1].split('.'); for (var i in y) { if (y[i].length == 0) { ok = false; } } }
2809 + return ok;
2810 + }
2811 +
2812 + function inviteAgentToMesh(meshid) {
2813 + if (xxdialogMode) return false;
2814 + var x = '', mesh = meshes[meshid];
2815 + if (features & 64) {
2816 + x += addHtmlValue('Invitation Type', '<select id=d2InviteType onchange=d2ChangedInviteType() style=width:236px><option value=0>Link invitation</option><option value=1>Email invitation</option></select>') + "<hr />";
2817 + x += "<div id=emailInviteDiv style=display:none>Invite someone to install the mesh agent. An email with be sent with the link to the mesh agent installation for the \"" + EscapeHtml(mesh.name) + "\" device group.<br /><br />";
2818 + x += addHtmlValue('Name (optional)', '<input id=agentInviteName value="" style=width:230px maxlength=64 />');
2819 + x += addHtmlValue('Email', '<input id=agentInviteEmail style=width:230px placeholder="example@email.com" onkeyup=validateAgentInvite()></input>');
2820 + x += addHtmlValue('Operating System', '<select id=agentInviteNameOs onchange=d2ChangedInviteType() style=width:236px><option value=4>Send installation link</option><option value=0 selected>Any supported</option><option value=1>Windows only</option><option value=3>Apple MacOS only</option><option value=2>Linux only</option></select>');
2821 + x += '<div id=d2agentexpirediv>';
2822 + x += addHtmlValue('Link Expiration', '<select id=agentInviteExpire style=width:236px><option value=1>1 hour</option><option value=8>8 hours</option><option value=24>1 day</option><option value=168>1 week</option><option value=5040>1 month</option><option value=0>Unlimited</option></select>');
2823 + x += '</div>';
2824 + x += addHtmlValue('Installation Type', '<select id=agentInviteType style=width:236px><option value=0>Background and interactive</option><option value=2>Background only</option><option value=1>Interactive only</option></select>');
2825 + x += addHtmlValue('Message<br />(optional)', '<textarea id=agentInviteMessage value="" style=width:230px;height:100px;resize:none maxlength=1024 /></textarea>');
2826 + x += '</div>';
2827 + }
2828 + x += '<div id=urlInviteDiv>Invite someone to install the mesh agent by sharing an invitation link. This link points the user to installation instructions for the \"' + EscapeHtml(mesh.name) + '\" device group. The link is public and no account for this server is needed.<br /><br />';
2829 + x += addHtmlValue('Link Expiration', '<select id=d2inviteExpire style=width:236px onchange=d2RequestInvitationLink()><option value=1>1 hour</option><option value=8>8 hours</option><option value=24>1 day</option><option value=168>1 week</option><option value=5040>1 month</option><option value=0>Unlimited</option></select>');
2830 + x += '<div id=agentInvitationLinkDiv style="text-align:center;font-size:large;margin:16px;display:none"><a href=# id=agentInvitationLink target="_blank" style=cursor:pointer></a> <img src=images/link4.png height=10 width=10 title="Copy link to clipboard" style=cursor:pointer onclick=d2CopyInviteToClip()></div></div>';
2831 + setDialogMode(2, "Invite", 3, performAgentInvite, x, meshid);
2832 + if (features & 64) { Q('d2InviteType').focus(); d2ChangedInviteType(); } else { Q('d2inviteExpire').focus(); validateAgentInvite(); }
2833 + d2RequestInvitationLink();
2834 + return false;
2835 + }
2836 +
2837 + function d2RequestInvitationLink() {
2838 + meshserver.send({ action: 'createInviteLink', meshid: xxdialogTag, expire: parseInt(Q('d2inviteExpire').value), flags: 0 });
2839 + }
2840 +
2841 + function d2ChangedInviteType() {
2842 + QV('urlInviteDiv', Q('d2InviteType').value == 0);
2843 + QV('d2agentexpirediv', Q('agentInviteNameOs').value == 4);
2844 + QV('emailInviteDiv', Q('d2InviteType').value == 1);
2845 + validateAgentInvite();
2846 + }
2847 +
2848 + function d2CopyInviteToClip() { copyTextToClip(Q('agentInvitationLink').href); }
2849 +
2850 + function validateAgentInvite() {
2851 + if ((features & 64) && (Q('d2InviteType').value == 1)) {
2852 + QE('idx_dlgOkButton', checkEmail(Q('agentInviteEmail').value));
2853 + QV('idx_dlgCancelButton', true);
2854 + } else {
2855 + QE('idx_dlgOkButton', true);
2856 + QV('idx_dlgCancelButton', false);
2857 + }
2858 + }
2859 +
2860 + function performAgentInvite(button, meshid) {
2861 + if ((features & 64) && (Q('d2InviteType').value == 1)) {
2862 + meshserver.send({ action: 'inviteAgent', meshid: meshid, email: Q('agentInviteEmail').value, name: Q('agentInviteName').value, os: Q('agentInviteNameOs').value, flags: Q('agentInviteType').value, msg: Q('agentInviteMessage').value, expire: parseInt(Q('agentInviteExpire').value) });
2863 + }
2864 + }
2865 +
2866 + function addAgentToMesh(meshid) {
2867 + if (xxdialogMode) return false;
2868 + var mesh = meshes[meshid], x = '', installType = 0;
2869 + x += addHtmlValue('Operating System', '<select id=aginsSelect onchange=addAgentToMeshClick() style=width:236px><option value=0>Windows</option><option value=1>Linux / BSD</option><option value=2>Apple MacOS</option><option value=3>Windows (UnInstall)</option><option value=4>Linux / BSD (UnInstall)</option></select>');
2870 + x += '<div id=aginsTypeDiv>';
2871 + x += addHtmlValue('Installation Type', '<select id=aginsType onchange=addAgentToMeshClick() style=width:236px><option value=0>Background & interactive</option><option value=2>Background only</option><option value=1>Interactive only</option></select>');
2872 + x += '</div><hr>';
2873 +
2874 + // \/:*?"<>|
2875 + var meshfilename = mesh.name
2876 + meshfilename = meshfilename.split('\\').join('').split('/').join('').split(':').join('').split('*').join('').split('?').join('').split('"').join('').split('<').join('').split('>').join('').split('|').join('').split(' ').join('').split('\'').join('');
2877 +
2878 + // Windows agent install
2879 + //x += "<div id=agins_windows>To add a new computer to device group \"" + EscapeHtml(mesh.name) + "\", download the mesh agent and configuration file and install the agent on the computer to manage.<br /><br />";
2880 + x += "<div id=agins_windows>To add a new computer to device group \"" + EscapeHtml(mesh.name) + "\", download the mesh agent and install it the computer to manage. This agent has server and device group information embedded within it.<br /><br />";
2881 + x += addHtmlValue('Mesh Agent', '<a id=aginsw32lnk href="meshagents?id=3&meshid=' + meshid.split('/')[2] + '&installflags=0" download onclick="setDialogMode(0)" title="32bit version of the MeshAgent">Windows (.exe)</a> <img src=images/link4.png height=10 width=10 title="Copy Windows 32bit agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshagents?id=3&meshid=' + meshid.split('/')[2] + '&installflags=",1)>');
2882 + x += addHtmlValue('Mesh Agent', '<a id=aginsw64lnk href="meshagents?id=4&meshid=' + meshid.split('/')[2] + '&installflags=0" download onclick="setDialogMode(0)" title="64bit version of the MeshAgent">Windows x64 (.exe)</a> <img src=images/link4.png height=10 width=10 title="Copy Windows 64bit agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshagents?id=4&meshid=' + meshid.split('/')[2] + '&installflags=",1)>');
2883 + if (debugmode > 0) { x += addHtmlValue('Settings File', '<a id=aginswmshlnk href="meshsettings?id=' + meshid.split('/')[2] + '&installflags=0" rel="noreferrer noopener" target="_blank">' + EscapeHtml(mesh.name) + ' settings (.msh)</a>'); }
2884 + x += "</div>";
2885 +
2886 + // Linux agent install
2887 + x += "<div id=agins_linux style=display:none>To add a computer to " + EscapeHtml(mesh.name) + " run the following command. Root credentials will be needed.<br />";
2888 + x += '<textarea id=agins_linux_area rows=2 cols=20 readonly=readonly style=width:100%;resize:none;height:120px;overflow:scroll;font-size:12px readonly></textarea>';
2889 + x += "<div style='font-size:x-small'>* For BSD, run \"pkg install wget sudo bash\" first.</div></div>";
2890 +
2891 + // MacOS agent install
2892 + x += "<div id=agins_osx style=display:none>To add a new computer to device group \"" + EscapeHtml(mesh.name) + "\", download the mesh agent and install it the computer to manage. This agent installer has server and device group information embedded within it.<br /><br />";
2893 + x += addHtmlValue('Mesh Agent', '<a href="meshosxagent?id=16&meshid=' + meshid.split('/')[2] + '" rel="noreferrer noopener" target="_blank" title="64bit version of MacOS Mesh Agent">MacOS Agent (64bit)</a> <img src=images/link4.png height=10 width=10 title="Copy MacOS agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshosxagent?id=16&meshid=' + meshid.split('/')[2] + '",0)>');
2894 + x += "</div>";
2895 +
2896 + // Windows agent uninstall
2897 + x += "<div id=agins_windows_un style=display:none>To remove a mesh agent, download the file below, run it and click \"uninstall\".<br /><br />";
2898 + x += addHtmlValue('Mesh Agent', '<a href="meshagents?id=3" download onclick="setDialogMode(0)" title="32bit version of the MeshAgent">Windows (.exe)</a>');
2899 + x += addHtmlValue('Mesh Agent', '<a href="meshagents?id=4" download onclick="setDialogMode(0)" title="64bit version of the MeshAgent">Windows x64 (.exe)</a>');
2900 + x += "</div>";
2901 +
2902 + // Linux agent uninstall
2903 + x += "<div id=agins_linux_un style=display:none>To remove a mesh agent, run the following command. Root credentials will be needed.<br />";
2904 + x += '<textarea id=agins_linux_area_un rows=2 cols=20 readonly=readonly style=width:100%;resize:none;height:120px;overflow:scroll;font-size:12px readonly></textarea>';
2905 + x += "</div>";
2906 +
2907 + setDialogMode(2, "Add Mesh Agent", 2, null, x, 'fileDownload');
2908 + var servername = serverinfo.name;
2909 + if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name.
2910 + var domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1);
2911 +
2912 + if (serverinfo.https == true)
2913 + {
2914 + var portStr = (serverinfo.port == 443)?'':(":" + serverinfo.port);
2915 + if ((features & 0x2000) == 0)
2916 + {
2917 + Q('agins_linux_area').value = "(wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://" + servername + portStr + domainUrlNoSlash + " '" + meshid.split('/')[2] + "'\r\n";
2918 + Q('agins_linux_area_un').value = "(wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n";
2919 + }
2920 + else
2921 + {
2922 + // Server asked that agent be installed to preferably not use a HTTP proxy.
2923 + Q('agins_linux_area').value = "wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://" + servername + portStr + domainUrlNoSlash + " '" + meshid.split('/')[2] + "'\r\n";
2924 + Q('agins_linux_area_un').value = "wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n";
2925 + }
2926 + }
2927 + else
2928 + {
2929 + var portStr = (serverinfo.port == 80) ? '' : (":" + serverinfo.port);
2930 + if ((features & 0x2000) == 0)
2931 + {
2932 + Q('agins_linux_area').value = "(wget http://" + servername + portStr + domainUrl + "meshagents?script=1 -O ./meshinstall.sh || wget http://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://" + servername + portStr + domainUrlNoSlash + " '" + meshid.split('/')[2] + "'\r\n";
2933 + Q('agins_linux_area_un').value = "(wget http://" + servername + portStr + domainUrl + "meshagents?script=1 -O ./meshinstall.sh || wget http://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n";
2934 + }
2935 + else
2936 + {
2937 + // Server asked that agent be installed to preferably not use a HTTP proxy.
2938 + Q('agins_linux_area').value = "wget http://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://" + servername + portStr + domainUrlNoSlash + " '" + meshid.split('/')[2] + "'\r\n";
2939 + Q('agins_linux_area_un').value = "wget http://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n";
2940 + }
2941 + }
2942 + Q('aginsSelect').focus();
2943 + addAgentToMeshClick();
2944 + return false;
2945 + }
2946 +
2947 + function copyAgentUrl(url,addflag) {
2948 + var servername = serverinfo.name;
2949 + if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name.
2950 + var domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1);
2951 + var portStr = (serverinfo.port == 443) ? '' : (":" + serverinfo.port);
2952 + var c = "https://" + servername + portStr + domainUrl + url;
2953 + if (addflag == 1) c += Q('aginsType').value;
2954 + copyTextToClip(c);
2955 + }
2956 +
2957 + function addAgentToMeshClick() {
2958 + var v = Q('aginsSelect').value;
2959 + QV('agins_windows', v == 0);
2960 + QV('agins_linux', v == 1);
2961 + QV('agins_osx', v == 2);
2962 + QV('agins_windows_un', v == 3);
2963 + QV('agins_linux_un', v == 4);
2964 + QV('aginsTypeDiv', v == 0);
2965 +
2966 + // Fix the links if needed
2967 + Q('aginsw32lnk').href = (Q('aginsw32lnk').href.split('installflags=')[0]) + 'installflags=' + Q('aginsType').value;
2968 + Q('aginsw64lnk').href = (Q('aginsw64lnk').href.split('installflags=')[0]) + 'installflags=' + Q('aginsType').value;
2969 + if (debugmode > 0) { Q('aginswmshlnk').href = (Q('aginswmshlnk').href.split('installflags=')[0]) + 'installflags=' + Q('aginsType').value; }
2970 + }
2971 +
2972 + function validateDeviceToMesh() {
2973 + QE('idx_dlgOkButton', (Q('dp1devicename').value.length > 0) && (passwordcheck(Q('dp1password').value)));
2974 + }
2975 +
2976 + function addDeviceToMeshEx(button, meshid) {
2977 + var amtuser = Q('dp1username').value;
2978 + if (amtuser == '') amtuser = 'admin';
2979 + var host = Q('dp1hostname').value;
2980 + if (host == '') host = Q('dp1devicename').value;
2981 + meshserver.send({ action: 'addamtdevice', meshid: meshid, devicename: Q('dp1devicename').value, hostname: host, amtusername: amtuser, amtpassword: Q('dp1password').value, amttls: Q('dp1tls').value });
2982 + }
2983 +
2984 + function deviceHeaderSet() {
2985 + if (deviceHeaderId == 0) { deviceHeaderId = 1; return; }
2986 + deviceHeaders["DevxHeader" + deviceHeaderId] = deviceHeaderTotal + ((deviceHeaderTotal == 1) ? ' node' : ' nodes');
2987 + //var title = '';
2988 + //for (x in deviceHeaderCount) { if (title.length > 0) title += ', '; title += deviceHeaderCount[x] + ' ' + PowerStateStr2(x); }
2989 + //deviceHeadersTitles["DevxHeader" + deviceHeaderId] = title;
2990 + deviceHeaderId++;
2991 + deviceHeaderCount = {};
2992 + deviceHeaderTotal = 0;
2993 + }
2994 +
2995 + var powerStateStrings = ['', '<span title="Device is powered on.">Powered</span>', '<span title="Device is in sleep state (S1).">Sleeping</span>', '<span title="Device is in sleep state (S2).">Sleeping</span>', '<span title="Device is in deep sleep state (S3).">Deep Sleep</span>', '<span title="Device is in hibernating state (S4).">Hibernating</span>', '<span title="Device is in powered off state (S5).">Soft-Off</span>', '<span title="Device is detected but power state could not be obtained.">Present</span>'];
2996 + var powerStateStrings2 = ['', 'Device is powered', 'Device is in sleep state (S1)', 'Device is in sleep state (S2)', 'Device is in deep sleep state (S3)', 'Device is hibernating (S4)', 'Device is in soft-off state (S5)', 'Device is present, but power state cannot be determined'];
2997 + var powerColorTable = ['pwsTransparent', 'pwsBlack', 'pwsBlue', 'pwsBlue2', 'pwsLightblue', 'pwsBlueviolet', 'pwsDarkgreen', 'pwsLightseagreen', 'pwsLightseagreen2'];
2998 + function NodeStateStr(node) {
2999 + var states = [];
3000 + if (node.state > 0 && node.state < powerStatetable.length) state.push(powerStatetable[node.state]);
3001 + if (node.conn) {
3002 + if ((node.conn & 1) != 0) { states.push('<span title="Mesh agent is connected and ready for use.">Agent</span>'); }
3003 + if ((node.conn & 2) != 0) { states.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">CIRA</span>'); }
3004 + else if ((node.conn & 4) != 0) { states.push('<span title="Intel&reg; AMT is routable.">Intel&reg; AMT</span>'); }
3005 + if ((node.conn & 8) != 0) { states.push('<span title="Mesh agent is reachable using another agent as relay.">Relay</span>'); }
3006 + }
3007 + if ((node.pwr != null) && (node.pwr != 0)) { states.push(powerStateStrings[node.pwr]); }
3008 + return states.join(', ');
3009 + }
3010 +
3011 + function PowerStateStr(x) {
3012 + if (x < powerStatetable.length) return powerStatetable[x];
3013 + return '';
3014 + }
3015 +
3016 + function PowerStateStr2(x) {
3017 + if ((x != 0) && (x < powerStatetable.length)) return powerStatetable[x];
3018 + return 'Unknown';
3019 + }
3020 +
3021 + function selectallButtonFunction() {
3022 + var elements = document.getElementsByClassName("DeviceCheckbox"), checkcount = 0;
3023 + for (var i=0;i<elements.length;i++) { if (elements[i].checked === true) checkcount++; }
3024 + for (var i=0;i<elements.length;i++) { elements[i].checked = (checkcount == 0); }
3025 + p1updateInfo();
3026 + }
3027 +
3028 + function p1updateInfo() {
3029 + var elements = document.getElementsByClassName("DeviceCheckbox"), checkcount = 0;
3030 + for (var i=0;i<elements.length;i++) { if (elements[i].checked === true) { checkcount++; } }
3031 + if (checkcount > 0) {
3032 + QE('GroupActionButton', true);
3033 + Q('SelectAllButton').value = 'Select None';
3034 + QV('cxmgroupsplit', true);
3035 + QV('cxmdesktop', true);
3036 + } else {
3037 + QE('GroupActionButton', false);
3038 + Q('SelectAllButton').value = 'Select All';
3039 + QV('cxmgroupsplit', false);
3040 + QV('cxmdesktop', false);
3041 + }
3042 + }
3043 +
3044 + function groupActionFunction() {
3045 + var x = "Select an operation to perform on all selected devices. Actions will be performed only with proper rights.<br /><br />";
3046 + x += addHtmlValue('Operation', '<select id=d2groupop><option value=100>Wake-up devices</option><option value=4>Sleep devices</option><option value=3>Reset devices</option><option value=2>Power off devices</option><option value=102>Move to device group</option><option value=101>Delete devices</option></select>');
3047 + setDialogMode(2, "Group Action", 3, groupActionFunctionEx, x);
3048 + }
3049 +
3050 + // Get the list of checked devices, removes any duplicates.
3051 + function getCheckedDevices() {
3052 + var nodeids = [], elements = document.getElementsByClassName("DeviceCheckbox"), checkcount = 0;
3053 + for (var i=0;i<elements.length;i++) { if (elements[i].checked) { if (elements[i].value) { var nid = elements[i].value.substring(6); if (nodeids.indexOf(nid) == -1) { nodeids.push(nid); } } } }
3054 + return nodeids;
3055 + }
3056 +
3057 + function groupActionFunctionEx() {
3058 + var op = Q('d2groupop').value;
3059 + if (op == 100) {
3060 + // Group wake
3061 + meshserver.send({ action: 'wakedevices', nodeids: getCheckedDevices() });
3062 + } else if (op == 101) {
3063 + // Group delete, ask for confirmation
3064 + var x = "Confirm delete selected devices(s)?<br /><br />";
3065 + x += "<label><input id=d2check type=checkbox onchange=d2groupActionFunctionDelEx() />Confirm</label>";
3066 + setDialogMode(2, "Delete Nodes", 3, groupActionFunctionDelEx, x);
3067 + QE('idx_dlgOkButton', false);
3068 + } else if (op == 102) {
3069 + // Move computers to a different group
3070 + p10showChangeGroupDialog(getCheckedDevices());
3071 + } else {
3072 + // Power operation
3073 + meshserver.send({ action: 'poweraction', nodeids: getCheckedDevices(), actiontype: op });
3074 + }
3075 + }
3076 +
3077 + function d2groupActionFunctionDelEx() { QE('idx_dlgOkButton', Q('d2check').checked); }
3078 + function groupActionFunctionDelEx() { meshserver.send({ action: 'removedevices', nodeids: getCheckedDevices() }); }
3079 +
3080 + function onSortSelectChange(skipsave) {
3081 + sort = document.getElementById("sortselect").selectedIndex;
3082 + if (!skipsave) { putstore("sort", sort); }
3083 + }
3084 +
3085 + function meshSort(a, b) { if (a.meshnamel > b.meshnamel) return 1; if (a.meshnamel < b.meshnamel) return -1; if (a.meshid == b.meshid) { if (showRealNames == true) { if (a.rnamel > b.rnamel) return 1; if (a.rnamel < b.rnamel) return -1; return 0; } else { if (a.namel > b.namel) return 1; if (a.namel < b.namel) return -1; return 0; } } return 0; }
3086 + function powerSort(a, b) { var ap = a.pwr?a.pwr:0; var bp = b.pwr?b.pwr:0; if (ap > bp) return -1; if (ap < bp) return 1; if (ap == bp) { if (showRealNames == true) { if (a.rnamel > b.rnamel) return 1; if (a.rnamel < b.rnamel) return -1; return 0; } else { if (a.namel > b.namel) return 1; if (a.namel < b.namel) return -1; return 0; } } return 0; }
3087 + function deviceSort(a, b) { if (a.namel > b.namel) return 1; if (a.namel < b.namel) return -1; return 0; }
3088 + function deviceHostSort(a, b) { if (a.rnamel > b.rnamel) return 1; if (a.rnamel < b.rnamel) return -1; return 0; }
3089 + function onSearchFocus(x) { searchFocus = x; }
3090 + function onMapSearchFocus(x) { mapSearchFocus = x; }
3091 + function onUserSearchFocus(x) { userSearchFocus = x; }
3092 + function onConsoleFocus(x) { consoleFocus = x; }
3093 +
3094 + function onSearchInputChanged() {
3095 + var x = Q('SearchInput').value.toLowerCase().trim(); putstore("_search", x);
3096 + var userSearch = null, ipSearch = null, groupSearch = null;
3097 + if (x.startsWith('user:')) { userSearch = x.substring(5); }
3098 + else if (x.startsWith('u:')) { userSearch = x.substring(2); }
3099 + else if (x.startsWith('ip:')) { ipSearch = x.substring(3); }
3100 + else if (x.startsWith('group:')) { groupSearch = x.substring(6); }
3101 + else if (x.startsWith('g:')) { groupSearch = x.substring(2); }
3102 +
3103 + if (x == '') {
3104 + // No search
3105 + for (var d in nodes) { nodes[d].v = true; }
3106 + } else if (ipSearch != null) {
3107 + // IP address search
3108 + for (var d in nodes) { nodes[d].v = ((nodes[d].ip != null) && (nodes[d].ip.indexOf(ipSearch) >= 0)); }
3109 + } else if (groupSearch != null) {
3110 + // Group filter
3111 + for (var d in nodes) { nodes[d].v = (meshes[nodes[d].meshid].name.toLowerCase().indexOf(groupSearch) >= 0); }
3112 + } else if (userSearch != null) {
3113 + // User search
3114 + for (var d in nodes) {
3115 + nodes[d].v = false;
3116 + if (nodes[d].users && nodes[d].users.length > 0) { for (var i in nodes[d].users) { if (nodes[d].users[i].toLowerCase().indexOf(userSearch) >= 0) { nodes[d].v = true; } } }
3117 + }
3118 + } else {
3119 + // Device name search
3120 + try {
3121 + var rs = x.split(/\s+/).join('|'), rx = new RegExp(rs); // In some cases (like +), this can throw an exception.
3122 + for (var d in nodes) {
3123 + nodes[d].v = (rx.test(nodes[d].name.toLowerCase())) || (nodes[d].rnamel != null && rx.test(nodes[d].rnamel.toLowerCase()));
3124 + if ((nodes[d].v == false) && nodes[d].tags) {
3125 + for (var s in nodes[d].tags) {
3126 + if (rx.test(nodes[d].tags[s].toLowerCase())) {
3127 + nodes[d].v = true;
3128 + break;
3129 + } else {
3130 + nodes[d].v = false;
3131 + }
3132 + }
3133 + }
3134 + }
3135 + } catch (ex) { for (var d in nodes) { nodes[d].v = true; } }
3136 + }
3137 + }
3138 +
3139 + var contextelement = null;
3140 + function handleContextMenu(event) {
3141 + hideContextMenu();
3142 + var scrollLeft = (window.pageXOffset !== null) ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft;
3143 + var scrollTop = (window.pageYOffset !== null) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
3144 + var elem = document.elementFromPoint(event.pageX - scrollLeft, event.pageY - scrollTop);
3145 + if (elem && elem != null && elem.id == "MxMESH") {
3146 + contextelement = elem;
3147 + var contextmenudiv = document.getElementById("meshContextMenu");
3148 + contextmenudiv.style.left = event.pageX + "px";
3149 + contextmenudiv.style.top = event.pageY + "px";
3150 + contextmenudiv.style.display = "block";
3151 + } else {
3152 + while (elem && elem != null && elem.id != "devs") { elem = elem.parentElement; }
3153 + if (!elem || elem == null) return true;
3154 + contextelement = elem;
3155 + var contextmenudiv = document.getElementById("contextMenu");
3156 + contextmenudiv.style.left = event.pageX + "px";
3157 + contextmenudiv.style.top = event.pageY + "px";
3158 + contextmenudiv.style.display = "block";
3159 + }
3160 +
3161 + // Get the node and set the menu options
3162 + var nodeid = contextelement.children[1].attributes.onclick.value;
3163 + var node = getNodeFromId(nodeid.substring(12, nodeid.length - 18));
3164 + var mesh = meshes[node.meshid];
3165 + var meshlinks = mesh.links[userinfo._id];
3166 + var meshrights = meshlinks.rights;
3167 + var consoleRights = ((meshrights & 16) != 0);
3168 +
3169 + // Check if we have terminal and file access
3170 + var terminalAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0));
3171 + var fileAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0));
3172 +
3173 + QV('cxdesktop', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((meshrights & 8) || (meshrights & 256)));
3174 + QV('cxterminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess);
3175 + QV('cxfiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (meshrights & 8) && fileAccess);
3176 + QV('cxevents', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (meshrights & 8));
3177 + QV('cxconsole', (consoleRights && (mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (meshrights & 8));
3178 +
3179 + return haltEvent(event);
3180 + }
3181 +
3182 + function cmaction(action,event) {
3183 + var nodeid = contextelement.children[1].attributes.onclick.value;
3184 + nodeid = nodeid.substring(12, nodeid.length - 18);
3185 + if (action == 7) { Q('viewselect').value = 3; Q('viewselect').onchange(); Q('autoConnectDesktopCheckbox').checked = true; Q('autoConnectDesktopCheckbox').onclick(); } // Multi-Desktop
3186 + if ((action > 0) && (action < 7)) {
3187 + var panel = [0, 10, 12, 11, 13, 16, 15][action]; // (invalid), General, Desktop, Terminal, Files, Events, Console
3188 + if (event && (event.shiftKey == true)) {
3189 + // Open the device in a different tab
3190 + window.open(window.location.origin + '?node=' + nodeid.split('/')[2] + '&viewmode=' + panel + '&hide=16', 'meshcentral:' + nodeid);
3191 + } else {
3192 + // Go to the right panel
3193 + gotoDevice(nodeid, panel);
3194 +
3195 + // If possible, connect...
3196 + var mesh = meshes[currentNode.meshid];
3197 + if ((currentNode.conn & 1) && (mesh.mtype == 2)) {
3198 + if ((panel == 11) && (desktop == null) && (currentNode.agent.caps & 1)) { connectDesktop(null, 1); } // Desktop
3199 + if ((panel == 12) && (terminal == null) && (currentNode.agent.caps & 2)) { connectTerminal(null, 1); } // Terminal
3200 + if ((panel == 13) && (files == null)) { connectFiles(null); } // files
3201 + }
3202 + }
3203 + }
3204 + }
3205 +
3206 + function cmmeshaction(action) {
3207 + var meshid = contextelement.attributes.onclick.value.substring(32, (32 + 69));
3208 + var elements = document.getElementsByClassName("DeviceCheckbox");
3209 + if (action == 1) { for (var i = 0; i < elements.length; i++) { if ( (elements[i].attributes) && (elements[i].attributes['class']['value'].substring(0, 69) == meshid)) { elements[i].checked = true; } } }
3210 + if (action == 2) { for (var i = 0; i < elements.length; i++) { if ( (elements[i].attributes) && (elements[i].attributes['class']['value'].substring(0, 69) == meshid)) { elements[i].checked = false; } } }
3211 + //if (action == 3) { window.location = "multidesktop.aspx?mesh=" + meshid + "&auto=1"; }
3212 + p1updateInfo();
3213 + }
3214 +
3215 + function hideContextMenu() {
3216 + QV('contextMenu', false);
3217 + QV('meshContextMenu', false);
3218 + contextelement = null;
3219 + }
3220 +
3221 + //
3222 + // DEVICES MAP
3223 + //
3224 +
3225 + // Maps code starts from here. Initialize all the variables
3226 + var xxmap = {
3227 + map: null,
3228 + contextmenu: null,
3229 + activeInteractions: [], // Save Modified features in this list
3230 + showindex: 0,
3231 + markersSource: null, // Initialize a Source Vector
3232 + markersLayer: null,
3233 + mapLayer: null, // Create a tile and use OSM source
3234 + mapView: null, // Sets the initial view
3235 + }
3236 +
3237 + // Add a feature for every Node and change style if connection status changes
3238 + function updateMapMarkers(selectedMesh) {
3239 + if ((xxmap != null) && (xxmap.map == null)) { try { loadmap(); } catch (ex) { console.error('loadmap() exception', ex); } }
3240 + if (xxmap == null) return;
3241 + var boundingBox = null;
3242 + for (var i in nodes) {
3243 + try {
3244 + var loc = map_parseNodeLoc(nodes[i]), feature = xxmap.markersSource.getFeatureById(nodes[i]._id);
3245 + if ((loc != null) && ((nodes[i].meshid == selectedMesh) || (selectedMesh == null))) { // Draw markers for devices with locations
3246 + var lat = loc[0], lon = loc[1], type = loc[2];
3247 + if (boundingBox == null) { boundingBox = [ lat, lon, lat, lon, 0 ]; } else { if (lat < boundingBox[0]) { boundingBox[0] = lat; } if (lon < boundingBox[1]) { boundingBox[1] = lon; } if (lat > boundingBox[2]) { boundingBox[2] = lat; } if (lon > boundingBox[3]) { boundingBox[3] = lon; } }
3248 + if (feature == null) { addFeature(nodes[i]); boundingBox[4] = 1; } else { updateFeature(nodes[i], feature); feature.setStyle(markerStyle(nodes[i], loc[2])); } // Update Feature
3249 + } else {
3250 + if (feature) { xxmap.markersSource.removeFeature(feature); }
3251 + }
3252 + } catch (ex) { console.error('updateMapMarkers() exception', ex, JSON.stringify(nodes[i])); }
3253 + }
3254 + return boundingBox;
3255 + }
3256 +
3257 + // Show node details on hovering over a feature
3258 + var map_cm_popup = new ol.Overlay({ element: Q('xmap-info-window'), positioning: 'bottom-center', stopEvent: false });
3259 +
3260 + // Edit Marker item
3261 + var map_cm_editMarker = { text: "Modify node location", callback: function (obj) { modifyMarkerloc(obj.data); } };
3262 +
3263 + // Clear Marker item
3264 + var map_cm_clearMarker = { text: "Remove node location", callback: function (obj) {
3265 + meshserver.send({ action: 'changedevice', nodeid: obj.data.a, userloc: [] }); // Clear the user position marker
3266 + }};
3267 +
3268 + // Save Marker item
3269 + var map_cm_saveMarker = { text: "Save node location", callback: function (obj) { saveMarkerloc(obj.data); } };
3270 +
3271 + // Build a context menu for a feature
3272 + var map_cm_nodemenu_items = [
3273 + { text: "General information", callback: function (obj) { if (obj.data !=null) { gotoDevice(obj.data, 10); } } },
3274 + { text: "Desktop", callback: function (obj) { if (obj.data !=null) { gotoDevice(obj.data, 11); } } },
3275 + { text: "Terminal", callback: function (obj) { if (obj.data !=null) { gotoDevice(obj.data, 12); } } },
3276 + { text: "Intel&reg; AMT", callback: function (obj) { if (obj.data !=null) { gotoDevice(obj.data, 14); } } },
3277 + '-',
3278 + { text: 'Zoom-in to extent', callback: function(obj) { var coords = obj.data.getGeometry().getCoordinates(); zoomToLocation(coords, 19); } },
3279 + { text: 'Zoom-out to extent', callback: function(obj) { var coords = obj.data.getGeometry().getCoordinates(); zoomToLocation(coords, 2); } }
3280 + ];
3281 +
3282 + // Context menu for clicks other than on feature
3283 + var contextmenu_items = [
3284 + { text: 'Refresh', callback: function () { refreshMap(true, true); } },
3285 + { text: 'Zoom to fit extent', callback: function () { zoomToFitExtent(); } },
3286 + { text: 'Center map here', callback: function(obj) { xxmap.mapView.animate({ center: obj.coordinate } ); } },
3287 + { text: 'Place node here', callback: function(obj) { placeNode(obj.coordinate); } }
3288 + ];
3289 +
3290 + function stringToIntHash(str) {
3291 + var hash = 0, i;
3292 + for (i = 0; i < str.length; i++) { hash = ((hash << 5) - hash) + str.charCodeAt(i); hash |= 0; }
3293 + return hash;
3294 + };
3295 +
3296 + // Get the lat/lon from a node
3297 + function map_parseNodeLoc(node) {
3298 + var loc = null, t = 0;
3299 + if (node.iploc) { loc = node.iploc; t = 1; }
3300 + if (node.wifiloc) { loc = node.wifiloc; t = 2; }
3301 + if (node.gpsloc) { loc = node.gpsloc; t = 3; }
3302 + if (node.userloc) { loc = node.userloc; t = 4; }
3303 + if ((loc == null) || (typeof loc != 'string')) return null;
3304 + loc = loc.split(',');
3305 + if (t == 1) {
3306 + // If this is IP location, randomize the position a little.
3307 + return [ parseFloat(loc[0]) + (stringToIntHash(node._id.substring(0, 20)) / 100000000000), parseFloat(loc[1]) + (stringToIntHash(node._id.substring(20)) / 100000000000), t ];
3308 + } else {
3309 + // Return the real position
3310 + return [ parseFloat(loc[0]), parseFloat(loc[1]), t ];
3311 + }
3312 + }
3313 +
3314 + // Load the entire map
3315 + function loadmap() {
3316 + if (xxmap == null) return;
3317 + if ((features & 0x8000) == 0) { QV('viewselectmapoption', false); QV('devViewButton4', false); xxmap = null; return; } // Geolocation not supported
3318 + try {
3319 + // Initialize a Source Vector
3320 + xxmap.markersSource = new ol.source.Vector();
3321 +
3322 + xxmap.markersLayer = new ol.layer.Vector({
3323 + source: xxmap.markersSource
3324 + });
3325 +
3326 + // Create a tile and use OSM source
3327 + xxmap.mapLayer = new ol.layer.Tile({ source: new ol.source.OSM() });
3328 +
3329 + xxmap.mapView = new ol.View({ // Set the initial view
3330 + center: ol.proj.transform([0, 0], 'EPSG:4326', 'EPSG:3857'),
3331 + zoom: 2,
3332 + minZoom: 2,
3333 + maxZoom: 20,
3334 + extent: ol.proj.transformExtent([-100000, -69.55, 100000, 69.55], 'EPSG:4326', 'EPSG:3857')
3335 + });
3336 +
3337 + xxmap.map = new ol.Map({
3338 + target: 'xdevicesmap',
3339 + layers: [xxmap.mapLayer, xxmap.markersLayer],
3340 + view: xxmap.mapView
3341 + });
3342 +
3343 + xxmap.map.addOverlay(map_cm_popup);
3344 +
3345 + // Goto information tab if a user clicks on a feature
3346 + xxmap.map.on('click', function(evt) {
3347 + var feature = xxmap.map.forEachFeatureAtPixel(evt.pixel, function(feat, layer) { return feat; });
3348 + if (feature) {
3349 + var nodeid = feature.getId();
3350 + if (nodeid != null) { gotoDevice(nodeid, 10); } // Goto general info tab
3351 + else { // For pointer
3352 + var nodeFeatgoto = getCorrespondingFeature(feature); gotoDevice(nodeFeatgoto.getId(), 10);
3353 + }
3354 + }
3355 + });
3356 +
3357 + // On hover feature show the name of the node. Also add pointer style
3358 + xxmap.map.on('pointermove', function(evt) {
3359 + var feature = xxmap.map.forEachFeatureAtPixel(evt.pixel, function(feat, layer) { return feat; });
3360 + if (feature) {
3361 + xxmap.map.getTargetElement().style.cursor = 'pointer';
3362 + var coord = feature.getGeometry().getCoordinates();
3363 + // map_cm_popup.setPosition(evt.coordinate);
3364 + map_cm_popup.setPosition(coord);
3365 + var featid = feature.getId();
3366 + if (featid) {
3367 + QH('xmap-info-window', feature.get('name'));
3368 + } else {
3369 + var nodeFeat = getCorrespondingFeature(feature); // Return the node feature associated to pointer.
3370 + QH('xmap-info-window', nodeFeat.get('name'));
3371 + }
3372 + } else {
3373 + xxmap.map.getTargetElement().style.cursor = '';
3374 + QH('xmap-info-window', '');
3375 + }
3376 + });
3377 +
3378 + // Initialize context menu for openlayers
3379 + var contextmenu = new ContextMenu({
3380 + width: 160,
3381 + defaultItems: false, // defaultItems are Zoom In/Zoom Out
3382 + items: contextmenu_items
3383 + });
3384 +
3385 + // On right click open the context menu
3386 + contextmenu.on("open", function (evt) {
3387 + var feature = xxmap.map.forEachFeatureAtPixel(evt.pixel, function(ft, l){ return ft; });
3388 + xxmap.contextmenu.clear(); //Clear the context menu
3389 + if (feature) {
3390 + var featId = feature.getId();
3391 + if (featId) { addContextMenuItems(feature); } // Node feature will have an id
3392 + else { // If the feature is a pointer, Get its corresponding Node feature
3393 + var nodeFeature = getCorrespondingFeature(feature); //return the node feature associated to pointer.
3394 + if (nodeFeature) { addContextMenuItems(nodeFeature); }
3395 + else{ xxmap.contextmenu.extend(contextmenu_items); }
3396 + }
3397 + }
3398 + else { xxmap.contextmenu.extend(contextmenu_items); }
3399 + });
3400 + if (xxmap.contextmenu == null) { xxmap.contextmenu = contextmenu; }
3401 + xxmap.map.addControl(xxmap.contextmenu);
3402 + //addMeshOptions(); // Adds Mesh names to mesh dropdown
3403 + } catch (ex) {
3404 + console.log(ex);
3405 + QV('viewselectmapoption', false);
3406 + QV('devViewButton4', false);
3407 + xxmap = null;
3408 + }
3409 + }
3410 +
3411 + // Add feature on to Map for a Node
3412 + function addFeature(node, lat, lon) {
3413 + var existingfeature = getModifiedFeature(node._id); // Check if Corresponding feature was Modified ( Modifed feature are in active interactions list)
3414 + if (existingfeature) { xxmap.markersSource.addFeature(existingfeature); } // Add that existing feature
3415 + else { // Add new feature for this node
3416 + if (!lat && !lon) { var loc = map_parseNodeLoc(node); lat = loc[0]; lon = loc[1]; }
3417 +
3418 + // Fix the longiture and send an event to patch the db to correct coordinate format. It will cause second unnecessary updateFeature on this node to the map.
3419 + if (lon > 180) { lon = 180 - lon; meshserver.send({ action: 'changedevice', nodeid: node._id, userloc: [ lat, lon ] }); }
3420 +
3421 + if ((lat < 90) && (lat > -90) && (lon < 180) && (lon > -180)) { // Check valid lat/lon
3422 + var feature = new ol.Feature({ geometry: new ol.geom.Point(ol.proj.transform([lon, lat], 'EPSG:4326','EPSG:3857')), name: node.name, status: node.conn, lat: lat, lon: lon });
3423 + feature.setId(node._id); // Set id for the device as nodeid
3424 + feature.setStyle(markerStyle(node));
3425 + xxmap.markersSource.addFeature(feature); // Add the feature to Marker Source
3426 + }
3427 + }
3428 + }
3429 +
3430 + // Removing any feature from map
3431 + function removeFeature(node) {
3432 + var feature = xxmap.markersSource.getFeatureById(node._id);
3433 + if (feature) { xxmap.markersSource.removeFeature(feature); }
3434 + }
3435 +
3436 + // Update feature
3437 + function updateFeature(node, feature) {
3438 + if (node.conn != feature.get('status') ) { // Update status if changed
3439 + feature.set('status',node.conn)
3440 + feature.setStyle(markerStyle(node));
3441 + }
3442 +
3443 + // Since this is IP address location, add some fixed randomness to the location. Avoid pin pile-up.
3444 + var loc = map_parseNodeLoc(node);
3445 + if (loc != null) {
3446 + var lat = loc[0], lon = loc[1];
3447 + if ((lat != feature.get('lat')) || (lon != feature.get('lon'))) { // Update lat and lon if changed
3448 + feature.set('lat', lat); feature.set('lon', lon);
3449 + var modifiedCoordinates = ol.proj.transform([parseFloat(lon), parseFloat(lat)], 'EPSG:4326', 'EPSG:3857');
3450 + feature.getGeometry().setCoordinates(modifiedCoordinates);
3451 + }
3452 + }
3453 +
3454 + if (node.name != feature.get('name') ) { feature.set('name', node.name); } // Update name
3455 + }
3456 +
3457 + // Enable dragging of a marker after edit option is clicked in context menu
3458 + function modifyMarkerloc(ft){
3459 + var featid = ft.getId();
3460 + if (featid) {
3461 + ft.setStyle(markerStyle(getNodeFromId(ft.a), 4)); // Switch to a user marker
3462 + if ( !getActiveInteractions(ft)) {
3463 + var dragInteration = new ol.interaction.Modify({
3464 + features: new ol.Collection([ft]),
3465 + pixelTolerance: 10
3466 + });
3467 + xxmap.activeInteractions.push({ featureid: featid, feature:ft, interaction: dragInteration }); // Also keep track of Interactions
3468 + xxmap.map.addInteraction(dragInteration);
3469 + }
3470 + }
3471 + }
3472 +
3473 + // This will be called when save location option is clicked in context menu
3474 + function saveMarkerloc(ft){
3475 + var featid = ft.getId()
3476 + if (featid) {
3477 + var actInteraction = getActiveInteractions(ft);
3478 + if (actInteraction) { // Check if the interaction exists
3479 + xxmap.map.removeInteraction(actInteraction); //Clear Interaction for that node
3480 + removeInteraction(featid);
3481 + var coord = ft.getGeometry().getCoordinates();
3482 + var v = ol.proj.transform(coord, 'EPSG:3857', 'EPSG:4326');
3483 + if (v[0] > 180) { v[0] = 180 - v[0]; }
3484 + var vx = [ v[1], v[0] ]; // Flip the coordinates around, lat/long
3485 + meshserver.send({ action: 'changedevice', nodeid: featid, userloc: vx }); // Send them to server to save changes
3486 + }
3487 + }
3488 + }
3489 +
3490 + // Style the Markers
3491 + function markerStyle(node, type) {
3492 + if (type == null) {
3493 + type = 0;
3494 + if (node.iploc) { type = 1; }
3495 + if (node.wifiloc) { type = 2; }
3496 + if (node.gpsloc) { type = 3; }
3497 + if (node.userloc) { type = 4; }
3498 + }
3499 + var types = ['', '-ip','-wifi','-gps','-user'];
3500 + var color = connStateColor(node);
3501 + var style = new ol.style.Style({
3502 + image: new ol.style.Icon({ color: color, anchor: [0.5, 1], src: 'images/mapmarker' + types[type] + '.png' })
3503 + //stroke: new ol.style.Stroke({ color: '#000', width: 20 })
3504 + //text: new ol.style.Text({ text: 'bob!', textAlign: 'right', offsetX: -10, fill: new ol.style.Fill({ color: '#000' }), stroke: new ol.style.Stroke({ color: '#fff', width: 2 }) })
3505 + });
3506 +
3507 + /*
3508 + deviceMark.setStyle(new ol.style.Style({
3509 + text: new ol.style.Text({
3510 + //font: '12px helvetica,sans-serif',
3511 + text: currentNode.name,
3512 + textAlign: 'right',
3513 + offsetX: -10,
3514 + fill: new ol.style.Fill({ color: '#000' }),
3515 + stroke: new ol.style.Stroke({ color: '#fff', width: 2 })
3516 + }),
3517 + image: new ol.style.Icon(({ color: [113, 140, 0], src: 'images/dot.png' })) }));
3518 + */
3519 +
3520 + return [ style ];
3521 + }
3522 +
3523 + // TODO: Add more connection status types. Currently we only change color if connection status changes
3524 + function connStateColor(nodeConn){
3525 + if (nodeConn.conn == 1 || nodeConn.conn == 3 || nodeConn.conn == 5) { return '#00ffdd'; } // Green for connected devices
3526 + return '#C70039'; // Red if the Agent is not connected
3527 + }
3528 +
3529 + // Add save/edit option to context menu
3530 + function addContextMenuItems(feature) {
3531 + if (getActiveInteractions(feature)) { // If this feature is modified then display save option in contextmenu
3532 + map_cm_saveMarker.data = feature;
3533 + xxmap.contextmenu.push(map_cm_saveMarker);
3534 + } else {
3535 + map_cm_editMarker.data = feature;
3536 + xxmap.contextmenu.push(map_cm_editMarker);
3537 + var node = getNodeFromId(feature.a);
3538 + if (node.userloc) {
3539 + map_cm_clearMarker.data = feature;
3540 + xxmap.contextmenu.push(map_cm_clearMarker);
3541 + }
3542 + }
3543 + map_cm_nodemenu_items.forEach(function (item){
3544 + if (item.text == 'Zoom-in to extent' || item.text == 'Zoom-out to extent') { item.data = feature; }
3545 + else { if (item != "-") { item.data = feature.getId(); } }
3546 + });
3547 + xxmap.contextmenu.extend(map_cm_nodemenu_items);
3548 + }
3549 +
3550 + // Return a active Interaction if it exists in activeInteractions list
3551 + function getActiveInteractions(feature) {
3552 + var featid = feature.getId();
3553 + for (var i = 0; i < xxmap.activeInteractions.length; i++) {
3554 + if (xxmap.activeInteractions[i].featureid == featid) { return xxmap.activeInteractions[i].interaction; }
3555 + }
3556 + return false;
3557 + }
3558 +
3559 + // Return Modified feature based on Id
3560 + function getModifiedFeature(featid) {
3561 + if (featid) {
3562 + for (var i = 0; i < xxmap.activeInteractions.length; i++) {
3563 + if (xxmap.activeInteractions[i].featureid == featid) { return xxmap.activeInteractions[i].feature; }
3564 + }
3565 + }
3566 + return null;
3567 + }
3568 +
3569 + // Remove Interaction
3570 + function removeInteraction(ftid) {
3571 + var index = -1;
3572 + for (var i = 0; i < xxmap.activeInteractions.length; i++) {
3573 + if (xxmap.activeInteractions[i].featureid === ftid) { index = i; break; }
3574 + }
3575 + if (index >= 0) { xxmap.activeInteractions.splice(index, 1); }
3576 + }
3577 +
3578 + // Check if pointer coordinates are equal to features and return node feature
3579 + function getCorrespondingFeature(pointerFeat) {
3580 + var pointerCoord = pointerFeat.getGeometry().getCoordinates();
3581 + for (var i = 0; i < xxmap.activeInteractions.length ; i++) {
3582 + var modifiedFeatures = xxmap.activeInteractions[i].feature;
3583 + var fearCoord = modifiedFeatures.getGeometry().getCoordinates();
3584 + if (fearCoord[0].toFixed(5) == pointerCoord[0].toFixed(5) && fearCoord[1].toFixed(5) == pointerCoord[1].toFixed(5) ) { return modifiedFeatures; }
3585 + }
3586 + return null;
3587 + }
3588 +
3589 + // Refresh the map and clear list
3590 + function refreshMap(reset, rebound){
3591 + if (reset) {
3592 + xxmap.map.setTarget(null);
3593 + xxmap.map = null;
3594 + xxmap.markersSource = null;
3595 + xxmap.mapView = null;
3596 + xxmap.mapLayer = null;
3597 + xxmap.activeInteractions = []; // Clear Active Interaction list
3598 + }
3599 + //clearMeshOptions();
3600 + //onSelectMeshChange();
3601 + var box = updateMapMarkers();
3602 + if ((box != null) && (rebound || (box[4] == 1))) {
3603 + var clat = (box[0] + box[2]) / 2;
3604 + var clon = (box[1] + box[3]) / 2;
3605 + var cscale = Math.max(Math.abs(box[0] - box[2]), Math.abs(box[1] - box[3]));
3606 + var view = xxmap.map.getView();
3607 + view.setCenter(ol.proj.transform([clon, clat], 'EPSG:4326', 'EPSG:3857'));
3608 + var i = 360, j = -2;
3609 + while (i > cscale) { j++; i = i / 2; }
3610 + view.setZoom(j);
3611 + }
3612 + }
3613 +
3614 + // Called When Place a node option is clicked from context menu
3615 + function placeNode(coords) {
3616 + if (xxdialogMode) return;
3617 + var x = '<div style=margin-bottom:6px><label for=selectnode-search>Search</label>&nbsp&nbsp<input type=text placeholder="Device name" id="selectnode-search" onchange=onPlaceNodeInputChange() onkeyup=onPlaceNodeInputChange() autocomplete=off style=width:120px></div><div id=placenode style="height:254px;overflow-y:auto;width:100%;margin:12px 1px 4px 1px;"><div id=noNodesMapPlace style=text-align:center;width:100%;display:none>No devices found.</div>';
3618 + for (var i in nodes) {
3619 + x += '<div class=noselect id=' + nodes[i]._id + '-rowid onclick=selectNodeToPlace(event,\''+ nodes[i]._id +'\') style=background-color:lightgray;margin-bottom:4px;border-radius:2px><input name=PlaceMapDeviceCheckbox id=' + nodes[i]._id + '-checkid type=checkbox style=width:16px;display:inline />';
3620 + x += '<div class=j' + nodes[i].icon + ' style=width:16px;height:16px;margin-top:2px;margin-right:4px;display:inline-block></div><div style=width:16px;display:inline>' + nodes[i].name + '</div></div>';
3621 + }
3622 + setDialogMode(2, "Select a node to place", 3, placeNodeEx, x + '</div>', coords);
3623 + onPlaceNodeInputChange();
3624 + }
3625 +
3626 + function placeNodeEx(button, coords) {
3627 + var elements = document.getElementsByName("PlaceMapDeviceCheckbox");
3628 + for (var i in elements) {
3629 + if (elements[i].checked) {
3630 + var node = getNodeFromId(elements[i].id.substring(0, elements[i].id.length - 8));
3631 + if (node) {
3632 + var feature = xxmap.markersSource.getFeatureById(i);
3633 + var v = ol.proj.transform(coords, 'EPSG:3857', 'EPSG:4326');
3634 + var vx = [ v[1], v[0] ]; // Flip the coordinates around, lat/long
3635 + if (feature) {
3636 + feature.getGeometry().setCoordinates(coords);
3637 + var activeInteraction = getActiveInteractions(feature);
3638 + if (activeInteraction) {
3639 + saveMarkerloc(feature);
3640 + } else { // If this feature is not saved after its location is changed, then send updated coords to server.
3641 + meshserver.send({ action: 'changedevice', nodeid: node._id, userloc: vx }); // Send them to server to save changes
3642 + }
3643 + } else {
3644 + meshserver.send({ action: 'changedevice', nodeid: node._id, userloc: vx }); // This Node is not yet added to maps.
3645 + }
3646 + }
3647 + }
3648 + }
3649 + }
3650 +
3651 + // Called when the user changes the search box
3652 + function onPlaceNodeInputChange() {
3653 + updatePlaceNodeTable(Q('selectnode-search').value.trim().toLowerCase());
3654 + }
3655 +
3656 + // Update the list of devices in the "place on map" table
3657 + function updatePlaceNodeTable(inputSearch) {
3658 + var elements = document.getElementsByName("PlaceMapDeviceCheckbox"), count = 0;
3659 + for (var i in nodes) {
3660 + var visible = ((nodes[i].namel.indexOf(inputSearch) >= 0 || inputSearch == '') || (nodes[i].rnamel != null && nodes[i].rnamel.indexOf(inputSearch) >= 0));
3661 + if (visible) { count++; }
3662 + QV(nodes[i]._id + '-rowid', visible);
3663 + }
3664 + QV('noNodesMapPlace', count == 0);
3665 + /*
3666 + console.log(selected);
3667 + for (var i in nodes) {
3668 + if ((nodes[i].name.toLowerCase().indexOf(inputSearch) >= 0 || inputSearch == '') || (nodes[i].rnamel != null && nodes[i].rnamel.toLowerCase().indexOf(inputSearch) >= 0)) {
3669 + console.log(selected.indexOf(nodes[i]._id));
3670 + x += '<div class=noselect id=' + nodes[i]._id + '-rowid onclick=selectNodeToPlace(event,\''+ nodes[i]._id +'\') style=background-color:lightgray;margin-bottom:4px;border-radius:2px><input name=PlaceMapDeviceCheckbox id=' + nodes[i]._id + '-checkid type=checkbox style=width:16px;display:inline ' + ((selected.indexOf(nodes[i]._id) >= 0)?'checked':'') + ' />';
3671 + x += '<div class=j' + nodes[i].icon + ' style=width:16px;height:16px;margin-top:2px;margin-right:4px;display:inline-block></div><div style=width:16px;display:inline>' + nodes[i].name + '</div></div>';
3672 + }
3673 + }
3674 + if (x == '') { x = '<div style=text-align:center;width:100%>No devices found.</div>'; }
3675 + QH('placenode', '');
3676 + */
3677 + }
3678 +
3679 + // Called when a user clicks on a device to toggle selection for placement on map.
3680 + function selectNodeToPlace(e, id) {
3681 + // Toggle checkbox if needed
3682 + if (e.target.name != 'PlaceMapDeviceCheckbox') { var inputElement = Q(id + '-checkid'); inputElement.checked = !inputElement.checked; }
3683 +
3684 + // Check button state
3685 + var elements = document.getElementsByName("PlaceMapDeviceCheckbox"), checkcount = 0;
3686 + for (var i in elements) { if (elements[i].checked) checkcount++; }
3687 + QE('idx_dlgOkButton', checkcount > 0);
3688 + }
3689 +
3690 + // Add option for available meshes in mesh Dropdown
3691 + function addMeshOptions(addMeshid, meshName) {
3692 + /*
3693 + var meshOptions = Q('select-mesh');
3694 + if (addMeshid && meshName) {
3695 + var option = document.createElement('option');
3696 + option.value =addMeshid;
3697 + option.text = meshName;
3698 + meshOptions.add(option); // Add specific option
3699 + }
3700 + else {
3701 + for (var i in meshes) { // Add all options
3702 + var option = document.createElement('option');
3703 + option.value = i;
3704 + option.text = meshes[i].name;
3705 + meshOptions.add(option);
3706 + }
3707 + }
3708 + */
3709 + }
3710 +
3711 + // Remove/Modify options in Mesh dropdown (if modMeshname is defined then Modify else Remove)
3712 + function meshOptionRmvMod(delMeshid, modMeshname){
3713 + /*
3714 + var meshOptions = Q('select-mesh');
3715 + if (delMeshid) {
3716 + var index=-1;
3717 + for (var i = 1; i < meshOptions.options.length; i++) {
3718 + if (meshOptions[i].value === delMeshid) { index=i; }
3719 + }
3720 + if (index > 0) {
3721 + if (modMeshname) {
3722 + meshOptions[index].innerHTML=modMeshname; // If Mesh name is Modified
3723 + }
3724 + else { meshOptions.remove(index); }
3725 + }
3726 + }
3727 + */
3728 + }
3729 +
3730 + //Check if there is any mesh created
3731 + function meshExists() {
3732 + for (var i in meshes) { if (meshes[i]) { return true; } }
3733 + return false;
3734 + }
3735 +
3736 + // Reset Mesh dropdown option to 'All' when a current view mesh is deleted.
3737 + function setMeshView(emeshid) {
3738 + var selectMeshElement=Q("select-mesh");
3739 + var selectedIndex = selectMeshElement.selectedIndex;
3740 + if (selectMeshElement[selectedIndex].value == emeshid) { selectMeshElement[0].selected = true; onSelectMeshChange(); }
3741 + }
3742 +
3743 + // Clear all mesh options except 'All'
3744 + function clearMeshOptions() {
3745 + /*
3746 + var meshOptions=Q('select-mesh');
3747 + for(var i = meshOptions.options.length - 1 ; i > 0 ; i--) { meshOptions.remove(i); }
3748 + */
3749 + }
3750 +
3751 + // Make a http get call- Replace this with AJAX get if jquery is used
3752 + function getSearchLocation() {
3753 + try {
3754 + var searchdata = Q('mapSearchLocation').value.trim();
3755 + if (searchdata.length > 0) {
3756 + var xmlhttp = new XMLHttpRequest(); // Compatible with Chrome, Opera, Safari, IE7+, Firefox.
3757 + xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { formatSearchData(xmlhttp.responseText); } }
3758 + xmlhttp.open("GET", 'https://nominatim.openstreetmap.org/search?q=' + searchdata + '&format=json', true); // Get request
3759 + xmlhttp.send();
3760 + }
3761 + } catch (e) {}
3762 + }
3763 +
3764 + // Format data recieved from nominatim API and display it on content window
3765 + function formatSearchData(data) {
3766 + try {
3767 + QH('xmapSearchResults','');
3768 + var dataInfo = JSON.parse(data), count = 0, x = '<div class="xmapItem">';
3769 + for (var i = 0; i < dataInfo.length; i++) {
3770 + if (dataInfo[i].display_name && dataInfo[i].boundingbox[0] && dataInfo[i].boundingbox[1] && dataInfo[i].boundingbox[2] && dataInfo[i].boundingbox[3]) {
3771 + count++;
3772 + var itemclass = (i % 2 == 0)?'xmapItemSel1':'xmapItemSel1';
3773 + x += '<div class="' + itemclass + '" onclick=mapGotoSelectedLocation(this)><div>' + dataInfo[i].display_name + '</div><div style=display:none>' + dataInfo[i].boundingbox[0] + '!#!' + dataInfo[i].boundingbox[1] + '!#!' + dataInfo[i].boundingbox[2] + '!#!' + dataInfo[i].boundingbox[3] + '</div></div>';
3774 + }
3775 + }
3776 + x += '</div>';
3777 + if (count == 1) {
3778 + // If only one result is returned then zoom to that location
3779 + var extent = [ parseFloat(dataInfo[0].boundingbox[2]), parseFloat(dataInfo[0].boundingbox[0]), parseFloat(dataInfo[0].boundingbox[3]), parseFloat(dataInfo[0].boundingbox[1]) ];
3780 + zoomToExtent(extent);
3781 + } else {
3782 + if (count == 0) { x = '<div style=width:200px>No location found.<div>'; }
3783 + QV('xmapSearchResultsDlg', true);
3784 + }
3785 + QH('xmapSearchResults', x);
3786 + }
3787 + catch (e) {}
3788 + }
3789 +
3790 + // Zoom into the bounding box
3791 + function mapGotoSelectedLocation(obj) {
3792 + var objchildren = obj.children;
3793 + var boundingBox = objchildren[1].innerHTML.split('!#!');
3794 + var extent = [parseFloat(boundingBox[2]), parseFloat(boundingBox[0]), parseFloat(boundingBox[3]), parseFloat(boundingBox[1])];
3795 + //Q('search-location').value = objchildren[0].innerHTML;
3796 + zoomToExtent(extent);
3797 + mapCloseSearchWindow();
3798 + }
3799 +
3800 + // Close the search window
3801 + function mapCloseSearchWindow() {
3802 + QH('xmapSearchResults', '');
3803 + QV('xmapSearchResultsDlg', false);
3804 + }
3805 +
3806 + // Zoom to specific cordinates
3807 + function zoomToLocation(coordinates, zoomVal) {
3808 + var view = xxmap.map.getView();
3809 + view.setCenter(coordinates);
3810 + view.setZoom(zoomVal);
3811 + }
3812 +
3813 + function zoomToFitExtent() {
3814 + var features = xxmap.markersSource.getFeatures();
3815 + if (features.length > 0) {
3816 + var extent = xxmap.markersSource.getExtent();
3817 + xxmap.map.getView().fit(extent, xxmap.map.getSize());
3818 + }
3819 + }
3820 +
3821 + function zoomToExtent(extent){
3822 + var boundingExtent = ol.proj.transformExtent(extent, ol.proj.get('EPSG:4326'), ol.proj.get('EPSG:3857'));
3823 + xxmap.map.getView().fit(boundingExtent, xxmap.map.getSize());
3824 + }
3825 +
3826 +
3827 + //
3828 + // MY DEVICE
3829 + //
3830 + function refreshDevice(nodeid) {
3831 + if (!currentNode || currentNode._id != nodeid) return;
3832 + gotoDevice(nodeid, xxcurrentView, true);
3833 + }
3834 +
3835 + function getNodeRights(nodeid) {
3836 + var node = getNodeFromId(nodeid), mesh = meshes[node.meshid];
3837 + return mesh.links[userinfo._id].rights;
3838 + }
3839 +
3840 + var currentNode;
3841 + var powerTimelineNode = null;
3842 + var powerTimelineReq = null;
3843 + var powerTimelineUpdate = null;
3844 + var powerTimeline = null;
3845 + function getCurrentNode() { return currentNode; };
3846 + function gotoDevice(nodeid, panel, refresh, event) {
3847 + // Remind the user to verify the email address
3848 + if ((userinfo.emailVerified !== true) && (serverinfo.emailcheck == true) && (userinfo.siteadmin != 0xFFFFFFFF)) { setDialogMode(2, "Account Security", 1, null, "Unable to access a device until a email address is verified. This is required for password recovery. Go to the \"My Account\" tab to change and verify an email address."); return; }
3849 +
3850 + // Remind the user to add two factor authentication
3851 + if ((features & 0x00040000) && !((userinfo.otpsecret == 1) || (userinfo.otphkeys > 0) || (userinfo.otpkeys > 0))) { setDialogMode(2, "Account Security", 1, null, "Unable to access a device until two-factor authentication is enabled. This is required for extra security. Go to the \"My Account\" tab and look at the \"Account Security\" section."); return; }
3852 +
3853 + if (event && (event.shiftKey == true)) {
3854 + // Open the device in a different tab
3855 + window.open(window.location.origin + '?node=' + nodeid.split('/')[2] + '&viewmode=10&hide=16', 'meshcentral:' + nodeid);
3856 + return;
3857 + }
3858 +
3859 + //disconnectAllKvmFunction();
3860 + var node = getNodeFromId(nodeid);
3861 + var mesh = meshes[node.meshid];
3862 + var meshrights = mesh.links[userinfo._id].rights;
3863 + if (!currentNode || currentNode._id != node._id || refresh == true) {
3864 + currentNode = node;
3865 +
3866 + // Add node name
3867 + var nname = EscapeHtml(node.name);
3868 + if (nname.length == 0) { nname = '<i>None</i>'; }
3869 + if (((meshrights & 4) != 0) && ((!mesh.flags) || ((mesh.flags & 2) == 0))) { nname = '<span tabindex=0 title="Click here to edit the server-side device name" onclick=showEditNodeValueDialog(0) onkeyup="if (event.key == \'Enter\') showEditNodeValueDialog(0)" style=cursor:pointer>' + nname + ' <img class=hoverButton src="images/link5.png" /></span>'; }
3870 + QH('p10deviceName', nname);
3871 + QH('p11deviceName', nname);
3872 + QH('p12deviceName', nname);
3873 + QH('p13deviceName', nname);
3874 + QH('p14deviceName', nname);
3875 + QH('p15deviceName', 'Console - ' + nname);
3876 + QH('p16deviceName', nname);
3877 +
3878 + // Node attributes
3879 + var x = '<table style=width:100%>';
3880 +
3881 + // Attribute: Mesh
3882 + x += addDeviceAttribute('<span title="The name of the device group this computer belong to.">Group</span>', '<a href=# title="The name of the device group this computer belong to" onclick=gotoMesh("' + node.meshid + '") style=cursor:pointer>' + EscapeHtml(meshes[node.meshid].name) + '</a>');
3883 +
3884 + // Attribute: Name
3885 + if ((node.rname != null) && (node.name != node.rname)) { x += addDeviceAttribute('<span title="The name of this computer as set in the operating system">Name</span>', '<span title="The name of this computer as set in the operating system">' + EscapeHtml(node.rname) + '</span>'); }
3886 +
3887 + // Attribute: Host
3888 + if ((features & 1) == 0) { // If not WAN-only, local hostname is in use
3889 + if ((meshrights & 4) != 0) {
3890 + if (node.host) {
3891 + x += addDeviceAttribute('Hostname', '<span onclick=showEditNodeValueDialog(1) style=cursor:pointer>' + EscapeHtml(node.host) + '</span>');
3892 + } else {
3893 + x += addDeviceAttribute('Hostname', '<span onclick=showEditNodeValueDialog(1) style=cursor:pointer><i>None</i></span>');
3894 + }
3895 + } else {
3896 + x += addDeviceAttribute('Hostname', EscapeHtml(node.host));
3897 + }
3898 + }
3899 +
3900 + // Attribute: Description
3901 + var description = node.desc?EscapeHtml(node.desc):"<i>None</i>";
3902 + if ((meshrights & 4) != 0) {
3903 + x += addDeviceAttribute('Description', '<span onclick=showEditNodeValueDialog(2) style=cursor:pointer>' + description + ' <img class=hoverButton src="images/link5.png" /></span>');
3904 + } else {
3905 + x += addDeviceAttribute('Description', description);
3906 + }
3907 +
3908 + // Attribute: Mesh Agent
3909 + var agentsStr = ['Unknown', 'Windows 32bit console', 'Windows 64bit console', 'Windows 32bit service', 'Windows 64bit service', 'Linux 32bit', 'Linux 64bit', 'MIPS', 'XENx86', 'Android ARM', 'Linux ARM', 'MacOS 32bit', 'Android x86', 'PogoPlug ARM', 'Android APK', 'Linux Poky x86-32bit', 'MacOS 64bit', 'ChromeOS', 'Linux Poky x86-64bit', 'Linux NoKVM x86-32bit', 'Linux NoKVM x86-64bit', 'Windows MinCore console', 'Windows MinCore service', 'NodeJS', 'ARM-Linaro', 'ARMv6l / ARMv7l', 'ARMv8 64bit', 'ARMv6l / ARMv7l / NoKVM', 'Unknown', 'Unknown', 'FreeBSD x86-64'];
3910 + if ((node.agent != null) && (node.agent.id != null) && (node.agent.ver != null)) {
3911 + var str = '';
3912 + if (node.agent.id <= agentsStr.length) { str = agentsStr[node.agent.id]; } else { str = agentsStr[0]; }
3913 + if (node.agent.ver != 0) { str += ' v' + node.agent.ver; }
3914 + x += addDeviceAttribute('Mesh Agent', str);
3915 + }
3916 +
3917 + // Attribute: Intel AMT
3918 + if (node.intelamt != null) {
3919 + var str = '';
3920 + var provisioningStates = { 0: 'Not Activated (Pre)', 1: 'Not Activated (In)', 2: 'Activated' };
3921 + if (node.intelamt.ver != null && node.intelamt.state == null) { str += '<i>Unknown State</i>, v' + node.intelamt.ver; } else
3922 +
3923 + if ((node.intelamt.ver == null) && (node.intelamt.state == 2)) { str += '<i>Activated</i>'; }
3924 + else if ((node.intelamt.ver == null) || (node.intelamt.state == null)) { str += '<i>Unknown Version & State</i>'; }
3925 + else {
3926 + str += provisioningStates[node.intelamt.state];
3927 + if ((node.intelamt.state == 2) && node.intelamt.flags) { if (node.intelamt.flags & 2) { str += ' <span title="Intel AMT is activated in Client Control Mode">CCM</span>'; } else if (node.intelamt.flags & 4) { str += ' <span title="Intel AMT is activated in Admin Control Mode">ACM</span>'; } }
3928 + str += (', v' + node.intelamt.ver);
3929 + }
3930 +
3931 + if (node.intelamt.tls == 1) { str += ', <span title="Intel AMT is setup with TLS network security">TLS</span>'; }
3932 + if (node.intelamt.state == 2) {
3933 + if (node.intelamt.user == null || node.intelamt.user == '') {
3934 + if ((meshrights & 4) != 0) {
3935 + str += ', <i style=color:#FF0000;cursor:pointer title="Edit Intel&reg; AMT credentials" onclick=editDeviceAmtSettings("' + node._id + '")>No Credentials</i>';
3936 + } else {
3937 + str += ', <i style=color:#FF0000>No Credentials</i>';
3938 + }
3939 + }
3940 + str += ' ';
3941 + if ((meshrights & 4) != 0) {
3942 + str += '<img src=images/link4.png height=10 width=10 title="Edit Intel&reg; AMT credentials" style=cursor:pointer onclick=editDeviceAmtSettings("' + node._id + '")>';
3943 + }
3944 + }
3945 + x += addDeviceAttribute('Intel&reg; AMT', str);
3946 + }
3947 +
3948 + if (mesh.mtype == 2) {
3949 + // Attribute: Mesh Agent Tag
3950 + if ((node.agent != null) && (node.agent.tag != null)) {
3951 + var tag = EscapeHtml(node.agent.tag);
3952 + if (tag.startsWith('mailto:')) { tag = '<a href="' + tag + '">' + tag.substring(7) + '</a>'; }
3953 + x += addDeviceAttribute('Agent Tag', tag);
3954 + }
3955 + } else {
3956 + // Attribute: Intel AMT Tag
3957 + if ((node.intelamt != null) && (node.intelamt.tag != null)) {
3958 + var tag = EscapeHtml(node.intelamt.tag);
3959 + if (tag.startsWith('mailto:')) { tag = '<a href="' + tag + '">' + tag.substring(7) + '</a>'; }
3960 + x += addDeviceAttribute('Intel&reg; AMT Tag', tag);
3961 + }
3962 + }
3963 +
3964 + // Attribute: Intel AMT
3965 + //if (node.intelamt && node.intelamt.user) { x += addDeviceAttribute('Intel&reg; AMT', node.intelamt.user); }
3966 +
3967 + // Operating system description
3968 + if (node.osdesc) { x += addDeviceAttribute('Operating System', node.osdesc); }
3969 +
3970 + // Active Users
3971 + if (node.users && node.conn && (node.users.length > 0) && (node.conn & 1)) { x += addDeviceAttribute('Active User' + ((node.users.length > 1)?'s':''), node.users.join(', ')); }
3972 +
3973 + // Attribute: Connectivity (Only show this if more than just the agent is connected).
3974 + var connectivity = node.conn;
3975 + if (connectivity && connectivity > 1) {
3976 + var cstate = [];
3977 + if ((node.conn & 1) != 0) cstate.push('<span title="Mesh agent is connected and ready for use.">Mesh Agent</span>');
3978 + if ((node.conn & 2) != 0) cstate.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">Intel&reg; AMT CIRA</span>');
3979 + else if ((node.conn & 4) != 0) cstate.push('<span title="Intel&reg; AMT is routable and ready for use.">Intel&reg; AMT</span>');
3980 + if ((node.conn & 8) != 0) cstate.push('<span title="Mesh agent is reachable using another agent as relay.">Mesh Relay</span>');
3981 + x += addDeviceAttribute('Connectivity', cstate.join(', '));
3982 + }
3983 +
3984 + // Node grouping tags
3985 + var groupingTags = '<i>None</i>';
3986 + if (node.tags != null) { groupingTags = ''; for (var i in node.tags) { groupingTags += '<span class="tagSpan">' + node.tags[i] + '</span>'; } }
3987 + if ((meshrights & 4) != 0) {
3988 + x += addDeviceAttribute('Tags', '<span onclick=showEditNodeValueDialog(3) style=cursor:pointer>' + groupingTags + ' <img class=hoverButton src="images/link5.png" /></span>');
3989 + } else {
3990 + x += addDeviceAttribute('Tags', groupingTags);
3991 + }
3992 +
3993 + x += '</table><br />';
3994 + // Show action button, only show if we have permissions 4, 8, 64
3995 + if ((meshrights & 76) != 0) { x += '<input type=button value=Actions title="Perform power actions on the device" onclick=deviceActionFunction() />'; }
3996 + x += '<input type=button value=Notes title="View notes about this device" onclick=showNotes(' + ((meshrights & 128) == 0) + ',"' + encodeURIComponent(node._id) + '") />';
3997 + //if ((connectivity & 1) && (meshrights & 8) && (node.agent.id < 5)) { x += '<input type=button value=Toast title="Display a text message of the remote device" onclick=deviceToastFunction() />'; }
3998 + QH('p10html', x);
3999 +
4000 + // Show node last 7 days timeline
4001 + masterUpdate(256);
4002 +
4003 + // Show bottom buttons
4004 + x = '<div class="p10html3right">';
4005 + if ((meshrights & 4) != 0) {
4006 + // TODO: Show change group only if there is another mesh of the same type.
4007 + x += '&nbsp;<a href=# onclick=p10showChangeGroupDialog(["' + node._id + '"]) title="Move this device to a different device group">Change Group</a>';
4008 + x += '&nbsp;<a href=# onclick=p10showDeleteNodeDialog("' + node._id + '") title="Remove this device">Delete Device</a>';
4009 + }
4010 + x += '</div><div class="p10html3left">';
4011 + if (mesh.mtype == 2) x += '<a href=# onclick=p10showNodeNetInfoDialog("' + node._id + '") title="Show device network interface information">Interfaces</a>&nbsp;';
4012 + if (xxmap != null) x += '<a href=# onclick=p10showNodeLocationDialog("' + node._id + '") title="Show device locations information">Location</a>&nbsp;';
4013 + if (((meshrights & 8) != 0) && (mesh.mtype == 2)) x += '<a href=# onclick=p10showMeshCmdDialog(1,"' + node._id + '") title="Traffic router used to connect to a device thru this server.">Router</a>&nbsp;';
4014 +
4015 + // RDP link, show this link only of the remote machine is Windows.
4016 + if (((connectivity & 1) != 0) && (clickOnce == true) && (mesh.mtype == 2) && ((meshrights & 8) != 0)) {
4017 + if ((node.agent.id > 0) && (node.agent.id < 5)) { x += '<a href=# onclick=p10clickOnce("' + node._id + '","RDP2",3389) title="Requires Microsoft ClickOnce support in your browser.">RDP</a>&nbsp;'; }
4018 + if (node.agent.id > 4) {
4019 + x += '<a href=# onclick=p10clickOnce("' + node._id + '","PSSH",22) title="Requires Microsoft ClickOnce support in your browser.">Putty</a>&nbsp;';
4020 + x += '<a href=# onclick=p10clickOnce("' + node._id + '","WSCP",22) title="Requires Microsoft ClickOnce support in your browser.">WinSCP</a>&nbsp;';
4021 + }
4022 + }
4023 + x += '</div><br>'
4024 +
4025 + QH('p10html3', x);
4026 +
4027 + // Set the node power state
4028 + var powerstate = PowerStateStr(node.state);
4029 + //if (node.state == 0) { powerstate = 'Unknown State'; }
4030 + if ((connectivity & 1) != 0) { if (powerstate.length > 0) { powerstate += '<br/>'; } powerstate += '<span style=font-size:12px title="Agent connected">Agent connected</span>'; }
4031 + if ((connectivity & 2) != 0) { if (powerstate.length > 0) { powerstate += '<br/>'; } powerstate += '<span style=font-size:12px title="Intel&reg; AMT connected">Intel&reg; AMT connected</span>'; }
4032 + else if ((connectivity & 4) != 0) { if (powerstate.length > 0) { powerstate += '<br/>'; } powerstate += '<span style=font-size:12px title="Intel&reg; AMT detected">Intel&reg; AMT detected</span>'; }
4033 + if ((powerstate == '') && node.lastconnect) { powerstate = '<span style=font-size:12px>Last seen:<br />' + printDateTime(new Date(node.lastconnect)) + '</span>'; }
4034 + QH('MainComputerState', powerstate);
4035 +
4036 + // Set the node icon
4037 + Q('MainComputerImage').setAttribute("src", "images/icons256-" + node.icon + "-1.png");
4038 + Q('MainComputerImage').className = ((!node.conn) || (node.conn == 0)?'gray':'');
4039 +
4040 + // Check if we have terminal and file access
4041 + var terminalAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0));
4042 + var fileAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0));
4043 + var amtAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 2048) == 0));
4044 +
4045 + // Setup/Refresh the desktop tab
4046 + if (terminalAccess) { setupTerminal(); }
4047 + if (fileAccess) { setupFiles(); }
4048 + var consoleRights = ((meshrights & 16) != 0);
4049 + if (consoleRights) { setupConsole(); } else { if (panel == 15) { panel = 10; } }
4050 +
4051 + // Show or hide the tabs
4052 + // mesh.mtype: 1 = Intel AMT only, 2 = Mesh Agent
4053 + // node.agent.caps (bitmask): 1 = Desktop, 2 = Terminal, 4 = Files, 8 = Console
4054 + QV('MainDevDesktop', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((meshrights & 8) || (meshrights & 256)));
4055 + QV('MainDevTerminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess);
4056 + QV('MainDevFiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (meshrights & 8) && fileAccess);
4057 + QV('MainDevAmt', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (meshrights & 8) && amtAccess);
4058 + QV('MainDevConsole', (consoleRights && (mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (meshrights & 8));
4059 + QV('p15uploadCore', (node.agent != null) && (node.agent.caps != null) && ((node.agent.caps & 16) != 0));
4060 + QH('p15coreName', ((node.agent != null) && (node.agent.core != null))?node.agent.core:'');
4061 +
4062 + // Setup/Refresh Intel AMT tab
4063 + var amtFrameNode = Q('p14iframe').contentWindow.getCurrentMeshNode();
4064 + if ((amtFrameNode != null) && (amtFrameNode._id != currentNode._id)) { Q('p14iframe').contentWindow.disconnect(); }
4065 + var online = ((node.conn & 6) != 0)?true:false; // If CIRA (2) or AMT (4) connected, enable Commander
4066 + Q('p14iframe').contentWindow.setConnectionState(online);
4067 + Q('p14iframe').contentWindow.setFrameHeight('650px');
4068 + Q('p14iframe').contentWindow.setAuthCallback(updateAmtCredentials);
4069 +
4070 + // Display "action" button on desktop/terminal/files
4071 + QV('deskActionsBtn', (meshrights & 72) != 0); // 72 = Wake-up + Remote Control permissions
4072 + QV('termActionsBtn', (meshrights & 72) != 0);
4073 + QV('filesActionsBtn', (meshrights & 72) != 0);
4074 +
4075 + // Request the power timeline
4076 + if ((powerTimelineNode != currentNode._id) && (powerTimelineReq != currentNode._id)) {
4077 + QH('p10html2', '');
4078 + powerTimelineReq = currentNode._id;
4079 + meshserver.send({ action: 'powertimeline', nodeid: currentNode._id });
4080 + meshserver.send({ action: 'lastconnect', nodeid: currentNode._id });
4081 + }
4082 +
4083 + // Reset the desktop tools
4084 + QV('DeskTools', false);
4085 + showDeskToolsProcesses();
4086 +
4087 + // Ask for device events
4088 + refreshDeviceEvents();
4089 +
4090 + // Update the web page title
4091 + if ((currentNode) && (xxcurrentView >= 10) && (xxcurrentView < 20)) { document.title = decodeURIComponent("{{{extitle}}}") + ' - ' + currentNode.name; } else { document.title = decodeURIComponent("{{{extitle}}}"); }
4092 +
4093 + // Clear user consent status if present
4094 + p11clearConsoleMsg();
4095 + p12clearConsoleMsg();
4096 + p13clearConsoleMsg();
4097 + }
4098 + setupDesktop(); // Always refresh the desktop, even if we are on the same device, we need to do some canvas switching.
4099 + if (!panel) panel = 10;
4100 + go(panel);
4101 + }
4102 +
4103 + function showNotes(readonly, noteid) {
4104 + if (xxdialogMode) return;
4105 + setDialogMode(2, "Notes", 2, showNotesEx, '<textarea id=d2devNotes ro=' + readonly + ' noteid=' + noteid + ' readonly style=background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:scroll></textarea><span style=font-size:10px>Device group notes can be viewed and changed by other device group administrators.<span>', noteid);
4106 + meshserver.send({ action: 'getNotes', id: decodeURIComponent(noteid) });
4107 + }
4108 +
4109 + function showNotesEx(buttons, tag) { meshserver.send({ action: 'setNotes', id: decodeURIComponent(tag), notes: encodeURIComponent(Q('d2devNotes').value) }); }
4110 +
4111 + function deviceChat() {
4112 + if (xxdialogMode) return;
4113 + var url = '/messenger?id=meshmessenger/' + encodeURIComponent(currentNode._id) + '/' + encodeURIComponent(userinfo._id) + '&title=' + currentNode.name;
4114 + if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; }
4115 + window.open(url, 'meshmessenger:' + currentNode._id);
4116 + meshserver.send({ action: 'meshmessenger', nodeid: decodeURIComponent(currentNode._id) });
4117 + }
4118 +
4119 + function deviceUrlFunction() {
4120 + if (xxdialogMode) return;
4121 + setDialogMode(2, "Open Page on Device", 3, deviceUrlFunctionEx, '<input id=d2devurl placeholder="http://server.com" style=width:100%;overflow-y:scroll></input>');
4122 + }
4123 +
4124 + function deviceUrlFunctionEx() {
4125 + meshserver.send({ action: 'msg', type: 'openUrl', nodeid: currentNode._id, url: Q('d2devurl').value });
4126 + }
4127 +
4128 + function deviceToastFunction() {
4129 + if (xxdialogMode) return;
4130 + setDialogMode(2, "Device Notification", 3, deviceToastFunctionEx, '<textarea id=d2devToast style=width:100%;height:80px;resize:none;overflow-y:scroll></textarea>');
4131 + }
4132 +
4133 + function deviceToastFunctionEx() {
4134 + meshserver.send({ action: 'toast', nodeids: [ currentNode._id ], title: 'MeshCentral', msg: Q('d2devToast').value });
4135 + }
4136 +
4137 + function deviceActionFunction() {
4138 + if (xxdialogMode) return;
4139 + var meshrights = meshes[currentNode.meshid].links[userinfo._id].rights;
4140 + var x = "Select an operation to perform on this device.<br /><br />";
4141 + var y = '<select id=d2deviceop style=float:right;width:250px>';
4142 + if ((meshrights & 64) != 0) { y += '<option value=100>Wake-up</option>'; } // Wake-up permission
4143 + if ((meshrights & 8) != 0) { y += '<option value=4>Sleep</option><option value=3>Reset</option><option value=2>Power off</option>'; } // Remote control permission
4144 + y += '</select>';
4145 + x += addHtmlValue('Operation', y);
4146 + setDialogMode(2, "Device Action", 3, deviceActionFunctionEx, x);
4147 + }
4148 +
4149 + function deviceActionFunctionEx() {
4150 + var op = Q('d2deviceop').value;
4151 + if (op == 100) {
4152 + // Device wake
4153 + meshserver.send({ action: 'wakedevices', nodeids: [ currentNode._id ] });
4154 + } else {
4155 + // Power operation
4156 + meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: op });
4157 + }
4158 + }
4159 +
4160 + // Called when MeshCommander needs new credentials or updated credentials.
4161 + function updateAmtCredentials(forceDialog) {
4162 + var node = getNodeFromId(currentNode._id);
4163 + if ((forceDialog == true) || (node.intelamt.user == null) || (node.intelamt.user == '')) {
4164 + editDeviceAmtSettings(currentNode._id, updateAmtCredentialsEx);
4165 + } else {
4166 + Q('p14iframe').contentWindow.connectButtonfunctionEx();
4167 + }
4168 + }
4169 +
4170 + function updateAmtCredentialsEx(button, tag) {
4171 + Q('p14iframe').contentWindow.connectButtonfunctionEx();
4172 + }
4173 +
4174 + // Look to see if we need to update the device timeline
4175 + function updateDeviceTimeline() {
4176 + if ((meshserver.State != 2) || (powerTimelineNode == null) || (powerTimelineUpdate == null) || (currentNode == null)) return;
4177 + if ((powerTimelineNode == powerTimelineReq) && (currentNode._id == powerTimelineNode) && (powerTimelineUpdate < Date.now())) {
4178 + powerTimelineUpdate = null;
4179 + meshserver.send({ action: 'powertimeline', nodeid: currentNode._id });
4180 + meshserver.send({ action: 'lastconnect', nodeid: currentNode._id });
4181 + }
4182 + }
4183 +
4184 + // Draw device power bars. The bars are 766px wide.
4185 + function drawDeviceTimeline() {
4186 + if ((currentNode == null) || (xxcurrentView < 10) || (xxcurrentView > 19)) return;
4187 + var timeline = null, now = Date.now();
4188 + if (currentNode._id == powerTimelineNode) { timeline = powerTimeline; }
4189 +
4190 + // Calculate when the timeline starts
4191 + var d = new Date();
4192 + d.setHours(0, 0, 0, 0);
4193 + d = new Date(d.getTime() - (1000 * 60 * 60 * 24 * 6));
4194 + var timelineStart = d.getTime();
4195 +
4196 + // De-compact the timeline
4197 + var timeline2 = [];
4198 + if (timeline != null && timeline.length > 1) {
4199 + timeline2.push([ 0, timeline[1], timeline[0] ]); // Start, End, Power
4200 + var ct = timeline[1];
4201 + for (var i = 2; i < timeline.length; i += 2) {
4202 + var power = timeline[i], dt = now;
4203 + if (timeline.length > (i + 1)) { dt = timeline[i + 1]; }
4204 + timeline2.push([ ct, ct + dt, power ]); // Start, End, Power
4205 + ct = ct + dt;
4206 + }
4207 + }
4208 +
4209 + // Draw the timeline
4210 + var x = '', count = 1, date = new Date();
4211 + var totalWidth = Q('masthead').offsetWidth - (160 + 9 + 9 + 14); // Compute the total width of the power bar
4212 + date.setHours(0, 0, 0, 0);
4213 + for (var i = 0; i < 7; i++) {
4214 + var datavalue = '', start = date.getTime(), end = start + (1000 * 60 * 60 * 24);
4215 + for (var j in timeline2) {
4216 + var block = timeline2[j];
4217 + if (isTimeBlockInside(start, end, block[0], block[1]) == true) {
4218 + var ts = Math.max(start, block[0]);
4219 + var te = Math.min(Math.min(end, block[1]), now);
4220 + var width = Math.round(((te - ts) * totalWidth) / 86400000);
4221 + if (width > 0) {
4222 + var title = powerStateStrings2[block[2]] + ' from ' + printTime(new Date(ts)) + ' to ' + printTime(new Date(te)) + '.';
4223 + datavalue += '<div class="pwState ' + powerColor(block[2]) + '" title="' + title + '" style="width:' + width + 'px;"></div>';
4224 + }
4225 + }
4226 + }
4227 + x += '<tr class=' + (((count % 2) == 0)?'altBack':'') + '><td><div>&nbsp;' + printDate(date) + '<div></div></div></td><td><div>' + datavalue + '</div></td></tr>';
4228 + ++count;
4229 + date = new Date(date.getTime() - (1000 * 60 * 60 * 24)); // Substract one day
4230 + }
4231 + QH('p10html2', '<table cellpadding=2 cellspacing=0><thead><tr style=><th scope=col style=text-align:center;width:150px>Day</th><th scope=col style=text-align:center><a download href="devicepowerevents.ashx?id=' + currentNode._id + '" onclick="setDialogMode(0)"><img title="Download power events" src="images/link4.png" /></a>7 Day Power State</th></tr></thead><tbody>' + x + '</tbody></table>');
4232 + }
4233 +
4234 + // Return a color for the given power state
4235 + function powerColor(x) { if (x < powerColorTable.length) { return powerColorTable[x]; } return 'pwsYellow'; }
4236 +
4237 + // Return true if the time block is visible within the start/end period
4238 + function isTimeBlockInside(start, end, blockStart, blockEnd) {
4239 + if ((blockStart < start) && (blockEnd > end)) return true; // Block is wider than timespan
4240 + if ((blockStart > start) && (blockStart < end)) return true;
4241 + if ((blockEnd > start) && (blockEnd < end)) return true;
4242 + return false;
4243 + }
4244 +
4245 + function addDeviceAttribute(name, value) { return '<tr><td class=style7>' + name + '</td><td class=style9>' + value + '</td></tr>'; }
4246 +
4247 + function editDeviceAmtSettings(nodeid, func, arg) {
4248 + if (xxdialogMode) return;
4249 + var x = '', node = getNodeFromId(nodeid), buttons = 3, meshrights = getNodeRights(nodeid);
4250 + if ((meshrights & 4) == 0) return;
4251 + x += addHtmlValue('Username', '<input id=dp10username style=width:230px maxlength=32 autocomplete=nope placeholder="admin" onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />');
4252 + x += addHtmlValue('Password', '<input id=dp10password type=password style=width:230px autocomplete=nope maxlength=32 onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />');
4253 + x += addHtmlValue('Security', '<select id=dp10tls style=width:236px><option value=0>No TLS security</option><option value=1>TLS security required</option></select>');
4254 + if ((node.intelamt.user != null) && (node.intelamt.user != '')) { buttons = 7; }
4255 + setDialogMode(2, "Edit Intel&reg; AMT credentials", buttons, editDeviceAmtSettingsEx, x, { node: node, func: func, arg: arg });
4256 + if ((node.intelamt.user != null) && (node.intelamt.user != '')) { Q('dp10username').value = node.intelamt.user; } else { Q('dp10username').value = 'admin'; }
4257 + Q('dp10tls').value = node.intelamt.tls;
4258 + validateDeviceAmtSettings();
4259 + }
4260 +
4261 + function validateDeviceAmtSettings() {
4262 + QE('idx_dlgOkButton', passwordcheck(Q('dp10password').value));
4263 + }
4264 +
4265 + function editDeviceAmtSettingsEx(button, tag) {
4266 + if (button == 2) {
4267 + // Delete button pressed, remove credentials
4268 + meshserver.send({ action: 'changedevice', nodeid: tag.node._id, intelamt: { user: '', pass: '' } });
4269 + } else {
4270 + // Change Intel AMT credentials
4271 + var amtuser = Q('dp10username').value;
4272 + if (amtuser == '') amtuser = 'admin';
4273 + var amtpass = Q('dp10password').value;
4274 + if (amtpass == '') amtuser = '';
4275 + meshserver.send({ action: 'changedevice', nodeid: tag.node._id, intelamt: { user: amtuser, pass: amtpass, tls: Q('dp10tls').value } });
4276 + tag.node.intelamt.user = amtuser;
4277 + tag.node.intelamt.tls = Q('dp10tls').value;
4278 + if (tag.func) { setTimeout(function () { tag.func(null, tag.arg); }, 300); }
4279 + }
4280 + }
4281 +
4282 + function p10showChangeGroupDialog(nodeids) {
4283 + if (xxdialogMode) return false;
4284 + var targetMeshId = null;
4285 + if (nodeids.length == 1) { try { targetMeshId = meshes[getNodeFromId(nodeids[0])]._id; } catch (ex) { } }
4286 +
4287 + // List all available alternative groups
4288 + var y = "<select id=p10newGroup style=width:236px>", count = 0;
4289 + for (var i in meshes) {
4290 + var meshrights = meshes[i].links[userinfo._id].rights;
4291 + if ((meshes[i]._id != targetMeshId) && (meshrights & 4)) { count++; y += "<option value='" + meshes[i]._id + "'>" + meshes[i].name + "</option>"; }
4292 + }
4293 + y += "</select>";
4294 +
4295 + if (count > 0) {
4296 + var x = (nodeids.length == 1) ? "Select a new group for this device<br /><br />" : "Select a new group for selected devices<br /><br />";
4297 + x += addHtmlValue('New Device Group', y);
4298 + setDialogMode(2, "Change Group", 3, p10showChangeGroupDialogEx, x, nodeids);
4299 + } else {
4300 + setDialogMode(2, "Change Group", 1, null, "No other device group of same type exists.");
4301 + }
4302 + return false;
4303 + }
4304 +
4305 + function p10showChangeGroupDialogEx(b, nodeids) {
4306 + meshserver.send({ action: 'changeDeviceMesh', nodeids: nodeids, meshid: Q('p10newGroup').value });
4307 + }
4308 +
4309 + function p10showDeleteNodeDialog(nodeid) {
4310 + if (xxdialogMode) return false;
4311 + var x = "Are you sure you want to delete node \"" + EscapeHtml(currentNode.name) + "\"?<br /><br />";
4312 + x += "<label><input id=p10check type=checkbox onchange=p10validateDeleteNodeDialog() />Confirm</label>";
4313 + setDialogMode(2, "Delete Node", 3, p10showDeleteNodeDialogEx, x, nodeid);
4314 + p10validateDeleteNodeDialog();
4315 + return false;
4316 + }
4317 +
4318 + function p10validateDeleteNodeDialog() {
4319 + QE('idx_dlgOkButton', Q('p10check').checked);
4320 + }
4321 +
4322 + function p10showDeleteNodeDialogEx(buttons, nodeid) {
4323 + meshserver.send({ action: 'removedevices', nodeids: [ nodeid ] });
4324 + }
4325 +
4326 + function p10clickOnce(nodeid, protocol, port) {
4327 + meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, tag: 'clickonce', protocol: protocol });
4328 + return false;
4329 + }
4330 +
4331 + // Show current location
4332 + var d2map = null;
4333 + function p10showNodeLocationDialog() {
4334 + if ((xxdialogMode != null) && (xxdialogTag == '@xxmap')) { setDialogMode(0); } else { if (xxdialogMode) return false; }
4335 + var markers = [], types = ['iploc', 'wifiloc', 'gpsloc', 'userloc'], boundingBox = null;
4336 +
4337 + for (var loctype in types) {
4338 + if (currentNode[types[loctype]] != null) {
4339 + var loc = currentNode[types[loctype]].split(','), lat = parseFloat(loc[0]), lon = parseFloat(loc[1]);
4340 + if ((lat < 90) && (lat > -90) && (lon < 180) && (lon > -180)) { // Check valid lat/lon
4341 + var deviceMark = new ol.Feature({ geometry: new ol.geom.Point(ol.proj.fromLonLat([lon, lat])) });
4342 + deviceMark.setStyle(markerStyle(currentNode, parseInt(loctype) + 1));
4343 + markers.push(deviceMark);
4344 +
4345 + if (boundingBox == null) { boundingBox = [ lat, lon, lat, lon, 0 ]; } else { if (lat < boundingBox[0]) { boundingBox[0] = lat; } if (lon < boundingBox[1]) { boundingBox[1] = lon; } if (lat > boundingBox[2]) { boundingBox[2] = lat; } if (lon > boundingBox[3]) { boundingBox[3] = lon; } }
4346 + }
4347 + }
4348 + }
4349 +
4350 + // Setup the device mark layer
4351 + var vectorSource = new ol.source.Vector({ features: markers });
4352 + var vectorLayer = new ol.layer.Vector({ source: vectorSource });
4353 +
4354 + //var x = '<div><a href="https://www.google.com/maps/preview/@' + lat + ',' + lng + ',12z" rel="noreferrer noopener" target=_blank>Open in Google maps</a></div>';
4355 + var x = '<div id=d2map style=width:100%;height:300px></div>';
4356 + setDialogMode(2, "Device Location", 1, null, x, '@xxmap');
4357 +
4358 + var clng = 0, clat = 0, zoom = 8;
4359 + if (boundingBox != null) {
4360 + var clat = (boundingBox[0] + boundingBox[2]) / 2;
4361 + var clng = (boundingBox[1] + boundingBox[3]) / 2;
4362 + var cscale = Math.max(Math.abs(boundingBox[0] - boundingBox[2]), Math.abs(boundingBox[1] - boundingBox[3]));
4363 + var i = 360, zoom = -2;
4364 + while (i > cscale) { zoom++; i = i / 2; }
4365 + }
4366 +
4367 + if (markers.length == 1) { zoom = 8; }
4368 +
4369 + // Setup the map
4370 + d2map = new ol.Map({
4371 + target: 'd2map',
4372 + interactions: ol.interaction.defaults({dragPan:false, mouseWheelZoom:false}),
4373 + layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }), vectorLayer ],
4374 + view: new ol.View({ center: ol.proj.fromLonLat([clng, clat]), zoom: zoom })
4375 + });
4376 + return false;
4377 + }
4378 +
4379 + // Show network interfaces
4380 + function p10showNodeNetInfoDialog() {
4381 + if (xxdialogMode) return false;
4382 + setDialogMode(2, "Network Interfaces", 1, null, "<div id=d2netinfo>Loading...</div>", 'if' + currentNode._id );
4383 + meshserver.send({ action: 'getnetworkinfo', nodeid: currentNode._id });
4384 + return false;
4385 + }
4386 +
4387 + // Show MeshCentral Router dialog
4388 + function p10showMeshRouterDialog() {
4389 + if (xxdialogMode) return;
4390 + var x = "<div>MeshCentral Router is a Windows tool for TCP port mapping. You can, for example, RDP into a remote device thru this server.</div><br />";
4391 + x += addHtmlValue('Win32 Executable', '<a style=cursor:pointer download href="meshagents?meshaction=winrouter" onclick="setDialogMode(0)">MeshCentralRouter.exe</a>');
4392 + setDialogMode(2, "MeshCentral Router", 1, null, x, "fileDownload");
4393 + }
4394 +
4395 + // Show MeshCmd dialog
4396 + function p10showMeshCmdDialog(mode, nodeid) {
4397 + if (xxdialogMode) return;
4398 + var y = "<select id=aginsSelect onclick=meshCmdOsClick() style=width:236px>";
4399 + y += "<option value=3>Windows (32bit)</option>";
4400 + y += "<option value=4>Windows (64bit)</option>";
4401 + y += "<option value=5>Linux x86 (32bit)</option>";
4402 + y += "<option value=6>Linux x86 (64bit)</option>";
4403 + y += "<option value=16>MacOS (64bit)</option>";
4404 + y += "<option value=25>Linux ARM, Raspberry Pi (32bit)</option>";
4405 + y += "</select>";
4406 +
4407 + var x = "";
4408 + if (mode == 0) { x += '<div>MeshCmd is a command line tool that performs lots of different operations. The action file can optionally be downloaded and edited to provide server information and credentials.<br /><br />'; }
4409 + if (mode == 1) { x += '<div>Download "meshcmd" with an action file to route traffic thru this server to this device. Make sure to edit meshaction.txt and add your account password or make any changes needed.<br /><br />'; }
4410 + x += addHtmlValue('Operating System', y);
4411 + x += addHtmlValue('MeshCmd', '<a id=meshcmddownloadid href="meshagents?meshcmd=3" download></a>');
4412 + if (mode == 0) { x += addHtmlValue('Action File', '<a href="meshagents?meshaction=generic" download>MeshAction (.txt)</a>'); }
4413 + if (mode == 1) { x += addHtmlValue('Action File', '<a href="meshagents?meshaction=route&nodeid=' + nodeid + '" download>MeshAction (.txt)</a>'); }
4414 + x += "</div>";
4415 + setDialogMode(2, ["Download MeshCmd","Network Router"][mode], 9, null, x, "fileDownload");
4416 + meshCmdOsClick();
4417 + }
4418 +
4419 + function meshCmdOsClick() {
4420 + var os = Q('aginsSelect').value, osn = '', osurl = '';
4421 + //Q('meshcmddownloadid').href = "meshagents?meshcmd=" + os;
4422 + if (os == 3) { osn = 'MeshCmd (Win32 executable)'; }
4423 + if (os == 4) { osn = 'MeshCmd (Win64 executable)'; }
4424 + if (os == 5) { osn = 'MeshCmd (Linux x86, 32bit)'; }
4425 + if (os == 6) { osn = 'MeshCmd (Linux x86, 64bit)'; }
4426 + if (os == 16) { osn = 'MeshCmd (MacOS, 64bit)'; }
4427 + if (os == 25) { osn = 'MeshCmd (Linux ARM, 32bit)'; }
4428 + QH('meshcmddownloadid', osn);
4429 + Q('meshcmddownloadid').setAttribute('href', 'meshagents?meshcmd=' + os);
4430 + }
4431 +
4432 + function p10showiconselector() {
4433 + if (xxdialogMode) return;
4434 + var mesh = meshes[currentNode.meshid];
4435 + var meshrights = mesh.links[userinfo._id].rights;
4436 + if ((meshrights & 4) == 0) return;
4437 +
4438 + var x = '<br><div style=display:inline-block;width:40px></div>';
4439 + x += '<div tabindex=0 style=display:inline-block class=i1 onclick=p10setIcon(1) onkeypress="if (event.key==\'Enter\') p10setIcon(1)"></div>';
4440 + x += '<div tabindex=0 style=display:inline-block class=i2 onclick=p10setIcon(2) onkeypress="if (event.key==\'Enter\') p10setIcon(2)"></div>';
4441 + x += '<div tabindex=0 style=display:inline-block class=i3 onclick=p10setIcon(3) onkeypress="if (event.key==\'Enter\') p10setIcon(3)"></div>';
4442 + x += '<div tabindex=0 style=display:inline-block class=i4 onclick=p10setIcon(4) onkeypress="if (event.key==\'Enter\') p10setIcon(4)"></div>';
4443 + x += '<div tabindex=0 style=display:inline-block class=i5 onclick=p10setIcon(5) onkeypress="if (event.key==\'Enter\') p10setIcon(5)"></div>';
4444 + x += '<div tabindex=0 style=display:inline-block class=i6 onclick=p10setIcon(6) onkeypress="if (event.key==\'Enter\') p10setIcon(6)"></div><br><br>';
4445 + setDialogMode(2, "Icon Selection", 0, null, x);
4446 + QV('id_dialogclose', true);
4447 + }
4448 +
4449 + function p10setIcon(icon) {
4450 + setDialogMode(0);
4451 + meshserver.send({ action: 'changedevice', nodeid: currentNode._id, icon: icon });
4452 + }
4453 +
4454 + var showEditNodeValueDialog_modes = ['Device Name', 'Hostname', 'Description', 'Tags'];
4455 + var showEditNodeValueDialog_modes2 = ['name', 'host', 'desc', 'tags'];
4456 + var showEditNodeValueDialog_modes3 = ['', '', '', 'Tag1, Tag2, Tag3'];
4457 + function showEditNodeValueDialog(mode) {
4458 + if (xxdialogMode) return;
4459 + var x = addHtmlValue(showEditNodeValueDialog_modes[mode], '<input id=dp10devicevalue maxlength=64 placeholder="' + showEditNodeValueDialog_modes3[mode] + '" onchange=p10editdevicevalueValidate(' + mode + ',event) onkeyup=p10editdevicevalueValidate(' + mode + ',event) />');
4460 + setDialogMode(2, "Edit Device", 3, showEditNodeValueDialogEx, x, mode);
4461 + var v = currentNode[showEditNodeValueDialog_modes2[mode]];
4462 + if (v == null) v = '';
4463 + if (Array.isArray(v)) { v = v.join(', '); }
4464 + Q('dp10devicevalue').value = v;
4465 + p10editdevicevalueValidate();
4466 + Q('dp10devicevalue').focus();
4467 + }
4468 +
4469 + function showEditNodeValueDialogEx(button, mode) {
4470 + var x = { action: 'changedevice', nodeid: currentNode._id };
4471 + x[showEditNodeValueDialog_modes2[mode]] = Q('dp10devicevalue').value;
4472 + meshserver.send(x);
4473 + }
4474 +
4475 + function p10editdevicevalueValidate(mode, e) {
4476 + var x = ((mode > 1) || (Q('dp10devicevalue').value.length > 0));
4477 + QE('idx_dlgOkButton', x);
4478 + if ((e != null) && (x == true) && (e.keyCode == 13)) { dialogclose(1); }
4479 + }
4480 +
4481 + //
4482 + // DESKTOP
4483 + //
4484 +
4485 + var desktopNode;
4486 + function setupDesktop() {
4487 + // Setup the remote desktop
4488 + if ((desktopNode != currentNode) && (desktop != null)) { desktop.Stop(); desktopNode = null; desktop = null; }
4489 +
4490 + // If the device desktop is already connected in multi-desktop, use that.
4491 + if ((desktopNode != currentNode) || (desktop == null)) {
4492 + var xdesk = multiDesktop[currentNode._id];
4493 + if (xdesk != null) {
4494 + // This device already has a canvas, use it.
4495 + QH('DeskParent', '');
4496 + var c = xdesk.m.CanvasId;
4497 + c.setAttribute('id', 'Desk');
4498 + c.setAttribute('onmousedown', 'dmousedown(event)');
4499 + c.setAttribute('onmouseup', 'dmouseup(event)');
4500 + c.setAttribute('onmousemove', 'dmousemove(event)');
4501 + c.removeAttribute('onclick');
4502 + Q('DeskParent').appendChild(c);
4503 + desktop = xdesk;
4504 + if (desktop.m.SendCompressionLevel) { desktop.m.SendCompressionLevel(1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); }
4505 + desktop.onStateChanged = onDesktopStateChange;
4506 + desktopNode = currentNode;
4507 + onDesktopStateChange(desktop, desktop.State);
4508 + delete multiDesktop[currentNode._id];
4509 + } else {
4510 + // Device is not already connected, just setup a blank canvas
4511 + QH('DeskParent', '<canvas id=Desk oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>');
4512 + desktopNode = currentNode;
4513 + }
4514 + // Setup the mouse wheel
4515 + Q('Desk').addEventListener('DOMMouseScroll', function (e) { return dmousewheel(e); });
4516 + Q('Desk').addEventListener('mousewheel', function (e) { return dmousewheel(e); });
4517 + }
4518 + desktopNode = currentNode;
4519 + updateDesktopButtons();
4520 + deskAdjust();
4521 +
4522 + // On some browsers like IE, we can't save screen shots. Hide the scheenshot/capture buttons.
4523 + if (!Q('Desk')['toBlob']) { QV('deskSaveBtn', false); }
4524 + }
4525 +
4526 + // Show and enable the right buttons
4527 + function updateDesktopButtons() {
4528 + var mesh = meshes[currentNode.meshid];
4529 + var deskState = 0;
4530 + if (desktop != null) { deskState = desktop.State; }
4531 + var meshrights = mesh.links[userinfo._id].rights;
4532 +
4533 + // Show the right buttons
4534 + QV('disconnectbutton1span', (deskState != 0));
4535 + QV('connectbutton1span', (deskState == 0) && ((meshrights & 8) || (meshrights & 256)) && (mesh.mtype == 2) && (currentNode.agent.caps & 1));
4536 + QV('connectbutton1hspan', (deskState == 0) && (meshrights & 8) && ((currentNode.intelamt != null) && (mesh.mtype == 1 || currentNode.intelamt.state == 2) && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))));
4537 +
4538 + // Show the right settings
4539 + QV('d7amtkvm', (currentNode.intelamt != null && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))) && ((deskState == 0) || (desktop.contype == 2)));
4540 + QV('d7meshkvm', (webRtcDesktop) || ((mesh.mtype == 2) && (currentNode.agent.caps & 1) && ((deskState == false) || (desktop.contype == 1))));
4541 +
4542 + // Enable buttons
4543 + var inputAllowed = (meshrights == 0xFFFFFFFF) || (((meshrights & 8) != 0) && ((meshrights & 256) == 0) && ((meshrights & 4096) == 0));
4544 + var online = ((currentNode.conn & 1) != 0); // If Agent (1) connected, enable remote desktop
4545 + QE('connectbutton1', online);
4546 + var hwonline = ((currentNode.conn & 6) != 0); // If CIRA (2) or AMT (4) connected, enable hardware terminal
4547 + QE('connectbutton1h', hwonline);
4548 + QE('deskSaveBtn', deskState == 3);
4549 + QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (deskState != 0) && (desktopsettings.showfocus));
4550 + QV('DeskClip', (currentNode.agent) && (currentNode.agent.id != 11) && (currentNode.agent.id != 16) && ((desktop == null) || (desktop.contype != 2))); // Clipboard not supported on MacOS
4551 + QE('DeskClip', deskState == 3);
4552 + QV('DeskWD', (currentNode.agent) && (currentNode.agent.id < 5) && inputAllowed);
4553 + QE('DeskWD', deskState == 3);
4554 + QV('deskkeys', (currentNode.agent) && (currentNode.agent.id < 5) && inputAllowed);
4555 + QE('deskkeys', deskState == 3);
4556 +
4557 + QV('DeskToolsButton', (inputAllowed) && (mesh.mtype == 2) && online);
4558 + QV('DeskChatButton', (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online);
4559 + QV('DeskNotifyButton', (browserfullscreen == false) && (currentNode.agent) && (currentNode.agent.id < 5) && (inputAllowed) && (mesh.mtype == 2) && online);
4560 + QV('DeskOpenWebButton', (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online);
4561 +
4562 + QV('DeskControlSpan', inputAllowed)
4563 + QV('deskActionsBtn', (browserfullscreen == false));
4564 + QV('deskActionsSettings', (browserfullscreen == false));
4565 + if (meshrights & 8) { Q('DeskControl').checked = (getstore('DeskControl', 1) == 1); } else { Q('DeskControl').checked = false; }
4566 + if (online == false) QV('DeskTools', false);
4567 + }
4568 +
4569 + // Debug
4570 + var autoConnectDesktopTimer = null;
4571 + function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(connectDesktop, 100); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } }
4572 +
4573 + function connectDesktop(e, contype) {
4574 + p11clearConsoleMsg();
4575 + if (desktop == null) {
4576 + desktopNode = currentNode;
4577 + if (contype == 2) {
4578 + // Setup the Intel AMT remote desktop
4579 + if ((desktopNode.intelamt.user == null) || (desktopNode.intelamt.user == '')) { editDeviceAmtSettings(desktopNode._id, connectDesktop, 2); return; }
4580 + desktop = CreateAmtRedirect(CreateAmtRemoteDesktop('Desk'), authCookie);
4581 + desktop.debugmode = debugmode;
4582 + desktop.onStateChanged = onDesktopStateChange;
4583 + desktop.m.bpp = (desktopsettings.encoding == 1 || desktopsettings.encoding == 3) ? 1 : 2;
4584 + desktop.m.useZRLE = (desktopsettings.encoding < 3);
4585 + desktop.m.localKeyMap = desktopsettings.localkeymap;
4586 + desktop.m.showmouse = desktopsettings.showmouse;
4587 + desktop.m.onScreenSizeChange = deskAdjust;
4588 + desktop.m.onKvmData = function (x) {
4589 + //console.log('onKvmData (' + x.length + '): ' + x);
4590 + // Send the presense probe only once if needed.
4591 + if (x.length == 0) { if (!desktop.m._sentPresence) { desktop.m._sentPresence = true; desktop.m.sendKvmData(JSON.stringify({ action: 'present', ver: 1 })); } return; }
4592 + var data = null;
4593 + try { data = JSON.parse(x); } catch (e) { }
4594 + if ((data != null) && (data.action != null)) {
4595 + if (data.action == 'restart') {
4596 + // Clear WebRTC channel
4597 + webRtcDesktopReset();
4598 + desktop.m.sendKvmData(JSON.stringify({ action: 'present', ver: 1 }));
4599 + } else if ((data.action == 'present') && (webRtcDesktop == null)) {
4600 + // Setup WebRTC channel
4601 + webRtcDesktop = { platform: data.platform };
4602 + var configuration = null; //{ "iceServers": [ { 'urls': 'stun:stun.services.mozilla.com' }, { 'urls': 'stun:stun.l.google.com:19302' } ] };
4603 + if (typeof RTCPeerConnection !== 'undefined') { webRtcDesktop.webrtc = new RTCPeerConnection(configuration); }
4604 + else if (typeof webkitRTCPeerConnection !== 'undefined') { webRtcDesktop.webrtc = new webkitRTCPeerConnection(configuration); }
4605 +
4606 + webRtcDesktop.webchannel = webRtcDesktop.webrtc.createDataChannel("DataChannel", {}); // { ordered: false, maxRetransmits: 2 }
4607 + webRtcDesktop.webchannel.onopen = function () {
4608 + // Switch to software KVM
4609 + //if (urlvars && urlvars['kvmdatatrace']) { console.log('WebRTC Data Channel Open'); }
4610 + console.log('WebRTC Data Channel Open');
4611 + Q('deskstatus').textContent = StatusStrs[desktop.State] + ', Soft-KVM';
4612 + desktop.m.hold(true);
4613 + webRtcDesktop.webRtcActive = true;
4614 + webRtcDesktop.softdesktop = CreateKvmDataChannel(webRtcDesktop.webchannel, CreateAgentRemoteDesktop('Desk', Q('id_mainarea')), desktop.m);
4615 + webRtcDesktop.softdesktop.m.setRotation(desktop.m.rotation);
4616 + webRtcDesktop.softdesktop.m.onScreenSizeChange = deskAdjust;
4617 + if (desktopsettings.quality) { webRtcDesktop.softdesktop.m.CompressionLevel = desktopsettings.quality; } // Number from 1 to 100. 50 or less is best.
4618 + if (desktopsettings.scaling) { webRtcDesktop.softdesktop.m.ScalingLevel = desktopsettings.scaling; }
4619 + webRtcDesktop.softdesktop.Start();
4620 +
4621 + // Check if we can get remote file access
4622 + // ###BEGIN###{DesktopInbandFiles}
4623 + /*
4624 + QV('go24', true); // Files
4625 + downloadFile = null;
4626 + p24files = webRtcDesktop.softdesktop;
4627 + p24targetpath = '';
4628 + webRtcDesktop.softdesktop.onControlMsg = onFilesControlData;
4629 + webRtcDesktop.softdesktop.sendCtrlMsg(JSON.stringify({ action: 'ls', reqid: 1, path: '' })); // Ask for the root folder
4630 + */
4631 + // ###END###{DesktopInbandFiles}
4632 + }
4633 + webRtcDesktop.webchannel.onclose = function (event) {
4634 + //if (urlvars['kvmdatatrace']) { console.log('WebRTC Data Channel Closed'); }
4635 + console.log('WebRTC Data Channel Closed');
4636 + webRtcDesktopReset();
4637 + }
4638 + webRtcDesktop.webrtc.onicecandidate = function (e) {
4639 + if (e.candidate == null) {
4640 + desktop.m.sendKvmData(JSON.stringify({ action: 'offer', ver: 1, sdp: webRtcDesktop.webrtcoffer.sdp }));
4641 + } else {
4642 + webRtcDesktop.webrtcoffer.sdp += ("a=" + e.candidate.candidate + "\r\n"); // New candidate, add it to the SDP
4643 + }
4644 + }
4645 + webRtcDesktop.webrtc.oniceconnectionstatechange = function () {
4646 + if ((webRtcDesktop != null) && (webRtcDesktop.webrtc != null) && ((webRtcDesktop.webrtc.iceConnectionState == 'disconnected') || (webRtcDesktop.webrtc.iceConnectionState == 'failed'))) { /*console.log('WebRTC ICE Failed');*/ webRtcDesktopReset(); }
4647 + }
4648 + webRtcDesktop.webrtc.createOffer(function (offer) {
4649 + // Got the offer
4650 + webRtcDesktop.webrtcoffer = offer;
4651 + webRtcDesktop.webrtc.setLocalDescription(offer, function () { }, webRtcDesktopReset);
4652 + }, webRtcDesktopReset, { mandatory: { OfferToReceiveAudio: false, OfferToReceiveVideo: false } });
4653 + } else if ((data.action == 'answer') && (webRtcDesktop != null)) {
4654 + // Complete the WebRTC channel
4655 + webRtcDesktop.webrtc.setRemoteDescription(new RTCSessionDescription({ type: 'answer', sdp: data.sdp }), function () { }, webRtcDesktopReset);
4656 + }
4657 + }
4658 + };
4659 + desktop.Start(desktopNode._id, 16994, '*', '*', 0);
4660 + desktop.contype = 2;
4661 + } else {
4662 + // Setup the Mesh Agent remote desktop
4663 + desktop = CreateAgentRedirect(meshserver, CreateAgentRemoteDesktop('Desk'), serverPublicNamePort, authCookie, domainUrl);
4664 + desktop.debugmode = debugmode;
4665 + desktop.m.debugmode = debugmode;
4666 + desktop.attemptWebRTC = attemptWebRTC;
4667 + desktop.onStateChanged = onDesktopStateChange;
4668 + desktop.onConsoleMessageChange = function () {
4669 + p11clearConsoleMsg();
4670 + if (desktop.consoleMessage) {
4671 + QH('p11DeskConsoleMsg', EscapeHtml(desktop.consoleMessage).split('\n').join('<br />'));
4672 + QV('p11DeskConsoleMsg', true);
4673 + p11DeskConsoleMsgTimer = setTimeout(p11clearConsoleMsg, 8000);
4674 + }
4675 + }
4676 + desktop.m.CompressionLevel = desktopsettings.quality; // Number from 1 to 100. 50 or less is best.
4677 + desktop.m.ScalingLevel = desktopsettings.scaling;
4678 + desktop.m.FrameRateTimer = desktopsettings.framerate;
4679 + desktop.m.onDisplayinfo = deskDisplayInfo;
4680 + desktop.m.onScreenSizeChange = deskAdjust;
4681 + desktop.Start(desktopNode._id);
4682 + desktop.contype = 1;
4683 + }
4684 + } else {
4685 + // Disconnect and clean up the remote desktop
4686 + desktop.Stop();
4687 + webRtcDesktopReset();
4688 + desktopNode = desktop = null;
4689 + }
4690 + }
4691 +
4692 + function p11clearConsoleMsg() { QV('p11DeskConsoleMsg', false); if (p11DeskConsoleMsgTimer) { clearTimeout(p11DeskConsoleMsgTimer); p11DeskConsoleMsgTimer = null; } }
4693 + function p12clearConsoleMsg() { QV('p12TermConsoleMsg', false); if (p12TermConsoleMsgTimer) { clearTimeout(p12TermConsoleMsgTimer); p12TermConsoleMsgTimer = null; } }
4694 + function p13clearConsoleMsg() { QV('p13FilesConsoleMsg', false); if (p13FilesConsoleMsgTimer) { clearTimeout(p13FilesConsoleMsgTimer); p13FilesConsoleMsgTimer = null; } }
4695 +
4696 + var webRtcDesktop = null;
4697 + function webRtcDesktopReset() {
4698 + if (webRtcDesktop == null) return;
4699 + if (webRtcDesktop.softdesktop != null) { webRtcDesktop.softdesktop.Stop(); webRtcDesktop.softdesktop = null; }
4700 + if (webRtcDesktop.webchannel != null) { try { webRtcDesktop.webchannel.close(); } catch (e) { } webRtcDesktop.webchannel = null; }
4701 + if (webRtcDesktop.webrtc != null) { try { webRtcDesktop.webrtc.close(); } catch (e) { } webRtcDesktop.webrtc = null; }
4702 + webRtcDesktop = null;
4703 + // Switch back to hardware KVM
4704 + if (desktop && desktop.m) {
4705 + desktop.m.hold(false);
4706 + Q('deskstatus').textContent = StatusStrs[desktop.State];
4707 + }
4708 + // ###BEGIN###{DesktopInbandFiles}
4709 + /*
4710 + p24files = null;
4711 + p24downloadFileCancel() // If any downloads are in process, cancel them.
4712 + p24uploadFileCancel(); // If any uploads are in process, cancel them.
4713 + QV('go24', false); // Files
4714 + if (currentView == 24) { go(14); }
4715 + */
4716 + // ###END###{DesktopInbandFiles}
4717 + }
4718 +
4719 + function onDesktopStateChange(xdesktop, state) {
4720 + var xstate = state;
4721 + if ((xstate == 3) && (xdesktop.contype == 2)) { xstate++; }
4722 + var str = StatusStrs[xstate];
4723 + if ((desktop != null) && (desktop.webRtcActive == true)) { str += ', WebRTC'; }
4724 + //if (desktop.m.stopInput == true) { str += ', Loopback'; }
4725 + QH('deskstatus', str);
4726 + switch (state) {
4727 + case 0:
4728 + // Disconnect and clean up the remote desktop
4729 + desktop.Stop();
4730 + desktopNode = desktop = null;
4731 + QV('DeskFocus', false);
4732 + QV('termdisplays', false);
4733 + deskFocusBtn.value = 'All Focus';
4734 + if (fullscreen == true) { deskToggleFull(); }
4735 + webRtcDesktopReset();
4736 + deskPreferedStickyDisplay = 0;
4737 + break;
4738 + case 2:
4739 + break;
4740 + default:
4741 + //console.log('Unknown onDesktopStateChange state', state);
4742 + break;
4743 + }
4744 + updateDesktopButtons();
4745 + deskAdjust();
4746 + setTimeout(deskAdjust, 50);
4747 + }
4748 +
4749 + function showDesktopSettings() {
4750 + if (xxdialogMode) return;
4751 + applyDesktopSettings();
4752 + updateDesktopButtons();
4753 + setDialogMode(7, "Remote Desktop Settings", 3, showDesktopSettingsChanged);
4754 + }
4755 +
4756 + function showDesktopSettingsChanged() {
4757 + desktopsettings.encoding = d7desktopmode.value;
4758 + desktopsettings.showfocus = d7showfocus.checked;
4759 + desktopsettings.showmouse = d7showcursor.checked;
4760 + desktopsettings.quality = d7bitmapquality.value;
4761 + desktopsettings.scaling = d7bitmapscaling.value;
4762 + desktopsettings.framerate = d7framelimiter.value;
4763 + desktopsettings.localkeymap = d7localKeyMap.checked;
4764 + localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings));
4765 + applyDesktopSettings();
4766 + if (desktop) {
4767 + if (desktop.contype == 1) {
4768 + if (desktop.State != 0) {
4769 + desktop.m.SendCompressionLevel(1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate);
4770 + }
4771 + }
4772 + if (desktop.contype == 2) {
4773 + if (desktopsettings.showfocus == false) { desktop.m.focusmode = 0; deskFocusBtn.value = 'All Focus'; }
4774 + if (desktop.State != 0) { desktop.Stop(); setTimeout(function () { connectDesktop(null, 2); }, 50); }
4775 + }
4776 + }
4777 + }
4778 +
4779 + function applyDesktopSettings() {
4780 + var r = '', ops = (features & 512)?[90,80,70,60,50,40,30,20,10,5,1]:[60,50,40,30,20,10,5,1];
4781 + for (var i in ops) { r += '<option value=' + ops[i] + '>' + ops[i] + '%</option>'; }
4782 + QH('d7bitmapquality', r);
4783 + d7desktopmode.value = desktopsettings.encoding;
4784 + d7showfocus.checked = desktopsettings.showfocus;
4785 + d7showcursor.checked = desktopsettings.showmouse;
4786 + d7bitmapquality.value = 40; // Default value
4787 + if (ops.indexOf(parseInt(desktopsettings.quality)) >= 0) { d7bitmapquality.value = desktopsettings.quality; }
4788 + d7bitmapscaling.value = desktopsettings.scaling;
4789 + if (desktopsettings.framerate) { d7framelimiter.value = desktopsettings.framerate; }
4790 + if (desktopsettings.localkeymap) { d7localKeyMap.checked = desktopsettings.localkeymap; }
4791 + QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (desktop.state != 0) && (desktopsettings.showfocus));
4792 + }
4793 +
4794 + // Enter browser fullscreen
4795 + function enterBrowserFullscreen(elem) {
4796 + if (elem.requestFullscreen) { elem.requestFullscreen(); }
4797 + else if (elem.msRequestFullscreen) { elem.msRequestFullscreen(); }
4798 + else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); }
4799 + else if (elem.webkitRequestFullscreen) { elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); }
4800 + }
4801 +
4802 + // Exit browser fullscreen
4803 + function exitBrowserFullscreen() {
4804 + if (document.exitFullscreen) { document.exitFullscreen(); }
4805 + else if (document.msExitFullscreen) { document.msExitFullscreen(); }
4806 + else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); }
4807 + else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); }
4808 + }
4809 +
4810 + // Return true if the browser is fullscreen. This is a delayed method that will return true/false late. Not very useful.
4811 + function isBrowserFullscreen() {
4812 + if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) { return false; } else { return true; }
4813 + }
4814 +
4815 + var fullscreen = false;
4816 + var browserfullscreen = false;
4817 + function deskToggleFull(e) {
4818 + fullscreen = !fullscreen;
4819 + if (fullscreen) {
4820 + QC('body').add("fulldesk");
4821 + //QS('deskarea3x').height = null;
4822 + // If shift is pressed, enter browser full screen.
4823 + if (e.shiftKey == true) { enterBrowserFullscreen(Q('deskarea0')); browserfullscreen = true; }
4824 + } else {
4825 + QC('body').remove("fulldesk");
4826 + exitBrowserFullscreen();
4827 + browserfullscreen = false;
4828 + toggleFullScreen();
4829 + }
4830 + deskAdjust();
4831 + //deskAdjust();
4832 + updateDesktopButtons();
4833 + }
4834 +
4835 + function deskToggleFocus() {
4836 + desktop.m.focusmode = (desktop.m.focusmode + 64) % 192;
4837 + Q('deskFocusBtn').value = ['All Focus', 'Small Focus', 'Large Focus'][desktop.m.focusmode / 64];
4838 + }
4839 +
4840 + function deskAdjust() {
4841 + var parentH = Q('DeskParent').clientHeight, parentW = Q('DeskParent').clientWidth;
4842 + var deskH = Q('Desk').height, deskW = Q('Desk').width;
4843 +
4844 + if (deskAspectRatio == 2) {
4845 + // Scale mode
4846 + QS('Desk')['margin-top'] = null;
4847 + QS('Desk').height = '100%';
4848 + QS('Desk').width = '100%';
4849 + //QS('deskarea3x').height = null;
4850 + QS('DeskParent').overflow = 'hidden';
4851 + } else if (deskAspectRatio == 1) {
4852 + // Zoomed mode
4853 + QS('Desk')['margin-top'] = '0px';
4854 + QS('Desk').height = deskH + 'px';
4855 + QS('Desk').width = deskW + 'px';
4856 + QS('DeskParent').overflow = 'scroll';
4857 + } else {
4858 + // Fixed aspect ratio
4859 + if ((parentH / parentW) > (deskH / deskW)) {
4860 + var hNew = ((deskH * parentW) / deskW) + 'px';
4861 + //if (webPageFullScreen || fullscreen) {
4862 + //QS('deskarea3x').height = null;
4863 + //} else {
4864 + // QS('deskarea3x').height = hNew;
4865 + //QS('deskarea3x').height = null;
4866 + //}
4867 + QS('Desk').height = hNew;
4868 + QS('Desk').width = '100%';
4869 + } else {
4870 + var wNew = ((deskW * parentH) / deskH) + 'px';
4871 + if (webPageFullScreen || fullscreen) {
4872 + QS('Desk').height = null;
4873 + } else {
4874 + QS('Desk').height = '100%';
4875 + }
4876 + QS('Desk').width = wNew;
4877 + }
4878 + QS('Desk')['margin-top'] = null;
4879 + QS('DeskParent').overflow = 'hidden';
4880 + }
4881 + }
4882 +
4883 + function mdeskAdjust(mod, sw, sh, cv) {
4884 + if (!mod || !sw || !sh || !cv) return;
4885 +
4886 + // Check if we are in single desktop mode
4887 + if (cv.id == "Desk") { deskAdjust(); return; }
4888 +
4889 + // Figure out and adjust the size to fill the width of the div
4890 + var vsize = [{ x: 180, y: 101 }, { x: 302, y: 169 }, { x: 454, y: 255 }][Q('sizeselect').selectedIndex];
4891 + var realw = vsize.x + 2, tw = Q('xdevices').clientWidth - 30, xw = Math.floor(tw / realw);
4892 + xw = realw + Math.floor((tw - (xw * realw)) / xw);
4893 + vsize.y = vsize.y * (xw / vsize.x);
4894 + vsize.x = xw;
4895 + var mh = vsize.y, mw = vsize.x;
4896 + if (mod.State != 0) { mh = vsize.y; mw = (sw / sh) * vsize.y; }
4897 + QS(cv.id)['max-height'] = mh + 'px';
4898 + QS(cv.id)['max-width'] = mw + 'px';
4899 + QS(cv.id)['margin-top'] = '0';
4900 + QS(cv.id)['margin-bottom'] = '0';
4901 + }
4902 +
4903 + // Remote desktop special key combos for Windows
4904 + function deskSendKeys() {
4905 + if (xxdialogMode || desktop == null || desktop.State != 3) return;
4906 + var ks = Q('deskkeys').value;
4907 + if (ks == 0) { // WIN+Down arrow
4908 + if (desktop.contype == 2) {
4909 + desktop.m.sendkey([[0xffe7,1],[0xff54,1],[0xff54,0],[0xffe7,0]]); // Intel AMT: Meta-left down, Down arrow press, Down arrow release, Meta-left release
4910 + } else {
4911 + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,40],[desktop.m.KeyAction.UP,40],[desktop.m.KeyAction.EXUP,0x5B]]); // Agent: L-Winkey press, Down arrow press, Down arrow release, L-Winkey release
4912 + }
4913 + } else if (ks == 1) { // WIN+Up arrow
4914 + if (desktop.contype == 2) {
4915 + desktop.m.sendkey([[0xffe7,1],[0xff52,1],[0xff52,0],[0xffe7,0]]); // Intel AMT: Meta-left down, Up arrow press, Up arrow release, Meta-left release
4916 + } else {
4917 + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,38],[desktop.m.KeyAction.UP,38],[desktop.m.KeyAction.EXUP,0x5B]]); // MeshAgent: L-Winkey press, Up arrow press, Up arrow release, L-Winkey release
4918 + }
4919 + } else if (ks == 2) { // WIN+L arrow
4920 + if (desktop.contype == 2) {
4921 + desktop.m.sendkey([[0xffe7,1],[0x6c,1],[0x6c,0],[0xffe7,0]]); // Intel AMT: Meta-left down, 'l' press, 'l' release, Meta-left release
4922 + } else {
4923 + desktop.sendCtrlMsg('{"action":"lock"}');
4924 + //desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,76],[desktop.m.KeyAction.UP,76],[desktop.m.KeyAction.EXUP,0x5B]]); // MeshAgent: L-Winkey press, 'L' press, 'L' release, L-Winkey release
4925 + //desktop.m.SendKeyMsgKC(desktop.m.KeyAction.EXDOWN, 0x5B);
4926 + //desktop.m.SendKeyMsgKC(desktop.m.KeyAction.DOWN, 76);
4927 + //desktop.m.SendKeyMsgKC(desktop.m.KeyAction.UP, 76);
4928 + //desktop.m.SendKeyMsgKC(desktop.m.KeyAction.EXUP, 0x5B);
4929 + }
4930 + } else if (ks == 3) { // WIN+M arrow
4931 + if (desktop.contype == 2) {
4932 + desktop.m.sendkey([[0xffe7,1],[0x6d,1],[0x6d,0],[0xffe7,0]]); // Intel AMT: Meta-left down, 'm' press, 'm' release, Meta-left release
4933 + } else {
4934 + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,0x5B]]); // MeshAgent: L-Winkey press, 'M' press, 'M' release, L-Winkey release
4935 + }
4936 + } else if (ks == 4) { // Shift+WIN+M arrow
4937 + if (desktop.contype == 2) {
4938 + desktop.m.sendkey([[0xffe1,1],[0xffe7,1],[0x6d,1],[0x6d,0],[0xffe7,0],[0xffe1,0]]); // Intel AMT: Shift-left down, Meta-left down, 'm' press, 'm' release, Meta-left release, Shift-left release
4939 + } else {
4940 + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.DOWN,16],[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,0x5B],[desktop.m.KeyAction.UP, 16]]); // MeshAgent: L-shift press, L-Winkey press, 'M' press, 'M' release, L-Winkey release, L-shift release
4941 + }
4942 + } else if (ks == 5) { // WIN
4943 + if (desktop.contype == 2) {
4944 + desktop.m.sendkey([[0xffe7,1],[0xffe7,0]]); // Intel AMT: Meta-left down, Meta-left release
4945 + } else {
4946 + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B], [desktop.m.KeyAction.EXUP,0x5B]]); // MeshAgent: L-Winkey press, L-Winkey release
4947 + }
4948 + } else if (ks == 6) { // WIN+R
4949 + if (desktop.contype == 2) {
4950 + desktop.m.sendkey([[0xffe7,1],[0x72,1],[0x72,0],[0xffe7,0]]); // Intel AMT: Meta-left down, 'r' press, 'r' release, Meta-left release
4951 + } else {
4952 + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.DOWN, 82], [desktop.m.KeyAction.UP, 82], [desktop.m.KeyAction.EXUP, 0x5B]]); // MeshAgent: L-Winkey press, 'R' press, 'R' release, L-Winkey release
4953 + }
4954 + } else if (ks == 7) { // ALT-F4
4955 + if (desktop.contype == 2) {
4956 + desktop.m.sendkey([[0xffe9,1],[0xffc1,1],[0xffc1,0],[0xffe9,0]]); // Intel AMT: Alt down, 'F4' press, 'F4' release, Alt release
4957 + } else {
4958 + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 18], [desktop.m.KeyAction.DOWN, 115], [desktop.m.KeyAction.UP, 115], [desktop.m.KeyAction.EXUP, 18]]); // MeshAgent: Alt press, 'F4' press, 'F4' release, Alt release
4959 + }
4960 + } else if (ks == 8) { // CTRL-W
4961 + if (desktop.contype == 2) {
4962 + desktop.m.sendkey([[0xffe3,1],[0x77,1],[0x77,0],[0xffe3,0]]); // Intel AMT: Ctrl down, 'w' press, 'w' release, Ctrl release
4963 + } else {
4964 + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 17], [desktop.m.KeyAction.DOWN, 87], [desktop.m.KeyAction.UP, 87], [desktop.m.KeyAction.EXUP, 17]]); // MeshAgent: Ctrl press, 'W' press, 'W' release, Ctrl release
4965 + }
4966 + } else if (ks == 9) { // ALT-TAB
4967 + if (desktop.contype == 2) {
4968 + desktop.m.sendkey([[0xffe9, 1], [0xff09, 1], [0xff09, 0], [0xffe9, 0]]); // Intel AMT: Alt down, 'TAB' press, 'TAB' release, Alt release
4969 + } else {
4970 + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 18], [desktop.m.KeyAction.DOWN, 9], [desktop.m.KeyAction.UP, 9], [desktop.m.KeyAction.EXUP, 18]]); // MeshAgent: Alt press, 'TAB' press, 'TAB' release, Alt release
4971 + }
4972 + } else if (ks == 10) { // CTRL-ALT-DEL
4973 + desktop.m.sendcad();
4974 + }
4975 + }
4976 +
4977 + // Show clipboard dialog
4978 + function showDeskClip() {
4979 + if (xxdialogMode || desktop == null || desktop.State != 3) return;
4980 + Q('DeskClip').blur();
4981 + var x = '';
4982 + x += '<input id=dlgClipGet type=button value="Get Clipboard" style=width:120px onclick=showDeskClipGet()>';
4983 + x += '<input id=dlgClipSet type=button value="Set Clipboard" style=width:120px onclick=showDeskClipSet()>';
4984 + x += '<div id=dlgClipStatus style="display:inline-block;margin-left:8px" ></div>';
4985 + x += '<textarea id=d2clipText style="width:100%;height:184px;resize:none" maxlength=65535></textarea>';
4986 + x += '<input type=button value="Close" style=width:80px;float:right onclick=dialogclose(0)><div style=height:26px;margin-top:3px><span id=linuxClipWarn style=display:none>Remote clipboard is valid for 60 seconds.</span>&nbsp;</div><div></div>';
4987 + setDialogMode(2, "Remote Clipboard", 8, null, x, 'clipboard');
4988 + Q('d2clipText').focus();
4989 + }
4990 +
4991 + function showDeskClipGet() {
4992 + if (desktop == null || desktop.State != 3) return;
4993 + meshserver.send({ action: 'msg', type: 'getclip', nodeid: currentNode._id });
4994 + }
4995 +
4996 + function showDeskClipSet() {
4997 + if (desktop == null || desktop.State != 3) return;
4998 + meshserver.send({ action: 'msg', type: 'setclip', nodeid: currentNode._id, data: Q('d2clipText').value });
4999 + QV('linuxClipWarn', currentNode && currentNode.agent && (currentNode.agent.id > 4) && (currentNode.agent.id != 21) && (currentNode.agent.id != 22));

This file is too large to show in full.

views/default.handlebars
+47 -25
@@ -45,11 +45,17 @@
45 <hr id="cxmgroupsplit" />
46 <div id="cxmdesktop" class="cmtext" onclick="cmaction(7,event)" style="display:none">Multi-Desktop</div>
47 </div>
48 - <div id="meshContextMenu" class="contextMenu,noselect" style="display: none; min-width: 0px">
48 + <div id="meshContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
49 <div id="cxselectall" class="cmtext" onclick="cmmeshaction(1,event)">Select All</div>
50 <div id="cxselectnone" class="cmtext" onclick="cmmeshaction(2,event)">Select None</div>
51 + <!--
52 <hr id="cxmgroupsplit2" style="display:none" />
53 <div id="cxmmdesktop" class="cmtext" style="display:none" onclick="cmmeshaction(3,event)">Multi-Desktop</div>
54 + -->
55 + </div>
56 + <div id="termShellContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
57 + <div id="cxtermnorm" class="cmtext" onclick="cmtermaction(1,event)">Normal Connect</div>
58 + <div id="cxtermps" class="cmtext" onclick="cmtermaction(2,event)">PowerShell Connect</div>
59 </div>
60 <!-- main page -->
61 <div id=container>
@@ -519,7 +525,7 @@
525 <tr>
526 <td class="areaHead">
527 <div class="toright2">
522 - <input id="termActionsBtn" type=button title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value=Actions onclick=deviceActionFunction()/>
528 + <input id="termActionsBtn" type=button title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value=Actions onclick=deviceActionFunction() />
529 </div>
530 <div>
531 <input type="button" id="autoconnectbutton2" value="AutoConnect" onclick=autoConnectTerminal(event) onkeypress="return false" onkeydown="return false" style="display:none">
@@ -3142,7 +3148,13 @@
3148 var scrollLeft = (window.pageXOffset !== null) ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft;
3149 var scrollTop = (window.pageYOffset !== null) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
3150 var elem = document.elementFromPoint(event.pageX - scrollLeft, event.pageY - scrollTop);
3145 - if (elem && elem != null && elem.id == "MxMESH") {
3151 + if (elem && elem != null && elem.id == "connectbutton2" && currentNode && currentNode.agent && (currentNode.agent.id > 0) && (currentNode.agent.id < 5)) {
3152 + contextelement = elem;
3153 + var contextmenudiv = document.getElementById("termShellContextMenu");
3154 + contextmenudiv.style.left = event.pageX + "px";
3155 + contextmenudiv.style.top = event.pageY + "px";
3156 + contextmenudiv.style.display = "block";
3157 + } else if (elem && elem != null && elem.id == "MxMESH") {
3158 contextelement = elem;
3159 var contextmenudiv = document.getElementById("meshContextMenu");
3160 contextmenudiv.style.left = event.pageX + "px";
@@ -3156,25 +3168,25 @@
3168 contextmenudiv.style.left = event.pageX + "px";
3169 contextmenudiv.style.top = event.pageY + "px";
3170 contextmenudiv.style.display = "block";
3159 - }
3171
3161 - // Get the node and set the menu options
3162 - var nodeid = contextelement.children[1].attributes.onclick.value;
3163 - var node = getNodeFromId(nodeid.substring(12, nodeid.length - 18));
3164 - var mesh = meshes[node.meshid];
3165 - var meshlinks = mesh.links[userinfo._id];
3166 - var meshrights = meshlinks.rights;
3167 - var consoleRights = ((meshrights & 16) != 0);
3172 + // Get the node and set the menu options
3173 + var nodeid = contextelement.children[1].attributes.onclick.value;
3174 + var node = getNodeFromId(nodeid.substring(12, nodeid.length - 18));
3175 + var mesh = meshes[node.meshid];
3176 + var meshlinks = mesh.links[userinfo._id];
3177 + var meshrights = meshlinks.rights;
3178 + var consoleRights = ((meshrights & 16) != 0);
3179
3169 - // Check if we have terminal and file access
3170 - var terminalAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0));
3171 - var fileAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0));
3180 + // Check if we have terminal and file access
3181 + var terminalAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0));
3182 + var fileAccess = ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0));
3183
3173 - QV('cxdesktop', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((meshrights & 8) || (meshrights & 256)));
3174 - QV('cxterminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess);
3175 - QV('cxfiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (meshrights & 8) && fileAccess);
3176 - QV('cxevents', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (meshrights & 8));
3177 - QV('cxconsole', (consoleRights && (mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (meshrights & 8));
3184 + QV('cxdesktop', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((meshrights & 8) || (meshrights & 256)));
3185 + QV('cxterminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess);
3186 + QV('cxfiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (meshrights & 8) && fileAccess);
3187 + QV('cxevents', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (meshrights & 8));
3188 + QV('cxconsole', (consoleRights && (mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (meshrights & 8));
3189 + }
3190
3191 return haltEvent(event);
3192 }
@@ -3204,17 +3216,25 @@
3216 }
3217
3218 function cmmeshaction(action) {
3207 - var meshid = contextelement.attributes.onclick.value.substring(32, (32 + 69));
3219 + var meshid = contextelement.attributes.onclick.value.substring(10, contextelement.attributes.onclick.value.length - 2);
3220 var elements = document.getElementsByClassName("DeviceCheckbox");
3209 - if (action == 1) { for (var i = 0; i < elements.length; i++) { if ( (elements[i].attributes) && (elements[i].attributes['class']['value'].substring(0, 69) == meshid)) { elements[i].checked = true; } } }
3210 - if (action == 2) { for (var i = 0; i < elements.length; i++) { if ( (elements[i].attributes) && (elements[i].attributes['class']['value'].substring(0, 69) == meshid)) { elements[i].checked = false; } } }
3221 + if ((action == 1) || (action == 2)) {
3222 + for (var i = 0; i < elements.length; i++) {
3223 + if ((elements[i].attributes) && (elements[i].attributes['class']['value'].split(' ')[0] == meshid)) { elements[i].checked = (action == 1); }
3224 + }
3225 + }
3226 //if (action == 3) { window.location = "multidesktop.aspx?mesh=" + meshid + "&auto=1"; }
3227 p1updateInfo();
3228 }
3229
3230 + function cmtermaction(action) {
3231 + connectTerminal(null, 1, { powershell: (action == 2) });
3232 + }
3233 +
3234 function hideContextMenu() {
3235 QV('contextMenu', false);
3236 QV('meshContextMenu', false);
3237 + QV('termShellContextMenu', false);
3238 contextelement = null;
3239 }
3240
@@ -5166,7 +5186,7 @@
5186 var autoConnectTerminalTimer = null;
5187 function autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } }
5188
5169 - function connectTerminal(e, contype) {
5189 + function connectTerminal(e, contype, options) {
5190 p12clearConsoleMsg();
5191 if (!terminal) {
5192 if (contype == 2) {
@@ -5194,6 +5214,7 @@
5214 termoptions.xterm = true;
5215 }
5216 }
5217 + if ((e && (e.shiftKey == true)) || (options && (options.powershell))) { termoptions.protocol = 6; }
5218 terminal = CreateAgentRedirect(meshserver, CreateAmtRemoteTerminal('Term', termoptions), serverPublicNamePort, authCookie, domainUrl);
5219 terminal.debugmode = debugmode;
5220 terminal.m.debugmode = debugmode;
@@ -6554,7 +6575,7 @@
6575
6576 function p20editmesh(focus) {
6577 if (xxdialogMode) return;
6557 - var x = addHtmlValue('Name', '<input id=dp20meshname style=width:230px maxlength=32 onchange=p20editmeshValidate() onkeyup=p20editmeshValidate() />');
6578 + var x = addHtmlValue('Name', '<input id=dp20meshname style=width:230px maxlength=32 onchange=p20editmeshValidate() onkeyup=p20editmeshValidate(event) />');
6579 x += addHtmlValue('Description', '<div style=width:230px;margin:0;padding:0><textarea id=dp20meshdesc maxlength=1024 style=width:100%;resize:none></textarea></div>');
6580 setDialogMode(2, "Edit Device Group", 3, p20editmeshEx, x);
6581 Q('dp20meshname').value = currentMesh.name;
@@ -6567,8 +6588,9 @@
6588 meshserver.send({ action: 'editmesh', meshid: currentMesh._id, meshname: Q('dp20meshname').value, desc: Q('dp20meshdesc').value });
6589 }
6590
6570 - function p20editmeshValidate() {
6591 + function p20editmeshValidate(e) {
6592 QE('idx_dlgOkButton', Q('dp20meshname').value.length > 0);
6593 + if (e && e.key == 'Enter') { Q('dp20meshdesc').focus(); }
6594 }
6595
6596 function p20editmeshconsent() {