mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 22:33:34 -07:00
WebUI: Replace getChildren
This commit is contained in:
parent
385f139cce
commit
5ca2ae6dcc
5 changed files with 27 additions and 12 deletions
|
@ -490,7 +490,9 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
const categoryList = document.getElementById("categoryFilterList");
|
const categoryList = document.getElementById("categoryFilterList");
|
||||||
if (!categoryList)
|
if (!categoryList)
|
||||||
return;
|
return;
|
||||||
categoryList.getChildren().each(c => c.destroy());
|
|
||||||
|
for (const category of categoryList.querySelectorAll("li"))
|
||||||
|
category.destroy();
|
||||||
|
|
||||||
const categoryItemTemplate = document.getElementById("categoryFilterItem");
|
const categoryItemTemplate = document.getElementById("categoryFilterItem");
|
||||||
|
|
||||||
|
@ -611,7 +613,8 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
if (tagFilterList === null)
|
if (tagFilterList === null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tagFilterList.getChildren().each(c => c.destroy());
|
for (const tag of tagFilterList.querySelectorAll("li"))
|
||||||
|
tag.destroy();
|
||||||
|
|
||||||
const tagItemTemplate = document.getElementById("tagFilterItem");
|
const tagItemTemplate = document.getElementById("tagFilterItem");
|
||||||
|
|
||||||
|
@ -664,7 +667,8 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||||
if (trackerFilterList === null)
|
if (trackerFilterList === null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
trackerFilterList.getChildren().each(c => c.destroy());
|
for (const tracker of trackerFilterList.querySelectorAll("li"))
|
||||||
|
tracker.destroy();
|
||||||
|
|
||||||
const trackerItemTemplate = document.getElementById("trackerFilterItem");
|
const trackerItemTemplate = document.getElementById("trackerFilterItem");
|
||||||
|
|
||||||
|
|
|
@ -478,7 +478,8 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
|
|
||||||
updateCategoriesSubMenu(categories) {
|
updateCategoriesSubMenu(categories) {
|
||||||
const contextCategoryList = $("contextCategoryList");
|
const contextCategoryList = $("contextCategoryList");
|
||||||
contextCategoryList.getChildren().each(c => c.destroy());
|
for (const category of contextCategoryList.querySelectorAll("li"))
|
||||||
|
category.destroy();
|
||||||
|
|
||||||
const createMenuItem = (text, imgURL, clickFn) => {
|
const createMenuItem = (text, imgURL, clickFn) => {
|
||||||
const anchor = document.createElement("a");
|
const anchor = document.createElement("a");
|
||||||
|
@ -633,7 +634,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
class SearchPluginsTableContextMenu extends ContextMenu {
|
class SearchPluginsTableContextMenu extends ContextMenu {
|
||||||
updateMenuItems() {
|
updateMenuItems() {
|
||||||
const enabledColumnIndex = (text) => {
|
const enabledColumnIndex = (text) => {
|
||||||
const columns = $("searchPluginsTableFixedHeaderRow").getChildren("th");
|
const columns = document.querySelectorAll("#searchPluginsTableFixedHeaderRow th");
|
||||||
for (let i = 0; i < columns.length; ++i) {
|
for (let i = 0; i < columns.length; ++i) {
|
||||||
if (columns[i].textContent === "Enabled")
|
if (columns[i].textContent === "Enabled")
|
||||||
return i;
|
return i;
|
||||||
|
@ -641,7 +642,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.showItem("Enabled");
|
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");
|
this.showItem("Uninstall");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1247,8 +1247,8 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||||
if ((progressFormatted === 100.0) && (progress !== 1.0))
|
if ((progressFormatted === 100.0) && (progress !== 1.0))
|
||||||
progressFormatted = 99.9;
|
progressFormatted = 99.9;
|
||||||
|
|
||||||
if (td.getChildren("div").length > 0) {
|
const div = td.firstElementChild;
|
||||||
const div = td.getChildren("div")[0];
|
if (div !== null) {
|
||||||
if (td.resized) {
|
if (td.resized) {
|
||||||
td.resized = false;
|
td.resized = false;
|
||||||
div.setWidth(progressColumnWidth - 5);
|
div.setWidth(progressColumnWidth - 5);
|
||||||
|
|
|
@ -2102,7 +2102,9 @@ 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) => {
|
||||||
$("networkInterface").getChildren().each(c => c.destroy());
|
for (const option of document.querySelectorAll("#networkInterface option"))
|
||||||
|
option.destroy();
|
||||||
|
|
||||||
fetch("api/v2/app/networkInterfaceList", {
|
fetch("api/v2/app/networkInterfaceList", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
cache: "no-store"
|
cache: "no-store"
|
||||||
|
@ -2130,7 +2132,9 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateInterfaceAddresses = (iface, default_addr) => {
|
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);
|
const url = new URL("api/v2/app/networkInterfaceAddressList", window.location);
|
||||||
url.search = new URLSearchParams({
|
url.search = new URLSearchParams({
|
||||||
iface: iface
|
iface: iface
|
||||||
|
|
|
@ -417,13 +417,19 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("rssDetailsView").getChildren().each(c => c.destroy());
|
clearDetails();
|
||||||
rssArticleTable.updateTable(false);
|
rssArticleTable.updateTable(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearDetails = () => {
|
||||||
|
for (const element of [...document.getElementById("rssDetailsView").children])
|
||||||
|
element.destroy();
|
||||||
|
};
|
||||||
|
|
||||||
const showDetails = (feedUid, articleID) => {
|
const showDetails = (feedUid, articleID) => {
|
||||||
markArticleAsRead(pathByFeedId.get(feedUid), articleID);
|
markArticleAsRead(pathByFeedId.get(feedUid), articleID);
|
||||||
$("rssDetailsView").getChildren().each(c => c.destroy());
|
clearDetails();
|
||||||
|
|
||||||
const article = feedData[feedUid].filter((article) => article.id === articleID)[0];
|
const article = feedData[feedUid].filter((article) => article.id === articleID)[0];
|
||||||
if (article) {
|
if (article) {
|
||||||
$("rssDetailsView").append((() => {
|
$("rssDetailsView").append((() => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue