{"version":3,"sources":["Feature.LangBar.js"],"names":["getCookie","name","cookieArr","document","cookie","split","i","length","cookiePair","trim","decodeURIComponent","setCookie","value","days","expires","date","Date","setTime","getTime","toUTCString","DoContinue","getElementById","window","location","href","DoClose","style","display","DoLanguageAlert","geoCountryCode","geoCountryLanguages","geoCountryNames","clientHeader","clientIP","defaultLanguage","chinaLanguage","hostname","toLowerCase","parser","createElement","pageLanguage","pathname","test","targetHostname","endsWith","replace","geoCountryLanguage","geoCountryName","undefined","console","log","showLangAlert","targetOption","options","text","DoLanguageBarInit","jQuery","ajax","url","headers","cf-connecting-ip","success","response","keyValue","lines","shouldSkip","forEach","line","countryCode","error"],"mappings":"AAAA,SAASA,UAAUC,GAKf,IAHA,IAAIC,EAAYC,SAASC,OAAOC,MAAM,KAG7BC,EAAI,EAAGA,EAAIJ,EAAUK,OAAQD,IAAK,CACvC,IAAIE,EAAaN,EAAUI,GAAGD,MAAM,KAIpC,GAAIJ,GAAQO,EAAW,GAAGC,OAEtB,OAAOC,mBAAmBF,EAAW,IAK7C,OAAO,KAGX,SAASG,UAAUV,EAAMW,EAAOC,GAC5B,IAAIC,EAAU,GACd,GAAID,EAAM,CACN,IAAIE,EAAO,IAAIC,KACfD,EAAKE,QAAQF,EAAKG,UAAoB,GAAPL,EAAY,GAAK,GAAK,KACrDC,EAAU,aAAeC,EAAKI,cAElChB,SAASC,OAASH,EAAO,KAAOW,GAAS,IAAME,EAAU,WAG7D,SAASM,aACL,IACIR,EADIT,SAASkB,eAAe,qBAClBT,MACdD,UAAU,kBAAmB,OAAQ,GACrCW,OAAOC,SAASC,KAAOZ,EAE3B,SAASa,UACGtB,SAASkB,eAAe,cAC9BK,MAAMC,QAAU,OAClBhB,UAAU,kBAAmB,OAAQ,GAEzC,SAASiB,gBAAgBC,EAAgBC,EAAqBC,EAAiBC,EAAcC,GACzF,IAAIC,EAAkB,QAClBC,EAAgB,QAEhBC,EAAWd,OAAOC,SAASa,SAASC,cACpCC,EAASnC,SAASoC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C,EAAiBC,EAAcC,IAErFoC,MAAO,WACHD,YAAc,KACdxC,gBAAgBwC,YAAatC,EAAqBC,EAAiBC,EAAcC","file":"Feature.LangBar.min.js","sourcesContent":["function getCookie(name) {\n // Split cookie string and get all individual name=value pairs in an array\n var cookieArr = document.cookie.split(\";\");\n\n // Loop through the array elements\n for (var i = 0; i < cookieArr.length; i++) {\n var cookiePair = cookieArr[i].split(\"=\");\n\n /* Removing whitespace at the beginning of the cookie name\n and compare it with the given string */\n if (name == cookiePair[0].trim()) {\n // Decode the cookie value and return\n return decodeURIComponent(cookiePair[1]);\n }\n }\n\n // Return null if not found\n return null;\n}\n\nfunction setCookie(name, value, days) {\n var expires = \"\";\n if (days) {\n var date = new Date();\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));\n expires = \"; expires=\" + date.toUTCString();\n }\n document.cookie = name + \"=\" + (value || \"\") + expires + \"; path=/\";\n}\n\nfunction DoContinue() {\n var e = document.getElementById(\"lang-alert-select\");\n var value = e.value;\n setCookie('langalertClosed', 'true', 1);\n window.location.href = value;\n}\nfunction DoClose() {\n var x = document.getElementById(\"lang-alert\");\n x.style.display = \"none\";\n setCookie('langalertClosed', 'true', 1);\n}\nfunction DoLanguageAlert(geoCountryCode, geoCountryLanguages, geoCountryNames, clientHeader, clientIP) {\n var defaultLanguage = \"en-us\";\n var chinaLanguage = \"zh-cn\";\n var defaultCountry = \"United States\";\n var hostname = window.location.hostname.toLowerCase();\n var parser = document.createElement('a');\n parser.href = window.location.href;\n var currPath = parser.pathname;\n var url = currPath.split('/');\n var pageLanguage = url[1].toLowerCase();\n if (pageLanguage == '') {\n pageLanguage = defaultLanguage;\n }\n if (!/^[a-z]{2}\\-[a-z]{2}/.test(pageLanguage)) {\n pageLanguage = defaultLanguage;\n }\n var targetHostname = \"\";\n if (hostname.endsWith(\".cn\")) {\n targetHostname = '/' + '/' + hostname.replace(\".cn\", \"\");\n pageLanguage = chinaLanguage;\n}\n var geoCountryLanguage = geoCountryLanguages[geoCountryCode];\n var geoCountryName = geoCountryNames[geoCountryCode];\n if (geoCountryLanguage === undefined) {\n geoCountryLanguage = defaultLanguage;\n }\n if (geoCountryName === undefined) {\n geoCountryName = defaultCountry;\n }\n console.log(\"lang: \" + pageLanguage);\n console.log(\"geoCountryLanguage: \" + geoCountryLanguage);\n console.log(\"geoCountryName: \" + geoCountryName);\n console.log(\"geoCountryCode: \" + geoCountryCode);\n var showLangAlert = false;\n if (geoCountryLanguage != pageLanguage) {\n showLangAlert = true;\n }\n if (geoCountryLanguage == chinaLanguage) {\n targetHostname = '/' + '/' + hostname + \".cn\";\n geoCountryLanguage = \"\";\n }\n targetHostname = targetHostname.replace(\".cn.cn\", \".cn\");\n console.log(\"targetHostname: \" + targetHostname);\n var targetOption = document.getElementById('lang-alert-select').options[0];\n targetOption.value = targetHostname + '/' + geoCountryLanguage;\n targetOption.text = geoCountryName;\n if (showLangAlert) {\n var x = document.getElementById(\"lang-alert\");\n x.style.display = \"block\";\n }\n}\nfunction DoLanguageBarInit(geoCountryLanguages, geoCountryNames, clientHeader, clientIP) {\n var langCookie = getCookie('langalertClosed');\n if (langCookie == null) {\n jQuery.ajax({\n url: \"/cdn-cgi/trace\",\n headers: { 'cf-connecting-ip': clientIP },\n success: function (response) {\n var lines = response.split(\"\\n\");\n var shouldSkip = false;\n var keyValue;\n lines.forEach(function (line) {\n if (shouldSkip) {\n return;\n }\n keyValue = line.split(\"=\");\n if (keyValue[0] == \"loc\") {\n shouldSkip = true;\n }\n });\n countryCode = decodeURIComponent(keyValue[1] || \"\").toLowerCase();\n DoLanguageAlert(countryCode, geoCountryLanguages, geoCountryNames, clientHeader, clientIP);\n },\n error: function () {\n countryCode = \"us\";\n DoLanguageAlert(countryCode, geoCountryLanguages, geoCountryNames, clientHeader, clientIP);\n }\n });\n }\n}"]}