";if((l.latest.indexOf(".")==-1)||(l.current==l.latest)||((features&2048)==0)){setDialogMode(2,"MeshCentral Version",1,null,I)}else{setDialogMode(2,"MeshCentral Version",3,server_showVersionDlgEx,I+" ");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 I="
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 '+C+'
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 I="One time tokens can be used as secondary authentication. Generate a set, print them and keep them in a safe place.";I+="
";if(l.passwords){var g=0;for(var d in l.passwords){if(++g%2){I+="
")}},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"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"accountcreate":case"accountchange":if(userinfo.name==l.event.account.name){var t=l.event.account.siteadmin?l.event.account.siteadmin:0;var w=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"})}userinfo=l.event.account;if(w!=t){updateSiteAdmin()}updateSelf()}if(users==null){break}users[l.event.account._id]=l.event.account;updateUsers();break;case"accountremove":if(users==null){break}delete users["user/"+domain+"/"+l.event.username.toLowerCase()];updateUsers();break;case"createmesh":if(l.event.links["user/"+domain+"/"+userinfo.name.toLowerCase()]!=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.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["user/"+domain+"/"+userinfo.name.toLowerCase()]==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(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 v=l.event.node;if(!meshes[v.meshid]){break}v.namel=v.name.toLowerCase();if(v.rname){v.rnamel=v.rname.toLowerCase()}else{v.rnamel=v.namel}v.meshnamel=meshes[v.meshid].name.toLowerCase();v.state=0;if(!v.icon){v.icon=1}v.ident=++nodeShortIdent;if(nodes==null){}nodes.push(v);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 v=nodes[e];if(currentNode==v){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 v=nodes[e];v.name=l.event.node.name;v.rname=l.event.node.rname;v.users=l.event.node.users;v.host=l.event.node.host;v.desc=l.event.node.desc;v.osdesc=l.event.node.osdesc;v.publicip=l.event.node.publicip;v.iploc=l.event.node.iploc;v.wifiloc=l.event.node.wifiloc;v.gpsloc=l.event.node.gpsloc;v.tags=l.event.node.tags;v.userloc=l.event.node.userloc;if(l.event.node.agent!=null){if(v.agent==null){v.agent={}}if(l.event.node.agent.ver!=null){v.agent.ver=l.event.node.agent.ver}if(l.event.node.agent.id!=null){v.agent.id=l.event.node.agent.id}if(l.event.node.agent.caps!=null){v.agent.caps=l.event.node.agent.caps}if(l.event.node.agent.core!=null){v.agent.core=l.event.node.agent.core}else{if(v.agent.core){delete v.agent.core}}v.agent.tag=l.event.node.agent.tag}if(l.event.node.intelamt!=null){if(v.intelamt==null){v.intelamt={}}if(l.event.node.intelamt.host!=null){v.intelamt.user=l.event.node.intelamt.host}if(l.event.node.intelamt.user!=null){v.intelamt.user=l.event.node.intelamt.user}if(l.event.node.intelamt.tls!=null){v.intelamt.tls=l.event.node.intelamt.tls}if(l.event.node.intelamt.ver!=null){v.intelamt.ver=l.event.node.intelamt.ver}if(l.event.node.intelamt.state!=null){v.intelamt.state=l.event.node.intelamt.state}}v.namel=v.name.toLowerCase();if(v.rname){v.rnamel=v.rname.toLowerCase()}else{v.rnamel=v.namel}if(l.event.node.icon){v.icon=l.event.node.icon}masterUpdate(2|4|8|16);refreshDevice(v._id);if((currentNode==v)&&(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 v=nodes[e];if(meshes[l.event.newMeshId]==null){if(currentNode==v){if(xxcurrentView>=10&&xxcurrentView<20){setDialogMode(0);go(1)}currentNode=null}nodes.splice(e,1);masterUpdate(4|16)}else{v.meshid=l.event.newMeshId;v.meshnamel=meshes[l.event.newMeshId].name.toLowerCase();masterUpdate(1|2|4)}refreshDevice(l.event.nodeid)}else{var v=l.event.node;if(!meshes[v.meshid]){break}v.namel=v.name.toLowerCase();if(v.rname){v.rnamel=v.rname.toLowerCase()}else{v.rnamel=v.namel}v.meshnamel=meshes[v.meshid].name.toLowerCase();v.state=0;if(!v.icon){v.icon=1}v.ident=++nodeShortIdent;if(nodes==null){}nodes.push(v);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 v=nodes[e];v.conn=l.event.conn;v.pwr=l.event.pwr;masterUpdate(4|16);refreshDevice(v._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 I="";if(l.event.results==null){I="
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 z=l.event.results[d],E=z.hostname;if(E.length>20){E=E.substring(0,20)+"..."}var G=''+EscapeHtml(E)+" - v"+z.ver;if(z.state==2){if(z.tls==1){G+=" with TLS."}else{G+=" without TLS."}}else{G+=" not activated."}I+='
'+G+"
"}if(I==""){I="
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
";x.push(nodes[t]._id)}}}}if((sort==3)&&(H!="")){if(nodes[t].tags){for(var w in nodes[t].tags){var K=nodes[t].tags[w];if(s[K]==null){s[K]=H;p[K]=1}else{s[K]+=H;p[K]+=1}if(O==3){break}}}H=""}deviceHeaderTotal++;if(typeof deviceHeaderCount[nodes[t].state]=="undefined"){deviceHeaderCount[nodes[t].state]=1}else{deviceHeaderCount[nodes[t].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];H+="
No devices are included in any groups, click on a device\'s "Groups" to add to a group.
'}else{H='
No devices matching this search.
'}}if((O==1)&&(a==2)){H+="
"}if((sort==0)&&(Q("SearchInput").value=="")&&(O<3)){for(var t in meshes){var y=meshes[t],A=y.links["user/"+domain+"/"+userinfo.name.toLowerCase()];if(A!=null){var C=A.rights;if(l[y._id]==null){if((g!="")&&(H!="")){H+=""}H+="
";QH("xdevices",H);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 I=P.x+2,N=M-5,R=Math.floor(N/I);R=I+Math.floor((N-(R*I))/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],J=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_"+J).appendChild(h.m.CanvasId);delete h.xxdelete;QH("skvmid_"+J,["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_"+J);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_"+J).appendChild(a);QH("skvmid_"+J,["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=J;desktop.onStateChanged=onMultiDesktopStateChange;multiDesktop[v]=desktop;desktop=desktopNode=currentNode=null;QH("DeskParent",'')}else{var a=document.createElement("canvas");a.setAttribute("id","kvmid_"+J);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_"+J).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["user/"+domain+"/"+userinfo.name.toLowerCase()].rights;if((b&8)||(b&256)){if(c.conn&1){connectMultiDesktop(c,1)}}}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(b.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(b.name)+" run the following command. Root credentials will be needed. ";j+="";j+="
";j+='
To add a new computer to device group "'+EscapeHtml(b.name)+'", download the mesh agent and install it the computer to manage. This agent installer has server and mesh information embedded within it.
To remove a mesh agent, run the following command. Root credentials will be needed. ";j+="";j+="
";setDialogMode(2,"Add Mesh Agent",2,null,j,"fileDownload");var h=serverinfo.name;if((h=="un-configured")||((features&2)!=0)){h=window.location.hostname}var e=((features&8192)!=0)?"--no-proxy ":"";if(serverinfo.https==true){var g=(serverinfo.port==443)?"":(":"+serverinfo.port);Q("agins_linux_area").value="wget https://"+h+g+"/meshagents?script=1 "+e+"--no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://"+h+g+" '"+d.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="wget https://"+h+g+"/meshagents?script=1 "+e+"--no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}else{var g=(serverinfo.port==80)?"":(":"+serverinfo.port);Q("agins_linux_area").value="wget http://"+h+g+"/meshagents?script=1 "+e+"-O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://"+h+g+" '"+d.split("/")[2]+"'\r\n";Q("agins_linux_area_un").value="wget http://"+h+g+"/meshagents?script=1 "+e+"-O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n"}Q("aginsSelect").focus();addAgentToMeshClick()}function fileDownload(g,d,a){var h=null,c="";if(a==1){c=Q("aginsType").value}else{if(a==2){c=Q("aginsSelect").value;if(parseInt(c)>=5){d=d.toLowerCase()}else{d+=".exe"}}}try{h=new XDomainRequest()}catch(b){}if(!h){h=new XMLHttpRequest()}h.open("GET",window.location.href+g+c);h.timeout=15000;h.responseType="blob";h.onprogress=function(e){};h.onload=function(j){saveAs(new Blob([j.target.response],{type:"application/octet-stream"}),d);if(xxdialogTag=="fileDownload"){setDialogMode(0)}};h.onerror=function(){if(xxdialogTag=="fileDownload"){setDialogMode(0)}alert("Agent downloads timeout.")};h.ontimeout=function(){if(xxdialogTag=="fileDownload"){setDialogMode(0)}alert("Unable to download agent.")};h.send()}function addAgentToMeshClick(){var a=Q("aginsSelect").value;QV("agins_windows",a==0);QV("agins_linux",a==1);QV("agins_osx",a==2);QV("agins_windows_un",a==3);QV("agins_linux_un",a==4);QV("aginsTypeDiv",a==0);if(debugmode>0){Q("aginswmshlnk").href=(Q("aginswmshlnk").href.split("installflags=")[0])+"installflags="+Q("aginsType").value}}function validateDeviceToMesh(){QE("idx_dlgOkButton",(Q("dp1devicename").value.length>0)&&(passwordcheck(Q("dp1password").value)))}function addDeviceToMeshEx(b,d){var a=Q("dp1username").value;if(a==""){a="admin"}var c=Q("dp1hostname").value;if(c==""){c=Q("dp1devicename").value}meshserver.send({action:"addamtdevice",meshid:d,devicename:Q("dp1devicename").value,hostname:c,amtusername:a,amtpassword:Q("dp1password").value,amttls:Q("dp1tls").value})}function deviceHeaderSet(){if(deviceHeaderId==0){deviceHeaderId=1;return}deviceHeaders["DevxHeader"+deviceHeaderId]=", "+deviceHeaderTotal+((deviceHeaderTotal==1)?" node":" nodes");deviceHeaderId++;deviceHeaderCount={};deviceHeaderTotal=0}var powerStateStrings=["",'Powered','Sleeping','Sleeping','Deep Sleep','Hibernating','Soft-Off','Present'];var powerStateStrings2=["","Device is powered","Device is in sleep state (S1)","Device is in sleep state (S2)","Device is in deep sleep state (S3)","Device is hibernating (S4)","Device is in soft-off state (S5)","Device is present, but power state cannot be determined"];var powerColorTable=["#00000000","black","blue","blue","lightblue","blueviolet","darkgreen","lightseagreen","lightseagreen"];function NodeStateStr(a){var b=[];if(a.state>0&&a.stateAgent')}if((a.conn&2)!=0){b.push('CIRA')}if((a.conn&4)!=0){b.push('Intel® AMT')}if((a.conn&8)!=0){b.push('Relay')}}if((a.pwr!=null)&&(a.pwr!=0)){b.push(powerStateStrings[a.pwr])}return b.join(", ")}function PowerStateStr(a){if(a0){QE("GroupActionButton",true);Q("SelectAllButton").value="Select None";QV("cxmgroupsplit",true);QV("cxmdesktop",true)}else{QE("GroupActionButton",false);Q("SelectAllButton").value="Select All";QV("cxmgroupsplit",false);QV("cxmdesktop",false)}}function groupActionFunction(){var a="Select an operation to perform on all selected devices. Actions will be performed only with proper rights.
"}QV("xmapSearchResultsDlg",true)}QH("xmapSearchResults",k)}catch(g){}}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["user/"+domain+"/"+userinfo.name.toLowerCase()].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,"New Device Group",1,null,'Unable to create a new device group 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(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["user/"+domain+"/"+userinfo.name.toLowerCase()].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){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'}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/icons200-"+q.icon+"-1.jpg");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="MeshCentral - "+currentNode.name}else{document.title="MeshCentral"}}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["user/"+domain+"/"+userinfo.name.toLowerCase()].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)+'"?
","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){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")}}}function account_removehkey(a){meshserver.send({action:"otp-hkey-remove",index:a});meshserver.send({action:"otp-hkey-get"})}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. Password hint can be used but is not recommanded.
";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.emailVerified!==true)&&(serverinfo.emailcheck==true)&&(userinfo.siteadmin!=4294967295)){setDialogMode(2,"New Device Group",1,null,'Unable to create a new device group 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}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 j="Unknown #"+currentMesh.mtype;var h=0;try{h=currentMesh.links["user/"+domain+"/"+userinfo.name.toLowerCase()].rights}catch(c){}if(currentMesh.mtype==1){j="Intel® AMT only, no agent"}if(currentMesh.mtype==2){j="Managed using a software agent"}var o="";o+=addHtmlValue("Name",addLinkConditional(EscapeHtml(currentMesh.name),"p20editmesh(1)",(h&1)!=0));o+=addHtmlValue("Description",addLinkConditional(((currentMesh.desc&¤tMesh.desc!="")?EscapeHtml(currentMesh.desc):"None"),"p20editmesh(2)",(h&1)!=0));var g=[];if(currentMesh.flags){if(currentMesh.flags&1){g.push("Auto-Remove")}}g=g.join(", ");if(g==""){g="None"}o+=addHtmlValue("Features",addLinkConditional(g,"p20editmeshfeatures()",(h&1)!=0));o+=addHtmlValue("Type",j);if(currentMesh.mtype==2){var e="No Policy";if(currentMesh.amt){if(currentMesh.amt.type==1){e="Deactivate Client Control Mode (CCM)"}else{if(currentMesh.amt.type==2){e="Simple Client Control Mode (CCM)";if(currentMesh.amt.cirasetup==2){e+=" + CIRA"}}}}o+=addHtmlValue("Intel® AMT",addLinkConditional(e,"p20editMeshAmt()",(h&4294967295)!=0))}if(h&1){o+=' '}o+="
';var a=1,m=[];for(var d in currentMesh.links){m.push({id:d,name:d.split("/")[2],rights:currentMesh.links[d].rights})}m.sort(function(p,q){if(p.name>q.name){return 1}if(p.name'}o+='
"}QH("p20info",o)}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;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","");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),cirasetup:parseInt(Q("dp20amtcira").value)}}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 Features",3,p20editmeshfeaturesEx,b)}function p20editmeshfeaturesEx(){var a=0;if(Q("d20flag1").checked){a+=1}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
";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+="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["user/"+domain+"/"+userinfo.name.toLowerCase()].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("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}}meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,username:Q("dp20username").value,meshadmin:a})}function p20viewuser(e){if(xxdialogMode){return}e=decodeURIComponent(e);var d="",b=currentMesh.links["user/"+domain+"/"+userinfo.name.toLowerCase()].rights,c=currentMesh.links[e].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&256)!=0){d+=", Remote View Only"}if((c&512)!=0){d+=", No Terminal"}if((c&1024)!=0){d+=", No Files"}if((c&2048)!=0){d+=", No Intel® AMT"}}d=d.substring(2);if(d==""){d="No Rights"}var a=1,g=addHtmlValue("User Name",EscapeHtml(decodeURIComponent(e.split("/")[2])));g+=addHtmlValue("Permissions",d);if((("user/"+domain+"/"+userinfo.name.toLowerCase())!=e)&&(b==4294967295||(((b&2)!=0)&&(c!=4294967295)))){a+=4}setDialogMode(2,"Device Group User",a,p20viewuserEx,g,e)}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 g=[],d=100,b=0;for(var c in users){g.push(c)}g.sort();var j=Q("UserSearchInput").value.toLowerCase();var k="
",a=true;k+="
Name
Groups
Last Access
Permissions";for(var c in g){var h=users[g[c]],e=null;if(wssessions!=null){e=wssessions[h._id]}if((e!=null)&&(h.name.toLowerCase().indexOf(j)>=0)){if(d>0){if(a){k+="
Online Users";a=false}k+=addUserHtml(h,e);d--}else{b++}}}a=true;for(var c in g){var h=users[g[c]],e=null;if(wssessions!=null){e=wssessions[h._id]}if((e==null)&&(h.name.toLowerCase().indexOf(j)>=0)){if(d>0){if(a){k+="
"+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 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+="
";QH("p30html3",r);r="";if(a==1){r="1 active session"}else{if(a>1){r=a+" active sessions"}}QH("MainUserState",r);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;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",name:currentUser.name,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",user:currentUser.name,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+="