diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/edit.js | 4 | ||||
-rw-r--r-- | src/home.js | 28 |
2 files changed, 30 insertions, 2 deletions
diff --git a/src/edit.js b/src/edit.js index 6c2f328..062a0de 100644 --- a/src/edit.js +++ b/src/edit.js @@ -15,7 +15,7 @@ let editors = []; let unsavedChanges = false; const inputEvent = new InputEvent('input'); -window.onload = () => { +window.addEventListener('load', () => { form = document.getElementById('update'); let inputs = form.elements; for (const input of inputs) { @@ -86,7 +86,7 @@ window.onload = () => { window.onkeydown = keyboardHandler; window.onbeforeunload = confirmExit; -}; +}); /** * Manage a keyboardEvent diff --git a/src/home.js b/src/home.js new file mode 100644 index 0000000..b10e7c3 --- /dev/null +++ b/src/home.js @@ -0,0 +1,28 @@ +/** @type {HTMLInputElement[]} */ +let checkboxes = []; + +window.addEventListener('load', () => { + checkboxes = document.getElementsByName('id[]'); + let checkall = document.getElementById('checkall'); + let checkbox = document.createElement('input'); + checkbox.type = 'checkbox'; + checkbox.addEventListener('input', checkallHandler); + checkall.innerHTML = ''; + checkall.appendChild(checkbox); +}); + +/** + * Manage input event on the checkall checkbox. + * @param {InputEvent} e the input event + */ +function checkallHandler(e) { + if (e.target.checked) { + for (const checkbox of checkboxes) { + checkbox.checked = true; + } + } else { + for (const checkbox of checkboxes) { + checkbox.checked = false; + } + } +} |