PageSourceSearch

https://mrembonabudget.com/wp-content/plugins/directorist/assets/js/global-geolocation.js?ver=1791279599

js mrembonabudget.com collected 2026-10-06 09:40:57 UTC 11,267 bytes, 268 lines download raw bytes

vendor: 3,595 bytes, lines 1-88
1/******/ (function(modules) { // webpackBootstrap
2/******/ 	// The module cache
3/******/ 	var installedModules = {};
4/******/
5/******/ 	// The require function
6/******/ 	function __webpack_require__(moduleId) {
7/******/
8/******/ 		// Check if module is in cache
9/******/ 		if(installedModules[moduleId]) {
10/******/ 			return installedModules[moduleId].exports;
11/******/ 		}
12/******/ 		// Create a new module (and put it into the cache)
13/******/ 		var module = installedModules[moduleId] = {
14/******/ 			i: moduleId,
15/******/ 			l: false,
16/******/ 			exports: {}
17/******/ 		};
18/******/
19/******/ 		// Execute the module function
20/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21/******/
22/******/ 		// Flag the module as loaded
23/******/ 		module.l = true;
24/******/
25/******/ 		// Return the exports of the module
26/******/ 		return module.exports;
27/******/ 	}
28/******/
29/******/
30/******/ 	// expose the modules object (__webpack_modules__)
31/******/ 	__webpack_require__.m = modules;
32/******/
33/******/ 	// expose the module cache
34/******/ 	__webpack_require__.c = installedModules;
35/******/
36/******/ 	// define getter function for harmony exports
37/******/ 	__webpack_require__.d = function(exports, name, getter) {
38/******/ 		if(!__webpack_require__.o(exports, name)) {
39/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
40/******/ 		}
41/******/ 	};
42/******/
43/******/ 	// define __esModule on exports
44/******/ 	__webpack_require__.r = function(exports) {
45/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47/******/ 		}
48/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
49/******/ 	};
50/******/
51/******/ 	// create a fake namespace object
52/******/ 	// mode & 1: value is a module id, require it
53/******/ 	// mode & 2: merge all properties of value into the ns
54/******/ 	// mode & 4: return value when already ns object
55/******/ 	// mode & 8|1: behave like require
56/******/ 	__webpack_require__.t = function(value, mode) {
57/******/ 		if(mode & 1) value = __webpack_require__(value);
58/******/ 		if(mode & 8) return value;
59/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60/******/ 		var ns = Object.create(null);
61/******/ 		__webpack_require__.r(ns);
62/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64/******/ 		return ns;
65/******/ 	};
66/******/
67/******/ 	// getDefaultExport function for compatibility with non-harmony modules
68/******/ 	__webpack_require__.n = function(module) {
69/******/ 		var getter = module && module.__esModule ?
70/******/ 			function getDefault() { return module['default']; } :
71/******/ 			function getModuleExports() { return module; };
72/******/ 		__webpack_require__.d(getter, 'a', getter);
73/******/ 		return getter;
74/******/ 	};
75/******/
76/******/ 	// Object.prototype.hasOwnProperty.call
77/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78/******/
79/******/ 	// __webpack_public_path__
80/******/ 	__webpack_require__.p = "";
81/******/
82/******/
83/******/ 	// Load entry module and return exports
84/******/ 	return __webpack_require__(__webpack_require__.s = 19);
85/******/ })
86/************************************************************************/
87/******/ ({
88
89/***/ "./assets/src/js/global/map-scripts/geolocation.js":
90/*!*********************************************************!*\
91  !*** ./assets/src/js/global/map-scripts/geolocation.js ***!
92  \*********************************************************/
93/*! no static exports found */
94/***/ (function(module, exports) {
95
96window.addEventListener('load', function () {
97  // Add focus class to the parent field of .directorist-location-js
98  function addFocusClass(location) {
99    // Get the parent field of .directorist-location-js
100    var parentField = location.closest('.directorist-search-field');
101
102    // Add the 'input-is-focused' class if not already present
103    if (parentField && !parentField.hasClass('input-is-focused')) {
104      parentField.addClass('input-is-focused');
105    }
106  }
107  (function ($) {
108    /* get current location */
109    setTimeout(function () {
110      if (directorist.i18n_text.select_listing_map === 'google') {
111        /* Event Delegation in Vanilla JS */
112        function eventDelegation(event, selector, program) {
113          document.body.addEventListener(event, function (e) {
114            document.querySelectorAll(selector).forEach(function (elem) {
115              if (e.target === elem) {
116                program(e);
117              }
118            });
119          });
120        }
121        (function () {
122          eventDelegation('click', '.directorist-filter-location-icon > i, .directorist-filter-location-icon > span', function (e) {
123            var locationInput = e.target.closest('.directorist-search-field').querySelector('.location-name');
124            var get_lat = e.target.closest('.directorist-search-field').querySelector("#cityLat");
125            var get_lng = e.target.closest('.directorist-search-field').querySelector("#cityLng");
126            function getLocation() {
127              if (navigator.geolocation) {
128                navigator.geolocation.getCurrentPosition(showPosition, showError);
129              } else {
130                locationInput.value = 'Geolocation is not supported by this browser.';
131              }
132            }
133            getLocation();
134            function showPosition(position) {
135              lat = position.coords.latitude;
136              lon = position.coords.longitude;
137              displayCurrentLocation(lat, lon);
138              get_lat.value = lat;
139              get_lng.value = lon;
140            }
141            function showError(error) {
142              switch (error.code) {
143                case error.PERMISSION_DENIED:
144                  locationInput.value = 'User denied the request for Geolocation.';
145                  break;
146                case error.POSITION_UNAVAILABLE:
147                  locationInput.value = 'Location information is unavailable.';
148                  break;
149                case error.TIMEOUT:
150                  locationInput.value = 'The request to get user location timed out.';
151                  break;
152                case error.UNKNOWN_ERROR:
153                  locationInput.value = 'An unknown error occurred.';
154                  break;
155              }
156            }
157            function displayLocation(latitude, longitude) {
158              var geocoder;
159              geocoder = new google.maps.Geocoder();
160              var latlng = new google.maps.LatLng(latitude, longitude);
161              geocoder.geocode({
162                latLng: latlng,
163                componentRestrictions: {
164                  country: 'GB'
165                }
166              }, function (results, status) {
167                if (status == google.maps.GeocoderStatus.OK) {
168                  if (results[0]) {
169                    var add = results[0].formatted_address;
170                    var value = add.split(',');
171                    count = value.length;
172                    country = value[count - 1];
173                    state = value[count - 2];
174                    city = value[count - 3];
175                    locationInput.value = city;
176                  } else {
177                    locationInput.value = 'address not found';
178                  }
179                } else {
180                  locationInput.value = "Geocoder failed due to: ".concat(status);
181                }
182              });
183            }
184            function displayCurrentLocation(latitude, longitude) {
185              var geocoder;
186              geocoder = new google.maps.Geocoder();
187              var latlng = new google.maps.LatLng(latitude, longitude);
188              geocoder.geocode({
189                latLng: latlng
190              }, function (results, status) {
191                if (status == google.maps.GeocoderStatus.OK) {
192                  if (results[0]) {
193                    var add = results[0].formatted_address;
194                    var value = add.split(',');
195                    count = value.length;
196                    country = value[count - 1];
197                    state = value[count - 2];
198                    city = value[count - 3];
199                    locationInput.value = value;
200                    $('.directorist-location-js, .atbdp-search-address').attr("data-value", city);
201                  } else {
202                    locationInput.value = 'address not found';
203                  }
204                } else {
205                  locationInput.value = "Geocoder failed due to: ".concat(status);
206                }
207              });
208            }
209            var parentField = e.target.closest('.directorist-search-field');
210            if (parentField && !parentField.classList.contains('input-is-focused')) {
211              parentField.classList.add('input-is-focused');
212            }
213          });
214        })();
215      } else if (directorist.i18n_text.select_listing_map === 'openstreet') {
216        function displayLocation(position, event) {
217          var lat = position.coords.latitude;
218          var lng = position.coords.longitude;
219          var locIcon = event.target;
220          $.ajax({
221            url: "https://nominatim.openstreetmap.org/reverse?format=json&lon=".concat(lng, "&lat=").concat(lat),
222            type: 'GET',
223            data: {},
224            success: function success(data) {
225              $('.directorist-location-js, .atbdp-search-address').val(data.display_name);
226              $('.directorist-location-js, .atbdp-search-address').attr("data-value", data.display_name);
227              $('#cityLat').val(lat);
228              $('#cityLng').val(lng);
229              addFocusClass($('.directorist-location-js'));
230            },
231            error: function error(err) {
232              $('.directorist-location-js').val('Location not found');
233              addFocusClass($('.directorist-location-js'));
234            }
235          });
236        }
237        $('body').on("click", ".directorist-filter-location-icon", function (e) {
238          navigator.geolocation.getCurrentPosition(function (position) {
239            return displayLocation(position, e);
240          });
241
242          // let parentField = e.target.closest('.directorist-search-field');
243
244          // if (parentField && !parentField.classList.contains('input-is-focused')) {
245          //     parentField.classList.add('input-is-focused');
246          // }
247        });
248      }
249    }, 1000);
250  })(jQuery);
251});
252
253/***/ })
253,
254
255/***/ 19:
256/*!***************************************************************!*\
257  !*** multi ./assets/src/js/global/map-scripts/geolocation.js ***!
258  \***************************************************************/
259/*! no static exports found */
260/***/ (function(module, exports, __webpack_require__) {
261
262module.exports = __webpack_require__(/*! ./assets/src/js/global/map-scripts/geolocation.js */"./assets/src/js/global/map-scripts/geolocation.js");
263
264
265/***/ })
266
267/******/ });
268//# sourceMappingURL=global-geolocation.js.map

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.