Favoriten gefixt

This commit is contained in:
Eskimue
2026-04-05 15:03:36 +02:00
parent 337dd75784
commit 5dfc805915
3 changed files with 393 additions and 8 deletions
+127
View File
@@ -350,3 +350,130 @@
[Sun Apr 5 14:33:51 2026] 127.0.0.1:49497 Closing
[Sun Apr 5 14:33:53 2026] 127.0.0.1:62595 [200]: GET /favicon.ico
[Sun Apr 5 14:33:53 2026] 127.0.0.1:62595 Closing
[Sun Apr 5 14:37:33 2026] 127.0.0.1:63475 Accepted
[Sun Apr 5 14:37:36 2026] 127.0.0.1:63475 [200]: GET /sternbedeckungen.php
[Sun Apr 5 14:37:36 2026] 127.0.0.1:63475 Closing
[Sun Apr 5 14:37:36 2026] 127.0.0.1:50828 Accepted
[Sun Apr 5 14:37:36 2026] 127.0.0.1:50828 [200]: GET /css/style.css
[Sun Apr 5 14:37:36 2026] 127.0.0.1:50828 Closing
[Sun Apr 5 14:37:36 2026] 127.0.0.1:53794 Accepted
[Sun Apr 5 14:37:36 2026] 127.0.0.1:53794 [200]: GET /js/astronomy.browser.min.js
[Sun Apr 5 14:37:36 2026] 127.0.0.1:53794 Closing
[Sun Apr 5 14:37:36 2026] 127.0.0.1:51101 Accepted
[Sun Apr 5 14:37:36 2026] 127.0.0.1:57430 Accepted
[Sun Apr 5 14:37:36 2026] 127.0.0.1:51101 [200]: GET /images/star16x16.png
[Sun Apr 5 14:37:36 2026] 127.0.0.1:57430 [200]: GET /images/star16x16_rays.png
[Sun Apr 5 14:37:36 2026] 127.0.0.1:51101 Closing
[Sun Apr 5 14:37:36 2026] 127.0.0.1:57430 Closing
[Sun Apr 5 14:37:36 2026] 127.0.0.1:56849 Accepted
[Sun Apr 5 14:37:38 2026] 127.0.0.1:56849 [200]: GET /favicon.ico
[Sun Apr 5 14:37:38 2026] 127.0.0.1:56849 Closing
[Sun Apr 5 14:37:38 2026] 127.0.0.1:53001 Accepted
[Sun Apr 5 14:37:39 2026] 127.0.0.1:53001 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:39 2026] 127.0.0.1:53001 Closing
[Sun Apr 5 14:37:50 2026] 127.0.0.1:63695 Accepted
[Sun Apr 5 14:37:50 2026] 127.0.0.1:63695 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:50 2026] 127.0.0.1:63695 Closing
[Sun Apr 5 14:37:50 2026] 127.0.0.1:56501 Accepted
[Sun Apr 5 14:37:51 2026] 127.0.0.1:56501 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:51 2026] 127.0.0.1:56501 Closing
[Sun Apr 5 14:37:51 2026] 127.0.0.1:53862 Accepted
[Sun Apr 5 14:37:52 2026] 127.0.0.1:53862 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:52 2026] 127.0.0.1:53862 Closing
[Sun Apr 5 14:37:52 2026] 127.0.0.1:55669 Accepted
[Sun Apr 5 14:37:52 2026] 127.0.0.1:55669 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:52 2026] 127.0.0.1:55669 Closing
[Sun Apr 5 14:37:52 2026] 127.0.0.1:56347 Accepted
[Sun Apr 5 14:37:53 2026] 127.0.0.1:56347 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:53 2026] 127.0.0.1:56347 Closing
[Sun Apr 5 14:37:53 2026] 127.0.0.1:56477 Accepted
[Sun Apr 5 14:37:54 2026] 127.0.0.1:56477 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:54 2026] 127.0.0.1:56477 Closing
[Sun Apr 5 14:37:55 2026] 127.0.0.1:53425 Accepted
[Sun Apr 5 14:37:56 2026] 127.0.0.1:53425 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:56 2026] 127.0.0.1:53425 Closing
[Sun Apr 5 14:37:56 2026] 127.0.0.1:60491 Accepted
[Sun Apr 5 14:37:56 2026] 127.0.0.1:60491 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:56 2026] 127.0.0.1:60491 Closing
[Sun Apr 5 14:37:56 2026] 127.0.0.1:53960 Accepted
[Sun Apr 5 14:37:57 2026] 127.0.0.1:53960 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:57 2026] 127.0.0.1:53960 Closing
[Sun Apr 5 14:37:57 2026] 127.0.0.1:52660 Accepted
[Sun Apr 5 14:37:57 2026] 127.0.0.1:52660 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:57 2026] 127.0.0.1:52660 Closing
[Sun Apr 5 14:37:58 2026] 127.0.0.1:49392 Accepted
[Sun Apr 5 14:37:58 2026] 127.0.0.1:49392 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:58 2026] 127.0.0.1:49392 Closing
[Sun Apr 5 14:37:58 2026] 127.0.0.1:59111 Accepted
[Sun Apr 5 14:37:59 2026] 127.0.0.1:59111 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:37:59 2026] 127.0.0.1:59111 Closing
[Sun Apr 5 14:37:59 2026] 127.0.0.1:62989 Accepted
[Sun Apr 5 14:38:00 2026] 127.0.0.1:62989 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:00 2026] 127.0.0.1:62989 Closing
[Sun Apr 5 14:38:00 2026] 127.0.0.1:61425 Accepted
[Sun Apr 5 14:38:00 2026] 127.0.0.1:61425 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:00 2026] 127.0.0.1:61425 Closing
[Sun Apr 5 14:38:00 2026] 127.0.0.1:64278 Accepted
[Sun Apr 5 14:38:01 2026] 127.0.0.1:64278 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:01 2026] 127.0.0.1:64278 Closing
[Sun Apr 5 14:38:01 2026] 127.0.0.1:49551 Accepted
[Sun Apr 5 14:38:01 2026] 127.0.0.1:49551 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:01 2026] 127.0.0.1:49551 Closing
[Sun Apr 5 14:38:02 2026] 127.0.0.1:61669 Accepted
[Sun Apr 5 14:38:02 2026] 127.0.0.1:61669 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:02 2026] 127.0.0.1:61669 Closing
[Sun Apr 5 14:38:02 2026] 127.0.0.1:55531 Accepted
[Sun Apr 5 14:38:03 2026] 127.0.0.1:55531 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:03 2026] 127.0.0.1:55531 Closing
[Sun Apr 5 14:38:03 2026] 127.0.0.1:55255 Accepted
[Sun Apr 5 14:38:04 2026] 127.0.0.1:55255 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:04 2026] 127.0.0.1:55255 Closing
[Sun Apr 5 14:38:04 2026] 127.0.0.1:57557 Accepted
[Sun Apr 5 14:38:05 2026] 127.0.0.1:57557 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:05 2026] 127.0.0.1:57557 Closing
[Sun Apr 5 14:38:05 2026] 127.0.0.1:50586 Accepted
[Sun Apr 5 14:38:06 2026] 127.0.0.1:50586 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:06 2026] 127.0.0.1:50586 Closing
[Sun Apr 5 14:38:06 2026] 127.0.0.1:64881 Accepted
[Sun Apr 5 14:38:06 2026] 127.0.0.1:64881 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:06 2026] 127.0.0.1:64881 Closing
[Sun Apr 5 14:38:06 2026] 127.0.0.1:51722 Accepted
[Sun Apr 5 14:38:07 2026] 127.0.0.1:51722 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:07 2026] 127.0.0.1:51722 Closing
[Sun Apr 5 14:38:07 2026] 127.0.0.1:55884 Accepted
[Sun Apr 5 14:38:07 2026] 127.0.0.1:55884 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:07 2026] 127.0.0.1:55884 Closing
[Sun Apr 5 14:38:08 2026] 127.0.0.1:55037 Accepted
[Sun Apr 5 14:38:08 2026] 127.0.0.1:55037 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:08 2026] 127.0.0.1:55037 Closing
[Sun Apr 5 14:38:08 2026] 127.0.0.1:53400 Accepted
[Sun Apr 5 14:38:09 2026] 127.0.0.1:53400 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:09 2026] 127.0.0.1:53400 Closing
[Sun Apr 5 14:38:09 2026] 127.0.0.1:63405 Accepted
[Sun Apr 5 14:38:10 2026] 127.0.0.1:63405 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:10 2026] 127.0.0.1:63405 Closing
[Sun Apr 5 14:38:10 2026] 127.0.0.1:55186 Accepted
[Sun Apr 5 14:38:10 2026] 127.0.0.1:55186 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:10 2026] 127.0.0.1:55186 Closing
[Sun Apr 5 14:38:10 2026] 127.0.0.1:50160 Accepted
[Sun Apr 5 14:38:11 2026] 127.0.0.1:50160 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:11 2026] 127.0.0.1:50160 Closing
[Sun Apr 5 14:38:11 2026] 127.0.0.1:56629 Accepted
[Sun Apr 5 14:38:11 2026] 127.0.0.1:56629 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:38:11 2026] 127.0.0.1:56629 Closing
[Sun Apr 5 14:40:25 2026] 127.0.0.1:65518 Accepted
[Sun Apr 5 14:40:25 2026] 127.0.0.1:65518 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:40:25 2026] 127.0.0.1:65518 Closing
[Sun Apr 5 14:40:25 2026] 127.0.0.1:50591 Accepted
[Sun Apr 5 14:40:32 2026] 127.0.0.1:50591 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:40:32 2026] 127.0.0.1:50591 Closing
[Sun Apr 5 14:40:38 2026] 127.0.0.1:60053 Accepted
[Sun Apr 5 14:40:39 2026] 127.0.0.1:60053 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:40:39 2026] 127.0.0.1:60053 Closing
[Sun Apr 5 14:40:39 2026] 127.0.0.1:58428 Accepted
[Sun Apr 5 14:40:44 2026] 127.0.0.1:58428 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:40:44 2026] 127.0.0.1:58428 Closing
[Sun Apr 5 14:40:48 2026] 127.0.0.1:54921 Accepted
[Sun Apr 5 14:40:50 2026] 127.0.0.1:54921 [200]: POST /sternbedeckungen.php
[Sun Apr 5 14:40:50 2026] 127.0.0.1:54921 Closing
[Sun Apr 5 14:40:50 2026] 127.0.0.1:61192 Accepted
+8
View File
@@ -1301,6 +1301,12 @@ footer a:hover { color: var(--gold); }
line-height: 1.4;
}
.favorites-loading-hint-error {
border-color: rgba(200, 60, 60, 0.35);
background: rgba(200, 60, 60, 0.12);
color: #f08080;
}
.favorites-loading-form.is-loading .btn {
opacity: 0.75;
cursor: wait;
@@ -1439,6 +1445,8 @@ footer a:hover { color: var(--gold); }
border: none;
padding: 0;
background: transparent;
margin: auto;
max-width: min(92vw, 560px);
}
.admin-dialog::backdrop {
+258 -8
View File
@@ -123,6 +123,53 @@ function countUserRows(PDO $pdo, string $tableName, int $userId): int
return (int) $stmtCount->fetchColumn();
}
function validateLocationForm(array $input, array &$errors): array
{
$name = trim((string) ($input['name'] ?? ''));
$latitude = trim((string) ($input['latitude'] ?? ''));
$longitude = trim((string) ($input['longitude'] ?? ''));
$elevation = trim((string) ($input['elevation'] ?? ''));
$timezone = trim((string) ($input['timezone'] ?? 'Europe/Berlin'));
if ($name === '') {
$errors[] = 'Bitte einen Namen für den Standort eingeben.';
}
if ($latitude === '' || !is_numeric($latitude)) {
$errors[] = 'Bitte einen gültigen Breitengrad eingeben.';
} else {
$lat = (float) $latitude;
if ($lat < -90 || $lat > 90) {
$errors[] = 'Der Breitengrad muss zwischen -90 und 90 liegen.';
}
}
if ($longitude === '' || !is_numeric($longitude)) {
$errors[] = 'Bitte einen gültigen Längengrad eingeben.';
} else {
$lon = (float) $longitude;
if ($lon < -180 || $lon > 180) {
$errors[] = 'Der Längengrad muss zwischen -180 und 180 liegen.';
}
}
if ($elevation !== '' && !is_numeric($elevation)) {
$errors[] = 'Die Höhe muss numerisch sein.';
}
if (!validTimezone($timezone)) {
$errors[] = 'Bitte eine gültige IANA-Zeitzone angeben, z. B. Europe/Berlin.';
}
return [
'name' => $name,
'latitude' => $latitude,
'longitude' => $longitude,
'elevation' => $elevation,
'timezone' => $timezone,
];
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = $_POST['action'] ?? '';
@@ -494,6 +541,85 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
}
if ($action === 'update_location') {
$locationId = (int) ($_POST['location_id'] ?? 0);
$locationForm = validateLocationForm($_POST, $errors);
$setDefault = isset($_POST['is_default']) ? 1 : 0;
if ($locationId <= 0) {
$errors[] = 'Ungültiger Standort.';
}
$existingLocation = null;
if (empty($errors)) {
$stmtLocation = $pdo->prepare("
SELECT `id`, `is_default`
FROM `app_user_locations`
WHERE `id` = :id
AND `user_id` = :user_id
LIMIT 1
");
$stmtLocation->execute([
':id' => $locationId,
':user_id' => $userId,
]);
$existingLocation = $stmtLocation->fetch();
if (!$existingLocation) {
$errors[] = 'Der Standort wurde nicht gefunden.';
}
}
if (empty($errors)) {
$pdo->beginTransaction();
try {
if ($setDefault === 1) {
$stmtReset = $pdo->prepare("
UPDATE `app_user_locations`
SET `is_default` = 0
WHERE `user_id` = :user_id
");
$stmtReset->execute([
':user_id' => $userId,
]);
}
$stmtUpdate = $pdo->prepare("
UPDATE `app_user_locations`
SET
`name` = :name,
`latitude` = :latitude,
`longitude` = :longitude,
`elevation` = :elevation,
`timezone` = :timezone,
`is_default` = :is_default,
`updated_at` = NOW()
WHERE `id` = :id
AND `user_id` = :user_id
");
$stmtUpdate->execute([
':id' => $locationId,
':user_id' => $userId,
':name' => $locationForm['name'],
':latitude' => (float) $locationForm['latitude'],
':longitude' => (float) $locationForm['longitude'],
':elevation' => $locationForm['elevation'] !== '' ? (float) $locationForm['elevation'] : null,
':timezone' => $locationForm['timezone'],
':is_default' => $setDefault === 1 ? 1 : (int) ($existingLocation['is_default'] ?? 0),
]);
$pdo->commit();
$successMessage = 'Der Standort wurde aktualisiert.';
} catch (Throwable $e) {
if ($pdo->inTransaction()) {
$pdo->rollBack();
}
$errors[] = 'Der Standort konnte nicht aktualisiert werden.';
}
}
}
if ($action === 'set_default_location') {
$locationId = (int) ($_POST['location_id'] ?? 0);
@@ -874,6 +1000,17 @@ $loggedIn = true;
<td><?= h($location['timezone']) ?></td>
<td><?= (int) $location['is_default'] === 1 ? '*' : '-' ?></td>
<td class="action-cell">
<button
type="button"
class="btn btn-sm btn-primary js-edit-location"
data-location-id="<?= (int) $location['id'] ?>"
data-location-name="<?= h((string) $location['name']) ?>"
data-location-latitude="<?= h((string) $location['latitude']) ?>"
data-location-longitude="<?= h((string) $location['longitude']) ?>"
data-location-elevation="<?= h($location['elevation'] !== null ? (string) $location['elevation'] : '') ?>"
data-location-timezone="<?= h((string) $location['timezone']) ?>"
data-location-default="<?= (int) $location['is_default'] === 1 ? '1' : '0' ?>"
>Bearbeiten</button>
<?php if ((int) $location['is_default'] !== 1): ?>
<form method="post" action="" class="favorites-loading-form" data-loading-message="Standard-Standort wird gesetzt...">
<input type="hidden" name="action" value="set_default_location">
@@ -885,7 +1022,7 @@ $loggedIn = true;
<form method="post" action="" class="favorites-loading-form" data-loading-message="Standort wird entfernt..." onsubmit="return confirm('Standort wirklich löschen?');">
<input type="hidden" name="action" value="delete_location">
<input type="hidden" name="location_id" value="<?= (int) $location['id'] ?>">
<button type="submit" class="btn btn-sm btn-danger">Loeschen</button>
<button type="submit" class="btn btn-sm btn-danger">Löschen</button>
</form>
<?php else: ?>
<span class="hint">Letzter Standort</span>
@@ -911,12 +1048,25 @@ $loggedIn = true;
<div id="map" class="map"></div>
<form method="post" action="" class="form-stack mt-xl favorites-loading-form" data-loading-message="Standort wird gespeichert...">
<form method="post" action="" id="add-location-form" class="form-stack mt-xl favorites-loading-form" data-loading-message="Standort wird gespeichert...">
<input type="hidden" name="action" value="add_location">
<div class="grid-2 gap-sm">
<div class="form-group">
<label for="name">Name</label>
<input type="text" id="name" name="name" required value="<?= h($_POST['name'] ?? '') ?>">
<input
type="text"
id="name"
name="name"
required
aria-describedby="add-location-name-error"
value="<?= h($_POST['name'] ?? '') ?>"
>
<p
id="add-location-name-error"
class="favorites-loading-hint favorites-loading-hint-error"
data-validation-hint="name"
<?= (($_POST['action'] ?? '') === 'add_location' && trim((string) ($_POST['name'] ?? '')) === '') ? '' : 'hidden' ?>
>Bitte einen Namen für den Standort eingeben.</p>
</div>
<div class="form-group">
<label for="timezone">Zeitzone (IANA)</label>
@@ -940,11 +1090,50 @@ $loggedIn = true;
Als Standard-Standort speichern
</label>
<button type="submit" class="btn btn-primary">Standort speichern</button>
<p class="favorites-loading-hint" hidden>Standort wird gespeichert...</p>
<p class="favorites-loading-hint" data-loading-hint hidden>Standort wird gespeichert...</p>
</form>
</div>
</div>
<dialog class="admin-dialog" id="editLocationDialog">
<form method="post" action="" class="admin-dialog-card form-stack favorites-loading-form" data-loading-message="Standort wird aktualisiert...">
<input type="hidden" name="action" value="update_location">
<input type="hidden" name="location_id" id="edit-location-id" value="">
<h3>Standort bearbeiten</h3>
<div class="grid-2 gap-sm">
<div class="form-group">
<label for="edit-location-name">Name</label>
<input type="text" id="edit-location-name" name="name" required>
</div>
<div class="form-group">
<label for="edit-location-timezone">Zeitzone (IANA)</label>
<input type="text" id="edit-location-timezone" name="timezone" required>
</div>
<div class="form-group">
<label for="edit-location-latitude">Breitengrad</label>
<input type="text" id="edit-location-latitude" name="latitude" required>
</div>
<div class="form-group">
<label for="edit-location-longitude">Längengrad</label>
<input type="text" id="edit-location-longitude" name="longitude" required>
</div>
<div class="form-group">
<label for="edit-location-elevation">Höhe (optional, Meter)</label>
<input type="text" id="edit-location-elevation" name="elevation">
</div>
</div>
<label class="form-checkbox">
<input type="checkbox" id="edit-location-default" name="is_default" value="1">
Als Standard-Standort speichern
</label>
<div class="admin-dialog-actions">
<button type="button" class="btn btn-secondary" id="editLocationCancel">Abbrechen</button>
<button type="submit" class="btn btn-primary">Änderungen speichern</button>
</div>
<p class="favorites-loading-hint" data-loading-hint hidden>Standort wird aktualisiert...</p>
</form>
</dialog>
<div class="grid-2">
<div class="card">
<h2>Satelliten suchen</h2>
@@ -959,7 +1148,7 @@ $loggedIn = true;
>
<button type="submit" class="btn btn-primary">Suchen</button>
</div>
<p class="favorites-loading-hint" hidden>Satelliten werden gesucht. Das kann kurz dauern...</p>
<p class="favorites-loading-hint" data-loading-hint hidden>Satelliten werden gesucht. Das kann kurz dauern...</p>
</form>
<?php if ($satelliteSearchQuery !== ''): ?>
@@ -1014,7 +1203,7 @@ $loggedIn = true;
>
<button type="submit" class="btn btn-primary">Suchen</button>
</div>
<p class="favorites-loading-hint" hidden>Kleinplaneten werden gesucht. Das kann etwas dauern...</p>
<p class="favorites-loading-hint" data-loading-hint hidden>Kleinplaneten werden gesucht. Das kann etwas dauern...</p>
</form>
<?php if ($minorplanetSearchQuery !== ''): ?>
@@ -1336,13 +1525,40 @@ $loggedIn = true;
})();
document.querySelectorAll('.favorites-loading-form').forEach((form) => {
form.addEventListener('submit', () => {
form.addEventListener('submit', (event) => {
if (form.id === 'add-location-form') {
const nameField = form.querySelector('#name');
const nameError = document.getElementById('add-location-name-error');
if (nameField) {
const trimmedName = nameField.value.trim();
if (trimmedName === '') {
event.preventDefault();
nameField.value = '';
nameField.focus();
if (nameError) {
nameError.textContent = 'Bitte einen Namen für den Standort eingeben.';
nameError.hidden = false;
}
return;
}
if (nameError) {
nameError.hidden = true;
}
}
}
const message = form.dataset.loadingMessage || 'Bitte warten...';
let hint = form.querySelector('.favorites-loading-hint');
let hint = form.querySelector('[data-loading-hint]');
if (!hint) {
hint = document.createElement('p');
hint.className = 'favorites-loading-hint';
hint.dataset.loadingHint = 'true';
form.appendChild(hint);
}
@@ -1361,6 +1577,40 @@ document.querySelectorAll('.favorites-loading-form').forEach((form) => {
});
});
});
(function () {
const dialog = document.getElementById('editLocationDialog');
const cancelButton = document.getElementById('editLocationCancel');
if (!dialog || typeof dialog.showModal !== 'function') {
return;
}
const idInput = document.getElementById('edit-location-id');
const nameInput = document.getElementById('edit-location-name');
const latitudeInput = document.getElementById('edit-location-latitude');
const longitudeInput = document.getElementById('edit-location-longitude');
const elevationInput = document.getElementById('edit-location-elevation');
const timezoneInput = document.getElementById('edit-location-timezone');
const defaultInput = document.getElementById('edit-location-default');
document.querySelectorAll('.js-edit-location').forEach((button) => {
button.addEventListener('click', () => {
idInput.value = button.dataset.locationId || '';
nameInput.value = button.dataset.locationName || '';
latitudeInput.value = button.dataset.locationLatitude || '';
longitudeInput.value = button.dataset.locationLongitude || '';
elevationInput.value = button.dataset.locationElevation || '';
timezoneInput.value = button.dataset.locationTimezone || 'Europe/Berlin';
defaultInput.checked = button.dataset.locationDefault === '1';
dialog.showModal();
});
});
cancelButton?.addEventListener('click', () => {
dialog.close();
});
})();
</script>
<?php require __DIR__ . '/footer.php'; ?>