mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 05:43:32 -07:00
Refactor logic to remove duplicate code
This commit is contained in:
parent
9339bbb26d
commit
f65b261962
1 changed files with 5 additions and 8 deletions
|
@ -2860,26 +2860,23 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
*/
|
*/
|
||||||
toggleGlobalCheckbox() {
|
toggleGlobalCheckbox() {
|
||||||
const checkbox = document.getElementById("rootMultiRename_cb");
|
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) {
|
for (const cb of document.querySelectorAll("input.RenamingCB")) {
|
||||||
if (checkbox.checked || checkbox.indeterminate) {
|
cb.indeterminate = false;
|
||||||
const cb = checkboxes[i];
|
if (isChecked) {
|
||||||
cb.checked = true;
|
cb.checked = true;
|
||||||
cb.indeterminate = false;
|
|
||||||
cb.state = "checked";
|
cb.state = "checked";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const cb = checkboxes[i];
|
|
||||||
cb.checked = false;
|
cb.checked = false;
|
||||||
cb.indeterminate = false;
|
|
||||||
cb.state = "unchecked";
|
cb.state = "unchecked";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const nodes = this.fileTree.toArray();
|
const nodes = this.fileTree.toArray();
|
||||||
for (const node of nodes)
|
for (const node of nodes)
|
||||||
node.checked = (checkbox.checked || checkbox.indeterminate) ? 0 : 1;
|
node.checked = isChecked ? 0 : 1;
|
||||||
|
|
||||||
this.updateGlobalCheckbox();
|
this.updateGlobalCheckbox();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue