X7ROOT File Manager
PHP:
7.4.33
OS:
Linux
User:
br4sil
Root
/
home
/
br4sil
/
public_html
/
maranhao
📤 Upload
📝 New File
📁 New Folder
Close
Editing: search-results.js
let lastScrollTop = 0 let isScrolling = false // Header scroll behavior function handleHeaderScroll() { const header = document.getElementById("stickyHeader") if (!header) return const scrollTop = window.pageYOffset || document.documentElement.scrollTop if (scrollTop > lastScrollTop && scrollTop > 100) { // Scrolling down & past threshold header.classList.add("hidden") header.classList.remove("visible") } else if (scrollTop < lastScrollTop || scrollTop <= 100) { // Scrolling up or at top header.classList.remove("hidden") header.classList.add("visible") } lastScrollTop = scrollTop <= 0 ? 0 : scrollTop } // Throttle scroll events for better performance function throttleScroll() { if (!isScrolling) { window.requestAnimationFrame(handleHeaderScroll) isScrolling = true setTimeout(() => { isScrolling = false }, 16) } } // Add scroll listener window.addEventListener("scroll", throttleScroll) // Initialize the page document.addEventListener("DOMContentLoaded", () => { setupEventListeners() populateSearchFields() }) function setupEventListeners() { // Search form const searchForm = document.getElementById("searchForm") if (searchForm) { searchForm.addEventListener("submit", handleSearch) } // Mobile search toggle const mobileSearchToggle = document.getElementById("mobileSearchToggle") const searchContainer = document.getElementById("searchContainerInline") if (mobileSearchToggle && searchContainer) { mobileSearchToggle.addEventListener("click", () => { searchContainer.classList.toggle("mobile-hidden") searchContainer.classList.toggle("mobile-visible") // Change icon based on state const icon = mobileSearchToggle.querySelector("i") if (searchContainer.classList.contains("mobile-visible")) { icon.className = "fas fa-times" } else { icon.className = "fas fa-search" } }) } // Close search when clicking outside (mobile only) document.addEventListener("click", (e) => { if (window.innerWidth <= 768) { const searchContainer = document.getElementById("searchContainerInline") const mobileToggle = document.getElementById("mobileSearchToggle") if ( searchContainer && mobileToggle && !searchContainer.contains(e.target) && !mobileToggle.contains(e.target) && searchContainer.classList.contains("mobile-visible") ) { searchContainer.classList.add("mobile-hidden") searchContainer.classList.remove("mobile-visible") const icon = mobileToggle.querySelector("i") icon.className = "fas fa-search" } } }) } function handleSearch(e) { e.preventDefault() const query = document.getElementById("searchInput").value const city = document.getElementById("citySelect").value // Update URL and reload results const newUrl = `search-results.html?q=${encodeURIComponent(query)}&city=${encodeURIComponent(city)}` window.history.pushState({}, "", newUrl) // In a real application, you would fetch new results here console.log("New search:", { query, city }) } function populateSearchFields() { const urlParams = new URLSearchParams(window.location.search) const query = urlParams.get("q") || "" const city = urlParams.get("city") || "" const searchInput = document.getElementById("searchInput") const citySelect = document.getElementById("citySelect") if (searchInput) searchInput.value = query if (citySelect) citySelect.value = city } // Utility function to get URL parameters function getUrlParameter(name) { name = name.replace(/[[]/, "\\[").replace(/[\]]/, "\\]") const regex = new RegExp("[\\?&]" + name + "=([^&#]*)") const results = regex.exec(location.search) return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")) }
Save
Cancel