1import { Controller } from "@hotwired/stimulus" 2 3export default class extends Controller { 4 static values = { interval: { type: Number, default: 5000 } } 5 6 connect() { 7 this.startRefreshing() 8 document.addEventListener("visibilitychange", this.handleVisibilityChange) 9 } 10 11 disconnect() { 12 this.stopRefreshing() 13 document.removeEventListener("visibilitychange", this.handleVisibilityChange) 14 } 15 16 startRefreshing() { 17 this.timer = setInterval(() => { 18 Turbo.visit(window.location.href, { action: "replace" }) 19 }, this.intervalValue) 20 } 21 22 stopRefreshing() { 23 if (this.timer) { 24 clearInterval(this.timer) 25 this.timer = null 26 } 27 } 28 29 handleVisibilityChange = () => { 30 if (document.hidden) { 31 this.stopRefreshing() 32 } else { 33 this.startRefreshing() 34 } 35 } 36}
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.