mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-10 18:41:26 -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"],
|
"curly": ["error", "multi-or-nest", "consistent"],
|
||||||
"eqeqeq": "error",
|
"eqeqeq": "error",
|
||||||
"guard-for-in": "error",
|
"guard-for-in": "error",
|
||||||
|
"no-implicit-coercion": "error",
|
||||||
"no-undef": "off",
|
"no-undef": "off",
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"no-var": "error",
|
"no-var": "error",
|
||||||
@ -73,7 +74,10 @@ export default [
|
|||||||
"Unicorn/no-array-for-each": "error",
|
"Unicorn/no-array-for-each": "error",
|
||||||
"Unicorn/no-for-loop": "error",
|
"Unicorn/no-for-loop": "error",
|
||||||
"Unicorn/no-zero-fractions": "error",
|
"Unicorn/no-zero-fractions": "error",
|
||||||
|
"Unicorn/prefer-classlist-toggle": "error",
|
||||||
|
"Unicorn/prefer-native-coercion-functions": "error",
|
||||||
"Unicorn/prefer-number-properties": "error",
|
"Unicorn/prefer-number-properties": "error",
|
||||||
|
"Unicorn/prefer-single-call": "error",
|
||||||
"Unicorn/switch-case-braces": ["error", "avoid"]
|
"Unicorn/switch-case-braces": ["error", "avoid"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -710,10 +710,8 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||||||
colElem.classList.toggle("reverse", isReverse);
|
colElem.classList.toggle("reverse", isReverse);
|
||||||
}
|
}
|
||||||
const oldColElem = getCol(this.dynamicTableFixedHeaderDivId, oldColumn);
|
const oldColElem = getCol(this.dynamicTableFixedHeaderDivId, oldColumn);
|
||||||
if (oldColElem !== null) {
|
if (oldColElem !== null)
|
||||||
oldColElem.classList.remove("sorted");
|
oldColElem.classList.remove("sorted", "reverse");
|
||||||
oldColElem.classList.remove("reverse");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectedRowId() {
|
getSelectedRowId() {
|
||||||
|
|||||||
@ -730,9 +730,7 @@ window.qBittorrent.Search ??= (() => {
|
|||||||
for (const plugin of responseJSON)
|
for (const plugin of responseJSON)
|
||||||
searchPlugins.push(plugin);
|
searchPlugins.push(plugin);
|
||||||
|
|
||||||
const pluginOptions = [];
|
const pluginOptions = [createOption("QBT_TR(Only enabled)QBT_TR[CONTEXT=SearchEngineWidget]", "enabled"), createOption("QBT_TR(All plugins)QBT_TR[CONTEXT=SearchEngineWidget]", "all")];
|
||||||
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 searchPluginsEmpty = (searchPlugins.length === 0);
|
const searchPluginsEmpty = (searchPlugins.length === 0);
|
||||||
if (!searchPluginsEmpty) {
|
if (!searchPluginsEmpty) {
|
||||||
|
|||||||
@ -17,12 +17,8 @@
|
|||||||
MochaUI.initializeTabs("aboutTabs");
|
MochaUI.initializeTabs("aboutTabs");
|
||||||
|
|
||||||
const showContent = (element) => {
|
const showContent = (element) => {
|
||||||
for (const content of document.querySelectorAll(".aboutTabContent")) {
|
for (const content of document.querySelectorAll(".aboutTabContent"))
|
||||||
if (content === element)
|
content.classList.toggle("invisible", (content !== element));
|
||||||
content.classList.remove("invisible");
|
|
||||||
else
|
|
||||||
content.classList.add("invisible");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById("aboutAboutLink").addEventListener("click", (event) => {
|
document.getElementById("aboutAboutLink").addEventListener("click", (event) => {
|
||||||
|
|||||||
@ -36,12 +36,8 @@
|
|||||||
MochaUI.initializeTabs("preferencesTabs");
|
MochaUI.initializeTabs("preferencesTabs");
|
||||||
|
|
||||||
const showTab = (element) => {
|
const showTab = (element) => {
|
||||||
for (const tab of document.querySelectorAll(".PrefTab")) {
|
for (const tab of document.querySelectorAll(".PrefTab"))
|
||||||
if (tab === element)
|
tab.classList.toggle("invisible", (tab !== element));
|
||||||
tab.classList.remove("invisible");
|
|
||||||
else
|
|
||||||
tab.classList.add("invisible");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById("PrefBehaviorLink").addEventListener("click", (e) => {
|
document.getElementById("PrefBehaviorLink").addEventListener("click", (e) => {
|
||||||
|
|||||||
@ -620,8 +620,8 @@
|
|||||||
|
|
||||||
if (articlesDiffer) {
|
if (articlesDiffer) {
|
||||||
// update unread count
|
// update unread count
|
||||||
const oldUnread = feedData[r.uid].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((v) => v).length;
|
const newUnread = r.articles.map((art) => !art.isRead).filter(Boolean).length;
|
||||||
const unreadDifference = newUnread - oldUnread;
|
const unreadDifference = newUnread - oldUnread;
|
||||||
|
|
||||||
// find all parents (and self) and add unread difference
|
// find all parents (and self) and add unread difference
|
||||||
@ -733,7 +733,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// calculate number of unread
|
// 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
|
// find all items that contain this rss feed and add unread count
|
||||||
for (const row of rssFeedTable.getRowValues()) {
|
for (const row of rssFeedTable.getRowValues()) {
|
||||||
if (dataEntry.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
if (dataEntry.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user