1if (typeof yatranslate === 'undefined') { 2 // ÐÑли пеÑÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ð½Ðµ обÑÑвлена, обÑÑвлÑем ÐµÑ 3 var yatranslate = { 4 /* ÐÑигиналÑнÑй ÑзÑк */ 5 lang: "ru", 6 }; 7} else { 8 // ÐÑли пеÑÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ñже обÑÑвлена, пеÑезапиÑÑваем ÐµÑ 9 yatranslate = { 10 /* ÐÑигиналÑнÑй ÑзÑк */ 11 lang: "ru", 12 }; 13} 14 15langCodeDescription = { 16 ru : 'Russian', 17 en: 'English', 18 de: 'German', 19 zh: 'China', 20 fr: 'French', 21 kk: 'Kazakh', 22 ba: 'Bashkir', 23 es: 'Spanish', 24 tr: 'Turkish', 25 ja: 'Japanese', 26} 27 28document.addEventListener('DOMContentLoaded', function () { 29 // Start 30 yaTranslateInit(); 31}) 32 33function yaTranslateInit() { 34 35 if (yatranslate.langFirstVisit && !localStorage.getItem('yt-widget')) { 36 /* ÐÑли ÑÑÑановлен ÑзÑк пеÑевода Ð´Ð»Ñ Ð¿ÐµÑвого поÑеÑÐµÐ½Ð¸Ñ Ð¸ в localStorage Ð½ÐµÑ yt-widget */ 37 /* If the translation language is installed for the first visit and in localStorage no yt-widget */ 38 yaTranslateSetLang(yatranslate.langFirstVisit); 39 } 40 41 // ÐодклÑÑаем Ð²Ð¸Ð´Ð¶ÐµÑ yandex translate 42 // Connecting the yandex translate widget 43 let script = document.createElement('script'); 44 script.src = `https://translate.yandex.net/website-widget/v1/widget.js?widgetId=ytWidget&pageLang=${yatranslate.lang}&widgetTheme=light&autoMode=false`; 45 document.getElementsByTagName('head')[0].appendChild(script); 46 47 // ÐолÑÑаем и запиÑÑваем ÑзÑк на коÑоÑÑй пеÑеводим 48 // We get and write down the language into which we translate 49 let code = yaTranslateGetCode(); 50 51 // ÐоказÑваем ÑекÑÑий ÑзÑк в Ð¼ÐµÐ½Ñ 52 // Show the current language in the menu 53 yaTranslateHtmlHandler(code); 54 55 // ÐеÑаем ÑобÑÑие клик на Ñлаги 56 // We hang the event click on the flags 57 yaTranslateEventHandler('click', '[data-ya-lang]', function (el) { 58 yaTranslateSetLang(el.getAttribute('data-ya-lang')); 59 // ÐеÑезагÑÑжаем ÑÑÑаниÑÑ 60 // Reloading the page 61 window.location.reload(); 62 }) 63} 64 65function yaTranslateSetLang(lang) { 66 // ÐапиÑÑваем вÑбÑаннÑй ÑзÑк в localStorage обÑÐµÐºÑ yt-widget 67 // Writing the selected language to localStorage 68 localStorage.setItem('yt-widget', JSON.stringify({ 69 "lang": lang, 70 "active": true 71 })); 72} 73 74function yaTranslateGetCode() { 75 // ÐозвÑаÑаем ÑзÑк на коÑоÑÑй пеÑеводим 76 // Returning the language to which we are translating 77 return (localStorage["yt-widget"] != undefined && JSON.parse(localStorage["yt-widget"]).lang != undefined) ? JSON.parse(localStorage["yt-widget"]).lang : yatranslate.lang; 78} 79 80function yaTranslateHtmlHandler(code) { 81 // ÐолÑÑаем ÑзÑк на коÑоÑÑй пеÑеводим и пÑоизводим Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ñе манипÑлÑÑии Ñ DOM 82 // We get the language to which we translate and produce the necessary manipulations with DOM 83 document.querySelector('[data-lang-active]').innerHTML = `<span translate="no">${langCodeDescription[code]}</span>`; 84 elementToRemove = document.querySelector(`[data-ya-lang="${code}"]`); 85 if(elementToRemove) { 86 elementToRemove.remove(); 87 } 88} 89 90function yaTranslateEventHandler(event, selector, handler) { 91 document.addEventListener(event, function (e) { 92 let el = e.target.closest(selector); 93 if (el) handler(el); 94 }); 95}
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.