PageSourceSearch

https://rx-hotel.com/wp-content/themes/relax-theme/assets/js/yandex-translate.js

js rx-hotel.com collected 2026-10-08 08:57:59 UTC 3,312 bytes, 73 lines download raw bytes

1const yatranslate = {
2    /* Original language */
3    lang: "ru",
4    /* The language we translate into on the first visit */
5    /* Язык, на который переводим при первом посещении */
6    // langFirstVisit: 'en',
7};
8
9document.addEventListener('DOMContentLoaded', function () {
10    // Start
11    yaTranslateInit();
12})
13
14function yaTranslateInit() {
15
16    if (yatranslate.langFirstVisit && !localStorage.getItem('yt-widget')) {
17        /* Если установлен язык перевода для первого посещения и в localStorage нет yt-widget */
18        /* If the translation language is installed for the first visit and in localStorage no yt-widget */
19        yaTranslateSetLang(yatranslate.langFirstVisit);
20    }
21
22    // Подключаем виджет yandex translate
23    // Connecting the yandex translate widget
24    let script = document.createElement('script');
25    script.src = `https://translate.yandex.net/website-widget/v1/widget.js?widgetId=ytWidget&pageLang=${yatranslate.lang}&widgetTheme=light&autoMode=false`;
26    document.getElementsByTagName('head')[0].appendChild(script);
27
28    // Получаем и записываем язык на который переводим
29    // We get and write down the language into which we translate
30    let code = yaTranslateGetCode();
31
32    // Показываем текущий язык в меню
33    // Show the current language in the menu
34    yaTranslateHtmlHandler(code);
35
36    // Вешаем событие клик на флаги
37    // We hang the event click on the flags
38    yaTranslateEventHandler('click', '[data-ya-lang]', function (el) {
39        yaTranslateSetLang(el.getAttribute('data-ya-lang'));
40        // Перезагружаем страницу
41        // Reloading the page
42        window.location.reload();
43    })
44}
45
46function yaTranslateSetLang(lang) {
47    // Записываем выбранный язык в localStorage объект yt-widget
48    // Writing the selected language to localStorage
49    localStorage.setItem('yt-widget', JSON.stringify({
50        "lang": lang,
51        "active": true
52    }));
53}
54
55function yaTranslateGetCode() {
56    // Возвращаем язык на который переводим
57    // Returning the language to which we are translating
58    return (localStorage["yt-widget"] != undefined && JSON.parse(localStorage["yt-widget"]).lang != undefined) ? JSON.parse(localStorage["yt-widget"]).lang : yatranslate.lang;
59}
60
61function yaTranslateHtmlHandler(code) {
62    // Получаем язык на который переводим и производим необходимые манипуляции с DOM
63    // We get the language to which we translate and produce the necessary manipulations with DOM
64    document.querySelector('[data-lang-active]').innerHTML = `<img class="lang__img lang__img_select" src="/wp-content/themes/relax-theme/assets/img/${code}.jpg" alt="${code}">`;
65    document.querySelector(`[data-ya-lang="${code}"]`).remove();
66}
67
68function yaTranslateEventHandler(event, selector, handler) {
69    document.addEventListener(event, function (e) {
70        let el = e.target.closest(selector);
71        if (el) handler(el);
72    });
73}

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.