Added weather api preparations and entrypoint for dockerfile
This commit is contained in:
+12
-3
@@ -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.';
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user