1document.addEventListener("DOMContentLoaded", function() { 2 3 document.querySelectorAll("[data-open-popup]").forEach(btn => { 4 btn.addEventListener("click", () => { 5 const popup = document.querySelector(".popup_select_city"); 6 if(popup) popup.style.display = "block"; 7 }); 8 }); 9 10 const popup = document.querySelector(".popup_select_city"); 11 if(popup) { 12 popup.addEventListener("click", e => { 13 if(e.target === popup) popup.style.display = "none"; 14 }); 15 } 16 17 const closeBtn = popup?.querySelector(".popup_close"); 18 if(closeBtn) { 19 closeBtn.addEventListener("click", () => { 20 popup.style.display = "none"; 21 }); 22 } 23 24 const input = document.getElementById("citySearch"); 25 const results = document.getElementById("searchResults"); 26 let timer = null; 27 28 input.addEventListener("input", function() { 29 clearTimeout(timer); 30 let query = this.value.trim(); 31 32 if (!query) { 33 results.style.display = "none"; 34 results.innerHTML = ""; 35 return; 36 } 37 38 timer = setTimeout(() => { 39 fetch("/local/ajax/search_city.php?q=" + encodeURIComponent(query)) 40 .then(response => response.json()) 41 .then(data => { 42 results.innerHTML = ""; 43 if (data.length > 0) { 44 data.forEach(city => { 45 let wrapper = document.createElement("div"); 46 wrapper.className = "result_item"; 47 48 let link = document.createElement("a"); 49 link.href = city.URL; 50 link.textContent = city.NAME; 51 52 wrapper.appendChild(link); 53 results.appendChild(wrapper); 54 }); 55 results.style.display = "block"; 56 } else { 57 results.style.display = "none"; 58 } 59 }) 60 .catch(err => { 61 console.error("ÐÑибка поиÑка:", err); 62 }); 63 }, 300); 64 }); 65 66});
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.