PageSourceSearch

https://limefitness.center/local/templates/limefitness.center_2026/components/bitrix/menu/inside/script.js

js limefitness.center collected 2026-10-06 06:25:04 UTC 2,085 bytes, 54 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function() {
2    const menu = document.getElementById("popupMenu");
3    if (!menu) return;
4    const links = menu.querySelectorAll("a[href^='#']");
5    const sections = [];
6    links.forEach(link => {
7        const anchor = link.getAttribute("href").replace('#', '');
8        if (anchor) {
9            const section = document.getElementById(anchor);
10            if (section) {
11                sections.push({link, section, anchor});
12            }
13        }
14    });
15
16    function updateActiveMenu() {
17        // Проверяем, почти ли пользователь в самом низу (footer виден)
18        const scrollBottom = window.innerHeight + window.pageYOffset;
19        const docHeight = Math.max(
20            document.body.scrollHeight, document.documentElement.scrollHeight,
21            document.body.offsetHeight, document.documentElement.offsetHeight,
22            document.body.clientHeight, document.documentElement.clientHeight
23        );
24
25        let activeIdx = 0;
26        let minOffset = Infinity;
27
28        sections.forEach((item, idx) => {
29            const rect = item.section.getBoundingClientRect();
30            const offset = Math.abs(rect.top);
31            if (rect.top < window.innerHeight / 2 && offset < minOffset) {
32                minOffset = offset;
33                activeIdx = idx;
34            }
35        });
36
37        const nearBottom = (docHeight - scrollBottom) < 100;
38        if (nearBottom) {
39            const footerIdx = sections.findIndex(item => item.anchor === 'footer');
40            if (footerIdx !== -1) {
41                activeIdx = footerIdx;
42            }
43        }
44
45        menu.querySelectorAll('.active').forEach(el => el.classList.remove('active'));
46        if (sections[activeIdx]) {
47            sections[activeIdx].link.classList.add('active');
48        }
49    }
50
51    updateActiveMenu();
52    window.addEventListener('scroll', updateActiveMenu, {passive:true});
53    window.addEventListener('resize', updateActiveMenu);
54});

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.