Skip to content

Commit

Permalink
WebUI: disallow unnecessary quotes in property name
Browse files Browse the repository at this point in the history
Those two forms are the same and from now on we enforce to one style.
  • Loading branch information
Chocobo1 committed Dec 22, 2024
1 parent a841fe9 commit 54e6a4f
Show file tree
Hide file tree
Showing 41 changed files with 142 additions and 141 deletions.
9 changes: 5 additions & 4 deletions src/webui/www/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default [
"Stylistic/no-mixed-operators": [
"error",
{
"groups": [
groups: [
["&", "|", "^", "~", "<<", ">>", ">>>", "==", "!=", "===", "!==", ">", ">=", "<", "<=", "&&", "||", "in", "instanceof"]
]
}
Expand All @@ -52,12 +52,13 @@ export default [
"error",
"double",
{
"avoidEscape": true,
"allowTemplateLiterals": true
avoidEscape: true,
allowTemplateLiterals: true
}
],
"Stylistic/quote-props": ["error", "consistent-as-needed"],
"Stylistic/semi": "error",
"Stylistic/spaced-comment": ["error", "always", { "exceptions": ["*"] }]
"Stylistic/spaced-comment": ["error", "always", { exceptions: ["*"] }]
}
}
];
4 changes: 2 additions & 2 deletions src/webui/www/private/addpeers.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
fetch("api/v2/torrents/addPeers", {
method: "POST",
body: new URLSearchParams({
"hashes": hash,
"peers": peers.join("|")
hashes: hash,
peers: peers.join("|")
})
})
.then((response) => {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/addtrackers.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
fetch("api/v2/torrents/addTrackers", {
method: "POST",
body: new URLSearchParams({
"hash": new URI().getData("hash"),
"urls": $("trackersUrls").value
hash: new URI().getData("hash"),
urls: $("trackersUrls").value
})
})
.then((response) => {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/addwebseeds.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
fetch("api/v2/torrents/addWebSeeds", {
method: "POST",
body: new URLSearchParams({
"hash": new URI().getData("hash"),
"urls": $("urls").value.split("\n").map(w => encodeURIComponent(w.trim())).filter(w => (w.length > 0)).join("|")
hash: new URI().getData("hash"),
urls: $("urls").value.split("\n").map(w => encodeURIComponent(w.trim())).filter(w => (w.length > 0)).join("|")
})
})
.then((response) => {
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/confirmfeeddeletion.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
fetch("api/v2/rss/removeItem", {
method: "POST",
body: new URLSearchParams({
"path": decodeURIComponent(path)
path: decodeURIComponent(path)
})
})
.then((response) => {
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/confirmruledeletion.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
fetch("api/v2/rss/removeRule", {
method: "POST",
body: new URLSearchParams({
"ruleName": decodeURIComponent(rule)
ruleName: decodeURIComponent(rule)
})
})
.then((response) => {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/confirmtrackerdeletion.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
fetch("api/v2/torrents/removeTrackers", {
method: "POST",
body: new URLSearchParams({
"hash": "*",
"urls": urls
hash: "*",
urls: urls
})
})
.then((response) => {
Expand Down
6 changes: 3 additions & 3 deletions src/webui/www/private/downloadlimit.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
fetch("api/v2/transfer/setDownloadLimit", {
method: "POST",
body: new URLSearchParams({
"limit": limit
limit: limit
})
})
.then(async (response) => {
Expand All @@ -68,8 +68,8 @@
fetch("api/v2/torrents/setDownloadLimit", {
method: "POST",
body: new URLSearchParams({
"hashes": hashes.join("|"),
"limit": limit
hashes: hashes.join("|"),
limit: limit
})
})
.then(async (response) => {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/editfeedurl.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
fetch("api/v2/rss/setFeedURL", {
method: "POST",
body: new URLSearchParams({
"path": new URI().getData("path"),
"url": newUrl
path: new URI().getData("path"),
url: newUrl
})
})
.then(async (response) => {
Expand Down
6 changes: 3 additions & 3 deletions src/webui/www/private/edittracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
fetch("api/v2/torrents/editTracker", {
method: "POST",
body: new URLSearchParams({
"hash": new URI().getData("hash"),
"origUrl": currentUrl,
"newUrl": $("trackerUrl").value
hash: new URI().getData("hash"),
origUrl: currentUrl,
newUrl: $("trackerUrl").value
})
})
.then((response) => {
Expand Down
6 changes: 3 additions & 3 deletions src/webui/www/private/editwebseed.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
fetch("api/v2/torrents/editWebSeed", {
method: "POST",
body: new URLSearchParams({
"hash": new URI().getData("hash"),
"origUrl": origUrl,
"newUrl": encodeURIComponent($("url").value.trim())
hash: new URI().getData("hash"),
origUrl: origUrl,
newUrl: encodeURIComponent($("url").value.trim())
})
})
.then((response) => {
Expand Down
16 changes: 8 additions & 8 deletions src/webui/www/private/newcategory.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
fetch("api/v2/torrents/createCategory", {
method: "POST",
body: new URLSearchParams({
"category": categoryName,
"savePath": savePath
category: categoryName,
savePath: savePath
})
})
.then((response) => {
Expand All @@ -88,8 +88,8 @@
fetch("api/v2/torrents/setCategory", {
method: "POST",
body: new URLSearchParams({
"hashes": uriHashes,
"category": categoryName
hashes: uriHashes,
category: categoryName
})
})
.then((response) => {
Expand All @@ -111,8 +111,8 @@
fetch("api/v2/torrents/createCategory", {
method: "POST",
body: new URLSearchParams({
"category": categoryName,
"savePath": savePath
category: categoryName,
savePath: savePath
})
})
.then((response) => {
Expand All @@ -130,8 +130,8 @@
fetch("api/v2/torrents/editCategory", {
method: "POST",
body: new URLSearchParams({
"category": uriCategoryName, // category name can't be changed
"savePath": savePath
category: uriCategoryName, // category name can't be changed
savePath: savePath
})
})
.then((response) => {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/newfeed.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
fetch("api/v2/rss/addFeed", {
method: "POST",
body: new URLSearchParams({
"url": feedURL,
"path": path ? (path + "\\" + feedURL) : ""
url: feedURL,
path: path ? (path + "\\" + feedURL) : ""
})
})
.then(async (response) => {
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/newfolder.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
fetch("api/v2/rss/addFolder", {
method: "POST",
body: new URLSearchParams({
"path": path ? (path + "\\" + folderName) : folderName
path: path ? (path + "\\" + folderName) : folderName
})
})
.then(async (response) => {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/newrule.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
fetch("api/v2/rss/setRule", {
method: "POST",
body: new URLSearchParams({
"ruleName": name,
"ruleDef": "{}"
ruleName: name,
ruleDef: "{}"
})
})
.then((response) => {
Expand Down
6 changes: 3 additions & 3 deletions src/webui/www/private/newtag.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
fetch("api/v2/torrents/addTags", {
method: "POST",
body: new URLSearchParams({
"hashes": uriHashes,
"tags": tagName
hashes: uriHashes,
tags: tagName
})
})
.then(async (response) => {
Expand All @@ -78,7 +78,7 @@
fetch("api/v2/torrents/createTags", {
method: "POST",
body: new URLSearchParams({
"tags": tagName
tags: tagName
})
})
.then(async (response) => {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/rename.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
fetch("api/v2/torrents/rename", {
method: "POST",
body: new URLSearchParams({
"hash": hash,
"name": name
hash: hash,
name: name
})
})
.then((response) => {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/rename_feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
fetch("api/v2/rss/moveItem", {
method: "POST",
body: new URLSearchParams({
"itemPath": oldPath,
"destPath": newPath
itemPath: oldPath,
destPath: newPath
})
})
.then(async (response) => {
Expand Down
6 changes: 3 additions & 3 deletions src/webui/www/private/rename_file.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
fetch((isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile"), {
method: "POST",
body: new URLSearchParams({
"hash": hash,
"oldPath": oldPath,
"newPath": newPath
hash: hash,
oldPath: oldPath,
newPath: newPath
})
})
.then((response) => {
Expand Down
16 changes: 8 additions & 8 deletions src/webui/www/private/rename_files.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@
new Keyboard({
defaultEventType: "keydown",
events: {
"Escape": function(event) {
window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault();
},
"Esc": function(event) {
window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault();
}
Escape: (event) => {
window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault();
},
Esc: (event) => {
window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault();
}
}
}).activate();

Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/rename_rule.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
fetch("api/v2/rss/renameRule", {
method: "POST",
body: new URLSearchParams({
"ruleName": oldName,
"newRuleName": newName
ruleName: oldName,
newRuleName: newName
})
})
.then((response) => {
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/scripts/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ window.qBittorrent.Cache ??= (() => {
fetch("api/v2/app/setPreferences", {
method: "POST",
body: new URLSearchParams({
"json": JSON.stringify(obj.data)
json: JSON.stringify(obj.data)
})
})
.then(async (response) => {
Expand Down
38 changes: 19 additions & 19 deletions src/webui/www/private/scripts/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,25 +724,25 @@ window.addEventListener("DOMContentLoaded", () => {
};

const statusSortOrder = Object.freeze({
"unknown": -1,
"forcedDL": 0,
"downloading": 1,
"forcedMetaDL": 2,
"metaDL": 3,
"stalledDL": 4,
"forcedUP": 5,
"uploading": 6,
"stalledUP": 7,
"checkingResumeData": 8,
"queuedDL": 9,
"queuedUP": 10,
"checkingUP": 11,
"checkingDL": 12,
"stoppedDL": 13,
"stoppedUP": 14,
"moving": 15,
"missingFiles": 16,
"error": 17
unknown: -1,
forcedDL: 0,
downloading: 1,
forcedMetaDL: 2,
metaDL: 3,
stalledDL: 4,
forcedUP: 5,
uploading: 6,
stalledUP: 7,
checkingResumeData: 8,
queuedDL: 9,
queuedUP: 10,
checkingUP: 11,
checkingDL: 12,
stoppedDL: 13,
stoppedUP: 14,
moving: 15,
missingFiles: 16,
error: 17
});

let syncMainDataTimeoutID = -1;
Expand Down
Loading

0 comments on commit 54e6a4f

Please sign in to comment.