home · contact · privacy
Fix formatting/readability of add_button code.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 23 Mar 2025 11:39:29 +0000 (12:39 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 23 Mar 2025 11:39:29 +0000 (12:39 +0100)
src/templates/edit_structured.tmpl

index 676f49a3b9c2bdc5387b3ac893604ad424cf16c4..0ca2416ed37f4a5fe028e9e7a9fb07d361655e67 100644 (file)
@@ -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) {