Added weather api preparations and entrypoint for dockerfile

This commit is contained in:
Joren de Graaf
2026-08-12 14:46:12 +02:00
parent 6a20cb80ca
commit 4aaafa7493
14 changed files with 319 additions and 14 deletions
+12 -3
View File
@@ -5,7 +5,12 @@ window.htmx = htmx;
document.addEventListener('click', (event) => {
const button = event.target.closest('[data-weather-location]');
if (!button || !navigator.geolocation) return;
if (!button) return;
const status = document.querySelector('[data-weather-location-status]');
if (!navigator.geolocation) {
if (status) status.textContent = 'Your browser does not support location services.';
return;
}
navigator.geolocation.getCurrentPosition(async ({coords}) => {
const payload = new URLSearchParams({
@@ -18,8 +23,12 @@ document.addEventListener('click', (event) => {
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: payload,
});
if (response.ok) {
window.location.reload();
if (!response.ok) {
if (status) status.textContent = 'Location could not be saved.';
return;
}
window.location.reload();
}, () => {
if (status) status.textContent = 'Location permission was not granted.';
});
});