mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 08:27:24 -06:00
WebUI: prefer for loop over Array.forEach method
These were missed in 6ac0c5a8b8.
Also refactor the code a bit.
PR #23231.
This commit is contained in:
@@ -16,34 +16,32 @@
|
|||||||
(() => {
|
(() => {
|
||||||
MochaUI.initializeTabs("aboutTabs");
|
MochaUI.initializeTabs("aboutTabs");
|
||||||
|
|
||||||
|
const showContent = (element) => {
|
||||||
|
for (const content of document.querySelectorAll(".aboutTabContent")) {
|
||||||
|
if (content === element)
|
||||||
|
content.classList.remove("invisible");
|
||||||
|
else
|
||||||
|
content.classList.add("invisible");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
document.getElementById("aboutAboutLink").addEventListener("click", (event) => {
|
document.getElementById("aboutAboutLink").addEventListener("click", (event) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".aboutTabContent"), (tab => tab.classList.add("invisible")));
|
showContent(document.getElementById("aboutAboutContent"));
|
||||||
document.getElementById("aboutAboutContent").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("aboutAuthorLink").addEventListener("click", (event) => {
|
document.getElementById("aboutAuthorLink").addEventListener("click", (event) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".aboutTabContent"), (tab => tab.classList.add("invisible")));
|
showContent(document.getElementById("aboutAuthorContent"));
|
||||||
document.getElementById("aboutAuthorContent").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("aboutSpecialThanksLink").addEventListener("click", (event) => {
|
document.getElementById("aboutSpecialThanksLink").addEventListener("click", (event) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".aboutTabContent"), (tab => tab.classList.add("invisible")));
|
showContent(document.getElementById("aboutSpecialThanksContent"));
|
||||||
document.getElementById("aboutSpecialThanksContent").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("aboutTranslatorsLink").addEventListener("click", (event) => {
|
document.getElementById("aboutTranslatorsLink").addEventListener("click", (event) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".aboutTabContent"), (tab => tab.classList.add("invisible")));
|
showContent(document.getElementById("aboutTranslatorsContent"));
|
||||||
document.getElementById("aboutTranslatorsContent").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("aboutLicenseLink").addEventListener("click", (event) => {
|
document.getElementById("aboutLicenseLink").addEventListener("click", (event) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".aboutTabContent"), (tab => tab.classList.add("invisible")));
|
showContent(document.getElementById("aboutLicenseContent"));
|
||||||
document.getElementById("aboutLicenseContent").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("aboutSoftwareUsedLink").addEventListener("click", (event) => {
|
document.getElementById("aboutSoftwareUsedLink").addEventListener("click", (event) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".aboutTabContent"), (tab => tab.classList.add("invisible")));
|
showContent(document.getElementById("aboutSoftwareUsedContent"));
|
||||||
document.getElementById("aboutSoftwareUsedContent").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -33,40 +33,40 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
// Tabs
|
|
||||||
MochaUI.initializeTabs("preferencesTabs");
|
MochaUI.initializeTabs("preferencesTabs");
|
||||||
|
|
||||||
|
const showTab = (element) => {
|
||||||
|
for (const tab of document.querySelectorAll(".PrefTab")) {
|
||||||
|
if (tab === element)
|
||||||
|
tab.classList.remove("invisible");
|
||||||
|
else
|
||||||
|
tab.classList.add("invisible");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
document.getElementById("PrefBehaviorLink").addEventListener("click", (e) => {
|
document.getElementById("PrefBehaviorLink").addEventListener("click", (e) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".PrefTab"), (tab => tab.classList.add("invisible")));
|
showTab(document.getElementById("BehaviorTab"));
|
||||||
document.getElementById("BehaviorTab").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
document.getElementById("PrefDownloadsLink").addEventListener("click", (e) => {
|
document.getElementById("PrefDownloadsLink").addEventListener("click", (e) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".PrefTab"), (tab => tab.classList.add("invisible")));
|
showTab(document.getElementById("DownloadsTab"));
|
||||||
document.getElementById("DownloadsTab").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
document.getElementById("PrefConnectionLink").addEventListener("click", (e) => {
|
document.getElementById("PrefConnectionLink").addEventListener("click", (e) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".PrefTab"), (tab => tab.classList.add("invisible")));
|
showTab(document.getElementById("ConnectionTab"));
|
||||||
document.getElementById("ConnectionTab").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
document.getElementById("PrefSpeedLink").addEventListener("click", (e) => {
|
document.getElementById("PrefSpeedLink").addEventListener("click", (e) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".PrefTab"), (tab => tab.classList.add("invisible")));
|
showTab(document.getElementById("SpeedTab"));
|
||||||
document.getElementById("SpeedTab").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
document.getElementById("PrefBittorrentLink").addEventListener("click", (e) => {
|
document.getElementById("PrefBittorrentLink").addEventListener("click", (e) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".PrefTab"), (tab => tab.classList.add("invisible")));
|
showTab(document.getElementById("BittorrentTab"));
|
||||||
document.getElementById("BittorrentTab").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
document.getElementById("PrefRSSLink").addEventListener("click", (e) => {
|
document.getElementById("PrefRSSLink").addEventListener("click", (e) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".PrefTab"), (tab => tab.classList.add("invisible")));
|
showTab(document.getElementById("RSSTab"));
|
||||||
document.getElementById("RSSTab").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
document.getElementById("PrefWebUILink").addEventListener("click", (e) => {
|
document.getElementById("PrefWebUILink").addEventListener("click", (e) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".PrefTab"), (tab => tab.classList.add("invisible")));
|
showTab(document.getElementById("WebUITab"));
|
||||||
document.getElementById("WebUITab").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
document.getElementById("PrefAdvancedLink").addEventListener("click", (e) => {
|
document.getElementById("PrefAdvancedLink").addEventListener("click", (e) => {
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".PrefTab"), (tab => tab.classList.add("invisible")));
|
showTab(document.getElementById("AdvancedTab"));
|
||||||
document.getElementById("AdvancedTab").classList.remove("invisible");
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user