mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-10 00:46:48 -06:00
WebUI: enforce coding style
* WebUI: prefer `classList.toggle()` over other pattern Addresses: https://github.com/qbittorrent/qBittorrent/pull/23231#discussion_r2328647152 * WebUI: prefer using built-in objects Constructor * WebUI: combine function calls PR #23261.
This commit is contained in:
parent
5edaf2cf10
commit
b0148ef36c
@ -36,6 +36,7 @@ export default [
|
||||
"curly": ["error", "multi-or-nest", "consistent"],
|
||||
"eqeqeq": "error",
|
||||
"guard-for-in": "error",
|
||||
"no-implicit-coercion": "error",
|
||||
"no-undef": "off",
|
||||
"no-unused-vars": "off",
|
||||
"no-var": "error",
|
||||
@ -73,7 +74,10 @@ export default [
|
||||
"Unicorn/no-array-for-each": "error",
|
||||
"Unicorn/no-for-loop": "error",
|
||||
"Unicorn/no-zero-fractions": "error",
|
||||
"Unicorn/prefer-classlist-toggle": "error",
|
||||
"Unicorn/prefer-native-coercion-functions": "error",
|
||||
"Unicorn/prefer-number-properties": "error",
|
||||
"Unicorn/prefer-single-call": "error",
|
||||
"Unicorn/switch-case-braces": ["error", "avoid"]
|
||||
}
|
||||
}
|
||||
|
||||
@ -710,10 +710,8 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||
colElem.classList.toggle("reverse", isReverse);
|
||||
}
|
||||
const oldColElem = getCol(this.dynamicTableFixedHeaderDivId, oldColumn);
|
||||
if (oldColElem !== null) {
|
||||
oldColElem.classList.remove("sorted");
|
||||
oldColElem.classList.remove("reverse");
|
||||
}
|
||||
if (oldColElem !== null)
|
||||
oldColElem.classList.remove("sorted", "reverse");
|
||||
}
|
||||
|
||||
getSelectedRowId() {
|
||||
|
||||
@ -730,9 +730,7 @@ window.qBittorrent.Search ??= (() => {
|
||||
for (const plugin of responseJSON)
|
||||
searchPlugins.push(plugin);
|
||||
|
||||
const pluginOptions = [];
|
||||
pluginOptions.push(createOption("QBT_TR(Only enabled)QBT_TR[CONTEXT=SearchEngineWidget]", "enabled"));
|
||||
pluginOptions.push(createOption("QBT_TR(All plugins)QBT_TR[CONTEXT=SearchEngineWidget]", "all"));
|
||||
const pluginOptions = [createOption("QBT_TR(Only enabled)QBT_TR[CONTEXT=SearchEngineWidget]", "enabled"), createOption("QBT_TR(All plugins)QBT_TR[CONTEXT=SearchEngineWidget]", "all")];
|
||||
|
||||
const searchPluginsEmpty = (searchPlugins.length === 0);
|
||||
if (!searchPluginsEmpty) {
|
||||
|
||||
@ -17,12 +17,8 @@
|
||||
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");
|
||||
}
|
||||
for (const content of document.querySelectorAll(".aboutTabContent"))
|
||||
content.classList.toggle("invisible", (content !== element));
|
||||
};
|
||||
|
||||
document.getElementById("aboutAboutLink").addEventListener("click", (event) => {
|
||||
|
||||
@ -36,12 +36,8 @@
|
||||
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");
|
||||
}
|
||||
for (const tab of document.querySelectorAll(".PrefTab"))
|
||||
tab.classList.toggle("invisible", (tab !== element));
|
||||
};
|
||||
|
||||
document.getElementById("PrefBehaviorLink").addEventListener("click", (e) => {
|
||||
|
||||
@ -620,8 +620,8 @@
|
||||
|
||||
if (articlesDiffer) {
|
||||
// update unread count
|
||||
const oldUnread = feedData[r.uid].map((art) => !art.isRead).filter((v) => v).length;
|
||||
const newUnread = r.articles.map((art) => !art.isRead).filter((v) => v).length;
|
||||
const oldUnread = feedData[r.uid].map((art) => !art.isRead).filter(Boolean).length;
|
||||
const newUnread = r.articles.map((art) => !art.isRead).filter(Boolean).length;
|
||||
const unreadDifference = newUnread - oldUnread;
|
||||
|
||||
// find all parents (and self) and add unread difference
|
||||
@ -733,7 +733,7 @@
|
||||
});
|
||||
|
||||
// calculate number of unread
|
||||
const numberOfUnread = dataEntry.articles.map((art) => !art.isRead).filter((v) => v).length;
|
||||
const numberOfUnread = dataEntry.articles.map((art) => !art.isRead).filter(Boolean).length;
|
||||
// find all items that contain this rss feed and add unread count
|
||||
for (const row of rssFeedTable.getRowValues()) {
|
||||
if (dataEntry.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user