From f65b2619626f3f34551b768c2fd7bf3040c56788 Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Sun, 17 Aug 2025 14:38:21 -0700 Subject: [PATCH] Refactor logic to remove duplicate code --- src/webui/www/private/scripts/dynamicTable.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index cf6e23642..e3ec5d413 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -2860,26 +2860,23 @@ window.qBittorrent.DynamicTable ??= (() => { */ toggleGlobalCheckbox() { const checkbox = document.getElementById("rootMultiRename_cb"); - const checkboxes = document.querySelectorAll("input.RenamingCB"); + const isChecked = checkbox.checked || checkbox.indeterminate; - for (let i = 0; i < checkboxes.length; ++i) { - if (checkbox.checked || checkbox.indeterminate) { - const cb = checkboxes[i]; + for (const cb of document.querySelectorAll("input.RenamingCB")) { + cb.indeterminate = false; + if (isChecked) { cb.checked = true; - cb.indeterminate = false; cb.state = "checked"; } else { - const cb = checkboxes[i]; cb.checked = false; - cb.indeterminate = false; cb.state = "unchecked"; } } const nodes = this.fileTree.toArray(); for (const node of nodes) - node.checked = (checkbox.checked || checkbox.indeterminate) ? 0 : 1; + node.checked = isChecked ? 0 : 1; this.updateGlobalCheckbox(); }