| | |
| | | |
| | | const data = await fetchData |
| | | const container = document.getElementById("search-container") |
| | | const sidebar = container?.closest(".sidebar") as HTMLElement |
| | | const searchIcon = document.getElementById("search-icon") |
| | | const searchBar = document.getElementById("search-bar") as HTMLInputElement | null |
| | | const results = document.getElementById("results-container") |
| | |
| | | if (searchBar) { |
| | | searchBar.value = "" // clear the input when we dismiss the search |
| | | } |
| | | if (sidebar) { |
| | | sidebar.style.zIndex = "unset" |
| | | } |
| | | if (results) { |
| | | removeAllChildren(results) |
| | | } |
| | | } |
| | | |
| | | function showSearch() { |
| | | if (sidebar) { |
| | | sidebar.style.zIndex = "1" |
| | | } |
| | | container?.classList.add("active") |
| | | searchBar?.focus() |
| | | } |
| | |
| | | searchIcon?.addEventListener("click", showSearch) |
| | | searchBar?.removeEventListener("input", onType) |
| | | searchBar?.addEventListener("input", onType) |
| | | |
| | | |
| | | // setup index if it hasn't been already |
| | | if (!index) { |
| | | index = new Document({ |