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.