1import { Controller } from "@hotwired/stimulus"; 2 3export default class extends Controller { 4 static targets = ["form", "latitude", "longitude", "error"]; 5 6 locate(event) { 7 event.preventDefault(); 8 if (!navigator.geolocation) 9 return this.#failed( 10 "Location is not available. Please enter your ZIP code.", 11 ); 12 13 navigator.geolocation.getCurrentPosition( 14 ({ coords }) => { 15 this.latitudeTarget.value = coords.latitude; 16 this.longitudeTarget.value = coords.longitude; 17 const postalCode = this.formTarget.querySelector( 18 '[name="postal_code"]', 19 ); 20 postalCode.required = false; 21 postalCode.value = ""; 22 this.formTarget.requestSubmit(); 23 }, 24 () => 25 this.#failed( 26 "We couldn't get your location. Please enter your ZIP code.", 27 ), 28 ); 29 } 30 31 #failed(message) { 32 this.errorTarget.textContent = message; 33 this.errorTarget.hidden = false; 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.