1import { Controller } from '@hotwired/stimulus' 2import { getCSRFToken } from 'controllers/helpers/csrf_token'; 3 4export default class extends Controller { 5 6 static targets = ["travelTimeSection"] 7 8 connect() { 9 this.maybeMakeTravelTimeRequest() 10 } 11 12 maybeMakeTravelTimeRequest() { 13 let propertySlugs = this.travelTimeSectionTargets.map((target) => target.dataset.slug) 14 if (propertySlugs.length == 0) { 15 return false 16 } 17 let locationSlug = this.element.dataset.locationSlug 18 let travelTimeMethod = this.element.dataset.travelTimeMethod 19 20 let query = new URLSearchParams() 21 query.append("property_slugs", propertySlugs) 22 query.append("location_slug", locationSlug) 23 query.append("travel_time_method", travelTimeMethod) 24 25 const token = getCSRFToken(); 26 fetch("/travel_times?" + query, { 27 method: "GET", 28 headers: { 29 "X-CSRF-Token": token, 30 "Content-Type": "text/vnd.turbo-stream.html", 31 }, 32 }).then((response) => { 33 response.text().then((html) => { 34 Turbo.renderStreamMessage(html) 35 }); 36 }); 37 } 38}
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.