PageSourceSearch

https://www.garant.ru/static/www/js/endless_scroll.js?933

js garant.ru collected 2026-09-24 06:23:59 UTC 2,635 bytes, 68 lines download raw bytes

1$(document).ready(function () {
2    let rootTagId = document.querySelector('.category-tag')?.dataset.tag_id ?? null;
3
4    const lastBlock = function() {
5        let endlessNews = document.querySelectorAll('.endless-bar-news');
6        return endlessNews[endlessNews.length - 1];
7    };
8
9    const lastArticle = function() {
10        let lastArticles = lastBlock().querySelectorAll('.endless_news_block_item');
11        return (lastArticles.length !== 0)
12            ? lastArticles[lastArticles.length - 1]
13            : null;
14    };
15
16    const loadSideBar = function() {
17        let lastDate = lastArticle() ? lastArticle().dataset.date : null;
18
19        $.ajax({
20            url: '/ajax/news/endless/?mode=new',
21            type: 'POST',
22            data: {
23                'form_data[last_date]': lastDate,
24                'form_data[root_tag_id]': rootTagId,
25            },
26            success: function (response) {
27                let topBlock = JSON.parse(response.replace('OK|', ''));
28                lastBlock().insertAdjacentHTML('afterend', topBlock.html);
29                
30                let nextBlockTmp = document.createElement('div');
31                nextBlockTmp.innerHTML = topBlock.html;
32
33                let scripts = nextBlockTmp.querySelectorAll('script');
34                scripts.forEach((script) => {
35                    let scriptTag = document.createElement('script');
36                    scriptTag.innerHTML = script.innerHTML;
37                    document.body.appendChild(scriptTag);
38                });
39            }
40        });
41    };
42
43    let lastOids = [];
44    window.addEventListener('scroll', function () {
45        var lastNewsBlock = null;
46        var lastNewsBlockHalf = null;
47
48        let lastOid = lastArticle() ? lastArticle().dataset.oid : null;
49        if (lastOid) {
50            lastNewsBlock = lastBlock();
51            lastNewsBlockHalf = $(lastNewsBlock).height() / 2;
52        } else {
53            let sections = document.querySelectorAll('.endless_news_block');
54            lastNewsBlock = sections[0];
55            lastNewsBlockHalf = $(lastNewsBlock).height() * 2;
56        }
57        let sideBarBottom = $(lastNewsBlock).offset().top + $(lastNewsBlock).height();
58        let scrollPos = $(window).scrollTop() + $(window).height();
59
60        if (scrollPos >= sideBarBottom - lastNewsBlockHalf) {
61            let lastOid = lastArticle() ? lastArticle().dataset.oid : null;
62            if (! lastOids.includes(lastOid)) {
63                lastOids.push(lastOid);
64                loadSideBar();
65            }
66        }
67    });
68});

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.