﻿<!doctypehtml><html lang=en dir=ltr xmlns=http://www.w3.org/1999/xhtml><meta http-equiv=X-UA-Compatible content="IE=edge"><meta http-equiv=Content-Type content="text/html;charset=utf-8"><meta name=viewport content="user-scalable=1,initial-scale=1,minimum-scale=1,maximum-scale=1"><meta name=apple-mobile-web-app-capable content=yes><meta name=format-detection content="telephone=no"><link type=image/x-icon href={{{domainurl}}}favicon.ico rel="shortcut icon"><link keeplink=1 type=text/css href=styles/style.css media=screen rel=stylesheet title=CSS><link type=text/css href=styles/ol.css media=screen rel=stylesheet title=CSS><link type=text/css href=styles/ol3-contextmenu.min.css media=screen rel=stylesheet title=CSS><link type=text/css href=styles/xterm.css media=screen rel=stylesheet title=CSS><script src=scripts/common-0.0.1{{{min}}}.js></script><script src=scripts/meshcentral{{{min}}}.js></script><script src=scripts/amt-0.2.0{{{min}}}.js></script><script src=scripts/amt-wsman-0.2.0{{{min}}}.js></script><script src=scripts/amt-desktop-0.0.2{{{min}}}.js></script><script src=scripts/amt-terminal-0.0.2{{{min}}}.js></script><script src=scripts/zlib{{{min}}}.js></script><script src=scripts/zlib-inflate{{{min}}}.js></script><script src=scripts/zlib-adler32{{{min}}}.js></script><script src=scripts/zlib-crc32{{{min}}}.js></script><script src=scripts/amt-redir-ws-0.1.0{{{min}}}.js></script><script src=scripts/amt-wsman-ws-0.2.0{{{min}}}.js></script><script src=scripts/agent-redir-ws-0.1.1{{{min}}}.js></script><script src=scripts/agent-redir-rtc-0.1.0{{{min}}}.js></script><script src=scripts/agent-desktop-0.0.2{{{min}}}.js></script><script src=scripts/qrcode.min.js></script><script src=scripts/xterm{{{min}}}.js></script><script src=scripts/xterm-addon-fit{{{min}}}.js></script><script keeplink=1 src=scripts/u2f-api{{{min}}}.js></script><script keeplink=1 src=scripts/charts{{{min}}}.js></script><script keeplink=1 src=scripts/filesaver.min.js></script><script keeplink=1 src=scripts/ol{{{min}}}.js></script><script keeplink=1 src=scripts/ol3-contextmenu{{{min}}}.js></script><title>{{{title}}}</title><body id=body oncontextmenu=handleContextMenu(event) style=display:none;min-width:495px onload='"undefined"!=typeof startup&&startup()'><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=cxdetails class=cmtext onclick=cmaction(6,event)>Details</div><div id=cxconsole class=cmtext onclick=cmaction(7,event)>Console</div><div id=cxplugins class=cmtext onclick=cmaction(8,event) style=display:none>Plugins</div><hr id=cxmgroupsplit><div id=cxmdesktop class=cmtext onclick=cmaction(9,event) style=display:none>Multi-Desktop</div></div><div id=meshContextMenu class="contextMenu noselect"style=display:none;min-width:0><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:0><div class=cmtext onclick=cmtermaction(1,event)><b>Admin Shell</b></div><div class=cmtext onclick=cmtermaction(6,event)>Admin PowerShell</div><div class=cmtext onclick=cmtermaction(8,event)>User Shell</div><div class=cmtext onclick=cmtermaction(9,event)>User PowerShell</div></div><div id=termShellContextMenuLinux class="contextMenu noselect"style=display:none;min-width:0><div class=cmtext onclick=cmtermaction(1,event)><b>Root Shell</b></div><div class=cmtext onclick=cmtermaction(8,event)>User Shell</div><div class=cmtext onclick=cmtermaction(100,event)>Login Shell</div></div><div id=deskConnectContextMenu class="contextMenu noselect"style=display:none;min-width:0><div class=cmtext onclick=cmdeskaction(1,event)>Ask Consent + Bar</div><div class=cmtext onclick=cmdeskaction(2,event)>Ask Consent</div><div class=cmtext onclick=cmdeskaction(3,event)>Privacy Bar</div></div><div id=altPortContextMenu class="contextMenu noselect"style=display:none;min-width:0><div class=cmtext onclick=cmaltportaction(1,event)>Alternate Port</div></div><div id=rfbPortContextMenu class="contextMenu noselect"style=display:none;min-width:0><div class=cmtext onclick=cmrfbportaction(1,event)>Alternate Port</div></div><div id=filesContextMenu class="contextMenu noselect"style=display:none;min-width:0><div class=cmtext onclick=cmfilesaction(1,event)>Rename</div><div class=cmtext onclick=cmfilesaction(2,event)>Edit</div><div class=cmtext onclick=cmfilesaction(3,event)>Delete</div></div><div id=deskPlayerContextMenu class="contextMenu noselect"style=display:none;min-width:0><div class=cmtext onclick=cmdeskplayeraction(1,event)>Open Player...</div></div><div id=container><div id=notifiyBox class=notifiyBox style=display:none></div><div id=masthead class=noselect><div style=float:left>{{{titlehtml}}}</div><div class=title>{{{title1}}}</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><span id=logoutControlSpan style=color:#fff></span><span id=idleTimeoutNotify style=color:#ff0></span></div><div id=page_leftbar><div style=height:16px></div><div id=LeftMenuMyDevices tabindex=0 class="lbbutton lbbuttonsel"title="My Devices"onclick=go(1,event) onkeypress='"Enter"==event.key&&go(1)'><div class=lb2></div></div><div id=LeftMenuMyAccount tabindex=0 class=lbbutton title="My Account"onclick=go(2,event) onkeypress='"Enter"==event.key&&go(2)'><div class=lb1></div></div><div id=LeftMenuMyEvents tabindex=0 class=lbbutton title="My Events"onclick=go(3,event) onkeypress='"Enter"==event.key&&go(3)'><div class=lb3></div></div><div id=LeftMenuMyFiles tabindex=0 class=lbbutton style=display:none title="My Files"onclick=go(5,event) onkeypress='"Enter"==event.key&&go(5)'><div class=lb4></div></div><div id=LeftMenuMyUsers tabindex=0 class=lbbutton style=display:none title="My Users"onclick=go(4,event) onkeypress='"Enter"==event.key&&go(4)'><div class=lb5></div></div><div id=LeftMenuMyServer tabindex=0 class=lbbutton style=display:none title="My Server"onclick=go(6,event) onkeypress='"Enter"==event.key&&go(6)'><div class=lb6></div></div></div><div id=topbar class=noselect><div><div style=position:relative><span id=logoutControlSpan2 style=color:#fff></span><div tabindex=0 id=uiMenuButton title="User interface selection"onclick=showUserInterfaceSelectMenu() onkeypress='"Enter"==event.key&&showUserInterfaceSelectMenu()'>&diams;<div id=uiMenu style=display:none><div tabindex=0 id=uiViewButton1 class=uiSelector onclick=userInterfaceSelectMenu(1) title="Left bar interface"onkeypress='"Enter"==event.key&&userInterfaceSelectMenu(1)'><div class=uiSelector1></div></div><div tabindex=0 id=uiViewButton2 class=uiSelector onclick=userInterfaceSelectMenu(2) title="Top bar interface"onkeypress='"Enter"==event.key&&userInterfaceSelectMenu(2)'><div class=uiSelector2></div></div><div tabindex=0 id=uiViewButton3 class=uiSelector onclick=userInterfaceSelectMenu(3) title="Fixed width interface"onkeypress='"Enter"==event.key&&userInterfaceSelectMenu(3)'><div class=uiSelector3></div></div><div tabindex=0 id=uiViewButton4 class=uiSelector onclick=toggleNightMode() title="Toggle night mode"onkeypress='"Enter"==event.key&&toggleNightMode()'><div class=uiSelector4></div></div><div tabindex=0 id=uiViewButton5 class=uiSelector onclick=toggleFooterBarMode() title="Toggle footer bar"onkeypress='"Enter"==event.key&&toggleFooterBarMode()'><div class=uiSelector5></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,event) onkeypress='"Enter"==event.key&&go(1)'>My Devices<td tabindex=0 id=MainMenuMyAccount class="topbar_td style3x"onclick=go(2,event) onkeypress='"Enter"==event.key&&go(2)'>My Account<td tabindex=0 id=MainMenuMyEvents class="topbar_td style3x"onclick=go(3,event) onkeypress='"Enter"==event.key&&go(3)'>My Events<td tabindex=0 id=MainMenuMyFiles class="topbar_td style3x"onclick=go(5,event) onkeypress='"Enter"==event.key&&go(5)'>My Files<td tabindex=0 id=MainMenuMyUsers class="topbar_td style3x"onclick=go(4,event) onkeypress='"Enter"==event.key&&go(4)'>My Users<td tabindex=0 id=MainMenuMyServer class="topbar_td style3x"onclick=go(6,event) onkeypress='"Enter"==event.key&&go(6)'>My Server<td class="topbar_td_end style3">&nbsp;</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,event) onkeypress='"Enter"==event.key&&go(10)'>General<td tabindex=0 id=MainDevDesktop class="topbar_td style3x"onclick=go(11,event) onkeypress='"Enter"==event.key&&go(11)'>Desktop<td tabindex=0 id=MainDevTerminal class="topbar_td style3x"onclick=go(12,event) onkeypress='"Enter"==event.key&&go(12)'>Terminal<td tabindex=0 id=MainDevFiles class="topbar_td style3x"onclick=go(13,event) onkeypress='"Enter"==event.key&&go(13)'>Files<td tabindex=0 id=MainDevEvents class="topbar_td style3x"onclick=go(16,event) onkeypress='"Enter"==event.key&&go(16)'>Events<td tabindex=0 id=MainDevInfo class="topbar_td style3x"onclick=go(17,event) onkeypress='"Enter"==event.key&&go(17)'>Details<td tabindex=0 id=MainDevAmt class="topbar_td style3x"onclick=go(14,event) onkeypress='"Enter"==event.key&&go(14)'>Intel&reg;AMT<td tabindex=0 id=MainDevConsole class="topbar_td style3x"onclick=go(15,event) onkeypress='"Enter"==event.key&&go(15)'>Console<td tabindex=0 id=MainDevPlugins class="topbar_td style3x"onclick=go(19,event) onkeypress='"Enter"==event.key&&go(19)'>Plugins<td class="topbar_td_end style3">&nbsp;</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,event) onkeypress='"Enter"==event.key&&go(20)'>General<td tabindex=0 id=MeshSummary class="topbar_td style3x"onclick=go(21,event) onkeypress='"Enter"==event.key&&go(21)'>Summary<td class="topbar_td_end style3">&nbsp;</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,event) onkeypress='"Enter"==event.key&&go(30)'>General<td tabindex=0 id=UserEvents class="topbar_td style3x"onclick=go(31,event) onkeypress='"Enter"==event.key&&go(31)'>Events<td class="topbar_td_end style3">&nbsp;</table></div><div id=UsersSubMenuSpan style=display:none><table id=UsersSubMenu cellpadding=0 cellspacing=0 class=style1><tr><td tabindex=0 id=UsersGeneral class="topbar_td style3x"onclick=go(4,event) onkeypress='"Enter"==event.key&&go(4)'>Users<td tabindex=0 id=UsersGroups class="topbar_td style3x"onclick=go(50,event) onkeypress='"Enter"==event.key&&go(50)'>Groups<td tabindex=0 id=UsersRecordings class="topbar_td style3x"onclick=go(52,event) onkeypress='"Enter"==event.key&&go(52)'>Recordings<td class="topbar_td_end style3">&nbsp;</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,event) onkeypress='"Enter"==event.key&&go(6)'>General<td tabindex=0 id=ServerStats class="topbar_td style3x"onclick=go(40,event) onkeypress='"Enter"==event.key&&go(40)'>Stats<td tabindex=0 id=ServerConsole class="topbar_td style3x"onclick=go(115,event) onkeypress='"Enter"==event.key&&go(115)'>Console<td tabindex=0 id=ServerTrace class="topbar_td style3x"onclick=go(41,event) onkeypress='"Enter"==event.key&&go(41)'>Trace<td tabindex=0 id=ServerPlugins class="topbar_td style3x"onclick=go(42,event) onkeypress='"Enter"==event.key&&go(42)'>Plugins<td class="topbar_td_end style3">&nbsp;</table></div><div id=UserDummyMenuSpan><table id=UserDummyMenu cellpadding=0 cellspacing=0 class=style1><tr><td class=style3>&nbsp;</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 id=p1title><div style=display:none id=devListToolbarViewIcons><div tabindex=0 id=devViewButton1 class=viewSelector onclick=onDeviceViewChange(1) onkeypress='"Enter"==event.key&&onDeviceViewChange(1)'title=Columns><div class=viewSelector2></div></div><div tabindex=0 id=devViewButton2 class=viewSelector onclick=onDeviceViewChange(2) onkeypress='"Enter"==event.key&&onDeviceViewChange(2)'title=List><div class=viewSelector1></div></div><div tabindex=0 id=devViewButton3 class=viewSelector onclick=onDeviceViewChange(3) onkeypress='"Enter"==event.key&&onDeviceViewChange(3)'title=Desktops><div class=viewSelector3></div></div><div tabindex=0 id=devViewButton4 class=viewSelector onclick=onDeviceViewChange(4) onkeypress='"Enter"==event.key&&onDeviceViewChange(4)'title=Map style=display:none><div class=viewSelector4></div></div></div><div><h1>My Devices</h1></div></div><table id=devListToolbarSpan class=noselect><tr><td class=h1><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 value="Group Action"onclick=groupActionFunction()>&nbsp; <input id=SearchInput placeholder=Filter onchange=onDeviceSearchChanged(event) onkeyup=onDeviceSearchChanged(event) 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> <label><input type=checkbox id=OnlineCheckBox onclick=onOnlineCheckBox(event)><span title="Only show devices that are online">Online</span></label> <span id=devCustomUIBar></span><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; <input id=KvmSearchInput placeholder=Filter onchange=onDeviceSearchChanged(event) onkeyup=onDeviceSearchChanged(event) autocomplete=off onfocus=onSearchFocus(1) onblur=onSearchFocus(0)>&nbsp;<td id=devMapToolbar class=style14 style=display:none>&nbsp;&nbsp;<input 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(!1,!0)><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 style=display:none>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 class=h2></table><div id=NoMeshesPanel style=display:none><table><tr><td valign=top style=width:50px><img src=images/info.png loading=lazy width=47 height=48><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></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><div id=p2title><h1>My Account</h1></div><div id=p2info style=overflow-y:auto><img id=p2AccountImage alt=""loading=lazy width=128 height=128 src=images/clipboard-128.png><div id=p2AccountSecurity style=display:none><p><strong>Account security</strong><div style=margin-left:25px><div id=managePhoneNumber1><div class=p2AccountActions><span id=authPhoneNumberCheck><strong>&#x2713;</strong></span></div><span><a href=# onclick="return account_managePhone()">Manage phone number</a><br></span></div><div id=manageEmail2FA><div class=p2AccountActions><span id=authEmailSetupCheck><strong>&#x2713;</strong></span></div><span><a href=# onclick="return account_manageAuthEmail()">Manage email authentication</a><br></span></div><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 class=mL><span id=managePhoneNumber2 style=display:none><a href=# onclick="return account_managePhone()">Manage phone number</a><br></span><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_showLocalizationSettings()">Localization Settings</a><br><a href=# onclick="return account_showAccountNotifySettings()">Notification Settings</a><br><span id=p2AccountPassActions><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></span></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><div id=p3 style=display:none><div id=p3title><h1>My Events</h1></div><table class=pTable><tr><td class=h1><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(2)><img src=images/link4.png height=10 width=10 title="Download Events"style=cursor:pointer></a>&nbsp;<td class=h2></table><div id=p3events></div></div><div id=p4 style=display:none><div id=p4title><h1>My Users</h1></div><table class=pTable><tr><td class=h1><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 type=button id=UsersSelectAllButton onclick=p3usersSelectallButtonFunction() value="Select All"> <input type=button id=UsersGroupActionButton disabled value="Group Action"onclick=p3usersGroupActionFunction()> <input id=UserNewAccountButton type=button onclick=showCreateNewAccountDialog() value="New Account..."> <input id=UserSearchInput style=width:120px;margin-left:6px placeholder=Filter onchange=onUserSearchInputChanged() onkeyup=onUserSearchInputChanged() autocomplete=off onfocus=onUserSearchFocus(1) onblur=onUserSearchFocus(0)></div><td class=h2></table><div id=p3users></div></div><div id=p5 style=display:none><div id=p5title><h1>My Files</h1></div><table id=p5toolbar cellpadding=0 cellspacing=0><tr><td id=p5filehead valign=bottom><div id=p5rightOfButtons></div><div><input type=button id=p5FolderUp disabled onclick="return p5folderup()"value=Up>&nbsp; <input type=button id=p5SelectAllButton disabled onclick=p5selectallfile() value="Select All">&nbsp; <input type=button id=p5RenameFileButton disabled value=Rename onclick=p5renamefile()>&nbsp; <input type=button id=p5DeleteFileButton disabled value=Delete onclick=p5deletefile()>&nbsp; <input type=button id=p5NewFolderButton disabled value="New Folder"onclick=p5createfolder()>&nbsp; <input type=button id=p5UploadButton disabled value=Upload onclick=p5uploadFile()>&nbsp; <input type=button id=p5CutButton disabled value=Cut onclick=p5copyFile(1)>&nbsp; <input type=button id=p5CopyButton disabled value=Copy onclick=p5copyFile(0)>&nbsp; <input type=button id=p5PasteButton disabled value=Paste onclick=p5pasteFile()>&nbsp;</div><tr><td id=p5filesubhead><div style=float:right><select id=p5sortdropdown onchange=updateFiles()><option value=1 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></table><div id=p5filetable><div id=p5PublicShare><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></table></div><div id=p6 style=display:none><div id=p6info style=overflow-y:auto><div id=p6title><img id=MainMeshImage src=serverpic.ashx><h1>My Server</h1></div><div id=p2ServerActions><p><strong>Server actions</strong><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 id=serverWarningsDiv style=display:none><br><strong>Server Warnings</strong><br><br><div id=serverWarnings></div></div></div></div><div id=p10 style=display:none><div id=p10title><div id=p10BackButton><div class=backButton tabindex=0 onclick=goBack() title=Back onkeypress='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><h1>General - <span id=p10deviceName></span></h1></div><div id=p10info style=overflow-y:auto><table style=width:100% cellpadding=0 cellspacing=0><tr><td style=width:auto valign=top><div id=p10html></div><td style=width:20px><td style=width:200px;vertical-align:top;position:relative valign=top><img id=p10deviceNotify onclick=showDeviceSessions(null,null,event) class=deviceNotifyLargeDot src=images/icon-relay-notify-40.png width=40 height=40><div id=p10deviceBattery class="deviceBatteryLarge deviceBatteryLarge1"></div><a href=# onclick=p10showiconselector()><img id=MainComputerImage></a><div id=MainComputerState></div></table><br><div id=p10html2></div><div id=p10html3></div><div id=p10html4></div></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='"Enter"==event.key&&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><div id=deskRecordIcon class=deskareaicon title="Server is recording this session"style=display:none;background-color:red;width:12px;height:12px;border-radius:6px;margin-top:5px></div><input id=deskFocusBtn type=button title="Toggle focus mode, when active only the region around the mouse is updated"onkeypress=return!1 onkeydown=return!1 value="Focus All"onclick=deskToggleFocus() style=margin-right:3px;display:none> <input id=deskActionsBtn type=button title="Perform power actions on the device"onkeypress=return!1 onkeydown=return!1 value=Actions onclick=deviceActionFunction() class=mR> <input id=deskActionsSettings type=button value=Settings... title="Edit remote desktop settings"onkeypress=return!1 onkeydown=return!1 onclick=showDesktopSettings() class=mR> <input type=button title="Change the power state of the remote machine"onkeypress=return!1 onkeydown=return!1 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!1 onkeydown=return!1 style=display:none> <span id=connectbutton1span><input type=button id=connectbutton1 cmenu=deskConnectButton value=Connect onclick=connectDesktop(event,3) onkeypress=return!1 onkeydown=return!1 disabled></span><span id=connectbutton1hspan>&nbsp;<input type=button id=connectbutton1h value="HW Connect"title="Connect using Intel AMT hardware KVM"onclick=connectDesktop(event,2) onkeypress=return!1 onkeydown=return!1 disabled></span><span id=disconnectbutton1span>&nbsp;<input type=button id=disconnectbutton1 value=Disconnect onclick=connectDesktop(event,0) onkeypress=return!1 onkeydown=return!1></span>&nbsp;<span id=deskstatus>Disconnected</span><span id=deskmetadata></span></div></div><div id=deskarea2><div class=areaProgress><div id=progressbar></div></div></div><div id=deskarea3x><div id=DeskFocus oncontextmenu=return!1 onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></div><div id=DeskParent><canvas id=Desk width=640 height=480 oncontextmenu=return!1 onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event) onmousewheel=dmousewheel(event)></canvas></div><div id=DeskTools><div id=deskToolsAreaTop><a id=DeskToolsRefreshButton style=right:2px onclick=refreshDeskTools()>Refresh</a><div id=deskToolsTopTabProcess class=deskToolsTopTab onclick=changeDeskToolTab(0) style=left:0;bottom:0>Processes</div><div id=deskToolsTopTabService class=deskToolsTopTab onclick=changeDeskToolTab(1) style=display:none;left:90px;color:gray>Services</div></div><div id=deskToolsArea><div id=DeskToolsProcessTab><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></div></div><div id=DeskToolsServiceTab style=display:none><div id=deskToolsServiceHeader><a class=colmn1 style=width:70px title="Sort by state"onclick=sortService(0)>State</a> <a class=colmn2 title="Sort by name"onclick=sortService(1)>Name</a></div><div id=DeskToolsServices></div></div></div></div><div id=p11DeskConsoleMsg style=display:none;cursor:pointer;position:absolute;left:30px;top:17px;color:#ff0;background-color:rgba(0,0,0,.6);padding:10px;border-radius:5px;text-align:left onclick=p11clearConsoleMsg()></div><div id=p11DeskSessionSelector style=display:none;position:absolute;left:30px;top:17px;right:30px;bottom:17px;overflow-y:auto></div></div><div id=deskarea4 class=areaFoot><div class=toright2><span id=DeskLatency title="Desktop Session Latency"></span> <span id=DeskTimer title="Session time"></span>&nbsp; <select id=termdisplays style=display:none onchange=deskSetDisplay(event) onkeypress=return!1 onkeydown=return!1></select>&nbsp; <input id=DeskToolsButton type=button value=Tools title="Toggle tools view"onkeypress=return!1 onkeydown=return!1 onclick=toggleDeskTools()>&nbsp; <span id=DeskChatButton class=deskarea title="Open chat window to this computer"><img src=images/icon-chat.png onclick=deviceChat(event) 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 the remote computer"><img src=images/icon-url2.png onclick=deviceUrlFunction() height=16 width=16 style=padding-top:2px></span><span id=DeskBackgroundButton title="Toggle remote desktop background"><img src=images/icon-background.png onclick=deviceToggleBackground(event) height=16 width=16 style=padding-top:2px></span><span id=DeskSaveImageButton title="Save a screenshot of the remote desktop"><img src=images/icon-camera.png onclick=deskSaveImage() height=16 width=16 style=padding-top:2px></span><span id=DeskRecordButton cmenu=deskPlayerContextMenu title="Record remote desktop session to file"style=display:none><img id=DeskRecordButtonImage src=images/icon-film.png onclick=deskRecordSession() 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<option value=11>Win+Left<option value=12>Win+Right</select> <input id=DeskWD type=button value=Send onkeypress=return!1 onkeydown=return!1 onclick=deskSendKeys()> <input id=DeskClip type=button value=Clipboard onkeypress=return!1 onkeydown=return!1 onclick=showDeskClip()> <input id=DeskType type=button value=Type onkeypress=return!1 onkeydown=return!1 onclick=showDeskType()> <label><span id=DeskControlSpan title="Toggle mouse and keyboard input"><input id=DeskControl type=checkbox onkeypress=return!1 onkeydown=return!1 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='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><div id=devListToolbarViewIcons2 style=float:right><div class=viewSelector onclick=deskToggleFull(event) title="Full Screen. Hold shift to browser full screen."><div class=viewSelector5></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><div id=termRecordIcon class=deskareaicon title="Server is recording this session"style=display:none;background-color:red;width:12px;height:12px;border-radius:6px;margin-top:5px;margin-left:5px></div><input id=termActionsBtn type=button title="Perform power actions on the device"onkeypress=return!1 onkeydown=return!1 value=Actions onclick=deviceActionFunction()></div><div><div id=idx_termFullBtn2 onclick=deskToggleFull(event)>&nbsp;&#x2716;</div><input type=button id=autoconnectbutton2 value=AutoConnect onclick=autoConnectTerminal(event) onkeypress=return!1 onkeydown=return!1 style=display:none> <span id=connectbutton2span><input type=button id=connectbutton2 cmenu=termConnectButton value=Connect onclick=connectTerminal(event,1) onkeypress=return!1 onkeydown=return!1 disabled></span><span id=connectbutton2hspan>&nbsp;<input type=button id=connectbutton2h value="HW Connect"title="Connect using Intel AMT hardware KVM"onclick=connectTerminal(event,2) onkeypress=return!1 onkeydown=return!1 disabled></span><span id=disconnectbutton2span>&nbsp;<input type=button id=disconnectbutton2 value=Disconnect onclick=connectTerminal(event,0) onkeypress=return!1 onkeydown=return!1></span>&nbsp;<span id=termstatus>Disconnected</span><span id=termtitle></span></div><tr><td><div class=areaProgress><div id=termprogressbar></div></div><tr><td id=termarea3x><div id=termarea3xdiv style=width:100%;height:100%></div><pre id=Term></pre><tr><td class=areaFoot><div class=toright2><span id=TermTimer title="Session time"></span>&nbsp; <span id=terminalSettingsButtons style=display:none><input id=id_tcrbutton type=button onkeypress=return!1 onkeydown=return!1 class=bottombutton value=CR+LF title="Toggle what the return key will send"onclick=termToggleCr()> <input id=id_tfxkeysbutton type=button onkeypress=return!1 onkeydown=return!1 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!1 onkeydown=return!1 class=bottombutton value="Extended Ascii"title="Toggle terminal emulation type"onclick=termToggleType()> </span><span id=terminalSizeDropDown style=display:none><select id=termSizeList onkeypress=return!1><option value=1>80x25<option value=2>100x30</select> </span><span id=specialKeyDropDown><select id=specialkeylist onkeypress=return!1></select> <input id=specialkeylistinput type=button onkeypress=return!1 class=bottombutton value=Send title="Send the selected special key"onclick=sendSpecialKey()></span></div><div>&nbsp; <input type=button onkeypress=return!1 onkeydown=return!1 class=bottombutton id=ctrlcbutton value=Ctl-C onclick='termSendKey(3,"ctrlcbutton")'> <input type=button onkeypress=return!1 onkeydown=return!1 class=bottombutton id=ctrlxbutton value=Ctl-X onclick='termSendKey(24,"ctrlxbutton")'> <input type=button onkeypress=return!1 onkeydown=return!1 class=bottombutton id=escbutton value=ESC onclick='termSendKey(27,"escbutton")'> <input type=button onkeypress=return!1 onkeydown=return!1 class=bottombutton id=bsbutton value=Backspace onclick='termSendKey(8,"bsbutton")'style=display:none> <input type=button onkeypress=return!1 onkeydown=return!1 class=bottombutton id=pastebutton value=Paste title="Paste text into the terminal"onclick=showTermPasteDialog() style=display:none></div></table><div id=p12TermConsoleMsg style=display:none;cursor:pointer;position:absolute;left:30px;top:45px;color:#ff0;background-color:rgba(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='"Enter"==event.key&&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 id=filesRecordIcon class=deskareaicon title="Server is recording this session"style=display:none;background-color:red;width:12px;height:12px;border-radius:6px;margin-top:5px;margin-left:5px></div></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><tr><td class=areaHead2 valign=bottom><div id=p13rightOfButtons class=toright2></div><div><input type=button id=p13FolderUp disabled onclick=p13folderup() value=Up>&nbsp; <input type=button id=p13SelectAllButton disabled onclick=p13selectallfile() value="Select All">&nbsp; <input type=button id=p13RenameFileButton disabled value=Rename onclick=p13renamefile()>&nbsp; <input type=button id=p13DeleteFileButton disabled value=Delete onclick=p13deletefile()>&nbsp; <input type=button id=p13ViewFileButton disabled value=Edit onclick=p13viewfile()>&nbsp; <input type=button id=p13NewFolderButton disabled value="New Folder"onclick=p13createfolder()>&nbsp; <input type=button id=p13UploadButton disabled value=Upload onclick=p13uploadFile()>&nbsp; <input type=button id=p13CutButton disabled value=Cut onclick=p13copyFile(1)>&nbsp; <input type=button id=p13CopyButton disabled value=Copy onclick=p13copyFile(0)>&nbsp; <input type=button id=p13PasteButton disabled value=Paste onclick=p13pasteFile()>&nbsp; <input type=button id=p13RefreshButton disabled value=Refresh onclick=p13folderup(9999)>&nbsp;</div><tr><td class=areaHead3><div class=toright2><select id=p13sortdropdown onchange=p13updateFiles()><option value=1 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></table><div id=p13FilesConsoleMsg style=display:none;cursor:pointer;position:absolute;left:30px;top:165px;color:#ff0;background-color:rgba(0,0,0,.6);padding:10px;border-radius:5px onclick=p13clearConsoleMsg()></div><div id=p13filetable><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></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='"Enter"==event.key&&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='"Enter"==event.key&&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><tr><td><div class=areaProgress><div id=consoleprogressbar></div></div><tr><td id=p15agentConsole><pre id=p15agentConsoleText></pre><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>&nbsp;<td id=p15outputselecttd><select id=p15outputselect><option value=1>Agent<option value=2>MQTT</select><td style=width:1%><input id=id_p15consoleClear type=button class=bottombutton value=Clear onclick=p15consoleClear()></table></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='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><h1>Events - <span id=p16deviceName></span></h1></div><table class=pTable><tr><td class=h1><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> <a href=# onclick=p3showDownloadEventsDialog(1)><img src=images/link4.png height=10 width=10 title="Download Events"style=cursor:pointer></a>&nbsp;<td class=h2></table><div id=p16events></div></div><div id=p17 style=display:none;margin-left:-18px><div id=p17title style=margin-left:18px><div id=p17BackButton style=float:left><div class=backButton tabindex=0 onclick=goBack() title=Back onkeypress='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><h1>Details - <span id=p17deviceName></span></h1></div><div id=p17info style=overflow-y:auto></div></div><div id=p19 style=display:none><div id=p19title><div id=p19BackButton style=float:left><div class=backButton tabindex=0 onclick=goBack() title=Back onkeypress='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><h1>Plugins - <span id=p19deviceName></span></h1></div><div id=p19headers></div><div id=p19pages></div></div><div id=p20 style=display:none><div id=p20title><picture id=MainMeshImage style=border-width:0;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></picture><div style=float:left><div class=backButton tabindex=0 onclick=goBack() title=Back onkeypress='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><h1>General - <span id=p20meshName></span></h1></div><p id=p20info></div><div id=p21 style=display:none><div id=p21title><div style=float:left><div class=backButton tabindex=0 onclick=goBack() title=Back onkeypress='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><h1>Summary - <span id=p21meshName></span></h1></div><div style=width:100%><div style=display:table;width:93%><div id=meshPowerChartDiv style=width:31%;display:inline-block;text-align:center;max-width:250px><div style=margin:10px;font-size:16px>Power States</div><canvas id=meshPowerChart style=width:250px;height:250px></canvas></div><div id=meshOsChartDiv style=width:31%;display:inline-block;text-align:center;max-width:250px><div style=margin:10px;font-size:16px>Agent Types</div><canvas id=meshOsChart style=width:250px;height:250px></canvas></div><div id=meshConnChartDiv style=width:31%;display:inline-block;text-align:center;max-width:250px><div style=margin:10px;font-size:16px>Connectivity</div><canvas id=meshConnChart style=width:250px;height:250px></canvas></div></div></div><p id=p21info></div><div id=p30 style=display:none><div id=p30title><div style=float:left><div class=backButton tabindex=0 onclick=goBack() title=Back onkeypress='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><h1>General - <span id=p30userName></span></h1></div><div id=p30info style=overflow-y:auto><table style=width:100% cellpadding=0 cellspacing=0><tr><td style=width:auto valign=top><div id=p30html></div><td style=width:20px><td style=width:200px;position:relative valign=top><img id=p30userAuthServiceLogo loading=lazy style=display:none class=userAuthStrategyLogo width=64 height=64><picture id=MainUserImage style=border-width:0;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></picture><div style=width:100%;text-align:center><strong><span id=MainUserState></span></strong></div></table><br><div id=p30html2></div><div id=p30html3></div></div></div><div id=p31 style=display:none><div id=p31title><div style=float:left><div class=backButton tabindex=0 onclick=goBack() title=Back onkeypress='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><h1>Events - <span id=p31userName></span></h1></div><table class=pTable><tr><td class=h1><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> <a href=# onclick=p3showDownloadEventsDialog(3)><img src=images/link4.png height=10 width=10 title="Download Events"style=cursor:pointer></a>&nbsp;<td class=h2></table><div id=p31events></div></div><div id=p40 style=display:none><div id=p40title><h1>My Server Stats</h1></div><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></canvas></div><div id=p41 style=display:none><div id=p41title><h1>My Server Tracing</h1></div><div class=areaHead><div class=toright2>Show <select id=p41limitdropdown onchange=displayServerTrace()><option value=100>Last 100<option value=250>Last 250<option value=500>Last 500<option value=1000>Last 1000</select> <input value=Clear type=button onclick=clearServerTracing()> <img src=images/link4.png height=10 width=10 title="Download trace (.csv)"style=cursor:pointer onclick=p41downloadServerTrace()>&nbsp;</div><div><input value=Tracing type=button onclick=setServerTracing()> <span id=p41traceStatus>None</span></div></div><div id=p41events></div></div><div id=p42 style=display:none><h1>My Server Plugins</h1><div class=areaHead><div class=toright2></div><div><input value="Download Plugin"type=button onclick="return pluginHandler.addPluginDlg()"></div></div><div id=pluginRestartNotice class=areaHead style=background-color:gold;display:none><div class=toright2><input value="Refresh Agent Cores"type=button onclick="return distributeCore(),!1"></div><div style=padding:2px><div style=padding:2px><b>Notice:</b> Plugins have been altered, this may require agent core update.</div></div></div><table id=p42tbl><tr class=DevSt><th style=width:26px><th style=width:10px><th class=chName>Name<th class=chDescription>Description<th class=chSite style=text-align:center>Link<th class=chVersion style=text-align:center>Version<th class=chUpgradeAvail style=text-align:center>Latest<th class=chStatus style=text-align:center>Status<th class=chAction style=text-align:center>Action<th style=width:10px></table><div id=pluginNoneNotice style=width:100%;text-align:center;padding-top:10px;display:none><i>No plugins on server.</i></div></div><div id=p43 style=display:none><div id=p43BackButton><div class=backButton tabindex=0 onclick=go(42) title=Back onkeypress='"Enter"==event.key&&go(42)'><div class=backButtonEx></div></div></div><h1>My Server Plugins - <span id=p43title></span></h1><iframe id=p43iframe frameborder=0 style="width:100%;height:calc(100vh - 245px);max-height:calc(100vh - 245px)"></iframe></div><div id=p50 style=display:none><div id=p50title><h1>My User Groups</h1></div><table class=pTable><tr><td class=h1><td class=style14><div style=float:right></div><div><input type=button id=UsersGroupsSelectAllButton onclick=p50usersSelectallButtonFunction() value="Select All"> <input type=button id=UsersGroupsGroupActionButton disabled value="Group Action"onclick=p50usersGroupActionFunction()> <input id=NewUserGroupButton type=button onclick=showCreateUserGroupDialog(1) value="New Group..."> <input id=DuplicateUserGroupButton type=button style=display:none onclick=showCreateUserGroupDialog(2) value="Duplicate Group..."></div><td class=h2></table><div id=p50groups></div></div><div id=p51 style=display:none><div id=p51title><div style=float:left><div class=backButton tabindex=0 onclick=goBack() title=Back onkeypress='"Enter"==event.key&&goBack()'><div class=backButtonEx></div></div></div><h1>User Group - <span id=p51groupName></span></h1></div><div id=p51info style=overflow-y:auto><table style=width:100% cellpadding=0 cellspacing=0><tr><td style=width:auto valign=top><div id=p51group></div><td style=width:20px><td style=width:200px valign=top><picture id=MainUserImage style=border-width:0;height:200px;width:200px;float:right><source type=image/webp width=200 height=200 srcset=images/webp/group-256.webp><img alt=""width=200 height=200 src=images/group-256.png></picture><div style=width:100%;text-align:center><strong><span id=MainUserState></span></strong></div></table><div id=p51group2></div><br></div></div><div id=p52 style=display:none><div id=p52title><h1>My User Recordings</h1></div><table class=pTable><tr><td class=h1><td class=style14><div style=float:right><input type=button onclick=openRecodringPlayer() value="Open Player..."></div><div><input type=button onclick=refreshRecodings() value=Refresh></div><td class=h2></table><div id=p52recordings style=overflow-y:auto></div></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 id=termsLinkFooter 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='"Enter"==event.key&&setDialogMode()'>&#x2716;</div><div id=id_dialogtitle></div></div><div id=dialogBody><div id=dialog1><div id=id_dialogMessage></div></div><div id=dialog2><div id=id_dialogOptions></div></div><div id=dialog3><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 id=d3auth name=auth style=display:none> <input 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 onclick=d3folderup() value=Up>&nbsp;</div><div id=d3serverfiles></div></div></div><div id=dialog4><input id=d4WrapButton type=button value="Wrap On"onclick=d4ToggleWrap()> <input id=d4SizeButton type=button value=Small onclick=d4ToggleSize()> <textarea id=d4editorarea autocomplete=off style="height:calc(100vh - 286px);width:100%;overflow:scroll;resize:none;white-space:pre"></textarea></div><div id=dialog7><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 dir=rtl><option 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 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 onclick=dialogclose(0)> <input id=idx_dlgOkButton type=button value=OK 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=p5fileDragAuthCookie name=auth><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></audio></div><script nonce=abc>"use strict";var args,urlargs,webState="{{{webstate}}}";for(var i in""!=webState&&(webState=JSON.parse(decodeURIComponent(webState))),webState)"desktopsettings"!=i&&localStorage.setItem(i,webState[i]);if(!webState.loctag)try{localStorage.removeItem("loctag")}catch(e){}var desktop,terminal,files,autoReconnect=!0,powerStatetable=["","Powered","Sleep","Sleep","Sleep","Hibernating","Power off","Present"],StatusStrs=["Disconnected","Connecting...","Setup...","Connected","Intel&reg; AMT Connected"],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"],sort=0,searchFocus=0,mapSearchFocus=0,userSearchFocus=0,consoleFocus=0,showRealNames=!1,meshserver=null,meshes={},meshcount=0,nodes=null,usergroups=null,filetree={},userinfo=null,serverinfo=null,events=[],users=null,wssessions=null,nodeShortIdent=0,desktopsettings={encoding:2,showfocus:!1,showmouse:!0,showcad:!0,quality:40,scaling:1024,framerate:50,localkeymap:!1},multidesktopsettings={quality:20,scaling:128,framerate:1e3},debugLevel=parseInt("{{{debuglevel}}}"),features=parseInt("{{{features}}}"),sessionTime=parseInt("{{{sessiontime}}}"),sessionRefreshTimer=null,domain="{{{domain}}}",domainUrl="{{{domainurl}}}",authCookie="{{{authCookie}}}",authRelayCookie="{{{authRelayCookie}}}",logoutControls=JSON.parse(decodeURIComponent("{{{logoutControls}}}")),authCookieRenewTimer=null,multiDesktop={},multiDesktopFilter=null,serverPublicNamePort="{{{serverDnsName}}}:{{{serverPublicPort}}}",amtScanResults=null,debugmode=0,clickOnce=0!=(256&features)&&detectClickOnce(),attemptWebRTC=0!=(128&features),passRequirements="{{{passRequirements}}}";""!=passRequirements&&(passRequirements=JSON.parse(decodeURIComponent(passRequirements)));var customui="{{{customui}}}";customui=""!=customui?JSON.parse(decodeURIComponent(customui)):null;var deskAspectRatio=0;try{deskAspectRatio=parseInt(getstore("deskAspectRatio","0"))}catch(e){}var uiMode=parseInt(getstore("uiMode",1)),webPageStackMenu=!1,webPageFullScreen=!0,nightMode="1"==getstore("nightMode","0"),footerBar="1"==getstore("footerBar","1"),sessionActivity=Date.now(),updateSessionTimer=null,pluginHandlerBuilder={{{pluginHandler}}},pluginHandler=null;null!=pluginHandlerBuilder&&(pluginHandler=new pluginHandlerBuilder);var installedPluginList=null,goBackStack=[],CollapsedGroups={};try{CollapsedGroups=JSON.parse(getstore("_collapse","{}"))}catch(e){}var xterm=null,xtermfit=null,xtermResizeTimer=null,p11DeskConsoleMsgTimer=null,p12TermConsoleMsgTimer=null,p13FilesConsoleMsgTimer=null;function startup(){if(0==(32&features)){var e=null;try{e=top.location.toString().toLowerCase()}catch(e){}if(top!=self&&(null==e||0==top.active))return void(top.location=self.location)}delete(urlargs=parseUriArgs()).viewmode,delete urlargs.gotonode,delete urlargs.gotomesh,delete urlargs.gotouser,delete urlargs.gotougrp,urlargs.key&&(Q("termsLinkFooter").href+="?key="+urlargs.key),(args=parseUriArgs()).locale||null!=(s=getstore("loctag",0))&&"*"!=s&&(args.locale=s);debugmode=args.debug,attemptWebRTC=0,null!=args.webrtc&&(attemptWebRTC=1==args.webrtc),QV("p13AutoConnect",debugmode),QV("autoconnectbutton2",debugmode),QV("autoconnectbutton1",debugmode),nightMode&&(QC("body").add("night"),QS("body")["background-color"]="#000"),toggleFullScreen();var t=0,n=parseInt("{{{hide}}}");(n||args.hide)&&(args.hide&&(t=parseInt(args.hide)),n&&(t|=n)),args.hide=t,QV("uiViewButton5",!(4&args.hide)),adjustPanels();var o="";logoutControls&&null!=logoutControls.name&&(o=format("Welcome {0}.",logoutControls.name)),null!=logoutControls.logoutUrl&&(o+=format(' <a href="'+logoutControls.logoutUrl+'" style="color:white">Logout</a>')),1&args.hide?QH("logoutControlSpan2",o):QH("logoutControlSpan",o),document.onclick=function(e){hideContextMenu()},document.onkeypress=ondockeypress,document.onkeydown=ondockeydown,document.onkeyup=ondockeyup,window.addEventListener("blur",ondocblur,!1),window.onresize=function(){hideContextMenu(),masterUpdate(512),null!=xtermfit&&12==xxcurrentView&&xtermfit.fit()},setTimeout(function(){masterUpdate(512)},200),(meshserver=MeshServerCreateControl(domainUrl,authCookie)).onStateChanged=onStateChanged,meshserver.onMessage=onMessage,meshserver.trace=1==args.trace,meshserver.Start(),Q("sortselect").selectedIndex=sort=getstore("sort",0),Q("sizeselect").selectedIndex=getstore("viewsize",1),Q("KvmSearchInput").value=Q("SearchInput").value=getstore("_search",""),showRealNames=1==getstore("showRealNames",0),Q("RealNameCheckBox").checked=showRealNames,Q("OnlineCheckBox").checked=1==getstore("onlineOnly",0),Q("viewselect").value=getstore("deviceView",1),Q("DeskControl").checked=1==getstore("DeskControl",1),QV("accountChangeEmailAddressSpan",0==(2097152&features)),masterUpdate(3);for(var i=1;i<5;i++)Q("devViewButton"+i).classList.remove("viewSelectorSel");Q("devViewButton"+Q("viewselect").value).classList.add("viewSelectorSel"),Q("p5filetable").addEventListener("drop",p5fileDragDrop,!1),Q("p5filetable").addEventListener("dragover",p5fileDragOver,!1),Q("p5filetable").addEventListener("dragleave",p5fileDragLeave,!1),Q("p13filetable").addEventListener("drop",p13fileDragDrop,!1),Q("p13filetable").addEventListener("dragover",p13fileDragOver,!1),Q("p13filetable").addEventListener("dragleave",p13fileDragLeave,!1),setInterval(updateDeviceTimeline,12e4);var a=null;try{a=localStorage.getItem("desktopsettings")}catch(e){}null!=a&&(desktopsettings=JSON.parse(a)),a=null;try{a=localStorage.getItem("multidesktopsettings")}catch(e){}null!=a&&(multidesktopsettings=JSON.parse(a)),applyDesktopSettings();for(var s="",r=1;r<27;r++)s+="<option value='"+r+"'>Ctrl-"+String.fromCharCode(64+r)+" ("+r+")</option>";QH("specialkeylist",s),setupGeneralServerStats(),setupServerTimelineStats(),userInterfaceSelectMenu(),setupMeshSummaryStats(),QV("p4UserBatchCreate",0==(524288&features)),d4EditWrapVal=getstore("editorWrap",0),d4EditSizeVal=getstore("editorSize",0),d4ToggleWrap(!0),d4ToggleSize(!0),null!=pluginHandler&&pluginHandler.callHook("onWebUIStartupEnd"),-1==["en","ko","ja","zh-chs"].indexOf("{{{lang}}}")&&""!="{{{lang}}}".toLowerCase()&&QC("body").add("nonenglish");var l=document.getElementsByClassName("topbar_td");for(var d in l)l[d].innerHTML&&(l[d].innerHTML=l[d].innerHTML.split(" ").join("&nbsp;"));if(null!=customui&&customui.devicesbarbuttons){s="";for(var d in customui.devicesbarbuttons){var c="one"==customui.devicesbarbuttons[d].selection||"many"==customui.devicesbarbuttons[d].selection?"disabled":"";s+='<input id="cui:'+d+'" type="button" value="'+customui.devicesbarbuttons[d].name+'" '+c+' onclick=customUIAction(event,"devicesbarbuttons") />'}QH("devCustomUIBar",s)}10<=sessionTime&&(sessionRefreshTimer=setTimeout(refreshCookieSession,Math.round(6e4*sessionTime*.8)))}function refreshCookieSession(){var e=null;try{e=new XDomainRequest}catch(e){}(e=e||new XMLHttpRequest).open("GET",window.location.origin+domainUrl+"refresh.ashx"),e.timeout=15e3,e.onload=function(){sessionRefreshTimer=setTimeout(refreshCookieSession,Math.round(6e4*sessionTime*.8))},e.onerror=e.ontimeout=function(){sessionRefreshTimer=null},e.send()}function customUIAction(e,t){var n=e.srcElement.id;if(0!=n.startsWith("cui:")){var o=customui[t][n.substring(4)];if(null!=o&&"devicesbarbuttons"==t){for(var i=document.getElementsByClassName("DeviceCheckbox"),a=[],s=0;s<i.length;s++)!0===i[s].checked&&a.push(i[s].defaultValue.substring(6));"string"==typeof o.action&&("event"==o.action&&meshserver.send({action:"uicustomevent",section:t,element:n.substring(4),selectedDevices:a}),o.action.startsWith("dialog:")&&showCustomUiDialog(o.action.substring(7),{section:t,element:n.substring(4),selectedDevices:a}))}}}function showCustomUiDialog(e,t){if(null!=customui&&null!=customui.dialogs&&"object"==typeof customui.dialogs[e]){var n="",o=customui.dialogs[e],i=3;if("string"==typeof o.text&&(n+="<div style=margin-bottom:8px>"+o.text+"</div>"),"number"==typeof o.buttons&&(i=o.buttons),"object"==typeof o.elements)for(var a in o.elements){var s=o.elements[a];if("text"==s.type&&(n+=addHtmlValue(s.name,"<input id=cui:"+a+" style=width:230px autocomplete=off />")),"droplist"==s.type){var r="";for(var l in s.options)r+='<option value="'+l+'">'+EscapeHtml(s.options[l])+"</option>";n+=addHtmlValue(s.name,'<select id="cui:'+a+'" style=width:230px autocomplete=off />'+r+"</select>")}}setDialogMode(2,o.title,i,showCustomUiDialogEx,n,{action:"uicustomevent",section:"dialogs",element:e,src:t,values:{}})}}function showCustomUiDialogEx(e,t){if(1==e){var n=customui.dialogs[t.element];if("object"==typeof n.elements)for(var o in n.elements){var i=n.elements[o];"text"==i.type&&(t.values[o]=Q("cui:"+o).value),"droplist"==i.type&&(t.values[o]=Q("cui:"+o).value)}meshserver.send(t)}}function adjustPanels(){var e=args.hide;0==footerBar&&(e|=4),QV("masthead",!(1&e)),QV("topbar",!(2&e)),QV("footer",!(4&e)),QV("p1title",!(8&e)),QV("p2title",!(8&e)),QV("p3title",!(8&e)),QV("p4title",!(8&e)),QV("p5title",!(8&e)),QV("p6title",!(8&e)),QV("p10title",!(8&e)),QV("p11title",!(8&e)),QV("p12title",!(8&e)),QV("p13title",!(8&e)),QV("p14title",!(8&e)),QV("p15title",!(8&e)),QV("p16title",!(8&e)),QV("p17title",!(8&e)),QV("p20title",!(8&e)),QV("p21title",!(8&e)),QV("p30title",!(8&e)),QV("p31title",!(8&e)),QV("p40title",!(8&e)),QV("p41title",!(8&e)),QV("p50title",!(8&e)),QV("p51title",!(8&e)),footerBar?QC("body").remove("nofooter"):QC("body").add("nofooter"),0!=args.hide&&(2==uiMode?(QS("container")["grid-template-rows"]=(1&e?"0":"66")+"px fit-content(48px) auto "+(4&e?"0":"45")+"px",QS("container")["-ms-grid-rows"]=(1&e?"0":"66")+"px fit-content(48px) auto "+(4&e?"0":"45")+"px"):(QS("container")["grid-template-rows"]=(1&e?"0":"66")+"px "+(2&e?"0":"24")+"px auto "+(4&e?"0":"45")+"px",QS("container")["-ms-grid-rows"]=(1&e?"0":"66")+"px "+(2&e?"0":"24")+"px auto "+(4&e?"0":"45")+"px"));var t=(1&e?0:66)+(2&e?0:24)+(4&e?0:45)+(8&e?0:60),n=1<uiMode?24:0;QS("p2info").height="calc(100vh - "+(20+t+n)+"px)",QS("p2info")["max-height"]="calc(100vh - "+(20+t+n)+"px)",QS("p3users")["max-height"]="calc(100vh - "+(50+t)+"px)",QS("p3events").height="calc(100vh - "+(50+t)+"px)",QS("p5filetable").height="calc(100vh - "+(99+t)+"px)",QS("p13filetable").height="calc(100vh - "+(127+t+n)+"px)",QS("serverMainStats").height="calc(100vh - "+(50+t+n)+"px)",QS("serverMainStats")["max-height"]="calc(100vh - "+(50+t+n)+"px)",QS("xdevices")["max-height"]="calc(100vh - "+(46+t)+"px)",QS("xdevicesmap")["max-height"]="calc(100vh - "+(46+t)+"px)",QS("p15agentConsole").height="calc(100vh - "+(84+t+n)+"px)",QS("p15agentConsole")["max-height"]="calc(100vh - "+(84+t+n)+"px)",QS("p15agentConsoleText").height="calc(100vh - "+(81+t+n)+"px)",QS("p15agentConsoleText")["max-height"]="calc(100vh - "+(81+t+n)+"px)";var o=!(0===args.xterm||null!=terminal&&null==xterm);fullscreen?(QS("deskarea3x").height=null,QS("deskarea3x")["max-height"]=null,QS("p14iframe").height=null,QS("p14iframe")["max-height"]=null,o&&(QS("termarea3x").height="calc(100vh - 55px)",QS("termarea3xdiv").height="calc(100vh - 55px)",QS("termarea3x")["max-width"]="calc(1px)")):(QS("deskarea3x").height="calc(100vh - "+(74+t+n)+"px)",QS("deskarea3x")["max-height"]="calc(100vh - "+(74+t+n)+"px)",QS("p14iframe").height="calc(100vh - "+(23+t+n)+"px)",QS("p14iframe")["max-height"]="calc(100vh - "+(23+t+n)+"px)",o&&(QS("termarea3x").height="calc(100vh - "+(74+t+n)+"px)",QS("termarea3xdiv").height="calc(100vh - "+(74+t+n)+"px)",QS("termarea3x")["max-width"]="calc(1px)")),QS("p43iframe").height="calc(100vh - "+(84+t)+"px)",QS("p43iframe")["max-height"]="calc(100vh - "+(84+t)+"px)",QS("p6info").height="calc(100vh - "+(t-50+n)+"px)",QS("p6info")["max-height"]="calc(100vh - "+(t-50+n)+"px)",QS("p10info").height="calc(100vh - "+(20+t+n)+"px)",QS("p10info")["max-height"]="calc(100vh - "+(20+t+n)+"px)",QS("p17info").height="calc(100vh - "+(20+t+n)+"px)",QS("p17info")["max-height"]="calc(100vh - "+(20+t+n)+"px)",QS("p30info").height="calc(100vh - "+(20+t+n)+"px)",QS("p30info")["max-height"]="calc(100vh - "+(20+t+n)+"px)",QS("p51info").height="calc(100vh - "+(20+t+n)+"px)",QS("p51info")["max-height"]="calc(100vh - "+(20+t+n)+"px)",QS("p16events").height="calc(100vh - "+(50+t+n)+"px)",QS("p16events")["max-height"]="calc(100vh - "+(50+t+n)+"px)",QS("p31events").height="calc(100vh - "+(50+t+n)+"px)",QS("p31events")["max-height"]="calc(100vh - "+(50+t+n)+"px)",QS("p41events").height="calc(100vh - "+(48+t+n)+"px)",QS("p41events")["max-height"]="calc(100vh - "+(48+t+n)+"px)",QS("p52recordings").height="calc(100vh - "+(48+t+n)+"px)",QS("p52recordings")["max-height"]="calc(100vh - "+(48+t+n)+"px)",""!="{{currentNode}}".toLowerCase()&&(QV("p10BackButton",!1),QV("p11BackButton",!1),QV("p12BackButton",!1),QV("p13BackButton",!1),QV("p14BackButton",!1),QV("p15BackButton",!1),QV("p16BackButton",!1)),p1updateInfo()}function toggleAspectRatio(e){1===e&&putstore("deskAspectRatio",deskAspectRatio=(deskAspectRatio+1)%3),deskAdjust()}function toggleStackMenu(e){1==webPageFullScreen&&(1===e&&putstore("webPageStackMenu",webPageStackMenu=!webPageStackMenu),0==webPageStackMenu?QC("body").remove("menu_stack"):(QC("body").add("menu_stack"),10<=xxcurrentView&&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"),Q("uiViewButton5").classList.remove("uiSelectorSel");try{Q("uiViewButton"+uiMode).classList.add("uiSelectorSel")}catch(e){}QV("uiMenu","none"==QS("uiMenu").display),nightMode&&Q("uiViewButton4").classList.add("uiSelectorSel"),footerBar&&Q("uiViewButton5").classList.add("uiSelectorSel")}function userInterfaceSelectMenu(e){e&&putstore("uiMode",uiMode=e),webPageFullScreen=uiMode<3,webPageStackMenu=1<uiMode,toggleFullScreen(0),toggleStackMenu(0),webPageStackMenu&&10<=xxcurrentView?QC("column_l").add("room4submenu"):QC("column_l").remove("room4submenu"),adjustPanels()}function toggleNightMode(){(nightMode=!nightMode)?(QC("body").add("night"),QS("body")["background-color"]="#000"):(QC("body").remove("night"),QS("body")["background-color"]="#d3d9d6"),putstore("nightMode",nightMode?"1":"0")}function toggleFooterBarMode(){putstore("footerBar",(footerBar=!footerBar)?"1":"0"),QS("container")["grid-template-rows"]=null,QS("container")["-ms-grid-rows"]=null,adjustPanels()}function toggleFullScreen(e){1===e&&putstore("webPageFullScreen",webPageFullScreen=!webPageFullScreen),0==webPageFullScreen?(QC("body").remove("menu_stack"),QC("body").remove("fullscreen"),QC("body").remove("arg_hide"),10<=xxcurrentView&&QC("column_l").add("room4submenu"),QV("UserDummyMenuSpan",!1)):(QC("body").add("fullscreen"),16&args.hide&&QC("body").add("arg_hide"),QV("page_leftbar",!(16&args.hide)),QV("MainMenuSpan",!(16&args.hide)),10<=xxcurrentView&&QC("column_l").remove("room4submenu"),QV("UserDummyMenuSpan",xxcurrentView<10&&webPageFullScreen)),masterUpdate(512),QV("body",!0)}function getNodeFromId(e){if(null!=nodes)for(var t in nodes)if(nodes[t]._id==e)return nodes[t];return null}function reload(){var e=window.location.href;e.endsWith("/#")&&(e=e.substring(0,e.length-2)),window.location.href=e}function onStateChanged(e,t,n,o){if(0==t){if(setDialogMode(0),go(0),powerTimelineUpdate=powerTimelineNode=powerTimelineReq=powerTimeline=null,deleteAllNotifications(),hideContextMenu(),QV("verifyEmailId2",!1),QV("logoutControl",!1),"noauth"==o)return void QH("p0span","Unable to perform authentication");2==n?autoReconnect&&setTimeout(serverPoll,5e3):QH("p0span","Unable to connect web socket"),null!=authCookieRenewTimer&&(clearInterval(authCookieRenewTimer),authCookieRenewTimer=null)}else 2==t&&(meshserver.send({action:"usergroups"}),meshserver.send({action:"meshes"}),meshserver.send({action:"nodes",id:"{{currentNode}}"}),null!=pluginHandler&&meshserver.send({action:"plugins"}),""=="{{currentNode}}".toLowerCase()&&meshserver.send({action:"files"}),""=="{{viewmode}}".toLowerCase()&&go(1),authCookieRenewTimer=setInterval(function(){meshserver.send({action:"authcookie"})},18e5))}function serverPoll(){var e=null;try{e=new XDomainRequest}catch(e){}(e=e||new XMLHttpRequest).open("HEAD",window.location.href),e.timeout=15e3,e.onload=function(){reload()},e.onerror=e.ontimeout=function(){setTimeout(serverPoll,1e4)},e.send()}function detectClickOnce(){for(var e in window.navigator.mimeTypes)if("application/x-ms-application"==window.navigator.mimeTypes[e].type)return!0;var t=window.navigator.userAgent.toUpperCase();return 0<=t.indexOf(".NET CLR 3.5")||0<=t.indexOf("(WINDOWS NT ")}function updateSiteAdmin(){var e=userinfo.siteadmin;QV("p2AccountSecurity",0==(4&features)&&0==serverinfo.domainauth&&0!=(4096&features)),QV("managePhoneNumber1",33554432&features&&67108864&features),QV("managePhoneNumber2",33554432&features&&!(67108864&features)),QV("manageEmail2FA",8388608&features),QV("p2AccountPassActions",0==(4&features)&&0==serverinfo.domainauth&&null!=userinfo&&0==userinfo._id.split("/")[2].startsWith("~")),QV("p2ServerActions",21&e),QV("LeftMenuMyServer",21&e),QV("MainMenuMyServer",21&e),QV("p2ServerActionsBackup",1&e),QV("p2ServerActionsRestore",4&e),QV("p2ServerActionsVersion",16&e),QV("MainMenuMyFiles",8&e),QV("LeftMenuMyFiles",8&e),0==(8&e)&&5==xxcurrentView&&(setDialogMode(0),go(1)),null!=currentNode&&gotoDevice(currentNode._id,xxcurrentView,!0),0!=(2&userinfo.siteadmin)?(null==users&&meshserver.send({action:"users"}),null==wssessions&&meshserver.send({action:"wssessioncount"})):(wssessions=users=null,masterUpdate(16384),(4==xxcurrentView||30<=xxcurrentView&&xxcurrentView<40)&&(setDialogMode(0),go(1),currentUser=null)),meshserver.send({action:"events",limit:parseInt(p3limitdropdown.value)}),QV("ServerConsole",4294967295===userinfo.siteadmin),QV("ServerTrace",4294967295===userinfo.siteadmin),115==xxcurrentView&&4294967295!=userinfo.siteadmin&&go(6),6==xxcurrentView&&0==(21&userinfo.siteadmin)&&go(1),0!=(21&e)&&meshserver.send({action:"serverstats",interval:1e4})}var updateNaggleTimer=null,updateNaggleFlags=0;function masterUpdate(e){updateNaggleFlags|=e,null==updateNaggleTimer&&(updateNaggleTimer=setTimeout(function(){512&updateNaggleFlags&&center(),1&updateNaggleFlags&&onSearchInputChanged(),2&updateNaggleFlags&&onSortSelectChange(!1),128&updateNaggleFlags&&updateMeshes(),4&updateNaggleFlags&&(updateDevices(),updateDeviceDetails(),21==xxcurrentView&&p21updateMesh()),8&updateNaggleFlags&&drawNotifications(),16&updateNaggleFlags&&32768&features&&updateMapMarkers(),32&updateNaggleFlags&&eventsUpdate(),64&updateNaggleFlags&&32768&features&&refreshMap(!1,!0),256&updateNaggleFlags&&drawDeviceTimeline(),1024&updateNaggleFlags&&deviceEventsUpdate(),2048&updateNaggleFlags&&userEventsUpdate(),4096&updateNaggleFlags&&p20updateMesh(),8192&updateNaggleFlags&&updateUserGroups(),16384&updateNaggleFlags&&updateUsers(),32768&updateNaggleFlags&&updateRecordings(),updateNaggleTimer=null,updateNaggleFlags=0,gotoStartViewPage()},150))}function count2factoraAuths(){var e=0;return 1==userinfo.otpsecret&&e++,8388608&features&&1==userinfo.otpekey&&e++,67108864&features&&null!=userinfo.phone&&e++,null!=userinfo.otphkeys&&(e+=userinfo.otphkeys),0<e&&1==userinfo.otpkeys&&e++,e}var backupCodesWarningDone=!1;function updateSelf(){var e=count2factoraAuths();if(QV("verifyEmailId",!0!==userinfo.emailVerified&&null!=userinfo.email&&1==serverinfo.emailcheck),QV("verifyEmailId2",!0!==userinfo.emailVerified&&null!=userinfo.email&&1==serverinfo.emailcheck),QV("manageOtp",0<e),QV("authPhoneNumberCheck",null!=userinfo.phone),QV("authEmailSetupCheck",1==userinfo.otpekey&&null!=userinfo.email&&1==userinfo.emailVerified),QV("authAppSetupCheck",1==userinfo.otpsecret),QV("authKeySetupCheck",0<userinfo.otphkeys),QV("authCodesSetupCheck",0<userinfo.otpkeys),masterUpdate(4228),0==backupCodesWarningDone&&1==e){addNotification({text:"Please add two-factor backup codes. If the current factor is lost, there is not way to recover this account.",title:"Two factor authentication"}),backupCodesWarningDone=!0}var t=4294967295==userinfo.siteadmin||0==(64&userinfo.siteadmin);if(QV("p2createMeshLink1",t),QV("p2createMeshLink2",t),QV("getStarted1",t),QV("getStarted2",!t),"number"==typeof userinfo.passchange)if(-1==userinfo.passchange)QH("p2nextPasswordUpdateTime"," - Reset on next login.");else if(null!=passRequirements&&"number"==typeof passRequirements.reset){var n=userinfo.passchange+86400*passRequirements.reset-Math.floor(Date.now()/1e3);if(n<0)QH("p2nextPasswordUpdateTime"," - Reset on next login.");else if(n<3600){var o=Math.floor(n/60);QH("p2nextPasswordUpdateTime",format(1==o?" - Reset in 1 minute.":" - Reset in {0} minutes.",o))}else if(n<86400){var i=Math.floor(n/3600);QH("p2nextPasswordUpdateTime",format(1==i?" - Reset in 1 hour.":" - Reset in {0} hours.",i))}else{var a=Math.floor(n/86400);QH("p2nextPasswordUpdateTime",format(1==i?" - Reset in 1 day.":" - Reset in {0} days.",a))}}QV("MainMenuMyUsers",null!=users&&0==(4&features)||0!=(512&userinfo.siteadmin)&&0!=(134217728&features)),QV("LeftMenuMyUsers",null!=users&&0==(4&features)||0!=(512&userinfo.siteadmin)&&0!=(134217728&features)),QV("UsersGeneral",null!=users&&0==(4&features)),QV("UsersGroups",null!=users&&0==(4&features)),QV("UsersRecordings",0!=(512&userinfo.siteadmin)&&0!=(134217728&features))}function setSessionActivity(){sessionActivity=Date.now(),QH("idleTimeoutNotify","")}function checkIdleSessionTimeout(){var e=Date.now()-sessionActivity;if(e>serverinfo.timeout)window.location.href="logout";else{var t=Math.round((serverinfo.timeout-e)/1e3);t<=60?QH("idleTimeoutNotify","<br />"+format(1==t?"1 second until disconnect":"{0} seconds until disconnect",t)):(t=Math.round(t/60))<=5&&QH("idleTimeoutNotify","<br />"+format(1==t?"1 minute until disconnect":"{0} minutes until disconnect",t))}}function onMessage(e,t){switch(t.action){case"trace":serverTrace.unshift(t),displayServerTrace();break;case"intersession":"removeNotify"==t.subaction&&notificationDelete(t.id);break;case"traceinfo":"object"==typeof t.traceSources&&(null!=t.traceSources&&0<t.traceSources.length?(serverTraceSources=t.traceSources,QH("p41traceStatus",EscapeHtml(t.traceSources.join(", ")))):(serverTraceSources=[],QH("p41traceStatus","None")));break;case"serverstats":updateGeneralServerStats(t);break;case"serverwarnings":if(null!=t.warnings&&0<t.warnings.length){var n="";for(var o in t.warnings)n+="<div style=color:red;padding-bottom:6px><b>WARNING: "+t.warnings[o]+"</b></div>";QH("serverWarnings",n),QV("serverWarningsDiv",!0)}break;case"servertimelinestats":setServerTimelineStats(t.events);break;case"authcookie":authCookie=t.cookie,authRelayCookie=t.rcookie;break;case"serverinfo":(serverinfo=t.serverinfo).timeout&&(setInterval(checkIdleSessionTimeout,1e4),checkIdleSessionTimeout()),1==debugmode&&console.log("Server time: ",printDateTime(new Date(serverinfo.serverTime)));break;case"userinfo":userinfo=t.userinfo,updateSiteAdmin(),updateSelf();break;case"users":for(var i in users={},t.users)users[t.users[i]._id]=t.users[i];null!=currentUser&&(currentUser=users[currentUser._id]),masterUpdate(16384),updateSelf();break;case"wssessioncount":wssessions=t.wssessions,masterUpdate(16384);break;case"meshes":for(var i in meshes={},t.meshes)meshes[t.meshes[i]._id]=t.meshes[i];null!=currentMesh&&(currentMesh=meshes[currentMesh._id]),masterUpdate(132);break;case"usergroups":var a=0;if(Array.isArray(t.ugroups)){for(var o in usergroups={},t.ugroups)a++,usergroups[t.ugroups[o]._id]=t.ugroups[o];0==a&&(usergroups=null)}else{for(var o in usergroups=t.ugroups,t.ugroups)a++,t.ugroups[o]._id=o;0==a&&(usergroups=null)}masterUpdate(8192);break;case"files":filetree=setupBackPointers(t.filetree),updateFiles(),d3updatefiles();break;case"nodes":for(var i in nodes=[],t.nodes)for(var s in t.nodes[i])null!=t.nodes[i][s]._id?(t.nodes[i][s].namel=t.nodes[i][s].name.toLowerCase(),t.nodes[i][s].rname?t.nodes[i][s].rnamel=t.nodes[i][s].rname.toLowerCase():t.nodes[i][s].rnamel=t.nodes[i][s].namel,t.nodes[i][s].meshnamel=meshes[i]?meshes[i].name.toLowerCase():"*",t.nodes[i][s].meshid=i,t.nodes[i][s].state=t.nodes[i][s].state?t.nodes[i][s].state:0,t.nodes[i][s].icon||(t.nodes[i][s].icon=1),t.nodes[i][s].ident=++nodeShortIdent,nodes.push(t.nodes[i][s])):console.log("Invalid node ("+s+"): "+JSON.stringify(t.nodes));null!=currentNode&&0==IsNodeViewable(currentNode)&&(currentNode=null,go(1)),null!=currentNode&&(null!=(currentNode=getNodeFromId(currentNode._id))?gotoDevice(currentNode._id,xxcurrentView,!0):go(1)),masterUpdate(71);break;case"powertimeline":if(t.nodeid!=powerTimelineReq)break;for(var o in powerTimelineNode=t.nodeid,powerTimeline=t.timeline,powerTimelineUpdate=Date.now()+3e5,powerTimeline)o%2==1&&(powerTimeline[o]=1e3*powerTimeline[o]);currentNode._id==t.nodeid&&masterUpdate(256);break;case"getsysinfo":if(t.nodeid!=powerTimelineReq)break;!0===t.noinfo?updateDeviceDetails(getNodeFromId(t.nodeid)):updateDeviceDetails(getNodeFromId(t.nodeid),t.hardware);break;case"lastconnect":null!=(L=getNodeFromId(t.nodeid))&&(L.lastconnect=t.time,L.lastaddr=t.addr,currentNode._id==L._id&&""==Q("MainComputerState").innerHTML&&QH("MainComputerState","<span>Last seen:<br />"+printDateTime(new Date(L.lastconnect))+"</span>"));break;case"msg":if(null!=t.nodeid){var r=-1;if(null!=nodes)for(var o in nodes)if(nodes[o]._id==t.nodeid){r=o;break}if(-1!=r)if("console"==t.type)p15consoleReceive(nodes[r],t.value,t.source);else if("notify"==t.type){if(0==(8&(s=getstore("notifications",0)))&&null!=t.amtMessage)break;s={text:t.value,title:t.title,icon:t.icon};null!=t.id&&(s.id=t.id),null!=t.nodeid&&(s.nodeid=t.nodeid),null!=t.tag&&(s.tag=t.tag),null!=t.username&&(s.username=t.username),addNotification(s)}else if("ps"==t.type)showDeskToolsProcesses(t);else if("services"==t.type)showDeskToolsServices(t);else if("getclip"==t.type&&"clipboard"==xxdialogTag&&null!=currentNode&&currentNode._id==t.nodeid)Q("d2clipText").value=t.data;else if("setclip"==t.type&&"clipboard"==xxdialogTag&&null!=currentNode&&currentNode._id==t.nodeid)QH("dlgClipStatus",t.success?"<span style=color:green>Success</span>":"<span style=color:red>Failed</span>"),setTimeout(function(){try{QH("dlgClipStatus","")}catch(e){}},2e3);else if("userSessions"==t.type&&null!=currentNode&&currentNode._id==t.nodeid&&null==desktop){var l=[];if(null!=t.data)for(var o in t.data)"Active"!=t.data[o].State&&"Console"!=t.data[o].StationName&&3!=debugmode||l.push(t.data[o]);if(0==l.length)connectDesktop(null,1,null,t.tag);else if(1==l.length)connectDesktop(null,1,l[0].SessionId,t.tag);else{n="";for(var o in l)n+='<div style="text-align:left;cursor:pointer;background-color:gray;margin:5px;padding:5px;border-radius:5px" onclick=connectDesktop(event,1,'+l[o].SessionId+","+t.tag+")>"+l[o].State+", "+l[o].StationName,l[o].Username&&(l[o].Domain?n+=" - "+l[o].Domain+"/"+l[o].Username:n+=" - "+l[o].Username),n+="</div>";QH("p11DeskSessionSelector",n),QV("p11DeskSessionSelector",!0)}}}else if("notify"==t.type){s={text:t.value,title:t.title,icon:t.icon};null!=t.id&&(s.id=t.id),null!=t.tag&&(s.tag=t.tag),null!=t.username&&(s.username=t.username),addNotification(s)}break;case"getnetworkinfo":if(currentNode._id!=t.nodeid)return;if(updateDeviceDetails(getNodeFromId(t.nodeid),null,t),2==xxdialogMode&&xxdialogTag=="if"+t.nodeid)if(null==t.netif)QH("d2netinfo","No network interface information available for this device.");else{n="<div class=dialogText>";if(currentNode.lastconnect&&(n+=addHtmlValue2("Last agent connection",printDateTime(new Date(currentNode.lastconnect)))),currentNode.lastaddr){var d=currentNode.lastaddr.split(":");2<d.length?n+=addHtmlValue2("Last agent address",currentNode.lastaddr+' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(currentNode.lastaddr)+'") width=10 height=10>'):isPrivateIP(currentNode.lastaddr)?n+=addHtmlValue2("Last agent address",d[0]+' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(d[0])+'") width=10 height=10>'):n+=addHtmlValue2("Last agent address",'<a href="https://iplocation.com/?ip='+d[0]+'" rel="noreferrer noopener" target="MeshIPLoopup">'+d[0]+'</a> <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(d[0])+'") width=10 height=10>')}for(var o in n+=addHtmlValue2("Last interfaces update",printDateTime(new Date(t.updateTime))),t.netif){var c=t.netif[o];n+="<hr />",c.name&&(n+=addHtmlValue2("Name","<b>"+EscapeHtml(c.name)+"</b>")),c.desc&&(n+=addHtmlValue2("Description",EscapeHtml(c.desc).replace("(R)","&reg;").replace("(r)","&reg;"))),c.dnssuffix&&(n+=addHtmlValue2("DNS suffix",EscapeHtml(c.dnssuffix)+' <img src="images/link4.png" title="Copy name to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(c.dnssuffix)+'") width=10 height=10>')),c.mac&&(n+=addHtmlValue2("MAC address",'<a href="https://dnslytics.com/mac-address-lookup/'+c.mac.substring(0,6)+'" rel="noreferrer noopener" target="MeshMACLoopup">'+EscapeHtml(c.mac.toLowerCase())+'</a> <img src="images/link4.png" title="Copy MAC address to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(c.mac.toLowerCase())+'") width=10 height=10>')),c.v4addr&&(n+=addHtmlValue2("IPv4 address",EscapeHtml(c.v4addr)+' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(c.v4addr)+'") width=10 height=10>')),c.v4mask&&(n+=addHtmlValue2("IPv4 mask",EscapeHtml(c.v4mask)+' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(c.v4mask)+'") width=10 height=10>')),c.v4gateway&&(n+=addHtmlValue2("IPv4 gateway",EscapeHtml(c.v4gateway)+' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(c.v4gateway)+'") width=10 height=10>')),c.gatewaymac&&(n+=addHtmlValue2("Gateway MAC",'<a href="https://dnslytics.com/mac-address-lookup/'+c.gatewaymac.substring(0,6)+'" rel="noreferrer noopener" target="MeshMACLoopup">'+EscapeHtml(c.gatewaymac.toLowerCase())+'</a> <img src="images/link4.png" title="Copy MAC address to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(c.gatewaymac.toLowerCase())+'") width=10 height=10>'))}n+="</div>",QH("d2netinfo",n)}break;case"serverversion":if(2==xxdialogMode&&"MeshCentralServerUpdate"==xxdialogTag){n="<div class=dialogText>";t.tags.current||(t.tags.current="Unknown"),t.tags.stable||(t.tags.stable="Unknown"),t.tags.latest||(t.tags.latest="Unknown"),n+=addHtmlValue2("Current Version","<b>"+EscapeHtml(t.tags.current)+"</b>"),n+="<hr />",n+=addHtmlValue2("<label><input id=d2updateCheck1 type=checkbox onclick=server_showVersionDlgUpdate()"+("Unknown"==t.tags.stable||t.tags.current==t.tags.stable?" disabled":"")+" /> Stable Version</label>","<b>"+EscapeHtml(t.tags.stable)+"</b>"),n+=addHtmlValue2("<label><input id=d2updateCheck2 type=checkbox onclick=server_showVersionDlgUpdate()"+("Unknown"==t.tags.latest||t.tags.current==t.tags.latest?" disabled":"")+" /> Latest Version</label>","<b>"+EscapeHtml(t.tags.latest)+"</b>"),n+="</div>",t.tags.current==t.tags.latest&&t.tags.current==t.tags.stable||0==(2048&features)?setDialogMode(2,"MeshCentral Version",1,null,n):(setDialogMode(2,"MeshCentral Version",3,server_showVersionDlgEx,n+="<hr />Check and click OK to start server self-update.",t.tags),server_showVersionDlgUpdate())}break;case"servererrors":if(2==xxdialogMode&&"MeshCentralServerErrors"==xxdialogTag)if(null==t.data)setDialogMode(2,"MeshCentral Server Errors",1,null,"Server has no error log.");else{n='<div class="dialogText dialogTextLog"><pre id=d2ServerErrorsLogPre>'+EscapeHtml(t.data)+"</pre></div>";n+='<br /><div style=float:right><img src=images/link4.png height=10 width=10 title="Download error log" style=cursor:pointer onclick=d2CopyServerErrorsToClip()></div>',setDialogMode(2,"MeshCentral Server Errors",3,server_showErrorsDlgEx,n+="<div><label><input id=d2clearErrorsCheck type=checkbox onclick=server_showErrorsDlgUpdate() /> Check and click OK to clear error log.</label></div>"),server_showErrorsDlgUpdate()}break;case"serverconsole":p15consoleReceive("serverconsole",t.value);break;case"events":null!=t.nodeid&&null!=currentNode&&t.nodeid==currentNode._id?(currentDeviceEvents=t.events,masterUpdate(1024)):null!=t.user&&t.user==currentUser.name?(currentUserEvents=t.events,masterUpdate(2048)):(events=t.events,masterUpdate(32));break;case"recordings":p52recordings=t.events,updateRecordings();break;case"getcookie":if("clickonce"==t.tag)if(1==t.trustedCert){var u=window.location.origin+domainUrl+"clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F"+window.location.hostname+"%2Fmeshrelay.ashx%3Fauth="+t.cookie+"&CH={{{webcerthash}}}&AP="+t.protocol+(1==debugmode?"":"&HOL=1");window.open(u,"_blank").opener=null}else{var p=""=="{{{serverRedirPort}}}".toLowerCase()?"{{{serverPublicPort}}}":"{{{serverRedirPort}}}";u="http://"+window.location.hostname+":"+p+domainUrl+"clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F"+window.location.hostname+"%2Fmeshrelay.ashx%3Fauth="+t.cookie+"&CH={{{webcerthash}}}&AP="+t.protocol+(1==debugmode?"":"&HOL=1");window.open(u,"_blank").opener=null}else if("novnc"==t.tag){var m=window.location.origin+domainUrl+"novnc/vnc.html?ws=wss%3A%2F%2F"+window.location.host+"%2Fmeshrelay.ashx%3Fauth%3D"+t.cookie+"&show_dot=1"+(urlargs.key?"&key="+urlargs.key:"");null!=(L=getNodeFromId(t.nodeid))&&(m+="&name="+encodeURIComponentEx(L.name)),window.open(m,"mcnovnc/"+t.nodeid).opener=null}else if("mstsc"==t.tag){u=window.location.origin+domainUrl+"mstsc.html?ws="+t.cookie+(urlargs.key?"&key="+urlargs.key:"");null!=(L=getNodeFromId(t.nodeid))&&(u+="&name="+encodeURIComponentEx(L.name)),window.open(u,"mcmstsc/"+t.nodeid).opener=null}break;case"getNotes":if((s=Q("d2devNotes"))&&t.id==decodeURIComponent(s.attributes.noteid.value))t.notes?QH("d2devNotes",decodeURIComponent(t.notes)):QH("d2devNotes",""),0==("true"==s.attributes.ro.value)&&(s.removeAttribute("readonly"),QE("idx_dlgOkButton",!0),QV("idx_dlgOkButton",!0),focusTextBox("d2devNotes"));break;case"otpauth-request":if(2==xxdialogMode&&"otpauth-request"==xxdialogTag){var g=t.secret;52==g.length?g=g.split(/(.............)/).filter(Boolean).join(" "):32==g.length&&(g=(g=g.split(/(....)/).filter(Boolean).join(" ")).substring(0,20)+"<br/>"+g.substring(20)),QH("d2optinfo","<table style=width:380px><tr><td style=vertical-align:top>"+format('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="{0}" 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.',t.url)+'<br /><br />Secret<br /><tt id=d2optsecret secret="'+t.secret+'" style=font-size:12px>'+g+'</tt><br /><br /></td><td style=width:1px;vertical-align:top><a href="'+t.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 autocomplete="one-time-code" inputmode="numeric" pattern="[0-9]*" 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:t.url,width:128,height:128,colorDark:"#000000",colorLight:"#EEE",correctLevel:QRCode.CorrectLevel.H}),QV("idx_dlgOkButton",!0),QE("idx_dlgOkButton",!1),Q("d2otpauthinput").focus()}break;case"otpauth-setup":if(xxdialogMode)return;setDialogMode(2,"Authenticator App",1,null,t.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,t.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;n="One time tokens can be used as secondary authentication. Generate a set, print them and keep them in a safe place.";if(n+='<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 class=selecttext style=width:100%;text-align:center>',t.passwords){var h=0,v="";for(var o in t.passwords){++h%2&&(n+="<tr>");for(var f=""+t.passwords[o].p;f.length<8;)f="0"+f;!0===t.passwords[o].u?(n+="<td>"+f.substring(0,4)+"&nbsp;"+f.substring(4),""!=v&&(v+=" "),v+=f):n+="<td><strike style=color:#BBB>"+f.substring(0,4)+"&nbsp;"+f.substring(4)}}else n+="<tr><td>No Active Tokens";n+="</table></div></div><br />",n+="<div><input type=button value=Close onclick=setDialogMode(0) style=float:right></input>",n+='<input type=button value="Generate New Tokens" onclick="account_manageOtp(1);"></input>',null!=t.passwords&&(n+='<input type=button value="Clear Tokens" onclick="account_manageOtp(2);"></input>',n+='&nbsp;<img src=images/link4.png height=10 width=10 title="Copy valid codes to clipboard" style=cursor:pointer onclick=copyTextToClip2("'+encodeURIComponentEx(v)+'")>'),setDialogMode(2,"Manage Backup Codes",8,null,n+="</div><br />","otpauth-manage");break;case"otp-hkey-get":if(xxdialogMode&&"otpauth-hardware-manage"!=xxdialogTag)return;var k='<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>',x="</table></div></div>";n='<a href="https://www.yubico.com/" rel="noreferrer noopener" target="_blank">Hardware keys</a> are used as secondary login authentication.';if(n+='<div style="max-height:150px;overflow-y:auto;overflow-x:hidden;margin-top:6px;margin-bottom:6px">',t.keys&&0<t.keys.length)for(var o in t.keys){var y=t.keys[o];n+=k+'<tr style=margin:5px><td style=width:30px><img width=24 height=18 src="images/hardware-key-'+(2==y.type?"OTP":"WebAuthn")+'-24.png" style=margin-top:4px><td style=width:250px>'+y.name+'<td><input type=button value="Remove" onclick=account_removehkey('+y.i+")></input>"+x}else n+=k+"<tr style=text-align:center><td>No Keys Configured"+x;n+="</div>",n+='<div><input type=button value="Close" onclick=setDialogMode(0) style=float:right></input>',0!=(131072&features)&&(n+='<input id=d2addkey3 type=button value="Add Key" onclick="account_addhkey(3);"></input>'),0!=(16384&features)&&(n+='<input id=d2addkey2 type=button value="Add YubiKey&reg; OTP" onclick="account_addhkey(2);"></input>'),setDialogMode(2,"Manage Security Keys",8,null,n+="</div><br />","otpauth-hardware-manage"),0==u2fSupported()&&QE("d2addkey1",!1);break;case"otp-hkey-yubikey-add":t.result?meshserver.send({action:"otp-hkey-get"}):setDialogMode(2,"Add Security Key",1,null,"<br />Error, Unable to add key.<br /><br />");break;case"otp-hkey-setup-response":if(xxdialogMode&&"otpauth-hardware-manage"!=xxdialogTag)return;1==t.result?meshserver.send({action:"otp-hkey-get"}):setDialogMode(2,"Add Security Key",1,null,"<br />ERROR: Unable to add key.<br /><br />","otpauth-hardware-manage");break;case"webauthn-startregister":if(xxdialogMode&&"otpauth-hardware-manage"!=xxdialogTag)return;setDialogMode(2,"Add Security Key",2,null,n='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='+t.name+" />");var b=t.request;t.request.challenge=Uint8Array.from(atob(t.request.challenge),function(e){return e.charCodeAt(0)}),t.request.user.id=Uint8Array.from(atob(t.request.user.id),function(e){return e.charCodeAt(0)}),setTimeout(function(){navigator.credentials.create({publicKey:b}).then(function(e){var t={rawId:btoa(String.fromCharCode.apply(null,new Uint8Array(e.rawId))),response:{attestationObject:btoa(String.fromCharCode.apply(null,new Uint8Array(e.response.attestationObject))),clientDataJSON:btoa(String.fromCharCode.apply(null,new Uint8Array(e.response.clientDataJSON)))},type:e.type};meshserver.send({action:"webauthn-endregister",response:t}),setDialogMode(0)},function(e){setDialogMode(2,"Add Security Key",1,null,"ERROR: "+e)})},100);break;case"verifyPhone":if(xxdialogMode&&"verifyPhone"!=xxdialogTag)return;n='<table><tr><td><img src="images/phone80.png" style=padding:8px>';n+="<td>Check your phone and enter the verification code.",setDialogMode(2,"Phone Notifications",3,account_managePhoneConfirm,n+='<br /><br /><div style=width:100%;text-align:center>Verification code: <input type=tel pattern="[0-9]" inputmode="number" maxlength=6 id=d2phoneCodeInput onKeyUp=account_managePhoneCodeValidate() onkeypress="if (event.key==\'Enter\') account_managePhoneCodeValidate(1)"></div></table>',t.cookie),Q("d2phoneCodeInput").focus(),account_managePhoneCodeValidate();break;case"event":if(!t.event.nolog){if(currentNode&&t.event.nodeid==currentNode._id){currentDeviceEvents.unshift(t.event);for(var w=parseInt(p16limitdropdown.value);currentDeviceEvents.length>w;)currentDeviceEvents.pop();masterUpdate(1024)}if(currentUser&&t.event.userid==currentUser._id){currentUserEvents.unshift(t.event);for(w=parseInt(p31limitdropdown.value);currentUserEvents.length>w;)currentUserEvents.pop();masterUpdate(2048)}events.unshift(t.event);for(w=parseInt(p3limitdropdown.value);events.length>w;)events.pop();masterUpdate(32)}if(t.event.noact)break;switch(t.event.action){case"recording":null!=p52recordings&&(p52recordings.unshift(t.event),t.event.present=1,updateRecordings());break;case"userWebState":try{if(null!=localStorage){var C=localStorage.getItem("showRealNames"),D=localStorage.getItem("uiMode"),S=localStorage.getItem("sort"),M=localStorage.getItem("loctag"),E=localStorage.getItem("nightMode"),A=localStorage.getItem("footerBar"),T=JSON.parse(t.event.state);for(var o in T)localStorage.setItem(o,T[o]);null!=T.deskAspectRatio&&T.deskAspectRatio!=deskAspectRatio&&(deskAspectRatio=T.deskAspectRatio,deskAdjust()),null!=T.showRealNames&&T.showRealNames!=C&&(showRealNames=Q("RealNameCheckBox").checked="1"==T.showRealNames,masterUpdate(6)),null!=T.uiMode&&T.uiMode!=D&&userInterfaceSelectMenu(parseInt(T.uiMode)),null!=T.sort&&T.sort!=S&&(document.getElementById("sortselect").selectedIndex=sort=parseInt(T.sort),masterUpdate(6)),null!=T.loctag&&T.loctag!=M&&(null!=T.loctag?args.locale=T.loctag:delete args.locale,masterUpdate(4294967295)),null!=T.nightMode&&T.nightMode!=E&&((nightMode="1"==T.nightMode)?(QC("body").add("night"),QS("body")["background-color"]="#000"):(QC("body").remove("night"),QS("body")["background-color"]="#d3d9d6")),null!=T.footerBar&&T.footerBar!=A&&(footerBar="1"==T.footerBar,QS("container")["grid-template-rows"]=null,QS("container")["-ms-grid-rows"]=null,adjustPanels())}}catch(e){}break;case"servertimelinestats":addServerTimelineStats(t.event.data);break;case"accountcreate":case"accountchange":if(userinfo._id==t.event.account._id){var N=t.event.account.siteadmin?t.event.account.siteadmin:0,U=userinfo.siteadmin?userinfo.siteadmin:0;(t.event.account.quota!=userinfo.quota||0==(8&userinfo.siteadmin)&&0!=(8&t.event.account.siteadmin))&&meshserver.send({action:"files"});var I=userinfo.groups;if(userinfo=t.event.account,U!=N&&updateSiteAdmin(),updateSelf(),0!=(2&userinfo.siteadmin)){var _=I||[],V=userinfo.groups?userinfo.groups:[];_.join(",")!=V.join(",")&&(users=wssessions=null,meshserver.send({action:"users"}),meshserver.send({action:"wssessioncount"}))}t.event.nodeListChange==userinfo._id&&meshserver.send({action:"nodes"})}if(null==users)break;null==userinfo.groups||0==userinfo.groups.length||1==findOne(t.event.account.groups,userinfo.groups)?users[t.event.account._id]=t.event.account:delete users[t.event.account._id],masterUpdate(16388);break;case"accountremove":if(null==users)break;delete users[t.event.userid],masterUpdate(16384);break;case"createusergroup":case"usergroupchange":null==usergroups&&(usergroups={});var R=usergroups[t.event.ugrpid];null==R?usergroups[t.event.ugrpid]={_id:t.event.ugrpid,name:t.event.name,desc:t.event.desc,domain:t.event.domain,links:t.event.links}:(R.name=t.event.name,t.event.desc?R.desc=t.event.desc:delete R.desc,t.event.links?R.links=t.event.links:delete R.links),masterUpdate(28672),meshserver.send({action:"meshes"}),meshserver.send({action:"nodes"});break;case"deleteusergroup":if(null!=usergroups&&null!=usergroups[t.event.ugrpid]){delete usergroups[t.event.ugrpid];var H=0;for(var o in usergroups)H++;0==H&&(usergroups=null),masterUpdate(24576)}break;case"createmesh":null!=meshes[t.event.meshid]||!serverinfo.manageAllDeviceGroups&&null==t.event.links[userinfo._id]||(meshes[t.event.meshid]={_id:t.event.meshid,name:t.event.name,mtype:t.event.mtype,desc:t.event.desc,links:t.event.links},masterUpdate(24708),meshserver.send({action:"files"}));break;case"meshchange":if(null==meshes[t.event.meshid]){var F=!1;for(var o in null!=t.event.links[userinfo._id]&&(F=!0),null!=userinfo.links[t.event.meshid]&&(F=!0),userinfo.links)o.startsWith("ugrp/")&&null!=t.event.links[o]&&(F=!0);F&&(meshes[t.event.meshid]={_id:t.event.meshid,name:t.event.name,mtype:t.event.mtype,desc:t.event.desc,links:t.event.links},meshserver.send({action:"nodes"}))}else{if(null!=t.event.name)for(var o in meshes[t.event.meshid].name=t.event.name,nodes)nodes[o].meshid==t.event.meshid&&(nodes[o].meshnamel=t.event.name.toLowerCase());if(null!=t.event.desc&&(meshes[t.event.meshid].desc=t.event.desc),null!=t.event.flags&&(meshes[t.event.meshid].flags=t.event.flags),null!=t.event.consent&&(meshes[t.event.meshid].consent=t.event.consent),t.event.links&&(meshes[t.event.meshid].links=t.event.links),t.event.amt&&(meshes[t.event.meshid].amt=t.event.amt),null!=t.event.invite?meshes[t.event.meshid].invite=t.event.invite:delete meshes[t.event.meshid].invite,0==IsMeshViewable(t.event.meshid)){20==xxcurrentView&&currentMesh==meshes[t.event.meshid]&&go(2),delete meshes[t.event.meshid];var P=[];for(var o in nodes)(nodes[o].meshid!=t.event.meshid||null!=userinfo.links&&null!=userinfo.links[nodes[o]._id])&&P.push(nodes[o]);nodes=P,10<=xxcurrentView&&xxcurrentView<20&&currentNode&&!IsNodeViewable(currentNode)&&(setDialogMode(0),go(1))}}masterUpdate(24708),currentNode&&!IsNodeViewable(currentNode)&&(currentNode=null,10<=xxcurrentView&&xxcurrentView<20&&go(1)),20==xxcurrentView&&currentMesh._id==t.event.meshid&&masterUpdate(4096);break;case"deletemesh":meshes[t.event.meshid]&&(delete meshes[t.event.meshid],masterUpdate(128),meshserver.send({action:"files"}));P=[];if(null!=nodes)for(var o in nodes)nodes[o].meshid!=t.event.meshid&&P.push(nodes[o]);nodes=P,masterUpdate(24580),20<=xxcurrentView&&xxcurrentView<30&&currentMesh._id==t.event.meshid&&(setDialogMode(0),go(2)),10<=xxcurrentView&&xxcurrentView<20&&currentNode&&!IsNodeViewable(currentNode)&&(setDialogMode(0),go(1));break;case"addnode":var L=t.event.node;if(!meshes[L.meshid])break;if(null!=getNodeFromId(L._id))break;L.namel=L.name.toLowerCase(),L.rname?L.rnamel=L.rname.toLowerCase():L.rnamel=L.namel,L.meshnamel=meshes[L.meshid]?meshes[L.meshid].name.toLowerCase():"*",L.state=0,L.icon||(L.icon=1),L.ident=++nodeShortIdent,nodes.push(L),masterUpdate(23);break;case"removenode":r=-1;for(var o in nodes)if(nodes[o]._id==t.event.nodeid){r=o;break}if(-1!=r){L=nodes[r];currentNode==L&&(10<=xxcurrentView&&xxcurrentView<20&&(setDialogMode(0),go(1)),currentNode=null),nodes.splice(r,1),masterUpdate(20)}break;case"changenode":r=-1;for(var o in nodes)if(nodes[o]._id==t.event.nodeid){r=o;break}if(-1!=r)(L=nodes[r]).name=t.event.node.name,L.rname=t.event.node.rname,L.users=t.event.node.users,L.host=t.event.node.host,L.desc=t.event.node.desc,L.ip=t.event.node.ip,L.osdesc=t.event.node.osdesc,L.publicip=t.event.node.publicip,L.iploc=t.event.node.iploc,L.wifiloc=t.event.node.wifiloc,L.gpsloc=t.event.node.gpsloc,L.tags=t.event.node.tags,L.userloc=t.event.node.userloc,L.rdpport=t.event.node.rdpport,L.rfbport=t.event.node.rfbport,L.consent=t.event.node.consent,null!=t.event.node.links?L.links=t.event.node.links:delete L.links,null!=t.event.node.agent&&(null==L.agent&&(L.agent={}),null!=t.event.node.agent.ver&&(L.agent.ver=t.event.node.agent.ver),null!=t.event.node.agent.id&&(L.agent.id=t.event.node.agent.id),null!=t.event.node.agent.caps&&(L.agent.caps=t.event.node.agent.caps),null!=t.event.node.agent.core?L.agent.core=t.event.node.agent.core:L.agent.core&&delete L.agent.core,L.agent.tag=t.event.node.agent.tag),null!=t.event.node.intelamt&&(null==L.intelamt&&(L.intelamt={}),null!=t.event.node.intelamt.state&&(L.intelamt.state=t.event.node.intelamt.state),null!=t.event.node.intelamt.host&&(L.intelamt.user=t.event.node.intelamt.host),null!=t.event.node.intelamt.user&&(L.intelamt.user=t.event.node.intelamt.user),null!=t.event.node.intelamt.tls&&(L.intelamt.tls=t.event.node.intelamt.tls),null!=t.event.node.intelamt.ver&&(L.intelamt.ver=t.event.node.intelamt.ver),null!=t.event.node.intelamt.tag&&(L.intelamt.tag=t.event.node.intelamt.tag),null!=t.event.node.intelamt.uuid&&(L.intelamt.uuid=t.event.node.intelamt.uuid),null!=t.event.node.intelamt.realm&&(L.intelamt.realm=t.event.node.intelamt.realm)),null!=t.event.node.av&&(L.av=t.event.node.av),L.namel=L.name.toLowerCase(),L.rname?L.rnamel=L.rname.toLowerCase():L.rnamel=L.namel,t.event.node.icon&&(L.icon=t.event.node.icon),masterUpdate(30),refreshDevice(L._id),currentNode==L&&null!=xxdialogMode&&"@xxmap"==xxdialogTag&&p10showNodeLocationDialog();break;case"nodemeshchange":r=-1;for(var o in nodes)if(nodes[o]._id==t.event.nodeid){r=o;break}if(-1!=r){L=nodes[r];null!=meshes[t.event.newMeshId]||null!=userinfo.links&&null!=userinfo.links[L._id]?(L.meshid=t.event.newMeshId,L.meshnamel=meshes[t.event.newMeshId]?meshes[t.event.newMeshId].name.toLowerCase():"*",masterUpdate(7)):(10<=xxcurrentView&&xxcurrentView<20&&!IsNodeViewable(currentNode)&&(currentNode=null,setDialogMode(0),go(1)),nodes.splice(r,1),masterUpdate(20)),refreshDevice(t.event.nodeid)}else{L=t.event.node;if(!meshes[L.meshid])break;L.namel=L.name.toLowerCase(),L.rname?L.rnamel=L.rname.toLowerCase():L.rnamel=L.namel,L.meshnamel=meshes[L.meshid]?meshes[L.meshid].name.toLowerCase():"*",L.state=0,L.icon||(L.icon=1),L.ident=++nodeShortIdent,nodes.push(L),masterUpdate(23)}break;case"nodeconnect":r=-1;for(var o in nodes)if(nodes[o]._id==t.event.nodeid){r=o;break}if(-1!=r){L=nodes[r],s=getstore("notifications",0);t.event.meshid&&userinfo.links&&userinfo.links[t.event.meshid]&&userinfo.links[t.event.meshid].notify?s&=userinfo.links[t.event.meshid].notify:s=0,2&s&&(0==(1&L.conn)&&0!=(1&t.event.conn)&&addNotification({text:"Agent connected",title:L.name,icon:L.icon,nodeid:L._id}),0==(2&L.conn)&&0!=(2&t.event.conn)&&addNotification({text:"Intel AMT detected",title:L.name,icon:L.icon,nodeid:L._id}),0==(4&L.conn)&&0!=(4&t.event.conn)&&addNotification({text:"Intel AMT CIRA connected",title:L.name,icon:L.icon,nodeid:L._id}),0==(16&L.conn)&&0!=(16&t.event.conn)&&addNotification({text:"MQTT connected",title:L.name,icon:L.icon,nodeid:L._id})),4&s&&(0!=(1&L.conn)&&0==(1&t.event.conn)&&addNotification({text:"Agent disconnected",title:L.name,icon:L.icon,nodeid:L._id}),0!=(2&L.conn)&&0==(2&t.event.conn)&&addNotification({text:"Intel AMT not detected",title:L.name,icon:L.icon,nodeid:L._id}),0!=(4&L.conn)&&0==(4&t.event.conn)&&addNotification({text:"Intel AMT CIRA disconnected",title:L.name,icon:L.icon,nodeid:L._id}),0!=(16&L.conn)&&0==(16&t.event.conn)&&addNotification({text:"MQTT disconnected",title:L.name,icon:L.icon,nodeid:L._id})),L.conn=t.event.conn,L.pwr=t.event.pwr,L.lastconnect=Date.now(),0==(1&L.conn)&&delete L.sessions,masterUpdate(21),refreshDevice(L._id)}break;case"wssessioncount":null!=wssessions&&(0==t.event.count&&wssessions[t.event.userid]?delete wssessions[t.event.userid]:wssessions[t.event.userid]=t.event.count,masterUpdate(16384));break;case"login":null!=users&&users[t.event.userid]&&(users[t.event.userid].login=Math.floor(new Date(t.event.time).getTime()/1e3));break;case"scanamtdevice":if(null==xxdialogMode||!Q("dp1range")||Q("dp1range").value!=t.event.range)return;n="";if(null==t.event.results)n="<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{for(var o in amtScanResults=t.event.results,t.event.results){var B=t.event.results[o],O=B.hostname;"host"==B.hosttype&&(O=capitalizeFirstLetter(O.split(".")[0])),20<O.length&&(O=O.substring(0,20)+"...");var G='<b title="'+EscapeHtml(B.hostname)+'">'+EscapeHtml(O)+"</b> - v"+B.ver;2==B.state?1==B.tls?G+=" with TLS.":G+=" without TLS.":G+=" not activated.",n+='<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(o)+'" 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>'+G+"</div></div></div>"}""==n&&(n="<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",n),QE("dp1range",!0),QE("dp1rangebutton",!0);break;case"notify":s={text:t.event.value,title:t.event.title,icon:t.event.icon};null!=t.id&&(s.id=t.id),null!=t.event.tag&&(s.tag=t.event.tag),addNotification(s);break;case"traceinfo":"object"==typeof t.event.traceSources&&(null!=t.event.traceSources&&0<t.event.traceSources.length?(serverTraceSources=t.event.traceSources,QH("p41traceStatus",EscapeHtml(t.event.traceSources.join(", ")))):(serverTraceSources=[],QH("p41traceStatus","None")));break;case"sysinfohash":null!=currentNode&&t.event.nodeid==powerTimelineReq&&meshserver.send({action:"getsysinfo",nodeid:t.event.nodeid});break;case"devicesessions":if(null==(L=getNodeFromId(t.event.nodeid)))break;if(L.sessions=t.event.sessions,null!=L.sessions){for(var o in L.sessions)0==Object.keys(L.sessions[o]).length&&delete L.sessions[o];0==Object.keys(L.sessions).length&&delete L.sessions}masterUpdate(4),null!=currentNode&&currentNode._id==t.event.nodeid&&gotoDevice(currentNode._id,xxcurrentView,!0),xxdialogTag=="SESSIONS-"+t.event.nodeid&&showDeviceSessions(t.event.nodeid,!0);break;case"stopped":break;case"updatePluginList":installedPluginList=t.event.list,updatePluginList();break;case"pluginStateChange":if(null==pluginHandler)break;pluginHandler.refreshPluginHandler();break;case"plugin":if(null==pluginHandler)break;try{pluginHandler[t.event.plugin][t.event.pluginaction](t)}catch(e){console.log("PluginHandler could not event message: ",e)}}break;case"createInviteLink":if(xxdialogTag!=t.meshid)break;var z=serverinfo.name;-1!=z.indexOf(".")&&0==(2&features)||(z=window.location.hostname);var K;domainUrl.substring(0,domainUrl.length-1);if(1==serverinfo.https)K="https://"+z+(443==serverinfo.port?"":":"+serverinfo.port)+domainUrl+"agentinvite?c="+t.cookie+(urlargs.key?"&key="+urlargs.key:"");else K="http://"+z+(80==serverinfo.port?"":":"+serverinfo.port)+domainUrl+"agentinvite?c="+t.cookie+(urlargs.key?"&key="+urlargs.key:"");Q("agentInvitationLink").href=K;var W=format(1==t.expire?"1 hour":"{0} hours",t.expire);24==t.expire&&(W="1 day"),168==t.expire&&(W="1 week"),5040==t.expire&&(W="1 month"),0==t.expire&&(W="Unlimited"),QH("agentInvitationLink",format("Invitation Link ({0})",W)),QV("agentInvitationLinkDiv",!0);break;case"getmqttlogin":if(null==currentNode||currentNode._id!=t.nodeid||null!=xxdialogMode)return;n="These settings can be used to connect MQTT for this device.<br /><br />";delete t.action,delete t.nodeid,setDialogMode(2,"MQTT Credentials",1,null,n+="<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>"+JSON.stringify(t)+"</textarea>");break;case"stopped":autoReconnect=!1,QH("p0span",t.msg);break;case"updatePluginList":installedPluginList=t.list,updatePluginList();break;case"pluginVersionsAvailable":if(null==pluginHandler)break;updatePluginList(t.list);break;case"downgradePluginVersions":var j='<select id="lastPluginVersion">';t.info.versionList.forEach(function(e){j+='<option value="'+e.zipball_url+'">'+e.name+"</option>"}),j+="</select>",setDialogMode(2,"Plugin Action",3,pluginActionEx,format("Select the version to downgrade the plugin: {0}",t.info.name)+"<hr />"+j+"<hr />Please be aware that downgrading is not recommended. Please only do so in the event that a recent upgrade has broken something.NaN"+t.info.id+'" />');break;case"pluginError":setDialogMode(2,"Plugin Error",1,null,t.msg);break;case"plugin":if(null==pluginHandler||"string"!=typeof t.plugin)break;try{pluginHandler[t.plugin][t.method](e,t)}catch(e){console.log("Error loading plugin handler ("+e+")")}}}function gotoStartViewPage(){var e=parseInt("{{viewmode}}");if(-1==xxcurrentView){if(""!="{{currentNode}}".toLowerCase()){if(null==getNodeFromId("{{currentNode}}"))return;gotoDevice("{{currentNode}}",e)}else if(null!=args.gotonode){if(null==getNodeFromId("node/"+domain+"/"+args.gotonode))return;gotoDevice("node/"+domain+"/"+args.gotonode,e),goBackStack.push(1)}else if(null!=args.gotomesh){if(null==meshes["mesh/"+domain+"/"+args.gotomesh])return;gotoMesh("mesh/"+domain+"/"+args.gotomesh),go(e),goBackStack.push(2)}else if(null!=args.gotouser){var t=args.gotouser;if(args.gotouser.indexOf("/")<0&&(t="user/"+domain+"/"+args.gotouser),null==users||null==users[t])return;gotoUser(t),go(e),goBackStack.push(4)}else if(null!=args.gotougrp){var n=args.gotougrp;if(args.gotougrp.indexOf("/")<0&&(n="ugrp/"+domain+"/"+args.gotougrp),null==usergroups||null==usergroups[n])return;gotoUserGroup(n),go(e),goBackStack.push(50)}else isNaN(e)?(setDialogMode(0),go(1)):go(e);delete args.gotonode,delete args.gotomesh,delete args.gotouser,delete args.gotougrp}}function onRealNameCheckBox(){putstore("showRealNames",(showRealNames=Q("RealNameCheckBox").checked)?1:0),masterUpdate(6)}function onOnlineCheckBox(e){putstore("onlineOnly",Q("OnlineCheckBox").checked?1:0),onDeviceSearchChanged(e)}function onDeviceViewChange(e){null!=e&&(Q("viewselect").value=e);for(var t=1;t<5;t++)Q("devViewButton"+t).classList.remove("viewSelectorSel");Q("devViewButton"+Q("viewselect").value).classList.add("viewSelectorSel"),putstore("deviceView",Q("viewselect").value),putstore("viewsize",Q("sizeselect").value),masterUpdate(4),setTimeout(function(){masterUpdate(512)},200)}function ondockeypress(e){if(setSessionActivity(),!xxdialogMode&&11==xxcurrentView&&desktop&&Q("DeskControl").checked){if(null!=currentNode){var t=GetNodeRights(currentNode);if(0==(4294967295==t||0!=(8&t)&&0==(256&t)))return!1;if(1==(4294967295!=t&&0!=(8&t)&&0==(256&t)&&0!=(4096&t))&&(1==e.altKey||1==e.ctrlKey||e.keyCode<32&&8!=e.keyCode&&13!=e.keyCode||90<e.keyCode))return!1}return desktop.m.handleKeys(e)}if(!xxdialogMode&&12==xxcurrentView&&terminal&&3==terminal.State&&null==xterm)return terminal.m.TermHandleKeys(e);if(!xxdialogMode&&(15==xxcurrentView||115==xxcurrentView))return agentConsoleHandleKeys(e);if(!xxdialogMode&&4==xxcurrentView){if(1==e.ctrlKey||1==e.altKey||1==e.metaKey)return;var n=0;if(e.key){if(1===e.key.length&&0==userSearchFocus&&(Q("UserSearchInput").value=Q("UserSearchInput").value+e.key,n=1),8==e.keyCode&&0==userSearchFocus){var o=Q("UserSearchInput").value;Q("UserSearchInput").value=o.substring(0,o.length-1),n=1}27==e.keyCode&&(Q("UserSearchInput").value="",n=1)}else 0!=e.charCode&&0==userSearchFocus&&(Q("UserSearchInput").value=Q("UserSearchInput").value+String.fromCharCode(e.charCode),n=1);if(0<n)return 1==n&&onUserSearchInputChanged(),haltEvent(e)}if(!xxdialogMode&&1==xxcurrentView){if(1==e.ctrlKey&&96==e.charCode)return showRealNames=!showRealNames,putstore("showRealNames",(Q("RealNameCheckBox").value=showRealNames)?1:0),void masterUpdate(6);if(1!=e.ctrlKey&&1!=e.altKey&&1!=e.metaKey){if(Q("viewselect").value<4){n=0;if(e.key){if(1===e.key.length&&0==searchFocus&&(Q("KvmSearchInput").value=Q("SearchInput").value=Q("SearchInput").value+e.key,n=1),8==e.keyCode&&0==searchFocus){o=Q("SearchInput").value;Q("KvmSearchInput").value=Q("SearchInput").value=o.substring(0,o.length-1),n=1}27==e.keyCode&&(Q("KvmSearchInput").value=Q("SearchInput").value="",n=1)}else 0!=e.charCode&&0==searchFocus&&(Q("KvmSearchInput").value=Q("SearchInput").value=Q("SearchInput").value+String.fromCharCode(e.charCode),n=1);if(0<n)return 1==n&&masterUpdate(5),haltEvent(e)}4==Q("viewselect").value&&(e.key?(1===e.key.length&&0==mapSearchFocus&&(Q("mapSearchLocation").value=Q("mapSearchLocation").value+e.key,n=1),27==e.keyCode&&(Q("mapSearchLocation").value="",mapCloseSearchWindow(),n=1),13==e.keyCode&&getSearchLocation()):0!=e.charCode&&0==mapSearchFocus&&(Q("mapSearchLocation").value=Q("mapSearchLocation").value+String.fromCharCode(e.charCode),n=1))}}}function ondockeydown(e){if(setSessionActivity(),!xxdialogMode&&11==xxcurrentView&&desktop&&Q("DeskControl").checked){if(null!=currentNode){var t=GetNodeRights(currentNode);if(0==(4294967295==t||0!=(8&t)&&0==(256&t)))return!1;if(1==(4294967295!=t&&0!=(8&t)&&0==(256&t)&&0!=(4096&t))&&(1==e.altKey||1==e.ctrlKey||e.keyCode<32&&8!=e.keyCode&&13!=e.keyCode||90<e.keyCode))return!1}return desktop.m.handleKeyDown(e)}if(!xxdialogMode&&12==xxcurrentView&&terminal&&3==terminal.State&&null==xterm&&(terminal.m.TermHandleKeyDown(e),37<=e.keyCode&&e.keyCode<=40&&haltEvent(e)),!xxdialogMode&&13==xxcurrentView&&116==e.keyCode&&null!=p13filetree)return haltEvent(e),!1;if(!xxdialogMode&&(15==xxcurrentView||115==xxcurrentView))return agentConsoleHandleKeys(e);if(!xxdialogMode&&4==xxcurrentView){if(8===e.keyCode&&0==userSearchFocus){var n=Q("UserSearchInput").value;Q("UserSearchInput").value=n.substring(0,n.length-1),o=1}if(27===e.keyCode&&(Q("UserSearchInput").value="",o=1),0<o)return 1==o&&masterUpdate(5),haltEvent(e)}if(!xxdialogMode&&1==xxcurrentView&&1!=e.ctrlKey&&1!=e.altKey&&1!=e.metaKey){var o=0;if(Q("viewselect").value<4){if(8===e.keyCode&&0==searchFocus){n=Q("SearchInput").value;Q("KvmSearchInput").value=Q("SearchInput").value=n.substring(0,n.length-1),o=1}if(27===e.keyCode&&(Q("KvmSearchInput").value=Q("SearchInput").value="",o=1),0<o)return 1==o&&masterUpdate(5),haltEvent(e)}if(4==Q("viewselect").value){if(8===e.keyCode&&0==mapSearchFocus){n=Q("mapSearchLocation").value;Q("mapSearchLocation").value=n.substring(0,n.length-1),o=1}27===e.keyCode&&(Q("mapSearchLocation").value="",mapCloseSearchWindow(),o=1)}}}function ondockeyup(e){if(setSessionActivity(),!xxdialogMode&&11==xxcurrentView&&desktop&&Q("DeskControl").checked){if(null!=currentNode){var t=GetNodeRights(currentNode);if(0==(4294967295==t||0!=(8&t)&&0==(256&t)))return!1;if(1==(4294967295!=t&&0!=(8&t)&&0==(256&t)&&0!=(4096&t))&&(1==e.altKey||1==e.ctrlKey||e.keyCode<32&&8!=e.keyCode&&13!=e.keyCode||90<e.keyCode))return!1}return desktop.m.handleKeyUp(e)}return!xxdialogMode&&12==xxcurrentView&&terminal&&3==terminal.State&&null==xterm?terminal.m.TermHandleKeyUp(e):xxdialogMode||13!=xxcurrentView||116!=e.keyCode||null==p13filetree?xxdialogMode||4!=xxcurrentView||(8!==e.keyCode||0!=searchFocus)&&27!==e.keyCode?(xxdialogMode&&27==e.keyCode&&dialogclose(0),xxdialogMode||0!=xxcurrentView||1==e.ctrlKey||1==e.altKey||1==e.metaKey?void 0:Q("viewselect").value<4&&(8===e.keyCode&&0==searchFocus||27===e.keyCode)?haltEvent(e):4==Q("viewselect").value&&(8===e.keyCode&&0==mapSearchFocus||27===e.keyCode)?haltEvent(e):void 0):haltEvent(e):(p13folderup(9999),haltEvent(e),!1)}function ondocblur(){if(!xxdialogMode&&11==xxcurrentView&&desktop&&Q("DeskControl").checked&&desktop.m.handleReleaseKeys)return desktop.m.handleReleaseKeys()}function devMouseHover(e,t){setSessionActivity();var n=Q("viewselect").value;if(1==n)(o=e.children[1].children[1]).children[0].classList.remove("g1s"),o.children[1].classList.remove("e2s"),o.children[2].classList.remove("g2s"),1==t&&(o.children[0].classList.add("g1s"),o.children[1].classList.add("e2s"),o.children[2].classList.add("g2s"));else if(2==n){var o;(o=e).children[2].classList.remove("g1s"),o.children[4].classList.remove("e2s"),o.children[3].classList.remove("g2s"),1==t&&(o.children[2].classList.add("g1s"),o.children[4].classList.add("e2s"),o.children[3].classList.add("g2s"))}}var deviceHeaderCount,deviceHeaderId=0,deviceHeaderTotal=0,deviceHeadersTitles={},deviceHeaders={},oldviewmode=0;function updateDevices(){if(null!=nodes&&1==xxcurrentView){var e="",t=0,n=null,o={},i=Q("viewselect").value,a={},s={};if(QV("xdevices",i<4),QV("xdevicesmap",4==i),QV("devListToolbar",i<3),QV("kvmListToolbar",3==i),QV("devMapToolbar",4==i),QV("devListToolbarSize",3==i),QV("NoMeshesPanel",0==nodes.length&&0==meshcount),QV("devListToolbarViewIcons",0<nodes.length),QV("devListToolbarSort",0<nodes.length&&i<4),0==nodes.length&&(i=1,sort=0),4==i)setTimeout(function(){null!=xxmap.map&&xxmap.map.updateSize()},200);else{deviceHeaderCount={},deviceHeaders={},deviceHeadersTitles={};var r=[];(deviceHeaderTotal=deviceHeaderId=0)==sort?nodes.sort(meshSort):1==sort?nodes.sort(powerSort):2==sort&&(1==showRealNames?nodes.sort(deviceHostSort):nodes.sort(deviceSort));for(var l=[],d=document.getElementsByClassName("DeviceCheckbox"),c=0;c<d.length;c++)d[c].checked&&l.push(d[c].value);oldviewmode<3&&3==i?multiDesktopFilter=l:3==oldviewmode&&i<3&&(l=multiDesktopFilter);var u=Q("column_l").clientWidth-60,p=Math.floor(u/301);for(var c in p=301+Math.floor((u-301*p)/p),nodes){if(0!=(K=nodes[c]).v){var m=meshes[K.meshid],g=GetNodeRights(K);if(0==sort){if((meshes[K.meshid]?K.meshid:"*")!=n){1!=i&&3!=i||null==n||(e+="</div>"),deviceHeaderSet();var h="";if(2==i&&(e+="<tr><td colspan=5>"),meshes[K.meshid]&&1==meshes[K.meshid].mtype&&(h="<span class=devHeaderx>, Intel&reg; AMT only</span>"),1==i&&null!=n&&(2==t&&(e+="<td><div style=width:301px></div></td>"),""!=e&&(e+="</tr></table>")),2==i&&(e+="<div>"),e+="<div class=DevSt style=width:100%;padding-top:4px><span style=float:right>",e+="<span id=DevxHeader"+deviceHeaderId+" class=devHeaderx></span>"+h,e+="</span>",1==i||2==i||3==i){var v=CollapsedGroups[K.meshid];e+='<img class=collapseImage id="DevxColImg'+deviceHeaderId+'" src=images/c'+(!0===v?"1":"2")+'.png height=8 width=8 style=margin-left:2px;margin-right:2px;cursor:pointer onclick=toggleCollapseGroup("'+deviceHeaderId+'","'+K.meshid+'",'+i+")></img>"}n=meshes[K.meshid]?(e+='<span id=MxMESH cmenu=meshContextMenu tabindex=0 style=cursor:pointer onclick=gotoMesh("'+K.meshid+"\") onkeypress=\"if (event.key=='Enter') gotoMesh('"+K.meshid+"')\">"+EscapeHtml(meshes[K.meshid].name)+"</span>"+getMeshActions(m,g)+"</div>",K.meshid):(e+="<span id=MxMESH><i>Individual Devices</i></span></div>","*"),2==i&&(e+="</div>"),t=0,(o[n]=1)!=i&&3!=i||(e+="<div id=DevxCol"+deviceHeaderId+(!0===v?" style=display:none":"")+">")}}else if(1==sort){var f=K.pwr?K.pwr:0;if(f!==n){if(1!=i&&3!=i||null==n||(e+="</div>"),deviceHeaderSet(),1==i&&null!==n&&(2==t&&(e+="<td><div style=width:301px></div></td>"),""!=e&&(e+="</tr></table>")),2==i&&(e+="<tr><td>"),e+="<div class=DevSt style=width:100%;padding-top:4px><span id=DevxHeader"+deviceHeaderId+" class=devHeaderx style=float:right></span>",1==i||2==i||3==i){v=CollapsedGroups["pwr:"+f];e+='<img class=collapseImage id="DevxColImg'+deviceHeaderId+'" src=images/c'+(!0===v?"1":"2")+'.png height=8 width=8 style=margin-left:2px;margin-right:2px;cursor:pointer onclick=toggleCollapseGroup("'+deviceHeaderId+'","pwr:'+f+'",'+i+")></img>"}e+="<span>"+PowerStateStr2(K.pwr)+"</span></div>",n=f,t=0,1!=i&&3!=i||(e+="<div id=DevxCol"+deviceHeaderId+(!0===v?" style=display:none":"")+">")}}else 2==sort&&null==n&&(n="1");0;var k=EscapeHtml(K.name);0==k.length&&(k="<i>None</i>"),null!=K.rname&&0<K.rname.length&&(k+=" / "+EscapeHtml(K.rname));var x=EscapeHtml(K.name);1==showRealNames&&null!=K.rname&&(x=EscapeHtml(K.rname)),0==x.length&&(x="<i>None</i>");var y="";if(null!=K.sessions&&(null==K.sessions.kvm&&null==K.sessions.terminal&&null==K.sessions.files||(y=2==i?"<img onclick=showDeviceSessions('"+K._id+"',null,event) class=deviceNotifySmallDot src=images/icon-relay-notify10.png width=10 height=10>":"<img onclick=showDeviceSessions('"+K._id+"',null,event) class=deviceNotifyDot src=images/icon-relay-notify.png width=16 height=16>"),null!=K.sessions.battery&&1==i)){var b=K.sessions.battery,w="";"ac"==b.state&&(w="Device is plugged-in"),"dc"==b.state&&(w="Device is battery powered");var C="",D=-1;"number"==typeof b.level&&0<=b.level&&b.level<=100&&(C=b.level+"%",5<(D=Math.floor((b.level+10)/25)+1)&&(lvl=5),"ac"==b.state&&(100==b.level?D=11:D+=5)),0<D&&(y+='<div class="deviceBatterySmall deviceBatterySmall'+D+'" title="'+(null!=w?w+", "+C:C)+'"></div>')}var S=K.icon;if(K.conn&&0!=K.conn||(S+=" gray"),1==i)e+="<div id=devs cmenu=devsContentMenu onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=display:inline-block;position:relative;width:"+p+'px;height:50px;padding-top:1px;padding-bottom:1px><div style=width:22px;height:50%;float:left;padding-top:12px><input class="'+K.meshid+' DeviceCheckbox" onclick=p1updateInfo() value=devid_'+K._id+" type=checkbox></div><div style=height:100%;cursor:pointer tabindex=0 onclick=gotoDevice('"+K._id+"',null,null,event) onkeypress=\"if (event.key=='Enter') gotoDevice('"+K._id+'\',null,null,event)"><div class="i'+S+'" style=width:50px;float:left></div><div style=height:100%><div class=g1></div><div class=e2><div class=e1 style=width:'+(p-100)+'px title="'+k+'">'+x+"</div><div>"+NodeStateStr(K)+"</div></div><div class=g2></div></div></div>"+y+"</div>";else if(2==i){var M=[];K.conn&&(0!=(1&K.conn)&&M.push('<span title="Mesh agent is connected and ready for use.">Agent</span>'),0!=(2&K.conn)?M.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">CIRA</span>'):0!=(4&K.conn)&&M.push('<span title="Intel&reg; AMT is routable.">AMT</span>'),0!=(8&K.conn)&&M.push('<span title="Mesh agent is reachable using another agent as relay.">Relay</span>'),0!=(16&K.conn)&&M.push('<span title="MQTT connection to the device is active.">MQTT</span>'));var E=K.meshid;1==sort?E="pwr:"+(K.pwr?K.pwr:0):3==sort&&(E="tag:**xx**xx*TaG*xx**xx**"),e+="<tr name=DevxCol"+E+((v=3!=sort&CollapsedGroups[E])?" style=display:none":"")+"><td style=position:relative><div id=devs cmenu=devsContentMenu 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('"+K._id+"',null,null,event)\">",e+='<div class=deviceBarCheckbox><input class="'+K.meshid+' DeviceCheckbox" onclick=p1updateInfo() value=devid_'+K._id+" type=checkbox></div>",e+="<div class=deviceBarIcon onclick=gotoDevice('"+K._id+"',null,null,event)><div class=\"j"+S+'" style=width:16px;margin-top:1px;margin-left:2px;height:16px></div></div>',e+="<div class=g1 style=height:18px;float:left></div><div class=g2 style=height:18px;float:right></div>",e+='<div class=style10 style=cursor:pointer;font-size:14px title="'+k+"\" onclick=gotoDevice('"+K._id+"',null,null,event)><span style=width:300px>"+x+"</span></div></div>"+y+"</td>",e+="<td style=text-align:center>"+getUserShortStr(K),e+="<td style=text-align:center>"+(null!=K.ip?K.ip:""),e+="<td style=text-align:center>"+M.join("&nbsp;+&nbsp;"),e+="</tr>"}else 3==i&&1&K.conn&&0!=(8&g||256&g)&&0!=(1&K.agent.caps)&&multiDesktopFilter&&(0==multiDesktopFilter.length||0<=multiDesktopFilter.indexOf("devid_"+K._id))&&(e+="<div id=devs cmenu=devsContentMenu style=display:inline-block;position:relative;margin:1px;background-color:lightgray;border-radius:5px;position:relative><div tabindex=0 style=padding:3px;cursor:pointer onclick=gotoDevice('"+K._id+"',11,null,event) onkeypress=\"if (event.key=='Enter') gotoDevice('"+K._id+"',11,null,event)\">"+y,e+='<div class="j'+S+'" style=width:16px;float:left></div>&nbsp;'+x+"</div>",e+="<span onclick=gotoDevice('"+K._id+"',null,null,event)></span><div id=xkvmid_"+K._id.split("/")[2]+"><div id=skvmid_"+K._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(\''+K._id+"') onkeypress=\"if (event.key=='Enter') toggleKvmDevice('"+K._id+"')\">Disconnected</div></div>",e+="</div>",r.push(K._id));if(3==sort&&""!=e){if(K.tags)for(var A in K.tags){var T=K.tags[A],N=(v=CollapsedGroups["tag:"+T],e.replace("**xx**xx*TaG*xx**xx**",encodeURIComponentEx(T)+(v?" style=display:none":"")));if(null==a[T]?(a[T]=N,s[T]=1):(a[T]+=N,s[T]+=1),3==i)break}e=""}deviceHeaderTotal++,void 0===deviceHeaderCount[K.state]?deviceHeaderCount[K.state]=1:deviceHeaderCount[K.state]++}}if(1==i&&null!=n&&(e+="</div>"),32<=r.length&&(Q("autoConnectDesktopCheckbox").checked=!1),QE("autoConnectDesktopCheckbox",r.length<32),3==sort){var U=[],I=0;for(var c in a)U.push(c);for(var A in U.sort(function(e,t){return e.toLowerCase().localeCompare(t.toLowerCase())}),U){c=U[A];if(2==i)e+="<tr><td colspan=4><div class=DevSt style=width:100%;padding-top:4px>",e+='<img class=collapseImage id="DevxColImg'+I+'" src=images/c'+(!0===(v=CollapsedGroups["tag:"+encodeURIComponentEx(c)])?"1":"2")+'.png height=8 width=8 style=margin-left:2px;margin-right:2px;cursor:pointer onclick=toggleCollapseGroup("'+I+'","tag:'+encodeURIComponentEx(c)+'",2)></img>',e+="<span class=devHeaderx style=float:right>"+s[c]+" node"+(1<s[c]?"s":"")+"</span><span>"+c+"</span></div>"+a[c];else e+="<div class=DevSt style=width:100%;padding-top:4px><span class=devHeaderx style=float:right>"+s[c]+" node"+(1<s[c]?"s":"")+"</span>",e+='<img class=collapseImage id="DevxColImg'+I+'" src=images/c'+(!0===(v=CollapsedGroups["tag:"+encodeURIComponentEx(c)])?"1":"2")+'.png height=8 width=8 style=margin-left:2px;margin-right:2px;cursor:pointer onclick=toggleCollapseGroup("'+I+'","tag:'+encodeURIComponentEx(c)+'")></img>',e+="<span>"+c+"</span></div>",e+="<div id=DevxCol"+I+(!0===v?" style=display:none":"")+">",e+=a[c],e+="</div>";I++}}var _=!1;if(""==e&&0<nodes.length&&""!=Q("SearchInput").value&&(_=!0,e=3==sort?'<div style="margin:30px">No devices are included in any groups, click on a device\'s "Groups" to add to a group.</div>':'<div style="margin:30px">No devices matching this search.</div>'),1==i&&2==t&&(e+="<td><div style=width:301px></div></td>"),0==sort&&""==Q("SearchInput").value&&i<3){var V=deviceHeaderId,R=[];for(var c in meshes)R.push(meshes[c]);for(var c in R.sort(nameSort),R){var H=R[c];g=GetMeshRights(H);if(null==o[H._id])""!=n&&""!=e&&(e+="</tr></table>"),e+="<table style=width:100%;padding-top:4px cellpadding=0 cellspacing=0><tr><td colspan=3 class=DevSt>",e+='<img class=collapseImage id="DevxColImg'+ ++V+'" src=images/c'+(!0===(v=CollapsedGroups[H._id])?"1":"2")+'.png height=8 width=8 style=margin-left:2px;margin-right:2px;cursor:pointer onclick=toggleCollapseGroup("'+V+'","'+H._id+'")></img>',e+='<span id=MxMESH style=cursor:pointer onclick=gotoMesh("'+H._id+'")>'+EscapeHtml(H.name)+"</span><span>",e+=getMeshActions(H,g),e+="</span></td></tr><tr>",1==H.mtype?(e+="<td><div style=padding:10px><i>No Intel&reg; AMT devices in this mesh",0!=(4&g)&&(e+=", <a href=# style=cursor:pointer onclick='return addDeviceToMesh(\""+H._id+"\")'>add one</a>")):2==H.mtype&&(e+="<td>",e+="<div id=DevxCol"+V+(!0===v?" style=display:none":"")+">",e+="<div style=padding:10px><i>No devices in this group",0!=(4&g)&&(e+=", <a href=# style=cursor:pointer onclick='return addAgentToMesh(\""+H._id+"\")'>add one</a>")),e+=".</i></div></td>",e+="</div>",n=H._id,0}}""!=e&&0==_?(e+="</table>",2==i&&(e="<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"+e+"</tr></table><div style=height:1px></div>")):(e+="</table>",3==sort&&(e='<div style="margin:10px"><i>No devices with tags found.</i></div>')),e+="<div style=border-top-style:solid;border-top-width:1px;border-top-color:#DDDDDD;cursor:pointer;font-size:10px>",i<3&&0==sort&&0<nodes.length&&(4294967295==userinfo.siteadmin||0==(64&userinfo.siteadmin))&&(e+='<a href=# onclick="return account_createMesh()" title="Create a new group of devices." style=cursor:pointer>Add Device Group</a>&nbsp'),4294967295!=userinfo.siteadmin&&0!=(128&userinfo.siteadmin)||(e+="<a href=# onclick='return p10showMeshCmdDialog(0)' style=cursor:pointer title=\"Download MeshCmd, a command line tool that performs many functions.\">MeshCmd</a>&nbsp","win32"==navigator.platform.toLowerCase()&&(e+="<a href=# onclick='return p10showMeshRouterDialog()' style=cursor:pointer title=\"Download MeshCentral Router, a TCP port mapping tool.\">Router</a>&nbsp")),e+="</div><br/>",QH("xdevices",e),deviceHeaderSet();d=document.getElementsByClassName("DeviceCheckbox");if(l)for(c=0;c<d.length;c++)d[c].checked=0<=l.indexOf(d[c].value);for(var c in deviceHeaders)QH(c,deviceHeaders[c]);for(var c in deviceHeadersTitles)Q(c).title=deviceHeadersTitles[c];if(p1updateInfo(),3==i&&1==xxcurrentView){var F=[{x:180,y:101},{x:302,y:169},{x:454,y:255}][Q("sizeselect").selectedIndex],P=F.x+2,L=u-5,B=Math.floor(L/P);for(var c in B=P+Math.floor((L-B*P)/B),F.y=F.y*(B/F.x),F.x=B,multiDesktop)multiDesktop[c].xxdelete=!0;for(var c in r){var O=r[c],G=O.split("/")[2],z=multiDesktop[O];if(null!=z)z.m.CanvasId.setAttribute("style","background-color:black;width:"+F.x+"px;height:"+F.y+"px"),Q("xkvmid_"+G).appendChild(z.m.CanvasId),delete z.xxdelete,QH("skvmid_"+G,["Disconnected","Connecting...","Setup...","",""][null==z.m.State?z.m.state:z.m.State]);else{var K=getNodeFromId(O);if(desktopNode==K&&null!=desktop){(t=desktop.m.CanvasId).setAttribute("id","kvmid_"+G),t.setAttribute("style","background-color:black;width:"+F.x+"px;height:"+F.y+"px"),t.setAttribute("onclick","toggleKvmDevice('"+O+"')"),t.removeAttribute("onmousedown"),t.removeAttribute("onmouseup"),t.removeAttribute("onmousemove"),Q("xkvmid_"+G).appendChild(t),QH("skvmid_"+G,["Disconnected","Connecting...","Setup...","",""][null==desktop.m.State?desktop.m.state:desktop.m.State]),desktop.m.SendCompressionLevel&&desktop.m.SendCompressionLevel(1,multidesktopsettings.quality,multidesktopsettings.scaling,multidesktopsettings.framerate),desktop.shortid=G,desktop.onStateChanged=onMultiDesktopStateChange,multiDesktop[O]=desktop,desktop=desktopNode=currentNode=null,QH("DeskParent",'<canvas id="Desk" oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>')}else{(t=document.createElement("canvas")).setAttribute("id","kvmid_"+G),t.setAttribute("width",640),t.setAttribute("height",480),t.setAttribute("oncontextmenu","return false"),t.setAttribute("style","background-color:black;width:"+F.x+"px;height:"+F.y+"px"),t.setAttribute("onclick","toggleKvmDevice('"+O+"')");try{Q("xkvmid_"+G).appendChild(t)}catch(e){}1==Q("autoConnectDesktopCheckbox").checked&&setTimeout(function(){connectMultiDesktop(K,1)},100)}}}for(var c in multiDesktop)1==multiDesktop[c].xxdelete?(multiDesktop[c].Stop(),delete multiDesktop[c]):debugmode&&multiDesktop[c].m&&multiDesktop[c].m.onScreenSizeChange&&mdeskAdjust(multiDesktop[c].m,multiDesktop[c].m.ScreenWidth,multiDesktop[c].m.ScreenHeight,multiDesktop[c].m.CanvasId);deskAdjust()}else disconnectAllKvmFunction(),Q("autoConnectDesktopCheckbox").checked=!1}oldviewmode=i}}function showDeviceSessions(e,t,n){if(n&&haltEvent(n),xxdialogMode&&!t)return!1;var o=null,i="";if(null==(o=null==e?currentNode:getNodeFromId(e))||null==o.sessions)return setDialogMode(0),!1;for(var a in o.sessions)if("kvm"==a&&null==o.sessions.multidesk)for(var s in i+="<u>Remote Desktop</u>",o.sessions.kvm)i+=addHtmlValue4(getUserName(s),1==o.sessions.kvm[s]?"1 session":nobreak(format("{0} sessions",o.sessions.kvm[s])));else if("multidesk"==a)for(var s in i+="<u>Remote Desktop</u>",o.sessions.multidesk)i+=addHtmlValue4(getUserName(s),1==o.sessions.multidesk[s]?"1 session":nobreak(format("{0} sessions",o.sessions.multidesk[s])));else if("terminal"==a)for(var s in i+="<u>Terminal</u>",o.sessions.terminal)i+=addHtmlValue4(getUserName(s),1==o.sessions.terminal[s]?"1 session":nobreak(format("{0} sessions",o.sessions.terminal[s])));else if("files"==a)for(var s in i+="<u>Files</u>",o.sessions.files)i+=addHtmlValue4(getUserName(s),1==o.sessions.files[s]?"1 session":nobreak(format("{0} sessions",o.sessions.files[s])));return""!=i&&setDialogMode(2,"Sessions - "+EscapeHtml(o.name),1,null,i,"SESSIONS-"+o._id),!1}function toggleCollapseGroup(e,t,n){var o;if(2==n){var i=document.getElementsByName("DevxCol"+t);if(0==i.length)return;(o="none"==i[0].style.display)?delete CollapsedGroups[t]:CollapsedGroups[t]=!0;for(var a=0;a<i.length;a++)i[a].style.display=o?"":"none"}else(o="none"==QS("DevxCol"+e).display)?delete CollapsedGroups[t]:CollapsedGroups[t]=!0,QV("DevxCol"+e,o);Q("DevxColImg"+e).src=o?"images/c2.png":"images/c1.png",putstore("_collapse",JSON.stringify(CollapsedGroups))}function toggleKvmDevice(e){"string"==typeof e&&(e=getNodeFromId(e));var t=GetNodeRights(e);(8&t||256&t)&&1&e.conn&&connectMultiDesktop(e,1)}function getUserShortStr(e){if(null==e||null==e.users||0==e.users.length)return"";if(1<e.users.length)return'<span title="'+EscapeHtml(e.users.join(", "))+'">'+nobreak(format("{0} users",e.users.length))+"</span>";var t=e.users[0],n=t,o=t.indexOf("\\");return 0<o&&(n=t.substring(o+1)),15<(n=EscapeHtml(n)).length&&(n=n.substring(0,14)+"&#8230;"),'<span title="'+EscapeHtml(t)+'">'+n+"</span>"}function autoConnectDesktops(){1==Q("autoConnectDesktopCheckbox").checked&&connectAllKvmFunction()}function connectAllKvmFunction(e){if(xxdialogMode)return!1;if(!0!==e){var t=0;for(var n in nodes){var o=nodes[n],i=nodes[n]._id;if(null==multiDesktop[i]&&(0==multiDesktopFilter.length||0<=multiDesktopFilter.indexOf("devid_"+i))){var a=GetNodeRights(o);(8&a||256&a)&&1&o.conn&&1==o.v&&t++}}if(8<t)return void setDialogMode(2,"Connect All",3,function(){connectAllKvmFunction(!0)},format("Are you sure you want to connect to {0} devices?",t))}for(var n in nodes)1==nodes[n].v&&null==multiDesktop[nodes[n]._id]&&(0==multiDesktopFilter.length||0<=multiDesktopFilter.indexOf("devid_"+nodes[n]._id))&&toggleKvmDevice(nodes[n]._id)}function disconnectAllKvmFunction(){if(xxdialogMode)return!1;for(var e in multiDesktop)multiDesktop[e].Stop();multiDesktop={}}function onMultiDesktopStateChange(e,t){try{QH("skvmid_"+e.shortid,["Disconnected","Connecting...","Setup...","",""][t])}catch(e){}}function onDeviceSearchChanged(e){"SearchInput"==e.target.id?Q("KvmSearchInput").value=Q("SearchInput").value:Q("SearchInput").value=Q("KvmSearchInput").value,masterUpdate(5)}function showMultiDesktopSettings(){QV("d7amtkvm",!1),QV("d7meshkvm",!0),d7bitmapquality.value=multidesktopsettings.quality,d7bitmapscaling.value=multidesktopsettings.scaling,multidesktopsettings.framerate?d7framelimiter.value=multidesktopsettings.framerate:d7framelimiter.value=100,setDialogMode(7,"Remote Desktop Settings",3,showMultiDesktopSettingsChanged)}function showMultiDesktopSettingsChanged(){for(var e in multidesktopsettings.quality=d7bitmapquality.value,multidesktopsettings.scaling=d7bitmapscaling.value,multidesktopsettings.framerate=d7framelimiter.value,localStorage.setItem("multidesktopsettings",JSON.stringify(multidesktopsettings)),multiDesktop)multiDesktop[e].m.SendCompressionLevel(1,multidesktopsettings.quality,multidesktopsettings.scaling,multidesktopsettings.framerate)}function connectMultiDesktop(e,t){var n=e._id,o=n.split("/")[2],i=multiDesktop[n];if(null==i){if(null==Q("kvmid_"+o))return;if(2==t){if(null==e.intelamt.user||""==e.intelamt.user)return;(i=CreateAmtRedirect(CreateAmtRemoteDesktop("kvmid_"+o),authCookie)).shortid=o,i.onStateChanged=onMultiDesktopStateChange,i.m.bpp=1,i.m.useZRLE=!0,i.m.showmouse=!0,i.m.onKvmData=function(e){console.log("KVM Data received in multi-desktop mode, this is not supported.")},0<debugmode&&(i.m.onScreenSizeChange=mdeskAdjust),i.Start(n,16994,"*","*",0),i.contype=2,multiDesktop[n]=i}else 1==t&&((i=CreateAgentRedirect(meshserver,CreateAgentRemoteDesktop("kvmid_"+o),serverPublicNamePort,authCookie,authRelayCookie,domainUrl)).m.mouseCursorActive(11==xxcurrentView),i.shortid=o,i.attemptWebRTC=attemptWebRTC,i.onStateChanged=onMultiDesktopStateChange,i.m.CompressionLevel=multidesktopsettings.quality,i.m.ScalingLevel=multidesktopsettings.scaling,multidesktopsettings.framerate&&(i.m.FrameRateTimer=multidesktopsettings.framerate),0<debugmode&&(i.m.onScreenSizeChange=mdeskAdjust),i.Start(n),i.contype=1,multiDesktop[n]=i)}else i.Stop(),delete multiDesktop[n]}function getMeshActions(e,t){if(0==(4&t))return"";var n="";return 0==(1024&features)&&(n+=' <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("'+e._id+"\")'>Add CIRA</a>"),1==e.mtype&&(0==(1&features)&&(n+=' <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("'+e._id+"\")'>Add Local</a>",n+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new Intel&reg; AMT computer by scanning the local network." onclick=\'return addAmtScanToMesh("'+e._id+"\")'>Scan Network</a>"),e.amt&&2==e.amt.type?n+=' <a href=# style=cursor:pointer;font-size:10px title="Perform Intel AMT client control mode (CCM) activation." onclick=\'return showCcmActivation("'+e._id+"\")'>Activation</a>":e.amt&&3==e.amt.type&&0!=(1048576&features)&&(n+=' <a href=# style=cursor:pointer;font-size:10px title="Perform Intel AMT admin control mode (ACM) activation." onclick=\'return showAcmActivation("'+e._id+"\")'>Activation</a>")),2==e.mtype&&(n+=' <a href=# style=cursor:pointer;font-size:10px title="Add a new computer to this device group by installing the mesh agent." onclick=\'return addAgentToMesh("'+e._id+"\")'>Add Agent</a>",0==(2&features)&&(n+=' <a href=# style=cursor:pointer;font-size:10px title="Invite someone to install the mesh agent on this device group." onclick=\'return inviteAgentToMesh("'+e._id+"\")'>Invite</a>")),n}function addDeviceToMesh(e){if(xxdialogMode)return!1;var t=meshes[e],n=format('Add a new Intel&reg; AMT device to device group "{0}".',EscapeHtml(t.name))+"<br /><br />";return n+=addHtmlValue("Device Name","<input id=dp1devicename style=width:230px maxlength=32 autocomplete=off onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />"),n+=addHtmlValue("Hostname",'<input id=dp1hostname style=width:230px maxlength=32 autocomplete=off placeholder="Same as device name" onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />'),n+=addHtmlValue("Username",'<input id=dp1username style=width:230px maxlength=32 autocomplete=off placeholder="admin" onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />'),n+=addHtmlValue("Password","<input id=dp1password type=password style=width:230px autocomplete=off maxlength=32 onchange=validateDeviceToMesh() onkeyup=validateDeviceToMesh() />"),setDialogMode(2,"Add Intel&reg; AMT device",3,addDeviceToMeshEx,n+=addHtmlValue("Security","<select id=dp1tls style=width:236px><option value=0>No TLS security</option><option value=1>TLS security required</option></select>"),e),validateDeviceToMesh(),Q("dp1devicename").focus(),!1}function showCcmActivation(e){if(xxdialogMode)return!1;var t=serverinfo.name,n=meshes[e];-1!=t.indexOf(".")&&0==(2&features)||(t=window.location.hostname);var o;domainUrl.substring(0,domainUrl.length-1);1==serverinfo.https?o="wss://"+t+(443==serverinfo.port?"":":"+serverinfo.port)+domainUrl:o="ws://"+t+(80==serverinfo.port?"":":"+serverinfo.port)+domainUrl;var i=format('Perform Intel AMT client control mode (CCM) activation to group "{0}" by downloading the MeshCMD tool and running it like this:',EscapeHtml(n.name))+"<br /><br />";return setDialogMode(2,"Intel&reg; AMT activation",9,null,i+="<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtccm --url "+o+"amtactivate?id="+e.split("/")[2]+" --serverhttpshash "+serverinfo.tlshash+"</textarea>"),Q("idx_dlgOkButton").focus(),!1}function showAcmActivation(e){if(xxdialogMode)return!1;var t=serverinfo.name,n=meshes[e];-1!=t.indexOf(".")&&0==(2&features)||(t=window.location.hostname);var o;domainUrl.substring(0,domainUrl.length-1);1==serverinfo.https?o="wss://"+t+(443==serverinfo.port?"":":"+serverinfo.port)+domainUrl:o="ws://"+t+(80==serverinfo.port?"":":"+serverinfo.port)+domainUrl;var i=format('Perform Intel AMT admin control mode (ACM) activation to group "{0}" by downloading the MeshCMD tool and running it like this:',EscapeHtml(n.name))+"<br /><br />";return i+="<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtacm --url "+o+"amtactivate?id="+e.split("/")[2]+" --serverhttpshash "+serverinfo.tlshash+"</textarea>",null!=serverinfo.amtAcmFqdn&&(i+="<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,i),Q("idx_dlgOkButton").focus(),!1}function addAmtScanToMesh(e){if(xxdialogMode)return!1;var t="Enter a range of IP addresses to scan for Intel AMT devices.<br /><br />";return t+=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>'),setDialogMode(2,"Scan for Intel&reg; AMT devices",3,addAmtScanToMeshEx,t+='<div id=dp1results style="width:100%;height:200px;background-color:white;border:1px gray solid;overflow-y:scroll"></div>',e),QE("idx_dlgOkButton",!1),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"),!1}function addAmtScanToMeshKeyUp(e){13==e.keyCode&&(haltEvent(e),addAmtScanToMeshButton())}function addAmtScanToMeshEx(e,t){for(var n=document.getElementsByClassName("DevScanCheckbox"),o=0;o<n.length;o++)if(n[o].checked){var i=n[o].getAttribute("tag"),a=amtScanResults[i],s=a.hostname;"host"==a.hosttype&&(s=capitalizeFirstLetter(s.split(".")[0])),meshserver.send({action:"addamtdevice",meshid:t,devicename:s,hostname:a.hostname,amtusername:"",amtpassword:"",amttls:a.tls})}}function addAmtScanToMeshButton(){QE("dp1range",!1),QE("dp1rangebutton",!1),QH("dp1results","<div style=width:100%;text-align:center;margin-top:12px>Scanning...</div>"),meshserver.send({action:"scanamtdevice",range:Q("dp1range").value})}function addAmtScanToMeshCheckbox(){for(var e=document.getElementsByClassName("DevScanCheckbox"),t=0,n=0;n<e.length;n++)e[n].checked&&t++;QE("idx_dlgOkButton",0<t)}function addCiraDeviceToMesh(e){if(xxdialogMode)return!1;var t=meshes[e],n=e.split("/")[2].replace(/\@/g,"X").replace(/\$/g,"X"),o="<select id=dlgAddCiraSel onclick=dlgAddCiraSelClick() style=width:230px><option value=0>MeshCommander Script</option><option value=1>Manual Username/Password</option>";0==(16&features)&&(o+="<option value=2>Manual Certificate</option></select>");var i="";return i+=addHtmlValue("Setup Method",o),i+="<hr>",i+="<div id=dlgAddCira0>"+format("To add a new Intel&reg; AMT device to device group \"{0}\" 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.",EscapeHtml(t.name))+"<br /><br />",i+=addHtmlValue("Setup CIRA",'<a href="mescript.ashx?type=1'+(urlargs.key?"&key="+urlargs.key:"")+"&meshid="+e+'" download>cira_setup.mescript</a>'),i+=addHtmlValue("Cleanup CIRA",'<a href="mescript.ashx?type=2'+(urlargs.key?"&key="+urlargs.key:"")+'" download>cira_clean.mescript</a>'),i+="</div>",i+="<div id=dlgAddCira1 style=display:none>"+format('To add a new Intel&reg; AMT device to device group "{0}" with CIRA, load the following certificate as trusted root within Intel AMT',EscapeHtml(t.name)),serverinfo.mpspass?i+=" and authenticate to the server using this username and password.<br /><br />":i+=" and authenticate to the server using this username and any password.<br /><br />",i+=addHtmlValue("Root Certificate",'<a href="MeshServerRootCert.cer'+(urlargs.key?"?key="+urlargs.key:"")+'" download>Root Certificate File</a>'),i+=addHtmlValue("Username",'<input style=width:230px readonly value="'+n.substring(0,16)+'" />'),serverinfo.mpspass&&(i+=addHtmlValue("Password",'<input style=width:230px readonly value="'+EscapeHtml(serverinfo.mpspass)+'" />')),null!=serverinfo&&(i+=addHtmlValue("MPS Server",'<input style=width:230px readonly value="'+EscapeHtml(serverinfo.mpsname)+":"+serverinfo.mpsport+'" />')),i+="</div>",0==(16&features)&&(i+="<div id=dlgAddCira2 style=display:none>"+format('To add a new Intel&reg; AMT device to device group "{0}" 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.',EscapeHtml(t.name))+"<br /><br />",i+=addHtmlValue("Root Certificate",'<a href="MeshServerRootCert.cer'+(urlargs.key?"?key="+urlargs.key:"")+'" download>Root Certificate File</a>'),i+=addHtmlValue("Organization",'<input style=width:230px readonly value="'+n+'" />'),null!=serverinfo&&(i+=addHtmlValue("MPS Server",'<input style=width:230px readonly value="'+EscapeHtml(serverinfo.mpsname)+":"+serverinfo.mpsport+'" />')),i+="</div>"),setDialogMode(2,"Add Intel&reg; AMT CIRA device",2,null,i,"fileDownload"),Q("dlgAddCiraSel").focus(),!1}function dlgAddCiraSelClick(){var e=Q("dlgAddCiraSel").value;QV("dlgAddCira0",0==e),QV("dlgAddCira1",1==e),QV("dlgAddCira2",2==e)}function checkEmail(e){var t=e.split("@"),n=2==t.length&&0<t[0].length&&1<t[1].split(".").length&&2<t[1].length;if(1==n){var o=t[1].split(".");for(var i in o)0==o[i].length&&(n=!1)}return n}function inviteAgentToMesh(e){if(xxdialogMode)return!1;var t="",n=meshes[e];return 64&features&&(t+=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 />",t+="<div id=emailInviteDiv style=display:none>"+format('Invite someone to install the mesh agent. An email with be sent with the link to the mesh agent installation for the "{0}" device group.',EscapeHtml(n.name))+"<br /><br />",t+=addHtmlValue("Name (optional)",'<input id=agentInviteName value="" style=width:230px maxlength=64 />'),t+=addHtmlValue("Email",'<input id=agentInviteEmail style=width:230px placeholder="example@email.com" onkeyup=validateAgentInvite()></input>'),t+=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>"),t+="<div id=d2agentexpirediv>",t+=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>"),t+="</div>",t+=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>"),t+=addHtmlValue("Message<br />(optional)",'<textarea id=agentInviteMessage value="" style=width:230px;height:100px;resize:none maxlength=1024 /></textarea>'),t+="</div>"),t+="<div id=urlInviteDiv>"+format('Invite someone to install the mesh agent by sharing an invitation link. This link points the user to installation instructions for the "{0}" device group. The link is public and no account for this server is needed.',EscapeHtml(n.name))+"<br /><br />",t+=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>"),setDialogMode(2,"Invite",3,performAgentInvite,t+='<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>',e),64&features?(Q("d2InviteType").focus(),d2ChangedInviteType()):(Q("d2inviteExpire").focus(),validateAgentInvite()),d2RequestInvitationLink(),!1}function d2RequestInvitationLink(){meshserver.send({action:"createInviteLink",meshid:xxdialogTag,expire:parseInt(Q("d2inviteExpire").value),flags:0})}function d2ChangedInviteType(){QV("urlInviteDiv",0==Q("d2InviteType").value),QV("d2agentexpirediv",4==Q("agentInviteNameOs").value),QV("emailInviteDiv",1==Q("d2InviteType").value),validateAgentInvite()}function d2CopyInviteToClip(){copyTextToClip(Q("agentInvitationLink").href)}function validateAgentInvite(){64&features&&1==Q("d2InviteType").value?(QE("idx_dlgOkButton",checkEmail(Q("agentInviteEmail").value)),QV("idx_dlgCancelButton",!0)):(QE("idx_dlgOkButton",!0),QV("idx_dlgCancelButton",!1))}function performAgentInvite(e,t){64&features&&1==Q("d2InviteType").value&&meshserver.send({action:"inviteAgent",meshid:t,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!1;var t=meshes[e],n="";n+=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>"),n+="<div id=aginsTypeDiv>",n+=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>"),n+="</div><hr>";var o=t.name;o=o.split("\\").join("").split("/").join("").split(":").join("").split("*").join("").split("?").join("").split('"').join("").split("<").join("").split(">").join("").split("|").join("").split(" ").join("").split("'").join(""),n+="<div id=agins_windows>"+format('To add a new computer to device group "{0}", download the mesh agent and install it the computer to manage. This agent has server and device group information embedded within it.',EscapeHtml(t.name))+"<br /><br />",n+=addHtmlValue("Mesh Agent",'<a id=aginsw32lnk href="meshagents?id=3&meshid='+e.split("/")[2]+"&installflags=0"+(urlargs.key?"&key="+urlargs.key:"")+'" 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)>'),n+=addHtmlValue("Mesh Agent",'<a id=aginsw64lnk href="meshagents?id=4&meshid='+e.split("/")[2]+"&installflags=0"+(urlargs.key?"&key="+urlargs.key:"")+'" 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)>'),0<debugmode&&(n+=addHtmlValue("Settings File",'<a id=aginswmshlnk href="meshsettings?id='+e.split("/")[2]+"&installflags=0"+(urlargs.key?"&key="+urlargs.key:"")+'" download rel="noreferrer noopener" target="_blank">'+format("{0} settings (.msh)",EscapeHtml(t.name))+"</a>")),n+="</div>",n+="<div id=agins_linux style=display:none>"+format("To add a computer to {0} run the following command. Root credentials will be needed.",EscapeHtml(t.name))+"<br />",n+="<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>",n+="<div style='font-size:x-small'>* For BSD, run \"pkg install wget sudo bash\" first.</div></div>",n+="<div id=agins_osx style=display:none>"+format('To add a new computer to device group "{0}", download the mesh agent and install it the computer to manage. This agent installer has server and device group information embedded within it.',EscapeHtml(t.name))+"<br /><br />",n+=addHtmlValue("Mesh Agent",'<a href="meshosxagent?id=16&meshid='+e.split("/")[2]+(urlargs.key?"&key="+urlargs.key:"")+'" download 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)>'),n+="</div>",n+='<div id=agins_windows_un style=display:none>To remove a mesh agent, download the file below, run it and click "uninstall".<br /><br />',n+=addHtmlValue("Mesh Agent",'<a href="meshagents?id=3'+(urlargs.key?"&key="+urlargs.key:"")+'" download onclick="setDialogMode(0)" title="32bit version of the MeshAgent">Windows (.exe)</a>'),n+=addHtmlValue("Mesh Agent",'<a href="meshagents?id=4'+(urlargs.key?"&key="+urlargs.key:"")+'" download onclick="setDialogMode(0)" title="64bit version of the MeshAgent">Windows x64 (.exe)</a>'),n+="</div>",n+="<div id=agins_linux_un style=display:none>To remove a mesh agent, run the following command. Root credentials will be needed.<br />",n+="<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>",setDialogMode(2,"Add Mesh Agent",2,null,n+="</div>","fileDownload");var i=serverinfo.name;-1!=i.indexOf(".")&&0==(2&features)||(i=window.location.hostname);var a=domainUrl.substring(0,domainUrl.length-1);if(1==serverinfo.https){var s=443==serverinfo.port?"":":"+serverinfo.port;0==(8192&features)?(Q("agins_linux_area").value='(wget "https://'+i+s+domainUrl+"meshagents?script=1"+(urlargs.key?"&key="+urlargs.key:"")+'" --no-check-certificate -O ./meshinstall.sh || wget "https://'+i+s+domainUrl+'meshagents?script=1" --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo -E ./meshinstall.sh https://'+i+s+a+" '"+e.split("/")[2]+"' || ./meshinstall.sh https://"+i+s+a+" '"+e.split("/")[2]+"'\r\n",Q("agins_linux_area_un").value='(wget "https://'+i+s+domainUrl+"meshagents?script=1"+(urlargs.key?"&key="+urlargs.key:"")+'" --no-check-certificate -O ./meshinstall.sh || wget "https://'+i+s+domainUrl+'meshagents?script=1" --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n'):(Q("agins_linux_area").value='wget "https://'+i+s+domainUrl+"meshagents?script=1"+(urlargs.key?"&key="+urlargs.key:"")+'" --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://'+i+s+a+" '"+e.split("/")[2]+"' || ./meshinstall.sh https://"+i+s+a+" '"+e.split("/")[2]+"'\r\n",Q("agins_linux_area_un").value='wget "https://'+i+s+domainUrl+"meshagents?script=1"+(urlargs.key?"&key="+urlargs.key:"")+'" --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n')}else{s=80==serverinfo.port?"":":"+serverinfo.port;0==(8192&features)?(Q("agins_linux_area").value='(wget "http://'+i+s+domainUrl+"meshagents?script=1"+(urlargs.key?"&key="+urlargs.key:"")+'" -O ./meshinstall.sh || wget "http://'+i+s+domainUrl+'meshagents?script=1" --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo -E ./meshinstall.sh http://'+i+s+a+" '"+e.split("/")[2]+"'\r\n",Q("agins_linux_area_un").value='(wget "http://'+i+s+domainUrl+"meshagents?script=1"+(urlargs.key?"&key="+urlargs.key:"")+'" -O ./meshinstall.sh || wget "http://'+i+s+domainUrl+'meshagents?script=1" --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n'):(Q("agins_linux_area").value='wget "http://'+i+s+domainUrl+"meshagents?script=1"+(urlargs.key?"&key="+urlargs.key:"")+'" --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://'+i+s+a+" '"+e.split("/")[2]+"'\r\n",Q("agins_linux_area_un").value='wget "http://'+i+s+domainUrl+"meshagents?script=1"+(urlargs.key?"&key="+urlargs.key:"")+'" --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n')}return Q("aginsSelect").focus(),addAgentToMeshClick(),!1}function copyAgentUrl(e,t){var n=serverinfo.name;-1!=n.indexOf(".")&&0==(2&features)||(n=window.location.hostname);domainUrl.substring(0,domainUrl.length-1);var o="https://"+n+(443==serverinfo.port?"":":"+serverinfo.port)+domainUrl+e;1==t&&(o+=Q("aginsType").value),copyTextToClip(o+=urlargs.key?"&key="+urlargs.key:"")}function addAgentToMeshClick(){var e=Q("aginsSelect").value;QV("agins_windows",0==e),QV("agins_linux",1==e),QV("agins_osx",2==e),QV("agins_windows_un",3==e),QV("agins_linux_un",4==e),QV("aginsTypeDiv",0==e),Q("aginsw32lnk").href=Q("aginsw32lnk").href.split("installflags=")[0]+"installflags="+Q("aginsType").value+(urlargs.key?"&key="+urlargs.key:""),Q("aginsw64lnk").href=Q("aginsw64lnk").href.split("installflags=")[0]+"installflags="+Q("aginsType").value+(urlargs.key?"&key="+urlargs.key:""),0<debugmode&&(Q("aginswmshlnk").href=Q("aginswmshlnk").href.split("installflags=")[0]+"installflags="+Q("aginsType").value+(urlargs.key?"&key="+urlargs.key:""))}function validateDeviceToMesh(){QE("idx_dlgOkButton",0<Q("dp1devicename").value.length&&passwordcheck(Q("dp1password").value))}function addDeviceToMeshEx(e,t){var n=Q("dp1username").value;""==n&&(n="admin");var o=Q("dp1hostname").value;""==o&&(o=Q("dp1devicename").value),meshserver.send({action:"addamtdevice",meshid:t,devicename:Q("dp1devicename").value,hostname:o,amtusername:n,amtpassword:Q("dp1password").value,amttls:Q("dp1tls").value})}function deviceHeaderSet(){0!=deviceHeaderId?(deviceHeaders["DevxHeader"+deviceHeaderId]=1==deviceHeaderTotal?"1 node":format("{0} nodes",deviceHeaderTotal),deviceHeaderId++,deviceHeaderCount={},deviceHeaderTotal=0):deviceHeaderId=1}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>'],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"],powerColorTable=["pwsTransparent","pwsBlack","pwsBlue","pwsBlue2","pwsLightblue","pwsBlueviolet","pwsDarkgreen","pwsLightseagreen","pwsLightseagreen2"];function NodeStateStr(e){var t=[];return 0<e.state&&e.state<powerStatetable.length&&state.push(powerStatetable[e.state]),e.conn&&(0!=(1&e.conn)&&t.push('<span title="Mesh agent is connected and ready for use.">Agent</span>'),0!=(2&e.conn)?t.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">CIRA</span>'):0!=(4&e.conn)&&t.push('<span title="Intel&reg; AMT is routable.">AMT</span>'),0!=(8&e.conn)&&t.push('<span title="Mesh agent is reachable using another agent as relay.">Relay</span>'),0!=(16&e.conn)&&t.push('<span title="MQTT connection to the device is active.">MQTT</span>')),null!=e.pwr&&0!=e.pwr&&t.push(powerStateStrings[e.pwr]),t.join(", ")}function PowerStateStr(e){return e<powerStatetable.length?powerStatetable[e]:""}function PowerStateStr2(e){return 0!=e&&e<powerStatetable.length?powerStatetable[e]:"Unknown"}function selectallButtonFunction(){for(var e=document.getElementsByClassName("DeviceCheckbox"),t=0,n=0;n<e.length;n++)!0===e[n].checked&&t++;for(n=0;n<e.length;n++)e[n].checked=0==t;p1updateInfo()}function p1updateInfo(){for(var e=document.getElementsByClassName("DeviceCheckbox"),t=0,n=0;n<e.length;n++)!0===e[n].checked&&t++;if(0<t?(QE("GroupActionButton",!0),Q("SelectAllButton").value="Select None",QV("cxmgroupsplit",!0),QV("cxmdesktop",!0)):(QE("GroupActionButton",!1),Q("SelectAllButton").value="Select All",QV("cxmgroupsplit",!1),QV("cxmdesktop",!1)),null!=customui&&customui.devicesbarbuttons)for(var n in customui.devicesbarbuttons)"one"==customui.devicesbarbuttons[n].selection&&QE("cui:"+n,1==t),"many"==customui.devicesbarbuttons[n].selection&&QE("cui:"+n,1<=t)}function groupActionFunction(){var e="",t=getCheckedDevices();if(4194304&features)for(var n in t)if(0!=(16&getNodeFromId(t[n]).conn)){e+="<option value=103>Send MQTT Message</option>";break}for(var n in t){var o=getNodeFromId(t[n]),i=GetNodeRights(o);if(0!=(1&o.conn)&&0!=(32768&i)){e+="<option value=104>Uninstall Agent</option>";break}}var a="Select an operation to perform on all selected devices. Actions will be performed only with proper rights.<br /><br />";setDialogMode(2,"Group Action",3,groupActionFunctionEx,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=105>Export device information</option><option value=102>Move to device group</option>"+e+"<option value=101>Delete devices</option></select>"))}function getCheckedDevices(){for(var e=[],t=document.getElementsByClassName("DeviceCheckbox"),n=0;n<t.length;n++)if(t[n].checked&&t[n].value){var o=t[n].value.substring(6);-1==e.indexOf(o)&&e.push(o)}return e}function uncheckAllDevices(){for(var e=document.getElementsByClassName("DeviceCheckbox"),t=0;t<e.length;t++)e[t].checked=!1}function groupActionFunctionEx(){var e=Q("d2groupop").value;if(100==e)meshserver.send({action:"wakedevices",nodeids:getCheckedDevices()}),uncheckAllDevices();else if(101==e){"<label><input id=d2check type=checkbox onchange=d2groupActionFunctionDelCheck() />Confirm</label>",setDialogMode(2,"Delete Nodes",3,d2groupActionFunctionDelExec,"Confirm delete selected devices(s)?<br /><br /><label><input id=d2check type=checkbox onchange=d2groupActionFunctionDelCheck() />Confirm</label>"),QE("idx_dlgOkButton",!1)}else 102==e?p10showChangeGroupDialog(getCheckedDevices()):103==e?p10showSendMqttMsgDialog(getCheckedDevices()):104==e?p10showSendUninstallAgentDialog(getCheckedDevices()):105==e?p2downloadDeviceInfo():(meshserver.send({action:"poweraction",nodeids:getCheckedDevices(),actiontype:parseInt(e)}),uncheckAllDevices())}function p2downloadDeviceInfo(){if(!xxdialogMode){var e="Download the list of devices with one of the file formats below.<br /><br />";e+=addHtmlValue("CSV Format","<a href=# style=cursor:pointer onclick='return p2downloadDeviceInfoCSV()'>devicelist.csv</a>"),setDialogMode(2,"Device Information Export",1,null,e+=addHtmlValue("JSON Format","<a href=# style=cursor:pointer onclick='return p2downloadDeviceInfoJSON()'>devicelist.json</a>"))}}function p2downloadDeviceInfoCSV(){var e="id, name, rname, host, icon, ip, osdesc, state, groupname, conn, pwr\r\n",t=getCheckedDevices();for(var n in t){var o=getNodeFromId(t[n]);e+='"'+o._id.split(",").join("")+'","'+o.name.split(",").join("")+'","'+(o.rname?o.rname.split(",").join(""):"")+'","'+(o.host?o.host.split(",").join(""):"")+'","'+o.icon+'","'+(o.ip?o.ip:"")+'","'+(o.osdesc?o.osdesc.split(",").join(""):"")+'","'+o.state+'","'+meshes[o.meshid].name.split(",").join("")+'","'+(o.conn?o.conn:"")+'","'+(o.pwr?o.pwr:"")+'"\r\n'}return saveAs(new Blob([e],{type:"application/octet-stream"}),"devicelist.csv"),uncheckAllDevices(),!1}function p2downloadDeviceInfoJSON(){var e=getCheckedDevices(),t=[];for(var n in e)t.push(getNodeFromId(e[n]));return saveAs(new Blob([JSON.stringify(t,null,2)],{type:"application/octet-stream"}),"devicelist.json"),uncheckAllDevices(),!1}function d2groupActionFunctionDelCheck(){QE("idx_dlgOkButton",Q("d2check").checked)}function d2groupActionFunctionDelExec(){meshserver.send({action:"removedevices",nodeids:getCheckedDevices()}),uncheckAllDevices()}function onSortSelectChange(e){sort=document.getElementById("sortselect").selectedIndex,e||putstore("sort",sort)}function nameSort(e,t){var n=e.name.toLowerCase(),o=t.name.toLowerCase();return o<n?1:n<o?-1:0}function meshSort(e,t){return e.meshnamel>t.meshnamel?1:e.meshnamel<t.meshnamel?-1:e.meshid==t.meshid?1==showRealNames?e.rnamel>t.rnamel?1:e.rnamel<t.rnamel?-1:0:e.namel>t.namel?1:e.namel<t.namel?-1:0:0}function powerSort(e,t){var n=e.pwr?e.pwr:0,o=t.pwr?t.pwr:0;return o<n?-1:n<o?1:n==o?1==showRealNames?e.rnamel>t.rnamel?1:e.rnamel<t.rnamel?-1:0:e.namel>t.namel?1:e.namel<t.namel?-1:0:0}function deviceSort(e,t){return e.namel>t.namel?1:e.namel<t.namel?-1:0}function deviceHostSort(e,t){return e.rnamel>t.rnamel?1:e.rnamel<t.rnamel?-1:0}function onSearchFocus(e){searchFocus=e}function onMapSearchFocus(e){mapSearchFocus=e}function onUserSearchFocus(e){userSearchFocus=e}function onConsoleFocus(e){consoleFocus=e}function onSearchInputChanged(){var e=Q("SearchInput").value.toLowerCase().trim();putstore("_search",Q("SearchInput").value);var t=null,n=null,o=null,i=null;if(e.startsWith("user:".toLowerCase())?t=e.substring("user:".length):e.startsWith("u:".toLowerCase())?t=e.substring("u:".length):e.startsWith("ip:".toLowerCase())?n=e.substring("ip:".length):e.startsWith("group:".toLowerCase())?o=e.substring("group:".length):e.startsWith("g:".toLowerCase())?o=e.substring("g:".length):e.startsWith("tag:".toLowerCase())?i=Q("SearchInput").value.trim().substring("tag:".length):e.startsWith("t:".toLowerCase())&&(i=Q("SearchInput").value.trim().substring("t:".length)),""==e)for(var a in nodes)nodes[a].v=!0;else if(null!=n)for(var a in nodes)nodes[a].v=null!=nodes[a].ip&&0<=nodes[a].ip.indexOf(n);else if(null!=o)for(var a in nodes)nodes[a].v=0<=meshes[nodes[a].meshid].name.toLowerCase().indexOf(o);else if(null!=i)for(var a in nodes)nodes[a].v=null==nodes[a].tags&&""==i||null!=nodes[a].tags&&0<=nodes[a].tags.indexOf(i);else if(null!=t){for(var a in nodes)if(nodes[a].v=!1,nodes[a].users&&0<nodes[a].users.length)for(var s in nodes[a].users)0<=nodes[a].users[s].toLowerCase().indexOf(t)&&(nodes[a].v=!0)}else try{var r=e.split(/\s+/).join("|"),l=new RegExp(r);for(var a in nodes)if(nodes[a].v=l.test(nodes[a].name.toLowerCase())||null!=nodes[a].rnamel&&l.test(nodes[a].rnamel.toLowerCase()),0==nodes[a].v&&nodes[a].tags)for(var d in nodes[a].tags){if(l.test(nodes[a].tags[d].toLowerCase())){nodes[a].v=!0;break}nodes[a].v=!1}}catch(e){for(var a in nodes)nodes[a].v=!0}if(Q("OnlineCheckBox").checked)for(var a in nodes)null!=nodes[a].conn&&0!=nodes[a].conn||(nodes[a].v=!1)}var contextelement=null;function handleContextMenu(e){if(hideContextMenu(),!xxdialogMode){for(var t=null!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,n=null!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,o=document.elementFromPoint(e.pageX-t,e.pageY-n);o&&null!=o&&null==o.attributes.cmenu;)o=o.parentElement;if(null==o)return!0;var i=o.attributes.cmenu.value;switch(i){case"termConnectButton":if(null==currentNode||null==currentNode.agent)return!0;contextelement=o;var a=document.getElementById("termShellContextMenu");4<currentNode.agent.id&&(a=document.getElementById("termShellContextMenuLinux")),showContextMenuDiv(a,e.pageX,e.pageY);break;case"deskConnectButton":if(null==currentNode||null==currentNode.agent)return!0;contextelement=o,showContextMenuDiv(document.getElementById("deskConnectContextMenu"),e.pageX,e.pageY);break;case"devsContentMenu":contextelement=o,showContextMenuDiv(a=document.getElementById("contextMenu"),e.pageX,e.pageY);var s=contextelement.children[1].attributes.onclick.value,r=getNodeFromId(s.substring(12,s.length-18)),l=meshes[r.meshid],d=GetNodeRights(r),c=0!=(16&d),u=4294967295==d||0==(65536&d),p=4294967295==d||0==(512&d),m=4294967295==d||0==(1024&d);QV("cxdesktop",(1==l.mtype||null==r.agent||null==r.agent.caps||0!=(1&r.agent.caps)||r.intelamt&&2==r.intelamt.state)&&(8&d||256&d)&&u),QV("cxterminal",(1==l.mtype||null==r.agent||null==r.agent.caps||0!=(2&r.agent.caps)||r.intelamt&&2==r.intelamt.state)&&8&d&&p),QV("cxfiles",2==l.mtype&&(null==r.agent||null==r.agent.caps||0!=(4&r.agent.caps))&&8&d&&m),QV("cxevents",null!=r.intelamt&&(2==r.intelamt.state||2&r.conn)&&8&d),QV("cxconsole",c&&2==l.mtype&&(null==r.agent||null==r.agent.caps||0!=(8&r.agent.caps))&&8&d);break;default:if(null==(a=document.getElementById(i)))return!0;contextelement=o,showContextMenuDiv(a,e.pageX,e.pageY)}return haltEvent(e)}}function showContextMenuDiv(e,t,n){var o=document.documentElement.getBoundingClientRect(),i=o.height,a=o.width;e.style.left=e.style.right=e.style.top=e.style.bottom=null,a/2<t?e.style.right=a-event.pageX+"px":e.style.left=event.pageX+"px",i/2<n?e.style.bottom=i-event.pageY+"px":e.style.top=event.pageY+"px",e.style.display="block"}function cmaction(e,t){var n=contextelement.children[1].attributes.onclick.value;if(n=n.substring(12,n.length-18),9==e&&(Q("viewselect").value=3,Q("viewselect").onchange(),Q("autoConnectDesktopCheckbox").checked=!0,Q("autoConnectDesktopCheckbox").onclick()),0<e&&e<9){var o=[0,10,12,11,13,16,17,15,19][e];if(t&&1==t.shiftKey)window.open(window.location.origin+"?node="+n.split("/")[2]+"&viewmode="+o+"&hide=16","meshcentral:"+n);else{gotoDevice(n,o);var i=meshes[currentNode.meshid];1&currentNode.conn&&2==i.mtype&&(11==o&&null==desktop&&1&currentNode.agent.caps&&connectDesktop(null,3),12==o&&null==terminal&&2&currentNode.agent.caps&&connectTerminal(null,1),13==o&&null==files&&connectFiles(null))}}}function cmmeshaction(e){var t=contextelement.attributes.onclick.value.substring(10,contextelement.attributes.onclick.value.length-2),n=document.getElementsByClassName("DeviceCheckbox");if(1==e||2==e)for(var o=0;o<n.length;o++)n[o].attributes&&n[o].attributes.class.value.split(" ")[0]==t&&(n[o].checked=1==e);p1updateInfo()}function cmtermaction(e){e<100?connectTerminal(null,1,{protocol:e}):100==e&&connectTerminal(null,1,{protocol:1,requireLogin:!0})}function cmdeskaction(e){1==e&&connectDesktop(null,3,null,72),2==e&&connectDesktop(null,3,null,8),3==e&&connectDesktop(null,3,null,64)}function cmaltportaction(e){if(!xxdialogMode){setDialogMode(2,"RDP Connection",3,function(){setDialogMode(0);var e=0<Q("d10rdpport").value.length?parseInt(Q("d10rdpport").value):3389;meshserver.send({action:"changedevice",nodeid:currentNode._id,rdpport:e}),null!=currentNode&&p10clickOnce(currentNode._id,"RDP2",e)},'RDP remote connection port:<br /><br /><input type=text placeholder="3389" inputmode="numeric" pattern="[0-9]*" onkeypress="return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)" maxlength=5 id=d10rdpport type=text>',currentNode),Q("d10rdpport").focus(),null!=currentNode.rdpport&&(Q("d10rdpport").value=currentNode.rdpport)}}function cmrfbportaction(e){if(!xxdialogMode){setDialogMode(2,"noVNC Connection",3,function(){setDialogMode(0);var e=0<Q("d10rfbport").value.length?parseInt(Q("d10rfbport").value):3389;meshserver.send({action:"changedevice",nodeid:currentNode._id,rfbport:e}),null!=currentNode&&p10rfb(currentNode._id,e)},'noVNC remote connection port:<br /><br /><input type=text placeholder="5900" inputmode="numeric" pattern="[0-9]*" onkeypress="return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)" maxlength=5 id=d10rfbport type=text>',currentNode),Q("d10rfbport").focus(),null!=currentNode.rfbport&&(Q("d10rfbport").value=currentNode.rfbport)}}function cmfilesaction(e){if(!xxdialogMode){var t=p13sort_files(p13filetree.dir)[parseInt(contextelement.attributes.fileindex.nodeValue)];1==e?(setDialogMode(2,"Rename",3,p13renamefileEx,'<input type=text id=p13renameinput maxlength=64 onkeyup=p13fileNameCheck(event) style=width:100% value="'+t.n+'" />',{action:"rename",path:p13filetreelocation.join("/"),oldname:t.n}),focusTextBox("p13renameinput"),p13fileNameCheck()):2==e?t.s<=204800?p13downloadfile(encodeURIComponentEx(p13filetreelocation.join("/")+"/"+t.n),encodeURIComponentEx(t.n),t.s,"viewer"):messagebox("File Editor","Only files less than 200k can be edited."):3==e&&setDialogMode(2,"Delete",3,p13deletefileCm,"Delete item?",t)}}function cmdeskplayeraction(e){xxdialogMode||window.open(window.location.origin+"{{{domainurl}}}player.htm","meshcentral-deskplayer")}function p13deletefileCm(e,t){files.sendText({action:"rm",reqid:1,path:p13filetreelocation.join("/"),delfiles:[t.n],rec:!1}),p13folderup(999)}function hideContextMenu(){QV("contextMenu",!1),QV("meshContextMenu",!1),QV("termShellContextMenu",!1),QV("termShellContextMenuLinux",!1),QV("deskConnectContextMenu",!1),QV("altPortContextMenu",!1),QV("rfbPortContextMenu",!1),QV("filesContextMenu",!1),QV("deskPlayerContextMenu",!1),contextelement=null}var map_cm_popup,map_cm_editMarker,map_cm_clearMarker,map_cm_saveMarker,map_cm_nodemenu_items,contextmenu_items,currentNode,xxmap={map:null,contextmenu:null,activeInteractions:[],showindex:0,markersSource:null,markersLayer:null,mapLayer:null,mapView:null};function updateMapMarkers(e){if(0!=(32768&features)){if(null!=xxmap&&null==xxmap.map)try{loadmap()}catch(e){console.error("loadmap() exception",e)}if(null!=xxmap){var t=null;for(var n in nodes)try{var o=map_parseNodeLoc(nodes[n]),i=xxmap.markersSource.getFeatureById(nodes[n]._id);if(null==o||nodes[n].meshid!=e&&null!=e)i&&xxmap.markersSource.removeFeature(i);else{var a=o[0],s=o[1];o[2];null==t?t=[a,s,a,s,0]:(a<t[0]&&(t[0]=a),s<t[1]&&(t[1]=s),a>t[2]&&(t[2]=a),s>t[3]&&(t[3]=s)),null==i?(addFeature(nodes[n]),t[4]=1):(updateFeature(nodes[n],i),i.setStyle(markerStyle(nodes[n],o[2])))}}catch(e){console.error("updateMapMarkers() exception",e,JSON.stringify(nodes[n]))}return t}}}function stringToIntHash(e){var t,n=0;for(t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return n}function map_parseNodeLoc(e){var t=null,n=0;return e.iploc&&(t=e.iploc,n=1),e.wifiloc&&(t=e.wifiloc,n=2),e.gpsloc&&(t=e.gpsloc,n=3),e.userloc&&(t=e.userloc,n=4),null==t||"string"!=typeof t?null:(t=t.split(","),1==n?[parseFloat(t[0])+stringToIntHash(e._id.substring(0,20))/1e11,parseFloat(t[1])+stringToIntHash(e._id.substring(20))/1e11,n]:[parseFloat(t[0]),parseFloat(t[1]),n])}function loadmap(){if(0!=(32768&features)&&null!=xxmap)if(0!=(32768&features)){QV("viewselectmapoption",!0),QV("devViewButton4",!0);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([-1e5,-69.55,1e5,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(e){var t=xxmap.map.forEachFeatureAtPixel(e.pixel,function(e,t){return e});if(t){var n=t.getId();if(null!=n)gotoDevice(n,10);else gotoDevice(getCorrespondingFeature(t).getId(),10)}}),xxmap.map.on("pointermove",function(e){var t=xxmap.map.forEachFeatureAtPixel(e.pixel,function(e,t){return e});if(t){xxmap.map.getTargetElement().style.cursor="pointer";var n=t.getGeometry().getCoordinates();if(map_cm_popup.setPosition(n),t.getId())QH("xmap-info-window",t.get("name"));else{var o=getCorrespondingFeature(t);QH("xmap-info-window",o.get("name"))}}else xxmap.map.getTargetElement().style.cursor="",QH("xmap-info-window","")});var e=new ContextMenu({width:160,defaultItems:!1,items:contextmenu_items});e.on("open",function(e){var t=xxmap.map.forEachFeatureAtPixel(e.pixel,function(e,t){return e});if(xxmap.contextmenu.clear(),t)if(t.getId())addContextMenuItems(t);else{var n=getCorrespondingFeature(t);n?addContextMenuItems(n):xxmap.contextmenu.extend(contextmenu_items)}else xxmap.contextmenu.extend(contextmenu_items)}),null==xxmap.contextmenu&&(xxmap.contextmenu=e),xxmap.map.addControl(xxmap.contextmenu)}catch(e){console.log(e),QV("viewselectmapoption",!1),QV("devViewButton4",!1),xxmap=null}}else xxmap=null}function addFeature(e,t,n){var o=getModifiedFeature(e._id);if(o)xxmap.markersSource.addFeature(o);else{if(!t&&!n){var i=map_parseNodeLoc(e);t=i[0],n=i[1]}if(180<n&&(n=180-n,meshserver.send({action:"changedevice",nodeid:e._id,userloc:[t,n]})),t<90&&-90<t&&n<180&&-180<n){var a=new ol.Feature({geometry:new ol.geom.Point(ol.proj.transform([n,t],"EPSG:4326","EPSG:3857")),name:e.name,status:e.conn,lat:t,lon:n});a.setId(e._id),a.setStyle(markerStyle(e)),xxmap.markersSource.addFeature(a)}}}function removeFeature(e){var t=xxmap.markersSource.getFeatureById(e._id);t&&xxmap.markersSource.removeFeature(t)}function updateFeature(e,t){e.conn!=t.get("status")&&(t.set("status",e.conn),t.setStyle(markerStyle(e)));var n=map_parseNodeLoc(e);if(null!=n){var o=n[0],i=n[1];if(o!=t.get("lat")||i!=t.get("lon")){t.set("lat",o),t.set("lon",i);var a=ol.proj.transform([parseFloat(i),parseFloat(o)],"EPSG:4326","EPSG:3857");t.getGeometry().setCoordinates(a)}}e.name!=t.get("name")&&t.set("name",e.name)}function modifyMarkerloc(e){var t=e.getId();if(t&&(e.setStyle(markerStyle(getNodeFromId(e.a),4)),!getActiveInteractions(e))){var n=new ol.interaction.Modify({features:new ol.Collection([e]),pixelTolerance:10});xxmap.activeInteractions.push({featureid:t,feature:e,interaction:n}),xxmap.map.addInteraction(n)}}function saveMarkerloc(e){var t=e.getId();if(t){var n=getActiveInteractions(e);if(n){xxmap.map.removeInteraction(n),removeInteraction(t);var o=e.getGeometry().getCoordinates(),i=ol.proj.transform(o,"EPSG:3857","EPSG:4326");180<i[0]&&(i[0]=180-i[0]);var a=[i[1],i[0]];meshserver.send({action:"changedevice",nodeid:t,userloc:a})}}}function markerStyle(e,t){null==t&&(t=0,e.iploc&&(t=1),e.wifiloc&&(t=2),e.gpsloc&&(t=3),e.userloc&&(t=4));var n=connStateColor(e);return[new ol.style.Style({image:new ol.style.Icon({color:n,anchor:[.5,1],src:"images/mapmarker"+["","-ip","-wifi","-gps","-user"][t]+".png"})})]}function connStateColor(e){return 1==e.conn||3==e.conn||5==e.conn?"#00ffdd":"#C70039"}function addContextMenuItems(t){getActiveInteractions(t)?(map_cm_saveMarker.data=t,xxmap.contextmenu.push(map_cm_saveMarker)):(map_cm_editMarker.data=t,xxmap.contextmenu.push(map_cm_editMarker),getNodeFromId(t.a).userloc&&(map_cm_clearMarker.data=t,xxmap.contextmenu.push(map_cm_clearMarker)));map_cm_nodemenu_items.forEach(function(e){"Zoom-in to extent"==e.text||"Zoom-out to extent"==e.text?e.data=t:"-"!=e&&(e.data=t.getId())}),xxmap.contextmenu.extend(map_cm_nodemenu_items)}function getActiveInteractions(e){for(var t=e.getId(),n=0;n<xxmap.activeInteractions.length;n++)if(xxmap.activeInteractions[n].featureid==t)return xxmap.activeInteractions[n].interaction;return!1}function getModifiedFeature(e){if(e)for(var t=0;t<xxmap.activeInteractions.length;t++)if(xxmap.activeInteractions[t].featureid==e)return xxmap.activeInteractions[t].feature;return null}function removeInteraction(e){for(var t=-1,n=0;n<xxmap.activeInteractions.length;n++)if(xxmap.activeInteractions[n].featureid===e){t=n;break}0<=t&&xxmap.activeInteractions.splice(t,1)}function getCorrespondingFeature(e){for(var t=e.getGeometry().getCoordinates(),n=0;n<xxmap.activeInteractions.length;n++){var o=xxmap.activeInteractions[n].feature,i=o.getGeometry().getCoordinates();if(i[0].toFixed(5)==t[0].toFixed(5)&&i[1].toFixed(5)==t[1].toFixed(5))return o}return null}function refreshMap(e,t){e&&(xxmap.map.setTarget(null),xxmap.map=null,xxmap.markersSource=null,xxmap.mapView=null,xxmap.mapLayer=null,xxmap.activeInteractions=[]);var n=updateMapMarkers();if(null!=n&&(t||1==n[4])){var o=(n[0]+n[2])/2,i=(n[1]+n[3])/2,a=Math.max(Math.abs(n[0]-n[2]),Math.abs(n[1]-n[3])),s=xxmap.map.getView();s.setCenter(ol.proj.transform([i,o],"EPSG:4326","EPSG:3857"));for(var r=360,l=-2;a<r;)l++,r/=2;s.setZoom(l)}}function placeNode(e){if(!xxdialogMode){var t='<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 n in nodes)t+="<div class=noselect id="+nodes[n]._id+"-rowid onclick=selectNodeToPlace(event,'"+nodes[n]._id+"') style=background-color:lightgray;margin-bottom:4px;border-radius:2px><input name=PlaceMapDeviceCheckbox id="+nodes[n]._id+"-checkid type=checkbox style=width:16px;display:inline />",t+="<div class=j"+nodes[n].icon+" style=width:16px;height:16px;margin-top:2px;margin-right:4px;display:inline-block></div><div style=width:16px;display:inline>"+nodes[n].name+"</div></div>";setDialogMode(2,"Select a node to place",3,placeNodeEx,t+"</div>",e),onPlaceNodeInputChange()}}function placeNodeEx(e,t){var n=document.getElementsByName("PlaceMapDeviceCheckbox");for(var o in n)if(n[o].checked){var i=getNodeFromId(n[o].id.substring(0,n[o].id.length-8));if(i){var a=xxmap.markersSource.getFeatureById(o),s=ol.proj.transform(t,"EPSG:3857","EPSG:4326"),r=[s[1],s[0]];if(a)a.getGeometry().setCoordinates(t),getActiveInteractions(a)?saveMarkerloc(a):meshserver.send({action:"changedevice",nodeid:i._id,userloc:r});else meshserver.send({action:"changedevice",nodeid:i._id,userloc:r})}}}function onPlaceNodeInputChange(){updatePlaceNodeTable(Q("selectnode-search").value.trim().toLowerCase())}function updatePlaceNodeTable(e){document.getElementsByName("PlaceMapDeviceCheckbox");var t=0;for(var n in nodes){var o=0<=nodes[n].namel.indexOf(e)||""==e||null!=nodes[n].rnamel&&0<=nodes[n].rnamel.indexOf(e);o&&t++,QV(nodes[n]._id+"-rowid",o)}QV("noNodesMapPlace",0==t)}function selectNodeToPlace(e,t){if("PlaceMapDeviceCheckbox"!=e.target.name){var n=Q(t+"-checkid");n.checked=!n.checked}var o=document.getElementsByName("PlaceMapDeviceCheckbox"),i=0;for(var a in o)o[a].checked&&i++;QE("idx_dlgOkButton",0<i)}function addMeshOptions(e,t){}function meshOptionRmvMod(e,t){}function meshExists(){for(var e in meshes)if(meshes[e])return!0;return!1}function setMeshView(e){var t=Q("select-mesh");t[t.selectedIndex].value==e&&(t[0].selected=!0,onSelectMeshChange())}function clearMeshOptions(){}function getSearchLocation(){try{var e=Q("mapSearchLocation").value.trim();if(0<e.length){var t=new XMLHttpRequest;t.onreadystatechange=function(){4==t.readyState&&200==t.status&&formatSearchData(t.responseText)},t.open("GET","https://nominatim.openstreetmap.org/search?q="+e+"&format=json",!0),t.send()}}catch(e){}}function formatSearchData(e){try{QH("xmapSearchResults","");for(var t=JSON.parse(e),n=0,o='<div class="xmapItem">',i=0;i<t.length;i++)if(t[i].display_name&&t[i].boundingbox[0]&&t[i].boundingbox[1]&&t[i].boundingbox[2]&&t[i].boundingbox[3]){n++;o+='<div class="xmapItemSel1" onclick=mapGotoSelectedLocation(this)><div>'+t[i].display_name+"</div><div style=display:none>"+t[i].boundingbox[0]+"!#!"+t[i].boundingbox[1]+"!#!"+t[i].boundingbox[2]+"!#!"+t[i].boundingbox[3]+"</div></div>"}if(o+="</div>",1==n)zoomToExtent([parseFloat(t[0].boundingbox[2]),parseFloat(t[0].boundingbox[0]),parseFloat(t[0].boundingbox[3]),parseFloat(t[0].boundingbox[1])]);else 0==n&&(o="<div style=width:200px>No location found.<div>"),QV("xmapSearchResultsDlg",!0);QH("xmapSearchResults",o)}catch(e){}}function mapGotoSelectedLocation(e){var t=e.children[1].innerHTML.split("!#!");zoomToExtent([parseFloat(t[2]),parseFloat(t[0]),parseFloat(t[3]),parseFloat(t[1])]),mapCloseSearchWindow()}function mapCloseSearchWindow(){QH("xmapSearchResults",""),QV("xmapSearchResultsDlg",!1)}function zoomToLocation(e,t){var n=xxmap.map.getView();n.setCenter(e),n.setZoom(t)}function zoomToFitExtent(){if(0<xxmap.markersSource.getFeatures().length){var e=xxmap.markersSource.getExtent();xxmap.map.getView().fit(e,xxmap.map.getSize())}}function zoomToExtent(e){var t=ol.proj.transformExtent(e,ol.proj.get("EPSG:4326"),ol.proj.get("EPSG:3857"));xxmap.map.getView().fit(t,xxmap.map.getSize())}function refreshDevice(e){currentNode&&currentNode._id==e&&gotoDevice(e,xxcurrentView,!0)}32768&features&&(map_cm_popup=new ol.Overlay({element:Q("xmap-info-window"),positioning:"bottom-center",stopEvent:!1}),map_cm_editMarker={text:"Modify node location",callback:function(e){modifyMarkerloc(e.data)}},map_cm_clearMarker={text:"Remove node location",callback:function(e){meshserver.send({action:"changedevice",nodeid:e.data.a,userloc:[]})}},map_cm_saveMarker={text:"Save node location",callback:function(e){saveMarkerloc(e.data)}},map_cm_nodemenu_items=[{text:"General information",callback:function(e){null!=e.data&&gotoDevice(e.data,10)}},{text:"Desktop",callback:function(e){null!=e.data&&gotoDevice(e.data,11)}},{text:"Terminal",callback:function(e){null!=e.data&&gotoDevice(e.data,12)}},{text:"Intel&reg; AMT",callback:function(e){null!=e.data&&gotoDevice(e.data,14)}},"-",{text:"Zoom-in to extent",callback:function(e){zoomToLocation(e.data.getGeometry().getCoordinates(),19)}},{text:"Zoom-out to extent",callback:function(e){zoomToLocation(e.data.getGeometry().getCoordinates(),2)}}],contextmenu_items=[{text:"Refresh",callback:function(){refreshMap(!0,!0)}},{text:"Zoom to fit extent",callback:function(){zoomToFitExtent()}},{text:"Center map here",callback:function(e){xxmap.mapView.animate({center:e.coordinate})}},{text:"Place node here",callback:function(e){placeNode(e.coordinate)}}]);var powerTimelineNode=null,powerTimelineReq=null,powerTimelineUpdate=null,powerTimeline=null;function getCurrentNode(){return currentNode}function gotoDevice(e,t,n,o){if(!0===userinfo.emailVerified||1!=serverinfo.emailcheck||4294967295==userinfo.siteadmin)if(262144&features&&0==count2factoraAuths())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.');else if(o&&1==o.shiftKey)window.open(window.location.origin+"?node="+e.split("/")[2]+"&viewmode=10&hide=16","meshcentral:"+e);else{var i=getNodeFromId(e);if(null!=i){var a=meshes[i.meshid],s=GetNodeRights(i),r=null==currentNode||currentNode._id!=e;if(!currentNode||currentNode._id!=i._id||1==n){if(currentNode=i,QV("p10deviceNotify",null!=currentNode.sessions&&(null!=currentNode.sessions.kvm||null!=currentNode.sessions.terminal||null!=currentNode.sessions.files)),QV("p10deviceBattery",!1),null!=currentNode.sessions&&null!=currentNode.sessions.battery){var l=currentNode.sessions.battery,d="";"ac"==l.state&&(d="Device is plugged-in"),"dc"==l.state&&(d="Device is battery powered");var c="",u=-1;"number"==typeof l.level&&0<=l.level&&l.level<=100&&(c=l.level+"%",5<(u=Math.floor((l.level+10)/25)+1)&&(lvl=5),"ac"==l.state&&(100==l.level?u=11:u+=5)),0<u&&(Q("p10deviceBattery").title=null!=d?d+", "+c:c,QV("p10deviceBattery",!0),Q("p10deviceBattery").className="deviceBatteryLarge deviceBatteryLarge"+u)}else QV("p10deviceBattery",!1);var p,m=EscapeHtml(i.name);0==m.length&&(m="<i>None</i>"),0==(4&s)||a.flags&&0!=(2&a.flags)||(m='<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>'+m+' <img class=hoverButton src="images/link5.png" /></span>'),p=m,a&&(m+="<span style=color:#AAA;font-size:small> - "+EscapeHtml(a.name)+"</span>"),QH("p10deviceName",m),QH("p11deviceName",m),QH("p12deviceName",m),QH("p13deviceName",m),QH("p14deviceName",m),QH("p15deviceName","Console - "+m),QH("p16deviceName",m),QH("p17deviceName",m),QH("p19deviceName",m);var g="<table style=width:100%>";0!=(8&args.hide)&&(g+="<br />"+addDeviceAttribute("Name",p)),a&&(g+=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("'+i.meshid+'") style=cursor:pointer>'+EscapeHtml(meshes[i.meshid].name)+"</a>")),null!=i.rname&&i.name!=i.rname&&(g+=addDeviceAttribute('<span title="The name of this computer as set in the operating system">OS Name</span>','<span title="The name of this computer as set in the operating system">'+EscapeHtml(i.rname)+"</span>")),0==(1&features)&&(g+=addDeviceAttribute("Hostname",addLinkConditional("<span onclick=showEditNodeValueDialog(1) style=cursor:pointer>"+(i.host?EscapeHtml(i.host):"<i>None</i>")+"</span>","showEditNodeValueDialog(1)",4&s)));var h=i.desc?EscapeHtml(i.desc):"<i>None</i>";if(g+=addDeviceAttribute("Description",0!=(4&s)?"<span onclick=showEditNodeValueDialog(2) style=cursor:pointer>"+h+' <img class=hoverButton src="images/link5.png" /></span>':h),null!=i.agent&&null!=i.agent.id&&null!=i.agent.ver){var v="";v=i.agent.id<=agentsStr.length?agentsStr[i.agent.id]:agentsStr[0],0!=i.agent.ver&&(v+=" v"+i.agent.ver),g+=addDeviceAttribute("Mesh Agent",v)}if(null!=i.intelamt){v="";var f={0:nobreak("Not Activated (Pre)"),1:nobreak("Not Activated (In)"),2:nobreak("Activated")};null!=i.intelamt.ver&&null==i.intelamt.state?v+="<i>Unknown State</i>, v"+i.intelamt.ver:null==i.intelamt.ver&&2==i.intelamt.state?v+="<i>Activated</i>":null==i.intelamt.ver||null==i.intelamt.state?v+="<i>Unknown Version & State</i>":(v+=f[i.intelamt.state],2==i.intelamt.state&&i.intelamt.flags&&(2&i.intelamt.flags?v+=' <span title="Intel AMT is activated in Client Control Mode">CCM</span>':4&i.intelamt.flags&&(v+=' <span title="Intel AMT is activated in Admin Control Mode">ACM</span>')),v+=", v"+i.intelamt.ver),1==i.intelamt.tls&&(v+=', <span title="Intel AMT is setup with TLS network security">TLS</span>'),2==i.intelamt.state&&(null!=i.intelamt.user&&""!=i.intelamt.user||(v+=0!=(4&s)?', <i style=color:#FF0000;cursor:pointer title="Edit Intel&reg; AMT credentials" onclick=editDeviceAmtSettings("'+i._id+'")>No Credentials</i>':", <i style=color:#FF0000>No Credentials</i>"),v+=" ",0!=(4&s)&&(v+='<img src=images/link4.png height=10 width=10 title="Edit Intel&reg; AMT credentials" style=cursor:pointer onclick=editDeviceAmtSettings("'+i._id+'")>'));var k='<span title="Intel&reg; Manageability Engine">Intel&reg; ME<span>';"number"==typeof i.intelamt.sku&&(0!=(8&i.intelamt.sku)?k='<span title="Intel&reg; Active Management Technology">Intel&reg; AMT<span>':0!=(16&i.intelamt.sku)&&(k='<span title="Intel&reg; Standard Manageability">Intel&reg; SM<span>')),g+=addDeviceAttribute(k,v)}if(null!=i.agent&&null!=i.agent.tag)(x=EscapeHtml(i.agent.tag)).startsWith("mailto:")&&(x='<a href="'+x+'">'+x.substring(7)+"</a>"),g+=addDeviceAttribute("Agent Tag",x);else if(null!=i.intelamt&&null!=i.intelamt.tag){var x;(x=EscapeHtml(i.intelamt.tag)).startsWith("mailto:")&&(x='<a href="'+x+'">'+x.substring(7)+"</a>"),g+=addDeviceAttribute("Intel&reg; AMT Tag",x)}if(i.osdesc&&(g+=addDeviceAttribute("Operating System",i.osdesc)),i.av&&0<i.av.length){var y=[];for(var b in i.av)if(i.av[b].product){var w=EscapeHtml(i.av[b].product);!0!==i.av[b].enabled&&(w+=" - <span style=color:red>Disabled</span>"),!0!==i.av[b].updated&&(w+=" - <span style=color:red>Out of date</span>"),1==i.av[b].enabled&&1==i.av[b].updated&&(w+=" - <span style=color:green>OK</span>"),y.push(w)}g+=addDeviceAttribute("Antivirus",y.join("<br />"))}if(i.users&&i.conn&&0<i.users.length&&1&i.conn&&(g+=addDeviceAttribute(format("Active User{0}",1<i.users.length?"s":""),i.users.join(", "))),null!=i.agent){var C=[],D=0;i.consent&&(D=i.consent),serverinfo.consent&&(D|=serverinfo.consent),64&D&&8&D?C.push("Desktop Prompt+Toolbar"):64&D?C.push("Desktop Toolbar"):8&D?C.push("Desktop Prompt"):1&D&&C.push("Desktop Notify"),16&D?C.push("Terminal Prompt"):2&D&&C.push("Terminal Notify"),32&D?C.push("Files Prompt"):4&D&&C.push("Files Notify"),7==D&&(C=["Always Notify"]),56==(56&D)&&(C=["Always Prompt"]),""==(C=C.join(", "))&&(C="<i>None</i>"),g+=addDeviceAttribute("User Consent",addLinkConditional(C,"p20editmeshconsent(3)",1&s))}var S=i.conn;if(S&&1<S){var M=[];0!=(1&i.conn)&&M.push('<span title="Mesh agent is connected and ready for use.">Mesh Agent</span>'),0!=(2&i.conn)?M.push('<span title="Intel&reg; AMT CIRA is connected and ready for use.">Intel&reg; AMT CIRA</span>'):0!=(4&i.conn)&&M.push('<span title="Intel&reg; AMT is routable and ready for use.">Intel&reg; AMT</span>'),0!=(8&i.conn)&&M.push('<span title="Mesh agent is reachable using another agent as relay.">Mesh Relay</span>'),0!=(16&i.conn)&&M.push('<span title="MQTT connection to the device is active.">MQTT</span>'),g+=addDeviceAttribute("Connectivity",M.join(", "))}var E="<i>None</i>";if(null!=i.tags)for(var b in E="",i.tags)E+='<span class="tagSpan">'+i.tags[b]+"</span>";g+=addDeviceAttribute("Tags",0!=(4&s)?"<span onclick=showEditNodeValueDialog(3) style=cursor:pointer>"+E+' <img class=hoverButton src="images/link5.png" /></span>':E),g+="</table><br />",0!=(76&s)&&(g+='<input type=button value="Actions" title="Perform power actions on the device" onclick=deviceActionFunction() />'),g+='<input type=button value="Notes" title="View notes about this device" onclick=showNotes('+(0==(128&s))+',"'+encodeURIComponentEx(i._id)+'") />',g+='<input type=button value="Log Event" title="Write an event for this device" onclick=writeDeviceEvent("'+encodeURIComponentEx(i._id)+'") />',1&S&&8&s&&(g+='<input type=button value="Message" title="Display a text message on the remote device" onclick=deviceMessageFunction() />'),QH("p10html",g),masterUpdate(256);var A=4294967295==s||0==(65536&s),T=4294967295==s||0==(512&s),N=4294967295==s||0==(1024&s),U=4294967295==s||0==(2048&s);g='<div class="p10html3right">',0!=(4&s)&&(g+='&nbsp;<a href=# onclick=p10showChangeGroupDialog(["'+i._id+'"]) title="Move this device to a different device group">Change Group</a>',g+='&nbsp;<a href=# onclick=p10showDeleteNodeDialog("'+i._id+'") title="Remove this device">Delete Device</a>'),g+='</div><div class="p10html3left">',i.agent&&(g+='<a href=# onclick=p10showNodeNetInfoDialog("'+i._id+'") title="Show device network interface information">Interfaces</a>&nbsp;'),32768&features&&null!=xxmap&&(g+='<a href=# onclick=p10showNodeLocationDialog("'+i._id+'") title="Show device locations information">Location</a>&nbsp;'),4294967295!=userinfo.siteadmin&&0!=(128&userinfo.siteadmin)||T&&0!=(8&s)&&null!=i.agent&&(g+='<a href=# onclick=p10showMeshCmdDialog(1,"'+i._id+'") title="Traffic router used to connect to a device thru this server.">MeshCmd</a>&nbsp;'),0!==args.xterm||!i.agent||0==(2&i.agent.caps)||0==(8&s)||4294967295!=s&&0!=(512&s)||(g+='<a href=# onclick=p10openxterm(event,"'+i._id+'") title="Open XTerm terminal">XTerm</a>&nbsp;'),0!=(1&S)&&1==clickOnce&&i.agent&&0!=(8&s)&&(0<i.agent.id&&i.agent.id<5&&(g+='<a href=# cmenu=altPortContextMenu id=rdpClickOnceLink onclick=p10clickOnce("'+i._id+'","RDP2") title="Requires Microsoft ClickOnce support in your browser.">RDP</a>&nbsp;'),4<i.agent.id&&(g+='<a href=# onclick=p10clickOnce("'+i._id+'","PSSH",22) title="Requires Microsoft ClickOnce support in your browser.">Putty</a>&nbsp;',g+='<a href=# onclick=p10clickOnce("'+i._id+'","WSCP",22) title="Requires Microsoft ClickOnce support in your browser.">WinSCP</a>&nbsp;')),0!=(1&S)&&i.agent&&0!=(8&s)&&0==(536870912&features)&&(g+='<a href=# cmenu=rfbPortContextMenu id=rfbLink onclick=p10rfb("'+i._id+'") title="Launch noVNC session to this device.">noVNC</a>&nbsp;'),0!=(1&S)&&i.agent&&0!=(8&s)&&0==(1073741824&features)&&(g+='<a href=# cmenu=rfbPortContextMenu id=mstscLink onclick=p10mstsc("'+i._id+'") title="Launch web-based RDP session to this device.">Web-RDP</a>&nbsp;'),4294967295==s&&4194304&features&&(g+='<a href=# onclick=p10showMqttLoginDialog("'+i._id+'") title="Get MQTT login credentials for this device.">MQTT Login</a>&nbsp;'),g+="</div><br>",QH("p10html3",g);var I=PowerStateStr(i.state);0!=(1&S)&&(0<I.length&&(I+="<br/>"),I+='<span style=font-size:12px title="Agent connected">Agent connected</span>'),0!=(2&S)?(0<I.length&&(I+="<br/>"),I+='<span style=font-size:12px title="Intel&reg; AMT connected">Intel&reg; AMT connected</span>'):0!=(4&S)&&(0<I.length&&(I+="<br/>"),I+='<span style=font-size:12px title="Intel&reg; AMT detected">Intel&reg; AMT detected</span>'),0!=(16&S)&&(0<I.length&&(I+="<br/>"),I+='<span style=font-size:12px title="MQTT connected">MQTT channel connected</span>'),""==I&&i.lastconnect&&(I="<span style=font-size:12px>Last seen:<br />"+printDateTime(new Date(i.lastconnect))+"</span>"),QH("MainComputerState",I),Q("MainComputerImage").setAttribute("src","images/icons256-"+i.icon+"-1.png"),Q("MainComputerImage").className=i.conn&&0!=i.conn?"":"gray",T&&setupTerminal(),N&&setupFiles();var _=0!=(16&s);_?setupConsole():15==t&&(t=10),QV("MainDevDesktop",A&&(null==i.agent&&("number"!=typeof i.intelamt.sku||0!=(8&i.intelamt.sku))||null!=i.agent&&(null==i.agent.caps||0!=(1&i.agent.caps)||i.intelamt&&2==i.intelamt.state))&&(8&s||256&s)),QV("MainDevTerminal",(null==i.agent&&null!=i.intelamt||null==i.agent.caps||0!=(2&i.agent.caps)||i.intelamt&&2==i.intelamt.state)&&8&s&&T),QV("MainDevFiles",null!=i.agent&&null!=i.agent.caps&&0!=(4&i.agent.caps)&&8&s&&N),QV("MainDevAmt",null!=i.intelamt&&(2==i.intelamt.state||2&i.conn)&&8&s&&U),QV("MainDevConsole",_&&null!=i.agent&&null!=i.agent.caps&&0!=(8&i.agent.caps)&&8&s),QV("MainDevPlugins",!1),QV("p15uploadCore",null!=i.agent&&null!=i.agent.caps&&0!=(16&i.agent.caps)),QH("p15coreName",null!=i.agent&&null!=i.agent.core?i.agent.core:"");var V=Q("p14iframe").contentWindow.getCurrentMeshNode();null!=V&&V._id!=currentNode._id&&Q("p14iframe").contentWindow.disconnect();var R=0!=(6&i.conn);if(Q("p14iframe").contentWindow.setConnectionState(R),Q("p14iframe").contentWindow.setFrameHeight("650px"),Q("p14iframe").contentWindow.setAuthCallback(updateAmtCredentials),QV("deskActionsBtn",0!=(72&s)),QV("termActionsBtn",0!=(72&s)),QV("filesActionsBtn",0!=(72&s)),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}),meshserver.send({action:"getsysinfo",nodeid:currentNode._id}),meshserver.send({action:"getnetworkinfo",nodeid:currentNode._id}),QH("p17info","")),QV("DeskTools",!1),showDeskToolsProcesses(),refreshDeviceEvents(),document.title=currentNode&&10<=xxcurrentView&&xxcurrentView<20?currentNode.name+(a?" - "+a.name:"")+" - "+decodeURIComponent("{{{extitle}}}"):decodeURIComponent("{{{extitle}}}"),r&&(p11clearConsoleMsg(),p12clearConsoleMsg(),p13clearConsoleMsg()),null!=pluginHandler){QH("p19headers",""),QH("p19pages",""),pluginHandler.callHook("onDeviceRefreshEnd",e,t,n,o);var H=getstore("_curPluginPage",null);null!=H&&null!=Q("p19ph-"+H)&&pluginHandler.callPluginPage(H,Q("p19ph-"+H))}if(g="",7&s&&(g+='<a href=# onclick="return p20showAddMeshUserDialog(5)" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add User</a>',null!=usergroups)){var F=0,P=!1;for(var b in usergroups)usergroups[b]._id.split("/")[1]==e.split("/")[1]&&(F++,null!=currentNode.links&&null!=currentNode.links[b]||(P=!0));0<F&&P&&(g+='<a href=# onclick="return p20showAddMeshUserDialog(6)" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add User Group</a>')}g+='<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 L=1;if(null!=currentNode.links){var B=[];for(var b in currentNode.links)(b.startsWith("user/")||b.startsWith("ugrp/"))&&B.push(b);for(var b in B.sort(),B){var O="",G="",z=B[b],K=currentNode.links[z].rights,W=EscapeHtml(z.split("/")[2]),j=(G=makeUserDeviceRightsString(K),!1);null!=users&&null!=users[z]&&(W=EscapeHtml(users[z].name)),null!=usergroups&&null!=usergroups[z]&&(W=EscapeHtml(usergroups[z].name),j=!0),0!=(2&s)&&(G=j?(O="<a href=# onclick='return p30removeUserFromNode(event,\""+encodeURIComponentEx(z)+'")\' title="Remove user group rights to this device group" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>','<span style=cursor:pointer onclick=p20showAddMeshUserDialog(6,"'+encodeURIComponentEx(z)+'")>'+G+" <img class=hoverButton style=cursor:pointer src=images/link5.png></span>"):(O="<a href=# onclick='return p30removeUserFromNode(event,\""+encodeURIComponentEx(z)+'")\' title="Remove user rights to this device group" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>','<span style=cursor:pointer onclick=p20showAddMeshUserDialog(5,"'+encodeURIComponentEx(z)+'")>'+G+" <img class=hoverButton style=cursor:pointer src=images/link5.png></span>")),null!=users&&(W=j?"<a href=# onclick='gotoUserGroup(\""+encodeURIComponentEx(z)+"\");haltEvent(event);'>"+W+"</a>":"<a href=# onclick='gotoUser(\""+encodeURIComponentEx(z)+"\");haltEvent(event);'>"+W+"</a>"),g+="<tr "+(++L%2==0?"style=background-color:#DDD":"")+'><td style=width:30%><div title="'+(j?"User Group":"User")+'" class=m'+(j?4:2)+"></div><div>&nbsp;"+W+"<div></div></div></td><td style=width:70%><div style=float:right>"+O+"</div><div>"+G+"</div></td></tr>"}}1==L&&(g+="<tr><td><div style=padding:6px>&nbsp;<i>No users with special device permissions</i><div></div></div></td><td></td></tr>"),g+="</tbody></table>",QH("p10html4",g);var q="";if(0==(268435456&features)&&10<=xxcurrentView&&xxcurrentView<=19&&null!=currentNode){for(var b in q="?viewmode="+xxcurrentView+"&gotonode="+currentNode._id.split("/")[2],urlargs)q+="&"+b+"="+urlargs[b];try{window.history.replaceState({},document.title,window.location.pathname+q)}catch(e){}}}setupDesktop(),go(t=t||10)}}else 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.')}function makeUserDeviceRightsString(e){if(57592==e)return"Full Device Rights";var t=[];if(8&e){var n=[];256&e&&n.push("No Input"),512&e&&n.push("No Terminal"),1024&e&&n.push("No Files"),2048&e&&n.push("No AMT"),4096&e&&n.push("Limited Input"),65536&e&&n.push("No Desktop"),0<n.length?t.push("Control ("+n.join(", ")+")"):t.push("Control")}return 16&e&&t.push("Console"),32&e&&t.push("Server Files"),64&e&&t.push("Wake"),128&e&&t.push("Notes"),8192&e&&t.push("Limit Events"),16384&e&&t.push("Chat"),32768&e&&t.push("Uninstall"),0==t.length?"No Rights":t.join(", ")}function makeDeviceGroupRightsString(e){if(4294967295==e)return"Full Rights";var t=[];if(1&e&&t.push("Edit Group"),2&e&&t.push("Manage Users"),4&e&&t.push("Manage Devices"),8&e){var n=[];256&e&&n.push("No Input"),512&e&&n.push("No Terminal"),1024&e&&n.push("No Files"),2048&e&&n.push("No AMT"),4096&e&&n.push("Limited Input"),65536&e&&n.push("No Desktop"),0<n.length?t.push("Control ("+n.join(", ")+")"):t.push("Control")}return 16&e&&t.push("Console"),32&e&&t.push("Server Files"),64&e&&t.push("Wake"),128&e&&t.push("Notes"),8192&e&&t.push("Limit Events"),16384&e&&t.push("Chat"),32768&e&&t.push("Uninstall"),0==t.length?"No Rights":t.join(", ")}function writeDeviceEvent(e){xxdialogMode||(setDialogMode(2,"Add Device Event",3,writeDeviceEventEx,"<textarea id=d2devEvent style=background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:scroll></textarea><span style=font-size:10px>This will add an entry to this device's event log.<span>",e),Q("d2devEvent").focus())}function writeDeviceEventEx(e,t){meshserver.send({action:"setDeviceEvent",nodeid:decodeURIComponent(t),msg:encodeURIComponentEx(Q("d2devEvent").value)})}function showNotes(e,t){xxdialogMode||(setDialogMode(2,"Notes",2,showNotesEx,"<textarea id=d2devNotes ro="+e+" noteid="+t+" 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>",t),meshserver.send({action:"getNotes",id:decodeURIComponent(t)}))}function showNotesEx(e,t){meshserver.send({action:"setNotes",id:decodeURIComponent(t),notes:encodeURIComponentEx(Q("d2devNotes").value)})}function deviceChat(e){if(!xxdialogMode){var t="/messenger?id=meshmessenger/"+encodeURIComponentEx(currentNode._id)+"/"+encodeURIComponentEx(userinfo._id)+"&title="+currentNode.name;null!=authCookie&&""!=authCookie&&(t+="&auth="+authCookie),e&&1==e.shiftKey?window.open(t,"meshmessenger:"+currentNode._id):window.open(t,"meshmessenger:"+currentNode._id,"directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=560"),meshserver.send({action:"meshmessenger",nodeid:decodeURIComponent(currentNode._id)})}}function deviceToggleBackground(){xxdialogMode||meshserver.send({action:"msg",type:"deskBackground",nodeid:currentNode._id,op:1})}function deviceUrlFunction(){xxdialogMode||(setDialogMode(2,"Open Page on Device",3,deviceUrlFunctionEx,'<input id=d2devurl placeholder="http://server.com" style=width:100%;overflow-y:scroll></input>'),Q("d2devurl").focus())}function deviceUrlFunctionEx(){meshserver.send({action:"msg",type:"openUrl",nodeid:currentNode._id,url:Q("d2devurl").value})}function deviceMessageFunction(){xxdialogMode||(setDialogMode(2,"Device Message",3,deviceMessageFunctionEx,"<div style=margin-bottom:4px>Display a message box on the remote device.</div><textarea id=d2devMessage style=width:100%;height:80px;resize:none;overflow-y:scroll></textarea>"),Q("d2devMessage").focus())}function deviceMessageFunctionEx(){meshserver.send({action:"msg",type:"messagebox",nodeid:currentNode._id,title:"{{{title}}}",msg:Q("d2devMessage").value})}function deviceToastFunction(){xxdialogMode||(setDialogMode(2,"Device Notification",3,deviceToastFunctionEx,"<textarea id=d2devToast style=width:100%;height:80px;resize:none;overflow-y:scroll></textarea>"),Q("d2devToast").focus())}function deviceToastFunctionEx(){meshserver.send({action:"toast",nodeids:[currentNode._id],title:"{{{title}}}",msg:Q("d2devToast").value})}function deviceActionFunction(){if(!xxdialogMode){var e=GetNodeRights(currentNode),t="Select an operation to perform on this device.<br /><br />",n="<select id=d2deviceop style=float:right;width:250px>";0!=(64&e)&&(n+="<option value=100>Wake-up</option>"),0!=(8&e)&&(n+="<option value=4>Sleep</option><option value=3>Reset</option><option value=2>Power off</option>"),0!=(16&currentNode.conn)&&(n+="<option value=103>Send MQTT Message</option>"),0!=(1&currentNode.conn)&&0!=(32768&e)&&(n+="<option value=104>Uninstall Agent</option>"),setDialogMode(2,"Device Action",3,deviceActionFunctionEx,t+=addHtmlValue("Operation",n+="</select>"))}}function deviceActionFunctionEx(){var e=Q("d2deviceop").value;100==e?meshserver.send({action:"wakedevices",nodeids:[currentNode._id]}):103==e?p10showSendMqttMsgDialog([currentNode._id]):104==e?p10showSendUninstallAgentDialog([currentNode._id]):meshserver.send({action:"poweraction",nodeids:[currentNode._id],actiontype:parseInt(e)})}function updateAmtCredentials(e){var t=getNodeFromId(currentNode._id);1==e||null==t.intelamt.user||""==t.intelamt.user?editDeviceAmtSettings(currentNode._id,updateAmtCredentialsEx):Q("p14iframe").contentWindow.connectButtonfunctionEx()}function updateAmtCredentialsEx(e,t){Q("p14iframe").contentWindow.connectButtonfunctionEx()}function updateDeviceTimeline(){2==meshserver.State&&null!=powerTimelineNode&&null!=powerTimelineUpdate&&null!=currentNode&&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(!(null==currentNode||xxcurrentView<10||19<xxcurrentView)){var e=null,t=Date.now();currentNode._id==powerTimelineNode&&(e=powerTimeline);var n=new Date;n.setHours(0,0,0,0);(n=new Date(n.getTime()-5184e5)).getTime();var o=[];if(null!=e&&1<e.length){o.push([0,e[1],e[0]]);for(var i=e[1],a=2;a<e.length;a+=2){var s=e[a],r=t;e.length>a+1&&(r=e[a+1]),o.push([i,i+r,s]),i+=r}}var l="",d=1,c=new Date,u=Q("masthead").offsetWidth-192;c.setHours(0,0,0,0);for(a=0;a<7;a++){var p="",m=c.getTime(),g=m+864e5;for(var h in o){var v=o[h];if(1==isTimeBlockInside(m,g,v[0],v[1])){var f=Math.max(m,v[0]),k=Math.min(Math.min(g,v[1]),t),x=Math.round((k-f)*u/864e5);if(0<x){var y=format("{0} from {1} to {2}.",powerStateStrings2[v[2]],printTime(new Date(f)),printTime(new Date(k)));p+='<div class="pwState '+powerColor(v[2])+'" title="'+y+'" style="width:'+x+'px;"></div>'}}}l+="<tr class="+(d%2==0?"altBack":"")+"><td><div>&nbsp;"+printDate(c)+"<div></div></div></td><td><div>"+p+"</div></td></tr>",++d,c=new Date(c.getTime()-864e5)}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+(urlargs.key?"&key="+urlargs.key:"")+'" onclick="setDialogMode(0)"><img title="Download power events" src="images/link4.png" /></a>7 Day Power State</th></tr></thead><tbody>'+l+"</tbody></table>")}}function powerColor(e){return e<powerColorTable.length?powerColorTable[e]:"pwsYellow"}function isTimeBlockInside(e,t,n,o){return n<e&&t<o||(e<n&&n<t||e<o&&o<t)}function addDeviceAttribute(e,t){return"<tr><td class=style7>"+e+"</td><td class=style9>"+t+"</td></tr>"}function editDeviceAmtSettings(e,t,n){if(!xxdialogMode){var o="",i=getNodeFromId(e),a=3;0!=(4&GetNodeRights(i))&&(o+=addHtmlValue("Username",'<input id=dp10username style=width:230px maxlength=32 autocomplete=nope placeholder="admin" onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />'),o+=addHtmlValue("Password","<input id=dp10password type=password style=width:230px autocomplete=nope maxlength=32 onchange=validateDeviceAmtSettings() onkeyup=validateDeviceAmtSettings() />"),o+=addHtmlValue("Security","<select id=dp10tls style=width:236px><option value=0>No TLS security</option><option value=1>TLS security required</option></select>"),null!=i.intelamt.user&&""!=i.intelamt.user&&(a=7),setDialogMode(2,"Edit Intel&reg; AMT credentials",a,editDeviceAmtSettingsEx,o,{node:i,func:t,arg:n}),null!=i.intelamt.user&&""!=i.intelamt.user?Q("dp10username").value=i.intelamt.user:Q("dp10username").value="admin",Q("dp10tls").value=i.intelamt.tls,validateDeviceAmtSettings())}}function validateDeviceAmtSettings(){QE("idx_dlgOkButton",passwordcheck(Q("dp10password").value))}function editDeviceAmtSettingsEx(e,t){if(2==e)meshserver.send({action:"changedevice",nodeid:t.node._id,intelamt:{user:"",pass:""}});else{var n=Q("dp10username").value;""==n&&(n="admin");var o=Q("dp10password").value;""==o&&(n=""),meshserver.send({action:"changedevice",nodeid:t.node._id,intelamt:{user:n,pass:o,tls:parseInt(Q("dp10tls").value)}}),t.node.intelamt.user=n,t.node.intelamt.tls=parseInt(Q("dp10tls").value),t.func&&setTimeout(function(){t.func(null,t.arg)},300)}}function p10showSendMqttMsgDialog(e){if(xxdialogMode)return!1;var t=addHtmlValue("Topic","<input id=dp2topic style=width:230px maxlength=64 onchange=p10validateSendMqttMsgDialog() onkeyup=p10validateSendMqttMsgDialog(event,1) />");return setDialogMode(2,"Send MQTT message",3,p10showSendMqttMsgDialogEx,t+=addHtmlValue("Message","<div style=width:230px;margin:0;padding:0><textarea id=dp2msg maxlength=4096 style=width:100%;height:150px;resize:none onchange=p10validateSendMqttMsgDialog() onkeyup=p10validateSendMqttMsgDialog(event,1)></textarea></div>"),e),p10validateSendMqttMsgDialog(),Q("dp2topic").focus(),!1}function p10validateSendMqttMsgDialog(){QE("idx_dlgOkButton",0<Q("dp2topic").value.length&&0<Q("dp2msg").value.length)}function p10showSendMqttMsgDialogEx(e,t){meshserver.send({action:"sendmqttmsg",nodeids:t,topic:Q("dp2topic").value,msg:Q("dp2msg").value}),uncheckAllDevices()}function p10showSendUninstallAgentDialog(e){if(xxdialogMode)return!1;var t="";return t=1<e.length?format("Are you sure you want to uninstall the selected {0} agents?",e.length):"Are you sure you want to uninstall selected agent?",t+="<br /><br />",1<e.length?t+="This will not remove the devices from the server, but the devices will not longer be able to connect to the server. All remote access to the devices will be lost. The devices must be connected for this command to work.":t+="This will not remove this device from the server, but the device will not longer be able to connect to the server. All remote access to the device will be lost. The device must be connect for this command to work.",setDialogMode(2,"Uninstall agent",3,p10showSendUninstallAgentDialogEx,t+="<br /><br /><label style=color:red><input id=p10check type=checkbox onchange=p10validateDeleteNodeDialog() />Confirm</label>",e),p10validateSendUninstallAgentDialog(),!1}function p10validateSendUninstallAgentDialog(){QE("idx_dlgOkButton",Q("p10check").checked)}function p10showSendUninstallAgentDialogEx(e,t){meshserver.send({action:"uninstallagent",nodeids:t}),uncheckAllDevices()}function p10showChangeGroupDialog(e){if(xxdialogMode)return!1;var t=null;if(1==e.length)try{t=meshes[getNodeFromId(e[0])]._id}catch(e){}var n="<select id=p10newGroup style=width:236px>",o=0;for(var i in meshes){var a=GetMeshRights(i);meshes[i]._id!=t&&4&a&&(o++,n+="<option value='"+meshes[i]._id+"'>"+meshes[i].name+"</option>")}if(n+="</select>",0<o){var s=1==e.length?"Select a new group for this device<br /><br />":"Select a new group for selected devices<br /><br />";setDialogMode(2,"Change Group",3,p10showChangeGroupDialogEx,s+=addHtmlValue("New Device Group",n),e)}else setDialogMode(2,"Change Group",1,null,"No other device group of same type exists.");return!1}function p10showChangeGroupDialogEx(e,t){meshserver.send({action:"changeDeviceMesh",nodeids:t,meshid:Q("p10newGroup").value}),uncheckAllDevices()}function p10showDeleteNodeDialog(e){return xxdialogMode||(setDialogMode(2,"Delete Node",3,p10showDeleteNodeDialogEx,format("Are you sure you want to delete node {0}?",EscapeHtml(currentNode.name))+"<br /><br /><label><input id=p10check type=checkbox onchange=p10validateDeleteNodeDialog() />Confirm</label>",e),p10validateDeleteNodeDialog()),!1}function p10validateDeleteNodeDialog(){QE("idx_dlgOkButton",Q("p10check").checked)}function p10showDeleteNodeDialogEx(e,t){meshserver.send({action:"removedevices",nodeids:[t]})}function p10clickOnce(e,t,n){return"RDP2"==t&&null==n&&(n=null!=currentNode.rdpport?currentNode.rdpport:3389),meshserver.send({action:"getcookie",nodeid:e,tcpport:n,tag:"clickonce",protocol:t}),!1}function p10rfb(e,t){null==t&&(t=null!=currentNode.rfbport?currentNode.rfbport:5900),meshserver.send({action:"getcookie",nodeid:e,tcpport:t,tag:"novnc"})}function p10mstsc(e,t){null==t&&(t=null!=currentNode.rdpport?currentNode.rdpport:3389),meshserver.send({action:"getcookie",nodeid:e,tcpport:t,tag:"mstsc"})}var d2map=null;function p10showNodeLocationDialog(){if(null!=xxdialogMode&&"@xxmap"==xxdialogTag)setDialogMode(0);else if(xxdialogMode)return!1;var e=[],t=["iploc","wifiloc","gpsloc","userloc"],n=null;for(var o in t)if(null!=currentNode[t[o]]){var i=currentNode[t[o]].split(","),a=parseFloat(i[0]),s=parseFloat(i[1]);if(a<90&&-90<a&&s<180&&-180<s){var r=new ol.Feature({geometry:new ol.geom.Point(ol.proj.fromLonLat([s,a]))});r.setStyle(markerStyle(currentNode,parseInt(o)+1)),e.push(r),null==n?n=[a,s,a,s,0]:(a<n[0]&&(n[0]=a),s<n[1]&&(n[1]=s),a>n[2]&&(n[2]=a),s>n[3]&&(n[3]=s))}}var l=new ol.source.Vector({features:e}),d=new ol.layer.Vector({source:l});setDialogMode(2,"Device Location",1,null,"<div id=d2map style=width:100%;height:300px></div>","@xxmap");var c=0,u=0,p=8;if(null!=n){u=(n[0]+n[2])/2,c=(n[1]+n[3])/2;var m=Math.max(Math.abs(n[0]-n[2]),Math.abs(n[1]-n[3])),g=360;for(p=-2;m<g;)p++,g/=2}return 1==e.length&&(p=8),d2map=new ol.Map({target:"d2map",interactions:ol.interaction.defaults({dragPan:!1,mouseWheelZoom:!1}),layers:[new ol.layer.Tile({source:new ol.source.OSM}),d],view:new ol.View({center:ol.proj.fromLonLat([c,u]),zoom:p})}),!1}function p10showNodeNetInfoDialog(){return xxdialogMode||(setDialogMode(2,"Network Interfaces",1,null,"<div id=d2netinfo>Loading...</div>","if"+currentNode._id),meshserver.send({action:"getnetworkinfo",nodeid:currentNode._id})),!1}function p10showMeshRouterDialog(){if(!xxdialogMode){var e="<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 />";e+=addHtmlValue("Win32 Executable",'<a style=cursor:pointer download href="meshagents?meshaction=winrouter'+(urlargs.key?"&key="+urlargs.key:"")+'" onclick="setDialogMode(0)">MeshCentralRouter.exe</a>');var t=serverinfo.name;-1!=t.indexOf(".")&&0==(2&features)||(t=window.location.hostname);domainUrl.substring(0,domainUrl.length-1);e+='<br /><div>Run MeshCentral Router and click "install" to make it launchable from the browser.</div>',e+='<br /><a style=cursor:pointer target="mcrouterframe" rel="noreferrer noopener" download href="'+("mcrouter://"+t+(443==serverinfo.port?"":":"+serverinfo.port)+domainUrl+"control.ashx?c="+authCookie+"&t="+serverinfo.tlshash+"&l={{{lang}}}")+'"><input type=button style=width:100%;cursor:pointer value="Launch MeshCentral Router" /></a>',setDialogMode(2,"MeshCentral Router",1,null,e+='<iframe style=display:none name="mcrouterframe"></iframe>',"fileDownload")}}function p10showMqttLoginDialog(e){meshserver.send({action:"getmqttlogin",nodeid:e})}function p10openxterm(e,t){haltEvent(e);var n="/xterm?nodeid="+encodeURIComponentEx(t)+"&auto=1",o=getNodeFromId(t);if(null!=o)return 0<=[1,2,3,4,21,22].indexOf(o.agent.id)?n+="&os=win":n+="&os=linux",window.open(n,"xterm:"+t),!1}function p10showMeshCmdDialog(e,t){if(!xxdialogMode){"<option value=3>Windows (32bit)</option>","<option value=4>Windows (64bit)</option>","<option value=5>Linux x86 (32bit)</option>","<option value=6>Linux x86 (64bit)</option>","<option value=16>MacOS (64bit)</option>","<option value=25>Linux ARM, Raspberry Pi (32bit)</option>","</select>";var n="";0==e&&(n+="<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 />"),1==e&&(n+='<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 />'),n+=addHtmlValue("Operating System","<select id=aginsSelect onclick=meshCmdOsClick() style=width:236px><option value=3>Windows (32bit)</option><option value=4>Windows (64bit)</option><option value=5>Linux x86 (32bit)</option><option value=6>Linux x86 (64bit)</option><option value=16>MacOS (64bit)</option><option value=25>Linux ARM, Raspberry Pi (32bit)</option></select>"),n+=addHtmlValue("MeshCmd",'<a id=meshcmddownloadid href="meshagents?meshcmd=3'+(urlargs.key?"&key="+urlargs.key:"")+'" download></a>'),0==e&&(n+=addHtmlValue("Action File",'<a href="meshagents?meshaction=generic'+(urlargs.key?"&key="+urlargs.key:"")+'" download>MeshAction (.txt)</a>')),1==e&&(n+=addHtmlValue("Action File",'<a href="meshagents?meshaction=route&nodeid='+t+(urlargs.key?"&key="+urlargs.key:"")+'" download>MeshAction (.txt)</a>')),setDialogMode(2,"Download MeshCmd",9,null,n+="</div>","fileDownload"),meshCmdOsClick()}}function meshCmdOsClick(){var e=Q("aginsSelect").value,t="";3==e&&(t="MeshCmd (Win32 executable)"),4==e&&(t="MeshCmd (Win64 executable)"),5==e&&(t="MeshCmd (Linux x86, 32bit)"),6==e&&(t="MeshCmd (Linux x86, 64bit)"),16==e&&(t="MeshCmd (MacOS, 64bit)"),25==e&&(t="MeshCmd (Linux ARM, 32bit)"),QH("meshcmddownloadid",t),Q("meshcmddownloadid").setAttribute("href","meshagents?meshcmd="+e+(urlargs.key?"&key="+urlargs.key:""))}function p10showiconselector(){if(!xxdialogMode&&0!=(4&GetNodeRights(currentNode))){'<div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i1 onclick=p10setIcon(1) onkeypress="if (event.key==\'Enter\') p10setIcon(1)"></div>','<div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i2 onclick=p10setIcon(2) onkeypress="if (event.key==\'Enter\') p10setIcon(2)"></div>','<div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i3 onclick=p10setIcon(3) onkeypress="if (event.key==\'Enter\') p10setIcon(3)"></div>','<div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i4 onclick=p10setIcon(4) onkeypress="if (event.key==\'Enter\') p10setIcon(4)"></div>',"<br />",'<div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i5 onclick=p10setIcon(5) onkeypress="if (event.key==\'Enter\') p10setIcon(5)"></div>','<div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i6 onclick=p10setIcon(6) onkeypress="if (event.key==\'Enter\') p10setIcon(6)"></div>','<div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i7 onclick=p10setIcon(7) onkeypress="if (event.key==\'Enter\') p10setIcon(7)"></div>','<div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i8 onclick=p10setIcon(8) onkeypress="if (event.key==\'Enter\') p10setIcon(8)"></div>',"<br /><br /></div>",setDialogMode(2,"Icon Selection",0,null,'<div style=text-align:center><br /><div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i1 onclick=p10setIcon(1) onkeypress="if (event.key==\'Enter\') p10setIcon(1)"></div><div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i2 onclick=p10setIcon(2) onkeypress="if (event.key==\'Enter\') p10setIcon(2)"></div><div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i3 onclick=p10setIcon(3) onkeypress="if (event.key==\'Enter\') p10setIcon(3)"></div><div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i4 onclick=p10setIcon(4) onkeypress="if (event.key==\'Enter\') p10setIcon(4)"></div><br /><div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i5 onclick=p10setIcon(5) onkeypress="if (event.key==\'Enter\') p10setIcon(5)"></div><div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i6 onclick=p10setIcon(6) onkeypress="if (event.key==\'Enter\') p10setIcon(6)"></div><div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i7 onclick=p10setIcon(7) onkeypress="if (event.key==\'Enter\') p10setIcon(7)"></div><div tabindex=0 style="display:inline-block;margin:0 10px 0 10px" class=i8 onclick=p10setIcon(8) onkeypress="if (event.key==\'Enter\') p10setIcon(8)"></div><br /><br /></div>'),QV("id_dialogclose",!0)}}function p10setIcon(e){setDialogMode(0),meshserver.send({action:"changedevice",nodeid:currentNode._id,icon:e})}var desktopNode,showEditNodeValueDialog_modes=["Device Name","Hostname","Description","Tags"],showEditNodeValueDialog_modes2=["name","host","desc","tags"],showEditNodeValueDialog_modes3=["","","","Tag1, Tag2, Tag3"];function showEditNodeValueDialog(e){if(!xxdialogMode){setDialogMode(2,"Edit Device",3,showEditNodeValueDialogEx,addHtmlValue(showEditNodeValueDialog_modes[e],'<input id=dp10devicevalue maxlength=64 placeholder="'+showEditNodeValueDialog_modes3[e]+'" onchange=p10editdevicevalueValidate('+e+",event) onkeyup=p10editdevicevalueValidate("+e+",event) />"),e);var t=currentNode[showEditNodeValueDialog_modes2[e]];null==t&&(t=""),Array.isArray(t)&&(t=t.join(", ")),Q("dp10devicevalue").value=t,p10editdevicevalueValidate(),Q("dp10devicevalue").focus()}}function showEditNodeValueDialogEx(e,t){var n={action:"changedevice",nodeid:currentNode._id};n[showEditNodeValueDialog_modes2[t]]=Q("dp10devicevalue").value,meshserver.send(n)}function p10editdevicevalueValidate(e,t){var n=1<e||0<Q("dp10devicevalue").value.length;QE("idx_dlgOkButton",n),null!=t&&1==n&&13==t.keyCode&&dialogclose(1)}function setupDesktop(){if(desktopNode!=currentNode&&null!=desktop&&(desktop.Stop(),desktop=desktopNode=null),desktopNode!=currentNode||null==desktop){var e=multiDesktop[currentNode._id];if(null!=e){QH("DeskParent","");var t=e.m.CanvasId;t.setAttribute("id","Desk"),t.setAttribute("onmousedown","dmousedown(event)"),t.setAttribute("onmouseup","dmouseup(event)"),t.setAttribute("onmousemove","dmousemove(event)"),t.removeAttribute("onclick"),Q("DeskParent").appendChild(t),(desktop=e).m.SendCompressionLevel&&desktop.m.SendCompressionLevel(1,desktopsettings.quality,desktopsettings.scaling,desktopsettings.framerate),desktop.onStateChanged=onDesktopStateChange,desktop.onMetadataChange=function(e){updateMetadata(desktop,"deskmetadata")},desktop&&desktop.m.mouseCursorActive&&desktop.m.mouseCursorActive(!0),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(e){return dmousewheel(e)}),Q("Desk").addEventListener("mousewheel",function(e){return dmousewheel(e)})}desktopNode=currentNode,updateDesktopButtons(),deskAdjust(),updateMetadata(desktop,"deskmetadata")}function updateDesktopButtons(){meshes[currentNode.meshid];var e=0;null!=desktop&&(e=desktop.State);var t=GetNodeRights(currentNode);QV("disconnectbutton1span",0!=e),QV("connectbutton1span",0==e&&(8&t||256&t)&&null!=currentNode.agent&&1&currentNode.agent.caps),QV("connectbutton1hspan",0==e&&8&t&&null!=currentNode.intelamt&&2==currentNode.intelamt.state&&null!=currentNode.intelamt.ver&&(null==currentNode.intelamt.sku||"number"==typeof currentNode.intelamt.sku&&0!=(8&currentNode.intelamt.sku))),QV("d7amtkvm",!(null==currentNode.intelamt||null==currentNode.intelamt.ver&&null!=currentNode.agent||0!=e&&2!=desktop.contype)),QV("d7meshkvm",webRtcDesktop||null!=currentNode.agent&&1&currentNode.agent.caps&&(0==e||1==desktop.contype));var n=4294967295==t||0!=(8&t)&&0==(256&t)&&0==(4096&t),o=0!=(1&currentNode.conn);QE("connectbutton1",o);var i=0!=(6&currentNode.conn);QE("connectbutton1h",i),QV("deskFocusBtn",null!=desktop&&2==desktop.contype&&0!=e&&desktopsettings.showfocus),QV("DeskClip",currentNode.agent&&11!=currentNode.agent.id&&16!=currentNode.agent.id&&(null==desktop||2!=desktop.contype)),QE("DeskClip",3==e),QE("DeskType",3==e),QV("DeskWD",n),QE("DeskWD",3==e),QV("deskkeys",n),QE("deskkeys",3==e),QV("DeskSaveImageButton",3==e&&null!=Q("Desk").toBlob),QV("DeskRecordButton",3==e&&null!=Q("Desk").toBlob&&null!=desktop.m.StartRecording),QV("DeskChatButton",0!=(16384&t)&&0==browserfullscreen&&n&&currentNode.agent&&o),QV("DeskNotifyButton",0!=(16384&t)&&0==browserfullscreen&&currentNode.agent&&currentNode.agent.id<5&&n&&currentNode.agent&&o),QV("DeskToolsButton",n&&currentNode.agent&&o),QV("DeskOpenWebButton",0==browserfullscreen&&n&&currentNode.agent&&o),QV("DeskBackgroundButton",3==e&&1==desktop.contype&&currentNode.agent&&11!=currentNode.agent.id&&16!=currentNode.agent.id&&o),QV("DeskControlSpan",n),QV("deskActionsBtn",0==browserfullscreen),QV("deskActionsSettings",0==browserfullscreen),Q("DeskControl").checked=!!(8&t)&&1==getstore("DeskControl",1),QS("DeskControlSpan").color=Q("DeskControl").checked?null:"red",0==o&&QV("DeskTools",!1)}var autoConnectDesktopTimer=null;function autoConnectDesktop(e){autoConnectDesktopTimer=null==autoConnectDesktopTimer?setInterval(function(){connectDesktop(null,1)},1e3):(clearInterval(autoConnectDesktopTimer),null)}var agentConsoleMessages=["","Waiting for user to grant access...","Denied","Failed to start remote terminal session, {0} ({1})","Timeout","Received invalid network data"];function formatAgentConsoleMessage(e,t,n){for(null==n&&(n=[]);n.length<3;)n.push("");return(t&&t<agentConsoleMessages.length?EscapeHtml(format(agentConsoleMessages[t],n[0],n[1],n[2])):EscapeHtml(e)).split("\n").join("<br />")+"<br /><br />"}function connectDesktop(e,t,n,o){if(!xxdialogMode)if(null!=e&&0!=e.shiftKey&&3==t&&(t=1),QV("p11DeskSessionSelector",!1),p11clearConsoleMsg(),null==desktop)if(desktopNode=currentNode,2==t){if(null==desktopNode.intelamt.user||""==desktopNode.intelamt.user)return void editDeviceAmtSettings(desktopNode._id,connectDesktop,2);(desktop=CreateAmtRedirect(CreateAmtRemoteDesktop("Desk"),authCookie)).debugmode=debugmode,desktop.onStateChanged=onDesktopStateChange,desktop.m.bpp=1==desktopsettings.encoding||3==desktopsettings.encoding?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(e){if(0!=e.length){var t=null;try{t=JSON.parse(e)}catch(e){}if(null!=t&&null!=t.action)if("restart"==t.action)webRtcDesktopReset(),desktop.m.sendKvmData(JSON.stringify({action:"present",ver:1}));else if("present"==t.action&&null==webRtcDesktop){webRtcDesktop={platform:t.platform};"undefined"!=typeof RTCPeerConnection?webRtcDesktop.webrtc=new RTCPeerConnection(null):"undefined"!=typeof webkitRTCPeerConnection&&(webRtcDesktop.webrtc=new webkitRTCPeerConnection(null)),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(!0),webRtcDesktop.webRtcActive=!0,webRtcDesktop.softdesktop=CreateKvmDataChannel(webRtcDesktop.webchannel,CreateAgentRemoteDesktop("Desk",Q("id_mainarea")),desktop.m),webRtcDesktop.softdesktop.m.setRotation(desktop.m.rotation),webRtcDesktop.softdesktop.m.onScreenSizeChange=deskAdjust,desktopsettings.quality&&(webRtcDesktop.softdesktop.m.CompressionLevel=desktopsettings.quality),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(e){null==e.candidate?desktop.m.sendKvmData(JSON.stringify({action:"offer",ver:1,sdp:webRtcDesktop.webrtcoffer.sdp})):webRtcDesktop.webrtcoffer.sdp+="a="+e.candidate.candidate+"\r\n"},webRtcDesktop.webrtc.oniceconnectionstatechange=function(){null==webRtcDesktop||null==webRtcDesktop.webrtc||"disconnected"!=webRtcDesktop.webrtc.iceConnectionState&&"failed"!=webRtcDesktop.webrtc.iceConnectionState||webRtcDesktopReset()},webRtcDesktop.webrtc.createOffer(function(e){webRtcDesktop.webrtcoffer=e,webRtcDesktop.webrtc.setLocalDescription(e,function(){},webRtcDesktopReset)},webRtcDesktopReset,{mandatory:{OfferToReceiveAudio:!1,OfferToReceiveVideo:!1}})}else"answer"==t.action&&null!=webRtcDesktop&&webRtcDesktop.webrtc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t.sdp}),function(){},webRtcDesktopReset)}else desktop.m._sentPresence||(desktop.m._sentPresence=!0,desktop.m.sendKvmData(JSON.stringify({action:"present",ver:1})))},desktop.Start(desktopNode._id,16994,"*","*",0),desktop.contype=2}else null==t||1==t||3==t&&4<currentNode.agent.id?((desktop=CreateAgentRedirect(meshserver,CreateAgentRemoteDesktop("Desk"),serverPublicNamePort,authCookie,authRelayCookie,domainUrl)).m.mouseCursorActive(11==xxcurrentView),desktop.debugmode=debugmode,desktop.m.debugmode=debugmode,desktop.attemptWebRTC=attemptWebRTC,desktop.options={},null!=n&&(desktop.options.tsid=n),null!=o&&(desktop.options.consent=o),desktop.onStateChanged=onDesktopStateChange,desktop.onConsoleMessageChange=function(){desktop.consoleMessage?(Q("p11DeskConsoleMsg").innerHTML+=formatAgentConsoleMessage(desktop.consoleMessage,desktop.consoleMessageId,desktop.consoleMessageArgs),QV("p11DeskConsoleMsg",!0),null!=p11DeskConsoleMsgTimer&&clearTimeout(p11DeskConsoleMsgTimer),desktop.consoleMessageTimeout&&(p11DeskConsoleMsgTimer=setTimeout(p11clearConsoleMsg,1e3*desktop.consoleMessageTimeout))):p11clearConsoleMsg()},desktop.onMetadataChange=function(e){updateMetadata(desktop,"deskmetadata")},desktop.m.CompressionLevel=desktopsettings.quality,desktop.m.ScalingLevel=desktopsettings.scaling,desktopsettings.framerate&&(desktop.m.FrameRateTimer=desktopsettings.framerate),desktop.m.onDisplayinfo=deskDisplayInfo,desktop.m.onScreenSizeChange=deskAdjust,desktop.Start(desktopNode._id),desktop.latency.callback=function(e){console.log("latency",e),updateSessionTime()},desktop.contype=1):3==t&&meshserver.send({action:"msg",type:"userSessions",nodeid:currentNode._id,tag:o});else desktop.Stop(),webRtcDesktopReset(),desktopNode=desktop=null,null!=pluginHandler&&pluginHandler.callHook("onDesktopDisconnect")}function updateMetadata(e,t){var n="",o=0;if(e&&3==e.State){if(e.metadata&&e.metadata.users)for(var i in e.metadata.users)o+=e.metadata.users[i];1<o&&(n="<span onclick=showSessionMetadata(1) style=cursor:pointer>"+format(", {0} watching",o)+"</span>")}QH("deskmetadata",n),e==desktop&&"sessionMetadata1"==xxdialogTag&&showSessionMetadata(1)}function showSessionMetadata(e){if(!xxdialogMode||xxdialogTag=="sessionMetadata"+e){xxdialogMode&&setDialogMode(0);var t=null;if(1==e&&(t=desktop),t&&t.metadata){var n="";if(t.metadata.startTime&&(n+=addHtmlValue4("Start Time",printDateTime(new Date(t.metadata.startTime)))),t.metadata.users)for(var o in t.metadata.users){var i=1==t.metadata.users[o]?"1 connection":format("{0} connections",t.metadata.users[o]),a=o.split("/")[2];null!=users&&null!=users[o]&&(a=users[o].name),n+=addHtmlValue4(format('User "{0}"',a),i)}setDialogMode(2,"Session Information",1,null,n,"sessionMetadata"+e)}}}function p11clearConsoleMsg(){QH("p11DeskConsoleMsg",""),QV("p11DeskConsoleMsg",!1),p11DeskConsoleMsgTimer&&(clearTimeout(p11DeskConsoleMsgTimer),p11DeskConsoleMsgTimer=null)}function p12clearConsoleMsg(){QH("p12TermConsoleMsg",""),QV("p12TermConsoleMsg",!1),p12TermConsoleMsgTimer&&(clearTimeout(p12TermConsoleMsgTimer),p12TermConsoleMsgTimer=null)}function p13clearConsoleMsg(){QH("p13FilesConsoleMsg",""),QV("p13FilesConsoleMsg",!1),p13FilesConsoleMsgTimer&&(clearTimeout(p13FilesConsoleMsgTimer),p13FilesConsoleMsgTimer=null)}var webRtcDesktop=null;function webRtcDesktopReset(){if(null!=webRtcDesktop){if(null!=webRtcDesktop.softdesktop&&(webRtcDesktop.softdesktop.Stop(),webRtcDesktop.softdesktop=null),null!=webRtcDesktop.webchannel){try{webRtcDesktop.webchannel.close()}catch(e){}webRtcDesktop.webchannel=null}if(null!=webRtcDesktop.webrtc){try{webRtcDesktop.webrtc.close()}catch(e){}webRtcDesktop.webrtc=null}webRtcDesktop=null,desktop&&desktop.m&&(desktop.m.hold(!1),Q("deskstatus").textContent=StatusStrs[desktop.State])}}function onDesktopStateChange(e,t){var n=t;3==n&&2==e.contype&&n++;var o=StatusStrs[n];switch(null!=desktop&&1==desktop.webRtcActive&&(o+=", WebRTC"),QH("deskstatus",o),t){case 0:null!=desktop.m.recordedData&&deskRecordSession(),desktop.Stop(),desktopNode=desktop=null,QV("DeskFocus",!1),QV("termdisplays",!1),QV("deskRecordIcon",!1),deskFocusBtn.value="All Focus",1==fullscreen&&deskToggleFull(),webRtcDesktopReset(),deskPreferedStickyDisplay=0;break;case 2:break;case 3:desktop&&1==desktop.serverIsRecording&&QV("deskRecordIcon",!0),desktop.startTime=new Date,null==updateSessionTimer&&(updateSessionTimer=setInterval(updateSessionTime,1e3))}updateDesktopButtons(),deskAdjust(),setTimeout(deskAdjust,50),updateMetadata(desktop,"deskmetadata")}function updateSessionTime(){var e="",t=0;desktop&&desktop.startTime?(desktop.latency&&0<=desktop.latency.current&&(e=format("{0} ms, ",desktop.latency.current)),t=Math.floor((new Date-desktop.startTime)/1e3),QH("DeskTimer",e+zeroPad(Math.floor(t/3600),2)+":"+zeroPad(Math.floor(t/60)%60,2)+":"+zeroPad(t%60,2))):QH("DeskTimer",""),t=0,terminal&&terminal.startTime?(terminal.latency&&0<=terminal.latency.current&&(e=format("{0} ms, ",terminal.latency.current)),t=Math.floor((new Date-terminal.startTime)/1e3),QH("TermTimer",e+zeroPad(Math.floor(t/3600),2)+":"+zeroPad(Math.floor(t/60)%60,2)+":"+zeroPad(t%60,2))):QH("TermTimer",""),null==desktop&&null==terminal&&(clearInterval(updateSessionTimer),updateSessionTimer=null)}function showDesktopSettings(){xxdialogMode||(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(),desktop&&(1==desktop.contype&&0!=desktop.State&&desktop.m.SendCompressionLevel(1,desktopsettings.quality,desktopsettings.scaling,desktopsettings.framerate),2==desktop.contype&&(0==desktopsettings.showfocus&&(desktop.m.focusmode=0,deskFocusBtn.value="All Focus"),0!=desktop.State&&(desktop.Stop(),setTimeout(function(){connectDesktop(null,2)},50))))}function applyDesktopSettings(){var e="",t=512&features?[90,80,70,60,50,40,30,20,10,5,1]:[60,50,40,30,20,10,5,1];for(var n in t)e+="<option value="+t[n]+">"+t[n]+"%</option>";QH("d7bitmapquality",e),d7desktopmode.value=desktopsettings.encoding,d7showfocus.checked=desktopsettings.showfocus,d7showcursor.checked=desktopsettings.showmouse,d7bitmapquality.value=40,0<=t.indexOf(parseInt(desktopsettings.quality))&&(d7bitmapquality.value=desktopsettings.quality),d7bitmapscaling.value=desktopsettings.scaling,desktopsettings.framerate?d7framelimiter.value=desktopsettings.framerate:d7framelimiter.value=100,desktopsettings.localkeymap&&(d7localKeyMap.checked=desktopsettings.localkeymap),QV("deskFocusBtn",null!=desktop&&2==desktop.contype&&0!=desktop.state&&desktopsettings.showfocus)}function enterBrowserFullscreen(e){e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}function exitBrowserFullscreen(){document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}function isBrowserFullscreen(){return!!(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)}var fullscreen=!1,browserfullscreen=!1;function deskToggleFull(e){var t=!(0===args.xterm||null!=terminal&&null==xterm);if(fullscreen=!fullscreen)QC("body").add("fulldesk"),QS("deskarea3x").height="100%",QS("deskarea3x")["max-height"]="100%",t?(QS("termTable").position="absolute",QS("termTable").top=QS("termTable").bottom=QS("termTable").left=QS("termTable").right="0"):(QS("termTable").height="100%",QS("termTable")["max-height"]="100%"),1==e.shiftKey&&(enterBrowserFullscreen(Q("container")),browserfullscreen=!0);else{QC("body").remove("fulldesk");var n=args.hide;0==footerBar&&(n|=4);var o=(1&n?0:66)+(2&n?0:24)+(4&n?0:45)+(8&n?0:60);QS("deskarea3x").height="calc(100vh - "+(75+o)+"px)",QS("deskarea3x")["max-height"]="calc(100vh - "+(75+o)+"px)",t?(QS("termTable").position=null,QS("termTable").top=QS("termTable").bottom=QS("termTable").left=QS("termTable").right=null):(QS("termTable").height="calc(100vh - "+(75+o)+"px)",QS("termTable")["max-height"]="calc(100vh - "+(75+o)+"px)"),1==browserfullscreen&&(exitBrowserFullscreen(),browserfullscreen=!1)}deskAdjust(),updateDesktopButtons(),adjustPanels(),null!=xterm&&12==xxcurrentView&&(xtermfit.fit(),xterm.focus())}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 e=Q("DeskParent").clientHeight,t=Q("DeskParent").clientWidth,n=Q("Desk").height,o=Q("Desk").width;if(2==deskAspectRatio)QS("Desk")["margin-top"]=null,QS("Desk").height="100%",QS("Desk").width="100%",QS("DeskParent").overflow="hidden";else if(1==deskAspectRatio)QS("Desk")["margin-top"]="0px",QS("Desk").height=n+"px",QS("Desk").width=o+"px",QS("DeskParent").overflow="scroll";else{if(n/o<e/t){var i=n*t/o+"px";QS("Desk").height=i,QS("Desk").width="100%"}else{var a=o*e/n+"px";QS("Desk").height=webPageFullScreen||fullscreen?null:"100%",QS("Desk").width=a}QS("Desk")["margin-top"]=null,QS("DeskParent").overflow="hidden"}}function mdeskAdjust(e,t,n,o){if(e&&t&&n&&o)if("Desk"!=o.id){var i=[{x:180,y:101},{x:302,y:169},{x:454,y:255}][Q("sizeselect").selectedIndex],a=i.x+2,s=Q("xdevices").clientWidth-30,r=Math.floor(s/a);r=a+Math.floor((s-r*a)/r),i.y=i.y*(r/i.x),i.x=r;var l=i.y,d=i.x;0!=e.State&&(l=i.y,d=t/n*i.y),QS(o.id)["max-height"]=l+"px",QS(o.id)["max-width"]=d+"px",QS(o.id)["margin-top"]="0",QS(o.id)["margin-bottom"]="0"}else deskAdjust()}function deskSendKeys(){if(!xxdialogMode&&null!=desktop&&3==desktop.State){var e=Q("deskkeys").value;0==e?2==desktop.contype?desktop.m.sendkey([[65511,1],[65364,1],[65364,0],[65511,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,40],[desktop.m.KeyAction.UP,40],[desktop.m.KeyAction.EXUP,91]]):1==e?2==desktop.contype?desktop.m.sendkey([[65511,1],[65362,1],[65362,0],[65511,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,38],[desktop.m.KeyAction.UP,38],[desktop.m.KeyAction.EXUP,91]]):2==e?2==desktop.contype?desktop.m.sendkey([[65511,1],[108,1],[108,0],[65511,0]]):desktop.sendCtrlMsg('{"action":"lock"}'):3==e?2==desktop.contype?desktop.m.sendkey([[65511,1],[109,1],[109,0],[65511,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,91]]):4==e?2==desktop.contype?desktop.m.sendkey([[65505,1],[65511,1],[109,1],[109,0],[65511,0],[65505,0]]):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]]):5==e?2==desktop.contype?desktop.m.sendkey([[65511,1],[65511,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.EXUP,91]]):6==e?2==desktop.contype?desktop.m.sendkey([[65511,1],[114,1],[114,0],[65511,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,82],[desktop.m.KeyAction.UP,82],[desktop.m.KeyAction.EXUP,91]]):7==e?2==desktop.contype?desktop.m.sendkey([[65513,1],[65473,1],[65473,0],[65513,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,18],[desktop.m.KeyAction.DOWN,115],[desktop.m.KeyAction.UP,115],[desktop.m.KeyAction.EXUP,18]]):8==e?2==desktop.contype?desktop.m.sendkey([[65507,1],[119,1],[119,0],[65507,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,17],[desktop.m.KeyAction.DOWN,87],[desktop.m.KeyAction.UP,87],[desktop.m.KeyAction.EXUP,17]]):9==e?2==desktop.contype?desktop.m.sendkey([[65513,1],[65289,1],[65289,0],[65513,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,18],[desktop.m.KeyAction.DOWN,9],[desktop.m.KeyAction.UP,9],[desktop.m.KeyAction.EXUP,18]]):10==e?desktop.m.sendcad():11==e?2==desktop.contype?desktop.m.sendkey([[65511,1],[65361,1],[65361,0],[65511,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,37],[desktop.m.KeyAction.UP,37],[desktop.m.KeyAction.EXUP,91]]):12==e&&(2==desktop.contype?desktop.m.sendkey([[65511,1],[65363,1],[65363,0],[65511,0]]):desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,39],[desktop.m.KeyAction.UP,39],[desktop.m.KeyAction.EXUP,91]]))}}function showDeskType(){if(!xxdialogMode&&null!=desktop&&3==desktop.State){Q("DeskType").blur();'<textarea id=d2typeText style="margin-top:5px;width:100%;height:184px;resize:none" maxlength=2000></textarea>',setDialogMode(2,"Remote Keyboard Entry",3,showDeskTypeEx,'<div>Enter text and click OK to remotely type it using a US english keyboard. Make sure to place the remote cursor at the correct position before proceeding.<div><textarea id=d2typeText style="margin-top:5px;width:100%;height:184px;resize:none" maxlength=2000></textarea>'),Q("d2typeText").focus()}}var AmtDeskTypeTimer=null,AmtDeskTypeContent=null,DeskTypeTranslate={39:222,42:106,43:107,44:188,45:189,46:190,47:191,59:186,61:187,91:219,92:220,93:221,96:192,191:111},DeskTypeShiftTranslate={33:49,34:222,35:51,36:52,37:53,38:55,40:57,41:48,58:186,60:188,62:190,63:191,64:50,94:54,95:189,106:56,107:187,123:219,124:220,125:221,126:192};function showDeskTypeEx(){var e=Q("d2typeText").value,t=Q("d2typeText").value.toUpperCase(),n=[],o=!1;if(2==desktop.contype){for(var i in e){var a=e.charCodeAt(i);n.push([a,1],[a,0])}AmtDeskTypeContent=n,AmtDeskTypeTimer=setInterval(function(){var e=AmtDeskTypeContent.shift();desktop&&desktop.m.sendkey(e[0],e[1]),null!=desktop&&0!=AmtDeskTypeContent.length||(clearInterval(AmtDeskTypeTimer),AmtDeskTypeContent=null)},10)}else{for(var i in e){a=e.charCodeAt(i);var s=t.charCodeAt(i);65<=a&&a<=90||97<=a&&a<=122?(a==s&&0==o&&(n.push([desktop.m.KeyAction.DOWN,16]),o=!0),a!=s&&1==o&&(n.push([desktop.m.KeyAction.UP,16]),o=!1)):48<=a&&a<=57?1==o&&(n.push([desktop.m.KeyAction.UP,16]),o=!1):DeskTypeTranslate[a]?(1==o&&(n.push([desktop.m.KeyAction.UP,16]),o=!1),s=DeskTypeTranslate[a]):DeskTypeShiftTranslate[a]&&(0==o&&(n.push([desktop.m.KeyAction.DOWN,16]),o=!0),s=DeskTypeShiftTranslate[a]),n.push([desktop.m.KeyAction.DOWN,s],[desktop.m.KeyAction.UP,s])}1==o&&(n.push([desktop.m.KeyAction.UP,16]),o=!1),desktop.m.SendKeyMsgKC(n)}}function showDeskClip(){if(!xxdialogMode&&null!=desktop&&3==desktop.State){Q("DeskClip").blur();'<input id=dlgClipGet type=button value="Get Clipboard" style=width:120px onclick=showDeskClipGet()>','<input id=dlgClipSet type=button value="Set Clipboard" style=width:120px onclick=showDeskClipSet()>','<div id=dlgClipStatus style="display:inline-block;margin-left:8px" ></div>','<textarea id=d2clipText style="width:100%;height:184px;resize:none" maxlength=65535></textarea>','<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,'<input id=dlgClipGet type=button value="Get Clipboard" style=width:120px onclick=showDeskClipGet()><input id=dlgClipSet type=button value="Set Clipboard" style=width:120px onclick=showDeskClipSet()><div id=dlgClipStatus style="display:inline-block;margin-left:8px" ></div><textarea id=d2clipText style="width:100%;height:184px;resize:none" maxlength=65535></textarea><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>',"clipboard"),Q("d2clipText").focus()}}function showDeskClipGet(){null!=desktop&&3==desktop.State&&meshserver.send({action:"msg",type:"getclip",nodeid:currentNode._id})}function showDeskClipSet(){null!=desktop&&3==desktop.State&&(meshserver.send({action:"msg",type:"setclip",nodeid:currentNode._id,data:Q("d2clipText").value}),QV("linuxClipWarn",currentNode&&currentNode.agent&&4<currentNode.agent.id&&21!=currentNode.agent.id&&22!=currentNode.agent.id))}function sendCAD(){xxdialogMode||null==desktop||3!=desktop.State||desktop.m.sendcad()}function toggleDeskTools(){xxdialogMode||("none"==QS("DeskTools").display?(QV("DeskTools",!0),Q("DeskTools").nodeid=currentNode._id,QH("DeskToolsProcesses",""),QH("DeskToolsServices",""),QV("deskToolsTopTabService",!1),changeDeskToolTab(0),refreshDeskTools(0),refreshDeskTools(1)):QV("DeskTools",!1))}var deskToolTabSelection=0;function changeDeskToolTab(e){QV("DeskToolsProcessTab",0==(deskToolTabSelection=e)),QV("DeskToolsServiceTab",1==e),QS("deskToolsTopTabProcess").bottom=0==e?"0px":"3px",QS("deskToolsTopTabService").bottom=1==e?"0px":"3px",QS("deskToolsTopTabProcess").color=0==e?"black":"gray",QS("deskToolsTopTabService").color=1==e?"black":"gray"}function refreshDeskTools(e){var t=null==e?deskToolTabSelection:e;QV("DeskToolsRefreshButton",!1),setTimeout(refreshDeskToolsEx,500),0==t&&meshserver.send({action:"msg",type:"ps",nodeid:currentNode._id}),1==t&&meshserver.send({action:"msg",type:"services",nodeid:currentNode._id})}function refreshDeskToolsEx(){QV("DeskToolsRefreshButton",!0)}var deskTools={sort:1,ssort:1,msg:null,smsg:null};function sortProcess(e){deskTools.sort=e,showDeskToolsProcesses(deskTools.msg)}function sortService(e){deskTools.ssort=e,showDeskToolsServices(deskTools.smsg)}function sortProcessPid(e,t){return e.p>t.p?1:e.p<t.p?-1:sortProcessName(e,t)}function sortProcessName(e,t){return e.d>t.d?1:e.d<t.d?-1:0}function showDeskToolsProcesses(e){if(null!=(deskTools.msg=e)){if(Q("DeskTools").nodeid==e.nodeid){var t=[],n=null;try{n=JSON.parse(e.value)}catch(e){}if(null!=n){for(var o in n)t.push({p:parseInt(o),c:n[o].cmd,d:n[o].cmd.toLowerCase(),u:n[o].user});0==deskTools.sort?t.sort(sortProcessPid):1==deskTools.sort&&t.sort(sortProcessName);var i="";for(var a in t)if(0!=t[a].p){var s=t[a].c;30<s.length&&(s='<span title="'+s+'">'+s.substring(0,30)+"...</span>"),i+="<div class=deskToolsBar><div style=width:50px;float:left;text-align:right;padding-right:5px>"+t[a].p+'</div><a href=# style=float:right;padding-right:5px;cursor:pointer title="Stop process" onclick=\'return stopProcess('+t[a].p+',"'+t[a].c+'")\'><img width=10 height=10 src="images/trash.png"></a><div style=float:right;padding-right:5px>'+(t[a].u?t[a].u:"")+"</div><div>"+s+"</div></div>"}QH("DeskToolsProcesses",i)}}}else QH("DeskToolsProcesses","")}function showDeskToolsServices(e){if(null!=(deskTools.smsg=e)){if(Q("DeskTools").nodeid==e.nodeid){QV("deskToolsTopTabService",!0);var t=[],n=null;try{n=JSON.parse(e.value)}catch(e){}if(null!=(deskTools.services=n)){for(var o in n)n[o].status?t.push({p:capitalizeFirstLetter(n[o].status.state.toLowerCase()),d:n[o].displayName,i:o}):n[o].serviceType&&t.push({p:n[o].serviceType,d:n[o].name,i:o});0==deskTools.ssort?t.sort(sortProcessPid):1==deskTools.ssort&&t.sort(sortProcessName);var i="";for(var o in t)if(0!=t[o].p){var a=t[o].d;30<a.length&&(a='<span title="'+a+'">'+a.substring(0,30)+"...</span>"),i+="<div onclick=showServiceDetailsDialog("+t[o].i+") class=deskToolsBar><div style=width:70px;float:left;padding-right:5px>"+t[o].p+"</div><div>"+a+"</div></div>"}QH("DeskToolsServices",i)}}}else QH("DeskToolsProcesses","")}function showServiceDetailsDialog(e){if(!xxdialogMode){var t=deskTools.services[e];if(null!=t){var n="";if(t.name&&(n+=addHtmlValue("Name",t.name)),t.displayName&&(n+=addHtmlValue("Display name",t.displayName)),t.status){t.status.state&&(n+=addHtmlValue("State",capitalizeFirstLetter(t.status.state.toLowerCase()))),t.status.pid&&(n+=addHtmlValue("PID",t.status.pid));var o=[];!0===t.status.isFileSystemDriver&&o.push("FileSystemDriver"),!0===t.status.isInteractive&&o.push("Interactive"),!0===t.status.isKernelDriver&&o.push("KernelDriver"),!0===t.status.isOwnProcess&&o.push("OwnProcess"),!0===t.status.isSharedProcess&&o.push("SharedProcess"),0<o.length&&(n+=addHtmlValue("Type",o.join(", ")))}setDialogMode(2,"Service Details",8,null,n+='<br/><div style=float:right;margin-bottom:12px><input type=button value="Close" onclick=showServiceDetailsDialogEx(0,'+e+')></div><div style=margin-bottom:12px><input type=button value="Start" onclick=showServiceDetailsDialogEx(1,'+e+')><input type=button value="Stop" onclick=showServiceDetailsDialogEx(2,'+e+')><input type=button value="Restart" onclick=showServiceDetailsDialogEx(3,'+e+")></div>",name)}}}function showServiceDetailsDialogEx(e,t){if(setDialogMode(0),0!=e){var n=deskTools.services[t];null!=n&&(1==e&&meshserver.send({action:"msg",type:"serviceStart",nodeid:currentNode._id,serviceName:n.name}),2==e&&meshserver.send({action:"msg",type:"serviceStop",nodeid:currentNode._id,serviceName:n.name}),3==e&&meshserver.send({action:"msg",type:"serviceRestart",nodeid:currentNode._id,serviceName:n.name}),setTimeout(function(){refreshDeskTools(1)},1e3))}}function toggleKvmControl(){putstore("DeskControl",Q("DeskControl").checked?1:0),QS("DeskControlSpan").color=Q("DeskControl").checked?null:"red"}function deskRecordSession(){if(null!=desktop)if(null==desktop.m.recordedData)Q("DeskRecordButtonImage").src="images/icon-film-red.png",desktop.m.StartRecording();else{Q("DeskRecordButtonImage").src="images/icon-film.png";var e=new Date,t="DesktopSesion-"+currentNode.name+"-"+e.getFullYear()+"-"+("0"+(e.getMonth()+1)).slice(-2)+"-"+("0"+e.getDate()).slice(-2)+"-"+("0"+e.getHours()).slice(-2)+"-"+("0"+e.getMinutes()).slice(-2);saveAs(data2blob(desktop.m.StopRecording().join("")),t+".mcrec")}}function deskSaveImage(){if(!xxdialogMode&&null!=desktop&&3==desktop.State){var e=new Date,t="Desktop-"+currentNode.name+"-"+e.getFullYear()+"-"+("0"+(e.getMonth()+1)).slice(-2)+"-"+("0"+e.getDate()).slice(-2)+"-"+("0"+e.getHours()).slice(-2)+"-"+("0"+e.getMinutes()).slice(-2);Q("Desk").toBlob(function(e){saveAs(e,t+".png")})}}function deskDisplayInfo(e,t,n){var o=0,i="";for(var a in t)o++,i+="<option"+(n==a?" selected":"")+" value="+a+">"+t[a]+"</option>",deskPreferedStickyDisplay==a&&n!=deskPreferedStickyDisplay&&desktop.m.SetDisplay(a),deskPreferedStickyDisplay=-1;QH("termdisplays",i),QV("termdisplays",1<o)}function deskGetDisplayNumbers(e){desktop.m.GetDisplayNumbers()}var deskPreferedStickyDisplay=-1;function deskSetDisplay(e){desktop.m.SetDisplay(deskPreferedStickyDisplay=parseInt(Q("termdisplays").value)),Q("termdisplays").blur()}var terminalNode,dblClickDetectArgs={t:0,x:0,y:0};function dblClickDetect(e){if(1==e.buttons){var t=Date.now();t-dblClickDetectArgs.t<250&&Math.abs(e.clientX-dblClickDetectArgs.x)<2&&Math.abs(e.clientY-dblClickDetectArgs.y)<2&&!xxdialogMode&&null!=desktop&&Q("DeskControl").checked&&(null!=webRtcDesktop&&null!=webRtcDesktop.softdesktop?(webRtcDesktop.softdesktop.m.mousedblclick(e),desktop.m.sendKeepAlive()):desktop.m.mousedblclick(e)),dblClickDetectArgs.t=t,dblClickDetectArgs.x=e.clientX,dblClickDetectArgs.y=e.clientY}}function dmousedown(e){setSessionActivity(),e.addx=Q("DeskParent").scrollLeft,e.addy=Q("DeskParent").scrollTop,!xxdialogMode&&null!=desktop&&Q("DeskControl").checked&&(null!=webRtcDesktop&&null!=webRtcDesktop.softdesktop?(webRtcDesktop.softdesktop.m.mousedown(e),desktop.m.sendKeepAlive()):desktop.m.mousedown(e)),dblClickDetect(e)}function dmouseup(e){setSessionActivity(),e.addx=Q("DeskParent").scrollLeft,e.addy=Q("DeskParent").scrollTop,!xxdialogMode&&null!=desktop&&Q("DeskControl").checked&&(null!=webRtcDesktop&&null!=webRtcDesktop.softdesktop?(webRtcDesktop.softdesktop.m.mouseup(e),desktop.m.sendKeepAlive()):desktop.m.mouseup(e))}function dmousemove(e){setSessionActivity(),e.addx=Q("DeskParent").scrollLeft,e.addy=Q("DeskParent").scrollTop,!xxdialogMode&&null!=desktop&&Q("DeskControl").checked&&(null!=webRtcDesktop&&null!=webRtcDesktop.softdesktop?(webRtcDesktop.softdesktop.m.mousemove(e),desktop.m.sendKeepAlive()):desktop.m.mousemove(e))}function dmousewheel(e){return setSessionActivity(),e.addx=Q("DeskParent").scrollLeft,e.addy=Q("DeskParent").scrollTop,!(xxdialogMode||null==desktop||!Q("DeskControl").checked)&&(null!=webRtcDesktop&&null!=webRtcDesktop.softdesktop?(webRtcDesktop.softdesktop.m.mousewheel(e),desktop.m.sendKeepAlive()):desktop.m.mousewheel&&desktop.m.mousewheel(e),haltEvent(e),!0)}function drotate(e){xxdialogMode||null==desktop||(desktop.m.setRotation(desktop.m.rotation+e),deskAdjust(),deskAdjust())}function stopProcess(e,t){return setDialogMode(2,"Process Control",3,stopProcessEx,format('Stop process #{0} "{1}"?',e,t),e),!1}function stopProcessEx(e,t){meshserver.send({action:"msg",type:"pskill",nodeid:currentNode._id,value:t}),setTimeout(refreshDeskTools,300)}function setupTerminal(){terminalNode!=currentNode&&null!=terminal&&(terminal.Stop(),terminal=null),terminalNode=currentNode,updateTerminalButtons()}function updateTerminalButtons(){meshes[terminalNode.meshid];var e=null!=terminal&&0!=terminal.state;QV("disconnectbutton2span",1==e),QV("connectbutton2span",0==e&&null!=currentNode.agent&&2&currentNode.agent.caps),QV("connectbutton2hspan",0==e&&null!=terminalNode.intelamt&&2==terminalNode.intelamt.state&&null!=terminalNode.intelamt.ver),QV("terminalSizeDropDown",0==e&&null!=terminalNode.intelamt&&2==terminalNode.intelamt.state&&null!=terminalNode.intelamt.ver);var t=0!=(1&terminalNode.conn);QE("connectbutton2",t);var n=0!=(6&terminalNode.conn);QE("connectbutton2h",n),QE("ctrlcbutton",e),QE("ctrlxbutton",e),QE("escbutton",e),QE("bsbutton",e),QE("pastebutton",e),QE("specialkeylist",e),QE("specialkeylistinput",e),QV("terminalSettingsButtons",terminal&&2==terminal.contype),terminal&&(Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation],Q("id_tfxkeysbutton").value=fxEmulations[terminal.m.fxEmulation],Q("id_tcrbutton").value="\r\n"==terminal.m.lineFeed?"CR+LF":"LF");var o=!(0===args.xterm||null!=terminal&&null==xterm);QV("termarea3xdiv",o),QV("Term",!o),QV("bsbutton",!o),QV("pastebutton",!o),QV("devListToolbarViewIcons2",o),QE("termSizeList",null==terminal)}function onTerminalStateChange(e,t){var n=t;3==n&&2==e.contype&&n++;var o=StatusStrs[n];switch(1==terminal.webRtcActive&&(o+=", WebRTC"),QH("termstatus",o),t){case 0:QH("termtitle",""),QV("termRecordIcon",!1),null==xterm?(e.m.TermResetScreen(),e.m.TermDraw()):(xterm.dispose(),xterm=xtermfit=null),null!=terminal&&(terminal.Stop(),terminal=null);break;case 3:e&&1==e.serverIsRecording&&QV("termRecordIcon",!0),terminal.startTime=new Date,null==updateSessionTimer&&(updateSessionTimer=setInterval(updateSessionTime,1e3)),null!=xterm&&xterm.focus()}updateTerminalButtons()}var autoConnectTerminalTimer=null;function autoConnectTerminal(e){autoConnectTerminalTimer=null==autoConnectTerminalTimer?setInterval(connectTerminal,100):(clearInterval(autoConnectTerminalTimer),null)}function CreateRemoteTunnel(e,t){var n={protocol:1};return null!=t&&"number"==typeof t.protocol&&(n.protocol=t.protocol),n.onTunnelUpdate=e,n.xxStateChange=function(e){},n.ProcessBinaryData=function(e){n.onTunnelUpdate(e)},n.ProcessData=function(e){n.onTunnelUpdate(e)},n.terminalEmulation=1,n.fxEmulation=0,n.lineFeed="\r\n",n}function tunnelUpdate(e){"string"==typeof e?xterm.writeUtf8(e):xterm.writeUtf8(new Uint8Array(e))}function xTermSendResize(){(xtermResizeTimer=null)!=xterm&&null!=terminal&&null!=terminal.sendCtrlMsg&&terminal.sendCtrlMsg(JSON.stringify({ctrlChannel:"102938",type:"termsize",cols:xterm.cols,rows:xterm.rows}))}function connectTerminal(e,t,n){if(p12clearConsoleMsg(),terminal)terminal.Stop(),terminal=null,fullscreen&&deskToggleFull();else if(2==t){if(null==terminalNode.intelamt.user||""==terminalNode.intelamt.user)return void editDeviceAmtSettings(terminalNode._id,connectTerminal,2);var o={};1==Q("termSizeList").value?(o.cols=80,o.rows=25):2==Q("termSizeList").value&&(o.cols=100,o.rows=30),fullscreen&&deskToggleFull(),QV("termarea3xdiv",!1),QV("Term",!0),(terminal=CreateAmtRedirect(CreateAmtRemoteTerminal("Term",o),authCookie)).debugmode=debugmode,terminal.m.debugmode=debugmode,terminal.m.onTitleChange=function(e,t){QH("termtitle"," - "+EscapeHtml(t))},terminal.onStateChanged=onTerminalStateChange,terminal.Start(terminalNode._id,16994,"*","*",0),terminal.contype=2,Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation]}else{o={protocol:null!=n&&"number"==typeof n.protocol?n.protocol:1};n&&n.requireLogin&&(o.requireLogin=!0),-1==[1,2,3,4,21,22].indexOf(currentNode.agent.id)&&(1==Q("termSizeList").value?(o.cols=80,o.rows=25,o.xterm=!0):2==Q("termSizeList").value?(o.cols=100,o.rows=30,o.xterm=!0):3==Q("termSizeList").value&&(o.cols=Math.floor((Q("column_l").clientWidth-60)/10),o.rows=Math.floor((Q("column_l").clientHeight-120)/20),o.xterm=!0)),e&&1==e.shiftKey&&(4<currentNode.agent.id?1==o.protocol&&(o.protocol=7):1==o.protocol&&(o.protocol=6)),0!==args.xterm?(QV("termarea3xdiv",!0),QV("Term",!1),null!=xterm&&xterm.dispose(),xtermfit=new FitAddon.FitAddon,xterm=new Terminal,xtermfit&&xterm.loadAddon(xtermfit),xterm.open(Q("termarea3xdiv")),xterm.onData(function(e){null!=terminal&&terminal.sendText(e)}),xtermfit&&xtermfit.fit(),xterm.onTitleChange(function(e){QH("termtitle"," - "+EscapeHtml(e))}),xterm.onResize(function(e){xtermResizeTimer&&clearTimeout(xtermResizeTimer),xtermResizeTimer=setTimeout(xTermSendResize,200)}),(terminal=CreateAgentRedirect(meshserver,CreateRemoteTunnel(tunnelUpdate,n),serverPublicNamePort,authCookie,authRelayCookie,domainUrl)).debugmode=debugmode,terminal.m.debugmode=debugmode,terminal.options={cols:xterm.cols,rows:xterm.rows},n&&n.requireLogin&&(terminal.options.requireLogin=!0),terminal.Start(terminalNode._id),terminal.onStateChanged=onTerminalStateChange,terminal.contype=1,terminal.attemptWebRTC=!1,terminal.onConsoleMessageChange=function(e,t){terminal.consoleMessage?(Q("p12TermConsoleMsg").innerHTML+=formatAgentConsoleMessage(terminal.consoleMessage,terminal.consoleMessageId,terminal.consoleMessageArgs),QV("p12TermConsoleMsg",!0),null!=p12TermConsoleMsgTimer&&clearTimeout(p12TermConsoleMsgTimer),terminal.consoleMessageTimeout&&(p12TermConsoleMsgTimer=setTimeout(p12clearConsoleMsg,1e3*terminal.consoleMessageTimeout))):p12clearConsoleMsg()}):(QV("termarea3xdiv",!1),QV("Term",!0),(terminal=CreateAgentRedirect(meshserver,CreateAmtRemoteTerminal("Term",o),serverPublicNamePort,authCookie,authRelayCookie,domainUrl)).options=o,terminal.debugmode=debugmode,terminal.m.debugmode=debugmode,terminal.m.onTitleChange=function(e,t){QH("termtitle"," - "+EscapeHtml(t))},terminal.m.lineFeed=0<=[1,2,3,4,21,22].indexOf(currentNode.agent.id)?"\r\n":"\r",terminal.attemptWebRTC=!1,terminal.onStateChanged=onTerminalStateChange,terminal.onConsoleMessageChange=function(){terminal.consoleMessage?(Q("p12TermConsoleMsg").innerHTML+=formatAgentConsoleMessage(terminal.consoleMessage,terminal.consoleMessageId,terminal.consoleMessageArgs),QV("p12TermConsoleMsg",!0),null!=p12TermConsoleMsgTimer&&clearTimeout(p12TermConsoleMsgTimer),terminal.consoleMessageTimeout&&(p12TermConsoleMsgTimer=setTimeout(p12clearConsoleMsg,1e3*terminal.consoleMessageTimeout))):p12clearConsoleMsg()},terminal.Start(terminalNode._id),terminal.contype=1,terminal.m.terminalEmulation=0,terminal.m.fxEmulation=0,Q("id_ttypebutton").value=terminalEmulations[0])}Q("connectbutton2").blur()}var terminalEmulations=["UTF8 Terminal","Extended ASCII","Intel ASCII"];function termToggleType(){terminal&&!xxdialogMode&&(terminal.m.terminalEmulation=(terminal.m.terminalEmulation+1)%3,Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation],Q("id_ttypebutton").blur())}var filesNode,fxEmulations=["Intel (F10 = ESC+[OM)","Alternate (F10 = ESC+0)","VT100+ (F10 = ESC+[OY)"];function termToggleFx(){terminal&&!xxdialogMode&&(terminal.m.fxEmulation=(terminal.m.fxEmulation+1)%3,Q("id_tfxkeysbutton").value=fxEmulations[terminal.m.fxEmulation],Q("id_tfxkeysbutton").blur())}function termToggleCr(){terminal&&!xxdialogMode&&("\n"==terminal.m.lineFeed?terminal.m.lineFeed="\r\n":terminal.m.lineFeed="\n",Q("id_tcrbutton").value="\r\n"==terminal.m.lineFeed?"CR+LF":"LF")}function termSendKey(e,t){terminal&&!xxdialogMode&&(null!=xterm?(terminal.sendText?terminal.sendText(String.fromCharCode(e)):terminal.send(String.fromCharCode(e)),xterm.focus()):null!=terminal&&(terminal.m.TermSendKey(e),Q(t).blur()))}function showTermPasteDialog(){terminal&&!xxdialogMode&&(Q("pastebutton").blur(),setDialogMode(2,"Paste",3,showTermPasteDialogEx,'<textarea id=d2pasteText style="width:100%;height:184px;resize:none"></textarea>'),Q("d2pasteText").focus())}function showTermPasteDialogEx(){terminal&&terminal.m.TermSendKeys(Q("d2pasteText").value)}function sendSpecialKey(){null!=xterm?(terminal.sendText(String.fromCharCode(Q("specialkeylist").value)),xterm.focus()):null!=terminal&&(terminal.m.TermSendKey(Q("specialkeylist").value),Q("specialkeylist").blur(),Q("specialkeylistinput").blur())}function setupFiles(){var e=filesNode==currentNode,t=0!=(1&(filesNode=currentNode).conn);QE("p13Connect",t),0!=e&&0!=t||!files||(files.Stop(),files=null)}function onFilesStateChange(e,t){p13Connect.value=0==t?"Connect":"Disconnect";var n=StatusStrs[t];switch(1==files.webRtcActive&&(n+=", WebRTC"),Q("p13Status").textContent=n,t){case 0:QH("p13files",""),p13filetree=null,p13filetreelocation=[],QH("p13currentpath",""),QE("p13FolderUp",!1),QV("filesRecordIcon",!1),p13setActions(),null!=files&&(files.Stop(),files=null);break;case 3:p13targetpath="",files&&(files.sendText({action:"ls",reqid:1,path:""}),1==files.serverIsRecording&&QV("filesRecordIcon",!0))}}function CreateRemoteFiles(e){var t={protocol:5};return t.onFileUpdate=e,t.xxStateChange=function(e){},t.ProcessData=function(e){t.onFileUpdate(e)},t}var autoConnectFilesTimer=null;function autoConnectFiles(e){autoConnectFilesTimer=null==autoConnectFilesTimer?setInterval(connectFiles,100):(clearInterval(autoConnectFilesTimer),null)}function connectFiles(e){p13clearConsoleMsg(),files?(files.Stop(),files=null):((files=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotFiles),serverPublicNamePort,authCookie,authRelayCookie,domainUrl)).attemptWebRTC=attemptWebRTC,files.onStateChanged=onFilesStateChange,files.onConsoleMessageChange=function(){files.consoleMessage?(Q("p13FilesConsoleMsg").innerHTML+=formatAgentConsoleMessage(files.consoleMessage,files.consoleMessageId,files.consoleMessageArgs),QV("p13FilesConsoleMsg",!0),null!=p13FilesConsoleMsgTimer&&clearTimeout(p13FilesConsoleMsgTimer),files.consoleMessageTimeout&&(p13FilesConsoleMsgTimer=setTimeout(p13clearConsoleMsg,1e3*files.consoleMessageTimeout))):p13clearConsoleMsg()},files.Start(filesNode._id)),p13clipboard=p13clipboardFolder=null,p13clipboardCut=0,p13updateClipview()}var p13sortorder,p13filetree=null,p13targetpath=null,p13filetreelocation=[];function p13gotFiles(e){if(0<e.length&&123!=e.charCodeAt(0))p13gotDownloadBinaryData(e);else if("download"!=(e=JSON.parse(decode_utf8(e))).action)if(e.path=e.path.replace(/\//g,"\\"),null!=p13filetree&&e.path==p13filetree.path){var t=p13getCheckedNames();p13filetree=e,p13updateFiles(t)}else{for(var n=e.path.replace(/\//g,"\\"),o=p13targetpath.replace(/\//g,"\\");0<n.length&&"\\"==n[0];)n=n.substring(1);for(;0<o.length&&"\\"==o[0];)o=o.substring(1);(n==o||"\\"==e.path&&""==p13targetpath)&&(p13filetree=e,p13updateFiles())}else p13gotDownloadCommand(e)}function p13getCheckedNames(){for(var e=[],t=document.getElementsByName("fd"),n=0;n<t.length;n++)t[n].checked&&e.push(p13filetree.dir[t[n].value].n);return e}function p13updateFiles(e){var t="",n="",o='<a href=# style=cursor:pointer onclick="return p13folderup(0)">Root</a>',i=p13filetree.path.split("\\");for(var a in p13filetreelocation=[],i)""!=i[a]&&p13filetreelocation.push(i[a]);for(var a in p13filetreelocation)o+=' / <a href=# style=cursor:pointer onclick="return p13folderup('+(parseInt(a)+1)+')">'+p13filetreelocation[a]+"</a>";var s=p13filetreelocation.join("/"),r=p13sort_files(p13filetree.dir);for(var a in r){var l,d=r[a],c=d.n;l=70<(l=c).length?'<span title="'+EscapeHtml(c)+'">'+EscapeHtml(c.substring(0,70))+"...</span>":EscapeHtml(c),c=EscapeHtml(c);var u="";if(null!=d.d)u=printDateTime(new Date(d.d))+"&nbsp;";var p="";null!=d.s&&(p=getFileSizeStr(d.s));var m="";if(d.t<3){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=""></span><span><div class=fileIcon'+d.t+' onclick=p13folderset("'+encodeURIComponentEx(d.nx)+'")></div><a href=# style=cursor:pointer onclick=\'return p13folderset("'+encodeURIComponentEx(d.nx)+"\")'>"+l+"</a></span></div>"}else{var g=l;0<d.s&&(g="<a href=# style=cursor:pointer onclick=\"return p13downloadfile('"+encodeURIComponentEx(s+"/"+c)+"','"+encodeURIComponentEx(c)+"',"+d.s+')">'+l+"</a>"),m="<div id=fileEntry cmenu=filesContextMenu fileIndex="+a+" 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>"+u+"</span><span style=float:right>"+p+"</span><span><div class=fileIcon"+d.t+"></div>"+g+"</span></div>"}d.t<3?t+=m:n+=m}if(QH("p13files",t+n),QH("p13currentpath",o),QE("p13FolderUp",0!=p13filetreelocation.length),null!=e){var h=document.getElementsByName("fd");for(a=0;a<h.length;a++)0<=e.indexOf(p13filetree.dir[h[a].value].n)&&(h[a].checked=!0)}p13setActions()}function p13folderset(e){p13targetpath=joinPaths(p13filetree.path,p13filetree.dir[e].n).split("\\").join("/"),files.sendText({action:"ls",reqid:1,path:p13targetpath})}function p13folderup(e){if(null==e)p13filetreelocation.pop();else for(;p13filetreelocation.length>e;)p13filetreelocation.pop();return p13targetpath=p13filetreelocation.join("/"),files.sendText({action:"ls",reqid:1,path:p13targetpath}),!1}function p13sort_filename(e,t){return e.ln>t.ln?1*p13sortorder:e.ln<t.ln?-1*p13sortorder:0}function p13sort_timestamp(e,t){return e.d>t.d?1*p13sortorder:e.d<t.d?-1*p13sortorder:0}function p13sort_bysize(e,t){return e.s==t.s?p13sort_filename(e,t):(e.s-t.s)*p13sortorder}function p13sort_files(e){var t=[],n=Q("p13sortdropdown").value;for(var o in e)e[o].nx=o,null==e[o].s&&(e[o].s=0),null==e[o].n&&(e[o].n=o),e[o].ln=e[o].n.toLowerCase(),t.push(e[o]);return p13sortorder=1,3<n&&(p13sortorder=-1,n-=3),1==n?t.sort(p13sort_filename):2==n?t.sort(p13sort_bysize):3==n&&t.sort(p13sort_timestamp),t}function p13setActions(){if(null==p13filetree)QE("p13DeleteFileButton",!1),QE("p13NewFolderButton",!1),QE("p13UploadButton",!1),QE("p13RenameFileButton",!1),QE("p13ViewFileButton",!1),QE("p13SelectAllButton",!1),Q("p13SelectAllButton").value="Select All",QE("p13RefreshButton",!1),QE("p13CutButton",!1),QE("p13CopyButton",!1),QE("p13PasteButton",!1);else{var e=p13getFileSelCount(),t=p13getFileCount(),n=p13getFileSelCount(!1),o=0<currentNode.agent.id&&currentNode.agent.id<5;QE("p13DeleteFileButton",0<e&&(0<p13filetreelocation.length||0==o)),QE("p13NewFolderButton",0<p13filetreelocation.length||0==o),QE("p13UploadButton",0<p13filetreelocation.length||0==o),QE("p13RenameFileButton",1==e&&(0<p13filetreelocation.length||0==o)),QE("p13ViewFileButton",1==e&&1==n&&(0<p13filetreelocation.length||0==o)),QE("p13SelectAllButton",0<t),Q("p13SelectAllButton").value=0<e?"Select None":"Select All",QE("p13RefreshButton",!0),QE("p13CutButton",0<e&&e==n&&(0<p13filetreelocation.length||0==o)),QE("p13CopyButton",0<e&&e==n&&(0<p13filetreelocation.length||0==o)),QE("p13PasteButton",(0<p13filetreelocation.length||0==o)&&null!=p13clipboard&&0<p13clipboard.length)}}function p13getFileSelCount(e){for(var t=0,n=document.getElementsByName("fd"),o=0;o<n.length;o++)!n[o].checked||0==e&&"3"!=n[o].attributes.file.value||t++;return t}function p13getFileSelDirCount(){for(var e=0,t=document.getElementsByName("fd"),n=0;n<t.length;n++)t[n].checked&&"999"==t[n].attributes.file.value&&e++;return e}function p13getFileCount(){return document.getElementsByName("fd").length}function p13selectallfile(){for(var e=0==p13getFileSelCount(),t=document.getElementsByName("fd"),n=0;n<t.length;n++)t[n].checked=e;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 e=p13getFileSelCount(),t=0<p13getFileSelDirCount()?"<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,1<e?format("Delete {0} selected items?",e)+t:"Delete selected item?"+t)}function p13deletefileEx(){for(var e=[],t=document.getElementsByName("fd"),n=0;n<t.length;n++)t[n].checked&&e.push(p13filetree.dir[t[n].value].n);files.sendText({action:"rm",reqid:1,path:p13filetreelocation.join("/"),delfiles:e,rec:Q("p13recdeleteinput").checked}),p13folderup(999)}function p13renamefile(){for(var e,t=document.getElementsByName("fd"),n=0;n<t.length;n++)t[n].checked&&(e=p13filetree.dir[t[n].value].n);setDialogMode(2,"Rename",3,p13renamefileEx,'<input type=text id=p13renameinput maxlength=64 onkeyup=p13fileNameCheck(event) style=width:100% value="'+e+'" />',{action:"rename",path:p13filetreelocation.join("/"),oldname:e}),focusTextBox("p13renameinput"),p13fileNameCheck()}function p13renamefileEx(e,t){t.newname=Q("p13renameinput").value,files.sendText(t),p13folderup(999)}function p13fileNameCheck(e){var t=isFilenameValid(Q("p13renameinput").value);QE("idx_dlgOkButton",t),1==t&&null!=e&&13==e.keyCode&&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 updateUploadDialogOk(e){QE("idx_dlgOkButton",0<Q("p13uploadinput").files.length)}function p13uploadFileEx(){p13doUploadFiles(Q("p13uploadinput").files)}function p13viewfile(){for(var e=document.getElementsByName("fd"),t=0;t<e.length;t++)if(e[t].checked){p13filetree.dir[e[t].value].s<=204800?p13downloadfile(encodeURIComponentEx(p13filetreelocation.join("/")+"/"+p13filetree.dir[e[t].value].n),encodeURIComponentEx(p13filetree.dir[e[t].value].n),p13filetree.dir[e[t].value].s,"viewer"):messagebox("File Editor","Only files less than 200k can be edited.");break}}var p13clipboard=null,p13clipboardFolder=null,p13clipboardCut=0;function p13copyFile(e){var t=document.getElementsByName("fd");p13clipboard=[],p13clipboardCut=e,p13clipboardFolder=p13targetpath;for(var n=0;n<t.length;n++)t[n].checked&&"3"==t[n].attributes.file.value&&p13clipboard.push(p13filetree.dir[t[n].value].n);p13updateClipview()}function p13pasteFile(){var e="";null!=p13clipboard&&0<p13clipboard.length&&(e=0==p13clipboardCut?1<p13clipboard.length?format("Confirm copy of {0} entries's to this location?",p13clipboard.length):format("Confirm copy of 1 entrie to this location?"):1<p13clipboard.length?format("Confirm move of {0} entries's to this location?",p13clipboard.length):format("Confirm move of 1 entrie to this location?")),setDialogMode(2,"Paste",3,p13pasteFileEx,e)}function p13pasteFileEx(){files.sendText({action:0==p13clipboardCut?"copy":"move",reqid:1,scpath:p13clipboardFolder,dspath:p13targetpath,names:p13clipboard}),p13folderup(999),1==p13clipboardCut&&(p13clipboardFolder=p13clipboard=null,p13clipboardCut=0,p13updateClipview())}function p13updateClipview(){var e="";null!=p13clipboard&&0<p13clipboard.length&&(e=0==p13clipboardCut?1<p13clipboard.length?format('Holding {0} entries for copy, <a href=# onclick="return p13clearClip()" style=cursor:pointer>Clear</a>.',p13clipboard.length):format('Holding 1 entrie for copy, <a href=# onclick="return p13clearClip()" style=cursor:pointer>Clear</a>.'):1<p13clipboard.length?format('Holding {0} entries for move, <a href=# onclick="return p13clearClip()" style=cursor:pointer>Clear</a>.',p13clipboard.length):format('Holding 1 entrie for move, <a href=# onclick="return p13clearClip()" style=cursor:pointer>Clear</a>.')),QH("p13bottomstatus",e),p13setActions()}function p13clearClip(){return p13clipboardFolder=p13clipboard=null,p13clipboardCut=0,p13updateClipview(),!1}function p13fileDragDrop(e){if(haltEvent(e),QV("p13bigfail",!1),QV("p13bigok",!1),null!=e.dataTransfer&&0!=e.dataTransfer.files.length&&null!=p13filetree){var t=[];for(var n in e.dataTransfer.files)null!=e.dataTransfer.files[n].size&&0!=e.dataTransfer.files[n].size&&t.push(e.dataTransfer.files[n]);0!=t.length&&p13doUploadFiles(t)}}var downloadFile,p13dragtimer=null;function p13fileDragOver(e){haltEvent(e),null!=p13dragtimer&&(clearTimeout(p13dragtimer),p13dragtimer=null);var t=null!=p13filetree;QV("p13bigok",t),QV("p13bigfail",!t)}function p13fileDragLeave(e){haltEvent(e),"p13filetable"!=e.target.id?(QV("p13bigfail",!1),QV("p13bigok",!1)):p13dragtimer=setTimeout(function(){QV("p13bigfail",!1),QV("p13bigok",!1),p13dragtimer=null},10)}function p13downloadfile(e,t,n,o){xxdialogMode||downloadFile||!files||(downloadFile={path:decodeURIComponent(e),file:decodeURIComponent(t),size:n,tsize:0,data:"",state:0,id:Math.random(),tag:o},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="+n+" />"))}function p13downloadFileCancel(){setDialogMode(0),files.sendText({action:"download",sub:"cancel",id:downloadFile.id}),downloadFile=null}function p13gotDownloadCommand(e){null!=downloadFile&&e.id==downloadFile.id&&("start"==e.sub?(downloadFile.state=1,files.sendText({action:"download",sub:"startack",id:downloadFile.id})):"cancel"==e.sub&&(downloadFile=null,setDialogMode(0)))}function p13gotDownloadBinaryData(e){downloadFile&&0!=downloadFile.state&&(4<e.length&&(downloadFile.tsize+=e.length-4,downloadFile.data+=e.substring(4),Q("d2progressBar").value=downloadFile.tsize),0!=(1&ReadInt(e,0))?"viewer"==downloadFile.tag?(setDialogMode(4,EscapeHtml(downloadFile.file),3,p13editSaveBack,null,downloadFile.file),QS("dialog").width="auto",QS("dialog").bottom="80px",QS("dialog").top=QS("dialog").left=QS("dialog").right="100px",Q("d4editorarea").value=downloadFile.data,downloadFile=null):(saveAs(data2blob(downloadFile.data),downloadFile.file),downloadFile=null,setDialogMode(0)):files.sendText({action:"download",sub:"ack",id:downloadFile.id}))}var uploadFile,d4EditWrapVal=0,d4EditSizeVal=0;function d4ToggleWrap(e){e||(d4EditWrapVal=++d4EditWrapVal%2),Q("d4WrapButton").value=["Wrap: ON","Wrap: OFF"][d4EditWrapVal],QS("d4editorarea").overflow=0==d4EditWrapVal?"auto":"scroll",QS("d4editorarea")["white-space"]=0==d4EditWrapVal?null:"pre",putstore("editorWrap",d4EditWrapVal)}function d4ToggleSize(e){e||(d4EditSizeVal=++d4EditSizeVal%4),QS("d4editorarea")["font-size"]=["100%","125%","150%","200%"][d4EditSizeVal],Q("d4SizeButton").value=["Size: 100%","Size: 125%","Size: 150%","Size: 200%"][d4EditSizeVal],putstore("editorSize",d4EditSizeVal)}function p13editSaveBack(e,t){var n=(new TextEncoder).encode(Q("d4editorarea").value);p13uploadFileContinue(1,[{name:t,size:n.byteLength,type:"text/plain",xdata:n}])}function p13doUploadFiles(e){if(!xxdialogMode){var t=0<currentNode.agent.id&&currentNode.agent.id<5,n=[],o=0;for(var i in p13filetree.dir)t?n.push(p13filetree.dir[i].n.toLowerCase()):n.push(p13filetree.dir[i].n);for(i=0;i<e.length;i++)t?0<=n.indexOf(e[i].name.toLowerCase())&&o++:0<=n.indexOf(e[i].name)&&o++;0==o?p13uploadFileContinue(1,e):setDialogMode(2,"Upload File",3,p13uploadFileContinue,format(1==o?"Upload will overwrite 1 file. Continue?":"Upload will overwrite {0} files. Continue?",o),e)}}function p13uploadFileContinue(e,t){(uploadFile={}).xpath=p13filetreelocation.join("/"),uploadFile.xfiles=t,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(e,t){switch(t){case 0:setTimeout(function(){p13folderup(9999)},200);break;case 3:p13uploadNextFile()}}function p13uploadReconnect(){uploadFile.ws=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotUploadData),serverPublicNamePort,authCookie,authRelayCookie,domainUrl),uploadFile.ws.attemptWebRTC=!1,uploadFile.ws.ctrlMsgAllowed=!1,uploadFile.ws.onStateChanged=onFileUploadStateChange,uploadFile.ws.Start(filesNode._id)}function p13uploadNextFile(){if(uploadFile.xfilePtr++,uploadFile.xfiles.length>uploadFile.xfilePtr){uploadFile.xptr=0;var e=uploadFile.xfiles[uploadFile.xfilePtr];QH("p13dfileName",e.name),Q("d2progressBar").max=e.size,Q("d2progressBar").value=0,null==e.xdata?(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:e.name,size:uploadFile.xdata.byteLength}))},uploadFile.xreader.readAsArrayBuffer(e)):(uploadFile.xdata=e.xdata,uploadFile.ws.sendText(JSON.stringify({action:"upload",reqid:uploadFile.xfilePtr,path:uploadFile.xpath,name:e.name,size:uploadFile.xdata.byteLength})))}else p13uploadFileCancel()}function p13uploadFileCancel(e,t){null!=uploadFile&&(null!=uploadFile.ws&&(uploadFile.ws.Stop(),uploadFile.ws=null),uploadFile=null),setDialogMode(0)}function p13gotUploadData(e){var t=JSON.parse(e);if(null!=uploadFile&&parseInt(uploadFile.xfilePtr)==parseInt(t.reqid))if("uploadstart"==t.action){p13uploadNextPart(!1);for(var n=0;n<8;n++)p13uploadNextPart(!0)}else"uploadack"==t.action?p13uploadNextPart(!1):"uploaderror"==t.action&&p13uploadFileCancel()}function p13uploadNextPart(e){var t=uploadFile.xdata,n=uploadFile.xptr,o=uploadFile.xptr+4096;if(o>t.byteLength){if(1==e)return;o=t.byteLength}if(n==t.byteLength)null!=uploadFile.ws&&(uploadFile.ws.Stop(),uploadFile.ws=null),uploadFile.xfiles.length>uploadFile.xfilePtr+1?p13uploadReconnect():p13uploadFileCancel();else{var i=t.slice(n,o);uploadFile.ws.send(i),uploadFile.xptr=o,Q("d2progressBar").value=o}}var currentDeviceEvents=null;function deviceEventsUpdate(){var e="",t=null;for(var n in currentDeviceEvents){var o=currentDeviceEvents[n],i=new Date(o.time);if(o.msg){null==o.h&&(o.h=Math.random()),printDate(i)!=t&&(null!=t&&(e+="</table>"),e+="<table class=p3eventsTable cellpadding=0 cellspacing=0><tr><td colspan=4 class=DevSt>"+(t=printDate(i))+"</td></tr>");var a="si3";"user"==o.etype&&(a="m2"),"server"==o.etype&&(a="si3");var s=EscapeHtml(o.msg).split("(R)").join("&reg;");o.username&&(s=2&userinfo.siteadmin&&o.userid?"<a href=# onclick='gotoUser(\""+encodeURIComponentEx(o.userid)+"\");haltEvent(event);'>"+EscapeHtml(o.username)+"</a> &rarr; "+s:EscapeHtml(o.username)+" &rarr; "+s),"relay"!=o.etype&&"relaylog"!=o.action||(a="relayIcon16"),e+="<tr onclick=showEventDetails("+o.h+",1) onmouseover=eventMouseHover(this,1) onmouseout=eventMouseHover(this,0) style=cursor:pointer><td style=width:18px><div class="+a+"></div></td><td class=g1>&nbsp;</td><td class=style10>"+printTime(i)+" - "+s+"</td><td class=g2>&nbsp;</td></tr><tr style=height:2px></tr>"}}null!=t&&(e+="</table>"),""==e&&(e="<br><i>No Events Found</i><br><br>"),QH("p16events",e)}function refreshDeviceEvents(){meshserver.send({action:"events",nodeid:currentNode._id,limit:parseInt(p16limitdropdown.value)})}function showEventDetails(e,t){var n,o;for(var i in 1==t&&(n=currentDeviceEvents),2==t&&(n=events),3==t&&(n=currentUserEvents),n)if(n[i].h==e){o=n[i];break}if(o){if(xxdialogMode)return!1;var a="<div style=overflow-y:auto>";for(var i in o)"h"!=i&&"_id"!=i&&"ids"!=i&&"domain"!=i&&null!=o[i]&&"object"!=typeof o[i]&&(a+=addHtmlValue3(EscapeHtml(i),EscapeHtml(o[i])));setDialogMode(2,"Event Details",9,null,a+="</div>")}}var consoleNode,DeviceDetailsHardware=null,DeviceDetailsNetwork=null,DeviceDetailsNodeId=null;function updateDeviceDetails(e,t,n){if(null!=currentNode&&(null==e&&(e=currentNode),currentNode._id==e._id)){DeviceDetailsNodeId!=e._id&&(DeviceDetailsNetwork=DeviceDetailsHardware=null,DeviceDetailsNodeId=e._id),null!=t&&(DeviceDetailsHardware=t),null!=n&&(DeviceDetailsNetwork=n),null==(t=DeviceDetailsHardware)&&(t={}),null==(n=DeviceDetailsNetwork)&&(n={});var o=[],i={};if(t.windows&&t.windows.osinfo||e.osdesc){var a="";if(e.rname&&(a+=addDetailItem("Name",EscapeHtml(e.rname),i)),e.osdesc&&(a+=addDetailItem("Version",EscapeHtml(e.osdesc),i)),t.windows&&t.windows.osinfo)(d=t.windows.osinfo).OSArchitecture&&(a+=addDetailItem("Architecture",EscapeHtml(d.OSArchitecture),i));""!=a&&o.push({name:"Operating System",html:a,img:"software64.png"})}if(e.agent){a="";if(null!=e.agent&&null!=e.agent.id&&null!=e.agent.ver){var s="";s=e.agent.id<=agentsStr.length?agentsStr[e.agent.id]:agentsStr[0],0!=e.agent.ver&&(s+=" v"+e.agent.ver),a+=addDetailItem("Mesh Agent",s)}if(0!=(1&e.conn)?a+=addDetailItem("Last agent connection","Connected now"):e.lastconnect&&(a+=addDetailItem("Last agent connection",printDateTime(new Date(e.lastconnect)))),e.lastaddr){var r=e.lastaddr.split(":");2<r.length?a+=addDetailItem("Last agent address",e.lastaddr):isPrivateIP(e.lastaddr)?a+=addDetailItem("Last agent address",r[0]):a+=addDetailItem("Last agent address",'<a href="https://iplocation.com/?ip='+r[0]+'" rel="noreferrer noopener" target="MeshIPLoopup">'+r[0]+"</a>")}""!=a&&o.push({name:"Mesh Agent",html:a,img:"meshagent64.png"})}if(null!=n.netif){a="";for(var l in a+="<table style=width:100%>",n.netif){var d=n.netif[l];a+="<tr><td><div class=style10 style=border-radius:5px;padding:8px>",a+="<div style=margin-bottom:3px><b>"+EscapeHtml(d.name+(d.dnssuffix?", "+d.dnssuffix:""))+"</b></div>",d.desc&&(a+=addDetailItem("Description",EscapeHtml(d.desc).split("(R)").join("&reg;"))),d.mac&&(d.gatewaymac?a+=addDetailItem("MAC Layer",format("MAC: {0}, Gateway: {1}",EscapeHtml(d.mac),EscapeHtml(d.gatewaymac))):a+=addDetailItem("MAC Layer",format("MAC: {0}",d.mac))),d.v4addr&&"0.0.0.0"!=d.v4addr&&(d.v4gateway&&d.v4mask?a+=addDetailItem("IPv4 Layer",format("IP: {0}, Mask: {1}, Gateway: {2}",EscapeHtml(d.v4addr),EscapeHtml(d.v4mask),EscapeHtml(d.v4gateway))):a+=addDetailItem("IPv4 Layer",format("IP: {0}",EscapeHtml(d.v4addr)))),a+="</div>"}""!=(a+="</table>")&&o.push({name:"Networking",html:a,img:"networking64.png"})}if(null!=e.intelamt){a="";a+=addDetailItem("Version",e.intelamt.ver?"v"+e.intelamt.ver:"<i>Unknown</i>",i);var c={0:nobreak("Not Activated (Pre)"),1:nobreak("Not Activated (In)"),2:nobreak("Activated")},u="";2==e.intelamt.state&&e.intelamt.flags&&(2&e.intelamt.flags?u=", Client Control Mode (CCM)":4&e.intelamt.flags&&(u=", Admin Control Mode (ACM)")),a+=addDetailItem("Provisioning State",(e.intelamt.state?c[e.intelamt.state]:"<i>Unknown</i>")+u,i),a+=addDetailItem("Security",1==e.intelamt.tls?"Secured using TLS":"TLS is not setup",i),""!=(a+=addDetailItem("Admin Credentials",null==e.intelamt.user||""==e.intelamt.user?"Not Known":"Known",i))&&o.push({name:"Intel&reg; Active Management Technology (Intel&reg; AMT)",html:a,img:"amt64.png"})}if(t.identifiers){a="";var p=t.identifiers;if(p.bios_vendor&&(a+=addDetailItem("Vendor",EscapeHtml(p.bios_vendor),i)),p.bios_version&&(a+=addDetailItem("Version",EscapeHtml(p.bios_version),i)),""!=a&&o.push({name:"BIOS",html:a,img:"chip64.png"}),a="",p.board_vendor&&(a+=addDetailItem("Vendor",EscapeHtml(p.board_vendor),i)),p.board_name&&(a+=addDetailItem("Name",EscapeHtml(p.board_name),i)),p.board_serial&&""!=p.board_serial&&(a+=addDetailItem("Serial",EscapeHtml(p.board_serial),i)),p.board_version&&(a+=addDetailItem("Version",EscapeHtml(p.board_version),i)),p.product_uuid&&(a+=addDetailItem("Identifier",EscapeHtml(p.product_uuid),i)),p.cpu_name&&(a+=addDetailItem("CPU",EscapeHtml(p.cpu_name).split("(TM)").join("&trade;").split("(R)").join("&reg;"),i)),p.gpu_name)for(var l in p.gpu_name)a+=addDetailItem("GPU",EscapeHtml(p.gpu_name[l]).split("(TM)").join("&trade;").split("(R)").join("&reg;"),i);""!=a&&o.push({name:"Motherboard",html:a,img:"motherboard64.png"})}if(t.windows&&t.windows.memory){a="";for(var l in t.windows.memory.sort(function(e,t){return e.BankLabel>t.BankLabel?1:e.BankLabel<t.BankLabel?-1:0}),a+="<table style=width:100%>",t.windows.memory){d=t.windows.memory[l];a+="<tr><td><div class=style10 style=border-radius:5px;padding:8px>",a+="<div style=margin-bottom:3px><b>"+EscapeHtml(d.BankLabel)+"</b></div>",d.Capacity&&(a+=addDetailItem("Capacity / Speed",format("{0} Mb, {1} Mhz",d.Capacity/1024/1024,d.Speed),i)),d.PartNumber&&(a+=addDetailItem("Part Number",EscapeHtml(d.Manufacturer&&"Undefined"!=d.Manufacturer?d.Manufacturer+", ":"")+EscapeHtml(d.PartNumber),i)),a+="</div>"}""!=(a+="</table>")&&o.push({name:"Memory",html:a,img:"ram64.png"})}if(t.identifiers&&p.storage_devices){a="";for(var l in p.storage_devices.sort(function(e,t){return e.Caption>t.Caption?1:e.Caption<t.Caption?-1:0}),a+="<table style=width:100%>",p.storage_devices){(d=p.storage_devices[l]).Size&&(a+="<tr><td><div class=style10 style=border-radius:5px;padding:8px>",a+="<div style=margin-bottom:3px><b>"+EscapeHtml(d.Caption)+"</b></div>",d.Model&&d.Model!=d.Caption&&(a+=addDetailItem("Model",EscapeHtml(d.Model),i)),d.Size&&("string"==typeof d.Size&&parseInt(d.Size)==d.Size&&(d.Size=parseInt(d.Size)),"number"==typeof d.Size&&(a+=addDetailItem("Capacity",format("{0} Mb",Math.floor(d.Size/1024/1024)),i)),"string"==typeof d.Size&&(a+=addDetailItem("Capacity",EscapeHtml(d.Size),i))),a+="</div>")}""!=(a+="</table>")&&o.push({name:"Storage",html:a,img:"storage64.png"})}a="";for(var l in o)null==o[l].img?a+="<div class=DevSt style=margin-bottom:3px;margin-left:16px><b>"+o[l].name+"</b></div><div style=margin-bottom:10px;margin-left:16px>"+o[l].html+"</div>":(a+="<table style=width:100%><tr>",a+="<td style=width:64px;vertical-align:top><img src=images/details/"+o[l].img+" border=0 width=64 /></td>",a+="<td><div class=DevSt style=margin-bottom:3px;margin-left:16px><b>"+o[l].name+"</b></div><div style=margin-bottom:10px;margin-left:16px>"+o[l].html+"</div></td>",a+="</tr></table>");""==a?QH("p17info","No information for this device."):QH("p17info",a)}}function agentConsoleHandleKeys(e){if(e.ctrlKey||e.altKey)return!0;var t=0,n=Q("p15consoleText");if(e.key)if(13==e.keyCode&&0==consoleFocus)p15consoleSend(e),t=1;else if(8==e.keyCode&&0==consoleFocus){var o=n.value;n.value=o.substring(0,o.length-1),t=1}else if(27==e.keyCode)n.value="",t=1;else if(38==e.keyCode||40==e.keyCode){var i=consoleHistory.indexOf(n.value);38==e.keyCode&&consoleHistory.length-1>i?n.value=consoleHistory[i+1]:40==e.keyCode&&0<i?n.value=consoleHistory[i-1]:40==e.keyCode&&0==i&&(n.value=""),t=1}else 1===e.key.length&&(insertTextAtCursor(n,e.key),t=1);else 0!=e.charCode&&0==consoleFocus&&(n.value=n.value+String.fromCharCode(e.charCode),t=1);return 0<t?haltEvent(e):void 0}function insertTextAtCursor(e,t){if(document.selection)e.focus(),sel=document.selection.createRange(),sel.text=t;else if(e.selectionStart||"0"==e.selectionStart){var n=e.selectionStart,o=e.selectionEnd;e.value=e.value.substring(0,n)+t+e.value.substring(o,e.value.length),e.setSelectionRange(o+1,o+1)}else e.value+=myValue}var consoleServerText="";function setupConsole(){if(115==xxcurrentView){var e="server"==consoleNode;consoleNode="server",QH("p15deviceName","My Server Console"),QE("p15consoleText",!0),QH("p15statetext",""),QH("p15coreName",""),QV("p15outputselecttd",!1),0==e&&(QH("p15agentConsoleText",consoleServerText),Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight)}else{e=consoleNode==currentNode,meshes[(consoleNode=currentNode).meshid];if(0!=(16&GetNodeRights(currentNode))){null==consoleNode.consoleText&&(consoleNode.consoleText=""),0==e&&(QH("p15agentConsoleText",consoleNode.consoleText),Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight);var t=0!=(1&consoleNode.conn)||0!=(16&consoleNode.conn),n=0!=(1&consoleNode.conn)?"Agent is online":"Agent is offline";0!=(16&consoleNode.conn)&&(n+=", MQTT is online"),QH("p15statetext",n),QE("p15consoleText",t),QE("p15uploadCore",0!=(1&consoleNode.conn)),QV("p15outputselecttd",17==(17&consoleNode.conn))}else QH("p15statetext","Access Denied"),QE("p15consoleText",!1),QE("p15uploadCore",!1),QV("p15outputselecttd",!1)}}function p15consoleClear(){QH("p15agentConsoleText",""),Q("id_p15consoleClear").blur(),115==xxcurrentView?consoleServerText="":consoleNode.consoleText=""}var consoleHistory=[];function p15consoleSend(e){if(!e||13==e.keyCode){var t=Q("p15consoleText").value,n="<div style=color:green>&gt; "+EscapeHtml(t)+"<br/></div>";if(115==xxcurrentView?(consoleServerText+=n,meshserver.send({action:"serverconsole",value:t})):0==(16&consoleNode.conn)||2!=Q("p15outputselect").value&&0!=(1&consoleNode.conn)?(consoleNode.consoleText+=n,meshserver.send({action:"msg",type:"console",nodeid:consoleNode._id,value:t})):(n="<div style=color:orange>MQTT&gt; "+EscapeHtml(t)+"<br/></div>",consoleNode.consoleText+=n,meshserver.send({action:"sendmqttmsg",topic:"console",nodeids:[consoleNode._id],msg:t})),Q("p15agentConsoleText").innerHTML+=n,Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight,Q("p15consoleText").value="",0<t.length){var o=consoleHistory.indexOf(t);0<=o&&consoleHistory.splice(o,1),consoleHistory.unshift(t),consoleHistory.splice(10)}}}function p15consoleReceive(e,t,n){"serverconsole"===e?(t="<div>"+EscapeHtml(t)+"</div>",consoleServerText+=t,"server"==consoleNode&&(Q("p15agentConsoleText").innerHTML+=t,Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight)):(t="MQTT"==n?"<div style=color:red>MQTT&gt; "+EscapeHtml(t)+"<br/></div>":"<div>"+EscapeHtml(t)+"</div>",null==e.consoleText?e.consoleText=t:e.consoleText+=t,consoleNode==e&&(Q("p15agentConsoleText").innerHTML+=t,Q("p15agentConsoleText").scrollTop=Q("p15agentConsoleText").scrollHeight))}function p15downloadConsoleText(){saveAs(new Blob([Q("p15agentConsoleText").innerText],{type:"application/octet-stream"}),"console.txt")}function p15uploadCore(e){xxdialogMode||(1==e.shiftKey?meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"default"}):1==e.altKey?meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"clear"}):1==e.ctrlKey?p15uploadCore2():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(){1==Q("d3coreMode").value?meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"default"}):2==Q("d3coreMode").value?meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"clear"}):3==Q("d3coreMode").value?p15uploadCore2():4==Q("d3coreMode").value?meshserver.send({action:"agentdisconnect",nodeid:consoleNode._id,disconnectMode:1}):5==Q("d3coreMode").value?meshserver.send({action:"agentdisconnect",nodeid:consoleNode._id,disconnectMode:2}):6==Q("d3coreMode").value&&meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"recovery"})}function p15uploadCore2(){xxdialogMode||(Q("d3localmodeform").action="uploadmeshcorefile.ashx",Q("d3auth").value=authCookie,Q("d3attrib").value=currentNode._id,setDialogMode(3,"Upload Mesh Agent Core",3,p15uploadCoreEx2),d3init())}function p15uploadCoreEx2(){if(1==Q("d3uploadMode").value)Q("d3submit").click();else{var e=d3getFileSel();1==e.length&&meshserver.send({action:"uploadagentcore",nodeid:consoleNode._id,type:"custom",path:d3filetreelocation.join("/")+"/"+e[0]})}}function account_managePhone(){var e;xxdialogMode||0==(33554432&features)||(null!=userinfo.phone?(e='<table style=width:100%><tr><td style=width:56px><img src="images/phone80.png" style=padding:8px>',e+="<td style=text-align:center><div style=padding:6px>Verified phone number</div><div style=font-size:20px>"+userinfo.phone+"</div>",setDialogMode(2,"Phone Notifications",3,account_managePhoneRemove,e+="<div style=margin:10px><label><input id=d2delPhone type=checkbox onclick=account_managePhoneRemoveValidate() />Remove phone number</label></div>"),account_managePhoneRemoveValidate()):(e='<table style=width:100%><tr><td style=width:56px><img src="images/phone80.png" style=padding:8px>',e+="<td>Enter your SMS capable phone number. Once verified, the number may be used for login verification and other notifications.",setDialogMode(2,"Phone Notifications",3,account_managePhoneAdd,e+='<br /><br /><div style=width:100%;text-align:center>Phone number: <input type=tel pattern="[0-9]" autocomplete="tel" inputmode="tel" maxlength=18 id=d2phoneinput onKeyUp=account_managePhoneValidate() onkeypress="if (event.key==\'Enter\') account_managePhoneValidate(1)"></div></table>',"verifyPhone"),Q("d2phoneinput").focus(),account_managePhoneValidate()))}function isPhoneNumber(e){return e.match(/^\(?([0-9]{3,4})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/)}function account_managePhoneValidate(e){var t=isPhoneNumber(Q("d2phoneinput").value);QE("idx_dlgOkButton",t),1==e&&t&&dialogclose(1)}function account_managePhoneCodeValidate(e){var t=6==Q("d2phoneCodeInput").value.length&&Q("d2phoneCodeInput").value.match(/[0-9]/);QE("idx_dlgOkButton",t),1==e&&t&&dialogclose(1)}function account_managePhoneConfirm(e,t){meshserver.send({action:"confirmPhone",code:Q("d2phoneCodeInput").value,cookie:t})}function account_managePhoneAdd(){0!=isPhoneNumber(Q("d2phoneinput").value)&&(QE("d2phoneinput",!1),meshserver.send({action:"verifyPhone",phone:Q("d2phoneinput").value}))}function account_managePhoneRemove(){Q("d2delPhone").checked&&meshserver.send({action:"removePhone"})}function account_managePhoneRemoveValidate(){QE("idx_dlgOkButton",Q("d2delPhone").checked)}function account_manageAuthEmail(){if(!xxdialogMode&&0!=(8388608&features)){var e=1==userinfo.otpekey&&null!=userinfo.email&&1==userinfo.emailVerified;setDialogMode(2,"Email Authentication",1,function(){e!=Q("email2facheck").checked&&meshserver.send({action:"otpemail",enabled:Q("email2facheck").checked})},"When enabled, on each login, you will be given the option to receive a login token to you email account for added security.<br /><br /><label><input id=email2facheck type=checkbox "+(e?"checked":"")+"/>Enable email two-factor authenticaiton.</label>")}}function account_manageAuthApp(){if(!xxdialogMode&&0!=(4096&features))return 1==userinfo.otpsecret?account_removeOtp():account_addOtp(),!1}function account_addOtp(){xxdialogMode||1==userinfo.otpsecret||0==(4096&features)||(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(e){var t=6==Q("d2otpauthinput").value.length;QE("idx_dlgOkButton",t),e&&13==e.keyCode&&t&&dialogclose(1)}function account_removeOtp(){xxdialogMode||1!=userinfo.otpsecret||0==(4096&features)||setDialogMode(2,"Authenticator App",3,function(){meshserver.send({action:"otpauth-clear"})},"Confirm removal of authenticator application 2-step login?")}function account_manageOtp(e){return 2==xxdialogMode&&"otpauth-manage"==xxdialogTag&&dialogclose(0),xxdialogMode||0==(4096&features)||0<count2factoraAuths()&&meshserver.send({action:"otpauth-getpasswords",subaction:e}),!1}function account_manageHardwareOtp(){return 2==xxdialogMode&&"otpauth-hardware-manage"==xxdialogTag&&dialogclose(0),xxdialogMode||0==(4096&features)||meshserver.send({action:"otp-hkey-get"}),!1}function account_addhkey(e){if(3==e){var t="Type in the name of the key to add.<br /><br />";t+=addHtmlValue("Key Name",'<input id=dp1keyname style=width:230px maxlength=20 autocomplete=off placeholder="MyKey" onkeyup=account_addhkeyValidate(event,2) />')}else if(2==e){t="Type in a key name, select the OTP box and press the button on the YubiKey&trade;.<br /><br />";t+=addHtmlValue("Key Name",'<input id=dp1keyname style=width:230px maxlength=20 autocomplete=off placeholder="MyKey" onkeyup=account_addhkeyValidate(event,1) />'),t+=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,t,e),Q("dp1keyname").focus()}function account_addhkeyValidate(e,t){null!=e&&13==e.keyCode&&(2==t?dialogclose(1):Q("dp1key").focus())}function account_addhkeyEx(e,t){var n=Q("dp1keyname").value;""==n&&(n="MyKey"),2==t?(meshserver.send({action:"otp-hkey-yubikey-add",name:n,otp:Q("dp1key").value}),setDialogMode(2,"Add Security Key",0,null,"<br />Checking...<br /><br /><br />","otpauth-hardware-manage")):3==t&&meshserver.send({action:"webauthn-startregister",name:n})}function account_removehkey(e){meshserver.send({action:"otp-hkey-remove",index:e}),meshserver.send({action:"otp-hkey-get"})}var currentMesh,filetreelinkpath,loclist={af:"Afrikaans",sq:"Albanian",ar:"Arabic (Standard)","ar-dz":"Arabic (Algeria)","ar-bh":"Arabic (Bahrain)","ar-eg":"Arabic (Egypt)","ar-iq":"Arabic (Iraq)","ar-jo":"Arabic (Jordan)","ar-kw":"Arabic (Kuwait)","ar-lb":"Arabic (Lebanon)","ar-ly":"Arabic (Libya)","ar-ma":"Arabic (Morocco)","ar-om":"Arabic (Oman)","ar-qa":"Arabic (Qatar)","ar-sa":"Arabic (Saudi Arabia)","ar-sy":"Arabic (Syria)","ar-tn":"Arabic (Tunisia)","ar-ae":"Arabic (U.A.E.)","ar-ye":"Arabic (Yemen)",an:"Aragonese",hy:"Armenian",as:"Assamese",ast:"Asturian",az:"Azerbaijani",eu:"Basque",bg:"Bulgarian",be:"Belarusian",bn:"Bengali",bs:"Bosnian",br:"Breton",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",zh:"Chinese","zh-hk":"Chinese (Hong Kong)","zh-cn":"Chinese (PRC)","zh-sg":"Chinese (Singapore)","zh-tw":"Chinese (Taiwan)",cv:"Chuvash",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch (Standard)","nl-be":"Dutch (Belgian)",en:"English","en-au":"English (Australia)","en-bz":"English (Belize)","en-ca":"English (Canada)","en-ie":"English (Ireland)","en-jm":"English (Jamaica)","en-nz":"English (New Zealand)","en-ph":"English (Philippines)","en-za":"English (South Africa)","en-tt":"English (Trinidad & Tobago)","en-gb":"English (United Kingdom)","en-us":"English (United States)","en-zw":"English (Zimbabwe)",eo:"Esperanto",et:"Estonian",fo:"Faeroese",fa:"Farsi (Persian)",fj:"Fijian",fi:"Finnish",fr:"French (Standard)","fr-be":"French (Belgium)","fr-ca":"French (Canada)","fr-fr":"French (France)","fr-lu":"French (Luxembourg)","fr-mc":"French (Monaco)","fr-ch":"French (Switzerland)",fy:"Frisian",fur:"Friulian",gd:"Gaelic (Scots)","gd-ie":"Gaelic (Irish)",gl:"Galacian",ka:"Georgian",de:"German (Standard)","de-at":"German (Austria)","de-de":"German (Germany)","de-li":"German (Liechtenstein)","de-lu":"German (Luxembourg)","de-ch":"German (Switzerland)",el:"Greek",gu:"Gujurati",ht:"Haitian",he:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",iu:"Inuktitut",ga:"Irish",it:"Italian (Standard)","it-ch":"Italian (Switzerland)",ja:"Japanese",kn:"Kannada",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ky:"Kirghiz",tlh:"Klingon",ko:"Korean","ko-kp":"Korean (North Korea)","ko-kr":"Korean (South Korea)",la:"Latin",lv:"Latvian",lt:"Lithuanian",lb:"Luxembourgish",mk:"FYRO Macedonian",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mo:"Moldavian",nv:"Navajo",ng:"Ndonga",ne:"Nepali",no:"Norwegian",nb:"Norwegian (Bokmal)",nn:"Norwegian (Nynorsk)",oc:"Occitan",or:"Oriya",om:"Oromo","fa-ir":"Persian/Iran",pl:"Polish",pt:"Portuguese","pt-br":"Portuguese (Brazil)",pa:"Punjabi","pa-in":"Punjabi (India)","pa-pk":"Punjabi (Pakistan)",qu:"Quechua",rm:"Rhaeto-Romanic",ro:"Romanian","ro-mo":"Romanian (Moldavia)",ru:"Russian","ru-mo":"Russian (Moldavia)",sz:"Sami (Lappish)",sg:"Sango",sa:"Sanskrit",sc:"Sardinian",sd:"Sindhi",si:"Singhalese",sr:"Serbian",sk:"Slovak",sl:"Slovenian",so:"Somani",sb:"Sorbian",es:"Spanish","es-ar":"Spanish (Argentina)","es-bo":"Spanish (Bolivia)","es-cl":"Spanish (Chile)","es-co":"Spanish (Colombia)","es-cr":"Spanish (Costa Rica)","es-do":"Spanish (Dominican Republic)","es-ec":"Spanish (Ecuador)","es-sv":"Spanish (El Salvador)","es-gt":"Spanish (Guatemala)","es-hn":"Spanish (Honduras)","es-mx":"Spanish (Mexico)","es-ni":"Spanish (Nicaragua)","es-pa":"Spanish (Panama)","es-py":"Spanish (Paraguay)","es-pe":"Spanish (Peru)","es-pr":"Spanish (Puerto Rico)","es-es":"Spanish (Spain)","es-uy":"Spanish (Uruguay)","es-ve":"Spanish (Venezuela)",sx:"Sutu",sw:"Swahili",sv:"Swedish","sv-fi":"Swedish (Finland)","sv-sv":"Swedish (Sweden)",ta:"Tamil",tt:"Tatar",te:"Teluga",th:"Thai",tig:"Tigre",ts:"Tsonga",tn:"Tswana",tr:"Turkish",tk:"Turkmen",uk:"Ukrainian",hsb:"Upper Sorbian",ur:"Urdu",ve:"Venda",vi:"Vietnamese",vo:"Volapuk",wa:"Walloon",cy:"Welsh",xh:"Xhosa",ji:"Yiddish",zu:"Zulu"},loclistex={"zh-chs":"Chinese (Simplified)"};function account_showLocalizationSettings(){if(xxdialogMode)return!1;var e=getstore("loctag",0),t="",n='<select id=d2locselect style=width:240px><option value="*">User browser value</option>';for(var o in loclist)n+='<option value="'+o+'"'+(e==o?" selected":"")+">"+o+" - "+loclist[o]+"</option>";if(n+="</select>",serverinfo.languages&&0<serverinfo.languages.length){t+="Changing the language will require a refresh of the page.<br /><br />";var i='<select id=d2langselect style=width:240px><option value="*">User browser value</option>';for(var o in serverinfo.languages){var a=serverinfo.languages[o];i+='<option value="'+a+'"'+(userinfo.lang==a?" selected":"")+">"+a+" - "+(loclist[a]?loclist[a]:loclistex[a])+"</option>"}t+=addHtmlValue("Language",i+="</select>")}return t+=addHtmlValue("Dates & Time",n),4294967295==userinfo.siteadmin&&""==domain&&(t+='<br /><a rel="noreferrer noopener" target="_blank" href="translator.htm">Help translate MeshCentral</a>'),setDialogMode(2,"Localization Settings",3,account_showLocalizationSettingsEx,t),!1}function account_showLocalizationSettingsEx(){var e=Q("d2langselect").value;"*"==e&&null==userinfo.lang&&(e=userinfo.lang),e!=userinfo.lang&&meshserver.send({action:"changelang",lang:e});var t=getstore("loctag",0),n=Q("d2locselect").value;t!=n&&("*"!=n?args.locale=n:delete args.locale,putstore("loctag",args.locale),masterUpdate(4294967295))}function account_enableNotifications(){return Notification&&Notification.requestPermission().then(function(e){QV("accountEnableNotificationsSpan","granted"!=e)}),!1}function account_showAccountNotifySettings(){if(xxdialogMode)return!1;setDialogMode(2,"Notification Settings",3,account_showAccountNotifySettingsEx,"<div><label><input id=p2notifyPlayNotifySound type=checkbox />Notification sound.</label></div><div><label><input id=p2notifyGroupName type=checkbox />Display device group name</label></div><div><label><input id=p2notifyIntelDeviceConnect type=checkbox />Device connections.</label></div><div><label><input id=p2notifyIntelDeviceDisconnect type=checkbox />Device disconnections.</label></div><div><label><input id=p2notifyIntelAmtKvmActions type=checkbox />Intel&reg; AMT desktop and serial events.</label></div>");var e=getstore("notifications",0);return Q("p2notifyPlayNotifySound").checked=1&e,Q("p2notifyIntelDeviceConnect").checked=2&e,Q("p2notifyIntelDeviceDisconnect").checked=4&e,Q("p2notifyIntelAmtKvmActions").checked=8&e,Q("p2notifyGroupName").checked=16&e,!1}function account_showAccountNotifySettingsEx(){var e=0;e+=Q("p2notifyPlayNotifySound").checked?1:0,e+=Q("p2notifyIntelDeviceConnect").checked?2:0,e+=Q("p2notifyIntelDeviceDisconnect").checked?4:0,e+=Q("p2notifyIntelAmtKvmActions").checked?8:0,putstore("notifications",e+=Q("p2notifyGroupName").checked?16:0)}function account_showVerifyEmail(){return xxdialogMode||1==userinfo.emailVerified||1!=serverinfo.emailcheck||setDialogMode(2,"Email Verification",3,account_showVerifyEmailEx,"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."),!1}function account_showVerifyEmailEx(){meshserver.send({action:"verifyemail",email:userinfo.email})}function account_showChangeEmail(){if(xxdialogMode)return!1;var e="Change your account email address here.<br /><br />";return setDialogMode(2,"Email Address Change",3,account_changeEmail,e+=addHtmlValue("Email","<input id=dp2email style=width:230px maxlength=256 onchange=account_validateEmail() onkeyup=account_validateEmail(event) />")),null!=userinfo.email&&(Q("dp2email").value=userinfo.email),account_validateEmail(),Q("dp2email").focus(),!1}function account_validateEmail(e,t){QE("idx_dlgOkButton",validateEmail(Q("dp2email").value)&&Q("dp2email").value!=userinfo.email),null!=e&&13==e.keyCode&&dialogclose(1)}function account_changeEmail(){meshserver.send({action:"changeemail",email:Q("dp2email").value})}function account_showDeleteAccount(){if(xxdialogMode)return!1;var e="To delete this account, type in the account password in both boxes below and hit ok.<br /><br />";return e+="<form method=post><input type=hidden name=action value=deleteaccount /><input type=hidden name=authcookie value="+authCookie+" /><table style=margin-left:80px><tr>",e+="<td align=right>Password:</td><td><input id=apassword1 type=password name=apassword1 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>",e+="</tr><tr><td align=right>Password:</td><td><input id=apassword2 type=password name=apassword2 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>",e+="</tr></table><br /><div style=padding:10px;margin-bottom:4px>",e+="<input id=account_dlgCancelButton type=button value=Cancel style=float:right;width:80px;margin-left:5px onclick=dialogclose(0)>",e+='<input id=account_dlgOkButton type=submit value=OK style="float:right;width:80px" onclick=dialogclose(1)>',setDialogMode(2,"Delete Account",0,null,e+="</div><br /></form>"),account_validateDeleteAccount(),Q("apassword1").focus(),!1}function account_showChangePassword(){if(xxdialogMode)return!1;var e="Change your account password by entering the old password and new password twice in the boxes below.";if(e+="<br /><br />",e+="<table style=margin-left:60px>",e+="<tr><td align=right>"+nobreak("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>",e+="<tr><td align=right>"+nobreak("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>",e+="<tr><td align=right>"+nobreak("New password:")+"</td><td><input id=apassword2 type=password name=apassword2 autocomplete=off onchange=account_validateNewPassword() onkeyup=account_validateNewPassword() onkeydown=account_validateNewPassword() /></td></tr>",65536&features&&(e+="<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>"),e+="</table>",passRequirements){var t=[],n=0;for(var o in passRequirements)"reset"!=o&&"hint"!=o&&(t.push(o+":"+passRequirements[o]),n++);0<n&&(e+="<br /><span style=font-size:x-small>Requirements: "+t.join(", ")+".</span>")}return setDialogMode(2,"Change Password",3,account_showChangePasswordEx,e+="<br />"),Q("apassword0").focus(),account_validateNewPassword(),!1}function account_showChangePasswordEx(){if(Q("apassword1").value==Q("apassword2").value){var e={action:"changepassword",oldpass:Q("apassword0").value,newpass:Q("apassword1").value};65536&features&&(e.hint=Q("apasswordhint").value),meshserver.send(e)}}function account_createMesh(){if(xxdialogMode)return!1;if(4294967295!=userinfo.siteadmin&&0!=(64&userinfo.siteadmin))return setDialogMode(2,"New Device Group",1,null,"This account does not have the rights to create a new device group."),!1;if(!0!==userinfo.emailVerified&&1==serverinfo.emailcheck&&4294967295!=userinfo.siteadmin)return 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.'),!1;if(262144&features&&!(1==userinfo.otpsecret||0<userinfo.otphkeys||0<userinfo.otpkeys||33554432&features&&67108864&features&&null!=userinfo.phone||8388608&features&&1==userinfo.otpekey))return 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.'),!1;var e="Create a new device group using the options below.<br /><br />";return e+=addHtmlValue("Name","<input id=dp2meshname style=width:230px maxlength=64 onchange=account_validateMeshCreate() onkeyup=account_validateMeshCreate(event,1) />"),e+=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>"),setDialogMode(2,"New Device Group",3,account_createMeshEx,e+=addHtmlValue("Description","<div style=width:230px;margin:0;padding:0><textarea id=dp2meshdesc maxlength=1024 style=width:100%;resize:none></textarea></div>")),account_validateMeshCreate(),Q("dp2meshname").focus(),!1}function account_validateMeshCreate(e,t){1==t&&null!=e&&"Enter"==e.key&&0<Q("dp2meshname").value.length&&Q("dp2meshtype").focus(),2==t&&null!=e&&"Enter"==e.key&&Q("dp2meshdesc").focus(),QE("idx_dlgOkButton",0<Q("dp2meshname").value.length)}function account_createMeshEx(e,t){meshserver.send({action:"createmesh",meshname:Q("dp2meshname").value,meshtype:Q("dp2meshtype").value,desc:Q("dp2meshdesc").value})}function account_validateDeleteAccount(){QE("account_dlgOkButton",0<Q("apassword1").value.length&&Q("apassword1").value==Q("apassword2").value)}function account_validateNewPassword(){var e="",t=0<Q("apassword0").value.length&&0<Q("apassword1").value.length&&Q("apassword1").value==Q("apassword2").value&&Q("apassword0").value!=Q("apassword1").value;if(65536&features&&Q("apasswordhint").value==Q("apassword1").value&&(t=!1),""!=Q("apassword1").value)if(null==passRequirements||""==passRequirements){var n=checkPasswordStrength(Q("apassword1").value);e=80<=n?"<span style=color:green>Strong<span>":60<=n?"<span style=color:blue>Good<span>":"<span style=color:red>Weak<span>"}else{0==checkPasswordRequirements(Q("apassword1").value,passRequirements)&&(t=!1,e="<span style=color:red>Policy<span>")}QH("dxPassWarn",e),QE("idx_dlgOkButton",t)}function checkPasswordStrength(e){var t=0,n={},o=0,i={digits:/\d/.test(e),lower:/[a-z]/.test(e),upper:/[A-Z]/.test(e),nonWords:/\W/.test(e)};if(!e)return 0;for(var a=0;a<e.length;a++)n[e[a]]=(n[e[a]]||0)+1,t+=5/n[e[a]];for(var s in i)o+=1==i[s]?1:0;return parseInt(t+10*(o-1))}function checkPasswordRequirements(e,t){if(null==t||""==t||"object"!=typeof t)return!0;if(t.min&&e.length<t.min)return!1;if(t.max&&e.length>t.max)return!1;for(var n=0,o=0,i=0,a=0,s=0;s<e.length;s++)/\d/.test(e[s])&&n++,/[a-z]/.test(e[s])&&o++,/[A-Z]/.test(e[s])&&i++,/\W/.test(e[s])&&a++;return!(t.numeric&&n<t.numeric)&&(!(t.lower&&o<t.lower)&&(!(t.upper&&i<t.upper)&&!(t.nonalpha&&a<t.nonalpha)))}function updateMeshes(){var e="",t=0,n=0;for(i in meshes){1<t&&(e+="</tr><tr>",t=0),t++,n++;var o=GetMeshRights(meshes[i]),a="Partial Rights";4294967295==o?a="Full Administrator":0==o&&(a="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>"+a+"</div></div><div class=g2 style=float:left></div></div></div></div>"}meshcount=n,QH("p2meshes",e),QV("p2noMeshFound",0==n)}function gotoMesh(e){return currentMesh=meshes[e],p20updateMesh(),go(20),!1}function server_showRestoreDlg(){if(xxdialogMode)return!1;var e="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 />";return e+='<form action="/restoreserver.ashx" enctype="multipart/form-data" method="post"><div>',e+="<input type=hidden name=auth value="+authCookie+">",e+='<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()>',e+="<input id=account_dlgCancelButton type=button value=Cancel style=float:right;width:80px;margin-left:5px onclick=dialogclose(0)>",e+="<input id=account_dlgOkButton type=submit value=OK style=float:right;width:80px onclick=dialogclose(1)>",setDialogMode(2,"Restore Server",0,null,e+="</div><br /><br /></form>"),account_validateServerRestore(),!1}function account_validateServerRestore(){QE("account_dlgOkButton",1==Q("account_dlgFileInput").files.length)}function server_showVersionDlg(){return xxdialogMode||(setDialogMode(2,"MeshCentral Version",1,null,"Loading...","MeshCentralServerUpdate"),meshserver.send({action:"serverversion"})),!1}function server_showVersionDlgUpdate(){var e=Q("d2updateCheck1").checked,t=Q("d2updateCheck2").checked;QE("d2updateCheck1","Unknown"!=xxdialogTag.stable&&xxdialogTag.current!=xxdialogTag.stable&&0==t),QE("d2updateCheck2","Unknown"!=xxdialogTag.latest&&xxdialogTag.current!=xxdialogTag.latest&&0==e),QE("idx_dlgOkButton",e&&!t||!e&&t)}function server_showVersionDlgEx(e,t){Q("d2updateCheck1").checked&&meshserver.send({action:"serverupdate",tag:"stable",version:t.stable}),Q("d2updateCheck2").checked&&meshserver.send({action:"serverupdate"})}function server_showErrorsDlg(){return xxdialogMode||(setDialogMode(2,"MeshCentral Errors",1,null,"Loading...","MeshCentralServerErrors"),meshserver.send({action:"servererrors"})),!1}function server_showErrorsDlgUpdate(){QE("idx_dlgOkButton",Q("d2clearErrorsCheck").checked)}function server_showErrorsDlgEx(){meshserver.send({action:"serverclearerrorlog"})}function d2CopyServerErrorsToClip(){saveAs(new Blob([Q("d2ServerErrorsLogPre").innerText],{type:"application/octet-stream"}),"servererrors.txt")}function p20updateMesh(){if(null!=currentMesh){var e=GetMeshRights(currentMesh),t=EscapeHtml(currentMesh.name);0==t.length&&(t="<i>None</i>"),0!=(1&e)&&(t='<span tabindex=0 title="Click here to edit the device group name" onclick=p20editmesh(1) onkeyup="if (event.key == \'Enter\') p20editmesh(1)" style=cursor:pointer>'+t+' <img class=hoverButton src="images/link5.png" /></span>'),QH("p20meshName",t);var n=format("Unknown #{0}",currentMesh.mtype);1==currentMesh.mtype&&(n="Intel&reg; AMT only, no agent"),2==currentMesh.mtype&&(n="Managed using a software agent");var o="";if(0!=(8&args.hide)&&(o+=addHtmlValue("Name",t)),o+=addHtmlValue("Description",addLinkConditional(currentMesh.desc&&""!=currentMesh.desc?EscapeHtml(currentMesh.desc):"<i>None</i>","p20editmesh(2)",0!=(1&e))),o+=addHtmlValue("Type",n),2==currentMesh.mtype){var i=[];currentMesh.flags&&(1&currentMesh.flags&&i.push("Auto-Remove"),2&currentMesh.flags&&i.push("Hostname Sync")),""==(i=i.join(", "))&&(i="<i>None</i>"),o+=addHtmlValue("Features",addLinkConditional(i,"p20editmeshfeatures()",1&e))}if(2==currentMesh.mtype){i=[];var a=0;currentMesh.consent&&(a=currentMesh.consent),serverinfo.consent&&(a|=serverinfo.consent),64&a&&8&a?i.push("Desktop Prompt+Toolbar"):64&a?i.push("Desktop Toolbar"):8&a?i.push("Desktop Prompt"):1&a&&i.push("Desktop Notify"),16&a?i.push("Terminal Prompt"):2&a&&i.push("Terminal Notify"),32&a?i.push("Files Prompt"):4&a&&i.push("Files Notify"),7==a&&(i=["Always Notify"]),56==(56&a)&&(i=["Always Prompt"]),""==(i=i.join(", "))&&(i="<i>None</i>"),o+=addHtmlValue("User Consent",addLinkConditional(i,"p20editmeshconsent(1)",1&e))}var s=0,r=[];if(userinfo.links&&userinfo.links[currentMesh._id]&&userinfo.links[currentMesh._id].notify&&(s=userinfo.links[currentMesh._id].notify),2&s&&r.push("Connect"),4&s&&r.push("Disconnect"),8&s&&r.push("Intel&reg; AMT"),0==r.length&&r.push("<i>None</i>"),o+=addHtmlValue("Notifications",addLink(r.join(", "),"p20editMeshNotify()")),16777216&features&&2==currentMesh.mtype){var l="<i>None</i>",d=!1;null!=currentMesh.invite&&(d=!0,l=currentMesh.invite.codes.join(", ")),o+=addHtmlValue("Invite Codes",addLinkConditional(l,"p20editmeshInviteCode()",1&e||d))}var c="No Policy";if(currentMesh.amt&&(1==currentMesh.amt.type?c="Deactivate Client Control Mode (CCM)":2==currentMesh.amt.type?(c="Simple Client Control Mode (CCM)",2==currentMesh.amt.cirasetup&&(c+=" + CIRA")):3==currentMesh.amt.type&&(c="Simple Admin Control Mode (ACM)",2==currentMesh.amt.cirasetup&&(c+=" + CIRA"))),o+=addHtmlValue("Intel&reg; AMT",addLinkConditional(c,"p20editMeshAmt()",1&e)),1&e&&(o+='<br><input type=button value=Notes title="View notes about this device group" onclick=showNotes(false,"'+encodeURIComponentEx(currentMesh._id)+'") />'),o+="<br style=clear:both><br>",2&e&&(o+='<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>',null!=usergroups)){var u=0,p=!1;for(var m in usergroups)usergroups[m]._id.split("/")[1]==currentMesh._id.split("/")[1]&&(u++,null!=currentMesh.links&&null!=currentMesh.links[m]||(p=!0));0<u&&p&&(o+='<a href=# onclick="return p20showAddMeshUserDialog(2)" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add User Group</a>')}4&e&&(1==currentMesh.mtype&&(o+="<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>',o+="<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>',currentMesh.amt&&2==currentMesh.amt.type?o+="<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>':currentMesh.amt&&3==currentMesh.amt.type&&0!=(1048576&features)&&(o+="<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>')),2==currentMesh.mtype&&(o+="<a href=# onclick='return addAgentToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Add a new computer to this device group by installing the mesh agent."><img src=images/icon-addnew.png border=0 height=12 width=12> Add Agent</a>',o+="<a href=# onclick='return inviteAgentToMesh(\""+currentMesh._id+'")\' style=cursor:pointer;margin-right:10px title="Invite someone to install the mesh agent on this device group."><img src=images/icon-addnew.png border=0 height=12 width=12> Invite</a>')),o+='<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 g=1,h=[];for(var m in currentMesh.links){var v=m.split("/")[2];currentMesh.links[m].name&&(v=currentMesh.links[m].name),m==userinfo._id&&(v=userinfo.name),null!=usergroups&&null!=usergroups[m]&&(v=usergroups[m].name),h.push({id:m,name:v,rights:currentMesh.links[m].rights})}for(var m in h.sort(function(e,t){return e.name>t.name?1:e.name<t.name?-1:0}),h){var f="",k=makeDeviceGroupRightsString(h[m].rights),x=2;h[m].id==userinfo._id||4294967295!=e&&0==(2&e)||(4294967295!=e&&4294967295==currentMesh.links[h[m].id].rights||(f="<a href=# onclick='return p20deleteUser(event,\""+encodeURIComponentEx(h[m].id)+'")\' title="Remove user rights to this device group" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>'),k='<span tabindex=0 style=cursor:pointer onclick=p20viewuser("'+encodeURIComponentEx(h[m].id)+"\") onkeypress=\"if (event.key=='Enter') p20viewuser('"+encodeURIComponentEx(h[m].id)+"')\">"+k+" <img class=hoverButton style=cursor:pointer src=images/link5.png></span>"),h[m].id.startsWith("ugrp/")&&(x=4);var y=EscapeHtml(decodeURIComponent(h[m].name));null!=usergroups&&h[m].id.startsWith("ugrp/")&&(y="<a tabindex=0 href=# onclick='gotoUserGroup(\""+encodeURIComponentEx(h[m].id)+"\");haltEvent(event);'>"+y+"</a>"),null!=users&&h[m].id.startsWith("user/")&&(y="<a tabindex=0 href=# onclick='gotoUser(\""+encodeURIComponentEx(h[m].id)+"\");haltEvent(event);'>"+y+"</a>"),o+="<tr style="+(g%2==0?";background-color:#DDD":"")+'><td style=width:30%><div title="User" class=m'+x+"></div><div>&nbsp;"+y+"<div></div></div></td><td style=width:70%><div style=float:right>"+f+"</div><div>"+k+"</div></td></tr>",++g}o+="</tbody></table>",4294967295==e&&(o+="<div style=font-size:x-small;text-align:right><span><a href=# onclick=p20showDeleteMeshDialog() style=cursor:pointer>Delete Group</a></span></div>"),QH("p20info",o);var b="";if(0==(268435456&features)&&20<=xxcurrentView&&xxcurrentView<=29&&null!=currentMesh){for(var m in b="?viewmode="+xxcurrentView+"&gotomesh="+currentMesh._id.split("/")[2],urlargs)b+="&"+m+"="+urlargs[m];try{window.history.replaceState({},document.title,window.location.pathname+b)}catch(e){}}}}function p20editMeshAmt(){if(!xxdialogMode){var e="",t="";0!=(1048576&features)&&(t="<option value=3>Simple Admin Control Mode (ACM)</option>"),1==currentMesh.mtype?e+=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>"+t+"</select>"):e+=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>"+t+"</select>"),setDialogMode(2,"Intel&reg; AMT Policy",3,p20editMeshAmtEx,e+="<div id=dp20amtpolicydiv></div>"),currentMesh.amt&&(Q("dp20amtpolicy").value=currentMesh.amt.type),p20editMeshAmtChange(),(currentMesh.amt&&2==currentMesh.amt.type||3==currentMesh.amt.type)&&(Q("dp20amtpolicypass").value=currentMesh.amt.password,2==currentMesh.amt.type&&null!=currentMesh.amt.badpass&&(Q("dp20amtbadpass").value=currentMesh.amt.badpass),0==(1024&features)&&(Q("dp20amtcira").value=currentMesh.amt.cirasetup)),dp20amtValidatePolicy()}}function p20editMeshAmtChange(){var e=Q("dp20amtpolicy").value,t="";2<=e&&(t=addHtmlValue("Password*","<input id=dp20amtpolicypass type=password style=width:230px maxlength=32 onchange=dp20amtValidatePolicy() onkeyup=dp20amtValidatePolicy() autocomplete=off />"),t+=addHtmlValue("Password*","<input id=dp20amtpolicypass2 type=password style=width:230px maxlength=32 onchange=dp20amtValidatePolicy() onkeyup=dp20amtValidatePolicy() autocomplete=off />"),2==e&&2==currentMesh.mtype&&(t+=addHtmlValue("Password mismatch","<select id=dp20amtbadpass style=width:230px><option value=0>Do nothing</option><option value=1>Reactivate Intel&reg; AMT</option></select>")),0==(1024&features)&&(t+=addHtmlValue('<span title="Client Initiated Remote Access">CIRA</span>',2==e?"<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>":"<select id=dp20amtcira style=width:230px><option value=0>Don't configure</option><option value=2>Connect to server</option></select>")),t+='<br/><span style="font-size:10px">* Leave blank to assign a random password to each device.</span><br/>',2==currentMesh.mtype&&(2==e?(t+='<span style="font-size:10px">This policy will not impact devices with Intel&reg; AMT in ACM mode.</span><br/>',t+='<span style="font-size:10px">This is not a secure policy as agents will be performing activation.</span>'):t+='<span style="font-size:10px">During activation, the agent will have access to admin password infomation.</span>')),QH("dp20amtpolicydiv",t),setTimeout(dp20amtValidatePolicy,1)}function dp20amtValidatePolicy(){var e=!0,t=Q("dp20amtpolicy").value;if(2==t||3==t){var n=Q("dp20amtpolicypass").value;e=n===Q("dp20amtpolicypass2").value&&(""===n||passwordcheck(n))}QE("idx_dlgOkButton",e)}function p20editMeshAmtEx(){var e=parseInt(Q("dp20amtpolicy").value),t={type:e};2==e?(t={type:e,password:Q("dp20amtpolicypass").value},2==currentMesh.mtype&&(t.badpass=parseInt(Q("dp20amtbadpass").value)),t.cirasetup=0==(1024&features)?parseInt(Q("dp20amtcira").value):1):3==e&&((t={type:e,password:Q("dp20amtpolicypass").value}).cirasetup=0==(1024&features)?parseInt(Q("dp20amtcira").value):1),meshserver.send({action:"meshamtpolicy",meshid:currentMesh._id,amtpolicy:t})}function p20showDeleteMeshDialog(){if(xxdialogMode)return!1;var e=format("Are you sure you want to delete group {0}? Deleting the device group will also delete all information about devices within this group.",EscapeHtml(currentMesh.name))+"<br /><br />";return setDialogMode(2,"Delete Group",3,p20showDeleteMeshDialogEx,e+="<label><input id=p20check type=checkbox onchange=p20validateDeleteMeshDialog() />Confirm</label>"),p20validateDeleteMeshDialog(),!1}function p20validateDeleteMeshDialog(){QE("idx_dlgOkButton",Q("p20check").checked)}function p20showDeleteMeshDialogEx(e,t){meshserver.send({action:"deletemesh",meshid:currentMesh._id,meshname:currentMesh.name})}function p20editmesh(e){if(!xxdialogMode){var t=addHtmlValue("Name","<input id=dp20meshname style=width:230px maxlength=32 onchange=p20editmeshValidate() onkeyup=p20editmeshValidate(event) />");setDialogMode(2,"Edit Device Group",3,p20editmeshEx,t+=addHtmlValue("Description","<div style=width:230px;margin:0;padding:0><textarea id=dp20meshdesc maxlength=1024 style=width:100%;resize:none></textarea></div>")),Q("dp20meshname").value=currentMesh.name,currentMesh.desc&&(Q("dp20meshdesc").value=currentMesh.desc),p20editmeshValidate(),2==e?Q("dp20meshdesc").focus():Q("dp20meshname").focus()}}function p20editmeshEx(){meshserver.send({action:"editmesh",meshid:currentMesh._id,meshname:Q("dp20meshname").value,desc:Q("dp20meshdesc").value})}function p20editmeshValidate(e){QE("idx_dlgOkButton",0<Q("dp20meshname").value.length),e&&"Enter"==e.key&&Q("dp20meshdesc").focus()}function p20editmeshconsent(e){if(!xxdialogMode){var t="",n=0,o="";1==e&&(n=currentMesh.consent?currentMesh.consent:0,o="Edit Device Group User Consent"),2==e&&(n=currentUser.consent?currentUser.consent:0,o="Edit User Consent"),3==e&&(n=currentNode.consent?currentNode.consent:0,o="Edit Device User Consent"),t+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px"><b>Desktop</b></div>',t+="<div><label><input type=checkbox id=d20flag1 "+(1&n?"checked":"")+">Notify user</label></div>",t+="<div><label><input type=checkbox id=d20flag2 "+(8&n?"checked":"")+">Prompt for user consent</label></div>",t+="<div><label><input type=checkbox id=d20flag7 "+(64&n?"checked":"")+">Show connection toolbar</label></div>",t+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:8px"><b>Terminal</b></div>',t+="<div><label><input type=checkbox id=d20flag3 "+(2&n?"checked":"")+">Notify user</label></div>",t+="<div><label><input type=checkbox id=d20flag4 "+(16&n?"checked":"")+">Prompt for user consent</label></div>",t+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:8px"><b>Files</b></div>',t+="<div><label><input type=checkbox id=d20flag5 "+(4&n?"checked":"")+">Notify user</label></div>",setDialogMode(2,o,3,p20editmeshconsentEx,t+="<div><label><input type=checkbox id=d20flag6 "+(32&n?"checked":"")+">Prompt for user consent</label></div>",e),serverinfo.consent&&(1&serverinfo.consent&&(Q("d20flag1").checked=!0),8&serverinfo.consent&&(Q("d20flag2").checked=!0),2&serverinfo.consent&&(Q("d20flag3").checked=!0),16&serverinfo.consent&&(Q("d20flag4").checked=!0),4&serverinfo.consent&&(Q("d20flag5").checked=!0),32&serverinfo.consent&&(Q("d20flag6").checked=!0),64&serverinfo.consent&&(Q("d20flag7").checked=!0),QE("d20flag1",!(1&serverinfo.consent)),QE("d20flag2",!(8&serverinfo.consent)),QE("d20flag3",!(2&serverinfo.consent)),QE("d20flag4",!(16&serverinfo.consent)),QE("d20flag5",!(4&serverinfo.consent)),QE("d20flag6",!(32&serverinfo.consent)),QE("d20flag7",!(64&serverinfo.consent)))}}function p20editmeshconsentEx(e,t){var n=0;Q("d20flag1").checked&&(n+=1),Q("d20flag2").checked&&(n+=8),Q("d20flag3").checked&&(n+=2),Q("d20flag4").checked&&(n+=16),Q("d20flag5").checked&&(n+=4),Q("d20flag6").checked&&(n+=32),Q("d20flag7").checked&&(n+=64),1==t&&meshserver.send({action:"editmesh",meshid:currentMesh._id,consent:n}),2==t&&meshserver.send({action:"edituser",id:currentUser._id,consent:n}),3==t&&meshserver.send({action:"changedevice",nodeid:currentNode._id,consent:n})}function p20editmeshfeatures(){if(!xxdialogMode){var e=currentMesh.flags?currentMesh.flags:0,t="<div><label><input type=checkbox id=d20flag1 "+(1&e?"checked":"")+">Remove device on disconnect</label><br></div>";setDialogMode(2,"Edit Device Group Features",3,p20editmeshfeaturesEx,t+="<div><label><input type=checkbox id=d20flag2 "+(2&e?"checked":"")+">Sync server device name to hostname</label><br></div>")}}function p20editmeshfeaturesEx(){var e=0;Q("d20flag1").checked&&(e+=1),Q("d20flag2").checked&&(e+=2),meshserver.send({action:"editmesh",meshid:currentMesh._id,flags:e})}function p20showAddMeshUserDialog(e,t){if(xxdialogMode)return!1;var n="";if(null==e||5==e)null==t&&(n+=null==e?"Allow users to manage this device group and devices in this group.":"Allow users to manage this device.",524288&features&&(n+=" Users need to login to this server once before they can be added to a device group."),n+="<br /><br />"),n+="<div style='position:relative'>",n+=addHtmlValue("User Identifiers",'<input id=dp20username style=width:230px maxlength=256 onchange=p20validateAddMeshUserDialog() onkeyup=p20validateAddMeshUserDialog() placeholder="user1, user2, user3" />'),n+="<div id=dp20usersuggest class=suggestionBox style='top:30px;left:130px;display:none'></div>",n+="</div><br>";else if(1==e){var o="";if(null==t){var i=getOrderedList(meshes,"name");for(var a in i)null!=currentUser.links&&null!=currentUser.links[i[a]._id]||(o+="<option value="+encodeURIComponentEx(i[a]._id)+">"+EscapeHtml(i[a].name)+"</option>")}else o+="<option value="+t+">"+EscapeHtml(meshes[decodeURIComponent(t)].name)+"</option>";n+=addHtmlValue("Device Group","<div style=width:230px;margin:0;padding:0><select onchange=p20validateAddMeshUserDialog() id=dp2groupid style=width:100%"+(t?" disabled":"")+">"+o+"</select></div>")}else if(2==e){if(null==usergroups)return;o="";var s=getOrderedList(usergroups,"name");for(var a in s)currentMesh._id.split("/")[1]==s[a]._id.split("/")[1]&&(null!=currentMesh.links&&null!=currentMesh.links[s[a]._id]||(o+="<option value="+encodeURIComponentEx(s[a]._id)+">"+EscapeHtml(s[a].name)+"</option>"));n+=addHtmlValue("User Group","<div style=width:230px;margin:0;padding:0><select onchange=p20validateAddMeshUserDialog() id=dp2groupid style=width:100%>"+o+"</select></div>")}else if(6==e){if(null==usergroups)return;o="";if(null==t){s=getOrderedList(usergroups,"name");for(var a in s)currentNode._id.split("/")[1]==s[a]._id.split("/")[1]&&(null!=currentNode.links&&null!=currentNode.links[s[a]._id]||(o+="<option value="+encodeURIComponentEx(s[a]._id)+">"+EscapeHtml(s[a].name)+"</option>"))}else o+="<option value="+t+">"+EscapeHtml(usergroups[decodeURIComponent(t)].name)+"</option>";n+=addHtmlValue("User Group","<div style=width:230px;margin:0;padding:0><select onchange=p20validateAddMeshUserDialog() id=dp2groupid style=width:100%"+(t?" disabled":"")+">"+o+"</select></div>")}else if(3==e){o="";t=t&&decodeURIComponent(t);i=getOrderedList(meshes,"name");for(var a in i)null==t&&null!=currentUserGroup.links&&null!=currentUserGroup.links[i[a]._id]||(o+="<option value="+encodeURIComponentEx(i[a]._id)+(t==i[a]._id?" selected":" ")+">"+EscapeHtml(i[a].name)+"</option>");n+=addHtmlValue("Device Group","<div style=width:230px;margin:0;padding:0><select onchange=p20validateAddMeshUserDialog("+e+") id=dp2groupid style=width:100%>"+o+"</select></div>")}else if(4==e||7==e){o="";var r=null,l=null;null!=t&&null!=(l=getNodeFromId(decodeURIComponent(t)))&&(r=l.meshid);i=getOrderedList(meshes,"name");for(var a in i)null!=i[a].links[userinfo._id]&&7&i[a].links[userinfo._id].rights&&(null==r&&(r=i[a]._id),o+="<option value="+encodeURIComponentEx(i[a]._id)+(r==i[a]._id?" selected":" ")+">"+EscapeHtml(i[a].name)+"</option>");n+=addHtmlValue("Device Group","<div style=width:230px;margin:0;padding:0><select onchange=p20changeMeshAddMeshUserDialog("+e+") id=dp2meshid style=width:100%>"+o+"</select></div>"),o="";var d=getOrderedList(nodes,"name");for(var a in d)d[a].meshid==r&&(o+="<option value="+encodeURIComponentEx(d[a]._id)+(l==d[a]?" selected":" ")+">"+EscapeHtml(d[a].name)+"</option>");n+=addHtmlValue("Device","<div style=width:230px;margin:0;padding:0><select onchange=p20validateAddMeshUserDialog("+e+") id=dp2nodeid style=width:100%>"+o+"</select></div>")}else{var c=(e=decodeURIComponent(e)).split("/")[2];users&&users[e]&&(c=users[e].name),usergroups&&usergroups[e]&&(c=usergroups[e].name),userinfo._id==e&&(c=userinfo.name),e.startsWith("ugrp/")?n+=format("Group permissions for {0}.",c)+"<br /><br />":n+=format("Group permissions for user {0}.",c)+"<br /><br />"}var u=-1,p=4!=e&&5!=e&&6!=e&&7!=e;if(n+='<div style="height:120px;overflow-y:scroll;border:1px solid gray">',p&&(n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20fulladmin>Full Administrator</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editmesh>Edit Device Group</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20manageusers>Manage Device Group Users</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20managecomputers>Manage Device Group Computers</label><br>"),n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remotecontrol>Remote Control</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remoteview style=margin-left:12px>Remote View Only</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20remotelimitedinput style=margin-left:12px>Limited Input Only</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20nodesktop style=margin-left:12px>No Desktop Access</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20noterminal style=margin-left:12px>No Terminal Access</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20nofiles style=margin-left:12px>No File Access</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20noamt style=margin-left:12px>No Intel&reg; AMT</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20meshagentconsole>Mesh Agent Console</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20meshserverfiles>Server Files</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20wakedevices>Wake Devices</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editnotes>Edit Device Notes</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20limitevents>Show Only Own Events</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20chatnotify>Chat & Notify</label><br>",n+="<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20uninstall>Uninstall Agent</label><br>",n+="</div>",null==e)setDialogMode(2,"Add Users to Device Group",3,p20showAddMeshUserDialogEx,n),QE("p20fulladmin",4294967295==GetMeshRights(currentMesh)),Q("dp20username").focus();else if(1===e)setDialogMode(2,null==t?"Add Device Group Permissions":"Edit Device Group Permissions",t?7:3,p20showAddMeshUserDialogEx,n,e),null!=t&&(u=meshes[decodeURIComponent(t)].links[currentUser._id].rights),4294967295==u&&(Q("p20fulladmin").checked=!0,u=-1);else if(2===e)setDialogMode(2,"Add User Group",3,p20showAddMeshUserDialogEx,n,e),QE("p20fulladmin",4294967295==GetMeshRights(currentMesh));else if(3===e)setDialogMode(2,null==t?"Add Device Group":"Edit Device Group",t?7:3,p20showAddMeshUserDialogEx,n,e),QE("dp2groupid",null==t),null!=t&&(u=currentUserGroup.links[decodeURIComponent(t)].rights),4294967295==u&&(Q("p20fulladmin").checked=!0,u=-1);else if(4===e)setDialogMode(2,null==t?"Add Device Permissions":"Edit Device Permissions",t?7:3,p20showAddMeshUserDialogEx,n,e),QE("dp2meshid",null==t),QE("dp2nodeid",null==t);else if(7===e)setDialogMode(2,null==t?"Add Device Permissions":"Edit Device Permissions",t?7:3,p20showAddMeshUserDialogEx,n,e),QE("dp2meshid",null==t),QE("dp2nodeid",null==t),null!=t&&(u=currentUserGroup.links[decodeURIComponent(t)].rights,QE("dp20username",!1));else if(5===e)setDialogMode(2,t?"Edit User Device Permissions":"Add User Device Permissions",t?7:3,p20showAddMeshUserDialogEx,n,e),null!=t&&(t=decodeURIComponent(t),null!=users&&null!=users[t]?Q("dp20username").value=users[t].name:Q("dp20username").value=t.split("/")[2],u=currentNode.links[t].rights,QE("dp20username",!1)),Q("dp20username").focus();else if(6===e)setDialogMode(2,t?"Edit User Group Device Permissions":"Add User Group Device Permissions",t?7:3,p20showAddMeshUserDialogEx,n,e),null!=t&&(u=currentNode.links[decodeURIComponent(t)].rights);else{e.startsWith("ugrp/")?setDialogMode(2,"Edit Device Group Permissions",7,p20showAddMeshUserDialogEx,n,e):setDialogMode(2,"Edit User Device Group Permissions",7,p20showAddMeshUserDialogEx,n,e);GetMeshRights(currentMesh);4294967295==(u=GetMeshRights(currentMesh,e))&&(Q("p20fulladmin").checked=!0,u=-1),QE("p20fulladmin",4294967295==GetMeshRights(currentMesh))}return-1!=u&&(p&&(1&u&&(Q("p20editmesh").checked=!0),2&u&&(Q("p20manageusers").checked=!0),4&u&&(Q("p20managecomputers").checked=!0)),8&u&&(Q("p20remotecontrol").checked=!0,65536&u&&(Q("p20nodesktop").checked=!0),256&u&&(Q("p20remoteview").checked=!0),512&u&&(Q("p20noterminal").checked=!0),1024&u&&(Q("p20nofiles").checked=!0),2048&u&&(Q("p20noamt").checked=!0),4096&u&&(Q("p20remotelimitedinput").checked=!0)),16&u&&(Q("p20meshagentconsole").checked=!0),32&u&&(Q("p20meshserverfiles").checked=!0),64&u&&(Q("p20wakedevices").checked=!0),128&u&&(Q("p20editnotes").checked=!0),8192&u&&(Q("p20limitevents").checked=!0),16384&u&&(Q("p20chatnotify").checked=!0),32768&u&&(Q("p20uninstall").checked=!0)),p20validateAddMeshUserDialog(e),!1}function p20changeMeshAddMeshUserDialog(e){var t="",n=decodeURIComponent(Q("dp2meshid").value);for(var o in nodes)nodes[o].meshid==n&&(t+="<option value="+encodeURIComponentEx(nodes[o]._id)+">"+EscapeHtml(nodes[o].name)+"</option>");QH("dp2nodeid",t),p20validateAddMeshUserDialog(e)}function p20setname(e){e=decodeURIComponent(e);var t=Q("dp20username").value.split(",");for(var n in t)t[n]=t[n].trim();return t[t.length-1]=e,Q("dp20username").value=t.join(", "),p20validateAddMeshUserDialog(),!1}function p20validateAddMeshUserDialog(e){var t,n=!0;if(4===e){var o=0,i=decodeURIComponent(Q("dp2nodeid").value);""!=i&&null!=currentUser.links&&null!=currentUser.links[i]&&(o=currentUser.links[i].rights),Q("p20remotecontrol").checked=0!=(8&o),Q("p20meshagentconsole").checked=0!=(16&o),Q("p20meshserverfiles").checked=0!=(32&o),Q("p20wakedevices").checked=0!=(64&o),Q("p20editnotes").checked=0!=(128&o),Q("p20remoteview").checked=0!=(256&o),Q("p20noterminal").checked=0!=(512&o),Q("p20nofiles").checked=0!=(1024&o),Q("p20noamt").checked=0!=(2048&o),Q("p20remotelimitedinput").checked=0!=(4096&o),Q("p20limitevents").checked=0!=(8192&o),Q("p20chatnotify").checked=0!=(16384&o),Q("p20uninstall").checked=0!=(32768&o),Q("p20nodesktop").checked=0!=(65536&o),n=""!=i}if(Q("dp20username")){var a=Q("dp20username").value.split(",");for(var s in a){var r=a[s]=a[s].trim();0==r.length?n=!1:0<=r.indexOf('"')&&(n=!1)}var l=!1,d=!1;if(null!=users){var c=a[a.length-1].trim(),u=c.toLowerCase(),p=[];if(0<c.length){for(var s in users){var m=users[s]._id.split("/");if((null==currentMesh||currentMesh.domain==m[1])&&(null==currentNode||currentNode.domain==m[1])){if(m[2]===u){d=!0;break}if(0<=users[s].name.toLowerCase().indexOf(u)&&(p.push([users[s]._id,users[s].name]),8<=p.length))break}}if(0==d&&0<p.length){var g="";for(var s in p){var h=p[s][0],v=p[s][1];h.split("/")[2]==v.toLowerCase()?g+="<div class=suggestionBoxItem onclick='p20setname(\""+encodeURIComponentEx(h.split("/")[2])+"\")'>"+EscapeHtml(v)+"</div>":g+="<div class=suggestionBoxItem onclick='p20setname(\""+encodeURIComponentEx(h.split("/")[2])+"\")'><div>"+EscapeHtml(v)+"</div><div class=suggestionBoxSubItem>"+EscapeHtml(h.split("/")[2])+"</div></div>"}QH("dp20usersuggest",g),l=!0}}}QV("dp20usersuggest",l)}QE("idx_dlgOkButton",n),null!=Q("p20fulladmin")?(t=!Q("p20fulladmin").checked,QE("p20editmesh",t),QE("p20manageusers",t),QE("p20managecomputers",t)):t=""!=i,QE("p20remotecontrol",t),QE("p20meshagentconsole",t),QE("p20meshserverfiles",t),QE("p20wakedevices",t),QE("p20editnotes",t),QE("p20limitevents",t),QE("p20remoteview",t&&Q("p20remotecontrol").checked),QE("p20remotelimitedinput",t&&Q("p20remotecontrol").checked&&!Q("p20remoteview").checked),QE("p20nodesktop",t&&Q("p20remotecontrol").checked),QE("p20noterminal",t&&Q("p20remotecontrol").checked),QE("p20nofiles",t&&Q("p20remotecontrol").checked),QE("p20noamt",t&&Q("p20remotecontrol").checked),QE("p20chatnotify",t),QE("p20uninstall",t)}function p20showAddMeshUserDialogEx(e,t){var n=0;if(null!=Q("p20fulladmin")&&1==Q("p20fulladmin").checked?n=4294967295:(null!=Q("p20fulladmin")&&(1==Q("p20editmesh").checked&&(n+=1),1==Q("p20manageusers").checked&&(n+=2),1==Q("p20managecomputers").checked&&(n+=4)),1==Q("p20remotecontrol").checked&&(n+=8),1==Q("p20meshagentconsole").checked&&(n+=16),1==Q("p20meshserverfiles").checked&&(n+=32),1==Q("p20wakedevices").checked&&(n+=64),1==Q("p20editnotes").checked&&(n+=128),1==Q("p20remoteview").checked&&(n+=256),1==Q("p20nodesktop").checked&&(n+=65536),1==Q("p20noterminal").checked&&(n+=512),1==Q("p20nofiles").checked&&(n+=1024),1==Q("p20noamt").checked&&(n+=2048),1==Q("p20remotelimitedinput").checked&&(n+=4096),1==Q("p20limitevents").checked&&(n+=8192),1==Q("p20chatnotify").checked&&(n+=16384),1==Q("p20uninstall").checked&&(n+=32768)),0==(8&n)&&(256&n&&(n-=256),512&n&&(n-=512),1024&n&&(n-=1024),2048&n&&(n-=2048),4096&n&&(n-=4096),65536&n&&(n-=65536)),1===t){var o=decodeURIComponent(Q("dp2groupid").value);null!=(a=meshes[o])&&meshserver.send({action:"addmeshuser",meshid:o,meshname:a.name,userids:[currentUser._id],meshadmin:n,remove:2==e})}else if(2===t){var i=decodeURIComponent(Q("dp2groupid").value);null!=(a=meshes[currentMesh._id])&&meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,userid:i,meshadmin:n,remove:2==e})}else if(3===t){var a;o=decodeURIComponent(Q("dp2groupid").value);null!=(a=meshes[o])&&meshserver.send({action:"addmeshuser",meshid:o,meshname:a.name,userids:[currentUserGroup._id],meshadmin:n,remove:2==e})}else if(4===t){null!=(c=getNodeFromId(d=decodeURIComponent(Q("dp2nodeid").value)))&&meshserver.send({action:"adddeviceuser",nodeid:d,nodename:c.name,userids:[currentUser._id],rights:n,remove:2==e})}else if(5===t){var s=Q("dp20username").value.split(","),r=[];for(var l in s)r.push(s[l].trim());meshserver.send({action:"adddeviceuser",nodeid:currentNode._id,nodename:currentNode.name,usernames:r,rights:n,remove:2==e})}else if(6===t){i=decodeURIComponent(Q("dp2groupid").value);null!=currentNode&&meshserver.send({action:"adddeviceuser",nodeid:currentNode._id,nodename:currentNode.name,userids:[i],rights:n,remove:2==e})}else if(7===t){var d,c;null!=(c=getNodeFromId(d=decodeURIComponent(Q("dp2nodeid").value)))&&meshserver.send({action:"adddeviceuser",nodeid:d,nodename:c.name,userids:[currentUserGroup._id],rights:n,remove:2==e})}else if(null==t){s=Q("dp20username").value.split(","),r=[];for(var l in s)r.push(s[l].trim());meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,usernames:r,meshadmin:n,remove:2==e})}else meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,userids:[t],meshadmin:n,remove:2==e})}function p20viewuser(e){if(!xxdialogMode){var t=decodeURIComponent(e),n=GetMeshRights(currentMesh),o=GetMeshRights(currentMesh,t);if(userinfo._id!=t&&(4294967295==n||0!=(2&n)&&4294967295!=o))p20showAddMeshUserDialog(e);else{var i=[];4294967295==o?i.push("Full Administrator (all rights)"):(0!=(1&o)&&i.push("Edit Device Group"),0!=(2&o)&&i.push("Manage Device Group Users"),0!=(4&o)&&i.push("Manage Device Group Computers"),0!=(8&o)&&i.push("Remote Control"),0!=(16&o)&&i.push("Agent Console"),0!=(32&o)&&i.push("Server Files"),0!=(64&o)&&i.push("Wake Devices"),0!=(128&o)&&i.push("Edit Notes"),0!=(8&o)&&0!=(256&o)&&i.push("Remote View Only"),0!=(8&o)&&0!=(65536&o)&&i.push("No Desktop"),0!=(8&o)&&0!=(512&o)&&i.push("No Terminal"),0!=(8&o)&&0!=(1024&o)&&i.push("No Files"),0!=(8&o)&&0!=(2048&o)&&i.push("No Intel&reg; AMT"),0!=(8&o)&&0!=(4096&o)&&0==(256&o)&&i.push("Limited Input"),0!=(8192&o)&&i.push("Self Events Only"),0!=(16384&o)&&i.push("Chat & Notify"),0!=(32768&o)&&i.push("Uninstall")),0==i.length&&i.push("No Rights");var a=t.split("/")[2];users&&users[t]&&(a=users[t].name),userinfo._id==t&&(a=userinfo.name);var s=1,r=addHtmlValue("User Name",EscapeHtml(decodeURIComponent(a)));t.split("/")[2]!=a&&(r+=addHtmlValue("User Identifier",EscapeHtml(t.split("/")[2]))),r+=addHtmlValue("Permissions",i.join(", ")),userinfo._id!=t&&(4294967295==n||0!=(2&n)&&4294967295!=o)&&(s+=4),setDialogMode(2,"Device Group User",s,p20viewuserEx,r,t)}}}function p20viewuserEx(e,t){if(2==e){var n=t.split("/")[2];users&&users[t]&&(n=users[t].name),usergroups&&usergroups[t]&&(n=usergroups[t].name),userinfo._id==t&&(n=userinfo.name),t.startsWith("user/")&&setDialogMode(2,"Remove User Permissions",3,p20viewuserEx2,format('Confirm removal of rights for user "{0}"?',EscapeHtml(decodeURIComponent(n))),t),t.startsWith("ugrp/")&&setDialogMode(2,"Remove User Group Permissions",3,p20viewuserEx2,format('Confirm removal of rights for user group "{0}"?',EscapeHtml(decodeURIComponent(n))),t)}}function p20deleteUser(e,t){return haltEvent(e),p20viewuserEx(2,decodeURIComponent(t)),!1}function p20viewuserEx2(e,t){meshserver.send({action:"removemeshuser",meshid:currentMesh._id,meshname:currentMesh.name,userid:t})}function p20editmeshInviteCode(){if(xxdialogMode)return!1;var e,t=GetMeshRights(currentMesh),n=serverinfo.name;(-1!=n.indexOf(".")&&0==(2&features)||(n=window.location.hostname),1==serverinfo.https)?e="https://"+n+(443==serverinfo.port?"":":"+serverinfo.port)+domainUrl+"invite":e="http://"+n+(80==serverinfo.port?"":":"+serverinfo.port)+domainUrl+"invite";if(1&t){var o="When enabled, invitation codes can be used by anyone to join devices to this device group using the following public link:<br /><br />";o+='<div style=width:100%;text-align:center><a target=_blank href="'+e+'">'+e+"</a></div><br />",o+="<div style=margin-bottom:5px><label><input id=agentJoinCheck type=checkbox onclick=p20editmeshInviteCodeValidate() />Enable Invite Codes</label></div>",o+=addHtmlValue("Invite Codes",'<input id=agentInviteCode style=width:236px onkeyup=p20editmeshInviteCodeValidate() placeholder="code1, code2, code3" />'),setDialogMode(2,"Invite Codes",3,p20editmeshInviteCodeEx,o+=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>")),null!=currentMesh.invite&&(Q("agentJoinCheck").checked=!0,Q("agentInviteCode").value=currentMesh.invite.codes.join(", "),Q("agentInviteType").value=3&currentMesh.invite.flags),p20editmeshInviteCodeValidate()}else{o="Invitation codes can be used by anyone to join devices to this device group using the following public link:<br /><br />";o+='<div style=width:100%;text-align:center><a target=_blank href="'+e+'">'+e+"</a></div><br />",o+=addHtmlValue("Invite Codes",currentMesh.invite.codes.join(", ")),setDialogMode(2,"Invite Codes",1,null,o+=addHtmlValue("Installation Type",["Background and interactive","Background only","Interactive only"][3&currentMesh.invite.flags]))}}function p20editmeshInviteCodeValidate(){var e=!0,t=Q("agentInviteCode").value.split(",");for(var n in t)t[n]=t[n].trim(),""==t[n]&&(e=!1);QE("agentInviteCode",Q("agentJoinCheck").checked),QE("agentInviteType",Q("agentJoinCheck").checked),QE("idx_dlgOkButton",0==Q("agentJoinCheck").checked||e)}function p20editmeshInviteCodeEx(){if(1==Q("agentJoinCheck").checked){var e=Q("agentInviteCode").value.split(",");for(var t in e)e[t]=e[t].trim();meshserver.send({action:"editmesh",meshid:currentMesh._id,invite:{codes:e,flags:parseInt(Q("agentInviteType").value)}})}else meshserver.send({action:"editmesh",meshid:currentMesh._id,invite:"*"})}function p20editMeshNotify(){if(xxdialogMode)return!1;var e=0;userinfo.links&&userinfo.links[currentMesh._id]&&userinfo.links[currentMesh._id].notify&&(e=userinfo.links[currentMesh._id].notify);return"<div><label><input id=p20notifyIntelDeviceConnect type=checkbox />Device connections.</label></div>","<div><label><input id=p20notifyIntelDeviceDisconnect type=checkbox />Device disconnections.</label></div>","<div><label><input id=p20notifyIntelAmtKvmActions type=checkbox />Intel&reg; AMT desktop and serial events.</label></div>",setDialogMode(2,"Notification Settings",3,p20editMeshNotifyEx,"Notification settings must also be turned on in account settings.<br /><br /><div><label><input id=p20notifyIntelDeviceConnect type=checkbox />Device connections.</label></div><div><label><input id=p20notifyIntelDeviceDisconnect type=checkbox />Device disconnections.</label></div><div><label><input id=p20notifyIntelAmtKvmActions type=checkbox />Intel&reg; AMT desktop and serial events.</label></div>"),Q("p20notifyIntelDeviceConnect").checked=2&e,Q("p20notifyIntelDeviceDisconnect").checked=4&e,Q("p20notifyIntelAmtKvmActions").checked=8&e,!1}function p20editMeshNotifyEx(){var e=0;e+=Q("p20notifyIntelDeviceConnect").checked?2:0,e+=Q("p20notifyIntelDeviceDisconnect").checked?4:0,e+=Q("p20notifyIntelAmtKvmActions").checked?8:0,meshserver.send({action:"changemeshnotify",meshid:currentMesh._id,notify:e})}function setupMeshSummaryStats(){var n=Chart.controllers.doughnut.prototype.draw;Chart.controllers.doughnut=Chart.controllers.doughnut.extend({draw:function(){n.apply(this,arguments);var e=this.chart.chart.ctx,t=e.fill;e.fill=function(){e.save(),e.shadowColor="blue",e.shadowBlur=10,e.shadowOffsetX=2,e.shadowOffsetY=2,t.apply(this,arguments),e.restore()}}}),window.meshPowerChart=new Chart(document.getElementById("meshPowerChart").getContext("2d"),{type:"doughnut",data:{datasets:[{data:[0,0],backgroundColor:["#20F","#40D","#60B","#809","#A07","#C05"]}]},options:{responsive:!0,legend:{position:"none"},animation:{animateScale:!0,animateRotate:!0},layout:{padding:{left:10,right:10,top:10,bottom:10}}}}),window.meshOsChart=new Chart(document.getElementById("meshOsChart").getContext("2d"),{type:"doughnut",data:{datasets:[{data:[0,0],backgroundColor:["#20F","#40D","#60B","#809","#A07","#C05"]}]},options:{responsive:!0,legend:{position:"none"},animation:{animateScale:!0,animateRotate:!0},layout:{padding:{left:10,right:10,top:10,bottom:10}}}}),window.meshConnChart=new Chart(document.getElementById("meshConnChart").getContext("2d"),{type:"doughnut",data:{datasets:[{data:[0,0],backgroundColor:["#20F","#40D","#60B","#809","#A07","#C05"]}],labels:["Not Connected","Agent","Intel AMT","Agent + Intel AMT"]},options:{responsive:!0,legend:{position:"none"},animation:{animateScale:!0,animateRotate:!0},layout:{padding:{left:10,right:10,top:10,bottom:10}}}})}function p21updateMesh(){if(null!=currentMesh){var e=GetMeshRights(currentMesh),t=EscapeHtml(currentMesh.name);0==t.length&&(t="<i>None</i>"),0!=(1&e)&&(t='<span tabindex=0 title="Click here to edit the device group name" onclick=p20editmesh(1) onkeyup="if (event.key == \'Enter\') p20editmesh(1)" style=cursor:pointer>'+t+' <img class=hoverButton src="images/link5.png" /></span>'),QH("p21meshName",t);var n={},o={},i=[0,0,0,0],a=!1,s=!1,r=!1;for(var l in nodes)nodes[l].meshid==currentMesh._id&&(nodes[l].agent&&(a=!0,null==n[nodes[l].agent.id]?n[nodes[l].agent.id]=1:n[nodes[l].agent.id]++),nodes[l].pwr&&(s=!0,null==o[nodes[l].pwr]?o[nodes[l].pwr]=1:o[nodes[l].pwr]++),0==nodes[l].conn?(r=!0,i[0]++):0!=(6&nodes[l].conn)?(r=!0,0!=(1&nodes[l].conn)?i[3]++:i[2]++):0!=(1&nodes[l].conn)&&(r=!0,i[1]++));var d=[],c=[],u=[],p=[];for(var l in n)d.push(n[l]),c.push(agentsStr[l]);for(var l in o)u.push(o[l]),p.push(powerStatetable[l]);window.meshPowerChart.config.data.datasets[0].data=u,window.meshPowerChart.config.data.labels=p,window.meshPowerChart.update(),2==currentMesh.mtype&&(window.meshOsChart.config.data.datasets[0].data=d,window.meshOsChart.config.data.labels=c,window.meshOsChart.update()),window.meshConnChart.config.data.datasets[0].data=i,window.meshConnChart.update();var m="",g=0;if(0<u.length){var h=[];for(var l in o)h.push([powerStatetable[l],o[l]]);for(var l in h.sort(function(e,t){return-(e[1]-t[1])}),m+='<table style="margin-top:10px;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>Power States</th><th scope=col style=text-align:left></th></tr>',h)m+="<tr style="+(++g%2==0?"background-color:#DDD":"")+"><td><divclass=m2></div><div>&nbsp;"+h[l][0]+"<div></div></div></td><td><div style=float:right>"+h[l][1]+" </div><div></div></td></tr>";m+="</tbody></table>"}if(0<d.length&&2==currentMesh.mtype){g=0;var v=[];for(var l in n)v.push([agentsStr[l],n[l]]);for(var l in v.sort(function(e,t){return-(e[1]-t[1])}),m+='<table style="margin-top:10px;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>Agent Types</th><th scope=col style=text-align:left></th></tr>',v)m+="<tr style="+(++g%2==0?"background-color:#DDD":"")+"><td><divclass=m2></div><div>&nbsp;"+v[l][0]+"<div></div></div></td><td><div style=float:right>"+v[l][1]+" </div><div></div></td></tr>";m+="</tbody></table>"}if(r){var f=[];for(l=g=0;l<4;l++)f.push([["Not Connected","Agent","Intel AMT","Agent + Intel AMT"][l],i[l]]);f.sort(function(e,t){return-(e[1]-t[1])}),m+='<table style="margin-top:10px;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>Connectivity</th><th scope=col style=text-align:left></th></tr>';for(l=0;l<4;l++)0<f[l][1]&&(m+="<tr style="+(++g%2==0?"background-color:#DDD":"")+"><td><divclass=m2></div><div>&nbsp;"+f[l][0]+"<div></div></div></td><td><div style=float:right>"+f[l][1]+" </div><div></div></td></tr>");m+="</tbody></table>"}""==m&&(m="<i>No devices in this device group.</i>"),QH("p21info",m),QS("meshPowerChartDiv").display=s?"inline-block":"none",QS("meshOsChartDiv").display=2==currentMesh.mtype&&a?"inline-block":"none",QS("meshConnChartDiv").display=r?"inline-block":"none"}}var sortorder,filetreelocation=[];function updateFiles(){if(QV("MainMenuMyFiles",0==(8&features)),0==(8&features)){for(var e,t="",n="",o='<a href=# style=cursor:pointer onclick="return p5folderup(0)">Root</a>',i="Root",a=filetree,s=1,r=[],l=filetreelinkpath,d=[],c=document.getElementsByName("fc"),u=0;u<c.length;u++)c[u].checked&&d.push(c[u].value);for(var u in filetreelinkpath="",filetreelocation){if(null==a.f||null==a.f[filetreelocation[u]])break;if(r.push(filetreelocation[u]),i+=" / "+filetreelocation[u],1==s){var p=filetreelocation[u].split("/");e=(""+window.location).split("?")[0]+p[0]+"files/"+p[2],filetreelinkpath+=filetreelocation[u]}else""!=filetreelinkpath&&(filetreelinkpath+="/"+filetreelocation[u],2<s&&(e+="/"+filetreelocation[u]));o+=' / <a href=# style=cursor:pointer onclick="return p5folderup('+s+')">'+(null!=(a=a.f[filetreelocation[u]]).n?a.n:filetreelocation[u])+"</a>",s++}filetreelocation=r;var m=i.toLowerCase().startsWith("root / "+userinfo._id+" / public"),g=p5sort_files(a.f);for(var u in g){var h,v=g[u],f=v.n;h=70<(h=f).length?'<span title="'+EscapeHtml(f)+'">'+EscapeHtml(f.substring(0,70))+"...</span>":EscapeHtml(f),f=EscapeHtml(f);var k="";if(null!=v.d)k=printDateTime(new Date(v.d))+"&nbsp;";var x="";null!=v.s&&(x=getFileSizeStr(v.s));var y="";if(v.t<3||4==v.t){y='<div class=filelist file=999><input file=999 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value="'+f+'">&nbsp;<span style=float:right title="">'+(1==v.t||4==v.t?p5getQuotabar(v):"")+"</span><span><div class=fileIcon"+v.t+' onclick=p5folderset("'+encodeURIComponentEx(v.nx)+'")></div><a href=# style=cursor:pointer onclick=\'return p5folderset("'+encodeURIComponentEx(v.nx)+"\")'>"+h+"</a></span></div>"}else{var b=h,w="";m&&(w='<img src="images/link2.png" style=cursor:pointer title="Display public link" onclick=\'return p5showPublicLink("'+e+"/"+encodeURIComponentEx(v.nx)+'?download=1")\' width=10 height=10 /> <img src="images/link4.png" title="Copy link to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(e+"/"+encodeURIComponentEx(v.nx)+"?download=1")+'") width=10 height=10>'),0<v.s&&(b=w+' <a rel="noreferrer noopener" target="_blank" download href="downloadfile.ashx?link='+encodeURIComponentEx(filetreelinkpath+"/"+v.nx)+'">'+h+"</a>"),y='<div class=filelist file=3><input file=3 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value="'+v.nx+'">&nbsp;<span class=fsize>'+k+"</span><span style=float:right>"+x+"</span><span><div class=fileIcon"+v.t+"></div>"+b+"</span></div>"}v.t<3?t+=y:n+=y}if(QH("p5rightOfButtons",p5getQuotabar(a)),QH("p5files",t+n),QH("p5currentpath",o),QE("p5FolderUp",0!=filetreelocation.length),QV("p5PublicShare",m),l==filetreelinkpath){c=document.getElementsByName("fc");for(u=0;u<c.length;u++)c[u].checked=0<=d.indexOf(c[u].value)}p5setActions()}}function getNiceSize(e){return e<=0?"Storage limit exceed":e<2048?format("{0} bytes remaining",e):e<2097152?format("{0} kilobytes remaining",Math.round(e/1024)):e<2147483648?format("{0} megabytes remaining",Math.round(e/1024/1024)):format("{0} gigabytes remaining",Math.round(e/1024/1024/1024))}function getNiceSize2(e){return e<=0?"None":e<2048?format("{0} b",e):e<2097152?format("{0} Kb",Math.round(e/1024)):e<2147483648?format("{0} Mb",Math.round(e/1024/1024)):format("{0} Gb",Math.round(e/1024/1024/1024))}function p5getQuotabar(e){for(;1<e.t&&4!=e.t;)e=e.parent;if(1!=e.t&&4!=e.t||null==e.maxbytes)return"";var t=Math.floor(e.s/1024),n=e.maxbytes-e.s;return'<span title="'+(1<e.c?format("{0}k in {1} files. {2}k maximum",t,e.c,Math.floor(e.maxbytes/1024/1024)):format("{0}k in 1 file. {1}k maximum",t,Math.floor(e.maxbytes/1024/1024)))+'">'+getNiceSize(n)+" <progress style=height:10px;width:100px value="+e.s+" max="+e.maxbytes+" /></span>"}function p5showPublicLink(e){return setDialogMode(2,"Public Link",1,null,'<input type=text style=width:350px value="'+e+'" readonly /> <img src="images/link4.png" title="Copy link to clipboard" style="cursor:pointer" onclick=copyTextToClip2("'+encodeURIComponentEx(e)+'") width=10 height=10>'),!1}function p5sort_filename(e,t){return e.ln>t.ln?1*sortorder:e.ln<t.ln?-1*sortorder:0}function p5sort_timestamp(e,t){return e.d>t.d?1*sortorder:e.d<t.d?-1*sortorder:0}function p5sort_bysize(e,t){return e.s==t.s?p5sort_filename(e,t):(e.s-t.s)*sortorder}function p5sort_files(e){var t=[],n=Q("p5sortdropdown").value;for(var o in e)e[o].nx=o,null==e[o].n&&(e[o].n=o),e[o].ln=e[o].n.toLowerCase(),t.push(e[o]);return sortorder=1,3<n&&(sortorder=-1,n-=3),1==n?t.sort(p5sort_filename):2==n?t.sort(p5sort_bysize):3==n&&t.sort(p5sort_timestamp),t}function p5setActions(){var e=getFileSelCount(),t=getFileCount(),n=getFileSelCount(!1);QE("p5DeleteFileButton",0<e&&0<filetreelocation.length),QE("p5NewFolderButton",0<filetreelocation.length),QE("p5UploadButton",0<filetreelocation.length),QE("p5RenameFileButton",1==e&&0<filetreelocation.length),QE("p5SelectAllButton",0<t),Q("p5SelectAllButton").value=0<e?"Select None":"Select All",QE("p5CutButton",0<n&&e==n),QE("p5CopyButton",0<n&&e==n),QE("p5PasteButton",null!=p5clipboard&&0<p5clipboard.length&&0<filetreelocation.length)}function getFileSelCount(e){for(var t=0,n=document.getElementsByName("fc"),o=0;o<n.length;o++)!n[o].checked||0==e&&"3"!=n[o].attributes.file.value||t++;return t}function getFileSelDirCount(){for(var e=0,t=document.getElementsByName("fc"),n=0;n<t.length;n++)t[n].checked&&"999"==t[n].attributes.file.value&&e++;return e}function getFileCount(){return document.getElementsByName("fc").length}function p5selectallfile(){for(var e=0==getFileSelCount(),t=document.getElementsByName("fc"),n=0;n<t.length;n++)t[n].checked=e;p5setActions()}function setupBackPointers(e){if(null!=e.f){var t=0,n=0;for(var o in e.f)setupBackPointers(e.f[o]),(e.f[o].parent=e).f[o].s&&(t+=e.f[o].s),e.f[o].c&&(n+=e.f[o].c),3==e.f[o].t&&n++;e.s=t,e.c=n}return e}function getFileSizeStr(e){return 1==e?"1 byte":format("{0} bytes",e)}function p5folderup(e){if(null==e)filetreelocation.pop();else for(;filetreelocation.length>e;)filetreelocation.pop();return updateFiles(),!1}function p5folderset(e){return filetreelocation.push(decodeURIComponent(e)),updateFiles(),!1}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 e=getFileSelCount(),t=0<getFileSelDirCount()?"<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,1<e?format("Delete {0} selected items?",e)+t:"Delete selected item?"+t)}function p5deletefileEx(){for(var e=[],t=document.getElementsByName("fc"),n=0;n<t.length;n++)t[n].checked&&e.push(t[n].value);meshserver.send({action:"fileoperation",fileop:"delete",path:filetreelocation,delfiles:e,rec:Q("p5recdeleteinput").checked})}function p5renamefile(){for(var e,t=document.getElementsByName("fc"),n=0;n<t.length;n++)t[n].checked&&(e=t[n].value);setDialogMode(2,"Rename",3,p5renamefileEx,'<input type=text id=p5renameinput maxlength=64 onkeyup=p5fileNameCheck(event) style=width:100% value="'+e+'" />',{action:"fileoperation",fileop:"rename",path:filetreelocation,oldname:e}),focusTextBox("p5renameinput"),p5fileNameCheck()}function p5renamefileEx(e,t){t.newname=Q("p5renameinput").value,meshserver.send(t)}function p5fileNameCheck(e){var t=isFilenameValid(Q("p5renameinput").value);QE("idx_dlgOkButton",t),1==t&&e&&13==e.keyCode&&dialogclose(1)}var isFilenameValid=function(){var t=/^[^\\/:\*\?"<>\|]+$/,n=/^\./,o=/^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i;return function(e){return t.test(e)&&!n.test(e)&&!o.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="'+encodeURIComponentEx(filetreelinkpath)+'" /><input type=file name=files id=p5uploadinput style=width:100% multiple=multiple onchange="p5updateUploadDialogOk(\'p5uploadinput\')" /><input type=hidden name=authCookie value='+authCookie+" /><input type=submit id=p5loginSubmit style=display:none /><span id=p5confirmOverwriteSpan style=display:none><br /><label><input type=checkbox id=p5confirmOverwrite onchange=\"p5updateUploadDialogOk('p5uploadinput')\" />Confirm overwrite?</label></span></form>"),p5updateUploadDialogOk("p5uploadinput")}function p5uploadFileEx(){Q("p5loginSubmit").click()}function p5updateUploadDialogOk(){var e=Q("p5uploadinput").files,t=[];for(var n in e)null!=e[n].size&&0!=e[n].size&&t.push(e[n]);var o=filetree,i=[],a=0;for(var n in filetreelocation)null!=o.f&&null!=o.f[filetreelocation[n]]&&(o=o.f[filetreelocation[n]]);if(QE("idx_dlgOkButton",0<e.length),0<e.length){if(null!=o.f){for(var n in o.f)i.push(n);for(n=0;n<e.length;n++)0<=i.indexOf(e[n].name)&&a++}QV("p5confirmOverwriteSpan",0<a),0<a?QE("idx_dlgOkButton",Q("p5confirmOverwrite").checked):(Q("p5confirmOverwrite").checked=!1,QE("idx_dlgOkButton",!0))}}var p5clipboard=null,p5clipboardFolder=null,p5clipboardCut=0;function p5copyFile(e){var t=document.getElementsByName("fc");p5clipboard=[],p5clipboardCut=e,p5clipboardFolder=Clone(filetreelocation);for(var n=0;n<t.length;n++)t[n].checked&&"3"==t[n].attributes.file.value&&(console.log("yy",t[n].value),p5clipboard.push(t[n].value));p5updateClipview()}function p5pasteFile(){var e="";null!=p5clipboard&&0<p5clipboard.length&&(e=format("Confim {0} of {1} entrie{2} to this location?",0==p5clipboardCut?"copy":"move",p5clipboard.length,1<p5clipboard.length?"s":"")),setDialogMode(2,"Paste",3,p5pasteFileEx,e)}function p5pasteFileEx(){meshserver.send({action:"fileoperation",fileop:0==p5clipboardCut?"copy":"move",scpath:p5clipboardFolder,path:filetreelocation,names:p5clipboard}),p5folderup(999),1==p5clipboardCut&&(p5clipboardFolder=p5clipboard=null,p5clipboardCut=0,p5updateClipview())}function p5updateClipview(){var e="";null!=p5clipboard&&0<p5clipboard.length&&(e=format("Holding {0} entrie{1} for {2}",p5clipboard.length,1<p5clipboard.length?"s":"",0==p5clipboardCut?"copy":"move")+', <a href=# onclick="return p5clearClip()" style=cursor:pointer>Clear</a>.'),QH("p5bottomstatus",e),p5setActions()}function p5clearClip(){return p5clipboardFolder=p5clipboard=null,p5clipboardCut=0,p5updateClipview(),!1}function p5fileDragDrop(e){if(!xxdialogMode&&(haltEvent(e),QV("bigfail",!1),QV("bigok",!1),null!=e.dataTransfer)){var t=[];for(var n in e.dataTransfer.files)null!=e.dataTransfer.files[n].size&&0!=e.dataTransfer.files[n].size&&t.push(e.dataTransfer.files[n]);if(0!=t.length){var o=filetree,i=[],a=0;for(var n in filetreelocation)null!=o.f&&null!=o.f[filetreelocation[n]]&&(o=o.f[filetreelocation[n]]);if(null!=o.f){for(var n in o.f)i.push(n);for(n=0;n<e.dataTransfer.files.length;n++)0<=i.indexOf(e.dataTransfer.files[n].name)&&a++}0==a?p5PerformUpload(1,t):setDialogMode(2,"Upload File",3,p5PerformUpload,format(1==a?"Upload will overwrite 1 file. Continue?":"Upload will overwrite {0} files. Continue?",a),t)}}}function p5PerformUpload(e,t){var n=0;p5uploadFile();try{Q("p5uploadinput").files=t}catch(e){n=1}if(0==n&&p5uploadFileEx(),setDialogMode(0),1==n){if(0==filetreelocation.length)return;for(var o=[],i=[],a=[],s=[],r=t.length,l=0,d=0;d<t.length;d++)l+=t[d].size;if(13e5<l)return void p5uploadFile();for(d=0;d<t.length;d++){var c=new FileReader,u=t[d];o.push(u.name),i.push(u.size),a.push(u.type),c.onload=function(e){s.push(e.target.result),0==--r&&(Q("p5fileDragName").value=o.join("*"),Q("p5fileDragSize").value=i.join("*"),Q("p5fileDragType").value=a.join("*"),Q("p5fileDragData").value=s.join("*"),Q("p5fileDragLink").value=encodeURIComponentEx(filetreelinkpath),Q("p5fileDragAuthCookie").value=authCookie,Q("p5loginSubmit2").click())},c.readAsDataURL(u)}}}var p5dragtimer=null;function p5fileDragOver(e){if(!xxdialogMode){haltEvent(e),null!=p5dragtimer&&(clearTimeout(p5dragtimer),p5dragtimer=null);var t=!0;0==filetreelocation.length&&(t=!1),QV("bigok",t),QV("bigfail",!t)}}function p5fileDragLeave(e){xxdialogMode||(haltEvent(e),"p5filetable"!=e.target.id?(QV("bigfail",!1),QV("bigok",!1)):p5dragtimer=setTimeout(function(){QV("bigfail",!1),QV("bigok",!1),p5dragtimer=null},10))}function eventMouseHover(e,t){e.children[1].classList.remove("g1s"),e.children[2].classList.remove("style10s"),e.children[3].classList.remove("g2s"),1==t&&(e.children[1].classList.add("g1s"),e.children[2].classList.add("style10s"),e.children[3].classList.add("g2s"))}function eventsUpdate(){var e="",t=null;for(var n in events){var o=events[n],i=new Date(o.time);if(o.msg){null==o.h&&(o.h=Math.random()),printDate(i)!=t&&(null!=t&&(e+="</table>"),e+="<table class=p3eventsTable cellpadding=0 cellspacing=0><tr><td colspan=4 class=DevSt>"+(t=printDate(i))+"</td></tr>");var a="si3";"ugrp"==o.etype&&(a="m4"),"user"==o.etype&&(a="m2"),"server"==o.etype&&(a="si3");var s=EscapeHtml(o.msg).split("(R)").join("&reg;");if(o.nodeid){var r=getNodeFromId(o.nodeid);null!=r&&(a="si"+r.icon,s="<a href=# onclick='gotoDevice(\""+o.nodeid+"\",10);haltEvent(event);'>"+EscapeHtml(r.name)+"</a> &rarr; "+s)}o.username&&(s=2&userinfo.siteadmin&&o.userid?"<a href=# onclick='gotoUser(\""+encodeURIComponentEx(o.userid)+"\");haltEvent(event);'>"+EscapeHtml(o.username)+"</a> &rarr; "+s:EscapeHtml(o.username)+" &rarr; "+s),"relay"!=o.etype&&"relaylog"!=o.action||(a="relayIcon16"),e+="<tr onclick=showEventDetails("+o.h+",2)  onmouseover=eventMouseHover(this,1) onmouseout=eventMouseHover(this,0) style=cursor:pointer><td style=width:18px><div class="+a+"></div></td><td class=g1>&nbsp;</td><td class=style10>"+printTime(i)+" - "+s+"</td><td class=g2>&nbsp;</td></tr><tr style=height:2px></tr>"}}null!=t&&(e+="</table>"),""==e&&(e="<br><i>No Events Found</i><br><br>"),QH("p3events",e)}function refreshEvents(){meshserver.send({action:"events",limit:parseInt(p3limitdropdown.value)})}function p3showDownloadEventsDialog(e){if(!xxdialogMode){var t="Download the list of events with one of the file formats below.<br /><br />";t+=addHtmlValue("CSV Format",'<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogCSV('+e+')">eventslist.csv</a>'),setDialogMode(2,"Event List Export",1,null,t+=addHtmlValue("JSON Format",'<a href=# style=cursor:pointer onclick="return p3downloadEventsDialogJSON('+e+')">eventslist.json</a>'),e)}}function p3downloadEventsDialogCSV(e){var t,n;for(var o in 1==e&&(n=currentDeviceEvents),2==e&&(n=events),3==e&&(n=currentUserEvents),t="utc, time, type, action, user, device, message\r\n",n){var i="";if(n[o].nodeid){var a=getNodeFromId(n[o].nodeid);a&&a.name&&(i=a.name)}t+='"'+n[o].time+'","'+printDateTime(new Date(n[o].time))+'","'+n[o].etype+'","'+(null!=n[o].action?n[o].action:"")+'","'+(null!=n[o].username?n[o].username:"")+'","'+EscapeHtml(i)+'","'+(null!=n[o].msg?n[o].msg:"").split(",").join(" -")+'"\r\n'}return saveAs(new Blob([t],{type:"application/octet-stream"}),"eventslist.csv"),!1}function p3downloadEventsDialogJSON(e){var t,n=[];for(var o in 1==e&&(t=currentDeviceEvents),2==e&&(t=events),3==e&&(t=currentUserEvents),t)n.push(events[o]);return saveAs(new Blob([JSON.stringify(n,null,2)],{type:"application/octet-stream"}),"eventslist.json"),!1}function updateUsers(){if(QV("UserNewAccountButton",0==(4&features)&&0==serverinfo.domainauth),null!=users&&0==(4&features)){var e=[],t=100,n=0;for(var o in users)e.push(users[o]);e.sort(nameSort);var i=Q("UserSearchInput").value.toLowerCase(),a=i;i.startsWith("email:")?(i=null,a=a.substring(6)):i.startsWith("name:")?(a=null,i=i.substring(5)):i.startsWith("e:")?(i=null,a=a.substring(2)):i.startsWith("n:")&&(a=null,i=i.substring(2));var s="<table class=p3usersTable cellpadding=0 cellspacing=0>",r=!0;s+="<th>Name<th style=width:80px>Device Groups<th style=width:120px>"+nobreak("Last Access")+"<th style=width:120px>Permissions";var l=[],d=document.getElementsByClassName("UserCheckbox");for(o=0;o<d.length;o++)d[o].checked&&l.push(d[o].value);for(var o in e){var c=e[o],u=null;null!=wssessions&&(u=wssessions[c._id]),null!=u&&(null!=i&&(""==i||0<=c.name.toLowerCase().indexOf(i))||null!=a&&null!=c.email&&0<=c.email.toLowerCase().indexOf(a))&&(0<t?(r&&(s+="<tr><td class=userTableHeader colspan=4>Online Users",r=!1),s+=addUserHtml(c,u),t--):n++)}for(var o in r=!0,e){c=e[o],u=null;null!=wssessions&&(u=wssessions[c._id]),null==u&&(null!=i&&(""==i||0<=c.name.toLowerCase().indexOf(i))||null!=a&&null!=c.email&&0<=c.email.toLowerCase().indexOf(a))&&(0<t?(r&&(s+="<tr><td class=userTableHeader colspan=4>Offline Users",r=!1),s+=addUserHtml(c,u),t--):n++)}s+="</table>",1==n?s+="<br />1 more user not shown, use search box to look for users...<br />":1<n&&(s+="<br />"+format("{0} more users not shown, use search box to look for users...",n)+"<br />"),100==t&&(s+="<br />No users found.<br />"),QH("p3users",s),d=document.getElementsByClassName("UserCheckbox");var p=encodeURIComponentEx(userinfo._id);for(o=0;o<d.length;o++)d[o].checked=0<=l.indexOf(d[o].value)&&d[o].value!=p;p3updateInfo(),null!=currentUser&&30==xxcurrentView&&gotoUser(encodeURIComponentEx(currentUser._id),!0)}else QH("p3users","")}function addUserHtml(e,t){var n="",o=" gray",i="",a=e._id!=userinfo._id,s="",r="";null!=t?(o="",a&&(i='<span style=float:right;margin-top:1px;margin-right:4px title=Chat><a href=# onclick=userChat(event,"'+encodeURIComponentEx(e._id)+'","'+encodeURIComponentEx(e.name)+"\")><img src='images/icon-chat.png' height=16 width=16 style=padding-top:2px /></a></span>",i+="<span style=float:right;margin-top:1px;margin-left:4px;margin-right:4px title=Notify><a href=# onclick='return showUserAlertDialog(event,\""+encodeURIComponentEx(e._id)+"\")'><img src='images/icon-notify.png' height=16 width=16 style=padding-top:2px /></a></span>"),s+=nobreak(1==t?"1 session":format("{0} sessions",t))):e.login&&(s+='<span title="'+format("Last login: {0}",printDateTime(new Date(1e3*e.login)))+'">'+printDate(new Date(1e3*e.login))+"</span>"),a&&(r+="<a href=# style=cursor:pointer onclick='return showUserAdminDialog(event,\""+encodeURIComponentEx(e._id)+"\")'>"),null!=e.siteadmin&&0!=(32&e.siteadmin)&&4294967295!=e.siteadmin&&(r+="Locked,&nbsp;"),r+="<span title='Server Permissions'>";var l=4294967071&e.siteadmin;null==e.siteadmin||0==l?r+="User":8==l?r+="User + Files":4294967295==e.siteadmin?r+="Administrator":r+=0!=(2&l)?"Manager":"Partial",null!=e.siteadmin&&4294967295!=e.siteadmin&&0!=(192&e.siteadmin)&&(r+="*"),r+="</span>",a&&(r+="</a>");var d=0;if(e.links)for(var c in e.links)c.startsWith("mesh/")&&d++;var u=EscapeHtml(e.name),p="";if(1==serverinfo.emailcheck&&(p=1!=e.emailVerified?' <b style=color:red title="Email is not verified">&#x2717;</b>':' <b style=color:green title="Email is verified">&#x2713</b>'),null!=e.email&&(0==(2097152&features)||e.email.toLowerCase()!=e.name.toLowerCase()?u+=', <a href="mailto:'+e.email+"\" '>"+e.email+"</a>"+p:u+=' <a href="mailto:'+e.email+'" \'><img src="images/mail12.png" height=9 width=12 title="Send email to user" style="margin-top:2px" /></a>'+p),null!=serverinfo.crossDomain){var m=e._id.split("/")[1];""!=m&&(u+=", <span style=color:#26F>"+m+"</span>")}return(0<e.otpsecret||0<e.otphkeys||1==e.otpekey&&8388608&features||null!=e.phone&&67108864&features)&&(u+=' <img src="images/key12.png" height=12 width=11 title="2nd factor authentication enabled" style="margin-top:2px" />'),null!=e.phone&&(u+=' <img src="images/phone12.png" height=12 width=7 title="Verified phone number" style="margin-top:2px" />'),null!=e.siteadmin&&0!=(32&e.siteadmin)&&4294967295!=e.siteadmin&&(u+=' <img src="images/padlock12.png" height=12 width=8 title="Account is locked" style="margin-top:2px" />'),n+="<tr tabindex=0 onmouseover=userMouseHover(this,1) onmouseout=userMouseHover(this,0) onkeypress=\"if (event.key=='Enter') gotoUser('"+encodeURIComponentEx(e._id)+"')\"><td>",n+="<div class=bar>",n+="<div class=baricon><input class=UserCheckbox value="+encodeURIComponentEx(e._id)+" onclick=p3updateInfo() type=checkbox"+(e._id==userinfo._id?" disabled":"")+'></div><div style=cursor:pointer onclick=gotoUser("'+encodeURIComponentEx(e._id)+'",false,event)>',n+='<div class=baricon><div class="m2'+o+'"></div></div>',n+="<div class=g1></div><div class=g2></div><div>",n+="<div><span>"+u+"</span>"+i+"</div></div><td style=text-align:center>"+d+"<td style=text-align:center>"+s+"<td style=text-align:center>"+r}function p3updateInfo(){for(var e=document.getElementsByClassName("UserCheckbox"),t=0,n=0;n<e.length;n++)!0===e[n].checked&&t++;QE("UsersGroupActionButton",0<t),Q("UsersSelectAllButton").value=0<t?"Select None":"Select All"}function p3usersSelectallButtonFunction(){for(var e=encodeURIComponentEx(userinfo._id),t=document.getElementsByClassName("UserCheckbox"),n=0,o=0;o<t.length;o++)!0===t[o].checked&&n++;for(o=0;o<t.length;o++)t[o].checked=0==n&&t[o].value!=e;p3updateInfo()}function p3usersGroupActionFunction(){for(var e=document.getElementsByClassName("UserCheckbox"),t=0,n=0;n<e.length;n++)!0===e[n].checked&&t++;if(0!=t){var o="Select an operation to perform on all selected users.<br /><br />";setDialogMode(2,"Group Action",3,p3usersGroupActionFunctionEx,o+=addHtmlValue("Operation","<select style=width:240px id=d3groupop><option value=1>Lock account</option><option value=2>Unlock account</option><option value=3>Delete account</option></select>"))}}function p3usersGroupActionFunctionEx(){for(var e=document.getElementsByClassName("UserCheckbox"),t=[],n=0;n<e.length;n++)!0===e[n].checked&&t.push(decodeURIComponent(e[n].value));var o=Q("d3groupop").value;if(1==o)for(var n in t){0==(32&(a=null==(i=users[t[n]]).siteadmin?0:i.siteadmin))&&(a+=32,meshserver.send({action:"edituser",id:i._id,siteadmin:a}))}else if(2==o)for(var n in t){var i,a;0!=(32&(a=null==(i=users[t[n]]).siteadmin?0:i.siteadmin))&&(a-=32,meshserver.send({action:"edituser",id:i._id,siteadmin:a}))}else if(3==o){"<label><input id=d3check type=checkbox onchange=p3usersGroupActionFunctionDelCheck() />Confirm</label>",setDialogMode(2,"Delete Accounts",3,p3groupActionFunctionDelExec,"Confirm delete selected account(s)?<br /><br /><label><input id=d3check type=checkbox onchange=p3usersGroupActionFunctionDelCheck() />Confirm</label>"),QE("idx_dlgOkButton",!1)}}function p3usersGroupActionFunctionDelCheck(){QE("idx_dlgOkButton",Q("d3check").checked)}function p3groupActionFunctionDelExec(e){for(var t=document.getElementsByClassName("UserCheckbox"),n=[],o=0;o<t.length;o++)!0===t[o].checked&&n.push(decodeURIComponent(t[o].value));for(var o in n){var i=users[n[o]];meshserver.send({action:"deleteuser",userid:i._id,username:i.name})}}function userMouseHover(e,t){var n=e.children[0].children[0].children[1];n.children[1].classList.remove("g1s"),n.children[2].classList.remove("g2s"),e.children[0].children[0].classList.remove("sbar"),1==t&&(n.children[1].classList.add("g1s"),n.children[2].classList.add("g2s"),e.children[0].children[0].classList.add("sbar"))}function userMouseHover2(e,t){var n=e.children[0].children[0];n.children[2].classList.remove("g1s"),n.children[3].classList.remove("g2s"),e.children[0].children[0].classList.remove("sbar"),1==t&&(n.children[2].classList.add("g1s"),n.children[3].classList.add("g2s"),e.children[0].children[0].classList.add("sbar"))}function userChat(e,t,n){haltEvent(e);var o="/messenger?id=meshmessenger/"+t+"/"+encodeURIComponentEx(userinfo._id)+"&title="+n;return null!=authCookie&&""!=authCookie&&(o+="&auth="+authCookie),window.open(o,"meshmessenger:"+t),meshserver.send({action:"meshmessenger",userid:decodeURIComponent(t)}),!1}function showSendSMS(e){xxdialogMode||(setDialogMode(2,"Send SMS",3,showSendSMSEx,"<textarea id=d2smsText maxlength=160 style=background-color:#fcf3cf;width:100%;height:100px;resize:none onKeyUp=showSendSMSValidate()></textarea><span style=font-size:10px><span>",e),Q("d2smsText").focus(),showSendSMSValidate())}function showSendSMSValidate(){QE("idx_dlgOkButton",0<Q("d2smsText").value.length)}function showSendSMSEx(e,t){0<Q("d2smsText").value.length&&meshserver.send({action:"smsuser",userid:decodeURIComponent(t),msg:Q("d2smsText").value})}function showSendEmail(e){if(!xxdialogMode){'<textarea id=d2emailText maxlength=10000 style="background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:auto" onKeyUp=showSendEmailValidate()></textarea>',setDialogMode(2,"Send Email",3,showSendEmailEx,'<input id=d2emailSubject style=background-color:#fcf3cf;width:100% placeholder="Subject"></input><textarea id=d2emailText maxlength=10000 style="background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:auto" onKeyUp=showSendEmailValidate()></textarea>',e),Q("d2emailSubject").focus(),showSendEmailValidate()}}function showSendEmailValidate(){QE("idx_dlgOkButton",0<Q("d2emailSubject").value.length&&0<Q("d2emailText").value.length)}function showSendEmailEx(e,t){0<Q("d2emailText").value.length&&meshserver.send({action:"emailuser",userid:decodeURIComponent(t),subject:Q("d2emailSubject").value,msg:Q("d2emailText").value})}function showUserAlertDialog(e,t){if(!xxdialogMode)return haltEvent(e),setDialogMode(2,format("Notify {0}",EscapeHtml(users[decodeURIComponent(t)].name)),3,showUserAlertDialogEx,'Send a text notification to this user.<textarea id=d2notifyText maxlength=2048 style="width:100%;height:184px;resize:none"></textarea>',t),Q("d2notifyText").focus(),!1}function showUserAlertDialogEx(e,t){meshserver.send({action:"notifyuser",userid:decodeURIComponent(t),msg:Q("d2notifyText").value})}function p4batchAccountCreate(){if(!xxdialogMode){setDialogMode(2,"User Account Import",3,p4batchAccountCreateEx,'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() />'),QE("idx_dlgOkButton",!1)}}function p4batchAccountCreateValidate(){QE("idx_dlgOkButton",null!=Q("d4importFile").value)}function p4batchAccountCreateEx(){var e=new FileReader;e.onload=function(e){var t=null;try{t=JSON.parse(e.target.result)}catch(e){return void setDialogMode(2,"User Account Import",1,null,format("Invalid JSON file: {0}.",e))}if(null!=t&&Array.isArray(t)){var n=!0;for(var o in t)("string"!=typeof t[o].user||t[o].user.length<1||64<t[o].user.length)&&(n=!1),("string"!=typeof t[o].pass||t[o].pass.length<1||256<t[o].pass.length)&&(n=!1),0==checkPasswordRequirements(t[o].pass,passRequirements)&&(n=!1),null!=t[o].email&&("string"!=typeof t[o].email||t[o].email.length<1||128<t[o].email.length)&&(n=!1);0==n?setDialogMode(2,"User Account Import",1,null,"Invalid JSON file format."):meshserver.send({action:"adduserbatch",users:t})}else setDialogMode(2,"User Account Import",1,null,"Invalid JSON file format.")},e.readAsText(Q("d4importFile").files[0])}function p4downloadUserInfo(){if(!xxdialogMode){var e="Download the list of users with one of the file formats below.<br /><br />";e+=addHtmlValue("CSV Format","<a href=# style=cursor:pointer onclick='return p4downloadUserInfoCSV()'>userlist.csv</a>"),setDialogMode(2,"User List Export",1,null,e+=addHtmlValue("JSON Format","<a href=# style=cursor:pointer onclick='return p4downloadUserInfoJSON()'>userlist.json</a>"))}}function p4downloadUserInfoCSV(){var e="id, name, email, creation, lastlogin, groups, authfactors\r\n";for(var t in users){var n=!1,o=[];(0<users[t].otpsecret||0<users[t].otphkeys)&&(n=!0,0<users[t].otpsecret&&o.push("AuthApp"),0<users[t].otphkeys&&o.push("SecurityKey"),0<users[t].otpkeys&&o.push("BackupCodes")),e+='"'+users[t]._id+'","'+users[t].name+'","'+(users[t].email?users[t].email:"")+'","'+(users[t].creation?new Date(1e3*users[t].creation):"")+'","'+(users[t].login?new Date(1e3*users[t].login):"")+'","'+(users[t].groups?users[t].groups.join(","):"")+'","'+(n?o.join(","):"")+'"\r\n'}return saveAs(new Blob([e],{type:"application/octet-stream"}),"userlist.csv"),!1}function p4downloadUserInfoJSON(){var e=[];for(var t in users)e.push(users[t]);return saveAs(new Blob([JSON.stringify(e,null,2)],{type:"application/octet-stream"}),"userlist.json"),!1}function showUserBroadcastDialog(e){if(!xxdialogMode){setDialogMode(2,"Broadcast Message",3,showUserBroadcastDialogEx,'Broadcast a message to all connected users.<textarea id=broadcastMessage value="" maxlength="256"/></textarea>',e?decodeURIComponent(e):null),Q("broadcastMessage").focus()}}function showUserBroadcastDialogEx(e,t){meshserver.send({action:"userbroadcast",msg:Q("broadcastMessage").value,target:t})}function showCreateNewAccountDialog(){if(!xxdialogMode){var e="";if(serverinfo.crossDomain){var t="<select style=width:240px id=p4domain>";for(var n in serverinfo.crossDomain)t+="<option value="+n+">"+(""==serverinfo.crossDomain[n]?"Default":EscapeHtml(serverinfo.crossDomain[n]))+"</option>";e+=addHtmlValue("Domain",t+="</select>")}if(0==(2097152&features)&&(e+=addHtmlValue("<span id=p4hname>Username</span>","<input id=p4name maxlength=64 autocomplete=username onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />")),e+=addHtmlValue("<span id=p4hemail>Email</span>",'<input id=p4email maxlength=256 autocomplete="email" inputmode="email" onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />'),e+=addHtmlValue("<span id=p4hp1>Password</span>",'<input id=p4pass1 type=password maxlength=256 autocomplete="new-password" onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />'),e+=addHtmlValue("<span id=p4hp2>Password</span>",'<input id=p4pass2 type=password maxlength=256 autocomplete="new-password" onchange=showCreateNewAccountDialogValidate() onkeyup=showCreateNewAccountDialogValidate() />'),e+="<div><label><input id=p4randomPassword onchange=showCreateNewAccountDialogValidate() type=checkbox />Randomize the password.</label></div>",e+="<div><label><input id=p4removeEvents onchange=showCreateNewAccountDialogValidate() type=checkbox />Remove all previous events for this userid.</label></div>",e+="<div><label><input id=p4resetNextLogin onchange=showCreateNewAccountDialogValidate() type=checkbox />Force password reset on next login.</label></div>",serverinfo.emailcheck&&(e+="<div><label><input id=p4verifiedEmail onchange=showCreateNewAccountDialogValidate() type=checkbox />Email is verified.</label></div>",e+="<div><label><input id=p4invitationEmail type=checkbox title=Email verified and forced password reset required. />Send invitation email.</label></div>"),passRequirements){var o=[],i=0;for(var n in passRequirements)"reset"!=n&&"hint"!=n&&(o.push(n+":"+passRequirements[n]),i++);0<i&&(e+="<div style=font-size:x-small;padding:6px>"+format("Requirements: {0}.",o.join(", "))+"</div>")}setDialogMode(2,"Create Account",3,showCreateNewAccountDialogEx,e),showCreateNewAccountDialogValidate(),0==(2097152&features)?Q("p4name").focus():Q("p4email").focus()}}function showCreateNewAccountDialogValidate(){var e=validateEmail(Q("p4email").value),t=!0,n=0<Q("p4pass1").value.length&&Q("p4pass1").value==Q("p4pass2").value&&checkPasswordRequirements(Q("p4pass1").value,passRequirements);0==(2097152&features)&&(t=!Q("p4name")||0<Q("p4name").value.length&&-1==Q("p4name").value.indexOf(" "),QS("p4hname").color=t?"black":"#7b241c"),QS("p4hemail").color=e?"black":"#7b241c",serverinfo.emailcheck&&(QE("p4verifiedEmail",e),QE("p4invitationEmail",e&&Q("p4resetNextLogin").checked&&Q("p4verifiedEmail").checked),0==e&&(Q("p4verifiedEmail").checked=!1),0!=Q("p4resetNextLogin").checked&&0!=Q("p4verifiedEmail").checked||(Q("p4invitationEmail").checked=!1)),QE("p4pass1",!Q("p4randomPassword").checked),QE("p4pass2",!Q("p4randomPassword").checked),QS("p4hp1").color=n||Q("p4randomPassword").checked?"black":"#7b241c",QS("p4hp2").color=n||Q("p4randomPassword").checked?"black":"#7b241c";var o=t&e;0==Q("p4randomPassword").checked&&(o&=n),QE("idx_dlgOkButton",o)}function showCreateNewAccountDialogEx(){var e={action:"adduser",username:0==(2097152&features)?Q("p4name").value:Q("p4email").value,email:Q("p4email").value,pass:Q("p4pass1").value,resetNextLogin:Q("p4resetNextLogin").checked,randomPassword:Q("p4randomPassword").checked,removeEvents:Q("p4removeEvents").checked};serverinfo.emailcheck&&(e.emailVerified=Q("p4verifiedEmail").checked,e.emailInvitation=Q("p4invitationEmail").checked),serverinfo.crossDomain&&(e.domain=serverinfo.crossDomain[parseInt(Q("p4domain").value)]),meshserver.send(e)}function showUserGroupDialog(e,t){if(!xxdialogMode){haltEvent(e),t=decodeURIComponent(t);var n=users[t.toLowerCase()],o="";null!=n.groups&&(o=n.groups.join(", "));var i="Enter a comma seperate list of administrative realms names.<br /><br />";return setDialogMode(2,"Administrative Realms",3,showUserGroupDialogEx,i+=addHtmlValue("Realms",'<input id=dp4usergroups style=width:230px value="'+o+'" placeholder="Name1, Name2, Name3" maxlength=256 onchange=p4validateUserGroups() onkeyup=p4validateUserGroups() />'),n),focusTextBox("dp4usergroups"),p4validateUserGroups(),!1}}function p4validateUserGroups(){var e=Q("dp4usergroups").value,t=0,n=e.indexOf('"')+e.indexOf("/")+e.indexOf(">")+e.indexOf("<")+e.indexOf("'"),o=e.split(",");for(var i in o)0==o[i].trim().length&&t++;QE("idx_dlgOkButton",""==e||-5==n&&t<1)}function showUserGroupDialogEx(e,t){var n=Q("dp4usergroups").value.split(","),o=[];for(var i in n){var a=n[i].trim();0<a.length&&o.push(a)}meshserver.send({action:"edituser",id:t._id,groups:o})}function showUserAdminDialog(e,t){if(!xxdialogMode){haltEvent(e),t=decodeURIComponent(t);var n=users[t.toLowerCase()];if(null!=n){var o=userinfo._id==n._id;return"<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/>","<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_fulladmin>Full Administrator</label><br>","<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverbackup>Server Backup</label><br>","<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverrestore>Server Restore</label><br>","<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverupdate>Server Updates</label><br>","<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_manageusers>Manage Users</label><br>","<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_manageusergroups>Manage User Groups</label><br>","<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_managerecordings>Manage Recordings</label><br>","<hr/></div><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_lockedaccount>Lock Account</label><br>","<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nonewgroups>No New Device Groups</label><br>","<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nomeshcmd>No Tools (MeshCmd/Router)</label><br>","</div>",setDialogMode(2,"Server Permissions",2+(o?0:1),showUserAdminDialogEx,"<div><div id=d2AdminPermissions><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/><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_fulladmin>Full Administrator</label><br><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverbackup>Server Backup</label><br><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverrestore>Server Restore</label><br><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_serverupdate>Server Updates</label><br><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_manageusers>Manage Users</label><br><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_manageusergroups>Manage User Groups</label><br><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_managerecordings>Manage Recordings</label><br><hr/></div><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_lockedaccount>Lock Account</label><br><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nonewgroups>No New Device Groups</label><br><label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nomeshcmd>No Tools (MeshCmd/Router)</label><br></div>",n),n.siteadmin&&0!=n.siteadmin&&(Q("ua_fulladmin").checked=4294967295==n.siteadmin,Q("ua_serverbackup").checked=4294967295!=n.siteadmin&&0!=(1&n.siteadmin),Q("ua_manageusers").checked=4294967295!=n.siteadmin&&0!=(2&n.siteadmin),Q("ua_serverrestore").checked=4294967295!=n.siteadmin&&0!=(4&n.siteadmin),Q("ua_fileaccess").checked=4294967295!=n.siteadmin&&0!=(8&n.siteadmin),Q("ua_serverupdate").checked=4294967295!=n.siteadmin&&0!=(16&n.siteadmin),Q("ua_lockedaccount").checked=4294967295!=n.siteadmin&&0!=(32&n.siteadmin),Q("ua_nonewgroups").checked=4294967295!=n.siteadmin&&0!=(64&n.siteadmin),Q("ua_nomeshcmd").checked=4294967295!=n.siteadmin&&0!=(128&n.siteadmin),Q("ua_manageusergroups").checked=4294967295!=n.siteadmin&&0!=(256&n.siteadmin),Q("ua_managerecordings").checked=4294967295!=n.siteadmin&&0!=(512&n.siteadmin)),QE("ua_fulladmin",!o&&4294967295==userinfo.siteadmin),QE("ua_serverbackup",!o&&4294967295==userinfo.siteadmin),QE("ua_manageusers",!o&&4294967295==userinfo.siteadmin),QE("ua_manageusergroups",!o&&4294967295==userinfo.siteadmin),QE("ua_managerecordings",!o&&4294967295==userinfo.siteadmin),QE("ua_serverrestore",!o&&4294967295==userinfo.siteadmin),QE("ua_fileaccess",!o&&4294967295==userinfo.siteadmin),QE("ua_fileaccessquota",!o&&4294967295==userinfo.siteadmin),QE("ua_serverupdate",!o&&4294967295==userinfo.siteadmin),QV("d2AdminPermissions",4294967295==userinfo.siteadmin),QE("ua_lockedaccount",!o&&2&userinfo.siteadmin&&4294967295!=n.siteadmin&&userinfo._id!=n._id),QE("ua_nonewgroups",!o&&2&userinfo.siteadmin&&4294967295!=n.siteadmin&&userinfo._id!=n._id),QE("ua_nomeshcmd",!o&&2&userinfo.siteadmin&&4294967295!=n.siteadmin&&userinfo._id!=n._id),Q("ua_fileaccessquota").value=null!=n.quota?n.quota/1024:"",showUserAdminDialogValidate(),!1}}}function showUserAdminDialogValidate(){4294967295==userinfo.siteadmin&&(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_manageusergroups",!Q("ua_fulladmin").checked&&Q("ua_manageusers").checked),QE("ua_fileaccessquota",Q("ua_fileaccess").checked&&!Q("ua_fulladmin").checked),QE("ua_managerecordings",!Q("ua_fulladmin").checked))}function showUserAdminDialogEx(e,t){var n=0,o=parseInt(Q("ua_fileaccessquota").value);1==Q("ua_fulladmin").checked?n=4294967295:(1==Q("ua_serverbackup").checked&&(n+=1),1==Q("ua_manageusers").checked&&(n+=2),1==Q("ua_serverrestore").checked&&(n+=4),1==Q("ua_fileaccess").checked&&(n+=8),1==Q("ua_serverupdate").checked&&(n+=16),1==Q("ua_lockedaccount").checked&&(n+=32),1==Q("ua_nonewgroups").checked&&(n+=64),1==Q("ua_nomeshcmd").checked&&(n+=128),1==Q("ua_manageusergroups").checked&&(n+=256),1==Q("ua_managerecordings").checked&&(n+=512));var i={action:"edituser",id:t._id,siteadmin:n};0==isNaN(o)&&(i.quota=1024*o),meshserver.send(i)}function onUserSearchInputChanged(){masterUpdate(16384)}function updateUserGroups(){var e=[],t="";if(usergroups)for(var n in usergroups)e.push(usergroups[n]);e.sort(nameSort);var o=[],i=document.getElementsByClassName("UserGroupCheckbox");for(n=0;n<i.length;n++)i[n].checked&&o.push(i[n].value);if(0==e.length)t+="<br />No groups found.<br />",QV("DuplicateUserGroupButton",!1);else{for(var n in t+="<table class=p3usersTable cellpadding=0 cellspacing=0>",t+="<th>Name<th style=width:80px>Users<th style=width:80px>Device Groups<th style=width:80px>Devices",e)t+=addUserGroupHtml(e[n]);t+="</table>",QV("DuplicateUserGroupButton",!0)}QH("p50groups",t),i=document.getElementsByClassName("UserGroupCheckbox");for(n=0;n<i.length;n++)i[n].checked=0<=o.indexOf(i[n].value);p50updateInfo(),null!=currentUserGroup&&51==xxcurrentView&&gotoUserGroup(encodeURIComponentEx(currentUserGroup._id),!0)}function addUserGroupHtml(e){var t=0,n=0,o=0;if(e.links)for(var i in e.links)i.startsWith("user/")&&t++,i.startsWith("mesh/")&&n++,i.startsWith("node/")&&o++;var a=EscapeHtml(e.name);if(null!=serverinfo.crossDomain){var s=e._id.split("/")[1];""!=s&&(a+=", <span style=color:#26F>"+EscapeHtml(s)+"</span>")}var r="<tr tabindex=0 onmouseover=userMouseHover2(this,1) onmouseout=userMouseHover2(this,0) onkeypress=\"if (event.key=='Enter') gotoUserGroup('"+encodeURIComponentEx(e._id)+"')\"><td style=cursor:pointer>";return r+="<div class=bar style=width:100%>",r+="<div class=baricon><input class=UserGroupCheckbox value="+encodeURIComponentEx(e._id)+" onclick=p50updateInfo() type=checkbox></div>",r+='<div class=baricon onclick=gotoUserGroup("'+encodeURIComponentEx(e._id)+'")><div class=m4></div></div>',r+='<div class=g1 onclick=gotoUserGroup("'+encodeURIComponentEx(e._id)+'")></div><div class=g2 onclick=gotoUserGroup("'+encodeURIComponentEx(e._id)+'")></div>',r+='<div onclick=gotoUserGroup("'+encodeURIComponentEx(e._id)+'")><span style=font-size:16px>'+a+"</span></div></div><td style=text-align:center>"+t+"<td style=text-align:center>"+n+"<td style=text-align:center>"+o}function p50updateInfo(){for(var e=document.getElementsByClassName("UserGroupCheckbox"),t=0,n=0;n<e.length;n++)!0===e[n].checked&&t++;QE("UsersGroupsGroupActionButton",0<t),Q("UsersGroupsSelectAllButton").value=0<t?"Select None":"Select All"}function p50usersSelectallButtonFunction(){for(var e=encodeURIComponentEx(userinfo._id),t=document.getElementsByClassName("UserGroupCheckbox"),n=0,o=0;o<t.length;o++)!0===t[o].checked&&n++;for(o=0;o<t.length;o++)t[o].checked=0==n&&t[o].value!=e;p50updateInfo()}function p50usersGroupActionFunction(){for(var e=document.getElementsByClassName("UserGroupCheckbox"),t=0,n=0;n<e.length;n++)!0===e[n].checked&&t++;if(0!=t){var o="Select an operation to perform on all selected users.<br /><br />";setDialogMode(2,"Group Action",3,p50usersGroupActionFunctionEx,o+=addHtmlValue("Operation","<select style=width:240px id=d50groupop><option value=1>Delete group</option></select>"))}}function p50usersGroupActionFunctionEx(){for(var e=document.getElementsByClassName("UserGroupCheckbox"),t=[],n=0;n<e.length;n++)!0===e[n].checked&&t.push(decodeURIComponent(e[n].value));if(1==Q("d50groupop").value){"<label><input id=d3check type=checkbox onchange=p50usersGroupActionFunctionDelCheck() />Confirm</label>",setDialogMode(2,"Delete User Groups",3,p50groupActionFunctionDelExec,"Confirm delete selected user groups(s)?<br /><br /><label><input id=d3check type=checkbox onchange=p50usersGroupActionFunctionDelCheck() />Confirm</label>"),QE("idx_dlgOkButton",!1)}}function p50usersGroupActionFunctionDelCheck(){QE("idx_dlgOkButton",Q("d3check").checked)}function p50groupActionFunctionDelExec(e){for(var t=document.getElementsByClassName("UserGroupCheckbox"),n=0;n<t.length;n++)!0===t[n].checked&&meshserver.send({action:"deleteusergroup",ugrpid:decodeURIComponent(t[n].value)})}function showCreateUserGroupDialog(e){if(!xxdialogMode){var t="",n="";if(2==e){if(usergroups)for(var o in usergroups)n+="<option value="+encodeURIComponentEx(o)+">"+EscapeHtml(usergroups[o].name)+"</option>";t+=addHtmlValue("User Group","<div style=width:230px;margin:0;padding:0><select id=dp4groupid style=width:100%>"+n+"</select></div>")}if(1==e&&serverinfo.crossDomain){n="<select style=width:240px id=p4domain>";for(var o in serverinfo.crossDomain)n+="<option value="+o+">"+(""==serverinfo.crossDomain[o]?"Default":EscapeHtml(serverinfo.crossDomain[o]))+"</option>";t+=addHtmlValue("Domain",n+="</select>")}t+=addHtmlValue("Name","<input id=p4name maxlength=64 onchange=showCreateUserGroupDialogValidate() onkeyup=showCreateUserGroupDialogValidate() />"),setDialogMode(2,1==e?"Create User Group":"Duplicate User Group",3,showCreateUserGroupDialogEx,t+=addHtmlValue("Description",'<textarea id=p4desc value="" style=width:230px;height:60px;resize:none maxlength=1024 /></textarea>'),e),showCreateUserGroupDialogValidate(),Q("p4name").focus()}}function showCreateUserGroupDialogValidate(){QE("idx_dlgOkButton",0<Q("p4name").value.length)}function showCreateUserGroupDialogEx(e,t){var n={action:"createusergroup",name:Q("p4name").value,desc:Q("p4desc").value};2==t&&(n.clone=decodeURIComponent(Q("dp4groupid").value)),1==t&&serverinfo.crossDomain&&(n.domain=serverinfo.crossDomain[parseInt(Q("p4domain").value)]),meshserver.send(n)}var currentUserGroup=null;function gotoUserGroup(e,t){if(!xxdialogMode||t){var n=currentUserGroup=usergroups?usergroups[decodeURIComponent(e)]:null;if(null!=n){var o=EscapeHtml(n.name);0==o.length&&(o="<i>None</i>"),0!=(256&userinfo.siteadmin)&&(o='<span tabindex=0 title="Click here to edit the user group name" onclick=p51editgroup(1) onkeyup="if (event.key == \'Enter\') p51editgroup(1)" style=cursor:pointer>'+o+' <img class=hoverButton src="images/link5.png" /></span>'),QH("p51groupName",o);var i=0,a=0,s=0;if(n.links)for(var r in n.links)r.startsWith("user/")&&i++,r.startsWith("mesh/")&&a++,r.startsWith("node/")&&s++;var l=n.desc;l=null==l||""==l?"<i>None<i>":EscapeHtml(l);var d="<div style=min-height:80px><table style=width:100%>";if(0!=(8&args.hide)&&(d+="<br />"+addDeviceAttribute("Name",o)),null!=serverinfo.crossDomain||0!=debugmode){var c=n._id.split("/")[1];d+=addDeviceAttribute("Domain",""!=c?EscapeHtml(c):"<i>Default</i>"),d+=addDeviceAttribute("Group Identifier",EscapeHtml(n._id))}0!=(256&userinfo.siteadmin)?d+=addDeviceAttribute("Description","<span onclick=p51editgroup(2) style=cursor:pointer>"+l+' <img class=hoverButton src="images/link5.png" /></span>'):d+=addDeviceAttribute("Description",l),d+=addDeviceAttribute("Users",i),d+=addDeviceAttribute("Device Groups",a),d+=addDeviceAttribute("Devices",s),d+="</table></div><br />",0!=(256&userinfo.siteadmin)&&(d+='<input type=button value="Broadcast" title="Send a notice to all users in this group." onclick=showUserBroadcastDialog("'+encodeURIComponentEx(n._id)+'") />'),QH("p51group",d),d="<br />",0!=(256&userinfo.siteadmin)&&(d+='<a href=# onclick="return p51showAddUserDialog()" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add Users</a>'),d+='<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>Group Members</th><th scope=col style=text-align:left></th></tr>';var u=1,p=[];for(var r in currentUserGroup.links)if(0!=r.startsWith("user/")){var m=r.split("/")[2];currentUserGroup.links[r].name&&(m=currentUserGroup.links[r].name),r==userinfo._id&&(m=userinfo.name),p.push({id:r,name:m,rights:currentUserGroup.links[r].rights})}for(var r in p.sort(function(e,t){return e.name>t.name?1:e.name<t.name?-1:0}),p){var g="<a href=# onclick='return p51deleteUser(event,\""+encodeURIComponentEx(p[r].id)+'")\' title="Remove user rights to this device group" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>',h=EscapeHtml(decodeURIComponent(p[r].name));null!=users&&(h="<a href=# onclick='gotoUser(\""+encodeURIComponentEx(p[r].id)+"\");haltEvent(event);'>"+h+"</a>"),d+="<tr "+(u%2==0?"style=background-color:#DDD":"")+'><td><div title="User" class=m2></div><div>&nbsp;'+h+"<div></div></div></td><td><div style=float:right>"+g+"</div></td></tr>",++u}1==u&&(d+="<tr><td><div style=padding:6px>&nbsp;<i>No Members</i><div></div></div></td><td></td></tr>"),d+="</tbody></table><br />";var v=0,f=!(u=1);for(var r in meshes)currentUserGroup._id.split("/")[1]==meshes[r]._id.split("/")[1]&&(v++,null!=currentUserGroup.links&&null!=currentUserGroup.links[r]||(f=!0));if(0<v&&f&&(d+='<a href=# onclick="return p20showAddMeshUserDialog(3)" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add Device Group</a>'),d+='<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>Common Device Groups</th><th scope=col style=text-align:left></th></tr>',currentUserGroup.links){var k=[];for(var r in currentUserGroup.links)r.startsWith("mesh/")&&null!=meshes[r]&&k.push(meshes[r]);for(var r in k=getOrderedList(k,"name")){var x=0,y=k[r],b=(g="",makeDeviceGroupRightsString(currentUserGroup.links[y._id].rights));userinfo.links&&null!=userinfo.links[y._id]&&null!=userinfo.links[y._id].rights&&(x=userinfo.links[y._id].rights);var w="<i>Unknown Device Group</i>";y&&(w="<a href=# onclick='gotoMesh(\""+y._id+"\");haltEvent(event);'>"+y.name+"</a>"),0!=(2&x)&&(g="<a href=# onclick='return p51removeMeshFromUserGroup(event,\""+encodeURIComponentEx(y._id)+'")\' title="Remove user group rights to this device group" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>',b='<span style=cursor:pointer onclick=p20showAddMeshUserDialog(3,"'+encodeURIComponentEx(y._id)+'")>'+b+" <img class=hoverButton style=cursor:pointer src=images/link5.png></span>"),d+="<tr "+(++u%2==0?"style=background-color:#DDD":"")+'><td style=width:30%><div title="Device Group" class=m99></div><div>&nbsp;'+w+"<div></div></div></td><td style=width:70%><div style=float:right>"+g+"</div><div>"+b+"</div></td></tr>"}}if(1==u&&(d+="<tr><td><div style=padding:6px>&nbsp;<i>No device groups in common</i><div></div></div></td><td></td></tr>"),d+="</tbody></table>",u=1,d+="<br />",currentUserGroup._id.split("/")[1]==userinfo._id.split("/")[1]&&(d+='<a href=# onclick="return p20showAddMeshUserDialog(7)" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add Device</a>'),d+='<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>Common Devices</th><th scope=col style=text-align:left></th></tr>',currentUserGroup.links){var C=[];for(var r in currentUserGroup.links){if(r.startsWith("node/"))null!=(D=getNodeFromId(r))&&C.push(D)}for(var r in C=getOrderedList(C,"name")){var D=C[r],S=(g="",b=makeUserDeviceRightsString(currentUserGroup.links[D._id].rights),x=GetNodeRights(D),"<i>Unknown Device</i>");D&&(S="<a href=# onclick='gotoDevice(\""+D._id+"\");haltEvent(event);'>"+D.name+"</a>"),0!=(2&x)&&(g="<a href=# onclick='return p51removeDeviceFromUserGroup(event,\""+encodeURIComponentEx(D._id)+'")\' title="Remove user group rights to this device" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>',b='<span style=cursor:pointer onclick=p20showAddMeshUserDialog(7,"'+encodeURIComponentEx(D._id)+'")>'+b+" <img class=hoverButton style=cursor:pointer src=images/link5.png></span>"),d+="<tr "+(++u%2==0?"style=background-color:#DDD":"")+'><td style=width:30%><div title="Device Group" class=m99></div><div>&nbsp;'+S+"<div></div></div></td><td style=width:70%><div style=float:right>"+g+"</div><div>"+b+"</div></td></tr>"}}1==u&&(d+="<tr><td><div style=padding:6px>&nbsp;<i>No devices in common</i><div></div></div></td><td></td></tr>"),d+="</tbody></table>",0!=(256&userinfo.siteadmin)&&(d+="<div style=font-size:x-small;text-align:right><span><a href=# onclick=p51showDeleteUserGroupDialog() style=cursor:pointer>Delete User Group</a></span></div>"),QH("p51group2",d),go(51);var M="";if(0==(268435456&features)&&51<=xxcurrentView&&xxcurrentView<=59&&null!=currentUserGroup){for(var r in M="?viewmode="+xxcurrentView+"&gotougrp="+(serverinfo.crossDomain?currentUserGroup._id:currentUserGroup._id.split("/")[2]),urlargs)M+="&"+r+"="+urlargs[r];try{window.history.replaceState({},document.title,window.location.pathname+M)}catch(e){}}}else 51==xxcurrentView&&(setDialogMode(0),go(50))}}function p51removeDeviceFromUserGroup(e,t){if(!xxdialogMode){var n=getNodeFromId(decodeURIComponent(t));null!=n&&setDialogMode(2,"Remove Device Permissions",3,p51removeDeviceFromUserGroupEx,format('Confirm removal of access rights for device "{0}"?',n.name),n._id)}}function p51removeDeviceFromUserGroupEx(e,t){meshserver.send({action:"adddeviceuser",nodeid:t,userids:[currentUserGroup._id],rights:0,remove:!0})}function p51removeMeshFromUserGroup(e,t){if(!xxdialogMode){var n=meshes[decodeURIComponent(t)];null!=n&&setDialogMode(2,"Remove Device Group Permissions",3,p51removeMeshFromUserGroupEx,format('Confirm removal of access rights for device group "{0}"?',n.name),n._id)}}function p51removeMeshFromUserGroupEx(e,t){meshserver.send({action:"removemeshuser",meshid:t,userid:currentUserGroup._id})}function p51editgroup(e){if(!xxdialogMode){var t=addHtmlValue("Name","<input id=dp51name style=width:230px maxlength=32 onchange=p51editgroupValidate() onkeyup=p51editgroupValidate(event) />");setDialogMode(2,"Edit User Group",3,p51editgroupEx,t+=addHtmlValue("Description","<div style=width:230px;margin:0;padding:0><textarea id=dp51desc maxlength=1024 style=width:100%;resize:none></textarea></div>")),Q("dp51name").value=currentUserGroup.name,currentUserGroup.desc&&(Q("dp51desc").value=currentUserGroup.desc),p51editgroupValidate(),2==e?Q("dp51desc").focus():Q("dp51name").focus()}}function p51editgroupEx(){meshserver.send({action:"editusergroup",ugrpid:currentUserGroup._id,name:Q("dp51name").value,desc:Q("dp51desc").value})}function p51editgroupValidate(e){QE("idx_dlgOkButton",0<Q("dp51name").value.length),e&&"Enter"==e.key&&Q("dp51desc").focus()}function p51showDeleteUserGroupDialog(){if(xxdialogMode)return!1;var e=format("Delete user group {0}?",EscapeHtml(currentUserGroup.name))+"<br /><br />";return setDialogMode(2,"Delete User Group",3,p51showDeleteUserGroupDialogEx,e+="<label><input id=p51check type=checkbox onchange=p51validateDeleteGroupDialog() />Confirm</label>"),p51validateDeleteGroupDialog(),!1}function p51validateDeleteGroupDialog(){QE("idx_dlgOkButton",Q("p51check").checked)}function p51showDeleteUserGroupDialogEx(e,t){meshserver.send({action:"deleteusergroup",ugrpid:currentUserGroup._id})}function p51deleteUser(e,t){return haltEvent(e),p51viewuserEx(2,decodeURIComponent(t)),!1}function p51viewuserEx(e,t){if(2==e){var n=t.split("/")[2];users&&users[t]&&(n=users[t].name),userinfo._id==t&&(n=userinfo.name),setDialogMode(2,"Remove User Membership",3,p51viewuserEx2,format('Confirm membership removal of user "{0}"?',EscapeHtml(decodeURIComponent(n))),t)}}function p51viewuserEx2(e,t){meshserver.send({action:"removeuserfromusergroup",ugrpid:currentUserGroup._id,userid:t})}function p51showAddUserDialog(){if(xxdialogMode)return!1;var e="Allow users to manage this device group and devices in this group.";return 524288&features&&(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 Identifiers",'<input id=dp51username style=width:230px maxlength=32 onchange=p51validateAddUserDialog() onkeyup=p51validateAddUserDialog() placeholder="user1, user2, user3" />'),e+="<div id=dp51usersuggest class=suggestionBox style='top:30px;left:130px;display:none'></div>",setDialogMode(2,"Add Users to User Group",3,p51showAddUserDialogEx,e+="</div><br>"),Q("dp51username").focus(),p51validateAddUserDialog(),!1}function p51setname(e){e=decodeURIComponent(e);var t=Q("dp51username").value.split(",");for(var n in t)t[n]=t[n].trim();return t[t.length-1]=e,Q("dp51username").value=t.join(", "),p51validateAddUserDialog(),!1}function p51validateAddUserDialog(){var e=!0;if(Q("dp51username")){var t=Q("dp51username").value.split(",");for(var n in t){var o=t[n]=t[n].trim();0==o.length?e=!1:0<=o.indexOf('"')&&(e=!1)}var i=!1,a=!1;if(null!=users){var s=t[t.length-1].trim(),r=s.toLowerCase(),l=[];if(0<s.length){for(var n in users){var d=users[n]._id.split("/");if(currentUserGroup.domain==d[1]&&d[2]===r){a=!0;break}if(0<=users[n].name.toLowerCase().indexOf(r)&&currentUserGroup.domain==d[1]&&(l.push([users[n]._id,users[n].name]),8<=l.length))break}if(0==a&&0<l.length){var c="";for(var n in l){var u=l[n][0],p=l[n][1];u.split("/")[2]==p.toLowerCase()?c+="<div class=suggestionBoxItem onclick='p51setname(\""+encodeURIComponentEx(u.split("/")[2])+"\")'>"+EscapeHtml(p)+"</div>":c+="<div class=suggestionBoxItem onclick='p51setname(\""+encodeURIComponentEx(u.split("/")[2])+"\")'><div>"+EscapeHtml(p)+"</div><div class=suggestionBoxSubItem>"+EscapeHtml(u.split("/")[2])+"</div></div>"}QH("dp51usersuggest",c),i=!0}}}QV("dp51usersuggest",i)}QE("idx_dlgOkButton",e)}function p51showAddUserDialogEx(e,t){if(null==t){var n=Q("dp51username").value.split(","),o=[];for(var i in n)o.push(n[i].trim());meshserver.send({action:"addusertousergroup",ugrpid:currentUserGroup._id,usernames:o})}else meshserver.send({action:"addusertousergroup",ugrpid:currentUserGroup._id,usernames:[t.split("/")[2]]})}var currentUser=null;function gotoUser(e,t,n){if((!xxdialogMode||t)&&(null==n||null==n.originalTarget||null==n.originalTarget.href)){var o=currentUser=users[decodeURIComponent(e)];if(null==o)return setDialogMode(0),void go(4);QH("p30userName",o.name),QH("p31userName",o.name);var i=o._id==userinfo._id,a=0;null!=wssessions&&wssessions[o._id]&&(a=wssessions[o._id]),Q("MainUserImage").classList.remove("gray"),0==a&&Q("MainUserImage").classList.add("gray");var s=o._id.split("/")[2];s.startsWith("~twitter:")?(QV("p30userAuthServiceLogo",!0),Q("p30userAuthServiceLogo").src="images/login/twitter64.png"):s.startsWith("~google:")?(QV("p30userAuthServiceLogo",!0),Q("p30userAuthServiceLogo").src="images/login/google64.png"):s.startsWith("~github:")?(QV("p30userAuthServiceLogo",!0),Q("p30userAuthServiceLogo").src="images/login/github64.png"):s.startsWith("~reddit:")?(QV("p30userAuthServiceLogo",!0),Q("p30userAuthServiceLogo").src="images/login/reddit64.png"):s.startsWith("~azure:")?(QV("p30userAuthServiceLogo",!0),Q("p30userAuthServiceLogo").src="images/login/azure64.png"):s.startsWith("~jumpcloud:")?(QV("p30userAuthServiceLogo",!0),Q("p30userAuthServiceLogo").src="images/login/jumpcloud64.png"):s.startsWith("~intel:")?(QV("p30userAuthServiceLogo",!0),Q("p30userAuthServiceLogo").src="images/login/intel64.png"):s.startsWith("~:")?(QV("p30userAuthServiceLogo",!0),Q("p30userAuthServiceLogo").src="images/login/generic64.png"):QV("p30userAuthServiceLogo",!1);var r=[],l="";null!=o.siteadmin&&0!=(32&o.siteadmin)&&4294967295!=o.siteadmin&&(l='<img src="images/padlock12.png" height=12 width=8 title="Account is locked" style="margin-top:2px" /> ',r.push("Locked account")),null==o.siteadmin||0==(4294967071&o.siteadmin)?r.push("No server rights"):8==o.siteadmin?r.push("Access to server files"):4294967295==o.siteadmin?r.push("Full administrator"):r.push("Partial rights"),null!=o.siteadmin&&4294967295!=o.siteadmin&&0!=(192&o.siteadmin)&&r.push("Restrictions");var d="<div style=min-height:80px><table style=width:100%>";0!=(8&args.hide)&&(d+="<br />"+addDeviceAttribute("Name",o.name));var c=o.email?EscapeHtml(o.email):"<i>Not set</i>",u="";if(serverinfo.emailcheck&&(u=1==o.emailVerified?'<b style=color:green;cursor:pointer title="Email is verified">&#x2713</b> ':'<b style=color:red;cursor:pointer title="Email not verified">&#x2717;</b> '),serverinfo.crossDomain||0!=debugmode){var p=o._id.split("/")[1];d+=addDeviceAttribute("Domain",""!=p?EscapeHtml(p):"<i>Default</i>"),d+=addDeviceAttribute("User Identifier",EscapeHtml(o._id))}else o.name.toLowerCase()!=o._id.split("/")[2]&&(d+=addDeviceAttribute("User Identifier",EscapeHtml(o._id.split("/")[2])));4294967295!=o.siteadmin||4294967295==userinfo.siteadmin?d+=addDeviceAttribute("Email",u+c+' <a href="mailto:'+o.email+'" \'><img class=hoverButton src="images/link1.png" /></a> <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30showUserEmailChangeDialog(event,"'+e+'") />'):d+=addDeviceAttribute("Email",u+c+' <a href="mailto:'+o.email+'" \'><img class=hoverButton src="images/link1.png" /></a>'),(33554432&features||null!=o.phone)&&(d+=addDeviceAttribute("Phone Number",(o.phone?o.phone:"<i>None</i>")+' <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30editPhone() />')),d+=addDeviceAttribute("Server Rights",l+r.join(", ")+" <img style=cursor:pointer class=hoverButton onclick='return showUserAdminDialog(event,\""+e+'")\' src="images/link5.png" />'),o.quota&&(d+=addDeviceAttribute("Server Quota",EscapeHtml(parseInt(o.quota)/1024)+" k")),d+=addDeviceAttribute("Creation",printDateTime(new Date(1e3*o.creation))),o.login&&(d+=addDeviceAttribute("Last Login",printDateTime(new Date(1e3*o.login)))),-1==o.passchange?d+=addDeviceAttribute("Password","Will be changed on next login."):o.passchange&&(d+=addDeviceAttribute("Password",format("Last changed: {0}",printDateTime(new Date(1e3*o.passchange)))));var m=0,g="<i>None<i>";if(o.links){for(var h in o.links)h.startsWith("mesh/")&&m++;1==m?g="1 group":1<m&&(g=format("{0} groups",m))}if(d+=addDeviceAttribute("Device Groups",g),4294967295==userinfo.siteadmin||2&userinfo.siteadmin){var v="<i>None</i>";if(o.groups)for(var h in v="",o.groups)v+='<span class="tagSpan">'+o.groups[h]+"</span>";d+=addDeviceAttribute("Admin Realms",addLinkConditional(v,'showUserGroupDialog(event,"'+e+'")',4294967295==userinfo.siteadmin||null==userinfo.groups&&userinfo._id!=o._id&&4294967295!=o.siteadmin))}var f=[],k=0;o.consent&&(k=o.consent),serverinfo.consent&&(k|=serverinfo.consent),64&k&&8&k?f.push("Desktop Prompt+Toolbar"):64&k?f.push("Desktop Toolbar"):8&k?f.push("Desktop Prompt"):1&k&&f.push("Desktop Notify"),16&k?f.push("Terminal Prompt"):2&k&&f.push("Terminal Notify"),32&k?f.push("Files Prompt"):4&k&&f.push("Files Notify"),7==k&&(f=["Always Notify"]),56==(56&k)&&(f=["Always Prompt"]),""==(f=f.join(", "))&&(f="<i>None</i>"),d+=addDeviceAttribute("User Consent",addLinkConditional(f,"p20editmeshconsent(2)",!0));var x=0;if(0<o.otpsecret||0<o.otphkeys){x=1;var y=[];0<o.otpsecret&&y.push("Authentication App"),0<o.otphkeys&&y.push("Security Key"),0<o.otpkeys&&y.push("Backup Codes"),null!=o.phone&&67108864&features&&y.push("SMS"),d+=addDeviceAttribute("Security",'<img src="images/key12.png" height=12 width=11 title="2nd factor authentication enabled" style="margin-top:2px" /> '+y.join(", "))}d+="</table></div><br />",d+='<input type=button value="Notes" title="View notes about this user" onclick=showNotes(false,"'+e+'") />',o.phone&&33554432&features&&(d+='<input type=button value="SMS" title="Send a SMS message to this user" onclick=showSendSMS("'+e+'") />'),"string"==typeof o.email&&!0===o.emailVerified&&64&features&&(d+='<input type=button value="Email" title="Send a email message to this user" onclick=showSendEmail("'+e+'") />'),!i&&0<a&&(d+='<input type=button value="Notify" title="Send user notification" onclick=showUserAlertDialog(event,"'+e+'") />'),QH("p30html",d),drawUserPermissions();var b=null!=userinfo.siteadmin&&2&userinfo.siteadmin&&4294967295!=o.siteadmin||4294967295==userinfo.siteadmin;d="<div style=float:right;font-size:x-small>",b&&(d+="<a href=# style=cursor:pointer onclick='return p30showDeleteUserDialog()' title=\"Remove this user\">Delete User</a>"),d+="</div><div style=font-size:x-small>",b&&0==(524288&features)&&"~"!=o._id.split("/")[2][0]&&(d+="<a href=# style=cursor:pointer onclick='return p30showUserChangePassDialog("+x+')\' title="Change the password for this user">Change Password</a>'),d+="</div><br>",QH("p30html3",d),d="",1==a?d="1 active session":1<a&&(d=format("{0} active sessions",a)),QH("MainUserState",d),go(30),QH("p31events",""),refreshUsersEvents();var w="";if(0==(268435456&features)&&30<=xxcurrentView&&xxcurrentView<=39&&null!=currentUser){for(var h in w="?viewmode="+xxcurrentView+"&gotouser="+(serverinfo.crossDomain?currentUser._id:currentUser._id.split("/")[2]),urlargs)w+="&"+h+"="+urlargs[h];try{window.history.replaceState({},document.title,window.location.pathname+w)}catch(e){}}}}function p30editPhone(){if(!xxdialogMode){var e='<table style=width:100%><tr><td style=width:56px><img src="images/phone80.png" style=padding:8px>';e+="<td style=width:100%;text-align:center>SMS capable phone number for this user.<br />Leave blank for none.",setDialogMode(2,"Phone Notifications",3,p30editPhoneEx,e+='<br /><br /><div style=width:100%;text-align:center>Phone number: <input type=tel pattern="[0-9]" autocomplete="tel" value="'+(currentUser.phone?currentUser.phone:"")+'" inputmode="tel" maxlength=18 id=d2phoneinput onKeyUp=p30editPhoneValidate() onkeypress="if (event.key==\'Enter\') p30editPhoneValidate(1)"></div></table>',"verifyPhone"),Q("d2phoneinput").focus(),p30editPhoneValidate()}}function p30editPhoneValidate(e){var t=""==Q("d2phoneinput").value||isPhoneNumber(Q("d2phoneinput").value);QE("idx_dlgOkButton",t),1==e&&t&&dialogclose(1)}function p30editPhoneEx(){meshserver.send({action:"edituser",id:currentUser._id,phone:Q("d2phoneinput").value})}function p30showUserEmailChangeDialog(e){if(xxdialogMode)return!1;var t="";return t+=addHtmlValue("Email","<input id=dp30email style=width:230px maxlength=32 onchange=p30validateEmail() onkeyup=p30validateEmail() />"),serverinfo.emailcheck&&(t+=addHtmlValue("Status","<select id=dp30verified style=width:230px onchange=p30validateEmail()><option value=0>Not verified</option><option value=1>Verified</option></select>")),setDialogMode(2,format("Change Email for {0}",EscapeHtml(currentUser.name)),3,p30showUserEmailChangeDialogEx,t),Q("dp30email").focus(),Q("dp30email").value=currentUser.email?currentUser.email:"",serverinfo.emailcheck&&(Q("dp30verified").value=currentUser.emailVerified?1:0),p30validateEmail(),!1}function p30validateEmail(){var e=Q("dp30email").value,t=e.split("@");t=2==t.length&&0<t[0].length&&1<t[1].split(".").length&&2<t[1].length&&e.length<1024&&(e!=userinfo.email||1==serverinfo.emailcheck&&Q("dp30verified").value!=(userinfo.emailVerified?1:0)),QE("idx_dlgOkButton",t)}function p30showUserEmailChangeDialogEx(){var e={action:"edituser",id:currentUser._id,email:Q("dp30email").value};serverinfo.emailcheck&&(e.emailVerified=1==Q("dp30verified").value),meshserver.send(e)}function p30showUserChangePassDialog(e){if(!xxdialogMode){var t="";if(t+=addHtmlValue("Password","<input id=p4pass1 type=password style=width:230px maxlength=256 onchange=p30showUserChangePassDialogValidate(1) onkeyup=p30showUserChangePassDialogValidate(1)></input>"),t+=addHtmlValue("Password","<input id=p4pass2 type=password style=width:230px maxlength=256 onchange=p30showUserChangePassDialogValidate(1) onkeyup=p30showUserChangePassDialogValidate(1)></input>"),65536&features&&(t+=addHtmlValue("Password hint","<input id=p4hint type=text style=width:230px maxlength=256></input>")),passRequirements){var n=[],o=0;for(var i in passRequirements)"reset"!=i&&"hint"!=i&&(n.push(i+":"+passRequirements[i]),o++);0<o&&(t+="<div style=font-size:x-small;padding:6px>"+format("Requirements: {0}.",n.join(", "))+"</div>")}t+="<div><label><input id=p4resetNextLogin type=checkbox />Force password reset on next login.</label></div>",1==e&&(t+="<div><label><input id=p4twoFactorRemove type=checkbox />Remove all 2nd factor authentication.</label></div>"),setDialogMode(2,format("Change Password for {0}",EscapeHtml(currentUser.name)),3,p30showUserChangePassDialogEx,t,e),p30showUserChangePassDialogValidate(),Q("p4pass1").focus(),-1==currentUser.passchange&&(Q("p4resetNextLogin").checked=!0)}}function p30showUserChangePassDialogValidate(){var e=!0;""==Q("p4pass1").value&&""==Q("p4pass2").value||(Q("p4pass1").value!=Q("p4pass2").value?e=!1:passRequirements&&0==checkPasswordRequirements(Q("p4pass1").value,passRequirements)&&(e=!1)),QE("idx_dlgOkButton",e)}function p30showUserChangePassDialogEx(e,t){var n=!1;if(1==t&&1==Q("p4twoFactorRemove").checked&&(n=!0),Q("p4pass1").value==Q("p4pass2").value){var o={action:"changeuserpass",userid:currentUser._id,pass:Q("p4pass1").value,removeMultiFactor:n,resetNextLogin:Q("p4resetNextLogin").checked};65536&features&&(o.hint=Q("p4hint").value),meshserver.send(o)}}function p30showDeleteUserDialog(){xxdialogMode||(setDialogMode(2,format("Delete User {0}",EscapeHtml(currentUser.name)),3,p30showDeleteUserDialogEx,format("Confirm deletion of user {0}?",EscapeHtml(currentUser.name))+"<br /><br /><label><input id=p10check type=checkbox onchange=p10validateDeleteNodeDialog() />Confirm</label>"),p10validateDeleteNodeDialog())}function p30showDeleteUserDialogEx(){meshserver.send({action:"deleteuser",userid:currentUser._id,username:currentUser.name})}function drawUserPermissions(){var e=1,t="",n=0,o=!1;for(var i in meshes)meshes[i]._id.split("/")[1]==currentUser._id.split("/")[1]&&(n++,null!=currentUser.links&&null!=currentUser.links[i]||(o=!0));if(0<n&&o&&(t+='<a href=# onclick="return p20showAddMeshUserDialog(1)" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add Device Group</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>Common Device Groups</th><th scope=col style=text-align:left></th></tr>',currentUser.links){var a=[];for(var i in currentUser.links)i.startsWith("mesh/")&&null!=meshes[i]&&a.push(meshes[i]);for(var i in a=getOrderedList(a,"name")){var s=0,r=a[i],l="",d=makeDeviceGroupRightsString(h=currentUser.links[r._id].rights);if(null!=r){userinfo.links&&null!=userinfo.links[r._id]&&null!=userinfo.links[r._id].rights&&(s=userinfo.links[r._id].rights);var c="<i>Unknown Device Group</i>";r&&(c="<a href=# onclick='gotoMesh(\""+r._id+"\");haltEvent(event);'>"+EscapeHtml(r.name)+"</a>"),currentUser._id!=userinfo._id&&0!=(2&s)&&(l="<a href=# onclick='return p30removeMeshFromUser(event,\""+encodeURIComponentEx(r._id)+'")\' title="Remove user rights to this device group" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>',d='<span style=cursor:pointer onclick=p20showAddMeshUserDialog(1,"'+encodeURIComponentEx(r._id)+'")>'+d+" <img class=hoverButton style=cursor:pointer src=images/link5.png></span>"),t+="<tr "+(++e%2==0?"style=background-color:#DDD":"")+'><td style=width:30%><div title="Device Group" class=m99></div><div>&nbsp;'+c+"<div></div></div></td><td style=width:70%><div style=float:right>"+l+"</div><div>"+d+"</div></td></tr>"}}}if(1==e&&(t+="<tr><td><div style=padding:6px>&nbsp;<i>No device groups in common</i><div></div></div></td><td></td></tr>"),t+="</tbody></table>",null!=usergroups){if(e=1,t+="<br />",0!=(256&userinfo.siteadmin)){var u=0,p=!1;for(var i in usergroups)usergroups[i]._id.split("/")[1]==currentUser._id.split("/")[1]&&(u++,null!=currentUser.links&&null!=currentUser.links[i]||(p=!0));0<u&&p&&(t+='<a href=# onclick="return p30showAddUserGroupDialog()" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add User Group</a>')}if(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 Group Memberships</th><th scope=col style=text-align:left></th></tr>',currentUser.links){var m=[];for(var i in currentUser.links)i.startsWith("ugrp/")&&null!=usergroups[i]&&m.push(usergroups[i]);for(var i in m=getOrderedList(m,"name")){var g=m[i],h=currentUser.links[m[i]._id].rights,v=(l="","<i>Unknown User Group</i>");null!=g&&(v=EscapeHtml(g.name),null!=usergroups&&(v="<a href=# onclick='gotoUserGroup(\""+encodeURIComponentEx(m[i]._id)+"\");haltEvent(event);'>"+v+"</a>")),0!=(256&userinfo.siteadmin)&&(l="<a href=# onclick='return p30RemoveUserGroup(event,\""+encodeURIComponentEx(m[i]._id)+'")\' title="Remove user group membership" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>'),t+="<tr "+(++e%2==0?"style=background-color:#DDD":"")+'><td><div title="User Group" class=m4></div><div>&nbsp;'+v+"<div></div></div></td><td><div style=float:right>"+l+"</div></td></tr>"}}1==e&&(t+="<tr><td><div style=padding:6px>&nbsp;<i>No user group memberships</i><div></div></div></td><td></td></tr>"),t+="</tbody></table>"}if(e=1,t+="<br />",currentUser._id.split("/")[1]==userinfo._id.split("/")[1]&&(t+='<a href=# onclick="return p20showAddMeshUserDialog(4)" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> Add Device</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>Common Devices</th><th scope=col style=text-align:left></th></tr>',currentUser.links){var f=[];for(var i in currentUser.links){if(i.startsWith("node/"))null!=(k=getNodeFromId(i))&&f.push(k)}for(var i in f.sort(nameSort),f){var k=f[i];h=currentUser.links[k._id].rights,l="",s=GetNodeRights(k);userinfo.links&&null!=userinfo.links[i]&&null!=userinfo.links[i].rights&&(s=userinfo.links[i].rights);var x=k?EscapeHtml(k.name):"<i>Unknown Device</i>";0!=(2&s)&&(l="<a href=# onclick='return p30removeNodeFromUser(event,\""+encodeURIComponentEx(k._id)+'")\' title="Remove user rights to this device group" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>',d='<span style=cursor:pointer onclick=p20showAddMeshUserDialog(4,"'+encodeURIComponentEx(k._id)+'")>'+makeUserDeviceRightsString(h)+" <img class=hoverButton style=cursor:pointer src=images/link5.png></span>"),x="<a href=# onclick='gotoDevice(\""+k._id+"\",10);haltEvent(event);'>"+x+"</a>",t+="<tr "+(++e%2==0?"style=background-color:#DDD":"")+'><td style=width:30%><div title="Device" class=si'+k.icon+"></div><div>&nbsp;"+x+"<div></div></div></td><td style=width:70%><div style=float:right>"+l+"</div><div>"+d+"</div></td></tr>"}}1==e&&(t+="<tr><td><div style=padding:6px>&nbsp;<i>No devices in common</i><div></div></div></td><td></td></tr>"),t+="</tbody></table>",QH("p30html2",t)}function p30removeNodeFromUser(e,t){if(!xxdialogMode){var n=getNodeFromId(decodeURIComponent(t));setDialogMode(2,"Remove Device Permissions",3,function(e,t){meshserver.send({action:"adddeviceuser",nodeid:t._id,nodename:t.name,userids:[currentUser._id],rights:0,remove:!0})},format('Confirm removal of access rights for device "{0}"?',n.name),n)}}function p30removeUserFromNode(e,n){if(!xxdialogMode){var t=null,o="";(n=decodeURIComponent(n)).startsWith("user/")?(users&&null!=(t=users[n])&&(o=t.name),setDialogMode(2,"Remove User Permissions",3,function(e,t){meshserver.send({action:"adddeviceuser",nodeid:currentNode._id,nodename:currentNode.name,userids:[n],rights:0,remove:!0})},o?format('Confirm removal of access rights for user "{0}"?',o):"Confirm removal of access rights?",t)):n.startsWith("ugrp/")&&(usergroups&&null!=(t=usergroups[n])&&(o=t.name),setDialogMode(2,"Remove User Group Permissions",3,function(e,t){meshserver.send({action:"adddeviceuser",nodeid:currentNode._id,nodename:currentNode.name,userids:[n],rights:0,remove:!0})},o?format('Confirm removal of access rights for user group "{0}"?',o):"Confirm removal of access rights?",t))}}function p30RemoveUserGroup(e,t){if(!xxdialogMode&&null!=usergroups){var n=decodeURIComponent(t),o=usergroups[n];setDialogMode(2,"Remove User Group Membership",3,p30RemoveUserGroupEx,format('Confirm membership removal of user group "{0}"?',null!=o?EscapeHtml(o.name):"<i>Unknown</i>"),n)}}function p30RemoveUserGroupEx(e,t){meshserver.send({action:"removeuserfromusergroup",ugrpid:t,userid:currentUser._id})}function p30showAddUserGroupDialog(){if(!xxdialogMode&&null!=usergroups){var e="";for(var t in usergroups)usergroups[t]._id.split("/")[1]==currentUser._id.split("/")[1]&&(null!=currentUser.links&&null!=currentUser.links[t]||(e+="<option value="+encodeURIComponentEx(t)+">"+EscapeHtml(usergroups[t].name)+"</option>"));return setDialogMode(2,"Add Membership",3,p30showAddUserGroupDialogEx,addHtmlValue("User Group","<div style=width:230px;margin:0;padding:0><select id=dp2groupid style=width:100%>"+e+"</select></div>")),Q("dp2groupid").focus(),!1}}function p30showAddUserGroupDialogEx(){meshserver.send({action:"addusertousergroup",ugrpid:decodeURIComponent(Q("dp2groupid").value),usernames:[currentUser._id.split("/")[2]]})}function p30removeMeshFromUser(e,t){if(!xxdialogMode){var n=meshes[decodeURIComponent(t)];null!=n&&setDialogMode(2,"Remove Device Group Permissions",3,p30removeMeshFromUserEx,format('Confirm removal of access rights for device group "{0}"?',n.name),n._id)}}function p30removeMeshFromUserEx(e,t){meshserver.send({action:"removemeshuser",meshid:t,userid:currentUser._id})}var currentUserEvents=null;function userEventsUpdate(){if(null!=currentUser){var e="",t=null;for(var n in currentUserEvents){var o=currentUserEvents[n],i=new Date(o.time);if(o.msg){null==o.h&&(o.h=Math.random()),printDate(i)!=t&&(null!=t&&(e+="</table>"),e+="<table class=p3eventsTable cellpadding=0 cellspacing=0><tr><td colspan=4 class=DevSt>"+(t=printDate(i))+"</td></tr>");var a="si3";"user"==o.etype&&(a="m2"),"server"==o.etype&&(a="si3");var s=EscapeHtml(o.msg).split("(R)").join("&reg;");if(o.nodeid){var r=getNodeFromId(o.nodeid);null!=r&&(a="si"+r.icon,s="<a href=# onclick='gotoDevice(\""+o.nodeid+"\",10);haltEvent(event);'>"+EscapeHtml(r.name)+"</a> &rarr; "+s)}o.username&&o.username!=currentUser.name&&(s=2&userinfo.siteadmin&&o.userid?"<a href=# onclick='gotoUser(\""+encodeURIComponentEx(o.userid)+"\");haltEvent(event);'>"+EscapeHtml(o.username)+"</a> &rarr; "+s:EscapeHtml(o.username)+" &rarr; "+s),"relay"!=o.etype&&"relaylog"!=o.action||(a="relayIcon16"),e+="<tr onclick=showEventDetails("+o.h+",3)  onmouseover=eventMouseHover(this,1) onmouseout=eventMouseHover(this,0) style=cursor:pointer><td style=width:18px><div class="+a+"></div></td><td class=g1>&nbsp;</td><td class=style10>"+printTime(i)+" - "+s+"</td><td class=g2>&nbsp;</td></tr><tr style=height:2px></tr>"}}null!=t&&(e+="</table>"),""==e&&(e="<br><i>No Events Found</i><br><br>"),QH("p31events",e)}}function refreshUsersEvents(){meshserver.send({action:"events",limit:parseInt(p31limitdropdown.value),user:currentUser.name})}var d3filetreelinkpath,p52recordings=null;function updateRecordings(){for(var e=[],t=document.getElementsByClassName("RecordingCheckbox"),n=0;n<t.length;n++)t[n].checked&&e.push(t[n].value);var o="<table class=p3usersTable cellpadding=0 cellspacing=0>";if(o+="<th>Session<th style=width:110px>"+nobreak("Start Time")+"<th style=width:110px>Duration<th style=width:110px>Size",null!=p52recordings){var i=null;for(var n in p52recordings){var a=p52recordings[n],s=printDate(new Date(a.time));s!=i&&(o+="<tr><td class=userTableHeader colspan=4>"+(i=s)),o+=addRecordingHtml(n,a)}}o+="</table>",QH("p52recordings",o),t=document.getElementsByClassName("RecordingCheckbox");for(n=0;n<t.length;n++)t[n].checked=0<=e.indexOf(t[n].value);p52updateInfo()}function addRecordingHtml(e,t){var n="";t.lengthTime&&(n=pad2(Math.floor(t.lengthTime/3600))+":"+pad2(Math.floor(t.lengthTime%3600/60))+":"+pad2(Math.floor(t.lengthTime%60)));var o=printTime(new Date(t.time));t.sessionStart&&(o=printTime(new Date(t.sessionStart)));var i="";t.size&&(i=format("{0} Kb",Math.round(t.size/1024)));var a="<i>Unknown</i>";t.name&&t.meshname&&(a=null!=meshes[t.meshid]?"<a href=# onclick='gotoMesh(\""+t.meshid+"\")'>"+EscapeHtml(t.meshname)+"</a> - <a href=# onclick='gotoDevice(\""+t.nodeid+"\",10)'>"+EscapeHtml(t.name)+"</a>":EscapeHtml(t.meshname)+" - "+EscapeHtml(t.name));if(null!=t.userids&&0<t.userids.length)if(1<t.userids.length)a+=" - "+format("{0} users",t.userids.length);else{var s=null;null!=users&&(s=users[t.userids[0]]),a+=null!=s?" - <a href=# onclick='gotoUser(\""+t.userids[0]+"\")'>"+EscapeHtml(s.name)+"</a>":" - "+EscapeHtml(t.userids[0].split("/")[2])}var r="",l="m0";1==t.present&&(l="m1",r="<div style=cursor:pointer;float:right><a href=recordings.ashx?file="+encodeURIComponentEx(t.filename)+' download><img src=images/link4.png height=10 width=10 title="Download Recording" download></a>&nbsp;</div>');var d="<tr tabindex=0 onmouseover=userMouseHover2(this,1) onmouseout=userMouseHover2(this,0) onkeypress=\"if (event.key=='Enter') showRecordingDialog(event,'"+e+"')\"><td style=cursor:pointer>";return d+="<div class=bar style=width:100%>",d+="<div></div>",d+='<div class=baricon onclick=showRecordingDialog(event,"'+e+'")><div class='+l+"></div></div>",d+='<div class=g1 onclick=showRecordingDialog(event,"'+e+'")></div><div class=g2 onclick=showRecordingDialog("'+e+'")></div>',d+='<div onclick=showRecordingDialog(event,"'+e+'")>'+r+"<div style=font-size:16px>"+a+"</div></div></div><td style=text-align:center>"+o+"<td style=text-align:center>"+n+"<td style=text-align:center>"+i}function showRecordingDialog(e,t){if(!xxdialogMode&&"IMG"!=e.target.tagName&&"A"!=e.target.tagName){var n=p52recordings[t],o="";if(n.protocol){var i="Unknown";1==n.protocol&&(i="Terminal"),2==n.protocol&&(i="Desktop"),5==n.protocol&&(i="Files"),100==n.protocol&&(i="Intel AMT WSMAN"),101==n.protocol&&(i="Intel AMT Redirection"),o+=addHtmlValue4("Protocol",i)}if(o+=addHtmlValue4("Status",1==n.present?"Present on server":"Not on server"),n.name&&(o+=addHtmlValue4("Device Name",EscapeHtml(n.name))),n.meshname&&(o+=addHtmlValue4("Device Group",EscapeHtml(n.meshname))),n.size&&(o+=addHtmlValue4("Size",format("{0} bytes",n.size))),n.startTime&&(o+=addHtmlValue4("Start Time",printTime(new Date(n.startTime)))),n.time&&(o+=addHtmlValue4("End Time",printTime(new Date(n.time)))),n.lengthTime&&(o+=addHtmlValue4("Duration",pad2(Math.floor(n.lengthTime/3600))+":"+pad2(Math.floor(n.lengthTime%3600/60))+":"+pad2(Math.floor(n.lengthTime%60)))),1==n.multiplex&&(o+=addHtmlValue4("Multiplexor","Enabled")),n.userids)for(var t in n.userids)o+=addHtmlValue4("User",n.userids[t].split("/")[2]);setDialogMode(2,"Recording Details",9,null,o)}}function refreshRecodings(){meshserver.send({action:"recordings",limit:1e3})}function openRecodringPlayer(){xxdialogMode||window.open(window.location.origin+"{{{domainurl}}}player.htm","meshcentral-deskplayer")}function p52updateInfo(){for(var e=document.getElementsByClassName("RecordingCheckbox"),t=0;t<e.length;t++)!0===e[t].checked&&0}function d3init(){Q("d3localFile").value="",d3modechange()}function d3modechange(){var e=Q("d3uploadMode").value;QV("d3localmode",1==e),QV("d3servermode",2==e),1==e?d3setActions():d3updatefiles()}var d3filetreelocation=[];function d3updatefiles(){if(1!=Q("d3uploadMode").value){for(var e="",t="",n=filetree,o=1,i=[],a=[],s=document.getElementsByName("fc"),r=0;r<s.length;r++)s[r].checked&&a.push(s[r].value);for(var r in d3filetreelinkpath="",d3filetreelocation){if(null==n.f||null==n.f[d3filetreelocation[r]])break;if(i.push(d3filetreelocation[r]),1==o){var l=d3filetreelocation[r].split("/");publicPath=window.location+l[0]+"files/"+l[2],d3filetreelocation[r]===userinfo._id?d3filetreelinkpath+="self":d3filetreelinkpath+=l[0]+"/"+l[2]}else""!=d3filetreelinkpath&&(d3filetreelinkpath+="/"+d3filetreelocation[r],2<o&&(publicPath+="/"+d3filetreelocation[r]));n=n.f[d3filetreelocation[r]],o++}d3filetreelocation=i;var d=p5sort_files(n.f);for(var r in d){var c,u=d[r],p=u.n;c=70<(c=p).length?'<span title="'+EscapeHtml(p)+'">'+EscapeHtml(p.substring(0,70))+"...</span>":EscapeHtml(p),p=EscapeHtml(p);var m="";null!=u.s&&(m=getFileSizeStr(u.s));var g="";if(u.t<3){g='<div class=filelist file=999><span style=float:right title=""></span><span><div class=fileIcon'+u.t+' onclick=d3folderset("'+encodeURIComponentEx(u.nx)+'")></div>&nbsp;<a href=# style=cursor:pointer onclick=\'return d3folderset("'+encodeURIComponentEx(u.nx)+"\")'>"+c+"</a></span></div>"}else{var h=c;g='<div class=filelist file=3><input style=float:left name=fcx class=fcb type=checkbox onchange=d3setActions() value="'+u.nx+'">&nbsp;<span style=float:right>'+m+"</span><span><div class=fileIcon"+u.t+"></div>"+h+"</span></div>"}u.t<3?e+=g:t+=g}QH("d3serverfiles",e+t),QE("p3FolderUp",0<d3filetreelocation.length),d3setActions()}}function d3folderset(e){return d3filetreelocation.push(decodeURIComponent(e)),d3updatefiles(),!1}function d3folderup(e){if(null==e)d3filetreelocation.pop();else for(;d3filetreelocation.length>e;)d3filetreelocation.pop();d3updatefiles()}function d3getFileSel(){for(var e=[],t=document.getElementsByName("fcx"),n=0;n<t.length;n++)t[n].checked&&e.push(t[n].value);return e}function d3setActions(){1==Q("d3uploadMode").value?QE("idx_dlgOkButton",0<Q("d3localFile").value.length):QE("idx_dlgOkButton",1==d3getFileSel().length)}var notifications=[];function clickNotificationIcon(e){1==e?QV("notifiyBox",!0):0==e?QV("notifiyBox",!1):QV("notifiyBox","none"==QS("notifiyBox").display),drawNotifications()}function setNotificationCount(e){parseInt(Q("notificationCount").innerHTML)!=e&&(QH("notificationCount",e),QS("notificationCount")["background-color"]=0==e?"lightblue":"orange",QV("notificationCount",0<e))}function drawNotifications(){var e=getstore("notifications",0),t="";if(0==notifications.length)t="<div style=margin:5px>There are currently no notifications</div>";else for(var n in notifications){var o=notifications[n],i="",a=new Date(o.time),s=0;if(null!=o.title&&(i="<b>"+o.title+"</b>: "),null!=o.nodeid){var r=getNodeFromId(o.nodeid);null!=r&&(s=r.icon,i=16&e?"<b>"+meshes[r.meshid].name+" / "+r.name+"</b>: ":"<b>"+r.name+"</b>: ")}t+='<div title="'+format("Occured at {0}",printDateTime(a))+'" id="notifyx'+o.id+'" class=notification style="cursor:pointer;border-top:1px solid '+(""==t?"transparent":"orange")+'">',s&&(t+="<div class=j"+s+' onclick="notificationSelected('+o.id+')" style=margin:5px;float:left></div>'),t+='<div onclick="notificationDelete('+o.id+')" class=unselectable title="Clear this notification" style=margin:5px;float:right;color:orange><b>X</b></div><div onclick="notificationSelected('+o.id+')" style=margin:5px>'+i+o.text+"</div></div>"}var l="";1<notifications.length&&(l='<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">'+t+"</div>"+l)}function notificationSelected(e,t){var n=-1;for(var o in notifications)notifications[o].id==e&&(n=o);-1!=n&&(notificationSelectedEx(notifications[n],e),t&&notifications[n]&&(notifications[n].notification&&(notifications[n].notification.close(),delete notifications[n].notification),notificationDelete(e)))}function notificationSelectedEx(e,t){null!=e.nodeid?"desktop"==e.tag?gotoDevice(e.nodeid,12):"terminal"==e.tag?gotoDevice(e.nodeid,11):"files"==e.tag?gotoDevice(e.nodeid,13):"intelamt"==e.tag?gotoDevice(e.nodeid,14):"console"==e.tag?gotoDevice(e.nodeid,15):gotoDevice(e.nodeid,10):null!=e.tag&&e.tag.startsWith("meshmessenger/")&&(window.open("/messenger?id="+e.tag+"&title="+encodeURIComponentEx(e.username),e.tag.split("/")[2]),notificationDelete(t))}function notificationDelete(e){var t=-1,n=Q("notifyx"+e);if(null!=n){for(var o in notifications)notifications[o].id==e&&(t=o);if(-1!=t&&(meshserver.send({action:"intersession",subaction:"removeNotify",id:e}),notifications[t].notification&&(notifications[t].notification.close(),delete notifications[t].notification),notifications.splice(t,1),n.parentNode.removeChild(n),setNotificationCount(notifications.length),0==notifications.length&&QV("notifiyBox",!1),1==notifications.length&&QV("notifyRemoveAll",!1),0<notifications.length&&0==t)){var i=notifications[0];QS("notifyx"+i.id)["border-top"]="1px solid transparent"}}}function addNotification(e){null==e.time&&(e.time=Date.now()),null==e.id&&(e.id=Math.random()),notifications.unshift(e),setNotificationCount(notifications.length),clickNotificationIcon(!0);var t=getstore("notifications",0);1&t&&Q("chimes").play();var n=null;if(Notification&&"granted"==Notification.permission){var o=e.text.split("&reg;").join("").split("<b>").join("").split("</b>").join("").split("<br />").join("\r\n");if(e.nodeid){var i=getNodeFromId(e.nodeid);i&&(n=16&t?new Notification("{{{title}}} - "+meshes[i.meshid].name+" - "+i.name,{tag:e.tag,body:o,icon:"/images/notify/icons128-"+i.icon+".png"}):new Notification("{{{title}}} - "+i.name,{tag:e.tag,body:o,icon:"/images/notify/icons128-"+i.icon+".png"}))}else{null==e.icon&&(e.icon=0);var a=e.title;a=null==a?"":" - "+e.title,n=new Notification("{{{title}}}"+a,{tag:e.tag,body:o,icon:"/images/notify/icons128-"+e.icon+".png"})}n.id=e.id,n.xtag=e.tag,n.nodeid=e.nodeid,n.username=e.username,n.onclick=function(e){notificationSelected(e.target.id,!0)},e.notification=n}}function deleteAllNotifications(){notifications=[],setNotificationCount(0),drawNotifications(),QV("notifiyBox",!1)}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:{events:[],responsive:!0,legend:{position:"none"},animation:{animateScale:!0,animateRotate:!0},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:{events:[],responsive:!0,legend:{position:"none"},animation:{animateScale:!0,animateRotate:!0},width:"60px"}})}var lastServerStats=null;function updateGeneralServerStats(e){if(null!=e?lastServerStats=e:e=lastServerStats,null!=e){var t={ServerState:"Server State",AgentErrorCounters:"Agent Error Counters",UnknownGroup:"Unknown Group",InvalidPKCSsignature:"Invalid PKCS signature",InvalidRSAsiguature:"Invalid RSA siguature",InvalidJSON:"Invalid JSON",UnknownAction:"Unknown Action",BadWebCertificate:"Bad Web Certificate",BadSignature:"Bad Signature",MaxSessionsReached:"Max Sessions Reached",UnknownDeviceGroup:"Unknown Device Group",InvalidDeviceGroupType:"Invalid Device Group Type",DuplicateAgent:"Duplicate Agent",ConnectedIntelAMT:"Connected Intel&reg; AMT",RelayErrors:"Relay Errors",UserAccounts:"User Accounts",DeviceGroups:"Device Groups",AgentSessions:"Agent Sessions",ConnectedUsers:"Connected Users",UsersSessions:"Users Sessions",RelaySessions:"Relay Sessions",RelayCount:"Relay Count"};if("object"==typeof e.cpuavg){var n=Math.min(e.cpuavg[0],1);window.serverStatCpu.config.data.datasets[0].data=[n,1-n],QH("serverCpuChartText",'<div style=margin-bottom:5px>CPU Load</div><div><b title="CPU load in the last minute">'+Math.round(100*e.cpuavg[0])/100+'</b>, <b title="CPU load in the last 5 minutes">'+Math.round(100*e.cpuavg[1])/100+'</b>, <b title="CPU load in the last 15 minutes">'+Math.round(100*e.cpuavg[2])/100+"</b></div>"),QS("serverCpuChartView").display="inline-block",window.serverStatCpu.update()}"number"==typeof e.totalmem&&"number"==typeof e.freemem&&(window.serverStatMemory.config.data.datasets[0].data=[e.totalmem-e.freemem,e.freemem],QH("serverMemoryChartText","<div style=margin-bottom:5px>Memory</div><div><b>"+getNiceSize2(e.freemem)+"</b> free, <b>"+getNiceSize2(e.totalmem)+"</b> total</div>"),QS("serverMemoryChartView").display="inline-block",window.serverStatMemory.update());var o="<div style=width:100% cellpadding=0 cellspacing=0>";if("object"==typeof e.values)for(var i in e.values)for(var a in o+="<div class=userTableHeader style=margin-bottom:4px;width:200px>"+(t[i]?t[i]:i)+"</div>",e.values[i])o+="<div style=display:inline-block><table class=serverStateTableCell><tr><td class=h1></td><td><span>"+(t[a]?t[a]:a)+"</span><span style=float:right>"+e.values[i][a]+"</span></td><td class=h2></td></tr></table></div>";o+="</div>",QH("serverStatsTable",o)}}var serverTimelineStats=null,serverTimelineConfig={type:"line",data:{labels:[],datasets:[{label:"",backgroundColor:"rgba(255, 99, 132, .5)",borderColor:"rgb(255, 99, 132)",data:[],fill:!0}]},options:{animation:!1,responsive:!0,maintainAspectRatio:!1,elements:{line:{cubicInterpolationMode:"monotone"}},scales:{xAxes:[{type:"time",time:{tooltipFormat:"ll HH:mm"},display:!0,scaleLabel:{display:!1,labelString:""}}],yAxes:[{type:"linear",display:!0,scaleLabel:{display:!0,labelString:""}}]}}};function refreshServerTimelineStats(e){meshserver.send({action:"servertimelinestats",hours:720})}function pastDate(e){var t=new Date;return t.setTime(t.getTime()-36e5*e),t}function setServerTimelineStats(e){serverTimelineStats=e,updateServerTimelineStats()}function addServerTimelineStats(e){if(null!=serverTimelineStats){serverTimelineStats.push(e);var t=Q("p40type").value;0==t?(serverTimelineConfig.data.datasets[0].data.push({x:e.time,y:e.conn.ca}),serverTimelineConfig.data.datasets[1].data.push({x:e.time,y:e.conn.cu}),serverTimelineConfig.data.datasets[2].data.push({x:e.time,y:e.conn.us}),serverTimelineConfig.data.datasets[3].data.push({x:e.time,y:e.conn.rs}),null!=e.conn.am&&serverTimelineConfig.data.datasets[4].data.push({x:e.time,y:e.conn.am})):1==t&&(serverTimelineConfig.data.datasets[0].data.push({x:e.time,y:e.mem.external/1048576}),serverTimelineConfig.data.datasets[1].data.push({x:e.time,y:e.mem.heapUsed/1048576}),serverTimelineConfig.data.datasets[2].data.push({x:e.time,y:e.mem.heapTotal/1048576}),serverTimelineConfig.data.datasets[3].data.push({x:e.time,y:e.mem.rss/1048576})),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 e,t=Q("p40type").value,n=pastDate(Q("p40time").value);if(serverTimelineConfig.options.scales.xAxes[0].time={min:n},0==t){serverTimelineConfig.options.scales.yAxes[0].scaleLabel.labelString="Connection Count",e={labels:[pastDate(0),n],datasets:[{label:"Agents",data:[],backgroundColor:"rgba(158, 151, 16, .1)",borderColor:"rgb(158, 151, 16)",fill:!0},{label:"Users",data:[],backgroundColor:"rgba(16, 84, 158, .1)",borderColor:"rgb(16, 84, 158)",fill:!0},{label:"User Sessions",data:[],backgroundColor:"rgba(255, 99, 132, .1)",borderColor:"rgb(255, 99, 132)",fill:!0},{label:"Relay Sessions",data:[],backgroundColor:"rgba(39, 158, 16, .1)",borderColor:"rgb(39, 158, 16)",fill:!0},{label:"Intel AMT",data:[],backgroundColor:"rgba(134, 16, 158, .1)",borderColor:"rgb(134, 16, 158)",fill:!0}]};for(var o=0;o<serverTimelineStats.length;o++){new Date(serverTimelineStats[o].time);1==serverTimelineStats[o].first&&(e.datasets[0].data.push({x:serverTimelineStats[o].time-1,y:NaN}),e.datasets[1].data.push({x:serverTimelineStats[o].time-1,y:NaN}),e.datasets[2].data.push({x:serverTimelineStats[o].time-1,y:NaN}),e.datasets[3].data.push({x:serverTimelineStats[o].time-1,y:NaN}),e.datasets[4].data.push({x:serverTimelineStats[o].time-1,y:NaN})),serverTimelineStats[o].conn&&(e.datasets[0].data.push({x:serverTimelineStats[o].time,y:serverTimelineStats[o].conn.ca}),e.datasets[1].data.push({x:serverTimelineStats[o].time,y:serverTimelineStats[o].conn.cu}),e.datasets[2].data.push({x:serverTimelineStats[o].time,y:serverTimelineStats[o].conn.us}),e.datasets[3].data.push({x:serverTimelineStats[o].time,y:serverTimelineStats[o].conn.rs}),null!=serverTimelineStats[o].conn.am&&e.datasets[4].data.push({x:serverTimelineStats[o].time,y:serverTimelineStats[o].conn.am}))}}else if(1==t){serverTimelineConfig.options.scales.yAxes[0].scaleLabel.labelString="Megabytes",e={labels:[pastDate(0),n],datasets:[{label:"External",data:[],backgroundColor:"rgba(158, 151, 16, .1)",borderColor:"rgb(158, 151, 16)",fill:!0},{label:"Heap Used",data:[],backgroundColor:"rgba(16, 84, 158, .1)",borderColor:"rgb(16, 84, 158)",fill:!0},{label:"Heap Total",data:[],backgroundColor:"rgba(255, 99, 132, .1)",borderColor:"rgb(255, 99, 132)",fill:!0},{label:"RSS",data:[],backgroundColor:"rgba(39, 158, 16, .1)",borderColor:"rgb(39, 158, 16)",fill:!0}]};for(o=0;o<serverTimelineStats.length;o++)1==serverTimelineStats[o].first&&(e.datasets[0].data.push({x:serverTimelineStats[o].time-1,y:NaN}),e.datasets[1].data.push({x:serverTimelineStats[o].time-1,y:NaN}),e.datasets[2].data.push({x:serverTimelineStats[o].time-1,y:NaN}),e.datasets[3].data.push({x:serverTimelineStats[o].time-1,y:NaN})),e.datasets[0].data.push({x:serverTimelineStats[o].time,y:serverTimelineStats[o].mem.external/1048576}),e.datasets[1].data.push({x:serverTimelineStats[o].time,y:serverTimelineStats[o].mem.heapUsed/1048576}),e.datasets[2].data.push({x:serverTimelineStats[o].time,y:serverTimelineStats[o].mem.heapTotal/1048576}),e.datasets[3].data.push({x:serverTimelineStats[o].time,y:serverTimelineStats[o].mem.rss/1048576})}serverTimelineConfig.data=e,window.serverMainStats.update()}function p40downloadEvents(){for(var e="time, conn.agent, conn.users, conn.usersessions, conn.relaysession, conn.intelamt, mem.external, mem.heapused, mem.heaptotal, mem.rss\r\n",t=0;t<serverTimelineStats.length;t++)serverTimelineStats[t].conn&&serverTimelineStats[t].mem&&(e+=new Date(serverTimelineStats[t].time)+", "+serverTimelineStats[t].conn.ca+", "+serverTimelineStats[t].conn.cu+", "+serverTimelineStats[t].conn.us+", "+serverTimelineStats[t].conn.rs+", "+(serverTimelineStats[t].conn.am?serverTimelineStats[t].conn.am:"")+", "+serverTimelineStats[t].mem.external+", "+serverTimelineStats[t].mem.heapUsed+", "+serverTimelineStats[t].mem.heapTotal+", "+serverTimelineStats[t].mem.rss+"\r\n");saveAs(new Blob([e],{type:"application/octet-stream"}),"ServerStats.csv")}var xxdialogMode,xxdialogFunc,xxdialogButtons,xxdialogTag,serverTrace=[],serverTraceSources=[];function displayServerTrace(){var e="",t=parseInt(Q("p41limitdropdown").value);for(var n in serverTrace.length>t&&serverTrace.splice(t),serverTrace)e+="<div class=traceEvent>"+EscapeHtml(new Date(serverTrace[n].time).toLocaleTimeString())+" - <b>"+EscapeHtml(serverTrace[n].source.toUpperCase())+"</b>: "+EscapeHtml(serverTrace[n].args.join(", "))+"</div>";QH("p41events",e)}function clearServerTracing(){serverTrace=[],displayServerTrace()}function setServerTracing(){var e="";e+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:5px"><b>Core Server</b></div>',e+="<div><label><input type=checkbox id=p41c1 "+(0<=serverTraceSources.indexOf("cookie")?"checked":"")+">Cookie encoder</label></div>",e+="<div><label><input type=checkbox id=p41c2 "+(0<=serverTraceSources.indexOf("dispatch")?"checked":"")+">Message Dispatcher</label></div>",e+="<div><label><input type=checkbox id=p41c3 "+(0<=serverTraceSources.indexOf("main")?"checked":"")+">Main Server Messages</label></div>",e+="<div><label><input type=checkbox id=p41c4 "+(0<=serverTraceSources.indexOf("peer")?"checked":"")+">MeshCentral Server Peering</label></div>",e+="<div><label><input type=checkbox id=p41c15 "+(0<=serverTraceSources.indexOf("agent")?"checked":"")+">MeshAgent traffic</label></div>",e+="<div><label><input type=checkbox id=p41c14 "+(0<=serverTraceSources.indexOf("agentupdate")?"checked":"")+">MeshAgent update</label></div>",e+="<div><label><input type=checkbox id=p41c16 "+(0<=serverTraceSources.indexOf("cert")?"checked":"")+">Server Certificate</label></div>",e+="<div><label><input type=checkbox id=p41c17 "+(0<=serverTraceSources.indexOf("db")?"checked":"")+">Server Database</label></div>",e+="<div><label><input type=checkbox id=p41c18 "+(0<=serverTraceSources.indexOf("email")?"checked":"")+">Email/SMS Traffic</label></div>",e+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:5px"><b>Web Server</b></div>',e+="<div><label><input type=checkbox id=p41c5 "+(0<=serverTraceSources.indexOf("web")?"checked":"")+">Web Server</label></div>",e+="<div><label><input type=checkbox id=p41c6 "+(0<=serverTraceSources.indexOf("webrequest")?"checked":"")+">Web Server Requests</label></div>",e+="<div><label><input type=checkbox id=p41c7 "+(0<=serverTraceSources.indexOf("relay")?"checked":"")+">Web Socket Relay</label></div>",e+='<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:5px"><b>Intel AMT</b></div>',e+="<div><label><input type=checkbox id=p41c9 "+(0<=serverTraceSources.indexOf("webrelay")?"checked":"")+">Connection Relay</label></div>",e+="<div><label><input type=checkbox id=p41c10 "+(0<=serverTraceSources.indexOf("mps")?"checked":"")+">CIRA Server</label></div>",setDialogMode(2,"Server Tracing",7,setServerTracingEx,e+="<div><label><input type=checkbox id=p41c11 "+(0<=serverTraceSources.indexOf("mpscmd")?"checked":"")+">CIRA Server Commands</label></div>")}function setServerTracingEx(e){var t=[],n=["cookie","dispatch","main","peer","web","webrequest","relay","webrelaydata","webrelay","mps","mpscmd","swarm","swarmcmd","agentupdate","agent","cert","db","email"];if(1==e)for(var o=1;o<19;o++)try{Q("p41c"+o).checked&&t.push(n[o-1])}catch(e){}meshserver.send({action:"traceinfo",traceSources:t})}function p41downloadServerTrace(){var e="time, source, message\r\n";for(var t in serverTrace)e+='"'+new Date(serverTrace[t].time).toLocaleTimeString()+'","'+serverTrace[t].source+'","'+serverTrace[t].args.join(", ")+'"\r\n';return saveAs(new Blob([e],{type:"application/octet-stream"}),"servertrace.csv"),!1}var xxcurrentView=-1;function setDialogMode(e,t,n,o,i,a){setSessionActivity(),QV("uiMenu",!1),xxdialogMode=e,xxdialogFunc=o,xxdialogButtons=n,xxdialogTag=a,QS("dialog").width=QS("dialog").top=QS("dialog").left=QS("dialog").right=QS("dialog").bottom=null,QE("idx_dlgOkButton",!0),QV("idx_dlgOkButton",1&n),QV("idx_dlgCancelButton",2&n),QV("id_dialogclose",2&n||8&n),QV("idx_dlgDeleteButton",4&n),QV("idx_dlgButtonBar",7&n),t&&QH("id_dialogtitle",t);for(var s=1;s<24;s++)QV("dialog"+s,s==e);QV("dialog",e),i&&(2==e?QH("id_dialogOptions",i):QH("id_dialogMessage",i))}function dialogclose(e){setSessionActivity();var t=xxdialogFunc,n=xxdialogButtons,o=xxdialogTag;setDialogMode(),(8&n||e)&&t&&t(e,o)}function center(){setSessionActivity(),11==xxcurrentView?deskAdjust():10==xxcurrentView?masterUpdate(256):1==xxcurrentView&&masterUpdate(4)}function messagebox(e,t){setSessionActivity(),QH("id_dialogMessage",t),setDialogMode(1,e,1)}function statusbox(e,t){setSessionActivity(),QH("id_dialogMessage",t),setDialogMode(1,e)}function goBack(){setSessionActivity(),xxdialogMode||0==goBackStack.length||(fullscreen&&deskToggleFull(),go(goBackStack.pop()),goBackStack.pop())}function go(e,t){if(null!=pluginHandler&&pluginHandler.callHook("goPageStart",e,t),setSessionActivity(),!xxdialogMode)if(QV("uiMenu",!1),t&&1==t.shiftKey&&15!=e&&""=="{{{currentNode}}}".toLowerCase())10<=e&&e<=19?currentNode&&window.open(window.location.origin+"{{{domainurl}}}?gotonode="+currentNode._id.split("/")[2]+"&viewmode="+e+"&hide=16","meshcentral:"+currentNode._id):20<=e&&e<=29?currentMesh&&window.open(window.location.origin+"{{{domainurl}}}?gotomesh="+currentMesh._id.split("/")[2]+"&viewmode="+e+"&hide=16","meshcentral:"+currentMesh._id):30<=e&&e<=39?currentUser&&window.open(window.location.origin+"{{{domainurl}}}?gotouser="+(serverinfo.crossDomain?currentUser._id:currentUser._id.split("/")[2])+"&viewmode="+e+"&hide=16","meshcentral:"+currentUser._id):50<=e&&e<=59?currentUserGroup&&window.open(window.location.origin+"{{{domainurl}}}?gotougrp="+(serverinfo.crossDomain?currentUserGroup._id:currentUserGroup._id.split("/")[2])+"&viewmode="+e+"&hide=16","meshcentral:"+currentUserGroup._id):window.open(window.location.origin+"{{{domainurl}}}?viewmode="+e+"&hide=0","meshcentral:"+e);else if(xxcurrentView!=e){xxcurrentView<0||e<10?goBackStack=[]:50!=xxcurrentView&&Math.floor(xxcurrentView/10)==Math.floor(e/10)||goBackStack.push(xxcurrentView),11==xxcurrentView&&null!=desktop&&null!=desktop.m.recordedData&&deskRecordSession(),(4==e&&0==(2&userinfo.siteadmin)||0!=(4&features))&&(e=52);for(var n=0;n<53;n++)QV("p"+n,n==e);if(xxcurrentView=e,fullscreen&&deskToggleFull(),0==(268435456&features)&&0<xxcurrentView){var o="";for(var n in 10<=xxcurrentView&&xxcurrentView<=19?null!=currentNode&&(o="?viewmode="+xxcurrentView+"&gotonode="+currentNode._id.split("/")[2]):20<=xxcurrentView&&xxcurrentView<=29?null!=currentMesh&&(o="?viewmode="+xxcurrentView+"&gotomesh="+currentMesh._id.split("/")[2]):30<=xxcurrentView&&xxcurrentView<=39?null!=currentUser&&(o="?viewmode="+xxcurrentView+"&gotouser="+(serverinfo.crossDomain?currentUser._id:currentUser._id.split("/")[2])):51<=xxcurrentView&&xxcurrentView<=51?null!=currentUserGroup&&null!=currentUserGroup._id&&(o="?viewmode="+xxcurrentView+"&gotougrp="+(serverinfo.crossDomain?currentUserGroup._id:currentUserGroup._id.split("/")[2])):1<xxcurrentView&&(o="?viewmode="+xxcurrentView),urlargs)o+=(""==o?"?":"&")+n+"="+urlargs[n];try{window.history.replaceState({},document.title,window.location.pathname+o)}catch(e){}}var i=["MainMenuMyDevices","MainMenuMyAccount","MainMenuMyEvents","MainMenuMyFiles","MainMenuMyUsers","MainMenuMyServer"];for(var n in i)QC(i[n]).remove("fullselect"),QC(i[n]).remove("semiselect");var a=["LeftMenuMyDevices","LeftMenuMyAccount","LeftMenuMyEvents","LeftMenuMyFiles","LeftMenuMyUsers","LeftMenuMyServer"];for(var n in a)QC(a[n]).remove("lbbuttonsel"),QC(a[n]).remove("lbbuttonsel2");var s=e<9?"fullselect":"semiselect",r=e<9||115==e||40==e||41==e||42==e?"lbbuttonsel2":"lbbuttonsel",l=0;0<goBackStack.length&&(l=goBackStack[goBackStack.length-1]),1==e||1==l||0==l&&10<=e&&e<20?(QC("MainMenuMyDevices").add(s),QC("LeftMenuMyDevices").add(r)):2==e||2==l||0==l&&20<=e&&e<30?(QC("MainMenuMyAccount").add(s),QC("LeftMenuMyAccount").add(r)):3==e?(QC("MainMenuMyEvents").add(s),QC("LeftMenuMyEvents").add(r)):4==e||30<=e&&e<40||50==e||51==e||52==e?(QC("MainMenuMyUsers").add(s),QC("LeftMenuMyUsers").add(r)):5==e?(QC("MainMenuMyFiles").add(s),QC("LeftMenuMyFiles").add(r)):(6==e||115==e||40<=e&&e<50)&&(QC("MainMenuMyServer").add(s),QC("LeftMenuMyServer").add(r)),QV("ServerPlugins",null!=pluginHandler),webPageStackMenu&&10<=e?QC("column_l").add("room4submenu"):QC("column_l").remove("room4submenu"),QV("topbar",0!=e),0==e&&webPageFullScreen&&QC("body").add("arg_hide"),QV("MainSubMenuSpan",10<=e&&e<20),QV("UserDummyMenuSpan",51==e||e<10&&6!=e&&webPageFullScreen),QV("MeshSubMenuSpan",20<=e&&e<30),QV("UserSubMenuSpan",30<=e&&e<40),QV("ServerSubMenuSpan",6==e||115==e||40==e||41==e||42==e||43==e),QV("UsersSubMenuSpan",4==e||50==e||52==e);var d={4:"UsersGeneral",10:"MainDev",11:"MainDevDesktop",12:"MainDevTerminal",13:"MainDevFiles",14:"MainDevAmt",15:"MainDevConsole",16:"MainDevEvents",17:"MainDevInfo",19:"MainDevPlugins",20:"MeshGeneral",21:"MeshSummary",30:"UserGeneral",31:"UserEvents",6:"ServerGeneral",40:"ServerStats",41:"ServerTrace",42:"ServerPlugins",50:"UsersGroups",52:"UsersRecordings",115:"ServerConsole"};for(var n in d)QC(d[n]).remove("style3x"),QC(d[n]).remove("style3sel"),QC(d[n]).add(e==n?"style3sel":"style3x");11==e&&deskAdjust(),115==e&&QV("p15",!0),QV("p15uploadCore",115!=e),QV("p15BackButton",115!=e),15!=e&&115!=e||setupConsole(),1==e&&masterUpdate(4),2==e&&Notification&&QV("accountEnableNotificationsSpan","granted"!=Notification.permission),40==e&&null==serverTimelineStats&&refreshServerTimelineStats(),42==e&&refreshPluginLatest(),21==e&&p21updateMesh(),52==e&&(null==p52recordings&&refreshRecodings(),updateRecordings()),12==e&&null!=xtermfit&&(xtermfit.fit(),xterm.focus()),document.title=currentNode&&10<=e&&e<20?currentNode.name+(meshes[currentNode.meshid]?" - "+meshes[currentNode.meshid].name:"")+" - "+decodeURIComponent("{{{extitle}}}"):decodeURIComponent("{{{extitle}}}"),null!=pluginHandler&&pluginHandler.callHook("goPageEnd",e,t),QS("column_l").overflow=0<=[11,12].indexOf(e)?"hidden":null}}function updatePluginList(e){if(null!=pluginHandler){if(Array.isArray(e)&&e.forEach(function(e){updatePluginList(e)}),QV("pluginNoneNotice",0==installedPluginList.length),installedPluginList.length){if(null!=e&&(null==installedPluginList.version_info&&(installedPluginList.version_info=[]),installedPluginList.version_info[e.id]=e),(n=Q("p42tbl").querySelectorAll(".p42tblRow")).length)for(var t in Object.values(n))n[t].parentNode.removeChild(n[t]);var r={0:{text:"Disabled",color:"858483"},1:{text:"Installed",color:"00aa00"}},l={0:{install:"Install",delete:"Delete"},1:{disable:"Disable",upgrade:"Upgrade"}},d=Q("p42tbl");installedPluginList.forEach(function(e){var t=[];if(1==e.hasAdminPanel&&e.status?e.nameHtml="<a onclick=\"return goPlugin('"+e.shortName+"', '"+e.name.replace(/'/g,"\\'")+"');\">"+e.name+"</a>":e.nameHtml=e.name,e.statusText=r[e.status].text,e.statusColor=r[e.status].color,null==e.versionHistoryUrl&&t.push("downgrade"),e.status||(e.version=" - "),e.upgradeAvail="Checking...",null!=installedPluginList.version_info&&null!=installedPluginList.version_info[e._id]){var n=installedPluginList.version_info[e._id];n.hasUpdate?e.upgradeAvail='<a title="View Changelog" target="_blank" href="'+n.changelogUrl+'">'+n.version+"</a>":(t.push("upgrade"),e.status?e.upgradeAvail="Up to date":e.upgradeAvail='<a title="View Changelog" target="_blank" href="'+n.changelogUrl+'">'+n.version+"</a>"),n.meshCentralCompat||(e.upgradeAvail+=' [ <span onclick="return setDialogMode(2, \'Compatibility Issue\', 1, null, \'This plugin version is not compatible with your MeshCentral installation, please upgrade MeshCentral first.\');" title="Version incompatible, please upgrade your MeshCentral installation first" style="cursor: pointer; color:red;"> ! </span> ]',t.push("install"),t.push("upgrade"))}e.actions="<select onchange=\"return pluginAction(this,'"+e._id+'\');"><option value=""> --</option>';var o=Object.entries(l[e.status]);for(var i in o)-1===t.indexOf(o[i][0])&&(e.actions+='<option value="'+o[i][0]+'">'+o[i][1]+"</option>");e.actions+="</select>";var a="<td><img style=margin-top:3px src=images/plugin24.png></td><td class=gradTable1>&nbsp;</td><td class=gradTable2>"+e.nameHtml+"</td><td class=gradTable2>"+e.description+'</td><td class=gradTable2 style=text-align:center><a href="'+e.homepage+'" target="_blank">Home</a></td><td class=gradTable2 style=text-align:center>'+e.version+'</td><td style=text-align:center class="pluginUpgradeAvailable gradTable2">'+e.upgradeAvail+'</td><td class=gradTable2 style="text-align:center;color:#'+e.statusColor+'">'+e.statusText+'</td><td class="pluginAction gradTable2" style=text-align:center>'+e.actions+"</td><td class=gradTable3>&nbsp;</td>",s=d.insertRow(-1);s.innerHTML=a,s.classList.add("p42tblRow"),s.setAttribute("data-id",e._id),s.setAttribute("id","pluginRow-"+e._id)})}else{var n=Q("p42tbl").querySelectorAll(".p42tblRow");for(var t in Object.values(n))n[t].parentNode.removeChild(n[t])}null==e&&refreshPluginLatest()}}function refreshPluginLatest(){null!=pluginHandler&&meshserver.send({action:"pluginLatestCheck"})}function distributeCore(){null!=pluginHandler&&(meshserver.send({action:"distributeCore",nodes:nodes}),QV("pluginRestartNotice",!1))}function pluginActionEx(){if(null!=pluginHandler){var e=Q("lastPluginAct").value,t=Q("lastPluginId").value,n=Q("lastPluginVersion").value;switch(e){case"upgrade":case"install":meshserver.send({action:"installplugin",id:t,version_only:!1});break;case"downgrade":Q("lastPluginVersion").querySelectorAll("option").forEach(function(e){e.value==n&&(pVers=e.text)}),meshserver.send({action:"installplugin",id:t,version_only:{name:pVers,url:n}});break;case"delete":meshserver.send({action:"removeplugin",id:t});break;case"disable":meshserver.send({action:"disableplugin",id:t})}QV("pluginRestartNotice",!0)}}function pluginAction(e,t){if(null!=pluginHandler){if("downgrade"==e.value)meshserver.send({action:"getpluginversions",id:t});else{var n=null;for(var o in installedPluginList)installedPluginList[o]._id==t&&(n=installedPluginList[o]);setDialogMode(2,"Plugin Action",3,pluginActionEx,format("Are you sure you want to {0} the plugin: {1}",e.value,n.name)+'<input id="lastPluginAct" type="hidden" value="'+e.value+'" /><input id="lastPluginId" type="hidden" value="'+t+'" /><input id="lastPluginVersion" type="hidden" value="" />')}e.value=""}}function goPlugin(e,t){null!=pluginHandler&&(null==e?Q("p43iframe").src="":(QH("p43title",t),Q("p43iframe").src="/pluginadmin.ashx?pin="+e,go(43)))}function GetMeshRights(e,t){if(null==e)return 0;if(null==t&&(t=userinfo._id),"string"==typeof e&&(e=meshes[e]),null==e||null==e.links)return 0;if(serverinfo.manageAllDeviceGroups)return 4294967295;var n=0,o=e.links[t];if(null!=o){if(4294967295==o.rights)return 4294967295;n=o.rights}var i=null;if(t==userinfo._id?i=userinfo:null!=users&&(i=users[t]),null!=i)for(var a in i.links)if(a.startsWith("ugrp/")&&null!=(o=e.links[a])){if(4294967295==o.rights)return 4294967295;n|=o.rights}return n}function IsMeshViewable(e,t){if(null==e)return!1;if(null==t&&(t=userinfo._id),"string"==typeof e&&(e=meshes[e]),null==e||null==e.links)return!1;if(null!=e.links[t])return!0;if(serverinfo.manageAllDeviceGroups)return!0;var n=null;if(t==userinfo._id?n=userinfo:null!=users&&(n=users[t]),null!=n)for(var o in n.links)if(o.startsWith("ugrp/")&&null!=e.links[o])return!0;return!1}function GetNodeRights(e,t){if(null==e)return 0;if(null==t&&(t=userinfo._id),"string"==typeof e&&null==(e=getNodeFromId(e)))return 0;var n=GetMeshRights(e.meshid,t);if(4294967295==n)return n;if(null!=e.links&&null!=e.links[t]&&(n|=e.links[t].rights),null!=e.links&&null!=userinfo.links)for(var o in e.links)o.startsWith("ugrp/")&&null!=userinfo.links[o]&&null!=e.links[o].rights&&(n|=e.links[o].rights);return n}function IsNodeViewable(e,t){if(null==e)return!1;if(null==t&&(t=userinfo._id),"string"==typeof e&&null==(e=getNodeFromId(e)))return!1;if(IsMeshViewable(e.meshid,t))return!0;if(null!=e.links&&null!=e.links[t])return!0;if(null!=e.links&&null!=userinfo.links)for(var n in e.links)if(n.startsWith("ugrp/")&&null!=userinfo.links[n]&&null!=e.links[n].rights)return!0;return!1}if("undefined"==typeof TextEncoder){window.TextEncoder=function(){},TextEncoder.prototype.encode=function(e){for(var t=e.length,n=-1,o="undefined"==typeof Uint8Array?new Array(1.5*t):new Uint8Array(3*t),i=0,a=0,s=0;s!==t;){if(i=e.charCodeAt(s),s+=1,55296<=i&&i<=56319){if(s===t){o[n+=1]=239,o[n+=1]=191,o[n+=1]=189;break}if(!(56320<=(a=e.charCodeAt(s))&&a<=57343)){o[n+=1]=239,o[n+=1]=191,o[n+=1]=189;continue}if(s+=1,65535<(i=1024*(i-55296)+a-56320+65536)){o[n+=1]=240|i>>>18,o[n+=1]=128|i>>>12&63,o[n+=1]=128|i>>>6&63,o[n+=1]=128|63&i;continue}}i<=127?o[n+=1]=0|i:(i<=2047?o[n+=1]=192|i>>>6:(o[n+=1]=224|i>>>12,o[n+=1]=128|i>>>6&63),o[n+=1]=128|63&i)}return"undefined"!=typeof Uint8Array?o.subarray(0,n+1):(o.length=n+1,o)},TextEncoder.prototype.toString=function(){return"[object TextEncoder]"};try{Object.defineProperty(TextEncoder.prototype,"encoding",{get:function(){if(TextEncoder.prototype.isPrototypeOf(this))return"utf-8";throw TypeError("Illegal invocation")}})}catch(e){TextEncoder.prototype.encoding="utf-8"}"undefined"!=typeof Symbol&&(TextEncoder.prototype[Symbol.toStringTag]="TextEncoder")}function joinPaths(){var e=[];for(var t in arguments){var n=arguments[t];if(null!=n&&""!=n){for(;n.endsWith("/")||n.endsWith("\\");)n=n.substring(0,n.length-1);for(;n.startsWith("/")||n.startsWith("\\");)n=n.substring(1);e.push(n)}}return e.join("/")}function putstore(e,t){try{if("undefined"==typeof localStorage||localStorage.getItem(e)==t)return;null==t?localStorage.removeItem(e):localStorage.setItem(e,t)}catch(e){}if("_"!=e[0]){var n={};try{for(var o=0,i=localStorage.length;o<i;++o){var a=localStorage.key(o);"_"!=a[0]&&(n[a]=localStorage.getItem(a),"desktopsettings"!=a&&"string"==typeof n[a]&&64<n[a].length&&delete n[a])}}catch(e){}meshserver.send({action:"userWebState",state:JSON.stringify(n)})}}function getstore(e,t){try{if("undefined"==typeof localStorage)return t;var n=localStorage.getItem(e);return null==n||null==n?t:n}catch(e){return t}}function addLink(e,t){return"<span tabindex=0 style=cursor:pointer;text-decoration:none onclick='"+t+"' onkeypress=\"if (event.key=='Enter') {"+t+'} ">'+e+" <img class=hoverButton src=images/link5.png></span>"}function addLinkConditional(e,t,n){return n?addLink(e,t):e}function haltEvent(e){return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!1}function addOption(e,t,n){var o=document.createElement("option");o.text=t,o.value=n,Q(e).add(o)}function passwordcheck(e){return 7<e.length&&/\d/.test(e)&&/[a-z]/.test(e)&&/[A-Z]/.test(e)&&/\W/.test(e)}function methodcheck(e){return!(!e||null==e||!e.Body||"SUCCESS"==e.Body.ReturnValueStr)&&(messagebox("Call Error",e.Header.Method+": "+e.Body.ReturnValueStr.replace("_"," ")),!0)}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(e,t){return"<tr><td><p>"+e+"<td>"+t}function FullTable(e,t){var n=TableStart();for(i in e)i&&e[i]&&(n+=TableEntry(i,e[i]));return n+TableEnd(t)}function TableEnd(e){return"<tr><td colspan=2><p>"+(e||"")+"</table>"}function AddButton(e,t){return'<input type=button value="'+e+'" onclick="'+t+'" style=margin:4px>'}function AddButton2(e,t){return'<input type=button value="'+e+'" onclick="'+t+'">'}function AddRefreshButton(e){return'<input type=button name=refreshbtn value=Refresh onclick="refreshButtons(false);'+e+'" style=margin:4px '+(0==refreshButtonsState?"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){for(var t,n=[],o=0,i=e.options.length;o<i;o++)(t=e.options[o]).selected&&n.push(t.value);return n}function getInstance(e,t){for(var n in e)if(e[n].InstanceID==t)return e[n];return null}function getItem(e,t,n){for(var o in e)if(e[o][t]==n)return e[o];return null}function guidToStr(e){return e.substring(6,8)+e.substring(4,6)+e.substring(2,4)+e.substring(0,2)+"-"+e.substring(10,12)+e.substring(8,10)+"-"+e.substring(14,16)+e.substring(12,14)+"-"+e.substring(16,20)+"-"+e.substring(20)}function getUrlVars(){for(var e,t=[],n=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),o=0;o<n.length;o++)0<(e=n[o].indexOf("="))&&(t[n[o].substring(0,e)]=n[o].substring(e+1,n[o].length));return t}function addHtmlValue(e,t){return"<table><td style=width:120px>"+e+"<td><b>"+t+"</b></table>"}function addHtmlValue2(e,t){return"<div><div style=display:inline-block;float:right>"+t+"</div><div style=display:inline-block>"+e+"</div></div>"}function addHtmlValue3(e,t){return"<div><b>"+e+"</b></div><div style=margin-left:16px>"+t+"</div>"}function addHtmlValue4(e,t){return"<table style=width:100%><td style=width:120px>"+e+"<td style=text-align:right><b>"+t+"</b></table>"}function parseUriArgs(){var e=window.document.location.href;e.endsWith("#")&&(e=e.substring(0,e.length-1));var t,n={},o=e.split(/[\?&|\=]/);for(i in o.splice(0,1),o)switch(i%2){case 0:t=decodeURIComponent(o[i]);break;case 1:n[t]=decodeURIComponent(o[i]);var i=parseInt(n[t]);i==n[t]&&(n[t]=i)}return n}function focusTextBox(e){setTimeout(function(){Q(e).selectionStart=Q(e).selectionEnd=65535,Q(e).focus()},0)}function validateEmail(e){return/^(([^<>()\[\]\\.,;:\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,}))$/.test(e)}function isPrivateIP(e){return e.startsWith("10.")||e.startsWith("172.16.")||e.startsWith("192.168.")}function u2fSupported(){return window.u2f&&(0<navigator.userAgent.indexOf("Chrome/")||0<navigator.userAgent.indexOf("Firefox/")||0<navigator.userAgent.indexOf("Opera/")||0<navigator.userAgent.indexOf("Safari/"))}function findOne(t,e){return null!=t&&null!=e&&e.some(function(e){return 0<=t.indexOf(e)})}function copyTextToClip(e){var t=document.createElement("DIV");t.textContent=e,document.body.appendChild(t),function(e){if(document.selection)(t=document.body.createTextRange()).moveToElementText(e),t.select();else if(window.getSelection){var t;(t=document.createRange()).selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(t)}}(t),document.execCommand("copy"),t.remove()}function copyTextToClip2(e){var t=document.createElement("DIV");t.textContent=decodeURIComponent(e),document.body.appendChild(t),function(e){if(document.selection)(t=document.body.createTextRange()).moveToElementText(e),t.select();else if(window.getSelection){var t;(t=document.createRange()).selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(t)}}(t),document.execCommand("copy"),t.remove()}function capitalizeFirstLetter(e){return e.charAt(0).toUpperCase()+e.slice(1)}function printDate(e){return e.toLocaleDateString(args.locale)}function printTime(e){return e.toLocaleTimeString(args.locale)}function printDateTime(e){return e.toLocaleString(args.locale)}function addDetailItem(e,t,n){return"<table style=width:100%><td>"+nobreak(e)+"<td style=text-align:right>"+t+"</table>"}function format(e){var n=Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,t){return void 0!==n[t]?n[t]:e})}function addTextLink(e,t,n){var o=t.toLowerCase().indexOf(e.toLowerCase());return-1==o?t:t.substring(0,o)+'<a href="'+n+'">'+e+"</a>"+t.substring(o+e.length)}function getOrderedList(e,i){var t=[];for(var n in e)t.push(e[n]);return t.sort(function(e,t){var n=e[i].toLowerCase(),o=t[i].toLowerCase();return o<n?1:n<o?-1:0}),t}function capitalizeFirstLetter(e){return e.charAt(0).toUpperCase()+e.slice(1)}function nobreak(e){return e.split(" ").join("&nbsp;")}function pad2(e){var t="00"+e;return t.substr(t.length-2)}function encodeURIComponentEx(e){return encodeURIComponent(e).replace(/'/g,"%27")}function getUserName(e){return users&&null!=users[e]?users[e].name:e.split("/")[2]}</script>