MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
// The form is already present in the DOM, so we can run immediately | // The form is already present in the DOM, so we can run immediately | ||
$(function() { | $(function() { | ||
Revision as of 15:16, 14 February 2026
// The form is already present in the DOM, so we can run immediately
$(function() {
const addr = $('input[name="Place[address]"]');
const lat = $('input[name="Place[latitude]"]');
const lon = $('input[name="Place[longitude]"]');
console.log("Address fields found:", addr.length);
if (addr.length === 0) {
console.log("Address field not found");
return;
}
addr.on('change', function() {
console.log("Address changed:", addr.val()); // <— ADD THIS LINE
const q = encodeURIComponent(addr.val());
if (!q) return;
const url = 'https://nominatim.openstreetmap.org/search?format=json&q=' + q;
$.getJSON(url, function(data) {
if (data && data.length > 0) {
lat.val(data[0].lat);
lon.val(data[0].lon);
}
});
});
});