From: Christian Heller Date: Sun, 23 Mar 2025 11:39:29 +0000 (+0100) Subject: Fix formatting/readability of add_button code. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/balance?a=commitdiff_plain;h=c895e27a0a1a6a5bb7ca884c8bff0b544eeda92c;p=ledgplom Fix formatting/readability of add_button code. --- diff --git a/src/templates/edit_structured.tmpl b/src/templates/edit_structured.tmpl index 676f49a..0ca2416 100644 --- a/src/templates/edit_structured.tmpl +++ b/src/templates/edit_structured.tmpl @@ -25,22 +25,22 @@ function update_form() { // basic helpers function add_button(parent_td, label, disabled, onclick) { // add button to td to run onclick (after updating dat_lines from inputs, - // and followed by calling taint and update_form + // and followed by calling taint and update_form) const btn = document.createElement("button"); parent_td.appendChild(btn); btn.textContent = label; btn.type = "button"; // otherwise will act as form submit btn.disabled = disabled; btn.onclick = function() { - let n_lines_jumped = 0; + let n_rows_jumped = 0; // to ignore table rows not representing dat_lines for (let i = 0; i < table.rows.length; i++) { const row = table.rows[i]; if (row.classList.contains('warning')) { - n_lines_jumped++; + n_rows_jumped++; continue; }; for (const input of table.rows[i].querySelectorAll('td input')) { - const line_to_update = dat_lines[i - n_lines_jumped]; + const line_to_update = dat_lines[i - n_rows_jumped]; if (input.name.endsWith('comment')) { line_to_update.comment = input.value; } else if (input.name.endsWith('error')) { @@ -58,9 +58,9 @@ function update_form() { } } } - onclick(); - taint(); - update_form(); + onclick(); + taint(); + update_form(); }; } function add_td(tr, colspan=1) {