/** Description: Login JS June 2014, 2017 Copyright (c) 2014, 2017-2022 by Cisco Systems, Inc. All rights reserved. */ (function() { var idleTimeOutMessage = undefined; var i18nTranslations = null; var localVal = "en"; var loginPageTranslationProperties={ "en":{ "common_logo": "logo", "common_username": "Username", "common_password": "Password", "login_help_with_login": "Help with Login", "login_copyright_msg": "Cisco Systems, Inc. All rights reserved. Cisco, the Cisco logo, and Cisco Systems are registered trademarks or trademarks of Cisco Systems, Inc. and/or its affiliates in the United States and certain other countries. All third party trademarks are the property of their respective owners.", "login_empty_username_or_password": "Empty Username and/or Password not allowed.", "login_username_should_not_contain_colon": "Username should not contain ':' character", "logout_logged_out_sucessfully": "Logged out successfully.", "login_wrong_credentials": "Wrong Credentials. Please Login again.", "sufficient_privilege": "The User ID does not have sufficient privilege to login. Contact your administrator or use a different User ID.", "login_PIV_error": "'Personal Identity Verification' is enabled. Invalid certificate received.", "login_login": "Log In", "login_preferred_lang": "Language", "login_login_now": "LOGIN NOW", "login_show_more": "Show more", "login_show_less": "Show less", "login_capslock": "Caps Lock is on", "login_bestview": "Best viewed with", "login_edge" : "Edge", "login_firefox" : "Firefox", "login_safari" : "Safari", "login_chrome" : "Chrome", "user_manual": "User Manual", "mewlc_idle_timeout_msg":"The default device credentials have expired due to inactivity. Please reboot the device to reset the credentials.", "ewc_internal_ap_conversion_msg":"Day-0 provisioning for mesh AP is in progress. Please retry login after sometime." }, "ja":{ "common_logo": "\u30ed\u30b4", "common_username": "\u30e6\u30fc\u30b6\u540d", "common_password": "\u30d1\u30b9\u30ef\u30fc\u30c9", "login_help_with_login": "\u30ed\u30b0\u30a4\u30f3\u306e\u30d8\u30eb\u30d7", "login_copyright_msg": "Cisco Systems, Inc. All rights reserved.Cisco\u3001Cisco\u30ed\u30b4\u3001\u304a\u3088\u3073Cisco Systems\u306f\u3001Cisco Systems, Inc.\u307e\u305f\u306f\u305d\u306e\u95a2\u9023\u4f1a\u793e\u306e\u7c73\u56fd\u304a\u3088\u3073\u305d\u306e\u4ed6\u306e\u4e00\u5b9a\u306e\u56fd\u306b\u304a\u3051\u308b\u767b\u9332\u5546\u6a19\u307e\u305f\u306f\u5546\u6a19\u3067\u3059\u3002\u7b2c\u4e09\u8005\u306e\u5546\u6a19\u306f\u3059\u3079\u3066\u3001\u305d\u308c\u305e\u308c\u306e\u6240\u6709\u8005\u306e\u8ca1\u7523\u3067\u3059\u3002", "login_empty_username_or_password": "\u30e6\u30fc\u30b6\u540d\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u7a7a\u306b\u3067\u304d\u307e\u305b\u3093\u3002", "login_username_should_not_contain_colon": "\u30e6\u30fc\u30b6\u540d\u306b\u300c:\u300d\u6587\u5b57\u3092\u542b\u3081\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093", "logout_logged_out_sucessfully": "\u6b63\u5e38\u306b\u30ed\u30b0\u30a2\u30a6\u30c8\u3057\u307e\u3057\u305f\u3002", "login_wrong_credentials": "\u8aa4\u3063\u305f\u30af\u30ec\u30c7\u30f3\u30b7\u30e3\u30eb\u3067\u3059\u3002\u518d\u5ea6\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u304f\u3060\u3055\u3044\u3002", "sufficient_privilege": "The User ID does not have sufficient privilege to login. Contact your administrator or use a different User ID.", "login_PIV_error": "'\u500b\u4ebaID\u306e\u691c\u8a3c' \u306f\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u7121\u52b9\u306a\u8a3c\u660e\u66f8\u3092\u53d7\u4fe1\u3057\u307e\u3057\u305f\u3002", "login_login": "Log In", "login_preferred_lang": "\u8a00\u8a9e", "login_login_now": "\u4eca\u3059\u3050\u30ed\u30b0\u30a4\u30f3", "login_show_more": "\u8a73\u7d30\u3092\u8868\u793a", "login_show_less": "\u7c21\u6613\u8868\u793a", "login_capslock": "Caps Lock is on", "login_bestview": "Best viewed with", "login_edge" : "Edge", "login_firefox" : "Firefox", "login_safari" : "Safari", "login_chrome" : "Chrome", "user_manual": "User Manual", "mewlc_idle_timeout_msg":"The default device credentials have expired due to inactivity. Please reboot the device to reset the credentials.", "ewc_internal_ap_conversion_msg":"Day-0 provisioning for mesh AP is in progress. Please retry login after sometime." } }; function getLocalizedValue(key, defaultValue) { var i18nValue = i18nTranslations[key]; if (i18nValue !== undefined && i18nValue !== null && i18nValue !== "" && i18nValue !== key) { return i18nValue; } else { return (defaultValue || key); } } var supportedLocaleMap = { 'en-US' : 'en', 'en' : 'en', 'ja_JP' : 'ja', 'ja' : 'ja' }; window.onload = function() { var langElements = document.getElementsByClassName("langLinkCSS"); var languageOptions = function() { if(this.getAttribute("class").indexOf("isSelected")==-1){ window.localStorage.preferredLanguage = this.getAttribute("lang"); localVal = this.getAttribute("lang"); document.getElementById("authmsg").innerHTML = ""; loadLocalizedBundle(); for (var i = 0; i < langElements.length; i++) { langElements[i].classList.remove("isSelected"); } this.className += ' isSelected'; } }; var pre = document.getElementsByTagName("pre"); var title_h1=document.getElementById("bannerHead"); var show_banner_elem=document.getElementById("show_banner_text"); var clickShow = function() { var content = pre[0]; if(show_banner_elem.getAttribute("class").indexOf("More")>-1){ show_banner_elem.innerHTML = getLocalizedValue("login_show_less", "Show less"); content.style.maxHeight="none"; show_banner_elem.classList.remove("More"); show_banner_elem.className="Less"; title_h1.style.maxHeight="none"; } else { show_banner_elem.innerHTML = getLocalizedValue("login_show_more", "Show more"); content.style.maxHeight="100px"; show_banner_elem.classList.remove("Less"); show_banner_elem.className="More"; title_h1.style.maxHeight="120px"; } }; show_banner_elem.addEventListener('click', clickShow, false); var focusCall = function() { if(show_banner_elem.getAttribute("class").indexOf("More")==-1){ clickShow(); } }; document.getElementById("username").addEventListener('focus', focusCall, false); document.getElementById("username").focus(); if(document.forms['loginform']['Username'].value !=""){ document.getElementById("username_placeholder").className="username-input-class"; } document.getElementById("password").addEventListener( 'keydown', function( event ) { var caps = event.getModifierState && event.getModifierState( 'CapsLock' ); if ( caps){ document.getElementById("capslockmsg").innerHTML = getLocalizedValue("login_capslock", "Caps Lock is on"); }else{ document.getElementById("capslockmsg").innerHTML = ""; } }); // The below events need to remove when our system starts supporting other than English. var blurCall = function(){ var rgx = /[^\x00-\x7F]+/; if (rgx.test(this.value)) { this.value = ""; alert(getLocalizedValue("allowed_chars_message","Input allowed in English only (ASCII characters)")); } }; document.getElementById("username").addEventListener('blur', blurCall, false); document.getElementById("password").addEventListener('blur', blurCall, false); var itr; if (navigator.languages && navigator.languages.length) { for ( itr = 0; itr < navigator.languages.length; itr++) { localVal = supportedLocaleMap[navigator.languages[itr]] || 'en'; if (localVal) { break; } } } else { localVal = supportedLocaleMap[navigator.browserLanguage || navigator.language]|| 'en'; } if (window.localStorage.preferredLanguage !== undefined && supportedLocaleMap[window.localStorage.preferredLanguage] !== undefined) { localVal = window.localStorage.preferredLanguage; } for (var i = 0; i < langElements.length; i++) { langElements[i].addEventListener('click', languageOptions, false); if(langElements[i].getAttribute("lang")==localVal){ langElements[i].className += ' isSelected'; } } function loadLocalizedBundle() { i18nTranslations=loginPageTranslationProperties[localVal]; document.getElementById("username_placeholder").innerHTML=getLocalizedValue("common_username", "Username"); document.getElementById("password_placeholder").innerHTML=getLocalizedValue("common_password", "Password"); document.getElementById("companylogo").setAttribute("alt", getLocalizedValue("common_logo", "logo")); document.getElementById("copyrightmsg").style.visibility= loginProp.showCopyright ? "visible" : "hidden"; var copyrightMessage = getLocalizedValue("login_copyright_msg", "Copyright Message"); document.getElementById("copyrightmsg2").innerHTML = loginProp.showCopyright ? copyrightMessage : ""; document.getElementById("login").setAttribute("value", getLocalizedValue("login_login", "Log In")); document.getElementById("plang").innerHTML = getLocalizedValue("login_preferred_lang", "Language")+":"; document.getElementById("companylogo").innerHTML = getLocalizedValue("common_logo", "logo"); document.getElementById("supportedBrowserInfo").style.display= loginProp.showCopyright ? "none" : "block"; /* Displaying supported browser info alone in RA devices */ let i = loginProp.showCopyright ? 0 : 1; document.getElementsByClassName("bestview_placeholder")[i].innerHTML = "" + getLocalizedValue("login_bestview", "Best viewed with") + ""; document.getElementsByClassName("edge_placeholder")[i].innerHTML = getLocalizedValue("login_edge", "Edge"); document.getElementsByClassName("firefox_placeholder")[i].innerHTML = getLocalizedValue("login_firefox", "Firefox"); document.getElementsByClassName("safari_placeholder")[i].innerHTML = getLocalizedValue("login_safari", "Safari"); document.getElementsByClassName("chrome_placeholder")[i].innerHTML = getLocalizedValue("login_chrome", "Chrome"); document.getElementsByClassName("rausermanual")[0].innerHTML = "" + getLocalizedValue("user_manual","User Manual") + ""; document.getElementsByClassName("rausermanual")[0].style.visibility= loginProp.showUserManual ? "visible" : "hidden"; document.getElementById("loginTitle").innerHTML = loginProp.vendor + " " + getLocalizedValue("troubleshooting_webui", "Webui") +" - " + getLocalizedValue("login_login", "Login"); var authBanner = document.getElementById("authmsg").innerHTML; if (authBanner.indexOf("Logged out") != -1) { document.getElementById("authmsg").innerHTML = "" + getLocalizedValue("logout_logged_out_sucessfully", "Logged out successfully.") + ""; } if (authBanner.indexOf("Access denied") != -1 || idleTimeOutMessage !== undefined) { document.getElementById("authmsg").innerHTML = "" + getLocalizedValue("mewlc_idle_timeout_msg","The default device credentials have expired due to inactivity. Please reboot the device to reset the credentials.") + ""; idleTimeOutMessage = 'The default device credentials have expired due to inactivity. Please reboot the device to reset the credentials.' } if (authBanner.indexOf("Wrong Credentials") != -1) { document.getElementById("authmsg").innerHTML = "" +getLocalizedValue("login_wrong_credentials", "Wrong Credentials. Please Login again.") + ""; } if (authBanner.indexOf("sufficient privilege") != -1) { document.getElementById("authmsg").innerHTML = "" + getLocalizedValue("sufficient_privilege", "The User ID does not have sufficient privilege to login. Contact your administrator or use a different User ID.") +""; } if (authBanner.indexOf("Day-0") != -1) { console.log("EWC: This scenario is applicable after Day-0 provisioning is completed. Login is disabled until Mesh AP conversion is completed."); document.getElementById("authmsg").innerHTML = "" +getLocalizedValue("ewc_internal_ap_conversion_msg", "Day-0 provisioning for mesh AP is in progress. Please retry login after sometime.") + ""; } if (pre.length > 0 && (pre[0].scrollHeight > pre[0].offsetHeight)){ show_banner_elem.style.display="inline-block"; title_h1.style.maxHeight="120px"; show_banner_elem.innerHTML=getLocalizedValue("login_show_more", "Show more"); }else{ show_banner_elem.style.display="none"; title_h1.style.maxHeight="none"; } if (bannerHead.getElementsByTagName('pre').length > 0) { var bannerContent = bannerHead.getElementsByTagName('pre')[0].innerHTML; var bannerValue = bannerContent.replace(/\n|\r/g, ""); if (bannerValue == "") { title_h1.style.display = "none"; } } } loadLocalizedBundle(); document.getElementById("loginPageSpinner").remove(); } if (window.location.href.indexOf("webui/") === -1) { window.location.href = "webui/"; } document.getElementById("myloginform").onsubmit = function() { return loadXMLDoc() }; function loadXMLDoc() { if (document.getElementById("username").value == "" || document.getElementById("password") == "") { document.getElementById("authmsg").innerHTML = "" +getLocalizedValue("login_empty_username_or_password", "Empty Username and/or Password not allowed.")+""; return false; } if (document.getElementById("username").value.indexOf(":") != -1) { document.getElementById("authmsg").innerHTML = "" +getLocalizedValue("login_username_should_not_contain_colon", "Username should not contain ':' character") +""; return false; } var xmlhttp; var usrname; var passwd; var base64enc; // code for IE7+, Firefox, Chrome, Opera, Safari if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4){ if(xmlhttp.status == 200){ if (xmlhttp.responseText.indexOf("Wrong") === -1) { document.write(xmlhttp.responseText); document.close(); location.pathname = "/webui/"; return; } if (location.protocol.indexOf("https") >= 0 && (navigator.appVersion.indexOf("Trident") > 0 || navigator.appName.indexOf("Internet Explorer") > 0)) { location.href = "unauthpage.html"; return; } else { document.write(xmlhttp.responseText); document.close(); } } else { document.write(xmlhttp.responseText); document.close(); } } } usrname = document.getElementById("username").value; passwd = document.getElementById("password").value; base64enc = "Basic " + btoa(usrname + ":" + passwd); xmlhttp.open("GET", "/webui/index.html", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Authorization", base64enc); xmlhttp.send(); return false; } })();