1import { Controller } from "@hotwired/stimulus" 2import { debounce } from "helpers/debounce" 3 4export default class extends Controller { 5 static targets = ["input", "frame"] 6 static values = { url: String, redirectUrl: String } 7 8 initialize() { 9 this.updateSearch = debounce(this.updateSearch.bind(this), 250) 10 } 11 12 updateSearch() { 13 const params = new URLSearchParams({ search_input: this.inputTarget.value }) 14 this.frameTarget.src = `${this.urlValue}?${params}` 15 } 16 17 async selectSource(event) { 18 event.preventDefault() 19 const response = await fetch(event.target.closest("a").href) 20 const json = await response.json() 21 if (response.ok) { 22 window.location = this.redirectUrlValue 23 } else { 24 this.frameTarget.innerHTML = `<span>${json.error}</span>` 25 } 26 } 27}
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.