PageSourceSearch

https://littlebirdelectronics.com.au/assets/controllers/ecommerce/remove_collect_controller-18bea4a2.js

js littlebirdelectronics.com.au collected 2026-09-25 14:11:15 UTC 1,462 bytes, 54 lines download raw bytes

1import { Controller } from "@hotwired/stimulus"
2
3export default class extends Controller {
4  static values = { url: String }
5  static targets = ["content", "undoBar"]
6
7  remove(event) {
8    event.preventDefault()
9    this.contentTarget.classList.add("hidden")
10    this.undoBarTarget.classList.remove("hidden")
11    this.timer = setTimeout(() => this.confirmRemove(), 5000)
12    this.boundKeydown = this.handleKeydown.bind(this)
13    document.addEventListener("keydown", this.boundKeydown)
14  }
15
16  undo() {
17    clearTimeout(this.timer)
18    this.removeKeydownListener()
19    this.undoBarTarget.classList.add("hidden")
20    this.contentTarget.classList.remove("hidden")
21  }
22
23  handleKeydown(event) {
24    if ((event.metaKey || event.ctrlKey) && event.key === "z") {
25      event.preventDefault()
26      this.undo()
27    }
28  }
29
30  confirmRemove() {
31    this.removeKeydownListener()
32    const token = document.querySelector('meta[name="csrf-token"]')?.content
33    fetch(this.urlValue, {
34      method: "DELETE",
35      headers: {
36        "X-CSRF-Token": token,
37        "Accept": "text/vnd.turbo-stream.html"
38      }
39    }).then(response => response.text())
40      .then(html => Turbo.renderStreamMessage(html))
41  }
42
43  removeKeydownListener() {
44    if (this.boundKeydown) {
45      document.removeEventListener("keydown", this.boundKeydown)
46      this.boundKeydown = null
47    }
48  }
49
50  disconnect() {
51    if (this.timer) clearTimeout(this.timer)
52    this.removeKeydownListener()
53  }
54}

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.