adasd
All checks were successful
Deploy / deploy (push) Successful in 58s

This commit is contained in:
2026-07-30 00:04:51 +02:00
parent 76591569b6
commit f6cb211859
10 changed files with 261 additions and 22 deletions

View File

@@ -583,6 +583,7 @@ $sectionLinks = [
<div class="stack gap-6">
<label class="label" for="cAge">Alter (Jahre)</label>
<input id="cAge" name="age_years" class="input" type="number" min="0" max="18" value="<?= htmlspecialchars((string)($editChild['age_years'] ?? ''), ENT_QUOTES) ?>">
<p class="muted small" style="margin:0;">Mit Geburtsdatum wird das Alter automatisch berechnet und jaehrlich aktualisiert. Ohne Geburtsdatum gilt der manuelle Wert.</p>
</div>
</div>
<div class="stack gap-6">
@@ -880,6 +881,47 @@ $sectionLinks = [
})();
<?php endif; ?>
(function(){
const birthInput = document.getElementById('cBirth');
const ageInput = document.getElementById('cAge');
if (!birthInput || !ageInput) return;
const calculateAge = (value) => {
if (!value) return null;
const birthDate = new Date(`${value}T00:00:00`);
if (Number.isNaN(birthDate.getTime())) return null;
const today = new Date();
today.setHours(0, 0, 0, 0);
if (birthDate > today) return null;
let age = today.getFullYear() - birthDate.getFullYear();
const monthDiff = today.getMonth() - birthDate.getMonth();
const dayDiff = today.getDate() - birthDate.getDate();
if (monthDiff < 0 || (monthDiff === 0 && dayDiff < 0)) {
age -= 1;
}
return Math.max(0, age);
};
const syncAgeField = () => {
const calculatedAge = calculateAge(birthInput.value);
if (calculatedAge === null) {
ageInput.readOnly = false;
ageInput.removeAttribute('aria-readonly');
return;
}
ageInput.value = String(calculatedAge);
ageInput.readOnly = true;
ageInput.setAttribute('aria-readonly', 'true');
};
birthInput.addEventListener('input', syncAgeField);
syncAgeField();
})();
(function(){
const statusText = document.getElementById('locationBrowserStatusText');
const hintText = document.getElementById('locationBrowserStatusHint');