Change Location
Find awesome listings near you!
;/* 🔒 ATTENTION JAVA EN PLUS DANS /STRATO-apps/wordpress_01/app/wp-content/plugins/aakd-cuisiniste-ferme/functions.php*/
/* 🔒 KILL GOOGLE GEOCODE GEOdirectory – AVANT TOUT */
(function(){
// Neutralise Google Places
if (window.google && google.maps && google.maps.places) {
google.maps.places.Autocomplete = function(){};
} // Neutralise fonctions GeoDirectory connues
window.geodir_geocode_address = function(){ return false; };
window.geodir_fill_location = function(){ return false; };
window.geodir_location_autocomplete = function(){ return false; }; // Supprime l'alerte Google
window.alert = (function(oldAlert){
return function(msg){
if (
typeof msg === 'string' &&
msg.includes('REQUEST_DENIED')
) {
return; // silence
}
oldAlert(msg);
};
})(window.alert);
})();
document.addEventListener("DOMContentLoaded", function () { if (window.AAKD_PAGE_INIT) return;
window.AAKD_PAGE_INIT = true; const form = document.querySelector("form.geodir-listing-search");
if (!form) return; const inputNear = form.querySelector("input.snear");
const latInput = form.querySelector(".sgeo_lat");
const lonInput = form.querySelector(".sgeo_lon");
const btnSearch = form.querySelector(".geodir_submit_search"); if (!inputNear || !latInput || !lonInput || !btnSearch) return; /* 🔒 Neutraliser GeoDirectory / Google */
if (window.geodir_geocode_address) {
window.geodir_geocode_address = function(){ return false; };
} /* 🧠 Résolution unique via BDD */
const resolveAndSubmit = (city) => { fetch(window.AAKD_AJAX_URL, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
body: new URLSearchParams({
action: "aakd_get_city_coords",
city: city
})
})
.then(r => r.json())
.then(res => { if (!res.success) {
alert("Ville non reconnue");
return;
} latInput.value = res.data.lat;
lonInput.value = res.data.lon; form.submit(); // submit FINAL
});
}; /* ⌨️ FRAPPE CLAVIER → clic bouton */
btnSearch.addEventListener("click", function (e) {
e.preventDefault(); const city = inputNear.value.trim();
if (!city) return; latInput.value = '';
lonInput.value = ''; resolveAndSubmit(city);
}); /* 🎤 MICRO (inchangé) */
window.addEventListener("aakd:voice-city", (e) => {
if (!e.detail?.city) return; inputNear.value = e.detail.city;
latInput.value = '';
lonInput.value = ''; resolveAndSubmit(e.detail.city);
}); });;