>4])+(md5_k[o]+(r[[o,5*o+1,3*o+5,7*o][e]%16+n]|0))))<<(e=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*e+o++%4])|l>>>32-e)),g,k]}for(o=4;o;){m[--o]=m[o]+e[o]}}p="";for(;o<32;){p+=((m[o>>3]>>((1^o++&7)*4))&15).toString(16)}return p}function rstr_md5(a){return hex2rstr(hex_md5(a))}function execArgumentsToXml(c){if(c===undefined||c===null){return null}var d="";for(var b in c){var a=c[b];if(!a){continue}if(a.__parameterType==="reference"){d+=referenceToXml(b,a)}else{d+=instanceToXml(b,a)}}return d}function instanceToXml(d,c){if(c===undefined||c===null){return null}var b=!!c.__namespace;var j=b?"
r[1]){K.recordLineTobackBuffer(0);A(1);F=r[1]}if(K.lineFeed="\r"){E=0}break;case"\r":E=0;break;default:if(E>=K.width){E=0;if(z){F++}if(F>=(K.height-1)){A(1);F=(K.height-1)}}w(N);E++;break}}function w(N){G[F][E]=N;q[F][E]=(u<<6)+(t<<12)+v}K.TermClear=function(N){for(var P=0;P "+a+" "+(a?a:"")+"
")};K.TermDrawLine=function(N,W,P){var R,O,S=1,U,V;for(var T=0;T1){console.log("KSend("+g.length+"): "+rstr2hex(g))}d.parent.send(g)};d.ProcessPictureMsg=function(h,k,l){var j=new Image();j.xcount=d.tilesReceived++;var g=d.tilesReceived;j.src="data:image/jpeg;base64,"+btoa(h.substring(4,h.length));j.onload=function(){if(d.Canvas!=null&&d.KillDraw'],M=0;p>M;M++){s.push("
"),o.innerHTML=s.join("");var O=o.childNodes[0],P=(n.width-O.offsetWidth)/2,R=(n.height-O.offsetHeight)/2;P>0&&R>0&&(O.style.margin=R+"px "+P+"px")},b.prototype.clear=function(){this._el.innerHTML=""},b}();QRCode=function(d,e){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:w.H},"string"==typeof e&&(e={text:e}),e){for(var g in e){this._htOption[g]=e[g]}}"string"==typeof d&&(d=document.getElementById(d)),this._android=G(),this._el=d,this._oQRCode=null,this._oDrawing=new J(this._el,this._htOption),this._htOption.text&&this.makeCode(this._htOption.text)},QRCode.prototype.makeCode=function(b){this._oQRCode=new u(K(b,this._htOption.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(b),this._oQRCode.make(),this._el.title=b,this._oDrawing.draw(this._oQRCode),this.makeImage()},QRCode.prototype.makeImage=function(){"function"==typeof this._oDrawing.makeImage&&(!this._android||this._android>=3)&&this._oDrawing.makeImage()},QRCode.prototype.clear=function(){this._oDrawing.clear()},QRCode.CorrectLevel=w}();"use strict";var webState="{{{webstate}}}";if(webState!=""){webState=JSON.parse(decodeURIComponent(webState))}for(var i in webState){localStorage.setItem(i,webState[i])}if(!webState.loctag){delete localStorage.removeItem("loctag")}var args;var autoReconnect=true;var powerStatetable=["","Powered","Sleep","Sleep","Sleep","Hibernating","Power off","Present"];var StatusStrs=["Disconnected","Connecting...","Setup...","Connected","Intel® AMT Connected"];var sort=0;var searchFocus=0;var mapSearchFocus=0;var userSearchFocus=0;var consoleFocus=0;var showRealNames=false;var meshserver=null;var meshes={};var meshcount=0;var nodes=null;var filetree={};var userinfo=null;var serverinfo=null;var events=[];var users=null;var wssessions=null;var nodeShortIdent=0;var desktop;var desktopsettings={encoding:2,showfocus:false,showmouse:true,showcad:true,quality:40,scaling:1024,framerate:50,localkeymap:false};var multidesktopsettings={quality:20,scaling:128,framerate:1000};var terminal;var files;var debugLevel=parseInt("{{{debuglevel}}}");var features=parseInt("{{{features}}}");var sessionTime=parseInt("{{{sessiontime}}}");var domain="{{{domain}}}";var domainUrl="{{{domainurl}}}";var authCookie="{{{authCookie}}}";var authCookieRenewTimer=null;var multiDesktop={};var multiDesktopFilter=null;var serverPublicNamePort="{{{serverDnsName}}}:{{{serverPublicPort}}}";var amtScanResults=null;var debugmode=0;var clickOnce=(((features&256)!=0)&&detectClickOnce());var attemptWebRTC=((features&128)!=0);var passRequirements="{{{passRequirements}}}";if(passRequirements!=""){passRequirements=JSON.parse(decodeURIComponent(passRequirements))}var deskAspectRatio=0;try{deskAspectRatio=parseInt(getstore("deskAspectRatio","0"))}catch(ex){}var uiMode=parseInt(getstore("uiMode",1));var webPageStackMenu=false;var webPageFullScreen=true;var nightMode=(getstore("_nightMode","0")=="1");var sessionActivity=Date.now();var p11DeskConsoleMsgTimer=null;var p12TermConsoleMsgTimer=null;var p13FilesConsoleMsgTimer=null;function startup(){if((features&32)==0){var h=null;try{h=top.location.toString().toLowerCase()}catch(b){}if(top!=self&&(h==null||top.active==false)){top.location=self.location;return}}args=parseUriArgs();if(!args.locale){var l=getstore("loctag",0);if((l!=null)&&(l!="*")){args.locale=l}}debugmode=args.debug;if(args.webrtc!=null){attemptWebRTC=(args.webrtc==1)}QV("p13AutoConnect",debugmode);QV("autoconnectbutton2",debugmode);QV("autoconnectbutton1",debugmode);if(nightMode){QC("body").add("night")}toggleFullScreen();if(args.hide){var d=parseInt(args.hide);QV("masthead",!(d&1));QV("topbar",!(d&2));QV("footer",!(d&4));QV("p10title",!(d&8));QV("p11title",!(d&8));QV("p12title",!(d&8));QV("p13title",!(d&8));QV("p14title",!(d&8));QV("p15title",!(d&8));QV("p16title",!(d&8));QS("container")["grid-template-rows"]=((d&1)?"0":"66")+"px "+((d&2)?"0":"24")+"px auto "+((d&4)?"0":"45")+"px";QS("container")["-ms-grid-rows"]=((d&1)?"0":"66")+"px "+((d&2)?"0":"24")+"px auto "+((d&4)?"0":"45")+"px";var m=(((d&1)?0:66)+((d&2)?0:24)+((d&4)?0:45)+((d&8)?0:60));QS("p3users")["max-height"]="calc(100vh - "+(124+m)+"px)";QS("p3events")["height"]="calc(100vh - "+(124+m)+"px)";QS("deskarea3x")["height"]="calc(100vh - "+(75+m)+"px)";QS("deskarea3x")["max-height"]="calc(100vh - "+(75+m)+"px)";QS("p5filetable")["height"]="calc(100vh - "+(160+m)+"px)";QS("p13filetable")["height"]="calc(100vh - "+(124+m)+"px)";QS("serverMainStats")["height"]="calc(100vh - "+(110+m)+"px)";QS("serverMainStats")["max-height"]="calc(100vh - "+(110+m)+"px)";QS("xdevices")["max-height"]="calc(100vh - "+(124+m)+"px)";QS("xdevicesmap")["max-height"]="calc(100vh - "+(124+m)+"px)";QS("p15agentConsole")["height"]="calc(100vh - "+(84+m)+"px)";QS("p15agentConsole")["max-height"]="calc(100vh - "+(84+m)+"px)";QS("p15agentConsoleText")["height"]="calc(100vh - "+(81+m)+"px)";QS("p15agentConsoleText")["max-height"]="calc(100vh - "+(81+m)+"px)"}if("{{currentNode}}"!=""){QV("p10BackButton",false);QV("p11BackButton",false);QV("p12BackButton",false);QV("p13BackButton",false);QV("p14BackButton",false);QV("p15BackButton",false);QV("p16BackButton",false)}p1updateInfo();document.onclick=function(c){hideContextMenu()};document.onkeypress=ondockeypress;document.onkeydown=ondockeydown;document.onkeyup=ondockeyup;window.addEventListener("blur",ondocblur,false);window.onresize=function(){masterUpdate(512)};setTimeout("masterUpdate(512)",200);meshserver=MeshServerCreateControl(domainUrl,authCookie);meshserver.onStateChanged=onStateChanged;meshserver.onMessage=onMessage;meshserver.trace=(args.trace==1);meshserver.Start();Q("sortselect").selectedIndex=sort=getstore("sort",0);Q("sizeselect").selectedIndex=getstore("_viewsize",1);Q("SearchInput").value=getstore("_search","");showRealNames=(getstore("showRealNames",0)==1);Q("RealNameCheckBox").checked=showRealNames;Q("viewselect").value=getstore("_deviceView",1);Q("DeskControl").checked=(getstore("DeskControl",1)==1);QV("accountChangeEmailAddressSpan",(features&2097152)==0);masterUpdate(3);for(var g=1;g<5;g++){Q("devViewButton"+g).classList.remove("viewSelectorSel")}Q("devViewButton"+Q("viewselect").value).classList.add("viewSelectorSel");Q("p5filetable").addEventListener("drop",p5fileDragDrop,false);Q("p5filetable").addEventListener("dragover",p5fileDragOver,false);Q("p5filetable").addEventListener("dragleave",p5fileDragLeave,false);Q("p13filetable").addEventListener("drop",p13fileDragDrop,false);Q("p13filetable").addEventListener("dragover",p13fileDragOver,false);Q("p13filetable").addEventListener("dragleave",p13fileDragLeave,false);setInterval(updateDeviceTimeline,120000);var k=localStorage.getItem("desktopsettings");if(k!=null){desktopsettings=JSON.parse(k)}k=localStorage.getItem("multidesktopsettings");if(k!=null){multidesktopsettings=JSON.parse(k)}applyDesktopSettings();var l="";for(var a=1;a<27;a++){l+=""}QH("specialkeylist",l);setupGeneralServerStats();setupServerTimelineStats();userInterfaceSelectMenu();QV("p4UserBatchCreate",(features&524288)==0)}function toggleAspectRatio(a){if(a===1){deskAspectRatio=((deskAspectRatio+1)%3);putstore("deskAspectRatio",deskAspectRatio)}deskAdjust()}function toggleStackMenu(a){if(webPageFullScreen==true){if(a===1){webPageStackMenu=!webPageStackMenu;putstore("webPageStackMenu",webPageStackMenu)}if(webPageStackMenu==false){QC("body").remove("menu_stack")}else{QC("body").add("menu_stack");if(xxcurrentView>=10){QC("column_l").remove("room4submenu")}}deskAdjust()}}function showUserInterfaceSelectMenu(){Q("uiViewButton1").classList.remove("uiSelectorSel");Q("uiViewButton2").classList.remove("uiSelectorSel");Q("uiViewButton3").classList.remove("uiSelectorSel");Q("uiViewButton4").classList.remove("uiSelectorSel");try{Q("uiViewButton"+uiMode).classList.add("uiSelectorSel")}catch(a){}QV("uiMenu",(QS("uiMenu").display=="none"));if(nightMode){Q("uiViewButton4").classList.add("uiSelectorSel")}}function userInterfaceSelectMenu(a){if(a){uiMode=a;putstore("uiMode",uiMode)}webPageFullScreen=(uiMode<3);webPageStackMenu=(uiMode>1);toggleFullScreen(0);toggleStackMenu(0);if(webPageStackMenu&&(xxcurrentView>=10)){QC("column_l").add("room4submenu")}else{QC("column_l").remove("room4submenu")}}function toggleNightMode(){nightMode=!nightMode;if(nightMode){QC("body").add("night")}else{QC("body").remove("night")}putstore("_nightMode",nightMode?"1":"0")}function toggleFullScreen(b){if(b===1){webPageFullScreen=!webPageFullScreen;putstore("webPageFullScreen",webPageFullScreen)}var a=0;if(args.hide){a=parseInt(args.hide)}if(webPageFullScreen==false){QC("body").remove("menu_stack");QC("body").remove("fullscreen");QC("body").remove("arg_hide");if(xxcurrentView>=10){QC("column_l").add("room4submenu")}QV("UserDummyMenuSpan",false)}else{QC("body").add("fullscreen");if(a&16){QC("body").add("arg_hide")}if(xxcurrentView>=10){QC("column_l").remove("room4submenu")}QV("UserDummyMenuSpan",(xxcurrentView<10)&&webPageFullScreen)}masterUpdate(512);QV("body",true)}function getNodeFromId(b){if(nodes!=null){for(var a in nodes){if(nodes[a]._id==b){return nodes[a]}}}return null}function reload(){var a=window.location.href;if(a.endsWith("/#")){a=a.substring(0,a.length-2)}window.location.href=a}function onStateChanged(c,d,b,a){if(d==0){setDialogMode(0);go(0);powerTimeline=null;powerTimelineReq=null;powerTimelineNode=null;powerTimelineUpdate=null;deleteAllNotifications();hideContextMenu();QV("verifyEmailId2",false);QV("logoutControl",false);if(a=="noauth"){QH("p0span","Unable to perform authentication");return}if(b==2){if(autoReconnect){setTimeout(serverPoll,5000)}}else{QH("p0span","Unable to connect web socket")}if(authCookieRenewTimer!=null){clearInterval(authCookieRenewTimer);authCookieRenewTimer=null}}else{if(d==2){meshserver.send({action:"meshes"});meshserver.send({action:"nodes",id:"{{currentNode}}"});if("{{currentNode}}"==""){meshserver.send({action:"files"})}go(1);authCookieRenewTimer=setInterval(function(){meshserver.send({action:"authcookie"})},1800000)}}}function serverPoll(){var b=null;try{b=new XDomainRequest()}catch(a){}if(!b){b=new XMLHttpRequest()}b.open("HEAD",window.location.href);b.timeout=15000;b.onload=function(){reload()};b.onerror=b.ontimeout=function(){setTimeout(serverPoll,10000)};b.send()}function detectClickOnce(){for(var a in window.navigator.mimeTypes){if(window.navigator.mimeTypes[a].type=="application/x-ms-application"){return true}}var b=window.navigator.userAgent.toUpperCase();return(b.indexOf(".NET CLR 3.5")>=0)||(b.indexOf("(WINDOWS NT ")>=0)}function updateSiteAdmin(){var a="{{{noServerBackup}}}";var b=userinfo.siteadmin;if(a==1){b&=4294967290}QV("p2AccountSecurity",((features&4)==0)&&(serverinfo.domainauth==false)&&((features&4096)!=0));QV("p2AccountActions",((features&4)==0)&&(serverinfo.domainauth==false));QV("p2AccountImage",((features&4)==0)&&(serverinfo.domainauth==false));QV("p2ServerActions",b&21);QV("LeftMenuMyServer",b&21);QV("MainMenuMyServer",b&21);QV("p2ServerActionsBackup",b&1);QV("p2ServerActionsRestore",b&4);QV("p2ServerActionsVersion",b&16);QV("MainMenuMyFiles",b&8);QV("LeftMenuMyFiles",b&8);if(((b&8)==0)&&(xxcurrentView==5)){setDialogMode(0);go(1)}if(currentNode!=null){gotoDevice(currentNode._id,xxcurrentView,true)}if((userinfo.siteadmin&2)!=0){if(users==null){meshserver.send({action:"users"})}if(wssessions==null){meshserver.send({action:"wssessioncount"})}}else{users=null;wssessions=null;updateUsers();if(xxcurrentView==4||((xxcurrentView>=30)&&(xxcurrentView<40))){setDialogMode(0);go(1);currentUser=null}}meshserver.send({action:"events",limit:parseInt(p3limitdropdown.value)});QV("ServerConsole",userinfo.siteadmin===4294967295);if((xxcurrentView==115)&&(userinfo.siteadmin!=4294967295)){go(6)}if((xxcurrentView==6)&&((userinfo.siteadmin&21)==0)){go(1)}if((b&21)!=0){meshserver.send({action:"serverstats",interval:10000})}}var updateNaggleTimer=null;var updateNaggleFlags=0;function masterUpdate(a){updateNaggleFlags|=a;if(updateNaggleTimer==null){updateNaggleTimer=setTimeout(function(){if(updateNaggleFlags&512){center()}if(updateNaggleFlags&1){onSearchInputChanged()}if(updateNaggleFlags&2){onSortSelectChange(false)}if(updateNaggleFlags&128){updateMeshes()}if(updateNaggleFlags&4){updateDevices()}if(updateNaggleFlags&8){drawNotifications()}if(updateNaggleFlags&16){updateMapMarkers()}if(updateNaggleFlags&32){eventsUpdate()}if(updateNaggleFlags&64){refreshMap(false,true)}if(updateNaggleFlags&256){drawDeviceTimeline()}if(updateNaggleFlags&1024){deviceEventsUpdate()}if(updateNaggleFlags&2048){userEventsUpdate()}if(updateNaggleFlags&4096){p20updateMesh()}updateNaggleTimer=null;updateNaggleFlags=0},150)}}function updateSelf(){QV("verifyEmailId",(userinfo.emailVerified!==true)&&(userinfo.email!=null)&&(serverinfo.emailcheck==true));QV("verifyEmailId2",(userinfo.emailVerified!==true)&&(userinfo.email!=null)&&(serverinfo.emailcheck==true));QV("manageOtp",(userinfo.otpsecret==1)||(userinfo.otphkeys>0));QV("authAppSetupCheck",userinfo.otpsecret==1);QV("authKeySetupCheck",userinfo.otphkeys>0);QV("authCodesSetupCheck",userinfo.otpkeys>0);masterUpdate(4+128+4096);var a=((userinfo.siteadmin==4294967295)||((userinfo.siteadmin&64)==0));QV("p2createMeshLink1",a);QV("p2createMeshLink2",a);QV("getStarted1",a);QV("getStarted2",!a);if(typeof userinfo.passchange=="number"){if(userinfo.passchange==-1){QH("p2nextPasswordUpdateTime"," - Reset on next login.")}else{if((passRequirements!=null)&&(typeof passRequirements.reset=="number")){var b=(userinfo.passchange)+(passRequirements.reset*86400)-Math.floor(Date.now()/1000);if(b<0){QH("p2nextPasswordUpdateTime"," - Reset on next login.")}else{if(b<3600){QH("p2nextPasswordUpdateTime"," - Reset in "+Math.floor(b/60)+" minute"+addLetterS(Math.floor(b/60))+".")}else{if(b<86400){QH("p2nextPasswordUpdateTime"," - Reset in "+Math.floor(b/3600)+" hour"+addLetterS(Math.floor(b/3600))+".")}else{QH("p2nextPasswordUpdateTime"," - Reset in "+Math.floor(b/86400)+" day"+addLetterS(Math.floor(b/86400))+".")}}}}}}}function addLetterS(a){return(a>1)?"s":""}function setSessionActivity(){sessionActivity=Date.now();QH("idleTimeoutNotify","")}function checkIdleSessionTimeout(){var a=(Date.now()-sessionActivity);if(a>serverinfo.timeout){window.location.href="logout"}else{var b=Math.round((serverinfo.timeout-a)/1000);if(b<=60){QH("idleTimeoutNotify","");for(var N=0;p>N;N++){s.push(' ")}s.push("')}s.push("
"+b+" second"+addLetterS(b)+" until disconnect")}else{b=Math.round(b/60);if(b<=5){QH("idleTimeoutNotify","
"+b+" minute"+addLetterS(b)+" until disconnect")}}}}function onMessage(O,o){switch(o.action){case"serverstats":updateGeneralServerStats(o);break;case"servertimelinestats":setServerTimelineStats(o.events);break;case"authcookie":authCookie=o.cookie;break;case"serverinfo":serverinfo=o.serverinfo;if(serverinfo.timeout){setInterval(checkIdleSessionTimeout,10000);checkIdleSessionTimeout()}break;case"userinfo":userinfo=o.userinfo;updateSiteAdmin();updateSelf();break;case"users":users={};for(var l in o.users){users[o.users[l]._id]=o.users[l]}updateUsers();break;case"wssessioncount":wssessions=o.wssessions;updateUsers();break;case"meshes":meshes={};for(var l in o.meshes){meshes[o.meshes[l]._id]=o.meshes[l]}masterUpdate(4+128);break;case"files":filetree=setupBackPointers(o.filetree);updateFiles();d3updatefiles();break;case"nodes":nodes=[];for(var l in o.nodes){if(!meshes[l]){console.log("Invalid mesh (1): "+l);continue}for(var q in o.nodes[l]){if(o.nodes[l][q]._id==null){console.log("Invalid node ("+q+"): "+JSON.stringify(o.nodes));continue}o.nodes[l][q].namel=o.nodes[l][q].name.toLowerCase();if(o.nodes[l][q].rname){o.nodes[l][q].rnamel=o.nodes[l][q].rname.toLowerCase()}else{o.nodes[l][q].rnamel=o.nodes[l][q].namel}o.nodes[l][q].meshnamel=meshes[l].name.toLowerCase();o.nodes[l][q].meshid=l;o.nodes[l][q].state=(o.nodes[l][q].state)?(o.nodes[l][q].state):0;o.nodes[l][q].desc=o.nodes[l][q].desc;o.nodes[l][q].ip=o.nodes[l][q].ip;if(!o.nodes[l][q].icon){o.nodes[l][q].icon=1}o.nodes[l][q].ident=++nodeShortIdent;nodes.push(o.nodes[l][q])}}masterUpdate(1|2|4|64);if(xxcurrentView==0){if("{{viewmode}}"!=""){go(parseInt("{{viewmode}}"))}else{setDialogMode(0);go(1)}}if("{{currentNode}}"!=""){gotoDevice("{{currentNode}}",parseInt("{{viewmode}}"))}break;case"powertimeline":if(o.nodeid!=powerTimelineReq){break}powerTimelineNode=o.nodeid;powerTimeline=o.timeline;powerTimelineUpdate=Date.now()+300000;for(var e in powerTimeline){if(e%2==1){powerTimeline[e]=powerTimeline[e]*1000}}if(currentNode._id==o.nodeid){masterUpdate(256)}break;case"lastconnect":var z=getNodeFromId(o.nodeid);if(z!=null){z.lastconnect=o.time;z.lastaddr=o.addr;if((currentNode._id==z._id)&&(Q("MainComputerState").innerHTML=="")){QH("MainComputerState","Last seen:
"+printDateTime(new Date(z.lastconnect))+"")}}break;case"msg":if(o.nodeid!=null){var g=-1;if(nodes!=null){for(var e in nodes){if(nodes[e]._id==o.nodeid){g=e;break}}}if(g!=-1){if(o.type=="console"){p15consoleReceive(nodes[g],o.value)}else{if(o.type=="notify"){var q=getstore("notifications",0);if(((q&8)==0)&&(o.amtMessage!=null)){break}var q={text:o.value,title:o.title,icon:o.icon};if(o.nodeid!=null){q.nodeid=o.nodeid}if(o.tag!=null){q.tag=o.tag}if(o.username!=null){q.username=o.username}addNotification(q)}else{if(o.type=="ps"){showDeskToolsProcesses(o)}else{if(o.type=="services"){showDeskToolsServices(o)}else{if((o.type=="getclip")&&(xxdialogTag=="clipboard")&&(currentNode!=null)&&(currentNode._id==o.nodeid)){Q("d2clipText").value=o.data}else{if((o.type=="setclip")&&(xxdialogTag=="clipboard")&&(currentNode!=null)&&(currentNode._id==o.nodeid)){QH("dlgClipStatus",o.success?"Success":"Failed");setTimeout(function(){try{QH("dlgClipStatus","")}catch(j){}},2000)}}}}}}}}else{if(o.type=="notify"){var q={text:o.value,title:o.title,icon:o.icon};if(o.tag!=null){q.tag=o.tag}if(o.username!=null){q.username=o.username}addNotification(q)}}break;case"getnetworkinfo":if((currentNode._id==o.nodeid)&&(xxdialogMode==2)&&(xxdialogTag=="if"+o.nodeid)){if(o.netif==null){QH("d2netinfo","No network interface information available for this device.")}else{var Z="
";if(s.name){Z+=addHtmlValue2("Name",""+EscapeHtml(s.name)+"")}if(s.desc){Z+=addHtmlValue2("Description",EscapeHtml(s.desc).replace("(R)","®").replace("(r)","®"))}if(s.dnssuffix){Z+=addHtmlValue2("DNS suffix",EscapeHtml(s.dnssuffix))}if(s.mac){Z+=addHtmlValue2("MAC address",''+EscapeHtml(s.mac.toLowerCase())+' ')}if(s.v4addr){Z+=addHtmlValue2("IPv4 address",EscapeHtml(s.v4addr)+' ')}if(s.v4mask){Z+=addHtmlValue2("IPv4 mask",EscapeHtml(s.v4mask)+' ')}if(s.v4gateway){Z+=addHtmlValue2("IPv4 gateway",EscapeHtml(s.v4gateway)+' ')}if(s.gatewaymac){Z+=addHtmlValue2("Gateway MAC",''+EscapeHtml(s.gatewaymac.toLowerCase())+' ')}}Z+="
");server_showVersionDlgUpdate()}}break;case"servererrors":if((xxdialogMode==2)&&(xxdialogTag=="MeshCentralServerErrors")){if(o.data==null){setDialogMode(2,"MeshCentral Server Errors",1,null,"Server has no error log.")}else{var Z=''+o.data+"
');server_showVersionDlgUpdate()}}break;case"serverconsole":p15consoleReceive("serverconsole",o.value);break;case"events":if((o.nodeid!=null)&&(o.nodeid==currentNode._id)){currentDeviceEvents=o.events;masterUpdate(1024)}else{if((o.user!=null)&&(o.user==currentUser.name)){currentUserEvents=o.events;masterUpdate(2048)}else{events=o.events;masterUpdate(32)}}break;case"getcookie":if(o.tag=="clickonce"){var a="{{{serverRedirPort}}}"==""?"{{{serverPublicPort}}}":"{{{serverRedirPort}}}";var L="http://"+window.location.hostname+":"+a+"/clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F"+window.location.hostname+"%2Fmeshrelay.ashx%3Fauth="+o.cookie+"&CH={{{webcerthash}}}&AP="+o.protocol+((debugmode==1)?"":"&HOL=1");var w=window.open(L,"_blank");w.opener=null}break;case"getNotes":var q=Q("d2devNotes");if(q&&(o.id==decodeURIComponent(q.attributes.noteid.value))){if(o.notes){QH("d2devNotes",decodeURIComponent(o.notes))}else{QH("d2devNotes","")}var M=(q.attributes.ro.value=="true");if(M==false){q.removeAttribute("readonly");QE("idx_dlgOkButton",true);QV("idx_dlgOkButton",true);focusTextBox("d2devNotes")}}break;case"otpauth-request":if((xxdialogMode==2)&&(xxdialogTag=="otpauth-request")){var N=o.secret;if(N.length==52){N=N.split(/(.............)/).filter(Boolean).join(" ")}else{if(N.length==32){N=N.split(/(....)/).filter(Boolean).join(" ");N=N.substring(0,20)+"
"+N.substring(20)}}QH("d2optinfo",'
');new QRCode(Q("qrcode"),{text:o.url,width:128,height:128,colorDark:"#000000",colorLight:"#EEE",correctLevel:QRCode.CorrectLevel.H});QV("idx_dlgOkButton",true);QE("idx_dlgOkButton",false);Q("d2otpauthinput").focus()}break;case"otpauth-setup":if(xxdialogMode){return}setDialogMode(2,"Authenticator App",1,null,o.success?"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,o.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 Z="One time tokens can be used as secondary authentication. Generate a set, print them and keep them in a safe place.";Z+="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
'+N+'
Enter the token here for 2-step login: ";if(o.passwords){var h=0;for(var e in o.passwords){if(++h%2){Z+="
"}var H=""+o.passwords[e].p;while(H.length<8){H="0"+H}if(o.passwords[e].u===true){Z+=" "+H.substring(0,4)+" "+H.substring(4)}else{Z+=" "+H.substring(0,4)+" "+H.substring(4);+""}}}else{Z+="No Active Tokens"}Z+="
";Z+="
";setDialogMode(2,"Manage Backup Codes",8,null,Z,"otpauth-manage");break;case"otp-hkey-get":if(xxdialogMode&&(xxdialogTag!="otpauth-hardware-manage")){return}var T="";var c="
";d+='
";d+=addHtmlValue("Setup CIRA",'cira_setup.mescript');d+=addHtmlValue("Cleanup CIRA",'cira_clean.mescript');d+="
";c+=' "}c+='
';c+=addHtmlValue("Link Expiration","");c+='
";var d=c.name;d=d.split("\\").join("").split("/").join("").split(":").join("").split("*").join("").split("?").join("").split('"').join("").split("<").join("").split(">").join("").split("|").join("").split(" ").join("").split("'").join("");j+='
';j+=addHtmlValue("Mesh Agent",'Windows (.exe) ');j+=addHtmlValue("Mesh Agent",'Windows x64 (.exe) ');if(debugmode>0){j+=addHtmlValue("Settings File",''+EscapeHtml(c.name)+" settings (.msh)")}j+="
";a+=addHtmlValue("Operation","");setDialogMode(2,"Group Action",3,groupActionFunctionEx,a)}function getCheckedDevices(){var e=[],b=document.getElementsByClassName("DeviceCheckbox"),a=0;for(var c=0;c";D+=addDeviceAttribute('Group',''+EscapeHtml(meshes[r.meshid].name)+"");if((r.rname!=null)&&(r.name!=r.rname)){D+=addDeviceAttribute('Name',''+EscapeHtml(r.rname)+"")}if((features&1)==0){if((p&4)!=0){if(r.host){D+=addDeviceAttribute("Hostname",""+EscapeHtml(r.host)+"")}else{D+=addDeviceAttribute("Hostname","None")}}else{D+=addDeviceAttribute("Hostname",EscapeHtml(r.host))}}var j=r.desc?EscapeHtml(r.desc):"None";if((p&4)!=0){D+=addDeviceAttribute("Description",""+j+' ')}else{D+=addDeviceAttribute("Description",j)}var a=["Unknown","Windows 32bit console","Windows 64bit console","Windows 32bit service","Windows 64bit service","Linux 32bit","Linux 64bit","MIPS","XENx86","Android ARM","Linux ARM","MacOS 32bit","Android x86","PogoPlug ARM","Android APK","Linux Poky x86-32bit","MacOS 64bit","ChromeOS","Linux Poky x86-64bit","Linux NoKVM x86-32bit","Linux NoKVM x86-64bit","Windows MinCore console","Windows MinCore service","NodeJS","ARM-Linaro","ARMv6l / ARMv7l","ARMv8 64bit","ARMv6l / ARMv7l / NoKVM","Unknown","Unknown","FreeBSD x86-64"];if((r.agent!=null)&&(r.agent.id!=null)&&(r.agent.ver!=null)){var A="";if(r.agent.id<=a.length){A=a[r.agent.id]}else{A=a[0]}if(r.agent.ver!=0){A+=" v"+r.agent.ver}D+=addDeviceAttribute("Mesh Agent",A)}if(r.intelamt!=null){var A="";var w={0:"Not Activated (Pre)",1:"Not Activated (In)",2:"Activated"};if(r.intelamt.ver!=null&&r.intelamt.state==null){A+="Unknown State, v"+r.intelamt.ver}else{if((r.intelamt.ver==null)&&(r.intelamt.state==2)){A+="Activated"}else{if((r.intelamt.ver==null)||(r.intelamt.state==null)){A+="Unknown Version & State"}else{A+=w[r.intelamt.state];if((r.intelamt.state==2)&&r.intelamt.flags){if(r.intelamt.flags&2){A+=' CCM'}else{if(r.intelamt.flags&4){A+=' ACM'}}}A+=(", v"+r.intelamt.ver)}}}if(r.intelamt.tls==1){A+=', TLS'}if(r.intelamt.state==2){if(r.intelamt.user==null||r.intelamt.user==""){if((p&4)!=0){A+=', No Credentials'}else{A+=", No Credentials"}}A+=" ";if((p&4)!=0){A+=''}}D+=addDeviceAttribute("Intel® AMT",A)}if(o.mtype==2){if((r.agent!=null)&&(r.agent.tag!=null)){var B=EscapeHtml(r.agent.tag);if(B.startsWith("mailto:")){B=''+B.substring(7)+""}D+=addDeviceAttribute("Agent Tag",B)}}else{if((r.intelamt!=null)&&(r.intelamt.tag!=null)){var B=EscapeHtml(r.intelamt.tag);if(B.startsWith("mailto:")){B=''+B.substring(7)+""}D+=addDeviceAttribute("Intel® AMT Tag",B)}}if(r.osdesc){D+=addDeviceAttribute("Operating System",r.osdesc)}if(r.av&&r.av.length>0){var E=[];for(var n in r.av){if(r.av[n].product){var d=EscapeHtml(r.av[n].product);if(r.av[n].enabled!==true){d+=" - Disabled"}if(r.av[n].updated!==true){d+=" - Out of date"}if((r.av[n].enabled==true)&&(r.av[n].updated==true)){d+=" - OK"}E.push(d)}}D+=addDeviceAttribute("Antivirus",E.join("
"))}if(r.users&&r.conn&&(r.users.length>0)&&(r.conn&1)){D+=addDeviceAttribute("Active User"+((r.users.length>1)?"s":""),r.users.join(", "))}var e=r.conn;if(e&&e>1){var h=[];if((r.conn&1)!=0){h.push('Mesh Agent')}if((r.conn&2)!=0){h.push('Intel® AMT CIRA')}else{if((r.conn&4)!=0){h.push('Intel® AMT')}}if((r.conn&8)!=0){h.push('Mesh Relay')}D+=addDeviceAttribute("Connectivity",h.join(", "))}var m="None";if(r.tags!=null){m="";for(var n in r.tags){m+=''+r.tags[n]+""}}if((p&4)!=0){D+=addDeviceAttribute("Tags",""+m+' ')}else{D+=addDeviceAttribute("Tags",m)}D+="
";if((p&76)!=0){D+=''}D+='';QH("p10html",D);masterUpdate(256);D='
";QH("p10html3",D);var v=PowerStateStr(r.state);if((e&1)!=0){if(v.length>0){v+="
"}v+='Agent connected'}if((e&2)!=0){if(v.length>0){v+="
"}v+='Intel® AMT connected'}else{if((e&4)!=0){if(v.length>0){v+="
"}v+='Intel® AMT detected'}}if((v=="")&&r.lastconnect){v="Last seen:
"+printDateTime(new Date(r.lastconnect))+""}QH("MainComputerState",v);Q("MainComputerImage").setAttribute("src","images/icons256-"+r.icon+"-1.png");Q("MainComputerImage").className=((!r.conn)||(r.conn==0)?"gray":"");var C=((p==4294967295)||((p&512)==0));var l=((p==4294967295)||((p&1024)==0));var b=((p==4294967295)||((p&2048)==0));if(C){setupTerminal()}if(l){setupFiles()}var g=((p&16)!=0);if(g){setupConsole()}else{if(u==15){u=10}}QV("MainDevDesktop",((o.mtype==1)||(r.agent==null)||(r.agent.caps==null)||((r.agent.caps&1)!=0)||(r.intelamt&&(r.intelamt.state==2)))&&((p&8)||(p&256)));QV("MainDevTerminal",((o.mtype==1)||(r.agent==null)||(r.agent.caps==null)||((r.agent.caps&2)!=0)||(r.intelamt&&(r.intelamt.state==2)))&&(p&8)&&C);QV("MainDevFiles",((o.mtype==2)&&((r.agent==null)||(r.agent.caps==null)||((r.agent.caps&4)!=0)))&&(p&8)&&l);QV("MainDevAmt",(r.intelamt!=null)&&((r.intelamt.state==2)||(r.conn&2))&&(p&8)&&b);QV("MainDevConsole",(g&&(o.mtype==2)&&((r.agent==null)||(r.agent.caps==null)||((r.agent.caps&8)!=0)))&&(p&8));QV("p15uploadCore",(r.agent!=null)&&(r.agent.caps!=null)&&((r.agent.caps&16)!=0));QH("p15coreName",((r.agent!=null)&&(r.agent.core!=null))?r.agent.core:"");var c=Q("p14iframe").contentWindow.getCurrentMeshNode();if((c!=null)&&(c._id!=currentNode._id)){Q("p14iframe").contentWindow.disconnect()}var t=((r.conn&6)!=0)?true:false;Q("p14iframe").contentWindow.setConnectionState(t);Q("p14iframe").contentWindow.setFrameHeight("650px");Q("p14iframe").contentWindow.setAuthCallback(updateAmtCredentials);QV("deskActionsBtn",(p&72)!=0);QV("termActionsBtn",(p&72)!=0);QV("filesActionsBtn",(p&72)!=0);if((powerTimelineNode!=currentNode._id)&&(powerTimelineReq!=currentNode._id)){QH("p10html2","");powerTimelineReq=currentNode._id;meshserver.send({action:"powertimeline",nodeid:currentNode._id});meshserver.send({action:"lastconnect",nodeid:currentNode._id})}QV("DeskTools",false);showDeskToolsProcesses();refreshDeviceEvents();if((currentNode)&&(xxcurrentView>=10)&&(xxcurrentView<20)){document.title=decodeURIComponent("{{{extitle}}}")+" - "+currentNode.name}else{document.title=decodeURIComponent("{{{extitle}}}")}p11clearConsoleMsg();p12clearConsoleMsg();p13clearConsoleMsg()}setupDesktop();if(!u){u=10}go(u)}function showNotes(b,a){if(xxdialogMode){return}setDialogMode(2,"Notes",2,showNotesEx,"Device group notes can be viewed and changed by other device group 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,'');Q("d2devurl").focus()}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,"");Q("d2devToast").focus()}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)&&(powerTimelineUpdate ";++b;h=new Date(h.getTime()-(1000*60*60*24))}QH("p10html2",'
")}function powerColor(a){if(a '+A+"Day 7 Day Power State "+a+" "+b+" "}function editDeviceAmtSettings(g,c,a){if(xxdialogMode){return}var h="",e=getNodeFromId(g),b=3,d=getNodeRights(g);if((d&4)==0){return}h+=addHtmlValue("Username",'');h+=addHtmlValue("Password","");h+=addHtmlValue("Security","");if((e.intelamt.user!=null)&&(e.intelamt.user!="")){b=7}setDialogMode(2,"Edit Intel® AMT credentials",b,editDeviceAmtSettingsEx,h,{node:e,func:c,arg:a});if((e.intelamt.user!=null)&&(e.intelamt.user!="")){Q("dp10username").value=e.intelamt.user}else{Q("dp10username").value="admin"}Q("dp10tls").value=e.intelamt.tls;validateDeviceAmtSettings()}function validateDeviceAmtSettings(){QE("idx_dlgOkButton",passwordcheck(Q("dp10password").value))}function editDeviceAmtSettingsEx(c,d){if(c==2){meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:"",pass:""}})}else{var b=Q("dp10username").value;if(b==""){b="admin"}var a=Q("dp10password").value;if(a==""){b=""}meshserver.send({action:"changedevice",nodeid:d.node._id,intelamt:{user:b,pass:a,tls:Q("dp10tls").value}});d.node.intelamt.user=b;d.node.intelamt.tls=Q("dp10tls").value;if(d.func){setTimeout(function(){d.func(null,d.arg)},300)}}}function p10showChangeGroupDialog(e){if(xxdialogMode){return false}var g=null;if(e.length==1){try{g=meshes[getNodeFromId(e[0])]._id}catch(b){}}var j="";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.")}return false}function p10showChangeGroupDialogEx(a,c){meshserver.send({action:"changeDeviceMesh",nodeids:c,meshid:Q("p10newGroup").value})}function p10showDeleteNodeDialog(a){if(xxdialogMode){return false}var b='Are you sure you want to delete node "'+EscapeHtml(currentNode.name)+'"?
';b+="";setDialogMode(2,"Delete Node",3,p10showDeleteNodeDialogEx,b,a);p10validateDeleteNodeDialog();return false}function p10validateDeleteNodeDialog(){QE("idx_dlgOkButton",Q("p10check").checked)}function p10showDeleteNodeDialogEx(a,b){meshserver.send({action:"removedevices",nodeids:[b]})}function p10clickOnce(a,c,b){meshserver.send({action:"getcookie",nodeid:a,tcpport:b,tag:"clickonce",protocol:c});return false}var d2map=null;function p10showNodeLocationDialog(){if((xxdialogMode!=null)&&(xxdialogTag=="@xxmap")){setDialogMode(0)}else{if(xxdialogMode){return false}}var m=[],n=["iploc","wifiloc","gpsloc","userloc"],a=null;for(var k in n){if(currentNode[n[k]]!=null){var j=currentNode[n[k]].split(","),h=parseFloat(j[0]),l=parseFloat(j[1]);if((h<90)&&(h>-90)&&(l<180)&&(l>-180)){var e=new ol.Feature({geometry:new ol.geom.Point(ol.proj.fromLonLat([l,h]))});e.setStyle(markerStyle(currentNode,parseInt(k)+1));m.push(e);if(a==null){a=[h,l,h,l,0]}else{if(ha[2]){a[2]=h}if(l>a[3]){a[3]=l}}}}}var p=new ol.source.Vector({features:m});var o=new ol.layer.Vector({source:p});var q="";setDialogMode(2,"Device Location",1,null,q,"@xxmap");var c=0,b=0,r=8;if(a!=null){var b=(a[0]+a[2])/2;var c=(a[1]+a[3])/2;var d=Math.max(Math.abs(a[0]-a[2]),Math.abs(a[1]-a[3]));var g=360,r=-2;while(g>d){r++;g=g/2}}if(m.length==1){r=8}d2map=new ol.Map({target:"d2map",interactions:ol.interaction.defaults({dragPan:false,mouseWheelZoom:false}),layers:[new ol.layer.Tile({source:new ol.source.OSM()}),o],view:new ol.View({center:ol.proj.fromLonLat([c,b]),zoom:r})});return false}function p10showNodeNetInfoDialog(){if(xxdialogMode){return false}setDialogMode(2,"Network Interfaces",1,null,"
";a+=addHtmlValue("Win32 Executable",'MeshCentralRouter.exe');setDialogMode(2,"MeshCentral Router",1,null,a,"fileDownload")}function p10showMeshCmdDialog(a,b){if(xxdialogMode){return}var d="";var c="";if(a==0){c+="
"}if(a==1){c+='
'}c+=addHtmlValue("Operating System",d);c+=addHtmlValue("MeshCmd",'');if(a==0){c+=addHtmlValue("Action File",'MeshAction (.txt)')}if(a==1){c+=addHtmlValue("Action File",'MeshAction (.txt)')}c+="
";c+="";c+="";c+="";c+="";c+="";c+="
";setDialogMode(2,"Icon Selection",0,null,c);QV("id_dialogclose",true)}function p10setIcon(a){setDialogMode(0);meshserver.send({action:"changedevice",nodeid:currentNode._id,icon:a})}var showEditNodeValueDialog_modes=["Device Name","Hostname","Description","Tags"];var showEditNodeValueDialog_modes2=["name","host","desc","tags"];var showEditNodeValueDialog_modes3=["","","","Tag1, Tag2, Tag3"];function showEditNodeValueDialog(a){if(xxdialogMode){return}var c=addHtmlValue(showEditNodeValueDialog_modes[a],'");setDialogMode(2,"Edit Device",3,showEditNodeValueDialogEx,c,a);var b=currentNode[showEditNodeValueDialog_modes2[a]];if(b==null){b=""}if(Array.isArray(b)){b=b.join(", ")}Q("dp10devicevalue").value=b;p10editdevicevalueValidate();Q("dp10devicevalue").focus()}function showEditNodeValueDialogEx(a,b){var c={action:"changedevice",nodeid:currentNode._id};c[showEditNodeValueDialog_modes2[b]]=Q("dp10devicevalue").value;meshserver.send(c)}function p10editdevicevalueValidate(b,a){var c=((b>1)||(Q("dp10devicevalue").value.length>0));QE("idx_dlgOkButton",c);if((a!=null)&&(c==true)&&(a.keyCode==13)){dialogclose(1)}}var desktopNode;function setupDesktop(){if((desktopNode!=currentNode)&&(desktop!=null)){desktop.Stop();desktopNode=null;desktop=null}if((desktopNode!=currentNode)||(desktop==null)){var b=multiDesktop[currentNode._id];if(b!=null){QH("DeskParent","");var a=b.m.CanvasId;a.setAttribute("id","Desk");a.setAttribute("onmousedown","dmousedown(event)");a.setAttribute("onmouseup","dmouseup(event)");a.setAttribute("onmousemove","dmousemove(event)");a.removeAttribute("onclick");Q("DeskParent").appendChild(a);desktop=b;if(desktop.m.SendCompressionLevel){desktop.m.SendCompressionLevel(1,desktopsettings.quality,desktopsettings.scaling,desktopsettings.framerate)}desktop.onStateChanged=onDesktopStateChange;desktopNode=currentNode;onDesktopStateChange(desktop,desktop.State);delete multiDesktop[currentNode._id]}else{QH("DeskParent",'');desktopNode=currentNode}Q("Desk").addEventListener("DOMMouseScroll",function(c){return dmousewheel(c)});Q("Desk").addEventListener("mousewheel",function(c){return dmousewheel(c)})}desktopNode=currentNode;updateDesktopButtons();deskAdjust();if(!Q("Desk")["toBlob"]){QV("deskSaveBtn",false)}}function updateDesktopButtons(){var d=meshes[currentNode.meshid];var a=0;if(desktop!=null){a=desktop.State}var e=d.links[userinfo._id].rights;QV("disconnectbutton1span",(a!=0));QV("connectbutton1span",(a==0)&&((e&8)||(e&256))&&(d.mtype==2)&&(currentNode.agent.caps&1));QV("connectbutton1hspan",(a==0)&&(e&8)&&((currentNode.intelamt!=null)&&(d.mtype==1||currentNode.intelamt.state==2)&&((currentNode.intelamt.ver!=null)||(d.mtype==1))));QV("d7amtkvm",(currentNode.intelamt!=null&&((currentNode.intelamt.ver!=null)||(d.mtype==1)))&&((a==0)||(desktop.contype==2)));QV("d7meshkvm",(webRtcDesktop)||((d.mtype==2)&&(currentNode.agent.caps&1)&&((a==false)||(desktop.contype==1))));var c=(e==4294967295)||(((e&8)!=0)&&((e&256)==0)&&((e&4096)==0));var g=((currentNode.conn&1)!=0);QE("connectbutton1",g);var b=((currentNode.conn&6)!=0);QE("connectbutton1h",b);QE("deskSaveBtn",a==3);QV("deskFocusBtn",(desktop!=null)&&(desktop.contype==2)&&(a!=0)&&(desktopsettings.showfocus));QV("DeskClip",(currentNode.agent)&&(currentNode.agent.id!=11)&&(currentNode.agent.id!=16)&&((desktop==null)||(desktop.contype!=2)));QE("DeskClip",a==3);QE("DeskType",a==3);QV("DeskWD",(currentNode.agent)&&(currentNode.agent.id<5)&&c);QE("DeskWD",a==3);QV("deskkeys",(currentNode.agent)&&(currentNode.agent.id<5)&&c);QE("deskkeys",a==3);QV("DeskToolsButton",(c)&&(d.mtype==2)&&g);QV("DeskChatButton",(browserfullscreen==false)&&(c)&&(d.mtype==2)&&g);QV("DeskNotifyButton",(browserfullscreen==false)&&(currentNode.agent)&&(currentNode.agent.id<5)&&(c)&&(d.mtype==2)&&g);QV("DeskOpenWebButton",(browserfullscreen==false)&&(c)&&(d.mtype==2)&&g);QV("DeskControlSpan",c);QV("deskActionsBtn",(browserfullscreen==false));QV("deskActionsSettings",(browserfullscreen==false));if(e&8){Q("DeskControl").checked=(getstore("DeskControl",1)==1)}else{Q("DeskControl").checked=false}if(g==false){QV("DeskTools",false)}}var autoConnectDesktopTimer=null;function autoConnectDesktop(a){if(autoConnectDesktopTimer==null){autoConnectDesktopTimer=setInterval(connectDesktop,100)}else{clearInterval(autoConnectDesktopTimer);autoConnectDesktopTimer=null}}function connectDesktop(b,a){p11clearConsoleMsg();if(desktop==null){desktopNode=currentNode;if(a==2){if((desktopNode.intelamt.user==null)||(desktopNode.intelamt.user=="")){editDeviceAmtSettings(desktopNode._id,connectDesktop,2);return}desktop=CreateAmtRedirect(CreateAmtRemoteDesktop("Desk"),authCookie);desktop.debugmode=debugmode;desktop.onStateChanged=onDesktopStateChange;desktop.m.bpp=(desktopsettings.encoding==1||desktopsettings.encoding==3)?1:2;desktop.m.useZRLE=(desktopsettings.encoding<3);desktop.m.localKeyMap=desktopsettings.localkeymap;desktop.m.showmouse=desktopsettings.showmouse;desktop.m.onScreenSizeChange=deskAdjust;desktop.m.onKvmData=function(h){if(h.length==0){if(!desktop.m._sentPresence){desktop.m._sentPresence=true;desktop.m.sendKvmData(JSON.stringify({action:"present",ver:1}))}return}var d=null;try{d=JSON.parse(h)}catch(g){}if((d!=null)&&(d.action!=null)){if(d.action=="restart"){webRtcDesktopReset();desktop.m.sendKvmData(JSON.stringify({action:"present",ver:1}))}else{if((d.action=="present")&&(webRtcDesktop==null)){webRtcDesktop={platform:d.platform};var c=null;if(typeof RTCPeerConnection!=="undefined"){webRtcDesktop.webrtc=new RTCPeerConnection(c)}else{if(typeof webkitRTCPeerConnection!=="undefined"){webRtcDesktop.webrtc=new webkitRTCPeerConnection(c)}}webRtcDesktop.webchannel=webRtcDesktop.webrtc.createDataChannel("DataChannel",{});webRtcDesktop.webchannel.onopen=function(){console.log("WebRTC Data Channel Open");Q("deskstatus").textContent=StatusStrs[desktop.State]+", Soft-KVM";desktop.m.hold(true);webRtcDesktop.webRtcActive=true;webRtcDesktop.softdesktop=CreateKvmDataChannel(webRtcDesktop.webchannel,CreateAgentRemoteDesktop("Desk",Q("id_mainarea")),desktop.m);webRtcDesktop.softdesktop.m.setRotation(desktop.m.rotation);webRtcDesktop.softdesktop.m.onScreenSizeChange=deskAdjust;if(desktopsettings.quality){webRtcDesktop.softdesktop.m.CompressionLevel=desktopsettings.quality}if(desktopsettings.scaling){webRtcDesktop.softdesktop.m.ScalingLevel=desktopsettings.scaling}webRtcDesktop.softdesktop.Start()};webRtcDesktop.webchannel.onclose=function(e){console.log("WebRTC Data Channel Closed");webRtcDesktopReset()};webRtcDesktop.webrtc.onicecandidate=function(j){if(j.candidate==null){desktop.m.sendKvmData(JSON.stringify({action:"offer",ver:1,sdp:webRtcDesktop.webrtcoffer.sdp}))}else{webRtcDesktop.webrtcoffer.sdp+=("a="+j.candidate.candidate+"\r\n")}};webRtcDesktop.webrtc.oniceconnectionstatechange=function(){if((webRtcDesktop!=null)&&(webRtcDesktop.webrtc!=null)&&((webRtcDesktop.webrtc.iceConnectionState=="disconnected")||(webRtcDesktop.webrtc.iceConnectionState=="failed"))){webRtcDesktopReset()}};webRtcDesktop.webrtc.createOffer(function(e){webRtcDesktop.webrtcoffer=e;webRtcDesktop.webrtc.setLocalDescription(e,function(){},webRtcDesktopReset)},webRtcDesktopReset,{mandatory:{OfferToReceiveAudio:false,OfferToReceiveVideo:false}})}else{if((d.action=="answer")&&(webRtcDesktop!=null)){webRtcDesktop.webrtc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:d.sdp}),function(){},webRtcDesktopReset)}}}}};desktop.Start(desktopNode._id,16994,"*","*",0);desktop.contype=2}else{desktop=CreateAgentRedirect(meshserver,CreateAgentRemoteDesktop("Desk"),serverPublicNamePort,authCookie,domainUrl);desktop.debugmode=debugmode;desktop.m.debugmode=debugmode;desktop.attemptWebRTC=attemptWebRTC;desktop.onStateChanged=onDesktopStateChange;desktop.onConsoleMessageChange=function(){p11clearConsoleMsg();if(desktop.consoleMessage){QH("p11DeskConsoleMsg",EscapeHtml(desktop.consoleMessage).split("\n").join("
"));QV("p11DeskConsoleMsg",true);p11DeskConsoleMsgTimer=setTimeout(p11clearConsoleMsg,8000)}};desktop.m.CompressionLevel=desktopsettings.quality;desktop.m.ScalingLevel=desktopsettings.scaling;desktop.m.FrameRateTimer=desktopsettings.framerate;desktop.m.onDisplayinfo=deskDisplayInfo;desktop.m.onScreenSizeChange=deskAdjust;desktop.Start(desktopNode._id);desktop.contype=1}}else{desktop.Stop();webRtcDesktopReset();desktopNode=desktop=null}}function p11clearConsoleMsg(){QV("p11DeskConsoleMsg",false);if(p11DeskConsoleMsgTimer){clearTimeout(p11DeskConsoleMsgTimer);p11DeskConsoleMsgTimer=null}}function p12clearConsoleMsg(){QV("p12TermConsoleMsg",false);if(p12TermConsoleMsgTimer){clearTimeout(p12TermConsoleMsgTimer);p12TermConsoleMsgTimer=null}}function p13clearConsoleMsg(){QV("p13FilesConsoleMsg",false);if(p13FilesConsoleMsgTimer){clearTimeout(p13FilesConsoleMsgTimer);p13FilesConsoleMsgTimer=null}}var webRtcDesktop=null;function webRtcDesktopReset(){if(webRtcDesktop==null){return}if(webRtcDesktop.softdesktop!=null){webRtcDesktop.softdesktop.Stop();webRtcDesktop.softdesktop=null}if(webRtcDesktop.webchannel!=null){try{webRtcDesktop.webchannel.close()}catch(a){}webRtcDesktop.webchannel=null}if(webRtcDesktop.webrtc!=null){try{webRtcDesktop.webrtc.close()}catch(a){}webRtcDesktop.webrtc=null}webRtcDesktop=null;if(desktop&&desktop.m){desktop.m.hold(false);Q("deskstatus").textContent=StatusStrs[desktop.State]}}function onDesktopStateChange(c,a){var d=a;if((d==3)&&(c.contype==2)){d++}var b=StatusStrs[d];if((desktop!=null)&&(desktop.webRtcActive==true)){b+=", WebRTC"}QH("deskstatus",b);switch(a){case 0:desktop.Stop();desktopNode=desktop=null;QV("DeskFocus",false);QV("termdisplays",false);deskFocusBtn.value="All Focus";if(fullscreen==true){deskToggleFull()}webRtcDesktopReset();deskPreferedStickyDisplay=0;break;case 2:break;default:break}updateDesktopButtons();deskAdjust();setTimeout(deskAdjust,50)}function showDesktopSettings(){if(xxdialogMode){return}applyDesktopSettings();updateDesktopButtons();setDialogMode(7,"Remote Desktop Settings",3,showDesktopSettingsChanged)}function showDesktopSettingsChanged(){desktopsettings.encoding=d7desktopmode.value;desktopsettings.showfocus=d7showfocus.checked;desktopsettings.showmouse=d7showcursor.checked;desktopsettings.quality=d7bitmapquality.value;desktopsettings.scaling=d7bitmapscaling.value;desktopsettings.framerate=d7framelimiter.value;desktopsettings.localkeymap=d7localKeyMap.checked;localStorage.setItem("desktopsettings",JSON.stringify(desktopsettings));applyDesktopSettings();if(desktop){if(desktop.contype==1){if(desktop.State!=0){desktop.m.SendCompressionLevel(1,desktopsettings.quality,desktopsettings.scaling,desktopsettings.framerate)}}if(desktop.contype==2){if(desktopsettings.showfocus==false){desktop.m.focusmode=0;deskFocusBtn.value="All Focus"}if(desktop.State!=0){desktop.Stop();setTimeout(function(){connectDesktop(null,2)},50)}}}}function applyDesktopSettings(){var c="",b=(features&512)?[90,80,70,60,50,40,30,20,10,5,1]:[60,50,40,30,20,10,5,1];for(var a in b){c+=""}QH("d7bitmapquality",c);d7desktopmode.value=desktopsettings.encoding;d7showfocus.checked=desktopsettings.showfocus;d7showcursor.checked=desktopsettings.showmouse;d7bitmapquality.value=40;if(b.indexOf(parseInt(desktopsettings.quality))>=0){d7bitmapquality.value=desktopsettings.quality}d7bitmapscaling.value=desktopsettings.scaling;if(desktopsettings.framerate){d7framelimiter.value=desktopsettings.framerate}if(desktopsettings.localkeymap){d7localKeyMap.checked=desktopsettings.localkeymap}QV("deskFocusBtn",(desktop!=null)&&(desktop.contype==2)&&(desktop.state!=0)&&(desktopsettings.showfocus))}function enterBrowserFullscreen(a){if(a.requestFullscreen){a.requestFullscreen()}else{if(a.msRequestFullscreen){a.msRequestFullscreen()}else{if(a.mozRequestFullScreen){a.mozRequestFullScreen()}else{if(a.webkitRequestFullscreen){a.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}}}}}function exitBrowserFullscreen(){if(document.exitFullscreen){document.exitFullscreen()}else{if(document.msExitFullscreen){document.msExitFullscreen()}else{if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else{if(document.webkitExitFullscreen){document.webkitExitFullscreen()}}}}}function isBrowserFullscreen(){if(!document.fullscreenElement&&!document.mozFullScreenElement&&!document.webkitFullscreenElement&&!document.msFullscreenElement){return false}else{return true}}var fullscreen=false;var browserfullscreen=false;function deskToggleFull(a){fullscreen=!fullscreen;if(fullscreen){QC("body").add("fulldesk");if(a.shiftKey==true){enterBrowserFullscreen(Q("deskarea0"));browserfullscreen=true}}else{QC("body").remove("fulldesk");if(browserfullscreen==true){exitBrowserFullscreen();browserfullscreen=false;toggleFullScreen()}}deskAdjust();updateDesktopButtons()}function deskToggleFocus(){desktop.m.focusmode=(desktop.m.focusmode+64)%192;Q("deskFocusBtn").value=["All Focus","Small Focus","Large Focus"][desktop.m.focusmode/64]}function deskAdjust(){var d=Q("DeskParent").clientHeight,e=Q("DeskParent").clientWidth;var a=Q("Desk").height,b=Q("Desk").width;if(deskAspectRatio==2){QS("Desk")["margin-top"]=null;QS("Desk").height="100%";QS("Desk").width="100%";QS("DeskParent").overflow="hidden"}else{if(deskAspectRatio==1){QS("Desk")["margin-top"]="0px";QS("Desk").height=a+"px";QS("Desk").width=b+"px";QS("DeskParent").overflow="scroll"}else{if((d/e)>(a/b)){var c=((a*e)/b)+"px";QS("Desk").height=c;QS("Desk").width="100%"}else{var g=((b*d)/a)+"px";if(webPageFullScreen||fullscreen){QS("Desk").height=null}else{QS("Desk").height="100%"}QS("Desk").width=g}QS("Desk")["margin-top"]=null;QS("DeskParent").overflow="hidden"}}}function mdeskAdjust(c,h,g,a){if(!c||!h||!g||!a){return}if(a.id=="Desk"){deskAdjust();return}var k=[{x:180,y:101},{x:302,y:169},{x:454,y:255}][Q("sizeselect").selectedIndex];var e=k.x+2,j=Q("xdevices").clientWidth-30,l=Math.floor(j/e);l=e+Math.floor((j-(l*e))/l);k.y=k.y*(l/k.x);k.x=l;var b=k.y,d=k.x;if(c.State!=0){b=k.y;d=(h/g)*k.y}QS(a.id)["max-height"]=b+"px";QS(a.id)["max-width"]=d+"px";QS(a.id)["margin-top"]="0";QS(a.id)["margin-bottom"]="0"}function deskSendKeys(){if(xxdialogMode||desktop==null||desktop.State!=3){return}var a=Q("deskkeys").value;if(a==0){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[65364,1],[65364,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,40],[desktop.m.KeyAction.UP,40],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==1){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[65362,1],[65362,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,38],[desktop.m.KeyAction.UP,38],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==2){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[108,1],[108,0],[65511,0]])}else{desktop.sendCtrlMsg('{"action":"lock"}')}}else{if(a==3){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[109,1],[109,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==4){if(desktop.contype==2){desktop.m.sendkey([[65505,1],[65511,1],[109,1],[109,0],[65511,0],[65505,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.DOWN,16],[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,91],[desktop.m.KeyAction.UP,16]])}}else{if(a==5){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==6){if(desktop.contype==2){desktop.m.sendkey([[65511,1],[114,1],[114,0],[65511,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,91],[desktop.m.KeyAction.DOWN,82],[desktop.m.KeyAction.UP,82],[desktop.m.KeyAction.EXUP,91]])}}else{if(a==7){if(desktop.contype==2){desktop.m.sendkey([[65513,1],[65473,1],[65473,0],[65513,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,18],[desktop.m.KeyAction.DOWN,115],[desktop.m.KeyAction.UP,115],[desktop.m.KeyAction.EXUP,18]])}}else{if(a==8){if(desktop.contype==2){desktop.m.sendkey([[65507,1],[119,1],[119,0],[65507,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,17],[desktop.m.KeyAction.DOWN,87],[desktop.m.KeyAction.UP,87],[desktop.m.KeyAction.EXUP,17]])}}else{if(a==9){if(desktop.contype==2){desktop.m.sendkey([[65513,1],[65289,1],[65289,0],[65513,0]])}else{desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,18],[desktop.m.KeyAction.DOWN,9],[desktop.m.KeyAction.UP,9],[desktop.m.KeyAction.EXUP,18]])}}else{if(a==10){desktop.m.sendcad()}}}}}}}}}}}}function showDeskType(){if(xxdialogMode||desktop==null||desktop.State!=3){return}Q("DeskType").blur();var a="
";setDialogMode(2,"Service Details",8,null,d,name)}}function showServiceDetailsDialogEx(a,b){setDialogMode(0);if(a==0){return}var c=deskTools.services[b];if(c!=null){if(a==1){meshserver.send({action:"msg",type:"serviceStart",nodeid:currentNode._id,serviceName:c.name})}if(a==2){meshserver.send({action:"msg",type:"serviceStop",nodeid:currentNode._id,serviceName:c.name})}setTimeout(function(){refreshDeskTools(1)},1000)}}function toggleKvmControl(){putstore("DeskControl",(Q("DeskControl").checked?1:0))}function deskSaveImage(){if(xxdialogMode||desktop==null||desktop.State!=3){return}var a=new Date(),b="Desktop-"+currentNode.name+"-"+a.getFullYear()+"-"+("0"+(a.getMonth()+1)).slice(-2)+"-"+("0"+a.getDate()).slice(-2)+"-"+("0"+a.getHours()).slice(-2)+"-"+("0"+a.getMinutes()).slice(-2);Q("Desk")["toBlob"](function(c){saveAs(c,b+".jpg")})}function deskDisplayInfo(g,b,e){var a=0,c="";for(var d in b){a++;c+="";if((deskPreferedStickyDisplay==d)&&(e!=deskPreferedStickyDisplay)){desktop.m.SetDisplay(d)}}QH("termdisplays",c);QV("termdisplays",a>1)}function deskGetDisplayNumbers(a){desktop.m.GetDisplayNumbers()}var deskPreferedStickyDisplay=0;function deskSetDisplay(a){desktop.m.SetDisplay(deskPreferedStickyDisplay=parseInt(Q("termdisplays").value));Q("termdisplays").blur()}var dblClickDetectArgs={t:0,x:0,y:0};function dblClickDetect(a){if(a.buttons!=1){return}var b=Date.now();if(((b-dblClickDetectArgs.t)<250)&&(Math.abs(a.clientX-dblClickDetectArgs.x)<2)&&(Math.abs(a.clientY-dblClickDetectArgs.y)<2)){if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousedblclick(a);desktop.m.sendKeepAlive()}else{desktop.m.mousedblclick(a)}}}dblClickDetectArgs.t=b;dblClickDetectArgs.x=a.clientX;dblClickDetectArgs.y=a.clientY}function dmousedown(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousedown(a);desktop.m.sendKeepAlive()}else{desktop.m.mousedown(a)}}dblClickDetect(a)}function dmouseup(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mouseup(a);desktop.m.sendKeepAlive()}else{desktop.m.mouseup(a)}}}function dmousemove(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousemove(a);desktop.m.sendKeepAlive()}else{desktop.m.mousemove(a)}}}function dmousewheel(a){setSessionActivity();a.addx=Q("DeskParent").scrollLeft;a.addy=Q("DeskParent").scrollTop;if(!xxdialogMode&&desktop!=null&&Q("DeskControl").checked){if((webRtcDesktop!=null)&&(webRtcDesktop.softdesktop!=null)){webRtcDesktop.softdesktop.m.mousewheel(a);desktop.m.sendKeepAlive()}else{if(desktop.m.mousewheel){desktop.m.mousewheel(a)}}haltEvent(a);return true}return false}function drotate(a){if(!xxdialogMode&&desktop!=null){desktop.m.setRotation(desktop.m.rotation+a);deskAdjust();deskAdjust()}}function stopProcess(a,b){setDialogMode(2,"Process Control",3,stopProcessEx,"Stop process #"+a+' "'+b+'"?',a);return false}function stopProcessEx(a,b){meshserver.send({action:"msg",type:"pskill",nodeid:currentNode._id,value:b});setTimeout(refreshDeskTools,300)}var terminalNode;function setupTerminal(){if((terminalNode!=currentNode)&&(terminal!=null)){terminal.Stop();terminal=null}terminalNode=currentNode;updateTerminalButtons()}function updateTerminalButtons(){var b=meshes[terminalNode.meshid];var d=((terminal!=null)&&(terminal.state!=0));QV("disconnectbutton2span",(d==true));QV("connectbutton2span",(d==false)&&(b.mtype==2)&&(currentNode.agent.caps&2));QV("connectbutton2hspan",(d==false)&&((terminalNode.intelamt!=null)&&(b.mtype==1||terminalNode.intelamt.state==2)&&((terminalNode.intelamt.ver!=null)||(b.mtype==1))));var c=((terminalNode.conn&1)!=0);QE("connectbutton2",c);var a=((terminalNode.conn&6)!=0);QE("connectbutton2h",a);QE("ctrlcbutton",d);QE("ctrlxbutton",d);QE("escbutton",d);QE("bsbutton",d);QE("pastebutton",d);QE("specialkeylist",d);QE("specialkeylistinput",d);QV("terminalSettingsButtons",(terminal)&&(terminal.contype==2));if(terminal){Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation];Q("id_tfxkeysbutton").value=fxEmulations[terminal.m.fxEmulation];Q("id_tcrbutton").value=(terminal.m.lineFeed=="\r\n")?"CR+LF":"LF"}}function onTerminalStateChange(d,a){var c=a;if((c==3)&&(d.contype==2)){c++}var b=StatusStrs[c];if(terminal.webRtcActive==true){b+=", WebRTC"}QH("termstatus",b);switch(a){case 0:QE("termSizeList",true);QH("termtitle","");d.m.TermResetScreen();d.m.TermDraw();if(terminal!=null){terminal.Stop();terminal=null}break;case 3:QE("termSizeList",false);break;default:QE("termSizeList",false);break}updateTerminalButtons()}var autoConnectTerminalTimer=null;function autoConnectTerminal(a){if(autoConnectTerminalTimer==null){autoConnectTerminalTimer=setInterval(connectTerminal,100)}else{clearInterval(autoConnectTerminalTimer);autoConnectTerminalTimer=null}}function connectTerminal(b,a,c){p12clearConsoleMsg();if(!terminal){if(a==2){if((terminalNode.intelamt.user==null)||(terminalNode.intelamt.user=="")){editDeviceAmtSettings(terminalNode._id,connectTerminal,2);return}var d={};if(Q("termSizeList").value==2){d.width=100;d.height=30}terminal=CreateAmtRedirect(CreateAmtRemoteTerminal("Term",d),authCookie);terminal.debugmode=debugmode;terminal.m.debugmode=debugmode;terminal.m.onTitleChange=function(e,g){QH("termtitle"," - "+EscapeHtml(g))};terminal.onStateChanged=onTerminalStateChange;terminal.Start(terminalNode._id,16994,"*","*",0);terminal.contype=2;Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation]}else{var d={};if([1,2,3,4,21,22].indexOf(currentNode.agent.id)==-1){if(Q("termSizeList").value==2){d.width=100;d.height=30;d.xterm=true}if(Q("termSizeList").value==3){d.width=Math.floor((Q("column_l").clientWidth-60)/10);d.height=Math.floor((Q("column_l").clientHeight-120)/20);d.xterm=true}}if((b&&(b.shiftKey==true))||(c&&(c.powershell))){d.protocol=6}terminal=CreateAgentRedirect(meshserver,CreateAmtRemoteTerminal("Term",d),serverPublicNamePort,authCookie,domainUrl);terminal.debugmode=debugmode;terminal.m.debugmode=debugmode;terminal.m.onTitleChange=function(e,g){QH("termtitle"," - "+EscapeHtml(g))};terminal.m.lineFeed=([1,2,3,4,21,22].indexOf(currentNode.agent.id)>=0)?"\r\n":"\r";terminal.attemptWebRTC=attemptWebRTC;terminal.onStateChanged=onTerminalStateChange;terminal.onConsoleMessageChange=function(){p12clearConsoleMsg();if(terminal.consoleMessage){QH("p12TermConsoleMsg",EscapeHtml(terminal.consoleMessage).split("\n").join("
"));QV("p12TermConsoleMsg",true);p12TermConsoleMsgTimer=setTimeout(p12clearConsoleMsg,8000)}};terminal.Start(terminalNode._id);terminal.contype=1;terminal.m.terminalEmulation=0;terminal.m.fxEmulation=0;Q("id_ttypebutton").value=terminalEmulations[0]}}else{terminal.Stop();terminal=null}Q("connectbutton2").blur()}var terminalEmulations=["UTF8 Terminal","Extended ASCII","Intel ASCII"];function termToggleType(){if(!terminal||xxdialogMode){return}terminal.m.terminalEmulation=(terminal.m.terminalEmulation+1)%3;Q("id_ttypebutton").value=terminalEmulations[terminal.m.terminalEmulation];Q("id_ttypebutton").blur()}var fxEmulations=["Intel (F10 = ESC+[OM)","Alternate (F10 = ESC+0)","VT100+ (F10 = ESC+[OY)"];function termToggleFx(){if(!terminal||xxdialogMode){return}terminal.m.fxEmulation=(terminal.m.fxEmulation+1)%3;Q("id_tfxkeysbutton").value=fxEmulations[terminal.m.fxEmulation];Q("id_tfxkeysbutton").blur()}function termToggleCr(){if(!terminal||xxdialogMode){return}if(terminal.m.lineFeed=="\n"){terminal.m.lineFeed="\r\n"}else{terminal.m.lineFeed="\n"}Q("id_tcrbutton").value=(terminal.m.lineFeed=="\r\n")?"CR+LF":"LF"}function termSendKey(b,a){if(!terminal||xxdialogMode){return}terminal.m.TermSendKey(b);Q(a).blur()}function showTermPasteDialog(){if(!terminal||xxdialogMode){return}Q("pastebutton").blur();setDialogMode(2,"Paste",3,showTermPasteDialogEx,'');Q("d2pasteText").focus()}function showTermPasteDialogEx(){if(!terminal){return}terminal.m.TermSendKeys(Q("d2pasteText").value)}function sendSpecialKey(){terminal.m.TermSendKey(Q("specialkeylist").value);Q("specialkeylist").blur();Q("specialkeylistinput").blur()}var filesNode;function setupFiles(){var b=(filesNode==currentNode);filesNode=currentNode;var a=((filesNode.conn&1)!=0)?true:false;QE("p13Connect",a);if(((b==false)||(a==false))&&files){files.Stop();files=null}}function onFilesStateChange(c,a){p13Connect.value=(a==0)?"Connect":"Disconnect";var b=StatusStrs[a];if(files.webRtcActive==true){b+=", WebRTC"}Q("p13Status").textContent=b;switch(a){case 0:QH("p13files","");p13filetree=null;p13filetreelocation=[];QH("p13currentpath","");QE("p13FolderUp",false);p13setActions();if(files!=null){files.Stop();files=null}break;case 3:p13targetpath="";files.sendText({action:"ls",reqid:1,path:""});break;default:break}}function CreateRemoteFiles(b){var a={protocol:5};a.onFileUpdate=b;a.xxStateChange=function(c){};a.ProcessData=function(c){a.onFileUpdate(c)};return a}var autoConnectFilesTimer=null;function autoConnectFiles(a){if(autoConnectFilesTimer==null){autoConnectFilesTimer=setInterval(connectFiles,100)}else{clearInterval(autoConnectFilesTimer);autoConnectFilesTimer=null}}function connectFiles(a){p13clearConsoleMsg();if(!files){files=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotFiles),serverPublicNamePort,authCookie,domainUrl);files.attemptWebRTC=attemptWebRTC;files.onStateChanged=onFilesStateChange;files.onConsoleMessageChange=function(){p13clearConsoleMsg();if(files.consoleMessage){QH("p13FilesConsoleMsg",EscapeHtml(files.consoleMessage).split("\n").join("
"));QV("p13FilesConsoleMsg",true);p13FilesConsoleMsgTimer=setTimeout(p13clearConsoleMsg,8000)}};files.Start(filesNode._id)}else{files.Stop();files=null}p13clipboard=p13clipboardFolder=null;p13clipboardCut=0;p13updateClipview()}var p13filetree=null;var p13targetpath=null;var p13filetreelocation=[];function p13gotFiles(b){if((b.length>0)&&(b.charCodeAt(0)!=123)){p13gotDownloadBinaryData(b);return}b=JSON.parse(decode_utf8(b));if(b.action=="download"){p13gotDownloadCommand(b);return}b.path=b.path.replace(/\//g,"\\");if((p13filetree!=null)&&(b.path==p13filetree.path)){var a=p13getCheckedNames();p13filetree=b;p13updateFiles(a)}else{var c=b.path.replace(/\//g,"\\"),d=p13targetpath.replace(/\//g,"\\");while((c.length>0)&&(c[0]=="\\")){c=c.substring(1)}while((d.length>0)&&(d[0]=="\\")){d=d.substring(1)}if((c==d)||((b.path=="\\")&&(p13targetpath==""))){p13filetree=b;p13updateFiles()}}}function p13getCheckedNames(){var b=[],a=document.getElementsByName("fd");for(var c=0;c
":"";setDialogMode(2,"Delete",3,p13deletefileEx,(a>1)?("Delete "+a+" selected items?"+b):("Delete selected item?"+b))}function p13deletefileEx(){var b=[],a=document.getElementsByName("fd");for(var c=0;c
")}function p13downloadFileCancel(){setDialogMode(0);files.sendText({action:"download",sub:"cancel",id:downloadFile.id});downloadFile=null}function p13gotDownloadCommand(a){if((downloadFile==null)||(a.id!=downloadFile.id)){return}if(a.sub=="start"){downloadFile.state=1;files.sendText({action:"download",sub:"startack",id:downloadFile.id})}else{if(a.sub=="cancel"){downloadFile=null;setDialogMode(0)}}}function p13gotDownloadBinaryData(a){if(!downloadFile||downloadFile.state==0){return}if(a.length>4){downloadFile.tsize+=(a.length-4);downloadFile.data+=a.substring(4);Q("d2progressBar").value=downloadFile.tsize}if((ReadInt(a,0)&1)!=0){saveAs(data2blob(downloadFile.data),downloadFile.file);downloadFile=null;setDialogMode(0)}else{files.sendText({action:"download",sub:"ack",id:downloadFile.id})}}var uploadFile;function p13doUploadFiles(a){if(xxdialogMode){return}uploadFile={};uploadFile.xpath=p13filetreelocation.join("/");uploadFile.xfiles=a;uploadFile.xfilePtr=-1;setDialogMode(2,"Upload File",10,p13uploadFileCancel,"
");p13uploadReconnect()}function onFileUploadStateChange(b,a){switch(a){case 0:p13folderup(9999);break;case 3:p13uploadNextFile();break;default:break}}function p13uploadReconnect(){uploadFile.ws=CreateAgentRedirect(meshserver,CreateRemoteFiles(p13gotUploadData),serverPublicNamePort,authCookie,domainUrl);uploadFile.ws.attemptWebRTC=false;uploadFile.ws.ctrlMsgAllowed=false;uploadFile.ws.onStateChanged=onFileUploadStateChange;uploadFile.ws.Start(filesNode._id)}function p13uploadNextFile(){uploadFile.xfilePtr++;if(uploadFile.xfiles.length>uploadFile.xfilePtr){uploadFile.xptr=0;var a=uploadFile.xfiles[uploadFile.xfilePtr];QH("p13dfileName",a.name);Q("d2progressBar").max=a.size;Q("d2progressBar").value=0;uploadFile.xreader=new FileReader();uploadFile.xreader.onload=function(){uploadFile.xdata=uploadFile.xreader.result;uploadFile.ws.sendText(JSON.stringify({action:"upload",reqid:uploadFile.xfilePtr,path:uploadFile.xpath,name:a.name,size:uploadFile.xdata.byteLength}))};uploadFile.xreader.readAsArrayBuffer(a)}else{p13uploadFileCancel()}}function p13uploadFileCancel(a,b){if(uploadFile!=null){if(uploadFile.ws!=null){uploadFile.ws.Stop();uploadFile.ws=null}uploadFile=null}setDialogMode(0)}function p13gotUploadData(b){var a=JSON.parse(b);if((uploadFile==null)||(parseInt(uploadFile.xfilePtr)!=parseInt(a.reqid))){return}if(a.action=="uploadstart"){p13uploadNextPart(false);for(var c=0;c<8;c++){p13uploadNextPart(true)}}else{if(a.action=="uploadack"){p13uploadNextPart(false)}else{if(a.action=="uploaderror"){p13uploadFileCancel()}}}}function p13uploadNextPart(c){var a=uploadFile.xdata;var e=uploadFile.xptr;var d=uploadFile.xptr+4096;if(d>a.byteLength){if(c==true){return}d=a.byteLength}if(e==a.byteLength){if(uploadFile.ws!=null){uploadFile.ws.Stop();uploadFile.ws=null}if(uploadFile.xfiles.length>uploadFile.xfilePtr+1){p13uploadReconnect()}else{p13uploadFileCancel()}}else{var b=a.slice(e,d);uploadFile.ws.send(b);uploadFile.xptr=d;Q("d2progressBar").value=d}}var currentDeviceEvents=null;function deviceEventsUpdate(){var h="",a=null;for(var c in currentDeviceEvents){var b=currentDeviceEvents[c],g=new Date(b.time);if(b.msg){if(b.h==null){b.h=Math.random()}if(printDate(g)!=a){if(a!=null){h+=""}a=printDate(g);h+="
"}if(h==""){h=" "}var d="si3";if(b.etype=="user"){d="m2"}if(b.etype=="server"){d="si3"}var e=EscapeHtml(b.msg).split("(R)").join("®");if(b.username){if((userinfo.siteadmin&2)&&(b.userid)){e=""+EscapeHtml(b.username)+" → "+e}else{e=EscapeHtml(b.username)+" → "+e}}if(b.etype=="relay"||b.action=="relaylog"){d="relayIcon16"}h+=""+a+" "+printTime(g)+" - "+e+" "}}if(a!=null){h+="
No Events Found
"}QH("p16events",h)}function refreshDeviceEvents(){meshserver.send({action:"events",nodeid:currentNode._id,limit:parseInt(p16limitdropdown.value)})}function showEventDetails(b,d){var a,g;if(d==1){a=currentDeviceEvents}if(d==2){a=events}if(d==3){a=currentUserEvents}for(var c in a){if(a[c].h==b){g=a[c];break}}if(g){if(xxdialogMode){return false}var e="
";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™.
";b+=addHtmlValue("Key Name",'');b+=addHtmlValue("YubiKey™ OTP","")}}setDialogMode(2,"Add Security Key",3,account_addhkeyEx,b,a);Q("dp1keyname").focus()}function account_addhkeyValidate(b,a){if((b!=null)&&(b.keyCode==13)){if(a==2){dialogclose(1)}else{Q("dp1key").focus()}}}function account_addhkeyEx(a,c){var b=Q("dp1keyname").value;if(b==""){b="MyKey"}if(c==2){meshserver.send({action:"otp-hkey-yubikey-add",name:b,otp:Q("dp1key").value});setDialogMode(2,"Add Security Key",0,null,"
Checking...
","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"})}var loclist={af:"Afrikaans",sq:"Albanian",ar:"Arabic (Standard)","ar-dz":"Arabic (Algeria)","ar-bh":"Arabic (Bahrain)","ar-eg":"Arabic (Egypt)","ar-iq":"Arabic (Iraq)","ar-jo":"Arabic (Jordan)","ar-kw":"Arabic (Kuwait)","ar-lb":"Arabic (Lebanon)","ar-ly":"Arabic (Libya)","ar-ma":"Arabic (Morocco)","ar-om":"Arabic (Oman)","ar-qa":"Arabic (Qatar)","ar-sa":"Arabic (Saudi Arabia)","ar-sy":"Arabic (Syria)","ar-tn":"Arabic (Tunisia)","ar-ae":"Arabic (U.A.E.)","ar-ye":"Arabic (Yemen)",an:"Aragonese",hy:"Armenian",as:"Assamese",ast:"Asturian",az:"Azerbaijani",eu:"Basque",bg:"Bulgarian",be:"Belarusian",bn:"Bengali",bs:"Bosnian",br:"Breton",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",zh:"Chinese","zh-hk":"Chinese (Hong Kong)","zh-cn":"Chinese (PRC)","zh-sg":"Chinese (Singapore)","zh-tw":"Chinese (Taiwan)",cv:"Chuvash",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch (Standard)","nl-be":"Dutch (Belgian)",en:"English","en-au":"English (Australia)","en-bz":"English (Belize)","en-ca":"English (Canada)","en-ie":"English (Ireland)","en-jm":"English (Jamaica)","en-nz":"English (New Zealand)","en-ph":"English (Philippines)","en-za":"English (South Africa)","en-tt":"English (Trinidad & Tobago)","en-gb":"English (United Kingdom)","en-us":"English (United States)","en-zw":"English (Zimbabwe)",eo:"Esperanto",et:"Estonian",fo:"Faeroese",fa:"Farsi (Persian)",fj:"Fijian",fi:"Finnish",fr:"French (Standard)","fr-be":"French (Belgium)","fr-ca":"French (Canada)","fr-fr":"French (France)","fr-lu":"French (Luxembourg)","fr-mc":"French (Monaco)","fr-ch":"French (Switzerland)",fy:"Frisian",fur:"Friulian",gd:"Gaelic (Scots)","gd-ie":"Gaelic (Irish)",gl:"Galacian",ka:"Georgian",de:"German (Standard)","de-at":"German (Austria)","de-de":"German (Germany)","de-li":"German (Liechtenstein)","de-lu":"German (Luxembourg)","de-ch":"German (Switzerland)",el:"Greek",gu:"Gujurati",ht:"Haitian",he:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",iu:"Inuktitut",ga:"Irish",it:"Italian (Standard)","it-ch":"Italian (Switzerland)",ja:"Japanese",kn:"Kannada",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ky:"Kirghiz",tlh:"Klingon",ko:"Korean","ko-kp":"Korean (North Korea)","ko-kr":"Korean (South Korea)",la:"Latin",lv:"Latvian",lt:"Lithuanian",lb:"Luxembourgish",mk:"FYRO Macedonian",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mo:"Moldavian",nv:"Navajo",ng:"Ndonga",ne:"Nepali",no:"Norwegian",nb:"Norwegian (Bokmal)",nn:"Norwegian (Nynorsk)",oc:"Occitan",or:"Oriya",om:"Oromo","fa-ir":"Persian/Iran",pl:"Polish",pt:"Portuguese","pt-br":"Portuguese (Brazil)",pa:"Punjabi","pa-in":"Punjabi (India)","pa-pk":"Punjabi (Pakistan)",qu:"Quechua",rm:"Rhaeto-Romanic",ro:"Romanian","ro-mo":"Romanian (Moldavia)",ru:"Russian","ru-mo":"Russian (Moldavia)",sz:"Sami (Lappish)",sg:"Sango",sa:"Sanskrit",sc:"Sardinian",sd:"Sindhi",si:"Singhalese",sr:"Serbian",sk:"Slovak",sl:"Slovenian",so:"Somani",sb:"Sorbian",es:"Spanish","es-ar":"Spanish (Argentina)","es-bo":"Spanish (Bolivia)","es-cl":"Spanish (Chile)","es-co":"Spanish (Colombia)","es-cr":"Spanish (Costa Rica)","es-do":"Spanish (Dominican Republic)","es-ec":"Spanish (Ecuador)","es-sv":"Spanish (El Salvador)","es-gt":"Spanish (Guatemala)","es-hn":"Spanish (Honduras)","es-mx":"Spanish (Mexico)","es-ni":"Spanish (Nicaragua)","es-pa":"Spanish (Panama)","es-py":"Spanish (Paraguay)","es-pe":"Spanish (Peru)","es-pr":"Spanish (Puerto Rico)","es-es":"Spanish (Spain)","es-uy":"Spanish (Uruguay)","es-ve":"Spanish (Venezuela)",sx:"Sutu",sw:"Swahili",sv:"Swedish","sv-fi":"Swedish (Finland)","sv-sv":"Swedish (Sweden)",ta:"Tamil",tt:"Tatar",te:"Teluga",th:"Thai",tig:"Tigre",ts:"Tsonga",tn:"Tswana",tr:"Turkish",tk:"Turkmen",uk:"Ukrainian",hsb:"Upper Sorbian",ur:"Urdu",ve:"Venda",vi:"Vietnamese",vo:"Volapuk",wa:"Walloon",cy:"Welsh",xh:"Xhosa",ji:"Yiddish",zu:"Zulu"};function account_showLocalizationSettings(){if(xxdialogMode){return false}var b=getstore("loctag",0);var c='";var d=addHtmlValue("Localization",c);setDialogMode(2,"Localization Settings",3,account_showLocalizationSettingsEx,d);return false}function account_showLocalizationSettingsEx(){var b=getstore("loctag",0);var a=Q("d2locselect").value;if(b!=a){if(a!="*"){args.locale=a}else{delete args.locale}putstore("loctag",args.locale);masterUpdate(4294967295)}}function account_enableNotifications(){if(Notification){Notification.requestPermission().then(function(a){QV("accountEnableNotificationsSpan",a!="granted")})}return false}function account_showAccountNotifySettings(){if(xxdialogMode){return false}var b="";b+="";b+="";b+="";b+="";setDialogMode(2,"Notification Settings",3,account_showAccountNotifySettingsEx,b);var a=getstore("notifications",0);Q("p2notifyPlayNotifySound").checked=(a&1);Q("p2notifyIntelDeviceConnect").checked=(a&2);Q("p2notifyIntelDeviceDisconnect").checked=(a&4);Q("p2notifyIntelAmtKvmActions").checked=(a&8);return false}function account_showAccountNotifySettingsEx(){var a=0;a+=Q("p2notifyPlayNotifySound").checked?1:0;a+=Q("p2notifyIntelDeviceConnect").checked?2:0;a+=Q("p2notifyIntelDeviceDisconnect").checked?4:0;a+=Q("p2notifyIntelAmtKvmActions").checked?8:0;putstore("notifications",a)}function account_showVerifyEmail(){if(xxdialogMode||(userinfo.emailVerified==true)||(serverinfo.emailcheck!=true)){return false}var a="Click ok to send a verification mail to:
";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();return false}function account_validateEmail(a,b){QE("idx_dlgOkButton",validateEmail(Q("dp2email").value)&&(Q("dp2email").value!=userinfo.email));if((a!=null)&&(a.keyCode==13)){dialogclose(1)}}function account_changeEmail(){meshserver.send({action:"changeemail",email:Q("dp2email").value})}function account_showDeleteAccount(){if(xxdialogMode){return false}var a="To delete this account, type in the account password in both boxes below and hit ok.
";a+="";setDialogMode(2,"Delete Account",0,null,a);account_validateDeleteAccount();Q("apassword1").focus();return false}function account_showChangePassword(){if(xxdialogMode){return false}var d="Change your account password by entering the old password and new password twice in the boxes below.";if(features&65536){" Password hint can be used but is not recommanded."}d+="
";d+="";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+=" ";d+="Old password: ";d+="New password: ";if(features&65536){d+="New password: "}d+="Password hint:
Requirements: "+b.join(", ")+"."}}d+="
";setDialogMode(2,"Change Password",3,account_showChangePasswordEx,d);Q("apassword0").focus();account_validateNewPassword();return false}function account_showChangePasswordEx(){if(Q("apassword1").value==Q("apassword2").value){var a={action:"changepassword",oldpass:Q("apassword0").value,newpass:Q("apassword1").value};if(features&65536){a.hint=Q("apasswordhint").value}meshserver.send(a)}}function account_createMesh(){if(xxdialogMode){return false}if((userinfo.siteadmin!=4294967295)&&((userinfo.siteadmin&64)!=0)){setDialogMode(2,"New Device Group",1,null,"This account does not have the rights to create a new device group.");return false}if((userinfo.emailVerified!==true)&&(serverinfo.emailcheck==true)&&(userinfo.siteadmin!=4294967295)){setDialogMode(2,"Account Security",1,null,'Unable to access a device until a email address is verified. This is required for password recovery. Go to the "My Account" tab to change and verify an email address.');return false}if((features&262144)&&!((userinfo.otpsecret==1)||(userinfo.otphkeys>0)||(userinfo.otpkeys>0))){setDialogMode(2,"Account Security",1,null,'Unable to access a device until two-factor authentication is enabled. This is required for extra security. Go to the "My Account" tab and look at the "Account Security" section.');return false}var a="Create a new device group using the options below.
";a+=addHtmlValue("Name","");a+=addHtmlValue("Type","");a+=addHtmlValue("Description","");setDialogMode(2,"New Device Group",3,account_createMeshEx,a);account_validateMeshCreate();Q("dp2meshname").focus();return false}function account_validateMeshCreate(a,b){if((b==1)&&(a!=null)&&(a.key=="Enter")&&(Q("dp2meshname").value.length>0)){Q("dp2meshtype").focus()}if((b==2)&&(a!=null)&&(a.key=="Enter")){Q("dp2meshdesc").focus()}QE("idx_dlgOkButton",Q("dp2meshname").value.length>0)}function account_createMeshEx(a,b){meshserver.send({action:"createmesh",meshname:Q("dp2meshname").value,meshtype:Q("dp2meshtype").value,desc:Q("dp2meshdesc").value})}function account_validateDeleteAccount(){QE("account_dlgOkButton",(Q("apassword1").value.length>0)&&(Q("apassword1").value==Q("apassword2").value))}function account_validateNewPassword(){var d="",a=(Q("apassword0").value.length>0)&&(Q("apassword1").value.length>0)&&(Q("apassword1").value==Q("apassword2").value)&&(Q("apassword0").value!=Q("apassword1").value);if((features&65536)&&(Q("apasswordhint").value==Q("apassword1").value)){a=false}if(Q("apassword1").value!=""){if(passRequirements==null||passRequirements==""){var c=checkPasswordStrength(Q("apassword1").value);if(c>=80){d="Strong"}else{if(c>=60){d="Good"}else{d="Weak"}}}else{var b=checkPasswordRequirements(Q("apassword1").value,passRequirements);if(b==false){a=false;d="Policy"}}}QH("dxPassWarn",d);QE("idx_dlgOkButton",a)}function checkPasswordStrength(e){var g=0,d={},h=0,j={digits:/\d/.test(e),lower:/[a-z]/.test(e),upper:/[A-Z]/.test(e),nonWords:/\W/.test(e)};if(!e){return 0}for(var b=0;b";a=0}a++;b++;var d=0;if(meshes[i].links[userinfo._id]){d=meshes[i].links[userinfo._id].rights}var g="Partial Rights";if(d==4294967295){g="Full Administrator"}else{if(d==0){g="No Rights"}}e+="
";a+='";setDialogMode(2,"Restore Server",0,null,a);account_validateServerRestore();return false}function account_validateServerRestore(){QE("account_dlgOkButton",Q("account_dlgFileInput").files.length==1)}function server_showVersionDlg(){if(xxdialogMode){return false}setDialogMode(2,"MeshCentral Version",1,null,"Loading...","MeshCentralServerUpdate");meshserver.send({action:"serverversion"});return false}function server_showVersionDlgUpdate(){QE("idx_dlgOkButton",Q("d2updateCheck").checked)}function server_showVersionDlgEx(){meshserver.send({action:"serverupdate"})}function server_showErrorsDlg(){if(xxdialogMode){return false}setDialogMode(2,"MeshCentral Errors",1,null,"Loading...","MeshCentralServerErrors");meshserver.send({action:"servererrors"});return false}function server_showErrorsDlgUpdate(){QE("idx_dlgOkButton",Q("d2updateCheck").checked)}function server_showErrorsDlgEx(){meshserver.send({action:"serverclearerrorlog"})}function d2CopyServerErrorsToClip(){saveAs(new Blob([Q("d2ServerErrorsLogPre").innerText],{type:"application/octet-stream"}),"servererrors.txt")}var currentMesh;function p20updateMesh(){if(currentMesh==null){return}QH("p20meshName",EscapeHtml(currentMesh.name));var m="Unknown #"+currentMesh.mtype;var l=0;try{l=currentMesh.links[userinfo._id].rights}catch(d){}if(currentMesh.mtype==1){m="Intel® AMT only, no agent"}if(currentMesh.mtype==2){m="Managed using a software agent"}var t="";t+=addHtmlValue("Name",addLinkConditional(EscapeHtml(currentMesh.name),"p20editmesh(1)",(l&1)!=0));t+=addHtmlValue("Description",addLinkConditional(((currentMesh.desc&¤tMesh.desc!="")?EscapeHtml(currentMesh.desc):"None"),"p20editmesh(2)",(l&1)!=0));t+=addHtmlValue("Type",m);if(currentMesh.mtype==2){var h=[];if(currentMesh.flags){if(currentMesh.flags&1){h.push("Auto-Remove")}if(currentMesh.flags&2){h.push("Hostname Sync")}}h=h.join(", ");if(h==""){h="None"}t+=addHtmlValue("Features",addLinkConditional(h,"p20editmeshfeatures()",l&1))}if(currentMesh.mtype==2){h=[];var a=0;if(currentMesh.consent){a=currentMesh.consent}if(serverinfo.consent){a|=serverinfo.consent}if(a&8){h.push("Desktop Prompt")}else{if(a&1){h.push("Desktop Notify")}}if(a&16){h.push("Terminal Prompt")}else{if(a&2){h.push("Terminal Notify")}}if(a&32){h.push("Files Prompt")}else{if(a&4){h.push("Files Notify")}}if(a==7){h=["Always Notify"]}if((a&56)==56){h=["Always Prompt"]}h=h.join(", ");if(h==""){h="None"}t+=addHtmlValue("User Consent",addLinkConditional(h,"p20editmeshconsent()",l&1))}var j=0,k=[];if(userinfo.links&&userinfo.links[currentMesh._id]&&userinfo.links[currentMesh._id].notify){j=userinfo.links[currentMesh._id].notify}if(j&2){k.push("Connect")}if(j&4){k.push("Disconnect")}if(j&8){k.push("Intel® AMT")}if(k.length==0){k.push("None")}t+=addHtmlValue("Notifications",addLink(k.join(", "),"p20editMeshNotify()"));var g="No Policy";if(currentMesh.amt){if(currentMesh.amt.type==1){g="Deactivate Client Control Mode (CCM)"}else{if(currentMesh.amt.type==2){g="Simple Client Control Mode (CCM)";if(currentMesh.amt.cirasetup==2){g+=" + CIRA"}}else{if(currentMesh.amt.type==3){g="Simple Admin Control Mode (ACM)";if(currentMesh.amt.cirasetup==2){g+=" + CIRA"}}}}}t+=addHtmlValue("Intel® AMT",addLinkConditional(g,"p20editMeshAmt()",l&1));if(l&1){t+='
'}t+="
";var c=currentMesh.links[userinfo._id];if(c&&((c.rights&2)!=0)){t+=' Add Users'}if((l&4)!=0){if(currentMesh.mtype==1){t+=" Install CIRA';t+=" Install local';if(currentMesh.amt&&(currentMesh.amt.type==2)){t+=" Activation'}else{if(currentMesh.amt&&(currentMesh.amt.type==3)&&((features&1048576)!=0)){t+=" Activation'}}}if(currentMesh.mtype==2){t+=" Install';t+=" Invite'}}t+='
";if(l==4294967295){t+=""}QH("p20info",t)}function p20editMeshAmt(){if(xxdialogMode){return}var b="",a="";if((features&1048576)!=0){a=""}if(currentMesh.mtype==1){b+=addHtmlValue("Type","")}else{b+=addHtmlValue("Type","")}b+="";setDialogMode(2,"Intel® AMT Policy",3,p20editMeshAmtEx,b);if(currentMesh.amt){Q("dp20amtpolicy").value=currentMesh.amt.type}p20editMeshAmtChange();if(currentMesh.amt&&(currentMesh.amt.type==2)||(currentMesh.amt.type==3)){Q("dp20amtpolicypass").value=currentMesh.amt.password;if((currentMesh.amt.type==2)&&(currentMesh.amt.badpass!=null)){Q("dp20amtbadpass").value=currentMesh.amt.badpass}if((features&1024)==0){Q("dp20amtcira").value=currentMesh.amt.cirasetup}}dp20amtValidatePolicy()}function p20editMeshAmtChange(){var a=Q("dp20amtpolicy").value,b="";if(a>=2){b=addHtmlValue("Password*","");b+=addHtmlValue("Password*","");if((a==2)&&(currentMesh.mtype==2)){b+=addHtmlValue("Password mismatch","")}if((features&1024)==0){if(a==2){b+=addHtmlValue('CIRA',"")}else{b+=addHtmlValue('CIRA',"")}}b+=' ';var b=1,p=[];for(var e in currentMesh.links){var s=e.split("/")[2];if(currentMesh.links[e].name){s=currentMesh.links[e].name}if(e==userinfo._id){s=userinfo.name}p.push({id:e,name:s,rights:currentMesh.links[e].rights})}p.sort(function(r,u){if(r.name>u.name){return 1}if(r.nameUser Authorizations ";++b}t+="
* Leave blank to assign a random password to each device.
';if(currentMesh.mtype==2){if(a==2){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.'}else{b+='During activation, the agent will have access to admin password infomation.'}}}QH("dp20amtpolicydiv",b);setTimeout(dp20amtValidatePolicy,1)}function dp20amtValidatePolicy(){var a=true,d=Q("dp20amtpolicy").value;if((d==2)||(d==3)){var b=Q("dp20amtpolicypass").value,c=Q("dp20amtpolicypass2").value;a=((b===c)&&((b==="")?true:passwordcheck(b)))}QE("idx_dlgOkButton",a)}function p20editMeshAmtEx(){var b=parseInt(Q("dp20amtpolicy").value),a={type:b};if(b==2){a={type:b,password:Q("dp20amtpolicypass").value};if(currentMesh.mtype==2){a.badpass=parseInt(Q("dp20amtbadpass").value)}if((features&1024)==0){a.cirasetup=parseInt(Q("dp20amtcira").value)}else{a.cirasetup=1}}else{if(b==3){a={type:b,password:Q("dp20amtpolicypass").value};if((features&1024)==0){a.cirasetup=parseInt(Q("dp20amtcira").value)}else{a.cirasetup=1}}}meshserver.send({action:"meshamtpolicy",meshid:currentMesh._id,amtpolicy:a})}function p20showDeleteMeshDialog(){if(xxdialogMode){return false}var a='Are you sure you want to delete group "'+EscapeHtml(currentMesh.name)+'"? Deleting the device group will also delete all information about devices within this group.
';a+="";setDialogMode(2,"Delete Group",3,p20showDeleteMeshDialogEx,a);p20validateDeleteMeshDialog();return false}function p20validateDeleteMeshDialog(){QE("idx_dlgOkButton",Q("p20check").checked)}function p20showDeleteMeshDialogEx(a,b){meshserver.send({action:"deletemesh",meshid:currentMesh._id,meshname:currentMesh.name})}function p20editmesh(a){if(xxdialogMode){return}var b=addHtmlValue("Name","");b+=addHtmlValue("Description","");setDialogMode(2,"Edit Device Group",3,p20editmeshEx,b);Q("dp20meshname").value=currentMesh.name;if(currentMesh.desc){Q("dp20meshdesc").value=currentMesh.desc}p20editmeshValidate();if(a==2){Q("dp20meshdesc").focus()}else{Q("dp20meshname").focus()}}function p20editmeshEx(){meshserver.send({action:"editmesh",meshid:currentMesh._id,meshname:Q("dp20meshname").value,desc:Q("dp20meshdesc").value})}function p20editmeshValidate(a){QE("idx_dlgOkButton",Q("dp20meshname").value.length>0);if(a&&a.key=="Enter"){Q("dp20meshdesc").focus()}}function p20editmeshconsent(){if(xxdialogMode){return}var b="",a=(currentMesh.consent)?currentMesh.consent:0;b+='
"}else{d=decodeURIComponent(d);var c=d.split("/")[2];if(users&&users[d]){c=users[d].name}if(userinfo._id==d){c=userinfo.name}e+="Group permissions for user "+c+".
"}e+='
";e+="
";e+="
";e+="
";e+="
";e+="
";e+="
";e+="
";e+="
";e+="
";e+="
";e+="
";e+="
";e+="
";e+="
"}QH("dp20usersuggest",k);j=true}}}QV("dp20usersuggest",j)}QE("idx_dlgOkButton",h);QE("p20fulladmin",g==4294967295);QE("p20editmesh",(!Q("p20fulladmin").checked)&&(g==4294967295));QE("p20manageusers",!Q("p20fulladmin").checked);QE("p20managecomputers",!Q("p20fulladmin").checked);QE("p20remotecontrol",!Q("p20fulladmin").checked);QE("p20meshagentconsole",!Q("p20fulladmin").checked);QE("p20meshserverfiles",!Q("p20fulladmin").checked);QE("p20wakedevices",!Q("p20fulladmin").checked);QE("p20editnotes",!Q("p20fulladmin").checked);QE("p20remoteview",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20remotelimitedinput",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked&&!Q("p20remoteview").checked);QE("p20noterminal",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20nofiles",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked);QE("p20noamt",!Q("p20fulladmin").checked&&Q("p20remotecontrol").checked)}function p20showAddMeshUserDialogEx(a,e){if(a==2){p20viewuserEx(a,e)}else{var d=0;if(Q("p20fulladmin").checked==true){d=4294967295}else{if(Q("p20editmesh").checked==true){d+=1}if(Q("p20manageusers").checked==true){d+=2}if(Q("p20managecomputers").checked==true){d+=4}if(Q("p20remotecontrol").checked==true){d+=8}if(Q("p20meshagentconsole").checked==true){d+=16}if(Q("p20meshserverfiles").checked==true){d+=32}if(Q("p20wakedevices").checked==true){d+=64}if(Q("p20editnotes").checked==true){d+=128}if(Q("p20remoteview").checked==true){d+=256}if(Q("p20noterminal").checked==true){d+=512}if(Q("p20nofiles").checked==true){d+=1024}if(Q("p20noamt").checked==true){d+=2048}if(Q("p20remotelimitedinput").checked==true){d+=4096}}if(e==null){var g=Q("dp20username").value.split(","),h=[];for(var c in g){h.push(g[c].trim())}meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,usernames:h,meshadmin:d})}else{meshserver.send({action:"addmeshuser",meshid:currentMesh._id,meshname:currentMesh.name,usernames:[e.split("/")[2]],meshadmin:d})}}}function p20viewuser(g){if(xxdialogMode){return}var j=decodeURIComponent(g);var b=currentMesh.links[userinfo._id].rights,c=currentMesh.links[j].rights;if(((userinfo._id)!=j)&&(b==4294967295||(((b&2)!=0)&&(c!=4294967295)))){p20showAddMeshUserDialog(g)}else{var d="";if(c==4294967295){d=", Full Administrator (all rights)"}else{if((c&1)!=0){d+=", Edit Device Group"}if((c&2)!=0){d+=", Manage Device Group Users"}if((c&4)!=0){d+=", Manage Device Group Computers"}if((c&8)!=0){d+=", Remote Control"}if((c&16)!=0){d+=", Agent Console"}if((c&32)!=0){d+=", Server Files"}if((c&64)!=0){d+=", Wake Devices"}if((c&128)!=0){d+=", Edit Notes"}if(((c&8)!=0)&&(c&256)!=0){d+=", Remote View Only"}if(((c&8)!=0)&&(c&512)!=0){d+=", No Terminal"}if(((c&8)!=0)&&(c&1024)!=0){d+=", No Files"}if(((c&8)!=0)&&(c&2048)!=0){d+=", No Intel® AMT"}if(((c&8)!=0)&&((c&4096)!=0)&&((c&256)==0)){d+=", Limited Input"}}d=d.substring(2);if(d==""){d="No Rights"}var e=j.split("/")[2];if(users&&users[j]){e=users[j].name}if(userinfo._id==j){e=userinfo.name}var a=1,h=addHtmlValue("User Name",EscapeHtml(decodeURIComponent(e)));if(j.split("/")[2]!=e){h+=addHtmlValue("User Identifier",EscapeHtml(j.split("/")[2]))}h+=addHtmlValue("Permissions",d);if(((userinfo._id)!=j)&&(b==4294967295||(((b&2)!=0)&&(c!=4294967295)))){a+=4}setDialogMode(2,"Device Group User",a,p20viewuserEx,h,j)}}function p20viewuserEx(a,c){if(a!=2){return}var b=c.split("/")[2];if(users&&users[c]){b=users[c].name}if(userinfo._id==c){b=userinfo.name}setDialogMode(2,"Remote Mesh User",3,p20viewuserEx2,"Confirm removal of user "+EscapeHtml(decodeURIComponent(b))+"?",c)}function p20deleteUser(a,b){haltEvent(a);p20viewuserEx(2,decodeURIComponent(b));return false}function p20viewuserEx2(a,b){meshserver.send({action:"removemeshuser",meshid:currentMesh._id,meshname:currentMesh.name,userid:b})}function p20editMeshNotify(){if(xxdialogMode){return false}var a=0;if(userinfo.links&&userinfo.links[currentMesh._id]&&userinfo.links[currentMesh._id].notify){a=userinfo.links[currentMesh._id].notify}var b="Notification settings must also be turned on in account settings.
";b+="";b+="";b+="";setDialogMode(2,"Notification Settings",3,p20editMeshNotifyEx,b);Q("p20notifyIntelDeviceConnect").checked=(a&2);Q("p20notifyIntelDeviceDisconnect").checked=(a&4);Q("p20notifyIntelAmtKvmActions").checked=(a&8);return false}function p20editMeshNotifyEx(){var a=0;a+=Q("p20notifyIntelDeviceConnect").checked?2:0;a+=Q("p20notifyIntelDeviceDisconnect").checked?4:0;a+=Q("p20notifyIntelAmtKvmActions").checked?8:0;meshserver.send({action:"changemeshnotify",meshid:currentMesh._id,notify:a})}var filetreelinkpath;var filetreelocation=[];function updateFiles(){QV("MainMenuMyFiles",((features&8)==0));if((features&8)!=0){return}var q="",r="",c='Root',o="Root",y,k=filetree,m=1;var j=[],v=filetreelinkpath,b=[],a=document.getElementsByName("fc");for(var s=0;s
":"";setDialogMode(2,"Delete",3,p5deletefileEx,(a>1)?("Delete "+a+" selected items?"+b):("Delete selected item?"+b))}function p5deletefileEx(){var b=[],a=document.getElementsByName("fc");for(var c=0;c
"}if(j==""){j=" "}var d="si3";if(b.etype=="user"){d="m2"}if(b.etype=="server"){d="si3"}var e=EscapeHtml(b.msg).split("(R)").join("®");if(b.nodeid){var g=getNodeFromId(b.nodeid);if(g!=null){d="si"+g.icon;e=""+EscapeHtml(g.name)+" → "+e}}if(b.username){if((userinfo.siteadmin&2)&&(b.userid)){e=""+EscapeHtml(b.username)+" → "+e}else{e=EscapeHtml(b.username)+" → "+e}}if(b.etype=="relay"||b.action=="relaylog"){d="relayIcon16"}j+=""+a+" "+printTime(h)+" - "+e+" "}}if(a!=null){j+="
No Events Found
"}QH("p3events",j)}function refreshEvents(){meshserver.send({action:"events",limit:parseInt(p3limitdropdown.value)})}function p3showDownloadEventsDialog(a){if(xxdialogMode){return}var b="Download the list of events with one of the file formats below.
";b+=addHtmlValue("CSV Format",'eventslist.csv');b+=addHtmlValue("JSON Format",'eventslist.json');setDialogMode(2,"Event List Export",1,null,b,a)}function p3downloadEventsDialogCSV(d){var a,b;if(d==1){b=currentDeviceEvents}if(d==2){b=events}if(d==3){b=currentUserEvents}a="time, type, action, user, message\r\n";for(var c in b){a+='"'+b[c].time+'","'+b[c].etype+'","'+((b[c].action!=null)?b[c].action:"")+'","'+((b[c].username!=null)?b[c].username:"")+'","'+((b[c].msg!=null)?b[c].msg:"")+'"\r\n'}saveAs(new Blob([a],{type:"application/octet-stream"}),"eventslist.csv");return false}function p3downloadEventsDialogJSON(c){var d=[],a;if(c==1){a=currentDeviceEvents}if(c==2){a=events}if(c==3){a=currentUserEvents}for(var b in a){d.push(events[b])}saveAs(new Blob([JSON.stringify(d)],{type:"application/octet-stream"}),"eventslist.json");return false}function updateUsers(){QV("MainMenuMyUsers",(users!=null)&&((features&4)==0));QV("LeftMenuMyUsers",(users!=null)&&((features&4)==0));QV("UserNewAccountButton",((features&4)==0)&&(serverinfo.domainauth==false));if((users==null)||((features&4)!=0)){QH("p3users","");return}var h=[],e=100,c=0;for(var d in users){h.push(d)}h.sort();var k=Q("UserSearchInput").value.toLowerCase();var b=k;if(k.startsWith("email:")){k=null;b=b.substring(6)}else{if(k.startsWith("name:")){b=null;k=k.substring(5)}else{if(k.startsWith("e:")){k=null;b=b.substring(2)}else{if(k.startsWith("n:")){b=null;k=k.substring(2)}}}}var l="",a=true;l+="
";if(c==1){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+=" Offline Users";a=false}l+=addUserHtml(j,g);e--}else{c++}}}l+="
1 more user not shown, use search box to look for users...
"}else{if(c>1){l+="
"+c+" more users not shown, use search box to look for users...
"}}if(e==100){l+="
No users found.
"}QH("p3users",l);if((currentUser!=null)&&(xxcurrentView==30)){gotoUser(encodeURIComponent(currentUser._id),true)}}function addUserHtml(n,l){var p="",b=" gray",e="m2",h="",k=(n.name!=userinfo.name),g="",j="";if(l!=null){b="";if(k){h='";h+=""}if(l==1){g+="1 session"}else{g+=l+" sessions"}}else{if(n.login){g+=''+printDate(new Date(n.login*1000))+""}}if(k){j+=""}if((n.siteadmin!=null)&&((n.siteadmin&32)!=0)&&(n.siteadmin!=4294967295)){j+="Locked, "}j+="";var m=n.siteadmin&(4294967295-224);if((n.siteadmin==null)||(m==0)){j+="User"}else{if(m==8){j+="User + Files"}else{if(n.siteadmin==4294967295){j+="Administrator"}else{if((m&2)!=0){j+="Manager"}else{j+="Partial"}}}}if((n.siteadmin!=null)&&(n.siteadmin!=4294967295)&&((n.siteadmin&(64+128))!=0)){j+="*"}j+="";if(k){j+=""}var c=0;if(n.links){for(var d in n.links){c++}}var o=EscapeHtml(n.name),a="";if(serverinfo.emailcheck==true){a=((n.emailVerified!=true)?' ✗':' ✓')}if(n.email!=null){if(((features&2097152)==0)||(n.email.toLowerCase()!=n.name.toLowerCase())){o+=", "+n.email+""+a}else{o+=" '+a}}if((n.otpsecret>0)||(n.otphkeys>0)){o+=' '}if((n.siteadmin!=null)&&((n.siteadmin&32)!=0)&&(n.siteadmin!=4294967295)){o+=' '}p+="';p+=" "+c+" "+g+" "+j;return p}function userMouseHover(b,c){var a=b.children[0].children[0];a.children[1].classList.remove("g1s");a.children[2].classList.remove("g2s");if(c==1){a.children[1].classList.add("g1s");a.children[2].classList.add("g2s")}b.children[0].children[0].style["background-color"]=((c==0)?"#c9c9c9":"#b9b9b9")}function userChat(a,d,b){haltEvent(a);var c="/messenger?id=meshmessenger/"+d+"/"+encodeURIComponent(userinfo._id)+"&title="+b;if((authCookie!=null)&&(authCookie!="")){c+="&auth="+authCookie}window.open(c,"meshmessenger:"+d);meshserver.send({action:"meshmessenger",userid:decodeURIComponent(d)});return false}function showUserAlertDialog(a,b){if(xxdialogMode){return}haltEvent(a);setDialogMode(2,"Notify "+EscapeHtml(users[decodeURIComponent(b)].name),3,showUserAlertDialogEx,'Send a text notification to this user.',b);Q("d2notifyText").focus();return false}function showUserAlertDialogEx(a,b){meshserver.send({action:"notifyuser",userid:decodeURIComponent(b),msg:Q("d2notifyText").value})}function doemail(b,a){if(xxdialogMode){return false}haltEvent(b);window.open("mailto:"+a);return false}function p4batchAccountCreate(){if(xxdialogMode){return}var a='Create many accounts at once by importing a JSON file with the following format: [\r\n {"user":"x1","pass":"x","email":"x1@x"},\r\n {"user":"x2","pass":"x","resetNextLogin":true}\r\n]
';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");return false}function p4downloadUserInfoJSON(){var b=[];for(var a in users){b.push(users[a])}saveAs(new Blob([JSON.stringify(b)],{type:"application/octet-stream"}),"userlist.json");return false}function showUserBroadcastDialog(){if(xxdialogMode){return}var a='Broadcast a message to all connected users.';setDialogMode(2,"Broadcast Message",3,showUserBroadcastDialogEx,a);Q("broadcastMessage").focus()}function showUserBroadcastDialogEx(){meshserver.send({action:"userbroadcast",msg:Q("broadcastMessage").value})}function showCreateNewAccountDialog(){if(xxdialogMode){return}var d="";if((features&2097152)==0){d+=addHtmlValue("Name","")}d+=addHtmlValue("Email","");d+=addHtmlValue("Password","");d+=addHtmlValue("Password","");d+="";d+="";if(serverinfo.emailcheck){d+="";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+="
";g+=addHtmlValue("Realms",'');setDialogMode(2,"Administrative Realms",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+="
";d+="
";d+="
";d+="
";d+="
";d+="
";d+="
";d+="
";d+="";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(((features&2097152)==0)&&((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",printDateTime(new Date(p.creation*1000)));if(p.login){s+=addDeviceAttribute("Last Login",printDateTime(new Date(p.login*1000)))}if(p.passchange==-1){s+=addDeviceAttribute("Password","Will be changed on next login.")}else{if(p.passchange){s+=addDeviceAttribute("Password","Last changed: "+printDateTime(new Date(p.passchange*1000)))}}var j=0,k="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);if((userinfo.siteadmin==4294967295)||(userinfo.siteadmin&2)){var q="None";if(p.groups){q="";for(var h in p.groups){q+=''+p.groups[h]+""}}s+=addDeviceAttribute("Admin Realms",addLinkConditional(q,'showUserGroupDialog(event,"'+r+'")',(userinfo.siteadmin==4294967295)||((userinfo.groups==null)&&(userinfo._id!=p._id)&&(p.siteadmin!=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+="
";s+='';if(!o&&(a>0)){s+=''}QH("p30html",s);drawUserTimeline();var b=true;if(p._id==userinfo._id){b=false}if(p.siteadmin&&p.siteadmin>0&&userinfo.siteadmin!=4294967295){b=false}s="
";QH("p30html3",s);s="";if(a==1){s="1 active session"}else{if(a>1){s=a+" active sessions"}}QH("MainUserState",s);go(30);QH("p31events","");refreshUsersEvents()}function p30showUserEmailChangeDialog(a){if(xxdialogMode){return false}var b="";b+=addHtmlValue("Email","");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();return false}function p30validateEmail(){var a=Q("dp30email").value,b=a.split("@");b=(b.length==2)&&(b[0].length>0)&&(b[1].split(".").length>1)&&(b[1].length>2)&&(a.length<1024)&&((a!=userinfo.email)||((serverinfo.emailcheck==true)&&(Q("dp30verified").value!=(userinfo.emailVerified?1:0))));QE("idx_dlgOkButton",b)}function p30showUserEmailChangeDialogEx(){var a={action:"edituser",id:currentUser._id,email:Q("dp30email").value};if(serverinfo.emailcheck){a.emailVerified=(Q("dp30verified").value==1)}meshserver.send(a)}function p30showUserChangePassDialog(b){if(xxdialogMode){return}var e="";e+=addHtmlValue("Password","");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+=" ";++b;h=new Date(h.getTime()-(1000*60*60*24))}QH("p30html2",'
")}var currentUserEvents=null;function userEventsUpdate(){var j="",a=null;for(var c in currentUserEvents){var b=currentUserEvents[c],h=new Date(b.time);if(b.msg){if(b.h==null){b.h=Math.random()}if(printDate(h)!=a){if(a!=null){j+=""}a=printDate(h);j+=" '+z+"Day 7 Day Login State
"}if(j==""){j=" "}var d="si3";if(b.etype=="user"){d="m2"}if(b.etype=="server"){d="si3"}var e=EscapeHtml(b.msg).split("(R)").join("®");if(b.nodeid){var g=getNodeFromId(b.nodeid);if(g!=null){d="si"+g.icon;e=""+EscapeHtml(g.name)+" → "+e}}if(b.username&&(b.username!=currentUser.name)){if((userinfo.siteadmin&2)&&(b.userid)){e=""+EscapeHtml(b.username)+" → "+e}else{e=EscapeHtml(b.username)+" → "+e}}if(b.etype=="relay"||b.action=="relaylog"){d="relayIcon16"}j+=""+a+" "+printTime(h)+" - "+e+" "}}if(a!=null){j+="
No Events Found
"}QH("p31events",j)}function refreshUsersEvents(){meshserver.send({action:"events",limit:parseInt(p31limitdropdown.value),user:currentUser.name})}function d3init(){Q("d3localFile").value="";d3modechange()}function d3modechange(){var a=Q("d3uploadMode").value;QV("d3localmode",a==1);QV("d3servermode",a==2);if(a==1){d3setActions()}else{d3updatefiles()}}var d3filetreelinkpath;var d3filetreelocation=[];function d3updatefiles(){if(Q("d3uploadMode").value==1){return}var m="",n="",e=filetree,j=1;var c=[],r=d3filetreelinkpath,b=[],a=document.getElementsByName("fc");for(var o=0;o
").join("\r\n");if(a.nodeid){var b=getNodeFromId(a.nodeid);if(b){c=new Notification("{{{title}}} - "+b.name,{tag:a.tag,body:e,icon:"/images/notify/icons128-"+b.icon+".png"})}}else{if(a.icon==null){a.icon=0}var g=a.title;if(g==null){g=""}else{g=" - "+a.title}c=new Notification("{{{title}}}"+g,{tag:a.tag,body:e,icon:"/images/notify/icons128-"+a.icon+".png"})}c.id=a.id;c.xtag=a.tag;c.nodeid=a.nodeid;c.username=a.username;c.onclick=function(h){notificationSelected(h.target.id,true)};a.notification=c}}function deleteAllNotifications(){notifications=[];setNotificationCount(0);drawNotifications();QV("notifiyBox",false)}function setupGeneralServerStats(){window.serverStatCpu=new Chart(document.getElementById("serverCpuChart").getContext("2d"),{type:"doughnut",data:{datasets:[{data:[0,0],backgroundColor:["#AAAAAA","#00AA00"]}],labels:["Used","Free"]},options:{responsive:true,legend:{position:"none",},animation:{animateScale:true,animateRotate:true},width:"60px"}});window.serverStatMemory=new Chart(document.getElementById("serverMemoryChart").getContext("2d"),{type:"doughnut",data:{datasets:[{data:[0,0],backgroundColor:["#AAAAAA","#00AA00"]}],labels:["Used","Free"]},options:{responsive:true,legend:{position:"none",},animation:{animateScale:true,animateRotate:true},width:"60px"}})}var lastServerStats=null;function updateGeneralServerStats(d){if(d!=null){lastServerStats=d}else{d=lastServerStats}if(d==null){return}if(typeof d.cpuavg=="object"){var c=Math.min(d.cpuavg[0],1);window.serverStatCpu.config.data.datasets[0].data=[c,1-c];QH("serverCpuChartText",'"+b+""+d.values[a][b]+" "}function TableStart2(){return"
"}function AddButton(b,a){return""}function AddButton2(b,a){return""}function AddRefreshButton(a){return""}function MoreStart(){return'▼ More '}function getSelectedOptions(e){var d=[],c;for(var a=0,b=e.options.length;a0){e[b[c].substring(0,d)]=b[c].substring(d+1,b[c].length)}}return e}function addHtmlValue(a,b){return""}function TableEntry(a,b){return" "+b}function FullTable(c,a){var b=TableStart();for(i in c){if(i&&c[i]){b+=TableEntry(i,c[i])}}return b+TableEnd(a)}function TableEnd(a){return"
"}function addHtmlValue2(a,b){return""+a+" "+b+"