Fertigkeiten: Praxispunkte (10 Kaestchen) und Wuergel je Fertigkeitsstufe in Bogen und PDF

This commit is contained in:
torsten 2026-11-22 19:31:30 +01:00
parent 3a5d366aba
commit 85fd24a0f0
10 changed files with 185 additions and 7 deletions

View file

@ -201,6 +201,36 @@
});
}
// Praxispunkte im Charakterbogen: Klick setzt die Punkte ohne Reload
document.addEventListener('submit', async function (event) {
const form = event.target.closest('[data-pp-form]');
if (!form) {
return;
}
event.preventDefault();
const pressed = event.submitter;
const want = pressed ? parseInt(pressed.value, 10) || 0 : 0;
try {
const response = await fetch(form.action, {
method: 'POST',
body: new FormData(form),
headers: { 'X-Requested-With': 'fetch' }
});
const data = await response.json();
if (!data || data.ok !== true) {
return;
}
form.querySelectorAll('.pp-slot').forEach(function (slot) {
const value = parseInt(slot.value, 10) || 0;
const filled = value <= data.pp;
slot.classList.toggle('is-filled', filled);
slot.setAttribute('aria-pressed', filled ? 'true' : 'false');
});
} catch (error) {
form.submit();
}
});
// Selektor-Schirme: Fertigkeiten und Zauber aus dem Katalog wählen
// Blendet Überschriften aus, wenn keine ihrer Einträge sichtbar ist.
const hideEmptyGroups = function (dialog) {