1import { Controller } from "@hotwired/stimulus" 2 3// Copy-first chip (UPI handle). The tick only shows when a copy actually 4// happened; clipboard failures fall back to execCommand, then to honesty. 5export default class extends Controller { 6 static targets = ["value", "label"] 7 8 copy() { 9 const text = this.valueTarget.textContent 10 if (navigator.clipboard && navigator.clipboard.writeText) { 11 navigator.clipboard.writeText(text).then( 12 () => this.done(true), 13 () => this.done(this.legacyCopy(text)) 14 ) 15 } else { 16 this.done(this.legacyCopy(text)) 17 } 18 } 19 20 legacyCopy(text) { 21 const ta = document.createElement("textarea") 22 ta.value = text 23 ta.style.position = "fixed" 24 ta.style.opacity = "0" 25 document.body.appendChild(ta) 26 ta.select() 27 let ok = false 28 try { ok = document.execCommand("copy") } catch {} 29 document.body.removeChild(ta) 30 return ok 31 } 32 33 done(ok) { 34 this.labelTarget.textContent = ok ? "COPIED â" : "PRESS & HOLD TO COPY" 35 clearTimeout(this.timeout) 36 this.timeout = setTimeout(() => { this.labelTarget.textContent = "COPY" }, 1800) 37 } 38 39 disconnect() { 40 clearTimeout(this.timeout) 41 } 42}
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.