";if((l.latest.indexOf(".")==-1)||(l.current==l.latest)||((features&2048)==0)){setDialogMode(2,"MeshCentral Version",1,null,R)}else{setDialogMode(2,"MeshCentral Version",3,server_showVersionDlgEx,R+" ");server_showVersionDlgUpdate()}}break;case"servererrors":if((xxdialogMode==2)&&(xxdialogTag=="MeshCentralServerErrors")){if(l.data==null){setDialogMode(2,"MeshCentral Server Errors",1,null,"Server has no error log.")}else{var R='
Install Google Authenticator or a compatible application and scan the barcode, use this link or enter the secret. Then, enter the current 6 digit token below to activate 2-Step login.
Secret '+J+'
Enter the token here for 2-step login:
');new QRCode(Q("qrcode"),{text:l.url,width:128,height:128,colorDark:"#000000",colorLight:"#EEE",correctLevel:QRCode.CorrectLevel.H});QV("idx_dlgOkButton",true);QE("idx_dlgOkButton",false);Q("d2otpauthinput").focus()}break;case"otpauth-setup":if(xxdialogMode){return}setDialogMode(2,"Authenticator App",1,null,l.success?"Authenticator app activation successful. You will now need a valid token to login again.":"2-step login activation failed. 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,l.success?"Authenticator application removed. You can reactivate this feature at any time.":"2-step login activation removal failed. Try again.");break;case"otpauth-getpasswords":if(xxdialogMode){return}var R="One time tokens can be used as secondary authentication. Generate a set, print them and keep them in a safe place.";R+="
";if(l.passwords){var g=0;for(var d in l.passwords){if(++g%2){R+="
")}}},l.request.timeoutSeconds);break;case"otp-hkey-setup-response":if(xxdialogMode&&(xxdialogTag!="otpauth-hardware-manage")){return}if(l.result==true){meshserver.send({action:"otp-hkey-get"})}else{setDialogMode(2,"Add Security Key",1,null," ERROR: Unable to add key.
","otpauth-hardware-manage")}break;case"webauthn-startregister":if(xxdialogMode&&(xxdialogTag!="otpauth-hardware-manage")){return}var R="Press the key button now.
";setDialogMode(2,"Add Security Key",2,null,R);var F=l.request;l.request.challenge=Uint8Array.from(atob(l.request.challenge),function(j){return j.charCodeAt(0)});l.request.user.id=Uint8Array.from(atob(l.request.user.id),function(j){return j.charCodeAt(0)});navigator.credentials.create({publicKey:F}).then(function(j){var m={rawId:btoa(String.fromCharCode.apply(null,new Uint8Array(j.rawId))),response:{attestationObject:btoa(String.fromCharCode.apply(null,new Uint8Array(j.response.attestationObject))),clientDataJSON:btoa(String.fromCharCode.apply(null,new Uint8Array(j.response.clientDataJSON)))},type:j.type};meshserver.send({action:"webauthn-endregister",response:m});setDialogMode(0)},function(j){setDialogMode(2,"Add Security Key",1,null,"ERROR: "+j)});break;case"event":if(!l.event.nolog){events.unshift(l.event);var c=parseInt(p3limitdropdown.value);while(events.length>c){events.pop()}masterUpdate(32)}switch(l.event.action){case"userWebState":if(localStorage!=null){var A=localStorage.getItem("showRealNames");var D=localStorage.getItem("uiMode");var C=localStorage.getItem("sort");var P=JSON.parse(l.event.state);for(var d in P){localStorage.setItem(d,P[d])}if((P.deskAspectRatio!=null)&&(P.deskAspectRatio!=deskAspectRatio)){deskAspectRatio=P.deskAspectRatio;deskAdjust()}if((P.showRealNames!=null)&&(P.showRealNames!=A)){showRealNames=Q("RealNameCheckBox").checked=(P.showRealNames=="1");masterUpdate(6)}if((P.uiMode!=null)&&(P.uiMode!=D)){userInterfaceSelectMenu(parseInt(P.uiMode))}if((P.sort!=null)&&(P.sort!=C)){document.getElementById("sortselect").selectedIndex=sort=parseInt(P.sort);masterUpdate(6)}}break;case"servertimelinestats":addServerTimelineStats(l.event.data);break;case"accountcreate":case"accountchange":if(userinfo.name==l.event.account.name){var t=l.event.account.siteadmin?l.event.account.siteadmin:0;var B=userinfo.siteadmin?userinfo.siteadmin:0;if((l.event.account.quota!=userinfo.quota)||(((userinfo.siteadmin&8)==0)&&((l.event.account.siteadmin&8)!=0))){meshserver.send({action:"files"})}var z=userinfo.groups;userinfo=l.event.account;if(B!=t){updateSiteAdmin()}updateSelf();if((userinfo.siteadmin&2)!=0){var y=z?z:[];var v=userinfo.groups?userinfo.groups:[];if(y.join(",")!=v.join(",")){users=wssessions=null;meshserver.send({action:"users"});meshserver.send({action:"wssessioncount"})}}}if(users==null){break}if((userinfo.groups==null)||(userinfo.groups.length==0)||(findOne(l.event.account.groups,userinfo.groups)==true)){users[l.event.account._id]=l.event.account}else{delete users[l.event.account._id]}updateUsers();break;case"accountremove":if(users==null){break}delete users["user/"+domain+"/"+l.event.username.toLowerCase()];updateUsers();break;case"createmesh":if(l.event.links[userinfo._id]!=null){meshes[l.event.meshid]={_id:l.event.meshid,name:l.event.name,mtype:l.event.mtype,desc:l.event.desc,links:l.event.links};masterUpdate(4+128);meshserver.send({action:"files"})}break;case"meshchange":if(meshes[l.event.meshid]==null){meshes[l.event.meshid]={_id:l.event.meshid,name:l.event.name,mtype:l.event.mtype,desc:l.event.desc,links:l.event.links};meshserver.send({action:"nodes"})}else{if(l.event.name){meshes[l.event.meshid].name=l.event.name}if(l.event.desc){meshes[l.event.meshid].desc=l.event.desc}if(l.event.flags!=null){meshes[l.event.meshid].flags=l.event.flags}if(l.event.consent!=null){meshes[l.event.meshid].consent=l.event.consent}if(l.event.links){meshes[l.event.meshid].links=l.event.links}if(l.event.amt){meshes[l.event.meshid].amt=l.event.amt}if(meshes[l.event.meshid].links[userinfo._id]==null){if((xxcurrentView==20)&&(currentMesh==meshes[l.event.meshid])){go(2)}delete meshes[l.event.meshid];var s=[];for(var d in nodes){if(nodes[d].meshid!=l.event.meshid){s.push(nodes[d])}}nodes=s;if(xxcurrentView>=10&&xxcurrentView<20&¤tNode&¤tNode.meshid==l.event.meshid){setDialogMode(0);go(1)}}}masterUpdate(4+128);if(currentNode&&(currentNode.meshid==l.event.meshid)){currentNode=null;if((xxcurrentView>=10)&&(xxcurrentView<20)){go(1)}}if(xxcurrentView==20&¤tMesh._id==l.event.meshid){p20updateMesh()}break;case"deletemesh":if(meshes[l.event.meshid]){delete meshes[l.event.meshid];masterUpdate(128);meshserver.send({action:"files"})}var s=[];if(nodes!=null){for(var d in nodes){if(nodes[d].meshid!=l.event.meshid){s.push(nodes[d])}}}nodes=s;masterUpdate(4);if(xxcurrentView>=20&&xxcurrentView<30&¤tMesh._id==l.event.meshid){setDialogMode(0);go(2)}if(xxcurrentView>=10&&xxcurrentView<20&¤tNode&¤tNode.meshid==l.event.meshid){setDialogMode(0);go(1)}break;case"addnode":var w=l.event.node;if(!meshes[w.meshid]){break}w.namel=w.name.toLowerCase();if(w.rname){w.rnamel=w.rname.toLowerCase()}else{w.rnamel=w.namel}w.meshnamel=meshes[w.meshid].name.toLowerCase();w.state=0;if(!w.icon){w.icon=1}w.ident=++nodeShortIdent;if(nodes==null){}nodes.push(w);masterUpdate(1|2|4|16);break;case"removenode":var e=-1;for(var d in nodes){if(nodes[d]._id==l.event.nodeid){e=d;break}}if(e!=-1){var w=nodes[e];if(currentNode==w){if(xxcurrentView>=10&&xxcurrentView<20){setDialogMode(0);go(1)}currentNode=null}nodes.splice(e,1);masterUpdate(4|16)}break;case"changenode":var e=-1;for(var d in nodes){if(nodes[d]._id==l.event.nodeid){e=d;break}}if(e!=-1){var w=nodes[e];w.name=l.event.node.name;w.rname=l.event.node.rname;w.users=l.event.node.users;w.host=l.event.node.host;w.desc=l.event.node.desc;w.ip=l.event.node.ip;w.osdesc=l.event.node.osdesc;w.publicip=l.event.node.publicip;w.iploc=l.event.node.iploc;w.wifiloc=l.event.node.wifiloc;w.gpsloc=l.event.node.gpsloc;w.tags=l.event.node.tags;w.userloc=l.event.node.userloc;if(l.event.node.agent!=null){if(w.agent==null){w.agent={}}if(l.event.node.agent.ver!=null){w.agent.ver=l.event.node.agent.ver}if(l.event.node.agent.id!=null){w.agent.id=l.event.node.agent.id}if(l.event.node.agent.caps!=null){w.agent.caps=l.event.node.agent.caps}if(l.event.node.agent.core!=null){w.agent.core=l.event.node.agent.core}else{if(w.agent.core){delete w.agent.core}}w.agent.tag=l.event.node.agent.tag}if(l.event.node.intelamt!=null){if(w.intelamt==null){w.intelamt={}}if(l.event.node.intelamt.host!=null){w.intelamt.user=l.event.node.intelamt.host}if(l.event.node.intelamt.user!=null){w.intelamt.user=l.event.node.intelamt.user}if(l.event.node.intelamt.tls!=null){w.intelamt.tls=l.event.node.intelamt.tls}if(l.event.node.intelamt.ver!=null){w.intelamt.ver=l.event.node.intelamt.ver}if(l.event.node.intelamt.state!=null){w.intelamt.state=l.event.node.intelamt.state}}w.namel=w.name.toLowerCase();if(w.rname){w.rnamel=w.rname.toLowerCase()}else{w.rnamel=w.namel}if(l.event.node.icon){w.icon=l.event.node.icon}masterUpdate(2|4|8|16);refreshDevice(w._id);if((currentNode==w)&&(xxdialogMode!=null)&&(xxdialogTag=="@xxmap")){p10showNodeLocationDialog()}}break;case"nodemeshchange":var e=-1;for(var d in nodes){if(nodes[d]._id==l.event.nodeid){e=d;break}}if(e!=-1){var w=nodes[e];if(meshes[l.event.newMeshId]==null){if(currentNode==w){if(xxcurrentView>=10&&xxcurrentView<20){setDialogMode(0);go(1)}currentNode=null}nodes.splice(e,1);masterUpdate(4|16)}else{w.meshid=l.event.newMeshId;w.meshnamel=meshes[l.event.newMeshId].name.toLowerCase();masterUpdate(1|2|4)}refreshDevice(l.event.nodeid)}else{var w=l.event.node;if(!meshes[w.meshid]){break}w.namel=w.name.toLowerCase();if(w.rname){w.rnamel=w.rname.toLowerCase()}else{w.rnamel=w.namel}w.meshnamel=meshes[w.meshid].name.toLowerCase();w.state=0;if(!w.icon){w.icon=1}w.ident=++nodeShortIdent;if(nodes==null){}nodes.push(w);masterUpdate(1|2|4|16)}break;case"nodeconnect":var e=-1;for(var d in nodes){if(nodes[d]._id==l.event.nodeid){e=d;break}}if(e!=-1){var w=nodes[e];w.conn=l.event.conn;w.pwr=l.event.pwr;masterUpdate(4|16);refreshDevice(w._id)}break;case"wssessioncount":if(wssessions!=null){if(l.event.count==0&&wssessions["user/"+domain+"/"+l.event.username.toLowerCase()]){delete wssessions["user/"+domain+"/"+l.event.username.toLowerCase()]}else{wssessions["user/"+domain+"/"+l.event.username.toLowerCase()]=l.event.count}updateUsers()}break;case"clearevents":events=[];masterUpdate(32);break;case"login":if(users!=null&&users["user/"+domain+"/"+l.event.username.toLowerCase()]){users["user/"+domain+"/"+l.event.username.toLowerCase()].login=Math.floor(new Date(l.event.time).getTime()/1000)}break;case"scanamtdevice":if((xxdialogMode==null)||(!Q("dp1range"))||(Q("dp1range").value!=l.event.range)){return}var R="";if(l.event.results==null){R="
Unable to scan this address range.
Sample IP range values 192.168.0.100 192.168.1.0/24 192.167.0.1-192.168.0.100
"}else{amtScanResults=l.event.results;for(var d in l.event.results){var G=l.event.results[d],L=G.hostname;if(L.length>20){L=L.substring(0,20)+"..."}var N=''+EscapeHtml(L)+" - v"+G.ver;if(G.state==2){if(G.tls==1){N+=" with TLS."}else{N+=" without TLS."}}else{N+=" not activated."}R+='
'+N+"
"}if(R==""){R="
Scan returned no results.
Sample IP range values 192.168.0.100 192.168.1.0/24 192.167.0.1-192.168.0.100
Connectivity"}for(var t in nodes){var E=nodes[t];if(E.v==false){continue}var z=meshes[E.meshid],B=z.links[userinfo._id];if(B==null){continue}var C=B.rights;if((O==3)&&(z.mtype==1)){continue}if(sort==0){if(E.meshid!=g){deviceHeaderSet();var o="";if(O==2){G+="
"}if(meshes[E.meshid].mtype==1){o=", Intel® AMT only"}if((O==1)&&(g!=null)){if(a==2){G+="
";x.push(E._id)}}}}if((sort==3)&&(G!="")){if(E.tags){for(var w in E.tags){var K=E.tags[w];if(s[K]==null){s[K]=G;p[K]=1}else{s[K]+=G;p[K]+=1}if(O==3){break}}}G=""}deviceHeaderTotal++;if(typeof deviceHeaderCount[E.state]=="undefined"){deviceHeaderCount[E.state]=1}else{deviceHeaderCount[E.state]++}}if(sort==3){var q=[];for(var t in s){q.push(t)}q.sort(function(c,j){return c.toLowerCase().localeCompare(j.toLowerCase())});for(var w in q){var t=q[w];G+="
No devices are included in any groups, click on a device\'s "Groups" to add to a group.
'}else{G='
No devices matching this search.
'}}if((O==1)&&(a==2)){G+="
"}if((sort==0)&&(Q("SearchInput").value=="")&&(O<3)){for(var t in meshes){var y=meshes[t],A=y.links[userinfo._id];if(A!=null){var C=A.rights;if(l[y._id]==null){if((g!="")&&(G!="")){G+=""}G+="
";QH("xdevices",G);deviceHeaderSet();var m=document.getElementsByClassName("DeviceCheckbox"),b=0;for(var t=0;t=0)}for(var t in deviceHeaders){QH(t,deviceHeaders[t])}for(var t in deviceHeadersTitles){Q(t).title=deviceHeadersTitles[t]}p1updateInfo();if(O==3){var P=[{x:180,y:101},{x:302,y:169},{x:454,y:255}][Q("sizeselect").selectedIndex];var H=P.x+2,N=M-5,R=Math.floor(N/H);R=H+Math.floor((N-(R*H))/R);P.y=P.y*(R/P.x);P.x=R;for(var t in multiDesktop){multiDesktop[t].xxdelete=true}for(var t in x){var v=x[t],I=v.split("/")[2],h=multiDesktop[v];if(h!=null){h.m.CanvasId.setAttribute("style","background-color:black;width:"+P.x+"px;height:"+P.y+"px");Q("xkvmid_"+I).appendChild(h.m.CanvasId);delete h.xxdelete;QH("skvmid_"+I,["Disconnected","Connecting...","Setup...","",""][((h.m.State==null)?h.m.state:h.m.State)])}else{var E=getNodeFromId(v);if((desktopNode==E)&&(desktop!=null)){var a=desktop.m.CanvasId;a.setAttribute("id","kvmid_"+I);a.setAttribute("style","background-color:black;width:"+P.x+"px;height:"+P.y+"px");a.setAttribute("onclick","toggleKvmDevice('"+v+"')");a.removeAttribute("onmousedown");a.removeAttribute("onmouseup");a.removeAttribute("onmousemove");Q("xkvmid_"+I).appendChild(a);QH("skvmid_"+I,["Disconnected","Connecting...","Setup...","",""][((desktop.m.State==null)?desktop.m.state:desktop.m.State)]);if(desktop.m.SendCompressionLevel){desktop.m.SendCompressionLevel(1,multidesktopsettings.quality,multidesktopsettings.scaling,multidesktopsettings.framerate)}desktop.shortid=I;desktop.onStateChanged=onMultiDesktopStateChange;multiDesktop[v]=desktop;desktop=desktopNode=currentNode=null;QH("DeskParent",'')}else{var a=document.createElement("canvas");a.setAttribute("id","kvmid_"+I);a.setAttribute("width",640);a.setAttribute("height",480);a.setAttribute("oncontextmenu","return false");a.setAttribute("style","background-color:black;width:"+P.x+"px;height:"+P.y+"px");a.setAttribute("onclick","toggleKvmDevice('"+v+"')");try{Q("xkvmid_"+I).appendChild(a)}catch(n){}if(Q("autoConnectDesktopCheckbox").checked==true){setTimeout(function(){connectMultiDesktop(E,1)},100)}}}}for(var t in multiDesktop){if(multiDesktop[t].xxdelete==true){multiDesktop[t].Stop();delete multiDesktop[t]}else{if(debugmode&&multiDesktop[t].m&&multiDesktop[t].m.onScreenSizeChange){mdeskAdjust(multiDesktop[t].m,multiDesktop[t].m.ScreenWidth,multiDesktop[t].m.ScreenHeight,multiDesktop[t].m.CanvasId)}}}deskAdjust()}else{disconnectAllKvmFunction();Q("autoConnectDesktopCheckbox").checked=false}}oldviewmode=O}function toggleKvmDevice(d){var c=getNodeFromId(d),a=meshes[c.meshid],b=a.links[userinfo._id].rights;if((b&8)||(b&256)){if(c.conn&1){connectMultiDesktop(c,1)}}}function getUserShortStr(b){if(b==null||b.users==null||b.users.length==0){return""}if(b.users.length>1){return''+b.users.length+" users"}var d=b.users[0],c=d,a=d.indexOf("\\");if(a>0){c=d.substring(a+1)}c=EscapeHtml(c);if(c.length>15){c=c.substring(0,14)+"…"}return''+c+""}function autoConnectDesktops(){if(Q("autoConnectDesktopCheckbox").checked==true){connectAllKvmFunction()}}function connectAllKvmFunction(){for(var a in nodes){if(multiDesktop[nodes[a]._id]==null){toggleKvmDevice(nodes[a]._id)}}}function disconnectAllKvmFunction(){for(var a in multiDesktop){multiDesktop[a].Stop()}multiDesktop={}}function onMultiDesktopStateChange(a,c){try{QH("skvmid_"+a.shortid,["Disconnected","Connecting...","Setup...","",""][c])}catch(b){}}function showMultiDesktopSettings(){QV("d7amtkvm",false);QV("d7meshkvm",true);d7bitmapquality.value=multidesktopsettings.quality;d7bitmapscaling.value=multidesktopsettings.scaling;if(multidesktopsettings.framerate){d7framelimiter.value=multidesktopsettings.framerate}else{d7framelimiter.value=1000}setDialogMode(7,"Remote Desktop Settings",3,showMultiDesktopSettingsChanged)}function showMultiDesktopSettingsChanged(){multidesktopsettings.quality=d7bitmapquality.value;multidesktopsettings.scaling=d7bitmapscaling.value;multidesktopsettings.framerate=d7framelimiter.value;localStorage.setItem("multidesktopsettings",JSON.stringify(multidesktopsettings));for(var a in multiDesktop){multiDesktop[a].m.SendCompressionLevel(1,multidesktopsettings.quality,multidesktopsettings.scaling,multidesktopsettings.framerate)}}function connectMultiDesktop(c,a){var d=c._id,e=d.split("/")[2];var b=multiDesktop[d];if(b==null){if(Q("kvmid_"+e)==null){return}if(a==2){if((c.intelamt.user==null)||(c.intelamt.user=="")){return}b=CreateAmtRedirect(CreateAmtRemoteDesktop("kvmid_"+e),authCookie);b.shortid=e;b.onStateChanged=onMultiDesktopStateChange;b.m.bpp=1;b.m.useZRLE=true;b.m.showmouse=true;b.m.onKvmData=function(g){console.log("KVM Data received in multi-desktop mode, this is not supported.")};if(debugmode>0){b.m.onScreenSizeChange=mdeskAdjust}b.Start(d,16994,"*","*",0);b.contype=2;multiDesktop[d]=b}else{if(a==1){b=CreateAgentRedirect(meshserver,CreateAgentRemoteDesktop("kvmid_"+e),serverPublicNamePort,authCookie);b.shortid=e;b.attemptWebRTC=attemptWebRTC;b.onStateChanged=onMultiDesktopStateChange;b.m.CompressionLevel=multidesktopsettings.quality;b.m.ScalingLevel=multidesktopsettings.scaling;b.m.FrameRateTimer=multidesktopsettings.framerate;if(debugmode>0){b.m.onScreenSizeChange=mdeskAdjust}b.Start(d);b.contype=1;multiDesktop[d]=b}}}else{b.Stop();delete multiDesktop[d]}}function getMeshActions(a,b){if((b&4)==0){return""}var c="";if((features&1024)==0){c+=' Add CIRA'}if(a.mtype==1){if((features&1)==0){c+=' Add Local';c+=' Scan Network'}}if(a.mtype==2){c+=' Add Agent';if(features&64){c+=' Invite'}}return c}function addDeviceToMesh(b){if(xxdialogMode){return}var a=meshes[b];var c='Add a new Intel® AMT device to device group "'+EscapeHtml(a.name)+'".
';c+=addHtmlValue("Device Name","");c+=addHtmlValue("Hostname",'');c+=addHtmlValue("Username",'');c+=addHtmlValue("Password","");c+=addHtmlValue("Security","");setDialogMode(2,"Add Intel® AMT device",3,addDeviceToMeshEx,c,b);validateDeviceToMesh();Q("dp1devicename").focus()}function addAmtScanToMesh(a){if(xxdialogMode){return}var b="Enter a range of IP addresses to scan for Intel AMT devices.
";b+=addHtmlValue("IP Range",'');b+='';setDialogMode(2,"Scan for Intel® AMT devices",3,addAmtScanToMeshEx,b,a);QE("idx_dlgOkButton",false);QH("dp1results","
Sample IP range values 192.168.0.100 192.168.1.0/24 192.167.0.1-192.168.0.100
To add a new Intel® AMT device to device group "'+EscapeHtml(a.name)+"\" with CIRA, download the following script files and use MeshCommander to run the script to configure computers.
To add a new Intel® AMT device to device group "'+EscapeHtml(a.name)+'" with CIRA, load the following certificate as trusted root within Intel AMT';if(serverinfo.mpspass){d+=" and authenticate to the server using this username and password.
"}else{d+=" and authenticate to the server using this username and any password.
To add a new Intel® AMT device to device group "'+EscapeHtml(a.name)+'" with CIRA, load the following certificate as trusted root within Intel AMT, authenticate using a client certificate with the following common name and connect to the following server.
"}setDialogMode(2,"Add Intel® AMT CIRA device",2,null,d,"fileDownload")}function dlgAddCiraSelClick(){var a=Q("dlgAddCiraSel").value;QV("dlgAddCira0",a==0);QV("dlgAddCira1",a==1);QV("dlgAddCira2",a==2)}function checkEmail(c){var d=c.split("@");var b=((d.length==2)&&(d[0].length>0)&&(d[1].split(".").length>1)&&(d[1].length>2));if(b==true){var e=d[1].split(".");for(var a in e){if(e[a].length==0){b=false}}}return b}function inviteAgentToMesh(b){if(xxdialogMode){return}var a=meshes[b];var c="Invite someone to install the mesh agent. An email with be sent with the link to the mesh agent installation for "+EscapeHtml(a.name)+".
To add a new computer to device group "'+EscapeHtml(c.name)+'", download the mesh agent and install it the computer to manage. This agent has server and mesh information embedded within it.
To add a computer to "+EscapeHtml(c.name)+" run the following command. Root credentials will be needed. ";j+="";j+="
";j+='
To add a new computer to device group "'+EscapeHtml(c.name)+'", download the mesh agent and install it the computer to manage. This agent installer has server and mesh information embedded within it.
"}QV("xmapSearchResultsDlg",true)}QH("xmapSearchResults",k)}catch(d){}}function mapGotoSelectedLocation(c){var d=c.children;var a=d[1].innerHTML.split("!#!");var b=[parseFloat(a[2]),parseFloat(a[0]),parseFloat(a[3]),parseFloat(a[1])];zoomToExtent(b);mapCloseSearchWindow()}function mapCloseSearchWindow(){QH("xmapSearchResults","");QV("xmapSearchResultsDlg",false)}function zoomToLocation(a,c){var b=xxmap.map.getView();b.setCenter(a);b.setZoom(c)}function zoomToFitExtent(){var b=xxmap.markersSource.getFeatures();if(b.length>0){var a=xxmap.markersSource.getExtent();xxmap.map.getView().fit(a,xxmap.map.getSize())}}function zoomToExtent(b){var a=ol.proj.transformExtent(b,ol.proj.get("EPSG:4326"),ol.proj.get("EPSG:3857"));xxmap.map.getView().fit(a,xxmap.map.getSize())}function refreshDevice(a){if(!currentNode||currentNode._id!=a){return}gotoDevice(a,xxcurrentView,true)}function getNodeRights(c){var b=getNodeFromId(c),a=meshes[b.meshid];return a.links[userinfo._id].rights}var currentNode;var powerTimelineNode=null;var powerTimelineReq=null;var powerTimelineUpdate=null;var powerTimeline=null;function getCurrentNode(){return currentNode}function gotoDevice(r,t,w,j){if((userinfo.emailVerified!==true)&&(serverinfo.emailcheck==true)&&(userinfo.siteadmin!=4294967295)){setDialogMode(2,"Account Security",1,null,'Unable to access a device until a email address is verified. This is required for password recovery. Go to the "My Account" tab to change and verify an email address.');return}if((features&262144)&&!((userinfo.otpsecret==1)||(userinfo.otphkeys>0)||(userinfo.otpkeys>0))){setDialogMode(2,"Account Security",1,null,'Unable to access a device until two-factor authentication is enabled. This is required for extra security. Go to the "My Account" tab and look at the "Account Security" section.');return}if(j&&(j.shiftKey==true)){window.open(window.location.origin+"?node="+r.split("/")[2]+"&viewmode=10&hide=16","meshcentral:"+r);return}var q=getNodeFromId(r);var n=meshes[q.meshid];var o=n.links[userinfo._id].rights;if(!currentNode||currentNode._id!=q._id||w==true){currentNode=q;var p=EscapeHtml(q.name);if(p.length==0){p="None"}if(((o&4)!=0)&&((!n.flags)||((n.flags&2)==0))){p=''+p+' '}QH("p10deviceName",p);QH("p11deviceName",p);QH("p12deviceName",p);QH("p13deviceName",p);QH("p14deviceName",p);QH("p15deviceName","Console - "+p);QH("p16deviceName",p);var B="
";QH("p10html3",B);var u=PowerStateStr(q.state);if((d&1)!=0){if(u.length>0){u+=" "}u+='Agent connected'}if((d&2)!=0){if(u.length>0){u+=" "}u+='Intel® AMT connected'}else{if((d&4)!=0){if(u.length>0){u+=" "}u+='Intel® AMT detected'}}if((u=="")&&q.lastconnect){u="Last seen: "+new Date(q.lastconnect).toLocaleDateString()+", "+new Date(q.lastconnect).toLocaleTimeString()+""}QH("MainComputerState",u);Q("MainComputerImage").setAttribute("src","images/icons256-"+q.icon+"-1.png");Q("MainComputerImage").className=((!q.conn)||(q.conn==0)?"gray":"");var A=((o==4294967295)||((o&512)==0));var k=((o==4294967295)||((o&1024)==0));var b=((o==4294967295)||((o&2048)==0));if(A){setupTerminal()}if(k){setupFiles()}var e=((o&16)!=0);if(e){setupConsole()}else{if(t==15){t=10}}QV("MainDevDesktop",((n.mtype==1)||(q.agent==null)||(q.agent.caps==null)||((q.agent.caps&1)!=0)||(q.intelamt&&(q.intelamt.state==2)))&&((o&8)||(o&256)));QV("MainDevTerminal",((n.mtype==1)||(q.agent==null)||(q.agent.caps==null)||((q.agent.caps&2)!=0)||(q.intelamt&&(q.intelamt.state==2)))&&(o&8)&&A);QV("MainDevFiles",((n.mtype==2)&&((q.agent==null)||(q.agent.caps==null)||((q.agent.caps&4)!=0)))&&(o&8)&&k);QV("MainDevAmt",(q.intelamt!=null)&&((q.intelamt.state==2)||(q.conn&2))&&(o&8)&&b);QV("MainDevConsole",(e&&(n.mtype==2)&&((q.agent==null)||(q.agent.caps==null)||((q.agent.caps&8)!=0)))&&(o&8));QV("p15uploadCore",(q.agent!=null)&&(q.agent.caps!=null)&&((q.agent.caps&16)!=0));QH("p15coreName",((q.agent!=null)&&(q.agent.core!=null))?q.agent.core:"");var c=Q("p14iframe").contentWindow.getCurrentMeshNode();if((c!=null)&&(c._id!=currentNode._id)){Q("p14iframe").contentWindow.disconnect()}var s=((q.conn&6)!=0)?true:false;Q("p14iframe").contentWindow.setConnectionState(s);Q("p14iframe").contentWindow.setFrameHeight("650px");Q("p14iframe").contentWindow.setAuthCallback(updateAmtCredentials);QV("deskActionsBtn",(o&72)!=0);QV("termActionsBtn",(o&72)!=0);QV("filesActionsBtn",(o&72)!=0);if((powerTimelineNode!=currentNode._id)&&(powerTimelineReq!=currentNode._id)){QH("p10html2","");powerTimelineReq=currentNode._id;meshserver.send({action:"powertimeline",nodeid:currentNode._id});meshserver.send({action:"lastconnect",nodeid:currentNode._id})}QV("DeskTools",false);showDeskToolsProcesses();refreshDeviceEvents();if((currentNode)&&(xxcurrentView>=10)&&(xxcurrentView<20)){document.title=decodeURIComponent("{{{extitle}}}")+" - "+currentNode.name}else{document.title=decodeURIComponent("{{{extitle}}}")}}setupDesktop();if(!t){t=10}go(t)}function showNotes(b,a){if(xxdialogMode){return}setDialogMode(2,"Notes",2,showNotesEx,"Notes can be viewed and changed by other administrators.",a);meshserver.send({action:"getNotes",id:decodeURIComponent(a)})}function showNotesEx(a,b){meshserver.send({action:"setNotes",id:decodeURIComponent(b),notes:encodeURIComponent(Q("d2devNotes").value)})}function deviceChat(){if(xxdialogMode){return}var a="/messenger?id=meshmessenger/"+encodeURIComponent(currentNode._id)+"/"+encodeURIComponent(userinfo._id)+"&title="+currentNode.name;if((authCookie!=null)&&(authCookie!="")){a+="&auth="+authCookie}window.open(a,"meshmessenger:"+currentNode._id);meshserver.send({action:"meshmessenger",nodeid:decodeURIComponent(currentNode._id)})}function deviceUrlFunction(){if(xxdialogMode){return}setDialogMode(2,"Open Page on Device",3,deviceUrlFunctionEx,'')}function deviceUrlFunctionEx(){meshserver.send({action:"msg",type:"openUrl",nodeid:currentNode._id,url:Q("d2devurl").value})}function deviceToastFunction(){if(xxdialogMode){return}setDialogMode(2,"Device Notification",3,deviceToastFunctionEx,"")}function deviceToastFunctionEx(){meshserver.send({action:"toast",nodeids:[currentNode._id],title:"MeshCentral",msg:Q("d2devToast").value})}function deviceActionFunction(){if(xxdialogMode){return}var a=meshes[currentNode.meshid].links[userinfo._id].rights;var b="Select an operation to perform on this device.
";var c="";b+=addHtmlValue("Operation",c);setDialogMode(2,"Device Action",3,deviceActionFunctionEx,b)}function deviceActionFunctionEx(){var a=Q("d2deviceop").value;if(a==100){meshserver.send({action:"wakedevices",nodeids:[currentNode._id]})}else{meshserver.send({action:"poweraction",nodeids:[currentNode._id],actiontype:a})}}function updateAmtCredentials(a){var b=getNodeFromId(currentNode._id);if((a==true)||(b.intelamt.user==null)||(b.intelamt.user=="")){editDeviceAmtSettings(currentNode._id,updateAmtCredentialsEx)}else{Q("p14iframe").contentWindow.connectButtonfunctionEx()}}function updateAmtCredentialsEx(a,b){Q("p14iframe").contentWindow.connectButtonfunctionEx()}function updateDeviceTimeline(){if((meshserver.State!=2)||(powerTimelineNode==null)||(powerTimelineUpdate==null)||(currentNode==null)){return}if((powerTimelineNode==powerTimelineReq)&&(currentNode._id==powerTimelineNode)&&(powerTimelineUpdate19)){return}var s=null,o=Date.now();if(currentNode._id==powerTimelineNode){s=powerTimeline}var e=new Date();e.setHours(0,0,0,0);e=new Date(e.getTime()-(1000*60*60*24*6));var u=e.getTime();var t=[];if(s!=null&&s.length>1){t.push([0,s[1],s[0]]);var c=s[1];for(var m=2;m(m+1)){k=s[m+1]}t.push([c,c+k,p]);c=c+k}}var A="",b=1,h=new Date();var w=Q("masthead").offsetWidth-(160+9+9+14);h.setHours(0,0,0,0);for(var m=0;m<7;m++){var g="",q=h.getTime(),l=q+(1000*60*60*24);for(var n in t){var a=t[n];if(isTimeBlockInside(q,l,a[0],a[1])==true){var y=Math.max(q,a[0]);var r=Math.min(Math.min(l,a[1]),o);var z=Math.round(((r-y)*w)/86400000);if(z>0){var v=powerStateStrings2[a[2]]+" from "+new Date(y).toLocaleTimeString()+" to "+new Date(r).toLocaleTimeString()+".";g+=''}}}A+="
"}function editDeviceAmtSettings(e,b){if(xxdialogMode){return}var g="",d=getNodeFromId(e),a=3,c=getNodeRights(e);if((c&4)==0){return}g+=addHtmlValue("Username",'');g+=addHtmlValue("Password","");g+=addHtmlValue("Security","");if((d.intelamt.user!=null)&&(d.intelamt.user!="")){a=7}setDialogMode(2,"Edit Intel® AMT credentials",a,editDeviceAmtSettingsEx,g,{node:d,func:b});if((d.intelamt.user!=null)&&(d.intelamt.user!="")){Q("dp10username").value=d.intelamt.user}else{Q("dp10username").value="admin"}Q("dp10tls").value=d.intelamt.tls;validateDeviceAmtSettings()}function validateDeviceAmtSettings(){QE("idx_dlgOkButton",passwordcheck(Q("dp10password").value))}function editDeviceAmtSettingsEx(c,d){if(c==2){meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:"",pass:""}})}else{var b=Q("dp10username").value;if(b==""){b="admin"}var a=Q("dp10password").value;if(a==""){b=""}meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:b,pass:a,tls:Q("dp10tls").value}});d.node.intelamt.user=b;d.node.intelamt.tls=Q("dp10tls").value;if(d.func){setTimeout(d.func,300)}}}function p10showChangeGroupDialog(e){if(xxdialogMode){return}var g=null;if(e.length==1){try{g=meshes[getNodeFromId(e[0])]._id}catch(b){}}var j="";if(a>0){var h=(e.length==1)?"Select a new group for this device
":"Select a new group for selected devices
";h+=addHtmlValue("New Device Group",j);setDialogMode(2,"Change Group",3,p10showChangeGroupDialogEx,h,e)}else{setDialogMode(2,"Change Group",1,null,"No other device group of same type exists.")}}function p10showChangeGroupDialogEx(a,c){meshserver.send({action:"changeDeviceMesh",nodeids:c,meshid:Q("p10newGroup").value})}function p10showDeleteNodeDialog(a){if(xxdialogMode){return}var b='Are you sure you want to delete node "'+EscapeHtml(currentNode.name)+'"?
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.
"}if(a==1){c+='
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.
","otpauth-request");meshserver.send({action:"otpauth-request"})}function account_addOtpCheck(a){var b=(Q("d2otpauthinput").value.length==6);QE("idx_dlgOkButton",b);if(a&&(a.keyCode==13)&&b){dialogclose(1)}}function account_removeOtp(){if(xxdialogMode||(userinfo.otpsecret!=1)||((features&4096)==0)){return}setDialogMode(2,"Authenticator App",3,function(){meshserver.send({action:"otpauth-clear"})},"Confirm removal of authenticator application 2-step login?")}function account_manageOtp(a){if((xxdialogMode==2)&&(xxdialogTag=="otpauth-manage")){dialogclose(0)}if(xxdialogMode||((features&4096)==0)){return}if((userinfo.otpsecret==1)||(userinfo.otphkeys>0)){meshserver.send({action:"otpauth-getpasswords",subaction:a})}}function account_manageHardwareOtp(){if((xxdialogMode==2)&&(xxdialogTag=="otpauth-hardware-manage")){dialogclose(0)}if(xxdialogMode||((features&4096)==0)){return}meshserver.send({action:"otp-hkey-get"})}function account_addhkey(a){if(a==1||a==3){var b="Type in the name of the key to add.
";b+=addHtmlValue("Key Name",'')}else{if(a==2){var b="Type in a key name, select the OTP box and press the button on the YubiKey™.
","otpauth-hardware-manage")}else{if(c==3){meshserver.send({action:"webauthn-startregister",name:b})}}}}function account_removehkey(a){meshserver.send({action:"otp-hkey-remove",index:a});meshserver.send({action:"otp-hkey-get"})}function account_enableNotifications(){if(Notification){Notification.requestPermission().then(function(a){QV("accountEnableNotificationsSpan",a!="granted")})}}function account_showVerifyEmail(){if(xxdialogMode||(userinfo.emailVerified==true)||(serverinfo.emailcheck!=true)){return}var a="Click ok to send a verification mail to:
"+EscapeHtml(userinfo.email)+"
Please wait a few minute to receive the verification.";setDialogMode(2,"Email Verification",3,account_showVerifyEmailEx,a)}function account_showVerifyEmailEx(){meshserver.send({action:"verifyemail",email:userinfo.email})}function account_showChangeEmail(){if(xxdialogMode){return}var a="Change your account email address here.
";a+=addHtmlValue("Email","");setDialogMode(2,"Email Address Change",3,account_changeEmail,a);if(userinfo.email!=null){Q("dp2email").value=userinfo.email}account_validateEmail();Q("dp2email").focus()}function account_validateEmail(a,b){QE("idx_dlgOkButton",validateEmail(Q("dp2email").value)&&(Q("dp2email").value!=userinfo.email));if((a!=null)&&(a.keyCode==13)){dialogclose(1)}}function account_changeEmail(){meshserver.send({action:"changeemail",email:Q("dp2email").value})}function account_showDeleteAccount(){if(xxdialogMode){return}var a="To delete this account, type in the account password in both boxes below and hit ok.
";a+="";setDialogMode(2,"Delete Account",0,null,a);account_validateDeleteAccount();Q("apassword1").focus()}function account_showChangePassword(){if(xxdialogMode){return}var d="Change your account password by entering the old password and new password twice in the boxes below.";if(features&65536){" Password hint can be used but is not recommanded."}d+="
";d+="
";d+="
Old password:
";d+="
New password:
";d+="
New password:
";if(features&65536){d+="
Password hint:
"}d+="
";if(passRequirements){var b=[],c=0;for(var a in passRequirements){if((a!="reset")&&(a!="hint")){b.push(a+":"+passRequirements[a]);c++}}if(c>0){d+=" Requirements: "+b.join(", ")+"."}}d+=" ";setDialogMode(2,"Change Password",3,account_showChangePasswordEx,d);Q("apassword0").focus();account_validateNewPassword()}function account_showChangePasswordEx(){if(Q("apassword1").value==Q("apassword2").value){var a={action:"changepassword",oldpass:Q("apassword0").value,newpass:Q("apassword1").value};if(features&65536){a.hint=Q("apasswordhint").value}meshserver.send(a)}}function account_createMesh(){if(xxdialogMode){return}if((userinfo.siteadmin!=4294967295)&&((userinfo.siteadmin&64)!=0)){setDialogMode(2,"New Device Group",1,null,"This account does not have the rights to create a new device group.");return}if((userinfo.emailVerified!==true)&&(serverinfo.emailcheck==true)&&(userinfo.siteadmin!=4294967295)){setDialogMode(2,"Account Security",1,null,'Unable to access a device until a email address is verified. This is required for password recovery. Go to the "My Account" tab to change and verify an email address.');return}if((features&262144)&&!((userinfo.otpsecret==1)||(userinfo.otphkeys>0)||(userinfo.otpkeys>0))){setDialogMode(2,"Account Security",1,null,'Unable to access a device until two-factor authentication is enabled. This is required for extra security. Go to the "My Account" tab and look at the "Account Security" section.');return}var a="Create a new device group using the options below.
"}meshcount=b;QH("p2meshes",e);QV("p2noMeshFound",b==0)}function gotoMesh(a){currentMesh=meshes[a];p20updateMesh();go(20)}function server_showRestoreDlg(){if(xxdialogMode){return}var a="Restore the server using a backup, this will delete the existing server data. Only do this if you know what you are doing.
";a+='";setDialogMode(2,"Restore Server",0,null,a);account_validateServerRestore()}function account_validateServerRestore(){QE("account_dlgOkButton",Q("account_dlgFileInput").files.length==1)}function server_showVersionDlg(){if(xxdialogMode){return}setDialogMode(2,"MeshCentral Version",1,null,"Loading...","MeshCentralServerUpdate");meshserver.send({action:"serverversion"})}function server_showVersionDlgUpdate(){QE("idx_dlgOkButton",Q("d2updateCheck").checked)}function server_showVersionDlgEx(){meshserver.send({action:"serverupdate"})}function server_showErrorsDlg(){if(xxdialogMode){return}setDialogMode(2,"MeshCentral Errors",1,null,"Loading...","MeshCentralServerErrors");meshserver.send({action:"servererrors"})}function server_showErrorsDlgUpdate(){QE("idx_dlgOkButton",Q("d2updateCheck").checked)}function server_showErrorsDlgEx(){meshserver.send({action:"serverclearerrorlog"})}var currentMesh;function p20updateMesh(){if(currentMesh==null){return}QH("p20meshName",EscapeHtml(currentMesh.name));var k="Unknown #"+currentMesh.mtype;var j=0;try{j=currentMesh.links[userinfo._id].rights}catch(d){}if(currentMesh.mtype==1){k="Intel® AMT only, no agent"}if(currentMesh.mtype==2){k="Managed using a software agent"}var q="";q+=addHtmlValue("Name",addLinkConditional(EscapeHtml(currentMesh.name),"p20editmesh(1)",(j&1)!=0));q+=addHtmlValue("Description",addLinkConditional(((currentMesh.desc&¤tMesh.desc!="")?EscapeHtml(currentMesh.desc):"None"),"p20editmesh(2)",(j&1)!=0));q+=addHtmlValue("Type",k);var h=[];if(currentMesh.flags){if(currentMesh.flags&1){h.push("Auto-Remove")}if(currentMesh.flags&2){h.push("Hostname Sync")}}h=h.join(", ");if(h==""){h="None"}q+=addHtmlValue("Features",addLinkConditional(h,"p20editmeshfeatures()",j&1));h=[];var a=0;if(currentMesh.consent){a=currentMesh.consent}if(serverinfo.consent){a|=serverinfo.consent}if(a&1){h.push("Desktop Notify")}if(a&2){h.push("Terminal Notify")}if(a&4){h.push("Files Notify")}h=h.join(", ");if(h==""){h="None"}q+=addHtmlValue("User Consent",addLinkConditional(h,"p20editmeshconsent()",j&1));if(currentMesh.mtype==2){var g="No Policy";if(currentMesh.amt){if(currentMesh.amt.type==1){g="Deactivate Client Control Mode (CCM)"}else{if(currentMesh.amt.type==2){g="Simple Client Control Mode (CCM)";if(currentMesh.amt.cirasetup==2){g+=" + CIRA"}}}}q+=addHtmlValue("Intel® AMT",addLinkConditional(g,"p20editMeshAmt()",j&1))}if(j&1){q+=' '}q+="
';var b=1,n=[];for(var e in currentMesh.links){var p=e.split("/")[2];if(currentMesh.links[e].name){p=currentMesh.links[e].name}if(e==userinfo._id){p=userinfo.name}n.push({id:e,name:p,rights:currentMesh.links[e].rights})}n.sort(function(r,s){if(r.name>s.name){return 1}if(r.name'}q+='
"}QH("p20info",q)}function p20editMeshAmt(){if(xxdialogMode){return}var a="";a+=addHtmlValue("Type","");a+="";setDialogMode(2,"Intel® AMT Policy",3,p20editMeshAmtEx,a);if(currentMesh.amt){Q("dp20amtpolicy").value=currentMesh.amt.type}p20editMeshAmtChange();if(currentMesh.amt&¤tMesh.amt.type==2){Q("dp20amtpolicypass").value=currentMesh.amt.password;Q("dp20amtbadpass").value=currentMesh.amt.badpass;if((features&1024)==0){Q("dp20amtcira").value=currentMesh.amt.cirasetup}}dp20amtValidatePolicy()}function p20editMeshAmtChange(){var a=Q("dp20amtpolicy").value,b="";if(a==2){b=addHtmlValue("Password*","");b+=addHtmlValue("Password mismatch","");if((features&1024)==0){b+=addHtmlValue('CIRA',"")}b+=' * Recommanded, leave blank to assign a random password to each device. ';b+='This policy will not impact devices with Intel® AMT in ACM mode. ';b+='This is not a secure policy as agents will be performing activation.'}QH("dp20amtpolicydiv",b)}function dp20amtValidatePolicy(){var a=true,c=Q("dp20amtpolicy").value;if(c==2){var b=Q("dp20amtpolicypass").value;a=(b=="")?true:passwordcheck(b)}QE("idx_dlgOkButton",a)}function p20editMeshAmtEx(){var b=parseInt(Q("dp20amtpolicy").value),a={type:b};if(b==2){a={type:b,password:Q("dp20amtpolicypass").value,badpass:parseInt(Q("dp20amtbadpass").value)};if((features&1024)==0){a.cirasetup=parseInt(Q("dp20amtcira").value)}else{a.cirasetup=1}}meshserver.send({action:"meshamtpolicy",meshid:currentMesh._id,amtpolicy:a})}function p20showDeleteMeshDialog(){if(xxdialogMode){return}var a='Are you sure you want to delete group "'+EscapeHtml(currentMesh.name)+'"? Deleting the device group will also delete all information about devices within this group.
";setDialogMode(2,"Edit Device Group User Consent",3,p20editmeshconsentEx,b);if(serverinfo.consent){if(serverinfo.consent&1){Q("d20flag1").checked=true}if(serverinfo.consent&2){Q("d20flag3").checked=true}if(serverinfo.consent&4){Q("d20flag5").checked=true}QE("d20flag1",!(serverinfo.consent&1));QE("d20flag3",!(serverinfo.consent&2));QE("d20flag5",!(serverinfo.consent&4))}}function p20editmeshconsentEx(){var a=0;if(Q("d20flag1").checked){a+=1}if(Q("d20flag3").checked){a+=2}if(Q("d20flag5").checked){a+=4}meshserver.send({action:"editmesh",meshid:currentMesh._id,consent:a})}function p20editmeshfeatures(){if(xxdialogMode){return}var a=(currentMesh.flags)?currentMesh.flags:0;var b="
Remove device on disconnect
";b+="
Sync server device name to hostname
";setDialogMode(2,"Edit Device Group Features",3,p20editmeshfeaturesEx,b)}function p20editmeshfeaturesEx(){var a=0;if(Q("d20flag1").checked){a+=1}if(Q("d20flag2").checked){a+=2}meshserver.send({action:"editmesh",meshid:currentMesh._id,flags:a})}function p20showAddMeshUserDialog(){if(xxdialogMode){return}var a="Allow a user to manage this device group and devices in this group.";if(features&524288){a+=" Users need to login to this server once before they can be added to a device group."}a+="
";a+=addHtmlValue("User Name","");a+='
';a+="Full Administrator ";a+="Edit Device Group ";a+="Manage Device Group Users ";a+="Manage Device Group Computers ";a+="Remote Control ";a+="Remote View Only ";a+="Limited Input Only ";a+="No Terminal Access ";a+="No File Access ";a+="No Intel® AMT ";a+="Mesh Agent Console ";a+="Server Files ";a+="Wake Devices ";a+="Edit Device Notes ";a+="
";setDialogMode(2,"Add User to Device Group",3,p20showAddMeshUserDialogEx,a);p20validateAddMeshUserDialog();Q("dp20username").focus()}function p20validateAddMeshUserDialog(){var a=currentMesh.links[userinfo._id].rights;QE("idx_dlgOkButton",(Q("dp20username").value.length>0));QE("p20fulladmin",a==4294967295);QE("p20editmesh",(!Q("p20fulladmin").checked)&&(a==4294967295));QE("p20manageusers",!Q("p20fulladmin").checked);QE("p20managecomputers",!Q("p20fulladmin").checked);QE("p20remotecontrol",!Q("p20fulladmin").checked);QE("p20meshagentconsole",!Q("p20fulladmin").checked);QE("p20meshserverfiles",!Q("p20fulladmin").checked);QE("p20wakedevices",!Q("p20fulladmin").checked);QE("p20editnotes",!Q("p20fulladmin").checked);QE("p20remoteview",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20remotelimitedinput",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked&&!Q("p20remoteview").checked);QE("p20noterminal",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20nofiles",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20noamt",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked)}function p20showAddMeshUserDialogEx(){var a=0;if(Q("p20fulladmin").checked==true){a=4294967295}else{if(Q("p20editmesh").checked==true){a+=1}if(Q("p20manageusers").checked==true){a+=2}if(Q("p20managecomputers").checked==true){a+=4}if(Q("p20remotecontrol").checked==true){a+=8}if(Q("p20meshagentconsole").checked==true){a+=16}if(Q("p20meshserverfiles").checked==true){a+=32}if(Q("p20wakedevices").checked==true){a+=64}if(Q("p20editnotes").checked==true){a+=128}if(Q("p20remoteview").checked==true){a+=256}if(Q("p20noterminal").checked==true){a+=512}if(Q("p20nofiles").checked==true){a+=1024}if(Q("p20noamt").checked==true){a+=2048}if(Q("p20remotelimitedinput").checked==true){a+=4096}}meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,username:Q("dp20username").value,meshadmin:a})}function p20viewuser(g){if(xxdialogMode){return}g=decodeURIComponent(g);var d="",b=currentMesh.links[userinfo._id].rights,c=currentMesh.links[g].rights;if(c==4294967295){d=", Full Administrator (all rights)"}else{if((c&1)!=0){d+=", Edit Device Group"}if((c&2)!=0){d+=", Manage Device Group Users"}if((c&4)!=0){d+=", Manage Device Group Computers"}if((c&8)!=0){d+=", Remote Control"}if((c&16)!=0){d+=", Agent Console"}if((c&32)!=0){d+=", Server Files"}if((c&64)!=0){d+=", Wake Devices"}if((c&128)!=0){d+=", Edit Notes"}if(((c&8)!=0)&&(c&256)!=0){d+=", Remote View Only"}if(((c&8)!=0)&&(c&512)!=0){d+=", No Terminal"}if(((c&8)!=0)&&(c&1024)!=0){d+=", No Files"}if(((c&8)!=0)&&(c&2048)!=0){d+=", No Intel® AMT"}if(((c&8)!=0)&&((c&4096)!=0)&&((c&256)==0)){d+=", Limited Input"}}d=d.substring(2);if(d==""){d="No Rights"}var e=g.split("/")[2];if(users){e=users[g].name}if(userinfo._id==g){e=userinfo.name}var a=1,h=addHtmlValue("User Name",EscapeHtml(e));if(g.split("/")[2]!=e){h+=addHtmlValue("User Identifier",EscapeHtml(g.split("/")[2]))}h+=addHtmlValue("Permissions",d);if(((userinfo._id)!=g)&&(b==4294967295||(((b&2)!=0)&&(c!=4294967295)))){a+=4}setDialogMode(2,"Device Group User",a,p20viewuserEx,h,g)}function p20viewuserEx(a,b){if(a!=2){return}setDialogMode(2,"Remote Mesh User",3,p20viewuserEx2,"Confirm removal of user "+b.split("/")[2]+"?",b)}function p20deleteUser(a,b){haltEvent(a);p20viewuserEx(2,decodeURIComponent(b))}function p20viewuserEx2(a,b){meshserver.send({action:"removemeshuser",meshid:currentMesh._id,meshname:currentMesh.name,userid:b})}var filetreelinkpath;var filetreelocation=[];function updateFiles(){QV("MainMenuMyFiles",((features&8)==0));if((features&8)!=0){return}var q="",r="",c="Root",o="Root",y,k=filetree,m=1;var j=[],v=filetreelinkpath,b=[],a=document.getElementsByName("fc");for(var s=0;s2){y+="/"+filetreelocation[s]}}}k=k.f[filetreelocation[s]];c+=" / "+(k.n!=null?k.n:filetreelocation[s])+"";m++}else{break}}filetreelocation=j;var w=o.toLowerCase().startsWith("root / "+userinfo._id+" / public");var l=p5sort_files(k.f);for(var s in l){var d=l[s],u=d.n,A;A=u;if(u.length>70){A=''+EscapeHtml(u.substring(0,70))+"..."}else{A=EscapeHtml(u)}u=EscapeHtml(u);var g="";if(d.d!=null){var e=new Date(d.d),g=(e.getMonth()+1)+"/"+(e.getDate())+"/"+e.getFullYear()+" "+e.toLocaleTimeString()+" "}var n="";if(d.s!=null){n=getFileSizeStr(d.s)}var p="";if(d.t<3||d.t==4){var z=(d.t==1||d.t==4)?p5getQuotabar(d):"",C="";p="
"}QH("p3events",h)}function showDeleteAllEventsDialog(){if(xxdialogMode){return}var a="Delete all events in the server event log?
";a+="Confirm";setDialogMode(2,"Delete All Events",3,showDeleteAllEventsDialogEx,a);validateDeleteAllEventsDialog()}function validateDeleteAllEventsDialog(){QE("idx_dlgOkButton",Q("p3check").checked)}function showDeleteAllEventsDialogEx(a,b){meshserver.send({action:"clearevents"})}function refreshEvents(){meshserver.send({action:"events",limit:parseInt(p3limitdropdown.value)})}function updateUsers(){QV("MainMenuMyUsers",(users!=null)&&((features&4)==0));QV("LeftMenuMyUsers",(users!=null)&&((features&4)==0));QV("UserNewAccountButton",((features&4)==0)&&(serverinfo.domainauth==false));if((users==null)||((features&4)!=0)){QH("p3users","");return}var h=[],e=100,c=0;for(var d in users){h.push(d)}h.sort();var k=Q("UserSearchInput").value.toLowerCase();var b=k;if(k.startsWith("email:")){k=null;b=b.substring(6)}else{if(k.startsWith("name:")){b=null;k=k.substring(5)}else{if(k.startsWith("e:")){k=null;b=b.substring(2)}else{if(k.startsWith("n:")){b=null;k=k.substring(2)}}}}var l="
",a=true;l+="
Name
Groups
Last Access
Permissions";for(var d in h){var j=users[h[d]],g=null;if(wssessions!=null){g=wssessions[j._id]}if((g!=null)&&((k!=null)&&((k=="")||(j.name.toLowerCase().indexOf(k)>=0))||((b!=null)&&((j.email!=null)&&(j.email.toLowerCase().indexOf(b)>=0))))){if(e>0){if(a){l+="
Online Users";a=false}l+=addUserHtml(j,g);e--}else{c++}}}a=true;for(var d in h){var j=users[h[d]],g=null;if(wssessions!=null){g=wssessions[j._id]}if((g==null)&&((k!=null)&&((k=="")||(j.name.toLowerCase().indexOf(k)>=0))||((b!=null)&&((j.email!=null)&&(j.email.toLowerCase().indexOf(b)>=0))))){if(e>0){if(a){l+="
"+j;return o}function userMouseHover(b,c){var a=b.children[0].children[0];a.children[1].classList.remove("g1s");a.children[2].classList.remove("g2s");if(c==1){a.children[1].classList.add("g1s");a.children[2].classList.add("g2s")}b.children[0].children[0].style["background-color"]=((c==0)?"#c9c9c9":"#b9b9b9")}function userChat(a,d,b){haltEvent(a);var c="/messenger?id=meshmessenger/"+d+"/"+encodeURIComponent(userinfo._id)+"&title="+b;if((authCookie!=null)&&(authCookie!="")){c+="&auth="+authCookie}window.open(c,"meshmessenger:"+d);meshserver.send({action:"meshmessenger",userid:decodeURIComponent(d)});return false}function showUserAlertDialog(a,b){if(xxdialogMode){return}haltEvent(a);setDialogMode(2,"Notify "+EscapeHtml(users[decodeURIComponent(b)].name),3,showUserAlertDialogEx,'Send a text notification to this user.',b);Q("d2notifyText").focus();return false}function showUserAlertDialogEx(a,b){meshserver.send({action:"notifyuser",userid:decodeURIComponent(b),msg:Q("d2notifyText").value})}function doemail(b,a){if(xxdialogMode){return}haltEvent(b);window.open("mailto:"+a);return false}function p4batchAccountCreate(){if(xxdialogMode){return}var a='Create many accounts at once by importing a JSON file with the following format:
';setDialogMode(2,"User Account Import",3,p4batchAccountCreateEx,a);QE("idx_dlgOkButton",false)}function p4batchAccountCreateValidate(){QE("idx_dlgOkButton",Q("d4importFile").value!=null)}function p4batchAccountCreateEx(){var a=new FileReader();a.onload=function(g){var d=null;try{d=JSON.parse(g.target.result)}catch(b){setDialogMode(2,"User Account Import",1,null,"Invalid JSON file: "+b+".");return}if((d!=null)&&(Array.isArray(d))){var e=true;for(var c in d){if((typeof d[c].user!="string")||(d[c].user.length<1)||(d[c].user.length>64)){e=false}if((typeof d[c].pass!="string")||(d[c].pass.length<1)||(d[c].pass.length>256)){e=false}if(checkPasswordRequirements(d[c].pass,passRequirements)==false){e=false}if((d[c].email!=null)&&((typeof d[c].email!="string")||(d[c].email.length<1)||(d[c].email.length>128))){e=false}}if(e==false){setDialogMode(2,"User Account Import",1,null,"Invalid JSON file format.")}else{meshserver.send({action:"adduserbatch",users:d})}}else{setDialogMode(2,"User Account Import",1,null,"Invalid JSON file format.")}};a.readAsText(Q("d4importFile").files[0])}function p4downloadUserInfo(){if(xxdialogMode){return}var a="Download the list of users with one of the file formats below.
";a+=addHtmlValue("CSV Format","userlist.csv");a+=addHtmlValue("JSON Format","userlist.json");setDialogMode(2,"User List Export",1,null,a)}function p4downloadUserInfoCSV(){var a="id, name, email, creation, lastlogin, groups, authfactors\r\n";for(var c in users){var d=false,b=[];if((users[c].otpsecret>0)||(users[c].otphkeys>0)){d=true;if(users[c].otpsecret>0){b.push("AuthApp")}if(users[c].otphkeys>0){b.push("SecurityKey")}if(users[c].otpkeys>0){b.push("BackupCodes")}}a+='"'+users[c]._id+'","'+users[c].name+'","'+(users[c].email?users[c].email:"")+'","'+(users[c].creation?new Date(users[c].creation*1000):"")+'","'+(users[c].login?new Date(users[c].login*1000):"")+'","'+(users[c].groups?users[c].groups.join(","):"")+'","'+(d?b.join(","):"")+'"\r\n'}saveAs(new Blob([a],{type:"application/octet-stream"}),"userlist.csv")}function p4downloadUserInfoJSON(){var b=[];for(var a in users){b.push(users[a])}saveAs(new Blob([JSON.stringify(b)],{type:"application/octet-stream"}),"userlist.json")}function showUserBroadcastDialog(){if(xxdialogMode){return}var a='Broadcast a message to all connected users.';setDialogMode(2,"Broadcast Message",3,showUserBroadcastDialogEx,a);Q("broadcastMessage").focus()}function showUserBroadcastDialogEx(){meshserver.send({action:"userbroadcast",msg:Q("broadcastMessage").value})}function showCreateNewAccountDialog(){if(xxdialogMode){return}var d="";d+=addHtmlValue("Name","");d+=addHtmlValue("Email","");d+=addHtmlValue("Password","");d+=addHtmlValue("Password","");d+="
Force password reset on next login.
";if(passRequirements){var b=[],c=0;for(var a in passRequirements){if((a!="reset")&&(a!="hint")){b.push(a+":"+passRequirements[a]);c++}}if(c>0){d+="
Requirements: "+b.join(", ")+".
"}}setDialogMode(2,"Create Account",3,showCreateNewAccountDialogEx,d);showCreateNewAccountDialogValidate();Q("p4name").focus()}function showCreateNewAccountDialogValidate(b){if((b==null)&&(Q("p4email").value.length>0)&&(validateEmail(Q("p4email").value))==false){QE("idx_dlgOkButton",false);return}var a=(!Q("p4name")||((Q("p4name").value.length>0)&&(Q("p4name").value.indexOf(" ")==-1)))&&Q("p4pass1").value.length>0&&Q("p4pass1").value==Q("p4pass2").value&&checkPasswordRequirements(Q("p4pass1").value,passRequirements);if(a&&passRequirements){if(checkPasswordRequirements(Q("p4pass1").value,passRequirements)==false){a=false}}QE("idx_dlgOkButton",a)}function showCreateNewAccountDialogEx(){meshserver.send({action:"adduser",username:Q("p4name").value,email:Q("p4email").value,pass:Q("p4pass1").value,resetNextLogin:Q("p4resetNextLogin").checked})}function showUserGroupDialog(a,d){if(xxdialogMode){return}haltEvent(a);d=decodeURIComponent(d);var c=users[d.toLowerCase()],b="";if(c.groups!=null){b=c.groups.join(", ")}var g="Enter a comma seperate list of groups.
";g+=addHtmlValue("Groups",'');setDialogMode(2,"User Groups",3,showUserGroupDialogEx,g,c);focusTextBox("dp4usergroups");p4validateUserGroups();return false}function p4validateUserGroups(){var b=Q("dp4usergroups").value;var e=0,c=b.indexOf('"')+b.indexOf("/")+b.indexOf(">")+b.indexOf("<")+b.indexOf("'");var a=b.split(",");for(var d in a){if(a[d].trim().length==0){e++}}QE("idx_dlgOkButton",(b=="")||((c==-5)&&(e<1)))}function showUserGroupDialogEx(a,h){var d=Q("dp4usergroups").value,b=d.split(","),c=[];for(var e in b){var k=b[e].trim();if(k.length>0){c.push(k)}}meshserver.send({action:"edituser",id:h._id,groups:c})}function showUserAdminDialog(a,c){if(xxdialogMode){return}haltEvent(a);c=decodeURIComponent(c);var d="
";d+="Server Files, k max, blank for default ";d+="Full Administrator ";d+="Server Backup ";d+="Server Restore ";d+="Server Updates ";d+="Manage Users ";d+="Lock Account ";d+="No New Device Groups ";d+="No Tools (MeshCmd/Router) ";d+="
";var b=users[c.toLowerCase()];setDialogMode(2,"Server Permissions",3,showUserAdminDialogEx,d,b);if(b.siteadmin&&b.siteadmin!=0){Q("ua_fulladmin").checked=(b.siteadmin==4294967295);Q("ua_serverbackup").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&1)!=0));Q("ua_manageusers").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&2)!=0));Q("ua_serverrestore").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&4)!=0));Q("ua_fileaccess").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&8)!=0));Q("ua_serverupdate").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&16)!=0));Q("ua_lockedaccount").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&32)!=0));Q("ua_nonewgroups").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&64)!=0));Q("ua_nomeshcmd").checked=((b.siteadmin!=4294967295)&&((b.siteadmin&128)!=0))}QE("ua_fulladmin",userinfo.siteadmin==4294967295);QE("ua_serverbackup",userinfo.siteadmin==4294967295);QE("ua_manageusers",userinfo.siteadmin==4294967295);QE("ua_serverrestore",userinfo.siteadmin==4294967295);QE("ua_fileaccess",userinfo.siteadmin==4294967295);QE("ua_fileaccessquota",userinfo.siteadmin==4294967295);QE("ua_serverupdate",userinfo.siteadmin==4294967295);QE("ua_lockedaccount",(userinfo.siteadmin&2)&&(b.siteadmin!=4294967295)&&(userinfo._id!=b._id));QE("ua_nonewgroups",(userinfo.siteadmin&2)&&(b.siteadmin!=4294967295)&&(userinfo._id!=b._id));QE("ua_nomeshcmd",(userinfo.siteadmin&2)&&(b.siteadmin!=4294967295)&&(userinfo._id!=b._id));Q("ua_fileaccessquota").value=(b.quota!=null)?(b.quota/1024):"";showUserAdminDialogValidate();return false}function showUserAdminDialogValidate(){if(userinfo.siteadmin==4294967295){QE("ua_serverbackup",!Q("ua_fulladmin").checked);QE("ua_manageusers",!Q("ua_fulladmin").checked);QE("ua_serverrestore",!Q("ua_fulladmin").checked);QE("ua_fileaccess",!Q("ua_fulladmin").checked);QE("ua_serverupdate",!Q("ua_fulladmin").checked);QE("ua_lockedaccount",!Q("ua_fulladmin").checked);QE("ua_nonewgroups",!Q("ua_fulladmin").checked);QE("ua_nomeshcmd",!Q("ua_fulladmin").checked);QE("ua_fileaccessquota",Q("ua_fileaccess").checked&&!Q("ua_fulladmin").checked)}}function showUserAdminDialogEx(a,d){var c=0,b=parseInt(Q("ua_fileaccessquota").value);if(Q("ua_fulladmin").checked==true){c=4294967295}else{if(Q("ua_serverbackup").checked==true){c+=1}if(Q("ua_manageusers").checked==true){c+=2}if(Q("ua_serverrestore").checked==true){c+=4}if(Q("ua_fileaccess").checked==true){c+=8}if(Q("ua_serverupdate").checked==true){c+=16}if(Q("ua_lockedaccount").checked==true){c+=32}if(Q("ua_nonewgroups").checked==true){c+=64}if(Q("ua_nomeshcmd").checked==true){c+=128}}var e={action:"edituser",id:d._id,siteadmin:c};if(isNaN(b)==false){e.quota=(b*1024)}meshserver.send(e)}function onUserSearchInputChanged(){updateUsers()}var currentUser=null;function gotoUser(r,g){if(xxdialogMode&&!g){return}var p=currentUser=users[decodeURIComponent(r)];if(p==null){setDialogMode(0);go(4);return}QH("p30userName",p.name);QH("p31userName",p.name);var o=(p.name==userinfo.name),a=0;if(wssessions!=null&&wssessions[p._id]){a=wssessions[p._id]}Q("MainUserImage").classList.remove("gray");if(a==0){Q("MainUserImage").classList.add("gray")}var l=[],n="";if((p.siteadmin!=null)&&((p.siteadmin&32)!=0)&&(p.siteadmin!=4294967295)){n=' ';l.push("Locked account")}if((p.siteadmin==null)||((p.siteadmin&(4294967295-224))==0)){l.push("No server rights")}else{if(p.siteadmin==8){l.push("Access to server files")}else{if(p.siteadmin==4294967295){l.push("Full administrator")}else{l.push("Partial rights")}}}if((p.siteadmin!=null)&&(p.siteadmin!=4294967295)&&((p.siteadmin&(64+128))!=0)){l.push("Restrictions")}var s="
";var c=p.email?EscapeHtml(p.email):"Not set",d="";if(serverinfo.emailcheck){d=((p.emailVerified==true)?'🗸 ':'🗴 ')}if(p.name.toLowerCase()!=p._id.split("/")[2]){s+=addDeviceAttribute("User Identifier",p._id.split("/")[2])}if((p.siteadmin!=4294967295)||(userinfo.siteadmin==4294967295)){s+=addDeviceAttribute("Email",d+''+c+'')}else{s+=addDeviceAttribute("Email",d+c+' ')}s+=addDeviceAttribute("Server Rights",n+''+l.join(", ")+"");if(p.quota){s+=addDeviceAttribute("Server Quota",EscapeHtml(parseInt(p.quota)/1024)+" k")}s+=addDeviceAttribute("Creation",new Date(p.creation*1000).toLocaleString());if(p.login){s+=addDeviceAttribute("Last Login",new Date(p.login*1000).toLocaleString())}if(p.passchange==-1){s+=addDeviceAttribute("Password","Will be changed on next login.")}else{if(p.passchange){s+=addDeviceAttribute("Password","Last changed: "+new Date(p.passchange*1000).toLocaleString())}}var j=0,k="None";if(p.links){for(var h in p.links){j++}if(j==1){k="1 group"}else{if(j>1){k=j+" groups"}}}s+=addDeviceAttribute("Device Groups",k);var q="None";if(p.groups){q="";for(var h in p.groups){q+=''+p.groups[h]+""}}s+=addDeviceAttribute("User Groups",addLinkConditional(q,'showUserGroupDialog(event,"'+r+'")',(userinfo.siteadmin==4294967295)||((userinfo.groups==null)&&(userinfo.siteadmin&2)&&(userinfo._id!=p._id)&&(p._id!=4294967295))));var m=0;if((p.otpsecret>0)||(p.otphkeys>0)){m=1;var e=[];if(p.otpsecret>0){e.push("Authentication App")}if(p.otphkeys>0){e.push("Security Key")}if(p.otpkeys>0){e.push("Backup Codes")}s+=addDeviceAttribute("Security",' '+e.join(", "))}s+="
";QH("p30html3",s);s="";if(a==1){s="1 active session"}else{if(a>1){s=a+" active sessions"}}QH("MainUserState",s);go(30);QH("p31events","");refreshUsersEvents()}function p30showUserEmailChangeDialog(a){if(xxdialogMode){return}var b="";b+=addHtmlValue("Email","");if(serverinfo.emailcheck){b+=addHtmlValue("Status","")}setDialogMode(2,"Change Email for "+EscapeHtml(currentUser.name),3,p30showUserEmailChangeDialogEx,b);Q("dp30email").focus();Q("dp30email").value=(currentUser.email?currentUser.email:"");if(serverinfo.emailcheck){Q("dp30verified").value=currentUser.emailVerified?1:0}p30validateEmail()}function p30validateEmail(){var a=Q("dp30email").value,b=a.split("@");b=(b.length==2)&&(b[0].length>0)&&(b[1].split(".").length>1)&&(b[1].length>2)&&(a.length<1024)&&((a!=userinfo.email)||((serverinfo.emailcheck==true)&&(Q("dp30verified").value!=(userinfo.emailVerified?1:0))));QE("idx_dlgOkButton",b)}function p30showUserEmailChangeDialogEx(){var a={action:"edituser",id:currentUser._id,email:Q("dp30email").value};if(serverinfo.emailcheck){a.emailVerified=(Q("dp30verified").value==1)}meshserver.send(a)}function p30showUserChangePassDialog(b){if(xxdialogMode){return}var e="";e+=addHtmlValue("Password","");e+=addHtmlValue("Password","");if(features&65536){e+=addHtmlValue("Password hint","")}if(passRequirements){var c=[],d=0;for(var a in passRequirements){if((a!="reset")&&(a!="hint")){c.push(a+":"+passRequirements[a]);d++}}if(d>0){e+="
Requirements: "+c.join(", ")+".
"}}e+="
Force password reset on next login.
";if(b==1){e+="
Remove all 2nd factor authentication.
"}setDialogMode(2,"Change Password for "+EscapeHtml(currentUser.name),3,p30showUserChangePassDialogEx,e,b);showCreateNewAccountDialogValidate(1);Q("p4pass1").focus()}function p30showUserChangePassDialogEx(a,e){var d=false;if((e==1)&&(Q("p4twoFactorRemove").checked==true)){d=true}if(Q("p4pass1").value==Q("p4pass2").value){var c={action:"changeuserpass",userid:currentUser._id,pass:Q("p4pass1").value,removeMultiFactor:d,resetNextLogin:Q("p4resetNextLogin").checked};if(features&65536){c.hint=Q("p4hint").value}meshserver.send(c)}}function p30showDeleteUserDialog(){if(xxdialogMode){return}setDialogMode(2,"Delete User "+EscapeHtml(currentUser.name),3,p30showDeleteUserDialogEx,"Confirm deletion of user "+EscapeHtml(currentUser.name)+"?")}function p30showDeleteUserDialogEx(){meshserver.send({action:"deleteuser",userid:currentUser._id,username:currentUser.name})}function drawUserTimeline(){var s=null,o=Date.now();s=[];var e=new Date();e.setHours(0,0,0,0);e=new Date(e.getTime()-(1000*60*60*24*6));var u=e.getTime();var t=[];if(s!=null&&s.length>1){t.push([0,s[1],s[0]]);var c=s[1];for(var m=2;m(m+1)){k=s[m+1]}t.push([c,c+k,p]);c=c+k}}var z="",b=1,h=new Date();h.setHours(0,0,0,0);for(var m=0;m<7;m++){var g="",q=h.getTime(),l=q+(1000*60*60*24);for(var n in t){var a=t[n];if(isTimeBlockInside(q,l,a[0],a[1])==true){var w=Math.max(q,a[0]);var r=Math.min(Math.min(l,a[1]),o);var y=Math.round((r-w)/112794);if(y>0){var v=powerStateStrings2[a[2]]+" from "+new Date(w).toLocaleTimeString()+" to "+new Date(r).toLocaleTimeString()+".";g+='"}}}z+="
")}var currentUserEvents=null;function userEventsUpdate(){var h="",a=null;for(var c in currentUserEvents){var b=currentUserEvents[c];var g=new Date(b.time);if(g.toLocaleDateString()!=a){if(a!=null){h+=""}h+="