PageSourceSearch

https://www.nri.com/cn/Scripts/top.js?d=202007

js nri.com collected 2026-10-01 08:39:08 UTC 2,536 bytes, 71 lines download raw bytes

1$(document).ready(function () {
2    var defaultExpires = 10;
3
4    redirectUser();
5
6    //redirect user to prev access language if exist, otherwise redirect user to browser language
7    function redirectUser() {
8        var domain = window.location.protocol + '//' + window.location.hostname + '/';
9        if (window.location.pathname === "/") {
10            var language = detectLanguage();
11            var newUrl = domain;
12            newUrl += language;
13            window.location.replace(newUrl);
14        }
15        else {
16            var contextLanguage = $("#context-language").val();
17            setCookieLang(contextLanguage.substring(0, 2), defaultExpires);
18        }
19    }
20
21    //get language from prev access if exist in cookie, otherwise get browser language
22    function detectLanguage() {
23        var cookie = getCookieLang();
24        return !cookie ? getBrowserLanguage() : cookie;
25    }
26
27    //get browser language
28    function getBrowserLanguage() {
29        var lang = navigator.language || navigator.userLanguage;
30        return getLanguageCode(lang);
31    }
32
33    //get language code
34    function getLanguageCode(language) {
35        return language == "ja" || language == "ja-JP" ? "jp" : language == "zh" || language.toLowerCase() == "zh-cn" ? "cn" : "en";
36    }
37
38    // set language to cookie
39    function setCookieLang(newLanguage, days) {
40        if (!days) {
41            var expires = '';
42        } else {
43            var expires = new Date();
44            expires.setDate(expires.getDate() + days);
45            expires = '; expires=' + expires.toUTCString();
46        }
47        document.cookie = 'languageDetection=' + getLanguageCode(newLanguage) + expires + '; path=/';
48    }
49
50    //get language from cookie
51    function getCookieLang() {
52        var siteCookie = document.cookie;
53        var cookieLang = siteCookie.indexOf(' languageDetection=');
54        if (cookieLang == -1) {
55            cookieLang = siteCookie.indexOf('languageDetection=');
56        }
57        if (cookieLang == -1) {
58            var cookieLangValue = null;
59        } else {
60            var cookieLangStart = siteCookie.indexOf('=', cookieLang) + 1;
61            var cookieLangEnd = siteCookie.indexOf(';', cookieLang);
62            if (cookieLangEnd == -1) {
63                cookieLangEnd = siteCookie.length;
64            }
65            cookieLangValue = unescape(siteCookie.substring(cookieLangStart, cookieLangEnd));
66        }
67        return cookieLangValue;
68    }
69
70});
71

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.