1document.addEventListener('alpine:init', () => { 2 Alpine.data('findASalesRep', (values) => ({ 3 currentZip: '', 4 loading: false, 5 salesReps: [], 6 apiEndpoint: 'https://portal.atlasroofing.com/includes/functions/find_a_sales_rep.php', 7 resultsRetrieved: false, 8 9 10 init() { 11 if(values && values?.zipCode) { 12 this.currentZip = values.zipCode 13 this.fetchSalesReps() 14 } else { 15 16 const onSuccess = (zip) => { 17 this.currentZip = zip 18 console.log(this.currentZip) 19 this.fetchSalesReps() 20 } 21 22 window.getLocation( 23 (position) => window.findZipCode(position, onSuccess) 24 ) 25 } 26 }, 27 async fetchSalesReps() { 28 if(!this.currentZip) { 29 return 30 } 31 32 try { 33 this.salesReps = []; 34 this.loading = true 35 const rawResponse = await fetch(`${this.apiEndpoint}?search_zip_code=${this.currentZip}`) 36 const response = await rawResponse.json() 37 this.salesReps = response.data 38 this.loading = false 39 } catch (error) { 40 console.error(error) 41 } finally { 42 this.loading = false 43 this.resultsRetrieved = true 44 } 45 }, 46 47 }) 48 ) 49});
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.