PageSourceSearch

https://hackorum.dev/assets/controllers/reply_quote_controller-d5b61f14.js

js hackorum.dev collected 2026-09-28 07:00:38 UTC 968 bytes, 35 lines download raw bytes

1import { Controller } from "@hotwired/stimulus"
2
3export default class extends Controller {
4  connect() {
5    this._stored = ""
6    this._onMouseUp = () => { this._stored = this._selectionInBody() }
7    this.element.addEventListener("mouseup", this._onMouseUp)
8  }
9
10  disconnect() {
11    this.element.removeEventListener("mouseup", this._onMouseUp)
12  }
13
14  injectSelection(event) {
15    const text = this._stored || this._selectionInBody()
16    this._stored = ""
17    if (!text) return
18
19    const input = document.createElement("input")
20    input.type = "hidden"
21    input.name = "selected_text"
22    input.value = text
23    event.target.appendChild(input)
24  }
25
26  _selectionInBody() {
27    const sel = window.getSelection()
28    if (!sel || sel.isCollapsed) return ""
29    const range = sel.getRangeAt(0)
30    const body = this.element.querySelector(".message-body")
31    return (body && body.contains(range.commonAncestorContainer))
32      ? sel.toString().trim()
33      : ""
34  }
35}

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.