WebUI: Replace getChildren

This commit is contained in:
skomerko 2025-01-30 16:31:23 +01:00
commit 5ca2ae6dcc
5 changed files with 27 additions and 12 deletions

View file

@ -490,7 +490,9 @@ window.addEventListener("DOMContentLoaded", () => {
const categoryList = document.getElementById("categoryFilterList");
if (!categoryList)
return;
categoryList.getChildren().each(c => c.destroy());
for (const category of categoryList.querySelectorAll("li"))
category.destroy();
const categoryItemTemplate = document.getElementById("categoryFilterItem");
@ -611,7 +613,8 @@ window.addEventListener("DOMContentLoaded", () => {
if (tagFilterList === null)
return;
tagFilterList.getChildren().each(c => c.destroy());
for (const tag of tagFilterList.querySelectorAll("li"))
tag.destroy();
const tagItemTemplate = document.getElementById("tagFilterItem");
@ -664,7 +667,8 @@ window.addEventListener("DOMContentLoaded", () => {
if (trackerFilterList === null)
return;
trackerFilterList.getChildren().each(c => c.destroy());
for (const tracker of trackerFilterList.querySelectorAll("li"))
tracker.destroy();
const trackerItemTemplate = document.getElementById("trackerFilterItem");

View file

@ -478,7 +478,8 @@ window.qBittorrent.ContextMenu ??= (() => {
updateCategoriesSubMenu(categories) {
const contextCategoryList = $("contextCategoryList");
contextCategoryList.getChildren().each(c => c.destroy());
for (const category of contextCategoryList.querySelectorAll("li"))
category.destroy();
const createMenuItem = (text, imgURL, clickFn) => {
const anchor = document.createElement("a");
@ -633,7 +634,7 @@ window.qBittorrent.ContextMenu ??= (() => {
class SearchPluginsTableContextMenu extends ContextMenu {
updateMenuItems() {
const enabledColumnIndex = (text) => {
const columns = $("searchPluginsTableFixedHeaderRow").getChildren("th");
const columns = document.querySelectorAll("#searchPluginsTableFixedHeaderRow th");
for (let i = 0; i < columns.length; ++i) {
if (columns[i].textContent === "Enabled")
return i;
@ -641,7 +642,7 @@ window.qBittorrent.ContextMenu ??= (() => {
};
this.showItem("Enabled");
this.setItemChecked("Enabled", (this.options.element.getChildren("td")[enabledColumnIndex()].textContent === "Yes"));
this.setItemChecked("Enabled", (this.options.element.children[enabledColumnIndex()].textContent === "Yes"));
this.showItem("Uninstall");
}

View file

@ -1247,8 +1247,8 @@ window.qBittorrent.DynamicTable ??= (() => {
if ((progressFormatted === 100.0) && (progress !== 1.0))
progressFormatted = 99.9;
if (td.getChildren("div").length > 0) {
const div = td.getChildren("div")[0];
const div = td.firstElementChild;
if (div !== null) {
if (td.resized) {
td.resized = false;
div.setWidth(progressColumnWidth - 5);

View file

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

View file

@ -417,13 +417,19 @@
});
});
$("rssDetailsView").getChildren().each(c => c.destroy());
clearDetails();
rssArticleTable.updateTable(false);
};
const clearDetails = () => {
for (const element of [...document.getElementById("rssDetailsView").children])
element.destroy();
};
const showDetails = (feedUid, articleID) => {
markArticleAsRead(pathByFeedId.get(feedUid), articleID);
$("rssDetailsView").getChildren().each(c => c.destroy());
clearDetails();
const article = feedData[feedUid].filter((article) => article.id === articleID)[0];
if (article) {
$("rssDetailsView").append((() => {