WIP: weather integration

This commit is contained in:
Joren de Graaf
2026-08-11 21:11:31 +02:00
parent f63134d00f
commit 6a20cb80ca
30 changed files with 1054 additions and 31 deletions
+21
View File
@@ -2,3 +2,24 @@ import './styles/app.scss';
import htmx from 'htmx.org';
window.htmx = htmx;
document.addEventListener('click', (event) => {
const button = event.target.closest('[data-weather-location]');
if (!button || !navigator.geolocation) return;
navigator.geolocation.getCurrentPosition(async ({coords}) => {
const payload = new URLSearchParams({
_token: button.dataset.locationToken,
latitude: String(coords.latitude),
longitude: String(coords.longitude),
});
const response = await fetch(button.dataset.locationUrl, {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: payload,
});
if (response.ok) {
window.location.reload();
}
});
});