1var MeridianApp = angular.module("MeridianApp"); 2 3MeridianApp.controller("dealerFinderController", function ($scope, $rootScope, $http) { 4 $scope.searchText = ""; 5 $scope.searchTextStatic = ''; 6 $scope.geoCodeResponse = null; 7 $scope.dataLoading = false; 8 9 $scope.checkEnter = function (e) { 10 if (e.which === 13) { 11 $scope.doSearch(); 12 } 13 } 14 15 $scope.init = function (lat, long, postCode) { 16 var location = { 17 latitude: lat ?? 52.35195290522457, 18 longitude: long ?? -0.1881304173615008, 19 locationName: postCode ?? "MeridianHQ" 20 }; 21 $scope.showDealers(location); 22 } 23 24 $scope.doSearch = function () { 25 if ($scope.searchText.length > 0) { 26 $scope.searchTextStatic = $scope.searchText; 27 $scope.geoCodeResponse = null; 28 $scope.dealers = []; 29 30 $http.get('/umbraco/api/geocoding/forwardgeocode?keyword=' + $scope.searchText) 31 .then(function requestSuccess(response) { 32 $scope.geoCodeResponse = response.data; 33 }, 34 function requestError(response) { 35 $scope.geoCodeResponse = null; 36 }); 37 } 38 } 39 40 $scope.myLocationDealers = function () { 41 navigator.geolocation.getCurrentPosition(function (position) { 42 var location = { 43 latitude: position.coords.latitude, 44 longitude: position.coords.longitude, 45 locationName: "My Location" 46 }; 47 $scope.showDealers(location); 48 }); 49 50 } 51 52 $scope.showDealers = function (result) { 53 $scope.dealers = []; 54 55 if (result == null || result.latitude == null || result.longitude == null) return; 56 57 $scope.searchText = result.locationName; 58 $scope.geoCodeResponse = null; 59 60 var lat = parseFloat(result.latitude); 61 var long = parseFloat(result.longitude); 62 63 64 $scope.dataLoading = true; 65 66 $http.get('/umbraco/api/dealersearch/search?userLatitude=' + lat + '&userLongitude=' + long) 67 .then(function searchSuccess(response) { 68 $scope.dataLoading = false; 69 $rootScope.$emit('userLocation', { 'latitude': lat, 'longitude': long }); 70 $rootScope.$emit('dealersResult', { 'dealers': response.data }); 71 $scope.dealers = response.data; 72 }, 73 function searchError(response) { 74 $scope.dataLoading = false; 75 }); 76 } 77 78 $scope.formattedDealerAddress = function (dealer) { 79 if (dealer == null) return null; 80 81 var addressParts = []; 82 if (dealer.addressLineOne !== '') addressParts.push(dealer.addressLineOne); 83 if (dealer.addressLineTwo !== '') addressParts.push(dealer.addressLineTwo); 84 if (dealer.townCity !== '') addressParts.push(dealer.townCity); 85 if (dealer.countyArea !== '') addressParts.push(dealer.countyArea); 86 if (dealer.postCode !== '') addressParts.push(dealer.postCode); 87 88 return addressParts.join(', '); 89 } 90});
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.