| | |
| | | const data = await fetchData |
| | | const container = document.getElementById("search-container") |
| | | const sidebar = container?.closest(".sidebar") as HTMLElement |
| | | const searchIcon = document.getElementById("search-icon") |
| | | const searchButton = document.getElementById("search-button") |
| | | const searchBar = document.getElementById("search-bar") as HTMLInputElement | null |
| | | const searchLayout = document.getElementById("search-layout") |
| | | const idDataMap = Object.keys(data) as FullSlug[] |
| | |
| | | } |
| | | |
| | | searchType = "basic" // reset search type after closing |
| | | |
| | | searchButton?.focus() |
| | | } |
| | | |
| | | function showSearch(searchTypeNew: SearchType) { |
| | |
| | | |
| | | document.addEventListener("keydown", shortcutHandler) |
| | | window.addCleanup(() => document.removeEventListener("keydown", shortcutHandler)) |
| | | searchIcon?.addEventListener("click", () => showSearch("basic")) |
| | | window.addCleanup(() => searchIcon?.removeEventListener("click", () => showSearch("basic"))) |
| | | searchButton?.addEventListener("click", () => showSearch("basic")) |
| | | window.addCleanup(() => searchButton?.removeEventListener("click", () => showSearch("basic"))) |
| | | searchBar?.addEventListener("input", onType) |
| | | window.addCleanup(() => searchBar?.removeEventListener("input", onType)) |
| | | |