WebUI: Replace getElements & getChildren

This PR further reduces Mootools usage.
PR #22220.
This commit is contained in:
skomerko
2025-02-04 10:08:18 +01:00
committed by GitHub
parent 463700b76d
commit 9c2e698514
6 changed files with 53 additions and 65 deletions

View File

@@ -478,7 +478,7 @@ window.qBittorrent.ContextMenu ??= (() => {
updateCategoriesSubMenu(categories) {
const contextCategoryList = $("contextCategoryList");
contextCategoryList.getChildren().each(c => c.destroy());
[...contextCategoryList.children].forEach((el) => { el.destroy(); });
const createMenuItem = (text, imgURL, clickFn) => {
const anchor = document.createElement("a");
@@ -633,15 +633,12 @@ window.qBittorrent.ContextMenu ??= (() => {
class SearchPluginsTableContextMenu extends ContextMenu {
updateMenuItems() {
const enabledColumnIndex = (text) => {
const columns = $("searchPluginsTableFixedHeaderRow").getChildren("th");
for (let i = 0; i < columns.length; ++i) {
if (columns[i].textContent === "Enabled")
return i;
}
const columns = document.querySelectorAll("#searchPluginsTableFixedHeaderRow th");
return Array.prototype.findIndex.call(columns, (column => column.textContent === "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");
}