PageSourceSearch

https://familyhealth.ua/wp-content/themes/family/js/toc-scroll.js?ver=1.0

js familyhealth.ua collected 2026-10-04 20:26:55 UTC 2,739 bytes, 101 lines download raw bytes

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.