PageSourceSearch

https://kovry-karat.ru/local/templates/.default/components/bitrix/…/news/bitrix/news.list/.default/script.js

js kovry-karat.ru collected 2026-10-08 07:49:27 UTC 3,003 bytes, 87 lines download raw bytes

1(function () {
2    'use strict';
3
4    function showGlobalLoader(message) {
5        if (window.KaratLoader && typeof window.KaratLoader.show === 'function') {
6            window.KaratLoader.show(message || 'Загружаем…');
7        }
8    }
9
10    function hideGlobalLoader() {
11        if (window.KaratLoader && typeof window.KaratLoader.hide === 'function') {
12            window.KaratLoader.hide();
13        }
14    }
15
16    function initList(root) {
17        var button = root.querySelector('[data-showcase-more]');
18        var items = root.querySelector('[data-showcase-items]');
19
20        if (!button || !items || !window.fetch || !window.DOMParser) {
21            return;
22        }
23
24        button.addEventListener('click', function (event) {
25            event.preventDefault();
26
27            if (button.classList.contains('is-loading')) {
28                return;
29            }
30
31            button.classList.add('is-loading');
32            showGlobalLoader('Загружаем…');
33
34            fetch(button.href, {
35                credentials: 'same-origin',
36                headers: {'X-Requested-With': 'XMLHttpRequest'}
37            })
38                .then(function (response) {
39                    if (!response.ok) {
40                        throw new Error('HTTP ' + response.status);
41                    }
42                    return response.text();
43                })
44                .then(function (html) {
45                    var doc = new DOMParser().parseFromString(html, 'text/html');
46                    var nextRoot = doc.querySelector('[data-showcase-list]');
47                    var nextItems = nextRoot ? nextRoot.querySelector('[data-showcase-items]') : null;
48
49                    if (!nextItems) {
50                        throw new Error('Showcase list fragment not found');
51                    }
52
53                    Array.prototype.slice.call(nextItems.children).forEach(function (card) {
54                        items.appendChild(document.importNode(card, true));
55                    });
56
57                    var nextButton = nextRoot.querySelector('[data-showcase-more]');
58                    if (nextButton) {
59                        button.href = nextButton.href;
60                    } else {
61                        var wrap = button.parentNode;
62                        if (wrap) {
63                            wrap.remove();
64                        }
65                    }
66
67                    button.classList.remove('is-loading');
68                    hideGlobalLoader();
69                })
70                .catch(function () {
71                    button.classList.remove('is-loading');
72                    hideGlobalLoader();
73                    window.location.href = button.href;
74                });
75        });
76    }
77
78    function boot() {
79        document.querySelectorAll('[data-showcase-list]').forEach(initList);
80    }
81
82    if (document.readyState === 'loading') {
83        document.addEventListener('DOMContentLoaded', boot);
84    } else {
85        boot();
86    }
87})();

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.