1import { Controller } from "@hotwired/stimulus" 2 3export default class extends Controller { 4 static targets = ["input"] 5 6 connect() { 7 this.frameLoadHandler = () => this.search() 8 this.element.addEventListener("turbo:frame-load", this.frameLoadHandler) 9 } 10 11 disconnect() { 12 this.element.removeEventListener("turbo:frame-load", this.frameLoadHandler) 13 } 14 15 search() { 16 const term = (this.inputTarget.value || "").toLowerCase() 17 const rows = this.element.querySelectorAll("[data-search-address]") 18 const isSearching = term !== "" 19 20 rows.forEach(row => { 21 if (!isSearching) { 22 row.classList.remove("search-hidden") 23 // Restore paginated hidden state when search is cleared 24 if (row.dataset.paginated === "true") { 25 row.classList.add("hidden") 26 } 27 return 28 } 29 30 const address = (row.dataset.searchAddress || "").toLowerCase() 31 const type = (row.dataset.searchType || "").toLowerCase() 32 const number = (row.dataset.searchNumber || "").toLowerCase() 33 const status = (row.dataset.searchStatus || "").toLowerCase() 34 35 const match = address.includes(term) || type.includes(term) || number.includes(term) || status.includes(term) 36 row.classList.toggle("search-hidden", !match) 37 // Temporarily reveal paginated rows that match the search 38 if (match) { 39 row.classList.remove("hidden") 40 } 41 }) 42 43 // Hide "Show more" buttons during active search without affecting their permanent hidden state 44 this.element.querySelectorAll("[data-show-more-target='button']").forEach(btn => { 45 btn.classList.toggle("search-hidden", isSearching) 46 }) 47 } 48};
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.