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.