PageSourceSearch

https://www.architect-design.ru/js/brands.js

js architect-design.ru collected 2026-10-02 12:24:25 UTC 2,486 bytes, 55 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2    const searchInput = document.querySelector('.brands .brands-search-input');
3    const brandsContainer = document.querySelector('.brands');
4    const infoSearch = document.querySelector('.brands .info-search');
5
6    if (!searchInput || !brandsContainer) return;
7
8    function isVisible(element) {
9        return element.offsetParent !== null;
10    }
11
12    function updateVisibility() {
13        const searchValue = searchInput.value.toLowerCase().trim();
14        const elementsWithDataSearch = brandsContainer.querySelectorAll('[data-search]');
15
16        // Разделяем поисковый запрос по запятым и убираем пробелы
17        const searchTerms = searchValue.split(',').map(term => term.trim()).filter(term => term !== '');
18
19        elementsWithDataSearch.forEach(function (element) {
20            const dataSearchContent = element.getAttribute('data-search').toLowerCase();
21
22            if (searchTerms.length === 0) {
23                // Если поиск пустой, показываем все элементы
24                element.removeAttribute('data-hidden');
25            } else {
26                // Проверяем, содержится ли хотя бы один из поисковых терминов
27                const found = searchTerms.some(term => dataSearchContent.includes(term));
28
29                if (found) {
30                    element.removeAttribute('data-hidden');
31                } else {
32                    element.setAttribute('data-hidden', '');
33                }
34            }
35        });
36
37        // Проверяем видимость .letter и .wrap-popular, чтобы показать .info-search если ничего не найдено
38        const letters = brandsContainer.querySelectorAll('.letter');
39        const hasVisibleLetters = Array.from(letters).some(letter => isVisible(letter));
40
41        const wrapPopular = brandsContainer.querySelector('.wrap-popular');
42        const hasVisiblePopular = wrapPopular && isVisible(wrapPopular);
43
44        // Показываем/скрываем .info-search
45        if (infoSearch) {
46            if (!hasVisibleLetters && !hasVisiblePopular) {
47                infoSearch.removeAttribute('data-hidden');
48            } else {
49                infoSearch.setAttribute('data-hidden', '');
50            }
51        }
52    }
53
54    searchInput.addEventListener('input', updateVisibility);
55});

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.