Finish green pool report submission
Also start the pattern of breaking out pool pages together in their own file. I think its easier to read this way.
This commit is contained in:
parent
9680fb6a68
commit
01ed2d6086
31 changed files with 5925 additions and 375 deletions
|
|
@ -66,12 +66,16 @@ function displaySuggestions(suggestions) {
|
|||
}
|
||||
// Handle click on a suggestion
|
||||
item.addEventListener('click', function() {
|
||||
addressInput.value = suggestion.properties.name || suggestion.properties.full_address;
|
||||
// Hide the suggestions container
|
||||
setLocationInputs(suggestion);
|
||||
suggestionsContainer.classList.add('d-none');
|
||||
|
||||
// Display the selected location details
|
||||
displaySelectedLocation(suggestion);
|
||||
setMapMarker(suggestion.geometry.coordinates);
|
||||
const locationSelected = new CustomEvent("locationselected", {
|
||||
detail: {
|
||||
coordinates: suggestion.geometry.coordinates,
|
||||
},
|
||||
});
|
||||
suggestionsContainer.dispatchEvent(locationSelected);
|
||||
});
|
||||
|
||||
suggestionsContainer.appendChild(item);
|
||||
|
|
@ -155,18 +159,45 @@ function onAddressInput() {
|
|||
}, 300);
|
||||
}
|
||||
|
||||
function setLocationInputs(suggestion) {
|
||||
let address = document.getElementById('address');
|
||||
let country = document.getElementById('address-country');
|
||||
let latitude = document.getElementById('latitude');
|
||||
let longitude = document.getElementById('longitude');
|
||||
let latlngAccuracyType = document.getElementById('latlng-accuracy-type');
|
||||
let postcode = document.getElementById('address-postcode');
|
||||
let place = document.getElementById('address-place');
|
||||
let region = document.getElementById('address-region');
|
||||
let street = document.getElementById('address-street');
|
||||
|
||||
// Extract context data from properties
|
||||
const props = suggestion.properties;
|
||||
const context = props.context || {};
|
||||
|
||||
// Populate structured fields
|
||||
address.value = props.full_address;
|
||||
country.value = context.country.name;
|
||||
latitude.value = props.coordinates.latitude;
|
||||
longitude.value = props.coordinates.longitude;
|
||||
latlngAccuracyType.value = props.coordinates.accuracy;
|
||||
postcode.value = context.postcode.name;
|
||||
place.value = context.place.name;
|
||||
region.value = context.region.name;
|
||||
street.value = context.country.name;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const addressInput = document.getElementById('addressInput');
|
||||
const address = document.getElementById('address');
|
||||
const suggestionsContainer = document.getElementById('suggestions');
|
||||
const locationDetails = document.getElementById('locationDetails');
|
||||
|
||||
|
||||
// Listen for input changes
|
||||
addressInput.addEventListener('input', onAddressInput);
|
||||
address.addEventListener('input', onAddressInput);
|
||||
|
||||
// Close suggestions when clicking outside
|
||||
document.addEventListener('click', function(event) {
|
||||
if (!addressInput.contains(event.target) && !suggestionsContainer.contains(event.target)) {
|
||||
if (!address.contains(event.target) && !suggestionsContainer.contains(event.target)) {
|
||||
suggestionsContainer.classList.add('d-none');
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue