1document.addEventListener("DOMContentLoaded", function () { 2 // ÐÑпомогаÑелÑÐ½Ð°Ñ ÑÑнкÑÐ¸Ñ Ð´Ð»Ñ ÑÑанÑлиÑеÑаÑии (ÑкÑаинÑкий/ÑÑÑÑкий -> лаÑиниÑа) 3 function slugify(text) { 4 const translitMap = { 5 а: "a", 6 б: "b", 7 в: "v", 8 г: "h", 9 Ò: "g", 10 д: "d", 11 е: "e", 12 Ñ: "ie", 13 ж: "zh", 14 з: "z", 15 и: "y", 16 Ñ: "i", 17 Ñ: "yi", 18 й: "i", 19 к: "k", 20 л: "l", 21 м: "m", 22 н: "n", 23 о: "o", 24 п: "p", 25 Ñ: "r", 26 Ñ: "s", 27 Ñ: "t", 28 Ñ: "u", 29 Ñ: "f", 30 Ñ : "kh", 31 Ñ: "ts", 32 Ñ: "ch", 33 Ñ: "sh", 34 Ñ: "shch", 35 Ñ: "", 36 Ñ: "yu", 37 Ñ: "ya", 38 " ": "-", 39 "'": "", 40 '"': "", 41 "«": "", 42 "»": "", 43 "â": "-", 44 "â": "-", 45 }; 46 47 return text 48 .toLowerCase() 49 .split("") 50 .map((char) => 51 translitMap[char] !== undefined ? translitMap[char] : char, 52 ) 53 .join("") 54 .replace(/[^a-z0-9\-]/g, "") 55 .replace(/-+/g, "-") 56 .replace(/^-|-$/g, ""); 57 } 58 59 const contentBlock = document.querySelector(".article_main_content"); 60 if (contentBlock) { 61 const headings = contentBlock.querySelectorAll("h2, h3");
62 headings.forEach((heading) => { 63 const isBadId = 64 heading.id && 65 (heading.id.includes("8217") || 66 heading.id.includes("___") || 67 heading.id.startsWith("#") || 68 /^\d/.test(heading.id)); 69 70 if (!heading.id || isBadId) { 71 // ÐенеÑиÑÑем ÑÑанÑлиÑеÑиÑованнÑй ID из ÑекÑÑа заголовка 72 heading.id = slugify(heading.textContent.trim()); 73 } 74 }); 75 } 76 77 // ÐÐ»Ð°Ð²Ð½Ð°Ñ Ð¿ÑокÑÑÑка 78 const tocLinks = document.querySelectorAll("#toc_container a.smooth-scroll"); 79 tocLinks.forEach((link) => { 80 link.addEventListener("click", function (e) { 81 e.preventDefault(); 82 const targetId = this.getAttribute("href").substring(1); 83 const targetElement = document.getElementById(targetId); 84 85 if (targetElement) { 86 const headerHeight = document.querySelector("header") 87 ? document.querySelector("header").offsetHeight 88 : 0; 89 const elementPosition = 90 targetElement.getBoundingClientRect().top + window.pageYOffset; 91 const offsetPosition = elementPosition - headerHeight - 20; 92 93 window.scrollTo({ 94 top: offsetPosition, 95 behavior: "smooth", 96 }); 97 history.pushState(null, null, "#" + targetId); 98 } 99 }); 100 }); 101});
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.