1const googleTranslateConfig = { 2 lang: "ru", 3}; 4 5function TranslateInit() { 6 7 let code = TranslateGetCode(); 8 9 10 if (code == googleTranslateConfig.lang) { 11 // ÐÑли ÑзÑк по ÑмолÑаниÑ, ÑÐ¾Ð²Ð¿Ð°Ð´Ð°ÐµÑ Ñ ÑзÑком на коÑоÑÑй пеÑеводим 12 // То оÑиÑаем кÑки 13 TranslateClearCookie(); 14 } 15 16 // ÐниÑиализиÑÑем Ð²Ð¸Ð´Ð¶ÐµÑ Ñ ÑзÑком по ÑмолÑÐ°Ð½Ð¸Ñ 17 //new google.translate.TranslateElement({pageLanguage: 'ru', includedLanguages: 'en,ru,be', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false}, 'google_translate_element'); 18 19 if(getCookie('glang') == 'be'){ 20 $('[data-google-lang="be"]').addClass('_active'); 21 new google.translate.TranslateElement({ 22 pageLanguage: googleTranslateConfig.lang, 23 }); 24 }else{ 25 $('[data-google-lang="ru"]').addClass('_active'); 26 } 27 28 // ÐеÑаем ÑобÑÑие клик на Ñлаги 29 $('[data-google-lang]').click(function () { 30 TranslateSetCookie($(this).attr("data-google-lang")) 31 32 //console.log($(this).attr("data-google-lang")); 33 // ÐеÑезагÑÑжаем ÑÑÑаниÑÑ 34 window.location.reload(); 35 }); 36} 37 38function TranslateGetCode() { 39 // ÐÑли кÑки неÑ, Ñо пеÑедаем деÑолÑнÑй ÑзÑк 40 let lang = (getCookie('googtrans') != undefined && getCookie('googtrans') != "null") ? getCookie('googtrans') : googleTranslateConfig.lang; 41 return lang.substr(-2); 42} 43 44function TranslateClearCookie() { 45 setCookie('googtrans', null); 46 setCookie("googtrans", null, { 47 domain: "." + document.domain, 48 }); 49} 50 51function TranslateSetCookie(code) { 52 //console.log(code); 53 // ÐапиÑÑваем кÑки /ÑзÑк_коÑоÑÑй_пеÑеводим/ÑзÑк_на_коÑоÑÑй_пеÑеводим 54 setCookie("glang", code); 55 setCookie('googtrans', "/auto/" + code); 56 setCookie("googtrans", "/auto/" + code, { 57 domain: "." + document.domain, 58 }); 59 60} 61 62function getCookie(name) { 63 let matches = document.cookie.match(new RegExp( 64 "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" 65 )); 66 return matches ? decodeURIComponent(matches[1]) : undefined; 67} 68 69function setCookie(name, value, options = {}) { 70 71 options = { 72 path: '/', 73 // пÑи Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ÑÑи добавÑÑе дÑÑгие знаÑÐµÐ½Ð¸Ñ Ð¿Ð¾ ÑмолÑÐ°Ð½Ð¸Ñ 74 ...options 75 }; 76 77 if (options.expires instanceof Date) { 78 options.expires = options.expires.toUTCString(); 79 } 80 81 let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value); 82 83 for (let optionKey in options) { 84 updatedCookie += "; " + optionKey; 85 let optionValue = options[optionKey]; 86 if (optionValue !== true) { 87 updatedCookie += "=" + optionValue; 88 } 89 } 90 91 document.cookie = updatedCookie; 92}
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.