1(function() { 2 const langElem = document.querySelector('.language'); 3 if (langElem) { 4 const languagesData = langElem.dataset.languages; 5 const currentLang = langElem.dataset.currentLang; 6 const currentPath = langElem.dataset.currentPath; 7 8 if (languagesData) { 9 let languages; 10 try { 11 languages = JSON.parse(decodeURIComponent(languagesData)); 12 } catch (e) { 13 languages = []; 14 } 15 const list = langElem.querySelector('.language__list'); 16 if (list && languages.length > 0) { 17 languages.forEach(function(l) { 18 const a = document.createElement('a'); 19 a.className = 'language__title' + (l.code === currentLang ? ' language__title_selected' : ''); 20 a.href = l.code === 'en' ? currentPath : '/' + l.code + currentPath; 21 a.textContent = l.name; 22 list.appendChild(a); 23 }); 24 } 25 } 26 27 document.addEventListener('click', function(e) { 28 if (!langElem.contains(e.target)) { 29 langElem.classList.remove('language_active'); 30 } else { 31 langElem.classList.toggle('language_active'); 32 } 33 }); 34 } 35 36 const popup = document.getElementById('termsPopup'); 37 const termsLink = document.getElementById('termsLink'); 38 const closeBtn = document.getElementById('termsClose'); 39 const termsContent = document.getElementById('termsContent'); 40 let termsLoaded = false; 41 42 if (popup && termsLink && termsContent) { 43 function openPopup(e) { 44 e.preventDefault(); 45 popup.classList.add('popup_visible'); 46 document.body.style.overflow = 'hidden'; 47 48 if (!termsLoaded) { 49 fetch('/terms') 50 .then(r => r.text()) 51 .then(html => { 52 const doc = new DOMParser().parseFromString(html, 'text/html'); 53 doc.querySelectorAll('script, style, iframe, object, embed').forEach(el => el.remove()); 54 doc.querySelectorAll('*').forEach(el => { 55 for (const attr of [...el.attributes]) { 56 if (attr.name.startsWith('on') || attr.value.startsWith('javascript:')) { 57 el.removeAttribute(attr.name); 58 } 59 } 60 }); 61 const content = doc.querySelector('.page__content, .terms-content, main, article'); 62 termsContent.innerHTML = content ? content.innerHTML : doc.body.innerHTML; 63 termsLoaded = true; 64 }); 65 } 66 } 67 68 function closePopup() { 69 popup.classList.remove('popup_visible'); 70 document.body.style.overflow = ''; 71 } 72 73 termsLink.addEventListener('click', openPopup); 74 if (closeBtn) closeBtn.addEventListener('click', closePopup); 75 popup.addEventListener('click', function(e) { 76 if (e.target === popup) closePopup(); 77 }); 78 document.addEventListener('keydown', function(e) { 79 if (e.key === 'Escape' && popup.classList.contains('popup_visible')) { 80 closePopup(); 81 } 82 }); 83 } 84})();
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.