apply review comments

This commit is contained in:
skomerko 2025-01-31 21:35:13 +01:00
commit 7528e52a4e
5 changed files with 11 additions and 33 deletions

View file

@ -491,8 +491,7 @@ window.addEventListener("DOMContentLoaded", () => {
if (!categoryList)
return;
for (const category of categoryList.querySelectorAll("li"))
category.destroy();
[...categoryList.children].forEach((el) => { el.destroy(); });
const categoryItemTemplate = document.getElementById("categoryFilterItem");
@ -613,8 +612,7 @@ window.addEventListener("DOMContentLoaded", () => {
if (tagFilterList === null)
return;
for (const tag of tagFilterList.querySelectorAll("li"))
tag.destroy();
[...tagFilterList.children].forEach((el) => { el.destroy(); });
const tagItemTemplate = document.getElementById("tagFilterItem");
@ -667,8 +665,7 @@ window.addEventListener("DOMContentLoaded", () => {
if (trackerFilterList === null)
return;
for (const tracker of trackerFilterList.querySelectorAll("li"))
tracker.destroy();
[...trackerFilterList.children].forEach((el) => { el.destroy(); });
const trackerItemTemplate = document.getElementById("trackerFilterItem");

View file

@ -478,8 +478,7 @@ window.qBittorrent.ContextMenu ??= (() => {
updateCategoriesSubMenu(categories) {
const contextCategoryList = $("contextCategoryList");
for (const category of contextCategoryList.querySelectorAll("li"))
category.destroy();
[...contextCategoryList.children].forEach((el) => { el.destroy(); });
const createMenuItem = (text, imgURL, clickFn) => {
const anchor = document.createElement("a");
@ -635,10 +634,7 @@ window.qBittorrent.ContextMenu ??= (() => {
updateMenuItems() {
const enabledColumnIndex = (text) => {
const columns = document.querySelectorAll("#searchPluginsTableFixedHeaderRow th");
for (let i = 0; i < columns.length; ++i) {
if (columns[i].textContent === "Enabled")
return i;
}
return Array.prototype.findIndex.call(columns, (column => column.textContent === "Enabled"));
};
this.showItem("Enabled");

View file

@ -819,11 +819,7 @@ window.qBittorrent.DynamicTable ??= (() => {
},
getTrByRowId: function(rowId) {
for (const tr of this.getTrs()) {
if (tr.rowId === rowId)
return tr;
}
return null;
return Array.prototype.find.call(this.getTrs(), (tr => tr.rowId === rowId));
},
updateTable: function(fullUpdate = false) {
@ -943,11 +939,7 @@ window.qBittorrent.DynamicTable ??= (() => {
},
selectNextRow: function() {
const visibleRows = [];
for (const tr of this.getTrs()) {
if (!tr.classList.contains("invisible") && (tr.style.display !== "none"))
visibleRows.push(tr);
}
const visibleRows = Array.prototype.filter.call(this.getTrs(), (tr => !tr.classList.contains("invisible") && (tr.style.display !== "none")));
const selectedRowId = this.getSelectedRowId();
let selectedIndex = -1;
@ -969,11 +961,7 @@ window.qBittorrent.DynamicTable ??= (() => {
},
selectPreviousRow: function() {
const visibleRows = [];
for (const tr of this.getTrs()) {
if (!tr.classList.contains("invisible") && (tr.style.display !== "none"))
visibleRows.push(tr);
}
const visibleRows = Array.prototype.filter.call(this.getTrs(), (tr => !tr.classList.contains("invisible") && (tr.style.display !== "none")));
const selectedRowId = this.getSelectedRowId();
let selectedIndex = -1;

View file

@ -2102,8 +2102,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// Advanced Tab
const updateNetworkInterfaces = (default_iface, default_iface_name) => {
for (const option of document.querySelectorAll("#networkInterface option"))
option.destroy();
[...document.getElementById("networkInterface").children].forEach((el) => { el.destroy(); });
fetch("api/v2/app/networkInterfaceList", {
method: "GET",
@ -2132,8 +2131,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
};
const updateInterfaceAddresses = (iface, default_addr) => {
for (const option of document.querySelectorAll("#optionalIPAddressToBind option"))
option.destroy();
[...document.getElementById("optionalIPAddressToBind").children].forEach((el) => { el.destroy(); });
const url = new URL("api/v2/app/networkInterfaceAddressList", window.location);
url.search = new URLSearchParams({

View file

@ -422,8 +422,7 @@
};
const clearDetails = () => {
for (const element of [...document.getElementById("rssDetailsView").children])
element.destroy();
[...document.getElementById("rssDetailsView").children].forEach((el) => { el.destroy(); });
};
const showDetails = (feedUid, articleID) => {