Moderní přístup k přidávání eventlistenerů

This commit is contained in:
Jonas Havelka 2025-03-05 15:35:26 +01:00
parent b38b279b2f
commit 158ee10836

View file

@ -1,22 +1,13 @@
Zobrazit: Zobrazit:
<input type="checkbox" <input type="checkbox" id="k_oprave_checkbox" checked>
id="k_oprave_checkbox"
onchange="toggle_corrections('k_oprave')" checked>
<label for="k_oprave_checkbox">K opravě (<span id="k_oprave_pocet"></span>)</label> <label for="k_oprave_checkbox">K opravě (<span id="k_oprave_pocet"></span>)</label>
<input type="checkbox" <input type="checkbox" id="opraveno_checkbox" checked>
id="opraveno_checkbox"
onchange="toggle_corrections('opraveno')" checked>
<label for="opraveno_checkbox">Opraveno (<span id="opraveno_pocet"></span>)</label> <label for="opraveno_checkbox">Opraveno (<span id="opraveno_pocet"></span>)</label>
<input type="checkbox" <input type="checkbox" id="neni_chyba_checkbox" checked>
id="neni_chyba_checkbox"
onchange="toggle_corrections('neni_chyba')" checked>
<label for="neni_chyba_checkbox">Není chyba (<span id="neni_chyba_pocet"></span>)</label> <label for="neni_chyba_checkbox">Není chyba (<span id="neni_chyba_pocet"></span>)</label>
<input type="checkbox" <input type="checkbox" id="k_zaneseni_checkbox" checked>
id="k_zaneseni_checkbox"
onchange="toggle_corrections('k_zaneseni')" checked>
<label for="k_zaneseni_checkbox">K zanesení (<span id="k_zaneseni_pocet"></span>)</label> <label for="k_zaneseni_checkbox">K zanesení (<span id="k_zaneseni_pocet"></span>)</label>
<button type="button" id="sbal-korektury">Sbal korektury</button> <button type="button" id="sbal-korektury">Sbal korektury</button>
<button type="button" id="rozbal-korektury">Rozbal korektury</button> <button type="button" id="rozbal-korektury">Rozbal korektury</button>
@ -56,6 +47,11 @@ Zobrazit:
place_comments(); place_comments();
} }
document.getElementById('k_oprave_checkbox').addEventListener('change', () => toggle_corrections('k_oprave'));
document.getElementById('opraveno_checkbox').addEventListener('change', () => toggle_corrections('opraveno'));
document.getElementById('neni_chyba_checkbox').addEventListener('change', () => toggle_corrections('neni_chyba'));
document.getElementById('k_zaneseni_checkbox').addEventListener('change', () => toggle_corrections('k_zaneseni'));
function updatuj_pocty_stavu() { function updatuj_pocty_stavu() {
const pocty_stavu = {}; const pocty_stavu = {};
for (const stav of Object.keys(spany_s_pocty_stavu)) pocty_stavu[stav] = 0; for (const stav of Object.keys(spany_s_pocty_stavu)) pocty_stavu[stav] = 0;