PageSourceSearch

https://www.fctele.com/wp-content/uploads/fctel-language-switcher/language-switcher-v2.js?ver=20260925-2

js fctele.com collected 2026-10-06 11:13:11 UTC 6,198 bytes, 99 lines download raw bytes

1(function () {
2  'use strict';
3
4  var runtimeVersion = 7;
5  if (Number(window.__FCTEL_LANGUAGE_SWITCHER__ || 0) >= runtimeVersion) return;
6  window.__FCTEL_LANGUAGE_SWITCHER__ = runtimeVersion;
7
8  var assetBase = '/wp-content/uploads/fctel-language-switcher/flags/';
9  var languages = [
10    { code: 'en', label: 'English', short: 'EN', flag: 'gb', path: '/' },
11    { code: 'es', label: 'Español', short: 'ES', flag: 'es', path: '/es/' },
12    { code: 'fr', label: 'Français', short: 'FR', flag: 'fr', path: '/fr/' },
13    { code: 'pt', label: 'Português', short: 'PT', flag: 'pt', path: '/pt/' },
14    { code: 'ar', label: 'العربية', short: 'AR', flag: 'sa', path: '/ar/' },
15    { code: 'ru', label: 'Русский', short: 'RU', flag: 'ru', path: '/ru/' },
16    { code: 'de', label: 'Deutsch', short: 'DE', flag: 'de', path: '/de/' },
17    { code: 'ko', label: '한국어', short: 'KO', flag: 'kr', path: '/ko/' },
18    { code: 'it', label: 'Italiano', short: 'IT', flag: 'it', path: '/it/' },
19    { code: 'id', label: 'Bahasa Indonesia', short: 'ID', flag: 'id', path: '/id/' },
20    { code: 'vi', label: 'Tiếng Việt', short: 'VI', flag: 'vi', path: '/vi/', pluginFlag: true },
21    { code: 'th', label: 'ไทย', short: 'TH', flag: 'th', path: '/th/', pluginFlag: true },
22    { code: 'tr', label: 'Türkçe', short: 'TR', flag: 'tr', path: '/tr/', pluginFlag: true },
23    { code: 'ja', label: '日本語', short: 'JA', flag: 'ja', path: '/ja/', pluginFlag: true }
24  ];
25
26  var legacySelectors = ['.gtranslate_wrapper','#gt_float_wrapper','.gt_float_switcher','.gt_switcher_wrapper','.gt_switcher','.goog-te-gadget'];
27  function suppressLegacyMenu(root) {
28    var scope = root && root.querySelectorAll ? root : document;
29    legacySelectors.forEach(function (selector) {
30      if (scope.matches && scope.matches(selector)) { scope.remove(); return; }
31      Array.prototype.forEach.call(scope.querySelectorAll(selector), function (node) { node.remove(); });
32    });
33  }
34  suppressLegacyMenu(document);
35  if (document.documentElement && window.MutationObserver) {
36    new MutationObserver(function (mutations) {
37      mutations.forEach(function (mutation) {
38        Array.prototype.forEach.call(mutation.addedNodes || [], function (node) {
39          if (node && node.nodeType === 1) suppressLegacyMenu(node);
40        });
41      });
42    }).observe(document.documentElement, { childList: true, subtree: true });
43  }
44
45  function currentLanguage() {
46    var first = (location.pathname.split('/').filter(Boolean)[0] || '').toLowerCase();
47    return languages.find(function (item) { return item.code === first; }) || languages[0];
48  }
49  function flagMarkup(item) {
50    var source = item.pluginFlag ? '/wp-content/plugins/gtranslate/flags/24/' + item.flag + '.png' : assetBase + item.flag + '.png?v=20260921-2';
51    return '<img class="fctel-lang__flag" src="' + source + '" alt="" width="28" height="19">';
52  }
53  function enforcePosition() {
54    var id = 'fctel-language-position-v6';
55    var old = document.getElementById(id);
56    if (old) old.remove();
57    var style = document.createElement('style');
58    style.id = id;
59    style.textContent = '#fctel-language-switcher.fctel-lang{top:10px!important;right:28px!important;bottom:auto!important;left:auto!important}' +
60      '@media(max-width:767px){#fctel-language-switcher.fctel-lang{top:22px!important;right:72px!important;bottom:auto!important;left:auto!important}}';
61    document.head.appendChild(style);
62  }
63  function targetUrl(item) {
64    var parts = location.pathname.split('/').filter(Boolean);
65    var translated = languages.some(function (language) { return language.code === parts[0]; });
66    var rest = translated ? parts.slice(1) : parts;
67    var path = (item.code === 'en' ? '/' : item.path) + rest.join('/');
68    if (location.pathname.endsWith('/') && !path.endsWith('/')) path += '/';
69    if (!path) path = '/';
70    var params = new URLSearchParams(location.search);
71    ['menu_probe','menu_runtime_check','verify','mobile_verify','fctel_ui'].forEach(function (key) { params.delete(key); });
72    var query = params.toString();
73    return path + (query ? '?' + query : '') + location.hash;
74  }
75
76  function build() {
77    enforcePosition();
78    var old = document.getElementById('fctel-language-switcher');
79    if (old) old.remove();
80    document.documentElement.classList.add('fctel-custom-language-menu');
81    var active = currentLanguage();
82    var root = document.createElement('div');
83    root.id = 'fctel-language-switcher'; root.className = 'fctel-lang';
84    root.innerHTML = '<button class="fctel-lang__current" type="button" aria-haspopup="listbox" aria-expanded="false">' + flagMarkup(active) + '<span class="fctel-lang__short">' + active.short + '</span><span class="fctel-lang__chevron" aria-hidden="true"></span></button>
84<div class="fctel-lang__menu" role="listbox" aria-label="Choose language"></div>';
85    var menu = root.querySelector('.fctel-lang__menu');
86    languages.forEach(function (item) {
87      var link = document.createElement('a');
88      link.className = 'fctel-lang__option' + (item.code === active.code ? ' is-active' : '');
89      link.href = targetUrl(item); link.lang = item.code; link.setAttribute('role','option'); link.setAttribute('aria-selected', item.code === active.code ? 'true' : 'false');
90      link.innerHTML = flagMarkup(item) + '<span>' + item.label + '</span>'; menu.appendChild(link);
91    });
92    var button = root.querySelector('.fctel-lang__current');
93    function close() { root.classList.remove('is-open'); button.setAttribute('aria-expanded','false'); }
94    button.addEventListener('click', function (event) { event.stopPropagation(); var open = root.classList.toggle('is-open'); button.setAttribute('aria-expanded', open ? 'true' : 'false'); });
95    document.addEventListener('click', close); document.addEventListener('keydown', function (event) { if (event.key === 'Escape') close(); });
96    document.body.appendChild(root); suppressLegacyMenu(document);
97  }
98  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', build, { once:true }); else build();
99})();

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.