PageSourceSearch

https://www.bosch-mobility.com/media/media_tech/assets/js/bbm_languageredirect.js

js bosch-mobility.com collected 2026-10-02 02:53:40 UTC 2,944 bytes, 74 lines download raw bytes

1(function() {
2    /**
3     * 14.04.2025 16:27
4     * CONFIG DXF PROD
5     * ----
6     * Set the class "js-disable-language-redirect" on the link nodes of the language select,
7     * or change the class name in the constants "LANGUAGE_SWITCH_LINK_CLASS". 
8     */
9  
10    // default language
11    const DEFAULT_LANGUAGE = 'en';
12  
13    // mapping of language to url
14    const LANGUAGE_URL_MAP = {
15      en: 'https://www.bosch-mobility.com/en/',
16      de: 'https://www.bosch-mobility.com/de/',
17      // pt-BR: 'https://www.bosch-mobility.com/pt/about-us/regions/brazil/',
18      // ja-JP: 'https://www.bosch-mobility.com/ja/about-us/regions/japan/',
19      // zh-CN: 'https://www.bosch-mobility.com/zh/about-us/regions/china/',
20	  // fr-FR: 'https://www.bosch-mobility.com/fr/about-us/regions/france/',
21    };
22  
23    // language switch link css class 
24    const LANGUAGE_SWITCH_LINK_CLASS = 'mLangDropdownItem';
25  
26    // cookie name
27    const COOKIE_NAME = 'languageRedirect';
28  
29    // window Location
30    const WINDOW_LOCATION = window.location.href;
31    
32    const pageLang = document.documentElement.lang;
33    const userLang = (navigator.language || navigator.userLanguage).split('-')[0];
34    const hasCookie = document.cookie.split(';').some(function(cookie) {
35      return cookie.includes(COOKIE_NAME + '=disabled');
36    });
37  
38    if (
39      pageLang !== userLang
40      && !hasCookie
41      && !(!LANGUAGE_URL_MAP[userLang] && pageLang === DEFAULT_LANGUAGE)
42      //&& WINDOW_LOCATION !== 'https://bosch-mobility-solutionscom.osh.bosch.tech'
43      //&& WINDOW_LOCATION !== 'http://q-www-ir7.webspace.bosch.com/_BBM_DE_V2_Q/de/'
44      //&& WINDOW_LOCATION !== 'http://q-www-ir7.webspace.bosch.com/_BBM_DE_V2_Q/en/'
45      && WINDOW_LOCATION !== 'https://bbm-pre-golive.qa.dxf.bosch.tech/en'
46      && WINDOW_LOCATION !== 'https://bbm-pre-golive.qa.dxf.bosch.tech/de'
47    ) {
48      const targetUrl = LANGUAGE_URL_MAP[userLang] || LANGUAGE_URL_MAP[DEFAULT_LANGUAGE];
49      window.location.href = targetUrl;
50    }
51  
52    if (window.NodeList && !NodeList.prototype.forEach) {
53      NodeList.prototype.forEach = function(callback, thisArg) {
54        thisArg = thisArg || window;
55        for (var i = 0; i < this.length; i++) {
56          callback.call(thisArg, this[i], i, this);
57        }
58      };
59    }
60  
61    function handleLanguageChange() {
62      const date = new Date();
63      date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000)); // 7 days
64      const cookie = COOKIE_NAME + '=disabled; expires=' + date.toUTCString() + '; path=/';
65      document.cookie = cookie;
66    }
67  
68    document.addEventListener('DOMContentLoaded', function() {
69      const languageSwitchNodes = document.querySelectorAll('.' + LANGUAGE_SWITCH_LINK_CLASS);
70      languageSwitchNodes.forEach(function(node) {
71        node.addEventListener('click', handleLanguageChange);
72      });
73    });
74  })();

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.