WebUI: Replace getElement with querySelector

All `getElement` instances (Mootools) were changed to `querySelector`.

PR #22082.
This commit is contained in:
skomerko 2024-12-31 14:31:46 +01:00 committed by GitHub
parent efe06f133d
commit 395dbaa5c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 13 deletions

View File

@ -246,24 +246,24 @@ window.qBittorrent.ContextMenu ??= (() => {
} }
setItemChecked(item, checked) { setItemChecked(item, checked) {
this.menu.getElement("a[href$=" + item + "]").firstElementChild.style.opacity = this.menu.querySelector(`a[href$="${item}"]`).firstElementChild.style.opacity =
checked ? "1" : "0"; checked ? "1" : "0";
return this; return this;
} }
getItemChecked(item) { getItemChecked(item) {
return this.menu.getElement("a[href$=" + item + "]").firstElementChild.style.opacity !== "0"; return this.menu.querySelector(`a[href$="${item}"]`).firstElementChild.style.opacity !== "0";
} }
// hide an item // hide an item
hideItem(item) { hideItem(item) {
this.menu.getElement("a[href$=" + item + "]").parentNode.classList.add("invisible"); this.menu.querySelector(`a[href$="${item}"]`).parentNode.classList.add("invisible");
return this; return this;
} }
// show an item // show an item
showItem(item) { showItem(item) {
this.menu.getElement("a[href$=" + item + "]").parentNode.classList.remove("invisible"); this.menu.querySelector(`a[href$="${item}"]`).parentNode.classList.remove("invisible");
return this; return this;
} }
@ -405,7 +405,7 @@ window.qBittorrent.ContextMenu ??= (() => {
if (all_are_downloaded) { if (all_are_downloaded) {
this.hideItem("downloadLimit"); this.hideItem("downloadLimit");
this.menu.getElement("a[href$=uploadLimit]").parentNode.classList.add("separator"); this.menu.querySelector("a[href$=uploadLimit]").parentNode.classList.add("separator");
this.hideItem("sequentialDownload"); this.hideItem("sequentialDownload");
this.hideItem("firstLastPiecePrio"); this.hideItem("firstLastPiecePrio");
this.showItem("superSeeding"); this.showItem("superSeeding");
@ -415,7 +415,7 @@ window.qBittorrent.ContextMenu ??= (() => {
const show_seq_dl = (all_are_seq_dl || !there_are_seq_dl); const show_seq_dl = (all_are_seq_dl || !there_are_seq_dl);
const show_f_l_piece_prio = (all_are_f_l_piece_prio || !there_are_f_l_piece_prio); const show_f_l_piece_prio = (all_are_f_l_piece_prio || !there_are_f_l_piece_prio);
this.menu.getElement("a[href$=firstLastPiecePrio]").parentNode.classList.toggle("separator", (!show_seq_dl && show_f_l_piece_prio)); this.menu.querySelector("a[href$=firstLastPiecePrio]").parentNode.classList.toggle("separator", (!show_seq_dl && show_f_l_piece_prio));
if (show_seq_dl) if (show_seq_dl)
this.showItem("sequentialDownload"); this.showItem("sequentialDownload");
@ -431,7 +431,7 @@ window.qBittorrent.ContextMenu ??= (() => {
this.setItemChecked("firstLastPiecePrio", all_are_f_l_piece_prio); this.setItemChecked("firstLastPiecePrio", all_are_f_l_piece_prio);
this.showItem("downloadLimit"); this.showItem("downloadLimit");
this.menu.getElement("a[href$=uploadLimit]").parentNode.classList.remove("separator"); this.menu.querySelector("a[href$=uploadLimit]").parentNode.classList.remove("separator");
this.hideItem("superSeeding"); this.hideItem("superSeeding");
} }
@ -458,7 +458,7 @@ window.qBittorrent.ContextMenu ??= (() => {
const contextTagList = $("contextTagList"); const contextTagList = $("contextTagList");
tagList.forEach((tag, tagHash) => { tagList.forEach((tag, tagHash) => {
const checkbox = contextTagList.getElement(`a[href="#Tag/${tag.name}"] input[type="checkbox"]`); const checkbox = contextTagList.querySelector(`a[href="#Tag/${tag.name}"] input[type="checkbox"]`);
const count = tagCount.get(tag.name); const count = tagCount.get(tag.name);
const hasCount = (count !== undefined); const hasCount = (count !== undefined);
const isLesser = (count < selectedRows.length); const isLesser = (count < selectedRows.length);
@ -658,11 +658,11 @@ window.qBittorrent.ContextMenu ??= (() => {
class RssFeedContextMenu extends ContextMenu { class RssFeedContextMenu extends ContextMenu {
updateMenuItems() { updateMenuItems() {
const selectedRows = window.qBittorrent.Rss.rssFeedTable.selectedRowsIds(); const selectedRows = window.qBittorrent.Rss.rssFeedTable.selectedRowsIds();
this.menu.getElement("a[href$=newSubscription]").parentNode.classList.add("separator"); this.menu.querySelector("a[href$=newSubscription]").parentNode.classList.add("separator");
switch (selectedRows.length) { switch (selectedRows.length) {
case 0: case 0:
// remove separator on top of newSubscription entry to avoid double line // remove separator on top of newSubscription entry to avoid double line
this.menu.getElement("a[href$=newSubscription]").parentNode.classList.remove("separator"); this.menu.querySelector("a[href$=newSubscription]").parentNode.classList.remove("separator");
// menu when nothing selected // menu when nothing selected
this.hideItem("update"); this.hideItem("update");
this.hideItem("markRead"); this.hideItem("markRead");

View File

@ -2305,7 +2305,7 @@ window.qBittorrent.DynamicTable ??= (() => {
node.checked = 0; node.checked = 0;
node.full_data.checked = 0; node.full_data.checked = 0;
const checkbox = tr.children[0].getElement("input"); const checkbox = tr.querySelector(".RenamingCB");
checkbox.state = "checked"; checkbox.state = "checked";
checkbox.indeterminate = false; checkbox.indeterminate = false;
checkbox.checked = true; checkbox.checked = true;

View File

@ -385,7 +385,7 @@ window.qBittorrent.Search ??= (() => {
const updateStatusIconElement = (searchId, text, image) => { const updateStatusIconElement = (searchId, text, image) => {
const searchTab = $(`${searchTabIdPrefix}${searchId}`); const searchTab = $(`${searchTabIdPrefix}${searchId}`);
if (searchTab) { if (searchTab) {
const statusIcon = searchTab.getElement(".statusIcon"); const statusIcon = searchTab.querySelector(".statusIcon");
statusIcon.alt = text; statusIcon.alt = text;
statusIcon.title = text; statusIcon.title = text;
statusIcon.src = image; statusIcon.src = image;
@ -436,7 +436,7 @@ window.qBittorrent.Search ??= (() => {
}; };
const getSelectedSearchId = () => { const getSelectedSearchId = () => {
const selectedTab = $("searchTabs").getElement("li.selected"); const selectedTab = $("searchTabs").querySelector("li.selected");
return selectedTab ? getSearchIdFromTab(selectedTab) : null; return selectedTab ? getSearchIdFromTab(selectedTab) : null;
}; };