var CscopeInfo=window.CscopeInfo||{};try{var isClient="undefined"!=typeof window&&window.document}catch(e){isClient=!1}try{var isLambda="undefined"!=typeof process&&!!process.env.LAMBDA_TASK_ROOT}catch(e){isLambda=!1}try{var isWebview="undefined"!=typeof Ti}catch(e){isWebview=!1}if(isWebview)log={logInfo:function(e){Ti.API.info("CScope Info: "+e)},logError:function(e){Ti.API.error("CScope Error: "+e)},logWarn:function(e){Ti.API.warn("CScope Warn: "+e)}};else var log={logInfo:function(e){console.log("CScope Info:",e)},logError:function(e){console.log("CScope Error:",e)},logWarn:function(e){console.log("CScope Warn:",e)}};var cscopenavbar=function(s){var y,t,n,d,c="user",r="",g=!1,f=!1,u=!1,o=!1,p=[],m="month",a={hour:"date",day:"month",month:"year",year:"decade"},M=[],h="",l=!1,e=!1,i=!1,v=environmentVariables.envVariables().environment;"prod"==v&&(console.log=function(){}),log.logInfo("Env "+v);var I={};function k(){log.logInfo("Init navbar"),_config[v].api.invokeUrl||s("#noApiMessage").show(),s("#loader").hide(),b()}function b(){d&&!e&&(e=!0,s("#navbar").load("navbar.html",function(){s('input:checkbox[value="userCheckbox"]').prop("checked",!0),s("#navbarteamlist").hide(),document.getElementById("userIcon").title=new AmazonCognitoIdentity.CognitoUserPool({UserPoolId:_config[v].cognito.userPoolId,ClientId:_config[v].cognito.userPoolClientId}).getCurrentUser().username.replace("-at-","@"),te(),Z(),function(){log.logInfo("navbarReady fired");var e=new CustomEvent("navbarReady",{detail:{name:"John"}});document.getElementById("navbar").dispatchEvent(e)}(),s.ajax({method:"GET",url:_config[v].api.invokeUrl+"/team",headers:{Authorization:d},data:{type:"managed"},contentType:"application/json",dataType:"text",success:q,error:function(e,o,t){console.log("Error getting team data: "+o+", Details: "+t+"Response: "+e.responseText),console.error("Error getting team data: ",o,", Details: ",t),console.error("Response team: ",e.responseText)}}),R(),w()}))}function w(){s.ajax({method:"GET",url:_config[v].api.invokeUrl+"/locator",headers:{Authorization:d},contentType:"application/json",dataType:"text",success:N,error:function(e,o,t){console.log("Error getting locator data: "+o+", Details: "+t+"Response: "+e.responseText),console.error("Error getting locator data: ",o,", Details: ",t),console.error("Response locator: ",e.responseText)}})}function N(e,o,t){log.logInfo("completeCallbackDevices "+JSON.stringify(e));var n,y,r=(n=e,JSON.parse(n)),a=[];if(0==r.length)return document.getElementById("noLocatorMessage").hidden=!1,void le();for(var d=0;d""+o.owner+o.model+o.generation+o.serial?1:0}),function(e){var o,t;if(log.logInfo("Serials "+JSON.stringify(e)),!(o=document.getElementById("seriallist")))return;if(p=[],o.firstChild)for(;o.firstChild;)o.removeChild(o.firstChild);for(var n,y,r=[],a=[],d={},l=[],i={},s=0;s"+e[s].owner.replace("-at-","@")+"
",a.push(y),r.push(e[s].owner),d[e[s].owner]=0,o.appendChild(y)):y=a[n];var c=e[s];delete c.checked,p.push(c),(t=document.createElement("input")).style.margin="0px 0px 0px 10px",t.type="checkbox",t.name="serial"+s,t.value=e[s].model+"-"+e[s].generation+"-"+e[s].serial,t.checked=e[s].checked,t.id="deviceListElement",y.appendChild(t);var g=e[s].freeText?'"'+e[s].freeText+'"':void 0,f=void 0!==g&&!g.includes("C.Scope Locator")&&!g.includes("C.Scope Transmitter");f?(l.includes(g)?y.appendChild(document.createTextNode(" "+g+" ["+i[g]+"] ")):y.appendChild(document.createTextNode(" "+g+" ")),l.push(g),i[g]=i[g]?i[g]+1:1):y.appendChild(document.createTextNode(" "+e[s].model+(e[s].generation?e[s].generation+"-"+e[s].serial:"-"+e[s].serial)+" ")),d[e[s].owner]++,d[e[s].owner]%3==0&&y.appendChild(document.createElement("br"))}}(a=y),P(),f=!0,s("input:checkbox").click(function(e){log.logInfo("ID is "+this.id),"deviceListElement"==this.id?log.logInfo((this.checked?"":"un")+"checked serial box "):"typeCheckbox"==this.id&&("userCheckbox"==this.value?this.checked?(c="user",s('input:checkbox[id="typeCheckbox"]').not(this).prop("checked",!1)):(c="team",s('input:checkbox[id="typeCheckbox"]').not(this).prop("checked",!0)):this.checked?(c="team",s('input:checkbox[id="typeCheckbox"]').not(this).prop("checked",!1)):(c="user",s('input:checkbox[id="typeCheckbox"]').not(this).prop("checked",!0)),log.logInfo("Value "+this.value),D())}),E(I),log.logInfo("After set device list "+JSON.stringify(a)),0==Object.keys(I).length&&log.logInfo("Get No Params Data"),K(m);var i=O();log.logInfo("completeCallbackDevices "+f+" "+g+" "+u),f&&g&&u&&A(i)}function S(e){log.logInfo("setSelectedDevices "+JSON.stringify(e));var o=document.getElementById("seriallist");if(o){log.logInfo("setSelectedDevices "+JSON.stringify(e)+" "+JSON.stringify(o.childNodes));for(var t=0;t '+t.title+"",e.appendChild(n)}U()}function U(){for(report in M){M[report];var e=document.getElementById("nav"+report);null!=e&&e.addEventListener("click",J)}}function J(e){menuItemId=e.currentTarget.id;var o=menuItemId.substr(3);selectedDevices=O(),x(selectedDevices,o)}function z(e){log.logInfo("Changing report key to "+e+" from "+h),""==e||""!=h&&M[e].type==M[h].type||(h=e,"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./"+M[e].type+".html"+C("report")),h=e,P()}function Z(){s("#preCannedDateRange").on("click",function(){null==m&&alert("Please select a range"),0==s('input:checkbox:checked[id^="deviceListElement"]').length&&alert("Please select a serial Number")}),s("#reloadUserData").click(function(){log.logInfo("Clicked Reload for "+JSON.stringify(y));var e=moment.tz(y.lastReload,moment.tz.guess()),o=moment(),t=moment().subtract(1,"days");if(e.isBetween(t,o)&&"simonfry.cscope-at-gmail.com"!=y)return log.logInfo("Too recent"),void alert("Each user can only reload data once every 24 hours, please try again later.");log.logInfo("Can reloadData");var n=prompt("Please enter the user who's data you want to reload.","User To Reload");""!=n&&"User To Reload"!=n&&null!=n?/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(n).toLowerCase())?(n=n.replace("@","-at-"),log.logInfo("Going to reload data for "+n),y.reloadData(y.user,n)):(log.logInfo("Invalid email address"),alert("Please enter a valid email address")):alert("Please enter a valid email address")}),s("#navBrowseLeft").click(function(){log.logInfo("Browse left "+t);var e=moment(t);ae(m,e)}),s("#navBrowseRight").click(function(){log.logInfo("Browse right "+n);var e=moment(n);ae(m,e)}),s("#navBrowseZoomOut").click(function(){m in a&&(m=a[m]),"date"==m&&(m="day"),K(m),$(m),log.logInfo("Zoom out to "+m);var e=B();W(m,e)}),s("#rangeLabel").html("Date Range"),s("#request").click(function(){log.logInfo("Requesting data"),"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),CscopeInfo.checkTokenState(),log.logInfo("Request for "+h),log.logInfo("Filter mode "+c),s(infoPanel).hide();var e=O();K(m),A(e)}),s("#navFilter").click(function(){s(infoPanel).is(":visible")?s(infoPanel).hide():s(infoPanel).show()}),s("#navSignOut").click(function(){window.confirm("Are you sure you want to sign out?")&&(CscopeInfo.signOut(),"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./signin.html"+C("signOut"))}),U(),s("#navUpload").click(function(){"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./upload.html"+C("report")}),s("#navTeam").click(function(){"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./team.html"+C("report")}),s("#navCertificate").click(function(){"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./certificate.html"+C("report")}),s("#navTeam").click(function(){"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./team.html"+C("report")}),s("#navAlert").click(function(){"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./alert.html"}),s("#navHelp").click(function(){window.open("./help.html?p="+window.location.pathname)}),s("#navChangePassword").click(function(){"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./changePassword.html?p="+window.location.pathname}),s("#navHome").click(function(){"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./index.html"}),s("#navLogo").click(function(){"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),de(),window.location="./index.html"}),s("#serial").change(D),s("#seriallist").change(D),s("#navbarteamlist").change(D),s("#navbarloalist").change(D)}function K(e){log.logInfo("updateZoomOutTitle "+e),"decade"!=e&&a[e]?(ee(),zoomOutLoa=a[e],"date"==zoomOutLoa&&(zoomOutLoa="day"),document.getElementById("navBrowseZoomOutLink").title=zoomOutLoa.charAt(0).toUpperCase()+zoomOutLoa.slice(1),log.logInfo("updateZoomOutTitle zoomOutLoa "+zoomOutLoa)):(log.logInfo("updateZoomOutTitle disableZoomOut "+e),oe())}function H(e,o,t){log.logInfo("checkReportAgainstDevices selectedDevices "+JSON.stringify(e)),log.logInfo("checkReportAgainstDevices allDevices "+JSON.stringify(o)),log.logInfo("checkReportAgainstDevices reportKey "+t);var n={match:!1,suggestedReportKey:null,suggestedDevice:null};return F(e,t)?n.match=!0:(n.suggestedReportKey=function(e){var o=null,t=Object.keys(M);for(var n in t){var y=t[n],r=M[y];if("deviceList"in r)for(var a in r.deviceList){var d=r.deviceList[a];for(var l in e){var i=e[l],s=!0,c=Object.keys(d);for(var g in c){var f=c[g];if((!d[f]||null==d[f])&&i[f]&&null!=i[f]){s=!1;break}if(i[f]&&i[f]!=d[f]){s=!1;break}}if(s){o=y;break}}}}return o}(e),n.suggestedDevice=Y(o,t)),log.logInfo("checkReportAgainstDevices result "+JSON.stringify(n)),n}function F(e,o){return null!=Y(e,o)}function Y(e,o){log.logInfo("getDefaultDevice deviceList "+JSON.stringify(e)),log.logInfo("getDefaultDevice reportKey "+o);var t=null,n=[];for(var y in o in M&&"deviceList"in M[o]&&(n=M[o].deviceList),e){var r=e[y];for(var a in n){var d=n[a],l=!0,i=Object.keys(d);for(var s in i){var c=i[s];if((!d[c]||null==d[c])&&r[c]&&null!=r[c]){l=!1;break}if(r[c]&&r[c]!=d[c]){l=!1;break}}if(l){t=r;break}}}return t}function G(e){if(log.logInfo("Time To Format "+e),isNaN(e))return"N/A";var o={"ar-SA":"dd/MM/yy","bg-BG":"dd.M.yyyy","ca-ES":"dd/MM/yyyy","zh-TW":"yyyy/M/d","cs-CZ":"d.M.yyyy","da-DK":"dd-MM-yyyy","de-DE":"dd.MM.yyyy","el-GR":"d/M/yyyy","en-US":"M/d/yyyy","fi-FI":"d.M.yyyy","fr-FR":"dd/MM/yyyy","he-IL":"dd/MM/yyyy","hu-HU":"yyyy. MM. dd.","is-IS":"d.M.yyyy","it-IT":"dd/MM/yyyy","ja-JP":"yyyy/MM/dd","ko-KR":"yyyy-MM-dd","nl-NL":"d-M-yyyy","nb-NO":"dd.MM.yyyy","pl-PL":"yyyy-MM-dd","pt-BR":"d/M/yyyy","ro-RO":"dd.MM.yyyy","ru-RU":"dd.MM.yyyy","hr-HR":"d.M.yyyy","sk-SK":"d. M. yyyy","sq-AL":"yyyy-MM-dd","sv-SE":"yyyy-MM-dd","th-TH":"d/M/yyyy","tr-TR":"dd.MM.yyyy","ur-PK":"dd/MM/yyyy","id-ID":"dd/MM/yyyy","uk-UA":"dd.MM.yyyy","be-BY":"dd.MM.yyyy","sl-SI":"d.M.yyyy","et-EE":"d.MM.yyyy","lv-LV":"yyyy.MM.dd.","lt-LT":"yyyy.MM.dd","fa-IR":"MM/dd/yyyy","vi-VN":"dd/MM/yyyy","hy-AM":"dd.MM.yyyy","az-Latn-AZ":"dd.MM.yyyy","eu-ES":"yyyy/MM/dd","mk-MK":"dd.MM.yyyy","af-ZA":"yyyy/MM/dd","ka-GE":"dd.MM.yyyy","fo-FO":"dd-MM-yyyy","hi-IN":"dd-MM-yyyy","ms-MY":"dd/MM/yyyy","kk-KZ":"dd.MM.yyyy","ky-KG":"dd.MM.yy","sw-KE":"M/d/yyyy","uz-Latn-UZ":"dd/MM yyyy","tt-RU":"dd.MM.yyyy","pa-IN":"dd-MM-yy","gu-IN":"dd-MM-yy","ta-IN":"dd-MM-yyyy","te-IN":"dd-MM-yy","kn-IN":"dd-MM-yy","mr-IN":"dd-MM-yyyy","sa-IN":"dd-MM-yyyy","mn-MN":"yy.MM.dd","gl-ES":"dd/MM/yy","kok-IN":"dd-MM-yyyy","syr-SY":"dd/MM/yyyy","dv-MV":"dd/MM/yy","ar-IQ":"dd/MM/yyyy","zh-CN":"yyyy/M/d","de-CH":"dd.MM.yyyy","en-GB":"dd/MM/yyyy","es-MX":"dd/MM/yyyy","fr-BE":"d/MM/yyyy","it-CH":"dd.MM.yyyy","nl-BE":"d/MM/yyyy","nn-NO":"dd.MM.yyyy","pt-PT":"dd-MM-yyyy","sr-Latn-CS":"d.M.yyyy","sv-FI":"d.M.yyyy","az-Cyrl-AZ":"dd.MM.yyyy","ms-BN":"dd/MM/yyyy","uz-Cyrl-UZ":"dd.MM.yyyy","ar-EG":"dd/MM/yyyy","zh-HK":"d/M/yyyy","de-AT":"dd.MM.yyyy","en-AU":"d/MM/yyyy","es-ES":"dd/MM/yyyy","fr-CA":"yyyy-MM-dd","sr-Cyrl-CS":"d.M.yyyy","ar-LY":"dd/MM/yyyy","zh-SG":"d/M/yyyy","de-LU":"dd.MM.yyyy","en-CA":"dd/MM/yyyy","es-GT":"dd/MM/yyyy","fr-CH":"dd.MM.yyyy","ar-DZ":"dd-MM-yyyy","zh-MO":"d/M/yyyy","de-LI":"dd.MM.yyyy","en-NZ":"d/MM/yyyy","es-CR":"dd/MM/yyyy","fr-LU":"dd/MM/yyyy","ar-MA":"dd-MM-yyyy","en-IE":"dd/MM/yyyy","es-PA":"MM/dd/yyyy","fr-MC":"dd/MM/yyyy","ar-TN":"dd-MM-yyyy","en-ZA":"yyyy/MM/dd","es-DO":"dd/MM/yyyy","ar-OM":"dd/MM/yyyy","en-JM":"dd/MM/yyyy","es-VE":"dd/MM/yyyy","ar-YE":"dd/MM/yyyy","en-029":"MM/dd/yyyy","es-CO":"dd/MM/yyyy","ar-SY":"dd/MM/yyyy","en-BZ":"dd/MM/yyyy","es-PE":"dd/MM/yyyy","ar-JO":"dd/MM/yyyy","en-TT":"dd/MM/yyyy","es-AR":"dd/MM/yyyy","ar-LB":"dd/MM/yyyy","en-ZW":"M/d/yyyy","es-EC":"dd/MM/yyyy","ar-KW":"dd/MM/yyyy","en-PH":"M/d/yyyy","es-CL":"dd-MM-yyyy","ar-AE":"dd/MM/yyyy","es-UY":"dd/MM/yyyy","ar-BH":"dd/MM/yyyy","es-PY":"dd/MM/yyyy","ar-QA":"dd/MM/yyyy","es-BO":"dd/MM/yyyy","es-SV":"dd/MM/yyyy","es-HN":"dd/MM/yyyy","es-NI":"dd/MM/yyyy","es-PR":"dd/MM/yyyy","am-ET":"d/M/yyyy","tzm-Latn-DZ":"dd-MM-yyyy","iu-Latn-CA":"d/MM/yyyy","sma-NO":"dd.MM.yyyy","mn-Mong-CN":"yyyy/M/d","gd-GB":"dd/MM/yyyy","en-MY":"d/M/yyyy","prs-AF":"dd/MM/yy","bn-BD":"dd-MM-yy","wo-SN":"dd/MM/yyyy","rw-RW":"M/d/yyyy","qut-GT":"dd/MM/yyyy","sah-RU":"MM.dd.yyyy","gsw-FR":"dd/MM/yyyy","co-FR":"dd/MM/yyyy","oc-FR":"dd/MM/yyyy","mi-NZ":"dd/MM/yyyy","ga-IE":"dd/MM/yyyy","se-SE":"yyyy-MM-dd","br-FR":"dd/MM/yyyy","smn-FI":"d.M.yyyy","moh-CA":"M/d/yyyy","arn-CL":"dd-MM-yyyy","ii-CN":"yyyy/M/d","dsb-DE":"d. M. yyyy","ig-NG":"d/M/yyyy","kl-GL":"dd-MM-yyyy","lb-LU":"dd/MM/yyyy","ba-RU":"dd.MM.yy","nso-ZA":"yyyy/MM/dd","quz-BO":"dd/MM/yyyy","yo-NG":"d/M/yyyy","ha-Latn-NG":"d/M/yyyy","fil-PH":"M/d/yyyy","ps-AF":"dd/MM/yy","fy-NL":"d-M-yyyy","ne-NP":"M/d/yyyy","se-NO":"dd.MM.yyyy","iu-Cans-CA":"d/M/yyyy","sr-Latn-RS":"d.M.yyyy","si-LK":"yyyy-MM-dd","sr-Cyrl-RS":"d.M.yyyy","lo-LA":"dd/MM/yyyy","km-KH":"yyyy-MM-dd","cy-GB":"dd/MM/yyyy","bo-CN":"yyyy/M/d","sms-FI":"d.M.yyyy","as-IN":"dd-MM-yyyy","ml-IN":"dd-MM-yy","en-IN":"dd-MM-yyyy","or-IN":"dd-MM-yy","bn-IN":"dd-MM-yy","tk-TM":"dd.MM.yy","bs-Latn-BA":"d.M.yyyy","mt-MT":"dd/MM/yyyy","sr-Cyrl-ME":"d.M.yyyy","se-FI":"d.M.yyyy","zu-ZA":"yyyy/MM/dd","xh-ZA":"yyyy/MM/dd","tn-ZA":"yyyy/MM/dd","hsb-DE":"d. M. yyyy","bs-Cyrl-BA":"d.M.yyyy","tg-Cyrl-TJ":"dd.MM.yy","sr-Latn-BA":"d.M.yyyy","smj-NO":"dd.MM.yyyy","rm-CH":"dd/MM/yyyy","smj-SE":"yyyy-MM-dd","quz-EC":"dd/MM/yyyy","quz-PE":"dd/MM/yyyy","hr-BA":"d.M.yyyy.","sr-Latn-ME":"d.M.yyyy","sma-SE":"yyyy-MM-dd","en-SG":"d/M/yyyy","ug-CN":"yyyy-M-d","sr-Cyrl-BA":"d.M.yyyy","es-US":"M/d/yyyy"},t="";"fr"in o?t=o.fr:t=o[Object.keys(o).find(function(e){return e.includes("fr")})];""==t&&(t="dd/MM/yyyy"),t=(t=t.split("d").join("D")).replace("yyyy","YYYY");var n=Intl.DateTimeFormat("fr",{hour:"numeric"}).resolvedOptions().hourCycle;return console.log("Hour cycle "+n),"h11"==n||"h12"==n?t+=" hh:mm A":"h23"!=n&&"h24"!=n||(t+=" HH:mm"),console.log("Timeline Report Format "+t),log.logInfo(e.format(t)),e.format(t)}function j(e){log.logInfo("setSelectedStartDate "+e),s("#preCannedDateRange").data("daterangepicker")&&s("#preCannedDateRange").data("daterangepicker").setStartDate(e)}function W(e,o){if(log.logInfo("getReportWithUserInputs Selected Date "+o+" loa "+e),L(),log.logInfo("getReportWithUserInputs "+f+" "+g+" "+u),f&&g&&u){log.logInfo("LOA "+e);var t=ye(e,o),n=re(e,o);log.logInfo("Moment - Start: "+t),log.logInfo("Moment - End: "+n),t=t.utc(),n=n.utc();O();ae(e,t)}else log.logInfo("getReportWithUserInputs not ready")}function q(e,o,t){var n=JSON.parse(e);log.logInfo("Teams length "+n.length),log.logInfo("Teams "+JSON.stringify(n)),0==n.length&&s("#filterTypeSwitch").hide(),function(e,t){log.logInfo("getDevicesForTeams"),log.logInfo("getDevicesForTeams teams "+JSON.stringify(e));var n=[],y={},o=[];for(var r in e)o.push(V("/locator",{team:e[r].name},"GET","application/json","text")),n.push(e[r].name);Promise.all(o).then(function(e){log.logInfo("getDevicesForTeams data is "+JSON.stringify(e));for(var o=0;o