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

View file

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

View file

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

View file

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

View file

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