1var searchTimeout; 2var currentRequest = null; 3 4function showMobileSearch() { 5 var modal = document.getElementById('mobileSearchModal'); 6 if (modal) { 7 modal.style.display = 'block'; 8 modal.classList.remove('hide'); 9 setTimeout(function() { 10 modal.classList.add('show'); 11 }, 10); 12 document.body.style.overflow = 'hidden'; 13 setTimeout(function() { 14 var input = document.getElementById('mobileSearchQuery'); 15 if (input) { 16 input.focus(); 17 } 18 }, 100); 19 } 20} 21 22function hideMobileSearch() { 23 var modal = document.getElementById('mobileSearchModal'); 24 if (modal) { 25 modal.classList.remove('show'); 26 modal.classList.add('hide'); 27 setTimeout(function() { 28 modal.style.display = 'none'; 29 modal.classList.remove('hide'); 30 }, 300); 31 document.body.style.overflow = ''; 32 var results = document.getElementById('mobileSearchResults'); 33 if (results) { 34 results.innerHTML = ''; 35 } 36 var input = document.getElementById('mobileSearchQuery'); 37 if (input) { 38 input.value = ''; 39 } 40 if (currentRequest && currentRequest.readyState !== 4) { 41 currentRequest.abort(); 42 currentRequest = null; 43 } 44 } 45} 46 47function goToSearchPage() { 48 var query = document.getElementById('mobileSearchQuery').value.trim(); 49 if (query.length < 2) { 50 return; 51 } 52 window.location.href = '/search/?q=' + encodeURIComponent(query) + '&send=Y&r=Y'; 53} 54 55function doMobileSearch() { 56 var query = document.getElementById('mobileSearchQuery').value.trim(); 57 58 if (query.length < 1) { 59 document.getElementById('mobileSearchResults').innerHTML = ''; 60 return; 61 } 62 63 if (query.length < 2) { 64 document.getElementById('mobileSearchResults').innerHTML = '<div class="search-empty">' + mobileSearchLang.ENTER_MIN_2 + '</div>'; 65 return; 66 } 67 68 goToSearchPage(); 69} 70 71$(function() { 72 var searchInput = document.getElementById('mobileSearchQuery'); 73 var searchButton = document.querySelector('.mobile-search-button'); 74 75 if (searchInput) { 76 searchInput.addEventListener('keyup', function(e) { 77 clearTimeout(searchTimeout); 78 var query = this.value.trim(); 79 80 if (query.length >= 2) { 81 searchTimeout = setTimeout(function() { 82 performAjaxSearch(); 83 }, 300); 84 } else if (query.length < 1) { 85 document.getElementById('mobileSearchResults').innerHTML = ''; 86 } else if (query.length < 2) { 87 document.getElementById('mobileSearchResults').innerHTML = '<div class="search-empty">' + mobileSearchLang.ENTER_MIN_2 + '</div>'; 88 } 89 }); 90 91 searchInput.addEventListener('keypress', function(e) { 92 if (e.key === 'Enter') { 93 clearTimeout(searchTimeout); 94 goToSearchPage(); 95 } 96 }); 97 } 98 99 if (searchButton) { 100 searchButton.addEventListener('click', function() { 101 goToSearchPage(); 102 }); 103 } 104 105 document.addEventListener('keydown', function(e) { 106 if (e.key === 'Escape') { 107 hideMobileSearch(); 108 } 109 }); 110}); 111 112function performAjaxSearch() { 113 var query = document.getElementById('mobileSearchQuery').value.trim(); 114 115 if (query.length < 2) { 116 return; 117 } 118 119 var resultsDiv = document.getElementById('mobileSearchResults'); 120 resultsDiv.innerHTML = '<div class="search-loading">' + mobileSearchLang.LOADING + '</div>'; 121 122 if (currentRequest && currentRequest.readyState !== 4) { 123 currentRequest.abort(); 124 } 125 126 currentRequest = $.ajax({ 127 url: mobileSearchAjaxUrl, 128 type: 'POST', 129 data: { 130 q: query, 131 iblock_id: mobileSearchIblockId, 132 site_id: mobileSearchSiteId 133 }, 134 dataType: 'json', 135 success: function(response) { 136 if (response.success && response.html) { 137 resultsDiv.innerHTML = response.html; 138 var allResultsHtml = '<div class="search-all-results"><button class="all-results-button" onclick="goToSearchPage()">' + mobileSearchLang.RESULTS + '</button></div>'; 139 resultsDiv.innerHTML += allResultsHtml; 140 if (typeof checkLazyItems === 'function') { 141 checkLazyItems();
142 } 143 if (typeof rebindAddToCart === 'function') { 144 rebindAddToCart(); 145 } 146 } else { 147 resultsDiv.innerHTML = '<div class="search-empty">' + (response.message || mobileSearchLang.NOT_FOUND) + '</div>'; 148 var allResultsHtml = '<div class="search-all-results"><button class="all-results-button" onclick="goToSearchPage()">' + mobileSearchLang.RESULTS + '</button></div>'; 149 resultsDiv.innerHTML += allResultsHtml; 150 } 151 currentRequest = null; 152 }, 153 error: function(xhr, status, error) { 154 console.error('AJAX Error:', status, error); 155 resultsDiv.innerHTML = '<div class="search-empty">' + mobileSearchLang.ERROR + '</div>'; 156 currentRequest = null; 157 } 158 }); 159}
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.