WebUI: prefer arrow functions whenever applicable

Compared to plain function, arrow function is simpler to understand (without bindings to `this`, `arguments`, `super`) and to read.
Now, plain function will only be used when this object is required.

PR #21691.
This commit is contained in:
Chocobo1
2024-11-01 04:17:41 +08:00
committed by GitHub
parent 7af6ac18aa
commit 72cbc83569
49 changed files with 574 additions and 570 deletions

View File

@@ -42,7 +42,7 @@ window.qBittorrent.PropPeers ??= (() => {
let syncTorrentPeersLastResponseId = 0;
let show_flags = true;
const loadTorrentPeersData = function() {
const loadTorrentPeersData = () => {
if ($("propPeers").hasClass("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) {
syncTorrentPeersLastResponseId = 0;
@@ -63,11 +63,11 @@ window.qBittorrent.PropPeers ??= (() => {
url: url,
method: "get",
noCache: true,
onComplete: function() {
onComplete: () => {
clearTimeout(loadTorrentPeersTimer);
loadTorrentPeersTimer = loadTorrentPeersData.delay(window.qBittorrent.Client.getSyncMainDataInterval());
},
onSuccess: function(response) {
onSuccess: (response) => {
$("error_div").textContent = "";
if (response) {
const full_update = (response["full_update"] === true);
@@ -106,13 +106,13 @@ window.qBittorrent.PropPeers ??= (() => {
}).send();
};
const updateData = function() {
const updateData = () => {
clearTimeout(loadTorrentPeersTimer);
loadTorrentPeersTimer = -1;
loadTorrentPeersData();
};
const clear = function() {
const clear = () => {
torrentPeersTable.clear();
};
@@ -120,7 +120,7 @@ window.qBittorrent.PropPeers ??= (() => {
targets: "#torrentPeersTableDiv",
menu: "torrentPeersMenu",
actions: {
addPeer: function(element, ref) {
addPeer: (element, ref) => {
const hash = torrentsTable.getCurrentTorrentID();
if (!hash)
return;
@@ -140,7 +140,7 @@ window.qBittorrent.PropPeers ??= (() => {
height: 260
});
},
banPeer: function(element, ref) {
banPeer: (element, ref) => {
const selectedPeers = torrentPeersTable.selectedRowsIds();
if (selectedPeers.length === 0)
return;
@@ -176,7 +176,7 @@ window.qBittorrent.PropPeers ??= (() => {
});
new ClipboardJS("#CopyPeerInfo", {
text: function(trigger) {
text: (trigger) => {
return torrentPeersTable.selectedRowsIds().join("\n");
}
});