PageSourceSearch

https://shsselect.com/assets/controllers/geolocation_controller-55628242.js

js shsselect.com collected 2026-09-24 18:24:51 UTC 2,448 bytes, 79 lines download raw bytes

1import { Controller } from "@hotwired/stimulus"
2
3export default class extends Controller {
4  static targets = ["form", "searchButton", "locationStatus"]
5
6  connect() {
7    console.log("Geolocation controller connected")
8    if (!("geolocation" in navigator)) {
9      this.locationStatusTarget.textContent = "Geolocation is not supported by your browser"
10      this.searchButtonTarget.disabled = true
11    }
12  }
13
14  findSchools(event) {
15    console.log("findSchools triggered")
16    event.preventDefault()
17    this.locationStatusTarget.textContent = "Getting your location... Please allow location access if prompted."
18    this.searchButtonTarget.disabled = true
19
20    navigator.geolocation.getCurrentPosition(
21      this.handleSuccess.bind(this),
22      this.handleError.bind(this),
23      { 
24        enableHighAccuracy: true,
25        timeout: 15000,
26        maximumAge: 0
27      }
28    )
29  }
30
31  handleSuccess(position) {
32    console.log("Location obtained:", position.coords)
33    const form = this.formTarget
34    const latitude = position.coords.latitude
35    const longitude = position.coords.longitude
36
37    // Remove any existing inputs
38    form.querySelector('input[name="latitude"]')?.remove()
39    form.querySelector('input[name="longitude"]')?.remove()
40
41    const latitudeInput = document.createElement('input')
42    latitudeInput.type = 'hidden'
43    latitudeInput.name = 'latitude'
44    latitudeInput.value = latitude
45
46    const longitudeInput = document.createElement('input')
47    longitudeInput.type = 'hidden'
48    longitudeInput.name = 'longitude'
49    longitudeInput.value = longitude
50
51    form.appendChild(latitudeInput)
52    form.appendChild(longitudeInput)
53    
54    this.locationStatusTarget.textContent = "Location found! Searching for schools..."
55    form.submit()
56  }
57
58  handleError(error) {
59    console.error("Geolocation error:", error)
60    let errorMessage = "Error getting your location. "
61    
62    switch(error.code) {
63      case error.PERMISSION_DENIED:
64        errorMessage += "Please allow location access and try again."
65        break
66      case error.POSITION_UNAVAILABLE:
67        errorMessage += "Location information is unavailable."
68        break
69      case error.TIMEOUT:
70        errorMessage += "Location request timed out. Please try again."
71        break
72      default:
73        errorMessage += error.message
74    }
75    
76    this.locationStatusTarget.textContent = errorMessage
77    this.searchButtonTarget.disabled = false
78  }
79} 

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.