WebUI: Use classlist.contains() instead of hasClass()

This commit is contained in:
skomerko 2024-12-03 09:59:44 +01:00
commit 8a494fbf95
11 changed files with 20 additions and 20 deletions

View file

@ -185,7 +185,7 @@ window.addEventListener("DOMContentLoaded", () => {
window.addEventListener("resize", window.qBittorrent.Misc.createDebounceHandler(500, (e) => { window.addEventListener("resize", window.qBittorrent.Misc.createDebounceHandler(500, (e) => {
// only save sizes if the columns are visible // only save sizes if the columns are visible
if (!$("mainColumn").hasClass("invisible")) if (!$("mainColumn").classList.contains("invisible"))
saveColumnSizes(); saveColumnSizes();
})); }));
@ -1225,7 +1225,7 @@ window.addEventListener("DOMContentLoaded", () => {
else { else {
$("showRssReaderLink").firstElementChild.style.opacity = "0"; $("showRssReaderLink").firstElementChild.style.opacity = "0";
$("rssTabLink").classList.add("invisible"); $("rssTabLink").classList.add("invisible");
if ($("rssTabLink").hasClass("selected")) if ($("rssTabLink").classList.contains("selected"))
$("transfersTabLink").click(); $("transfersTabLink").click();
} }
@ -1239,7 +1239,7 @@ window.addEventListener("DOMContentLoaded", () => {
else { else {
$("showSearchEngineLink").firstElementChild.style.opacity = "0"; $("showSearchEngineLink").firstElementChild.style.opacity = "0";
$("searchTabLink").classList.add("invisible"); $("searchTabLink").classList.add("invisible");
if ($("searchTabLink").hasClass("selected")) if ($("searchTabLink").classList.contains("selected"))
$("transfersTabLink").click(); $("transfersTabLink").click();
} }
@ -1253,7 +1253,7 @@ window.addEventListener("DOMContentLoaded", () => {
else { else {
$("showLogViewerLink").firstElementChild.style.opacity = "0"; $("showLogViewerLink").firstElementChild.style.opacity = "0";
$("logTabLink").classList.add("invisible"); $("logTabLink").classList.add("invisible");
if ($("logTabLink").hasClass("selected")) if ($("logTabLink").classList.contains("selected"))
$("transfersTabLink").click(); $("transfersTabLink").click();
} }

View file

@ -92,7 +92,7 @@ window.qBittorrent.ContextMenu ??= (() => {
const scrollableMenuMaxHeight = document.documentElement.clientHeight * 0.75; const scrollableMenuMaxHeight = document.documentElement.clientHeight * 0.75;
if (this.menu.hasClass("scrollableMenu")) if (this.menu.classList.contains("scrollableMenu"))
this.menu.style.maxHeight = `${scrollableMenuMaxHeight}px`; this.menu.style.maxHeight = `${scrollableMenuMaxHeight}px`;
// draw the menu off-screen to know the menu dimensions // draw the menu off-screen to know the menu dimensions
@ -119,7 +119,7 @@ window.qBittorrent.ContextMenu ??= (() => {
const uls = this.menu.getElementsByTagName("ul"); const uls = this.menu.getElementsByTagName("ul");
for (let i = 0; i < uls.length; ++i) { for (let i = 0; i < uls.length; ++i) {
const ul = uls[i]; const ul = uls[i];
if (ul.hasClass("scrollableMenu")) if (ul.classList.contains("scrollableMenu"))
ul.style.maxHeight = `${scrollableMenuMaxHeight}px`; ul.style.maxHeight = `${scrollableMenuMaxHeight}px`;
const rectParent = ul.parentNode.getBoundingClientRect(); const rectParent = ul.parentNode.getBoundingClientRect();
const xPosOrigin = rectParent.left; const xPosOrigin = rectParent.left;

View file

@ -711,7 +711,7 @@ window.qBittorrent.DynamicTable ??= (() => {
for (let i = 0; i < trs.length; ++i) { for (let i = 0; i < trs.length; ++i) {
const tr = trs[i]; const tr = trs[i];
this.selectedRows.push(tr.rowId); this.selectedRows.push(tr.rowId);
if (!tr.hasClass("selected")) if (!tr.classList.contains("selected"))
tr.classList.add("selected"); tr.classList.add("selected");
} }
}, },

View file

@ -335,8 +335,8 @@ window.qBittorrent.PropFiles ??= (() => {
let loadTorrentFilesDataTimer = -1; let loadTorrentFilesDataTimer = -1;
const loadTorrentFilesData = () => { const loadTorrentFilesData = () => {
if ($("propFiles").hasClass("invisible") if ($("propFiles").classList.contains("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) { || $("propertiesPanel_collapseToggle").classList.contains("panel-expand")) {
// Tab changed, don't do anything // Tab changed, don't do anything
return; return;
} }

View file

@ -76,8 +76,8 @@ window.qBittorrent.PropGeneral ??= (() => {
let loadTorrentDataTimer = -1; let loadTorrentDataTimer = -1;
const loadTorrentData = () => { const loadTorrentData = () => {
if ($("propGeneral").hasClass("invisible") if ($("propGeneral").classList.contains("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) { || $("propertiesPanel_collapseToggle").classList.contains("panel-expand")) {
// Tab changed, don't do anything // Tab changed, don't do anything
return; return;
} }

View file

@ -43,8 +43,8 @@ window.qBittorrent.PropPeers ??= (() => {
let show_flags = true; let show_flags = true;
const loadTorrentPeersData = () => { const loadTorrentPeersData = () => {
if ($("propPeers").hasClass("invisible") if ($("propPeers").classList.contains("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) { || $("propertiesPanel_collapseToggle").classList.contains("panel-expand")) {
syncTorrentPeersLastResponseId = 0; syncTorrentPeersLastResponseId = 0;
torrentPeersTable.clear(); torrentPeersTable.clear();
return; return;

View file

@ -43,8 +43,8 @@ window.qBittorrent.PropTrackers ??= (() => {
let loadTrackersDataTimer = -1; let loadTrackersDataTimer = -1;
const loadTrackersData = () => { const loadTrackersData = () => {
if ($("propTrackers").hasClass("invisible") if ($("propTrackers").classList.contains("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) { || $("propertiesPanel_collapseToggle").classList.contains("panel-expand")) {
// Tab changed, don't do anything // Tab changed, don't do anything
return; return;
} }

View file

@ -43,8 +43,8 @@ window.qBittorrent.PropWebseeds ??= (() => {
let loadWebSeedsDataTimer = -1; let loadWebSeedsDataTimer = -1;
const loadWebSeedsData = () => { const loadWebSeedsData = () => {
if ($("propWebSeeds").hasClass("invisible") if ($("propWebSeeds").classList.contains("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) { || $("propertiesPanel_collapseToggle").classList.contains("panel-expand")) {
// Tab changed, don't do anything // Tab changed, don't do anything
return; return;
} }

View file

@ -238,7 +238,7 @@ window.qBittorrent.Search ??= (() => {
return; return;
const searchId = getSearchIdFromTab(tab); const searchId = getSearchIdFromTab(tab);
const isTabSelected = tab.hasClass("selected"); const isTabSelected = tab.classList.contains("selected");
const newTabToSelect = isTabSelected ? (tab.nextSibling || tab.previousSibling) : null; const newTabToSelect = isTabSelected ? (tab.nextSibling || tab.previousSibling) : null;
const currentSearchId = getSelectedSearchId(); const currentSearchId = getSelectedSearchId();

View file

@ -108,7 +108,7 @@
}; };
const save = () => { const save = () => {
const rows = [...document.querySelectorAll("#manageCookiesTable tbody tr")].filter(e => !e.hasClass("invisible")); const rows = [...document.querySelectorAll("#manageCookiesTable tbody tr")].filter(e => !e.classList.contains("invisible"));
const cookies = rows.map(row => { const cookies = rows.map(row => {
const expDateValue = row.querySelector("td.expDate input").valueAsNumber; const expDateValue = row.querySelector("td.expDate input").valueAsNumber;
// remove ms from string // remove ms from string

View file

@ -370,7 +370,7 @@
onSuccess: (response) => { onSuccess: (response) => {
$("error_div").textContent = ""; $("error_div").textContent = "";
if ($("logTabColumn").hasClass("invisible")) if ($("logTabColumn").classList.contains("invisible"))
return; return;
if (response.length > 0) { if (response.length > 0) {