PageSourceSearch

https://www.kuipgroup.com/wp-content/themes/dt-the7/js/language-redirect.js?ver=1.0

js kuipgroup.com collected 2026-10-10 01:37:13 UTC 2,985 bytes, 69 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function() {
2    // 获取指定名称的 cookie
3    function getCookie(name) {
4        let cookieArr = document.cookie.split(";");
5        for (let i = 0; i < cookieArr.length; i++) {
6            let cookiePair = cookieArr[i].split("=");
7            if (name == cookiePair[0].trim()) {
8                return decodeURIComponent(cookiePair[1]);
9            }
10        }
11        return null;
12    }
13    
14    // 如果没有 lang_set cookie,进行语言重定向
15    //并且 url中不包含 manualLanguage , 如果包含了,说明是用户手动选择的
16    if (!getCookie('lang_set') && window.location.href.indexOf('manualLanguage')==-1) {
17        console.log("should not exec when manual click switch")
18        let lang = navigator.language || navigator.userLanguage;
19        lang = lang.substring(0, 2);
20
21        if (lang === 'zh' && siteData.currentHost === 'www.kuipgroup.com') {
22            document.cookie = "lang_set=true; path=/; max-age=" + (60 * 60 * 24 * 30); // 30天有效期
23            window.location.href = 'https://zh.kuipgroup.com' + siteData.currentPath;
24        } else if (lang !== 'zh' && siteData.currentHost === 'zh.kuipgroup.com') {
25            document.cookie = "lang_set=true; path=/; max-age=" + (60 * 60 * 24 * 30); // 30天有效期
26            window.location.href = 'https://www.kuipgroup.com' + siteData.currentPath;
27        }
28    }
29    
30    //同步到 cookie 中
31    if(window.location.href.indexOf('manualLanguage')>-1){
32        console.log("manual click language")
33        if (siteData.currentHost === 'www.kuipgroup.com') {
34            document.cookie = "lang_set=true; path=/; max-age=" + (60 * 60 * 24 * 30); // 30天有效期
35        } else if (siteData.currentHost === 'zh.kuipgroup.com') {
36            document.cookie = "lang_set=true; path=/; max-age=" + (60 * 60 * 24 * 30); // 30天有效期
37        }
38    }
39
40    // 处理语言切换按钮
41    const langOptions = document.querySelectorAll('.lang-option');
42    langOptions.forEach(option => {
43        option.addEventListener('click', function (event) {
44            event.preventDefault();
45            const selectedLang = this.getAttribute('data-lang');
46            let targetUrl = '';
47
48            if (selectedLang === 'zh') {
49                targetUrl = 'https://zh.kuipgroup.com' + siteData.currentPath;
50            } else if (selectedLang === 'en') {
51                targetUrl = 'https://www.kuipgroup.com' + siteData.currentPath;
52            }
53
54console.log("targetUrl",targetUrl)
55            
56            targetUrl = targetUrl + "?manualLanguage=true"
57            
58            
59console.log("targetUrl222",targetUrl)
60            
61            // 设置一个cookie,表示用户已经选择了语言
62            document.cookie = "lang_set=true; path=/; max-age=" + (60 * 60 * 24 * 30); // 30天有效期
63            
64            
65            // 跳转到目标URL
66            window.location.href = targetUrl;
67        });
68    });
69});

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.