WebUI: prefer arrow function in callbacks

This commit is contained in:
Chocobo1 2024-05-27 22:57:28 +08:00 committed by sledgehammer999
parent 1ef21bc2b7
commit a19d623ead
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2
32 changed files with 215 additions and 214 deletions

View file

@ -30,6 +30,7 @@ export default [
"no-undef": "off", "no-undef": "off",
"no-unused-vars": "off", "no-unused-vars": "off",
"no-var": "error", "no-var": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error", "prefer-const": "error",
"Stylistic/no-mixed-operators": [ "Stylistic/no-mixed-operators": [
"error", "error",

View file

@ -24,14 +24,14 @@
} }
}).activate(); }).activate();
window.addEvent("domready", function() { window.addEvent("domready", () => {
const hash = new URI().getData("hash"); const hash = new URI().getData("hash");
if (!hash) if (!hash)
return false; return false;
$("peers").focus(); $("peers").focus();
$("addPeersOk").addEvent("click", function(e) { $("addPeersOk").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
const peers = $("peers").get("value").trim().split(/[\r\n]+/); const peers = $("peers").get("value").trim().split(/[\r\n]+/);

View file

@ -10,7 +10,7 @@
<script> <script>
"use strict"; "use strict";
window.addEvent("domready", function() { window.addEvent("domready", () => {
new Keyboard({ new Keyboard({
defaultEventType: "keydown", defaultEventType: "keydown",
events: { events: {
@ -26,7 +26,7 @@
}).activate(); }).activate();
$("trackersUrls").focus(); $("trackersUrls").focus();
$("addTrackersButton").addEvent("click", function(e) { $("addTrackersButton").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
const hash = new URI().getData("hash"); const hash = new URI().getData("hash");
new Request({ new Request({

View file

@ -21,7 +21,7 @@
icon.style.fill = "var(--color-border-default)"; icon.style.fill = "var(--color-border-default)";
} }
window.addEvent("domready", function() { window.addEvent("domready", () => {
new Request({ new Request({
url: "images/object-locked.svg", url: "images/object-locked.svg",
method: "get", method: "get",
@ -41,12 +41,12 @@
let prefDeleteContentFiles = prefCache.delete_torrent_content_files; let prefDeleteContentFiles = prefCache.delete_torrent_content_files;
$("deleteFromDiskCB").checked ||= prefDeleteContentFiles; $("deleteFromDiskCB").checked ||= prefDeleteContentFiles;
$("deleteFromDiskCB").addEvent("click", function(e) { $("deleteFromDiskCB").addEvent("click", (e) => {
setRememberBtnEnabled($("deleteFromDiskCB").checked !== prefDeleteContentFiles); setRememberBtnEnabled($("deleteFromDiskCB").checked !== prefDeleteContentFiles);
}); });
// Set current "Delete files" choice as the default // Set current "Delete files" choice as the default
$("rememberBtn").addEvent("click", function(e) { $("rememberBtn").addEvent("click", (e) => {
window.parent.qBittorrent.Cache.preferences.set({ window.parent.qBittorrent.Cache.preferences.set({
data: { data: {
"delete_torrent_content_files": $("deleteFromDiskCB").checked "delete_torrent_content_files": $("deleteFromDiskCB").checked
@ -60,11 +60,11 @@
const hashes = new URI().getData("hashes").split("|"); const hashes = new URI().getData("hashes").split("|");
$("cancelBtn").focus(); $("cancelBtn").focus();
$("cancelBtn").addEvent("click", function(e) { $("cancelBtn").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
window.parent.qBittorrent.Client.closeWindows(); window.parent.qBittorrent.Client.closeWindows();
}); });
$("confirmBtn").addEvent("click", function(e) { $("confirmBtn").addEvent("click", (e) => {
parent.torrentsTable.deselectAll(); parent.torrentsTable.deselectAll();
new Event(e).stop(); new Event(e).stop();
const cmd = "api/v2/torrents/delete"; const cmd = "api/v2/torrents/delete";

View file

@ -167,7 +167,7 @@
const encodedUrls = new URI().getData("urls"); const encodedUrls = new URI().getData("urls");
if (encodedUrls) { if (encodedUrls) {
const urls = encodedUrls.split("|").map(function(url) { const urls = encodedUrls.split("|").map((url) => {
return decodeURIComponent(url); return decodeURIComponent(url);
}); });
@ -177,7 +177,7 @@
let submitted = false; let submitted = false;
$("downloadForm").addEventListener("submit", function() { $("downloadForm").addEventListener("submit", () => {
$("startTorrentHidden").value = $("startTorrent").checked ? "false" : "true"; $("startTorrentHidden").value = $("startTorrent").checked ? "false" : "true";
$("dlLimitHidden").value = $("dlLimitText").value.toInt() * 1024; $("dlLimitHidden").value = $("dlLimitText").value.toInt() * 1024;
@ -187,7 +187,7 @@
submitted = true; submitted = true;
}); });
$("download_frame").addEventListener("load", function() { $("download_frame").addEventListener("load", () => {
if (submitted) if (submitted)
window.parent.qBittorrent.Client.closeWindows(); window.parent.qBittorrent.Client.closeWindows();
}); });

View file

@ -10,7 +10,7 @@
<script> <script>
"use strict"; "use strict";
window.addEvent("domready", function() { window.addEvent("domready", () => {
new Keyboard({ new Keyboard({
defaultEventType: "keydown", defaultEventType: "keydown",
events: { events: {
@ -36,7 +36,7 @@
$("trackerUrl").value = currentUrl; $("trackerUrl").value = currentUrl;
$("trackerUrl").focus(); $("trackerUrl").focus();
$("editTrackerButton").addEvent("click", function(e) { $("editTrackerButton").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
const hash = new URI().getData("hash"); const hash = new URI().getData("hash");
new Request({ new Request({

View file

@ -29,7 +29,7 @@
} }
}).activate(); }).activate();
window.addEvent("domready", function() { window.addEvent("domready", () => {
const uriAction = window.qBittorrent.Misc.safeTrim(new URI().getData("action")); const uriAction = window.qBittorrent.Misc.safeTrim(new URI().getData("action"));
const uriHashes = window.qBittorrent.Misc.safeTrim(new URI().getData("hashes")); const uriHashes = window.qBittorrent.Misc.safeTrim(new URI().getData("hashes"));
const uriCategoryName = window.qBittorrent.Misc.safeTrim(new URI().getData("categoryName")); const uriCategoryName = window.qBittorrent.Misc.safeTrim(new URI().getData("categoryName"));
@ -52,7 +52,7 @@
$("categoryName").focus(); $("categoryName").focus();
} }
$("categoryNameButton").addEvent("click", function(e) { $("categoryNameButton").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
const savePath = $("savePath").value.trim(); const savePath = $("savePath").value.trim();

View file

@ -29,7 +29,7 @@
} }
}).activate(); }).activate();
window.addEvent("domready", function() { window.addEvent("domready", () => {
const uriAction = window.qBittorrent.Misc.safeTrim(new URI().getData("action")); const uriAction = window.qBittorrent.Misc.safeTrim(new URI().getData("action"));
const uriHashes = window.qBittorrent.Misc.safeTrim(new URI().getData("hashes")); const uriHashes = window.qBittorrent.Misc.safeTrim(new URI().getData("hashes"));
@ -38,7 +38,7 @@
$("tagName").focus(); $("tagName").focus();
$("tagNameButton").addEvent("click", function(e) { $("tagNameButton").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
const tagName = $("tagName").value.trim(); const tagName = $("tagName").value.trim();

View file

@ -29,14 +29,14 @@
} }
}).activate(); }).activate();
window.addEvent("domready", function() { window.addEvent("domready", () => {
const name = new URI().getData("name"); const name = new URI().getData("name");
// set text field to current value // set text field to current value
if (name) if (name)
$("rename").value = name; $("rename").value = name;
$("rename").focus(); $("rename").focus();
$("renameButton").addEvent("click", function(e) { $("renameButton").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
// check field // check field
const name = $("rename").value.trim(); const name = $("rename").value.trim();

View file

@ -30,7 +30,7 @@
} }
}).activate(); }).activate();
window.addEvent("domready", function() { window.addEvent("domready", () => {
const hash = new URI().getData("hash"); const hash = new URI().getData("hash");
const oldPath = new URI().getData("path"); const oldPath = new URI().getData("path");
const isFolder = ((new URI().getData("isFolder")) === "true"); const isFolder = ((new URI().getData("isFolder")) === "true");
@ -41,7 +41,7 @@
if (!isFolder) if (!isFolder)
$("rename").setSelectionRange(0, oldName.lastIndexOf(".")); $("rename").setSelectionRange(0, oldName.lastIndexOf("."));
$("renameButton").addEvent("click", function(e) { $("renameButton").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
// check field // check field
const newName = $("rename").value.trim(); const newName = $("rename").value.trim();

View file

@ -57,7 +57,7 @@
checkboxHeader = new Element("input"); checkboxHeader = new Element("input");
checkboxHeader.set("type", "checkbox"); checkboxHeader.set("type", "checkbox");
checkboxHeader.set("id", "rootMultiRename_cb"); checkboxHeader.set("id", "rootMultiRename_cb");
checkboxHeader.addEvent("click", function(e) { checkboxHeader.addEvent("click", (e) => {
bulkRenameFilesTable.toggleGlobalCheckbox(); bulkRenameFilesTable.toggleGlobalCheckbox();
fileRenamer.selectedFiles = bulkRenameFilesTable.getSelectedRows(); fileRenamer.selectedFiles = bulkRenameFilesTable.getSelectedRows();
fileRenamer.update(); fileRenamer.update();
@ -145,7 +145,7 @@
}; };
// Setup Search Events that control renaming // Setup Search Events that control renaming
$("multiRenameSearch").addEvent("input", function(e) { $("multiRenameSearch").addEvent("input", (e) => {
const sanitized = e.target.value.replace(/\n/g, ""); const sanitized = e.target.value.replace(/\n/g, "");
$("multiRenameSearch").set("value", sanitized); $("multiRenameSearch").set("value", sanitized);
@ -154,17 +154,17 @@
LocalPreferences.set("multirename_search", sanitized); LocalPreferences.set("multirename_search", sanitized);
fileRenamer.setSearch(sanitized); fileRenamer.setSearch(sanitized);
}); });
$("use_regex_search").addEvent("change", function(e) { $("use_regex_search").addEvent("change", (e) => {
fileRenamer.useRegex = e.target.checked; fileRenamer.useRegex = e.target.checked;
LocalPreferences.set("multirename_useRegex", e.target.checked); LocalPreferences.set("multirename_useRegex", e.target.checked);
fileRenamer.update(); fileRenamer.update();
}); });
$("match_all_occurrences").addEvent("change", function(e) { $("match_all_occurrences").addEvent("change", (e) => {
fileRenamer.matchAllOccurrences = e.target.checked; fileRenamer.matchAllOccurrences = e.target.checked;
LocalPreferences.set("multirename_matchAllOccurrences", e.target.checked); LocalPreferences.set("multirename_matchAllOccurrences", e.target.checked);
fileRenamer.update(); fileRenamer.update();
}); });
$("case_sensitive").addEvent("change", function(e) { $("case_sensitive").addEvent("change", (e) => {
fileRenamer.caseSensitive = e.target.checked; fileRenamer.caseSensitive = e.target.checked;
LocalPreferences.set("multirename_caseSensitive", e.target.checked); LocalPreferences.set("multirename_caseSensitive", e.target.checked);
fileRenamer.update(); fileRenamer.update();
@ -177,7 +177,7 @@
// Clear renamed column // Clear renamed column
document document
.querySelectorAll("span[id^='filesTablefileRenamed']") .querySelectorAll("span[id^='filesTablefileRenamed']")
.forEach(function(span) { .forEach((span) => {
span.set("text", ""); span.set("text", "");
}); });
@ -192,7 +192,7 @@
}; };
// Setup Replace Events that control renaming // Setup Replace Events that control renaming
$("multiRenameReplace").addEvent("input", function(e) { $("multiRenameReplace").addEvent("input", (e) => {
const sanitized = e.target.value.replace(/\n/g, ""); const sanitized = e.target.value.replace(/\n/g, "");
$("multiRenameReplace").set("value", sanitized); $("multiRenameReplace").set("value", sanitized);
@ -201,22 +201,22 @@
LocalPreferences.set("multirename_replace", sanitized); LocalPreferences.set("multirename_replace", sanitized);
fileRenamer.setReplacement(sanitized); fileRenamer.setReplacement(sanitized);
}); });
$("applies_to_option").addEvent("change", function(e) { $("applies_to_option").addEvent("change", (e) => {
fileRenamer.appliesTo = e.target.value; fileRenamer.appliesTo = e.target.value;
LocalPreferences.set("multirename_appliesTo", e.target.value); LocalPreferences.set("multirename_appliesTo", e.target.value);
fileRenamer.update(); fileRenamer.update();
}); });
$("include_files").addEvent("change", function(e) { $("include_files").addEvent("change", (e) => {
fileRenamer.includeFiles = e.target.checked; fileRenamer.includeFiles = e.target.checked;
LocalPreferences.set("multirename_includeFiles", e.target.checked); LocalPreferences.set("multirename_includeFiles", e.target.checked);
fileRenamer.update(); fileRenamer.update();
}); });
$("include_folders").addEvent("change", function(e) { $("include_folders").addEvent("change", (e) => {
fileRenamer.includeFolders = e.target.checked; fileRenamer.includeFolders = e.target.checked;
LocalPreferences.set("multirename_includeFolders", e.target.checked); LocalPreferences.set("multirename_includeFolders", e.target.checked);
fileRenamer.update(); fileRenamer.update();
}); });
$("file_counter").addEvent("input", function(e) { $("file_counter").addEvent("input", (e) => {
let value = e.target.valueAsNumber; let value = e.target.valueAsNumber;
if (!value) { value = 0; } if (!value) { value = 0; }
if (value < 0) { value = 0; } if (value < 0) { value = 0; }
@ -228,7 +228,7 @@
}); });
// Setup Rename Operation Events // Setup Rename Operation Events
$("renameButton").addEvent("click", function(e) { $("renameButton").addEvent("click", (e) => {
// Disable Search Options // Disable Search Options
$("multiRenameSearch").disabled = true; $("multiRenameSearch").disabled = true;
$("use_regex_search").disabled = true; $("use_regex_search").disabled = true;
@ -282,7 +282,7 @@
$("rename_error").set("text", `QBT_TR(Rename failed: file or folder already exists)QBT_TR[CONTEXT=PropertiesWidget] \`${row.renamed}\``); $("rename_error").set("text", `QBT_TR(Rename failed: file or folder already exists)QBT_TR[CONTEXT=PropertiesWidget] \`${row.renamed}\``);
} }
}; };
$("renameOptions").addEvent("change", function(e) { $("renameOptions").addEvent("change", (e) => {
const combobox = e.target; const combobox = e.target;
const replaceOperation = combobox.value; const replaceOperation = combobox.value;
if (replaceOperation === "Replace") { if (replaceOperation === "Replace") {
@ -297,7 +297,7 @@
LocalPreferences.set("multirename_replaceAll", fileRenamer.replaceAll); LocalPreferences.set("multirename_replaceAll", fileRenamer.replaceAll);
$("renameButton").set("value", replaceOperation); $("renameButton").set("value", replaceOperation);
}); });
$("closeButton").addEvent("click", function() { $("closeButton").addEvent("click", () => {
window.parent.qBittorrent.Client.closeWindows(); window.parent.qBittorrent.Client.closeWindows();
event.preventDefault(); event.preventDefault();
}); });
@ -308,7 +308,7 @@
}; };
const handleTorrentFiles = function(files, selectedRows) { const handleTorrentFiles = function(files, selectedRows) {
const rows = files.map(function(file, index) { const rows = files.map((file, index) => {
const row = { const row = {
fileId: index, fileId: index,
@ -330,12 +330,12 @@
const rootNode = new window.qBittorrent.FileTree.FolderNode(); const rootNode = new window.qBittorrent.FileTree.FolderNode();
rootNode.autoCheckFolders = false; rootNode.autoCheckFolders = false;
rows.forEach(function(row) { rows.forEach((row) => {
const pathItems = row.path.split(window.qBittorrent.Filesystem.PathSeparator); const pathItems = row.path.split(window.qBittorrent.Filesystem.PathSeparator);
pathItems.pop(); // remove last item (i.e. file name) pathItems.pop(); // remove last item (i.e. file name)
let parent = rootNode; let parent = rootNode;
pathItems.forEach(function(folderName) { pathItems.forEach((folderName) => {
if (folderName === ".unwanted") { if (folderName === ".unwanted") {
return; return;
} }

View file

@ -156,7 +156,7 @@ let selected_filter = LocalPreferences.get("selected_filter", "all");
let setFilter = function() {}; let setFilter = function() {};
let toggleFilterDisplay = function() {}; let toggleFilterDisplay = function() {};
window.addEventListener("DOMContentLoaded", function() { window.addEventListener("DOMContentLoaded", () => {
let isSearchPanelLoaded = false; let isSearchPanelLoaded = false;
let isLogPanelLoaded = false; let isLogPanelLoaded = false;
@ -167,7 +167,7 @@ window.addEventListener("DOMContentLoaded", function() {
LocalPreferences.set("properties_height_rel", properties_height_rel); LocalPreferences.set("properties_height_rel", properties_height_rel);
}; };
window.addEvent("resize", function() { window.addEvent("resize", () => {
// only save sizes if the columns are visible // only save sizes if the columns are visible
if (!$("mainColumn").hasClass("invisible")) if (!$("mainColumn").hasClass("invisible"))
saveColumnSizes.delay(200); // Resizing might takes some time. saveColumnSizes.delay(200); // Resizing might takes some time.
@ -771,7 +771,7 @@ window.addEventListener("DOMContentLoaded", function() {
update_categories = true; update_categories = true;
} }
if (response["categories_removed"]) { if (response["categories_removed"]) {
response["categories_removed"].each(function(category) { response["categories_removed"].each((category) => {
const categoryHash = window.qBittorrent.Client.genHash(category); const categoryHash = window.qBittorrent.Client.genHash(category);
category_list.delete(categoryHash); category_list.delete(categoryHash);
}); });
@ -842,7 +842,7 @@ window.addEventListener("DOMContentLoaded", function() {
setupCopyEventHandler(); setupCopyEventHandler();
} }
if (response["torrents_removed"]) if (response["torrents_removed"])
response["torrents_removed"].each(function(hash) { response["torrents_removed"].each((hash) => {
torrentsTable.removeRow(hash); torrentsTable.removeRow(hash);
removeTorrentFromCategoryList(hash); removeTorrentFromCategoryList(hash);
update_categories = true; // Always to update All category update_categories = true; // Always to update All category
@ -1002,7 +1002,7 @@ window.addEventListener("DOMContentLoaded", function() {
} }
}; };
$("alternativeSpeedLimits").addEvent("click", function() { $("alternativeSpeedLimits").addEvent("click", () => {
// Change icon immediately to give some feedback // Change icon immediately to give some feedback
updateAltSpeedIcon(!alternativeSpeedLimits); updateAltSpeedIcon(!alternativeSpeedLimits);
@ -1023,7 +1023,7 @@ window.addEventListener("DOMContentLoaded", function() {
$("DlInfos").addEvent("click", globalDownloadLimitFN); $("DlInfos").addEvent("click", globalDownloadLimitFN);
$("UpInfos").addEvent("click", globalUploadLimitFN); $("UpInfos").addEvent("click", globalUploadLimitFN);
$("showTopToolbarLink").addEvent("click", function(e) { $("showTopToolbarLink").addEvent("click", (e) => {
showTopToolbar = !showTopToolbar; showTopToolbar = !showTopToolbar;
LocalPreferences.set("show_top_toolbar", showTopToolbar.toString()); LocalPreferences.set("show_top_toolbar", showTopToolbar.toString());
if (showTopToolbar) { if (showTopToolbar) {
@ -1037,7 +1037,7 @@ window.addEventListener("DOMContentLoaded", function() {
MochaUI.Desktop.setDesktopSize(); MochaUI.Desktop.setDesktopSize();
}); });
$("showStatusBarLink").addEvent("click", function(e) { $("showStatusBarLink").addEvent("click", (e) => {
showStatusBar = !showStatusBar; showStatusBar = !showStatusBar;
LocalPreferences.set("show_status_bar", showStatusBar.toString()); LocalPreferences.set("show_status_bar", showStatusBar.toString());
if (showStatusBar) { if (showStatusBar) {
@ -1071,11 +1071,11 @@ window.addEventListener("DOMContentLoaded", function() {
navigator.registerProtocolHandler("magnet", templateUrl, navigator.registerProtocolHandler("magnet", templateUrl,
"qBittorrent WebUI magnet handler"); "qBittorrent WebUI magnet handler");
}; };
$("registerMagnetHandlerLink").addEvent("click", function(e) { $("registerMagnetHandlerLink").addEvent("click", (e) => {
registerMagnetHandler(); registerMagnetHandler();
}); });
$("showFiltersSidebarLink").addEvent("click", function(e) { $("showFiltersSidebarLink").addEvent("click", (e) => {
showFiltersSidebar = !showFiltersSidebar; showFiltersSidebar = !showFiltersSidebar;
LocalPreferences.set("show_filters_sidebar", showFiltersSidebar.toString()); LocalPreferences.set("show_filters_sidebar", showFiltersSidebar.toString());
if (showFiltersSidebar) { if (showFiltersSidebar) {
@ -1091,7 +1091,7 @@ window.addEventListener("DOMContentLoaded", function() {
MochaUI.Desktop.setDesktopSize(); MochaUI.Desktop.setDesktopSize();
}); });
$("speedInBrowserTitleBarLink").addEvent("click", function(e) { $("speedInBrowserTitleBarLink").addEvent("click", (e) => {
speedInTitle = !speedInTitle; speedInTitle = !speedInTitle;
LocalPreferences.set("speed_in_browser_title_bar", speedInTitle.toString()); LocalPreferences.set("speed_in_browser_title_bar", speedInTitle.toString());
if (speedInTitle) if (speedInTitle)
@ -1101,19 +1101,19 @@ window.addEventListener("DOMContentLoaded", function() {
processServerState(); processServerState();
}); });
$("showSearchEngineLink").addEvent("click", function(e) { $("showSearchEngineLink").addEvent("click", (e) => {
window.qBittorrent.Client.showSearchEngine(!window.qBittorrent.Client.isShowSearchEngine()); window.qBittorrent.Client.showSearchEngine(!window.qBittorrent.Client.isShowSearchEngine());
LocalPreferences.set("show_search_engine", window.qBittorrent.Client.isShowSearchEngine().toString()); LocalPreferences.set("show_search_engine", window.qBittorrent.Client.isShowSearchEngine().toString());
updateTabDisplay(); updateTabDisplay();
}); });
$("showRssReaderLink").addEvent("click", function(e) { $("showRssReaderLink").addEvent("click", (e) => {
window.qBittorrent.Client.showRssReader(!window.qBittorrent.Client.isShowRssReader()); window.qBittorrent.Client.showRssReader(!window.qBittorrent.Client.isShowRssReader());
LocalPreferences.set("show_rss_reader", window.qBittorrent.Client.isShowRssReader().toString()); LocalPreferences.set("show_rss_reader", window.qBittorrent.Client.isShowRssReader().toString());
updateTabDisplay(); updateTabDisplay();
}); });
$("showLogViewerLink").addEvent("click", function(e) { $("showLogViewerLink").addEvent("click", (e) => {
window.qBittorrent.Client.showLogViewer(!window.qBittorrent.Client.isShowLogViewer()); window.qBittorrent.Client.showLogViewer(!window.qBittorrent.Client.isShowLogViewer());
LocalPreferences.set("show_log_viewer", window.qBittorrent.Client.isShowLogViewer().toString()); LocalPreferences.set("show_log_viewer", window.qBittorrent.Client.isShowLogViewer().toString());
updateTabDisplay(); updateTabDisplay();
@ -1366,11 +1366,11 @@ window.addEventListener("DOMContentLoaded", function() {
tabsOnload: function() { tabsOnload: function() {
MochaUI.initializeTabs("panelTabs"); MochaUI.initializeTabs("panelTabs");
$("logMessageLink").addEvent("click", function(e) { $("logMessageLink").addEvent("click", (e) => {
window.qBittorrent.Log.setCurrentTab("main"); window.qBittorrent.Log.setCurrentTab("main");
}); });
$("logPeerLink").addEvent("click", function(e) { $("logPeerLink").addEvent("click", (e) => {
window.qBittorrent.Log.setCurrentTab("peer"); window.qBittorrent.Log.setCurrentTab("peer");
}); });
}, },
@ -1500,7 +1500,7 @@ window.addEventListener("DOMContentLoaded", function() {
LocalPreferences.set("selected_tab", this.id); LocalPreferences.set("selected_tab", this.id);
}); });
$("propertiesPanel_collapseToggle").addEvent("click", function(e) { $("propertiesPanel_collapseToggle").addEvent("click", (e) => {
updatePropertiesPanel(); updatePropertiesPanel();
}); });
}, },

View file

@ -161,19 +161,19 @@ window.qBittorrent.ContextMenu = (function() {
}, },
setupEventListeners: function(elem) { setupEventListeners: function(elem) {
elem.addEvent("contextmenu", function(e) { elem.addEvent("contextmenu", (e) => {
this.triggerMenu(e, elem); this.triggerMenu(e, elem);
}.bind(this)); });
elem.addEvent("click", function(e) { elem.addEvent("click", (e) => {
this.hide(); this.hide();
}.bind(this)); });
elem.addEvent("touchstart", function(e) { elem.addEvent("touchstart", (e) => {
this.hide(); this.hide();
this.touchStartAt = performance.now(); this.touchStartAt = performance.now();
this.touchStartEvent = e; this.touchStartEvent = e;
}.bind(this)); });
elem.addEvent("touchend", function(e) { elem.addEvent("touchend", (e) => {
const now = performance.now(); const now = performance.now();
const touchStartAt = this.touchStartAt; const touchStartAt = this.touchStartAt;
const touchStartEvent = this.touchStartEvent; const touchStartEvent = this.touchStartEvent;
@ -185,7 +185,7 @@ window.qBittorrent.ContextMenu = (function() {
if (((now - touchStartAt) >= this.options.touchTimer) && isTargetUnchanged) { if (((now - touchStartAt) >= this.options.touchTimer) && isTargetUnchanged) {
this.triggerMenu(touchStartEvent, elem); this.triggerMenu(touchStartEvent, elem);
} }
}.bind(this)); });
}, },
addTarget: function(t) { addTarget: function(t) {
@ -215,25 +215,25 @@ window.qBittorrent.ContextMenu = (function() {
//get things started //get things started
startListener: function() { startListener: function() {
/* all elements */ /* all elements */
this.targets.each(function(el) { this.targets.each((el) => {
this.setupEventListeners(el); this.setupEventListeners(el);
}.bind(this), this); }, this);
/* menu items */ /* menu items */
this.menu.getElements("a").each(function(item) { this.menu.getElements("a").each(function(item) {
item.addEvent("click", function(e) { item.addEvent("click", (e) => {
e.preventDefault(); e.preventDefault();
if (!item.hasClass("disabled")) { if (!item.hasClass("disabled")) {
this.execute(item.get("href").split("#")[1], $(this.options.element)); this.execute(item.get("href").split("#")[1], $(this.options.element));
this.fireEvent("click", [item, e]); this.fireEvent("click", [item, e]);
} }
}.bind(this)); });
}, this); }, this);
//hide on body click //hide on body click
$(document.body).addEvent("click", function() { $(document.body).addEvent("click", () => {
this.hide(); this.hide();
}.bind(this)); });
}, },
updateMenuItems: function() {}, updateMenuItems: function() {},

View file

@ -135,7 +135,7 @@ window.qBittorrent.Download = (function() {
} }
}; };
$(window).addEventListener("load", function() { $(window).addEventListener("load", () => {
getPreferences(); getPreferences();
getCategories(); getCategories();
}); });

View file

@ -210,7 +210,7 @@ window.qBittorrent.DynamicTable = (function() {
resetElementBorderStyle(borderChangeElement, changeBorderSide === "right" ? "left" : "right"); resetElementBorderStyle(borderChangeElement, changeBorderSide === "right" ? "left" : "right");
borderChangeElement.getSiblings('[class=""]').each(function(el) { borderChangeElement.getSiblings('[class=""]').each((el) => {
resetElementBorderStyle(el); resetElementBorderStyle(el);
}); });
} }
@ -272,7 +272,7 @@ window.qBittorrent.DynamicTable = (function() {
} }
if (this.currentHeaderAction === "drag") { if (this.currentHeaderAction === "drag") {
resetElementBorderStyle(el); resetElementBorderStyle(el);
el.getSiblings('[class=""]').each(function(el) { el.getSiblings('[class=""]').each((el) => {
resetElementBorderStyle(el); resetElementBorderStyle(el);
}); });
} }
@ -431,10 +431,10 @@ window.qBittorrent.DynamicTable = (function() {
const val = LocalPreferences.get("columns_order_" + this.dynamicTableDivId); const val = LocalPreferences.get("columns_order_" + this.dynamicTableDivId);
if ((val === null) || (val === undefined)) if ((val === null) || (val === undefined))
return; return;
val.split(",").forEach(function(v) { val.split(",").forEach((v) => {
if ((v in this.columns) && (!columnsOrder.contains(v))) if ((v in this.columns) && (!columnsOrder.contains(v)))
columnsOrder.push(v); columnsOrder.push(v);
}.bind(this)); });
for (let i = 0; i < this.columns.length; ++i) for (let i = 0; i < this.columns.length; ++i)
if (!columnsOrder.contains(this.columns[i].name)) if (!columnsOrder.contains(this.columns[i].name))
@ -575,14 +575,14 @@ window.qBittorrent.DynamicTable = (function() {
return; return;
const trs = this.tableBody.getElements("tr"); const trs = this.tableBody.getElements("tr");
trs.each(function(el, i) { trs.each((el, i) => {
if (i % 2) { if (i % 2) {
el.addClass("alt"); el.addClass("alt");
} }
else { else {
el.removeClass("alt"); el.removeClass("alt");
} }
}.bind(this)); });
}, },
selectAll: function() { selectAll: function() {
@ -622,7 +622,7 @@ window.qBittorrent.DynamicTable = (function() {
let select = false; let select = false;
const that = this; const that = this;
this.tableBody.getElements("tr").each(function(tr) { this.tableBody.getElements("tr").each((tr) => {
if ((tr.rowId === rowId1) || (tr.rowId === rowId2)) { if ((tr.rowId === rowId1) || (tr.rowId === rowId2)) {
select = !select; select = !select;
that.selectedRows.push(tr.rowId); that.selectedRows.push(tr.rowId);
@ -638,7 +638,7 @@ window.qBittorrent.DynamicTable = (function() {
reselectRows: function(rowIds) { reselectRows: function(rowIds) {
this.deselectAll(); this.deselectAll();
this.selectedRows = rowIds.slice(); this.selectedRows = rowIds.slice();
this.tableBody.getElements("tr").each(function(tr) { this.tableBody.getElements("tr").each((tr) => {
if (rowIds.includes(tr.rowId)) if (rowIds.includes(tr.rowId))
tr.addClass("selected"); tr.addClass("selected");
}); });
@ -646,7 +646,7 @@ window.qBittorrent.DynamicTable = (function() {
setRowClass: function() { setRowClass: function() {
const that = this; const that = this;
this.tableBody.getElements("tr").each(function(tr) { this.tableBody.getElements("tr").each((tr) => {
if (that.isRowSelected(tr.rowId)) if (that.isRowSelected(tr.rowId))
tr.addClass("selected"); tr.addClass("selected");
else else
@ -686,14 +686,14 @@ window.qBittorrent.DynamicTable = (function() {
filteredRows[rows[i].rowId] = rows[i]; filteredRows[rows[i].rowId] = rows[i];
} }
filteredRows.sort(function(row1, row2) { filteredRows.sort((row1, row2) => {
const column = this.columns[this.sortedColumn]; const column = this.columns[this.sortedColumn];
const res = column.compareRows(row1, row2); const res = column.compareRows(row1, row2);
if (this.reverseSort === "0") if (this.reverseSort === "0")
return res; return res;
else else
return -res; return -res;
}.bind(this)); });
return filteredRows; return filteredRows;
}, },
@ -1516,14 +1516,14 @@ window.qBittorrent.DynamicTable = (function() {
} }
} }
filteredRows.sort(function(row1, row2) { filteredRows.sort((row1, row2) => {
const column = this.columns[this.sortedColumn]; const column = this.columns[this.sortedColumn];
const res = column.compareRows(row1, row2); const res = column.compareRows(row1, row2);
if (this.reverseSort === "0") if (this.reverseSort === "0")
return res; return res;
else else
return -res; return -res;
}.bind(this)); });
return filteredRows; return filteredRows;
}, },
@ -1780,14 +1780,14 @@ window.qBittorrent.DynamicTable = (function() {
filteredRows = rows; filteredRows = rows;
} }
filteredRows.sort(function(row1, row2) { filteredRows.sort((row1, row2) => {
const column = this.columns[this.sortedColumn]; const column = this.columns[this.sortedColumn];
const res = column.compareRows(row1, row2); const res = column.compareRows(row1, row2);
if (this.reverseSort === "0") if (this.reverseSort === "0")
return res; return res;
else else
return -res; return -res;
}.bind(this)); });
return filteredRows; return filteredRows;
}, },
@ -1860,9 +1860,9 @@ window.qBittorrent.DynamicTable = (function() {
populateTable: function(root) { populateTable: function(root) {
this.fileTree.setRoot(root); this.fileTree.setRoot(root);
root.children.each(function(node) { root.children.each((node) => {
this._addNodeToTable(node, 0); this._addNodeToTable(node, 0);
}.bind(this)); });
}, },
_addNodeToTable: function(node, depth) { _addNodeToTable: function(node, depth) {
@ -1888,9 +1888,9 @@ window.qBittorrent.DynamicTable = (function() {
this.updateRowData(node.data); this.updateRowData(node.data);
} }
node.children.each(function(child) { node.children.each((child) => {
this._addNodeToTable(child, depth + 1); this._addNodeToTable(child, depth + 1);
}.bind(this)); });
}, },
getRoot: function() { getRoot: function() {
@ -2021,7 +2021,7 @@ window.qBittorrent.DynamicTable = (function() {
checkbox.set("id", "cbRename" + id); checkbox.set("id", "cbRename" + id);
checkbox.set("data-id", id); checkbox.set("data-id", id);
checkbox.set("class", "RenamingCB"); checkbox.set("class", "RenamingCB");
checkbox.addEvent("click", function(e) { checkbox.addEvent("click", (e) => {
const node = that.getNode(id); const node = that.getNode(id);
node.checked = e.target.checked ? 0 : 1; node.checked = e.target.checked ? 0 : 1;
node.full_data.checked = node.checked; node.full_data.checked = node.checked;
@ -2103,7 +2103,7 @@ window.qBittorrent.DynamicTable = (function() {
reselectRows: function(rowIds) { reselectRows: function(rowIds) {
const that = this; const that = this;
this.deselectAll(); this.deselectAll();
this.tableBody.getElements("tr").each(function(tr) { this.tableBody.getElements("tr").each((tr) => {
if (rowIds.includes(tr.rowId)) { if (rowIds.includes(tr.rowId)) {
const node = that.getNode(tr.rowId); const node = that.getNode(tr.rowId);
node.checked = 0; node.checked = 0;
@ -2122,7 +2122,7 @@ window.qBittorrent.DynamicTable = (function() {
altRow: function() { altRow: function() {
let addClass = false; let addClass = false;
const trs = this.tableBody.getElements("tr"); const trs = this.tableBody.getElements("tr");
trs.each(function(tr) { trs.each((tr) => {
if (tr.hasClass("invisible")) if (tr.hasClass("invisible"))
return; return;
@ -2135,11 +2135,11 @@ window.qBittorrent.DynamicTable = (function() {
tr.addClass("nonAlt"); tr.addClass("nonAlt");
} }
addClass = !addClass; addClass = !addClass;
}.bind(this)); });
}, },
_sortNodesByColumn: function(nodes, column) { _sortNodesByColumn: function(nodes, column) {
nodes.sort(function(row1, row2) { nodes.sort((row1, row2) => {
// list folders before files when sorting by name // list folders before files when sorting by name
if (column.name === "original") { if (column.name === "original") {
const node1 = this.getNode(row1.data.rowId); const node1 = this.getNode(row1.data.rowId);
@ -2152,20 +2152,20 @@ window.qBittorrent.DynamicTable = (function() {
const res = column.compareRows(row1, row2); const res = column.compareRows(row1, row2);
return (this.reverseSort === "0") ? res : -res; return (this.reverseSort === "0") ? res : -res;
}.bind(this)); });
nodes.each(function(node) { nodes.each((node) => {
if (node.children.length > 0) if (node.children.length > 0)
this._sortNodesByColumn(node.children, column); this._sortNodesByColumn(node.children, column);
}.bind(this)); });
}, },
_filterNodes: function(node, filterTerms, filteredRows) { _filterNodes: function(node, filterTerms, filteredRows) {
if (node.isFolder) { if (node.isFolder) {
const childAdded = node.children.reduce(function(acc, child) { const childAdded = node.children.reduce((acc, child) => {
// we must execute the function before ORing w/ acc or we'll stop checking child nodes after the first successful match // we must execute the function before ORing w/ acc or we'll stop checking child nodes after the first successful match
return (this._filterNodes(child, filterTerms, filteredRows) || acc); return (this._filterNodes(child, filterTerms, filteredRows) || acc);
}.bind(this), false); }, false);
if (childAdded) { if (childAdded) {
const row = this.getRow(node); const row = this.getRow(node);
@ -2196,7 +2196,7 @@ window.qBittorrent.DynamicTable = (function() {
return []; return [];
const generateRowsSignature = function(rows) { const generateRowsSignature = function(rows) {
const rowsData = rows.map(function(row) { const rowsData = rows.map((row) => {
return row.full_data; return row.full_data;
}); });
return JSON.stringify(rowsData); return JSON.stringify(rowsData);
@ -2205,25 +2205,25 @@ window.qBittorrent.DynamicTable = (function() {
const getFilteredRows = function() { const getFilteredRows = function() {
if (this.filterTerms.length === 0) { if (this.filterTerms.length === 0) {
const nodeArray = this.fileTree.toArray(); const nodeArray = this.fileTree.toArray();
const filteredRows = nodeArray.map(function(node) { const filteredRows = nodeArray.map((node) => {
return this.getRow(node); return this.getRow(node);
}.bind(this)); });
return filteredRows; return filteredRows;
} }
const filteredRows = []; const filteredRows = [];
this.getRoot().children.each(function(child) { this.getRoot().children.each((child) => {
this._filterNodes(child, this.filterTerms, filteredRows); this._filterNodes(child, this.filterTerms, filteredRows);
}.bind(this)); });
filteredRows.reverse(); filteredRows.reverse();
return filteredRows; return filteredRows;
}.bind(this); }.bind(this);
const hasRowsChanged = function(rowsString, prevRowsStringString) { const hasRowsChanged = function(rowsString, prevRowsStringString) {
const rowsChanged = (rowsString !== prevRowsStringString); const rowsChanged = (rowsString !== prevRowsStringString);
const isFilterTermsChanged = this.filterTerms.reduce(function(acc, term, index) { const isFilterTermsChanged = this.filterTerms.reduce((acc, term, index) => {
return (acc || (term !== this.prevFilterTerms[index])); return (acc || (term !== this.prevFilterTerms[index]));
}.bind(this), false); }, false);
const isFilterChanged = ((this.filterTerms.length !== this.prevFilterTerms.length) const isFilterChanged = ((this.filterTerms.length !== this.prevFilterTerms.length)
|| ((this.filterTerms.length > 0) && isFilterTermsChanged)); || ((this.filterTerms.length > 0) && isFilterTermsChanged));
const isSortedColumnChanged = (this.prevSortedColumn !== this.sortedColumn); const isSortedColumnChanged = (this.prevSortedColumn !== this.sortedColumn);
@ -2285,9 +2285,9 @@ window.qBittorrent.DynamicTable = (function() {
populateTable: function(root) { populateTable: function(root) {
this.fileTree.setRoot(root); this.fileTree.setRoot(root);
root.children.each(function(node) { root.children.each((node) => {
this._addNodeToTable(node, 0); this._addNodeToTable(node, 0);
}.bind(this)); });
}, },
_addNodeToTable: function(node, depth) { _addNodeToTable: function(node, depth) {
@ -2316,9 +2316,9 @@ window.qBittorrent.DynamicTable = (function() {
this.updateRowData(node.data); this.updateRowData(node.data);
} }
node.children.each(function(child) { node.children.each((child) => {
this._addNodeToTable(child, depth + 1); this._addNodeToTable(child, depth + 1);
}.bind(this)); });
}, },
getRoot: function() { getRoot: function() {
@ -2472,7 +2472,7 @@ window.qBittorrent.DynamicTable = (function() {
altRow: function() { altRow: function() {
let addClass = false; let addClass = false;
const trs = this.tableBody.getElements("tr"); const trs = this.tableBody.getElements("tr");
trs.each(function(tr) { trs.each((tr) => {
if (tr.hasClass("invisible")) if (tr.hasClass("invisible"))
return; return;
@ -2485,11 +2485,11 @@ window.qBittorrent.DynamicTable = (function() {
tr.addClass("nonAlt"); tr.addClass("nonAlt");
} }
addClass = !addClass; addClass = !addClass;
}.bind(this)); });
}, },
_sortNodesByColumn: function(nodes, column) { _sortNodesByColumn: function(nodes, column) {
nodes.sort(function(row1, row2) { nodes.sort((row1, row2) => {
// list folders before files when sorting by name // list folders before files when sorting by name
if (column.name === "name") { if (column.name === "name") {
const node1 = this.getNode(row1.data.rowId); const node1 = this.getNode(row1.data.rowId);
@ -2502,20 +2502,20 @@ window.qBittorrent.DynamicTable = (function() {
const res = column.compareRows(row1, row2); const res = column.compareRows(row1, row2);
return (this.reverseSort === "0") ? res : -res; return (this.reverseSort === "0") ? res : -res;
}.bind(this)); });
nodes.each(function(node) { nodes.each((node) => {
if (node.children.length > 0) if (node.children.length > 0)
this._sortNodesByColumn(node.children, column); this._sortNodesByColumn(node.children, column);
}.bind(this)); });
}, },
_filterNodes: function(node, filterTerms, filteredRows) { _filterNodes: function(node, filterTerms, filteredRows) {
if (node.isFolder) { if (node.isFolder) {
const childAdded = node.children.reduce(function(acc, child) { const childAdded = node.children.reduce((acc, child) => {
// we must execute the function before ORing w/ acc or we'll stop checking child nodes after the first successful match // we must execute the function before ORing w/ acc or we'll stop checking child nodes after the first successful match
return (this._filterNodes(child, filterTerms, filteredRows) || acc); return (this._filterNodes(child, filterTerms, filteredRows) || acc);
}.bind(this), false); }, false);
if (childAdded) { if (childAdded) {
const row = this.getRow(node); const row = this.getRow(node);
@ -2546,7 +2546,7 @@ window.qBittorrent.DynamicTable = (function() {
return []; return [];
const generateRowsSignature = function(rows) { const generateRowsSignature = function(rows) {
const rowsData = rows.map(function(row) { const rowsData = rows.map((row) => {
return row.full_data; return row.full_data;
}); });
return JSON.stringify(rowsData); return JSON.stringify(rowsData);
@ -2555,25 +2555,25 @@ window.qBittorrent.DynamicTable = (function() {
const getFilteredRows = function() { const getFilteredRows = function() {
if (this.filterTerms.length === 0) { if (this.filterTerms.length === 0) {
const nodeArray = this.fileTree.toArray(); const nodeArray = this.fileTree.toArray();
const filteredRows = nodeArray.map(function(node) { const filteredRows = nodeArray.map((node) => {
return this.getRow(node); return this.getRow(node);
}.bind(this)); });
return filteredRows; return filteredRows;
} }
const filteredRows = []; const filteredRows = [];
this.getRoot().children.each(function(child) { this.getRoot().children.each((child) => {
this._filterNodes(child, this.filterTerms, filteredRows); this._filterNodes(child, this.filterTerms, filteredRows);
}.bind(this)); });
filteredRows.reverse(); filteredRows.reverse();
return filteredRows; return filteredRows;
}.bind(this); }.bind(this);
const hasRowsChanged = function(rowsString, prevRowsStringString) { const hasRowsChanged = function(rowsString, prevRowsStringString) {
const rowsChanged = (rowsString !== prevRowsStringString); const rowsChanged = (rowsString !== prevRowsStringString);
const isFilterTermsChanged = this.filterTerms.reduce(function(acc, term, index) { const isFilterTermsChanged = this.filterTerms.reduce((acc, term, index) => {
return (acc || (term !== this.prevFilterTerms[index])); return (acc || (term !== this.prevFilterTerms[index]));
}.bind(this), false); }, false);
const isFilterChanged = ((this.filterTerms.length !== this.prevFilterTerms.length) const isFilterChanged = ((this.filterTerms.length !== this.prevFilterTerms.length)
|| ((this.filterTerms.length > 0) && isFilterTermsChanged)); || ((this.filterTerms.length > 0) && isFilterTermsChanged));
const isSortedColumnChanged = (this.prevSortedColumn !== this.sortedColumn); const isSortedColumnChanged = (this.prevSortedColumn !== this.sortedColumn);
@ -3181,11 +3181,11 @@ window.qBittorrent.DynamicTable = (function() {
filteredRows = rows; filteredRows = rows;
} }
filteredRows.sort(function(row1, row2) { filteredRows.sort((row1, row2) => {
const column = this.columns[this.sortedColumn]; const column = this.columns[this.sortedColumn];
const res = column.compareRows(row1, row2); const res = column.compareRows(row1, row2);
return (this.reverseSort === "0") ? res : -res; return (this.reverseSort === "0") ? res : -res;
}.bind(this)); });
return filteredRows; return filteredRows;
}, },
@ -3244,11 +3244,11 @@ window.qBittorrent.DynamicTable = (function() {
filteredRows = rows; filteredRows = rows;
} }
filteredRows.sort(function(row1, row2) { filteredRows.sort((row1, row2) => {
const column = this.columns[this.sortedColumn]; const column = this.columns[this.sortedColumn];
const res = column.compareRows(row1, row2); const res = column.compareRows(row1, row2);
return (this.reverseSort === "0") ? res : -res; return (this.reverseSort === "0") ? res : -res;
}.bind(this)); });
return filteredRows; return filteredRows;
} }

View file

@ -81,9 +81,9 @@ window.qBittorrent.FileTree = (function() {
this.nodeMap[node.rowId] = node; this.nodeMap[node.rowId] = node;
} }
node.children.each(function(child) { node.children.each((child) => {
this.generateNodeMap(child); this.generateNodeMap(child);
}.bind(this)); });
}, },
getNode: function(rowId) { getNode: function(rowId) {
@ -101,17 +101,17 @@ window.qBittorrent.FileTree = (function() {
*/ */
toArray: function() { toArray: function() {
const nodes = []; const nodes = [];
this.root.children.each(function(node) { this.root.children.each((node) => {
this._getArrayOfNodes(node, nodes); this._getArrayOfNodes(node, nodes);
}.bind(this)); });
return nodes; return nodes;
}, },
_getArrayOfNodes: function(node, array) { _getArrayOfNodes: function(node, array) {
array.push(node); array.push(node);
node.children.each(function(child) { node.children.each((child) => {
this._getArrayOfNodes(child, array); this._getArrayOfNodes(child, array);
}.bind(this)); });
} }
}); });
@ -161,7 +161,7 @@ window.qBittorrent.FileTree = (function() {
let isFirstFile = true; let isFirstFile = true;
this.children.each(function(node) { this.children.each((node) => {
if (node.isFolder) if (node.isFolder)
node.calculateSize(); node.calculateSize();
@ -185,7 +185,7 @@ window.qBittorrent.FileTree = (function() {
progress += (node.progress * node.size); progress += (node.progress * node.size);
availability += (node.availability * node.size); availability += (node.availability * node.size);
} }
}.bind(this)); });
this.size = size; this.size = size;
this.remaining = remaining; this.remaining = remaining;

View file

@ -206,7 +206,7 @@ window.qBittorrent.Misc = (function() {
*/ */
const containsAllTerms = function(text, terms) { const containsAllTerms = function(text, terms) {
const textToSearch = text.toLowerCase(); const textToSearch = text.toLowerCase();
return terms.every(function(term) { return terms.every((term) => {
const isTermRequired = (term[0] === "+"); const isTermRequired = (term[0] === "+");
const isTermExcluded = (term[0] === "-"); const isTermExcluded = (term[0] === "-");
if (isTermRequired || isTermExcluded) { if (isTermRequired || isTermExcluded) {

View file

@ -109,14 +109,14 @@ const initializeWindows = function() {
}; };
function addClickEvent(el, fn) { function addClickEvent(el, fn) {
["Link", "Button"].each(function(item) { ["Link", "Button"].each((item) => {
if ($(el + item)) { if ($(el + item)) {
$(el + item).addEvent("click", fn); $(el + item).addEvent("click", fn);
} }
}); });
} }
addClickEvent("download", function(e) { addClickEvent("download", (e) => {
new Event(e).stop(); new Event(e).stop();
showDownloadPage(); showDownloadPage();
}); });
@ -149,7 +149,7 @@ const initializeWindows = function() {
updateMainData(); updateMainData();
}; };
addClickEvent("preferences", function(e) { addClickEvent("preferences", (e) => {
new Event(e).stop(); new Event(e).stop();
const id = "preferencesPage"; const id = "preferencesPage";
new MochaUI.Window({ new MochaUI.Window({
@ -174,7 +174,7 @@ const initializeWindows = function() {
}); });
}); });
addClickEvent("upload", function(e) { addClickEvent("upload", (e) => {
new Event(e).stop(); new Event(e).stop();
const id = "uploadPage"; const id = "uploadPage";
new MochaUI.Window({ new MochaUI.Window({
@ -400,7 +400,7 @@ const initializeWindows = function() {
} }
}; };
addClickEvent("delete", function(e) { addClickEvent("delete", (e) => {
new Event(e).stop(); new Event(e).stop();
deleteFN(); deleteFN();
}); });
@ -437,7 +437,7 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds(); const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) { if (hashes.length) {
let enable = false; let enable = false;
hashes.each(function(hash, index) { hashes.each((hash, index) => {
const row = torrentsTable.rows[hash]; const row = torrentsTable.rows[hash];
if (!row.full_data.auto_tmm) if (!row.full_data.auto_tmm)
enable = true; enable = true;
@ -1098,12 +1098,12 @@ const initializeWindows = function() {
} }
}); });
["stop", "start", "recheck"].each(function(item) { ["stop", "start", "recheck"].each((item) => {
addClickEvent(item, function(e) { addClickEvent(item, (e) => {
new Event(e).stop(); new Event(e).stop();
const hashes = torrentsTable.selectedRowsIds(); const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) { if (hashes.length) {
hashes.each(function(hash, index) { hashes.each((hash, index) => {
new Request({ new Request({
url: "api/v2/torrents/" + item, url: "api/v2/torrents/" + item,
method: "post", method: "post",
@ -1117,8 +1117,8 @@ const initializeWindows = function() {
}); });
}); });
["decreasePrio", "increasePrio", "topPrio", "bottomPrio"].each(function(item) { ["decreasePrio", "increasePrio", "topPrio", "bottomPrio"].each((item) => {
addClickEvent(item, function(e) { addClickEvent(item, (e) => {
new Event(e).stop(); new Event(e).stop();
setQueuePositionFN(item); setQueuePositionFN(item);
}); });
@ -1138,7 +1138,7 @@ const initializeWindows = function() {
} }
}; };
addClickEvent("about", function(e) { addClickEvent("about", (e) => {
new Event(e).stop(); new Event(e).stop();
const id = "aboutpage"; const id = "aboutpage";
new MochaUI.Window({ new MochaUI.Window({
@ -1160,7 +1160,7 @@ const initializeWindows = function() {
}); });
}); });
addClickEvent("logout", function(e) { addClickEvent("logout", (e) => {
new Event(e).stop(); new Event(e).stop();
new Request({ new Request({
url: "api/v2/auth/logout", url: "api/v2/auth/logout",
@ -1171,7 +1171,7 @@ const initializeWindows = function() {
}).send(); }).send();
}); });
addClickEvent("shutdown", function(e) { addClickEvent("shutdown", (e) => {
new Event(e).stop(); new Event(e).stop();
if (confirm("QBT_TR(Are you sure you want to quit qBittorrent?)QBT_TR[CONTEXT=MainWindow]")) { if (confirm("QBT_TR(Are you sure you want to quit qBittorrent?)QBT_TR[CONTEXT=MainWindow]")) {
new Request({ new Request({
@ -1189,8 +1189,8 @@ const initializeWindows = function() {
}); });
// Deactivate menu header links // Deactivate menu header links
$$("a.returnFalse").each(function(el) { $$("a.returnFalse").each((el) => {
el.addEvent("click", function(e) { el.addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
}); });
}); });

View file

@ -266,7 +266,7 @@ window.qBittorrent.PiecesBar = (() => {
if (!obj) if (!obj)
return; return;
if (!obj.parentNode) if (!obj.parentNode)
return setTimeout(function() { checkForParent(id); }, 1); return setTimeout(() => { checkForParent(id); }, 1);
obj.refresh(); obj.refresh();
} }

View file

@ -82,7 +82,7 @@ window.qBittorrent.PropFiles = (function() {
const getChildFiles = function(node) { const getChildFiles = function(node) {
if (node.isFolder) { if (node.isFolder) {
node.children.each(function(child) { node.children.each((child) => {
getChildFiles(child); getChildFiles(child);
}); });
} }
@ -92,7 +92,7 @@ window.qBittorrent.PropFiles = (function() {
} }
}; };
node.children.each(function(child) { node.children.each((child) => {
getChildFiles(child); getChildFiles(child);
}); });
@ -229,7 +229,7 @@ window.qBittorrent.PropFiles = (function() {
if (checkbox.state === "checked") { if (checkbox.state === "checked") {
setCheckboxUnchecked(checkbox); setCheckboxUnchecked(checkbox);
// set file priority for all checked to Ignored // set file priority for all checked to Ignored
torrentFilesTable.getFilteredAndSortedRows().forEach(function(row) { torrentFilesTable.getFilteredAndSortedRows().forEach((row) => {
const rowId = row.rowId; const rowId = row.rowId;
const fileId = row.full_data.fileId; const fileId = row.full_data.fileId;
const isChecked = (row.full_data.checked === TriState.Checked); const isChecked = (row.full_data.checked === TriState.Checked);
@ -244,7 +244,7 @@ window.qBittorrent.PropFiles = (function() {
setCheckboxChecked(checkbox); setCheckboxChecked(checkbox);
priority = FilePriority.Normal; priority = FilePriority.Normal;
// set file priority for all unchecked to Normal // set file priority for all unchecked to Normal
torrentFilesTable.getFilteredAndSortedRows().forEach(function(row) { torrentFilesTable.getFilteredAndSortedRows().forEach((row) => {
const rowId = row.rowId; const rowId = row.rowId;
const fileId = row.full_data.fileId; const fileId = row.full_data.fileId;
const isUnchecked = (row.full_data.checked === TriState.Unchecked); const isUnchecked = (row.full_data.checked === TriState.Unchecked);
@ -324,7 +324,7 @@ window.qBittorrent.PropFiles = (function() {
}).send(); }).send();
const ignore = (priority === FilePriority.Ignored); const ignore = (priority === FilePriority.Ignored);
ids.forEach(function(_id) { ids.forEach((_id) => {
torrentFilesTable.setIgnored(_id, ignore); torrentFilesTable.setIgnored(_id, ignore);
const combobox = $("comboPrio" + _id); const combobox = $("comboPrio" + _id);
@ -388,7 +388,7 @@ window.qBittorrent.PropFiles = (function() {
const handleNewTorrentFiles = function(files) { const handleNewTorrentFiles = function(files) {
is_seed = (files.length > 0) ? files[0].is_seed : true; is_seed = (files.length > 0) ? files[0].is_seed : true;
const rows = files.map(function(file, index) { const rows = files.map((file, index) => {
let progress = (file.progress * 100).round(1); let progress = (file.progress * 100).round(1);
if ((progress === 100) && (file.progress < 1)) if ((progress === 100) && (file.progress < 1))
progress = 99.9; progress = 99.9;
@ -421,12 +421,12 @@ window.qBittorrent.PropFiles = (function() {
const rootNode = new window.qBittorrent.FileTree.FolderNode(); const rootNode = new window.qBittorrent.FileTree.FolderNode();
rows.forEach(function(row) { rows.forEach((row) => {
const pathItems = row.fileName.split(window.qBittorrent.Filesystem.PathSeparator); const pathItems = row.fileName.split(window.qBittorrent.Filesystem.PathSeparator);
pathItems.pop(); // remove last item (i.e. file name) pathItems.pop(); // remove last item (i.e. file name)
let parent = rootNode; let parent = rootNode;
pathItems.forEach(function(folderName) { pathItems.forEach((folderName) => {
if (folderName === ".unwanted") if (folderName === ".unwanted")
return; return;
@ -474,7 +474,7 @@ window.qBittorrent.PropFiles = (function() {
parent.addChild(childNode); parent.addChild(childNode);
++rowId; ++rowId;
}.bind(this)); });
torrentFilesTable.populateTable(rootNode); torrentFilesTable.populateTable(rootNode);
torrentFilesTable.updateTable(false); torrentFilesTable.updateTable(false);
@ -516,7 +516,7 @@ window.qBittorrent.PropFiles = (function() {
const rowIds = []; const rowIds = [];
const fileIds = []; const fileIds = [];
selectedRows.forEach(function(rowId) { selectedRows.forEach((rowId) => {
const elem = $("comboPrio" + rowId); const elem = $("comboPrio" + rowId);
rowIds.push(rowId); rowIds.push(rowId);
fileIds.push(elem.get("data-file-id")); fileIds.push(elem.get("data-file-id"));
@ -526,10 +526,10 @@ window.qBittorrent.PropFiles = (function() {
const uniqueFileIds = {}; const uniqueFileIds = {};
for (let i = 0; i < rowIds.length; ++i) { for (let i = 0; i < rowIds.length; ++i) {
const rows = getAllChildren(rowIds[i], fileIds[i]); const rows = getAllChildren(rowIds[i], fileIds[i]);
rows.rowIds.forEach(function(rowId) { rows.rowIds.forEach((rowId) => {
uniqueRowIds[rowId] = true; uniqueRowIds[rowId] = true;
}); });
rows.fileIds.forEach(function(fileId) { rows.fileIds.forEach((fileId) => {
uniqueFileIds[fileId] = true; uniqueFileIds[fileId] = true;
}); });
} }
@ -721,8 +721,8 @@ window.qBittorrent.PropFiles = (function() {
const expandAllNodes = function() { const expandAllNodes = function() {
const root = torrentFilesTable.getRoot(); const root = torrentFilesTable.getRoot();
root.children.each(function(node) { root.children.each((node) => {
node.children.each(function(child) { node.children.each((child) => {
_collapseNode(child, false, true, false); _collapseNode(child, false, true, false);
}); });
}); });
@ -731,8 +731,8 @@ window.qBittorrent.PropFiles = (function() {
const collapseAllNodes = function() { const collapseAllNodes = function() {
const root = torrentFilesTable.getRoot(); const root = torrentFilesTable.getRoot();
root.children.each(function(node) { root.children.each((node) => {
node.children.each(function(child) { node.children.each((child) => {
_collapseNode(child, true, true, false); _collapseNode(child, true, true, false);
}); });
}); });
@ -757,7 +757,7 @@ window.qBittorrent.PropFiles = (function() {
if (!isChildNode || applyToChildren || !canSkipNode) if (!isChildNode || applyToChildren || !canSkipNode)
_updateNodeState(node, shouldCollapse); _updateNodeState(node, shouldCollapse);
node.children.each(function(child) { node.children.each((child) => {
_hideNode(child, shouldCollapse); _hideNode(child, shouldCollapse);
if (!child.isFolder) if (!child.isFolder)

View file

@ -86,7 +86,7 @@ window.qBittorrent.PropPeers = (function() {
} }
} }
if (response["peers_removed"]) { if (response["peers_removed"]) {
response["peers_removed"].each(function(hash) { response["peers_removed"].each((hash) => {
torrentPeersTable.removeRow(hash); torrentPeersTable.removeRow(hash);
}); });
} }

View file

@ -75,7 +75,7 @@ window.qBittorrent.PropTrackers = (function() {
torrentTrackersTable.clear(); torrentTrackersTable.clear();
if (trackers) { if (trackers) {
trackers.each(function(tracker) { trackers.each((tracker) => {
let status; let status;
switch (tracker.status) { switch (tracker.status) {
case 0: case 0:
@ -147,7 +147,7 @@ window.qBittorrent.PropTrackers = (function() {
}, },
onShow: function() { onShow: function() {
const selectedTrackers = torrentTrackersTable.selectedRowsIds(); const selectedTrackers = torrentTrackersTable.selectedRowsIds();
const containsStaticTracker = selectedTrackers.some(function(tracker) { const containsStaticTracker = selectedTrackers.some((tracker) => {
return (tracker.indexOf("** [") === 0); return (tracker.indexOf("** [") === 0);
}); });

View file

@ -58,9 +58,9 @@ window.qBittorrent.PropWebseeds = (function() {
}, },
removeAllRows: function() { removeAllRows: function() {
this.rows.each(function(tr, url) { this.rows.each((tr, url) => {
this.removeRow(url); this.removeRow(url);
}.bind(this)); });
}, },
updateRow: function(tr, row) { updateRow: function(tr, row) {
@ -124,7 +124,7 @@ window.qBittorrent.PropWebseeds = (function() {
$("error_div").set("html", ""); $("error_div").set("html", "");
if (webseeds) { if (webseeds) {
// Update WebSeeds data // Update WebSeeds data
webseeds.each(function(webseed) { webseeds.each((webseed) => {
const row = []; const row = [];
row.length = 1; row.length = 1;
row[0] = webseed.url; row[0] = webseed.url;

View file

@ -450,14 +450,14 @@ window.qBittorrent.Search = (function() {
}; };
const openSearchTorrentDescriptionUrl = function() { const openSearchTorrentDescriptionUrl = function() {
searchResultsTable.selectedRowsIds().each(function(rowId) { searchResultsTable.selectedRowsIds().each((rowId) => {
window.open(searchResultsTable.rows.get(rowId).full_data.descrLink, "_blank"); window.open(searchResultsTable.rows.get(rowId).full_data.descrLink, "_blank");
}); });
}; };
const copySearchTorrentName = function() { const copySearchTorrentName = function() {
const names = []; const names = [];
searchResultsTable.selectedRowsIds().each(function(rowId) { searchResultsTable.selectedRowsIds().each((rowId) => {
names.push(searchResultsTable.rows.get(rowId).full_data.fileName); names.push(searchResultsTable.rows.get(rowId).full_data.fileName);
}); });
return names.join("\n"); return names.join("\n");
@ -465,7 +465,7 @@ window.qBittorrent.Search = (function() {
const copySearchTorrentDownloadLink = function() { const copySearchTorrentDownloadLink = function() {
const urls = []; const urls = [];
searchResultsTable.selectedRowsIds().each(function(rowId) { searchResultsTable.selectedRowsIds().each((rowId) => {
urls.push(searchResultsTable.rows.get(rowId).full_data.fileUrl); urls.push(searchResultsTable.rows.get(rowId).full_data.fileUrl);
}); });
return urls.join("\n"); return urls.join("\n");
@ -473,7 +473,7 @@ window.qBittorrent.Search = (function() {
const copySearchTorrentDescriptionUrl = function() { const copySearchTorrentDescriptionUrl = function() {
const urls = []; const urls = [];
searchResultsTable.selectedRowsIds().each(function(rowId) { searchResultsTable.selectedRowsIds().each((rowId) => {
urls.push(searchResultsTable.rows.get(rowId).full_data.descrLink); urls.push(searchResultsTable.rows.get(rowId).full_data.descrLink);
}); });
return urls.join("\n"); return urls.join("\n");
@ -481,7 +481,7 @@ window.qBittorrent.Search = (function() {
const downloadSearchTorrent = function() { const downloadSearchTorrent = function() {
const urls = []; const urls = [];
searchResultsTable.selectedRowsIds().each(function(rowId) { searchResultsTable.selectedRowsIds().each((rowId) => {
urls.push(searchResultsTable.rows.get(rowId).full_data.fileUrl); urls.push(searchResultsTable.rows.get(rowId).full_data.fileUrl);
}); });
@ -579,7 +579,7 @@ window.qBittorrent.Search = (function() {
const getSearchCategories = function() { const getSearchCategories = function() {
const populateCategorySelect = function(categories) { const populateCategorySelect = function(categories) {
const categoryHtml = []; const categoryHtml = [];
categories.each(function(category) { categories.each((category) => {
const option = new Element("option"); const option = new Element("option");
option.set("value", category.id); option.set("value", category.id);
option.set("html", category.name); option.set("html", category.name);
@ -633,7 +633,7 @@ window.qBittorrent.Search = (function() {
if (response !== prevSearchPluginsResponse) { if (response !== prevSearchPluginsResponse) {
prevSearchPluginsResponse = response; prevSearchPluginsResponse = response;
searchPlugins.length = 0; searchPlugins.length = 0;
response.forEach(function(plugin) { response.forEach((plugin) => {
searchPlugins.push(plugin); searchPlugins.push(plugin);
}); });
@ -655,7 +655,7 @@ window.qBittorrent.Search = (function() {
return window.qBittorrent.Misc.naturalSortCollator.compare(leftName, rightName); return window.qBittorrent.Misc.naturalSortCollator.compare(leftName, rightName);
}); });
allPlugins.each(function(plugin) { allPlugins.each((plugin) => {
if (plugin.enabled === true) if (plugin.enabled === true)
pluginsHtml.push("<option value='" + window.qBittorrent.Misc.escapeHtml(plugin.name) + "'>" + window.qBittorrent.Misc.escapeHtml(plugin.fullName) + "</option>"); pluginsHtml.push("<option value='" + window.qBittorrent.Misc.escapeHtml(plugin.name) + "'>" + window.qBittorrent.Misc.escapeHtml(plugin.fullName) + "</option>");
}); });
@ -744,11 +744,11 @@ window.qBittorrent.Search = (function() {
const setupSearchTableEvents = function(enable) { const setupSearchTableEvents = function(enable) {
if (enable) if (enable)
$$(".searchTableRow").each(function(target) { $$(".searchTableRow").each((target) => {
target.addEventListener("dblclick", downloadSearchTorrent, false); target.addEventListener("dblclick", downloadSearchTorrent, false);
}); });
else else
$$(".searchTableRow").each(function(target) { $$(".searchTableRow").each((target) => {
target.removeEventListener("dblclick", downloadSearchTorrent, false); target.removeEventListener("dblclick", downloadSearchTorrent, false);
}); });
}; };

View file

@ -29,7 +29,7 @@
} }
}).activate(); }).activate();
window.addEvent("domready", function() { window.addEvent("domready", () => {
const path = new URI().getData("path"); const path = new URI().getData("path");
// set text field to current value // set text field to current value
@ -37,7 +37,7 @@
$("setLocation").value = decodeURIComponent(path); $("setLocation").value = decodeURIComponent(path);
$("setLocation").focus(); $("setLocation").focus();
$("setLocationButton").addEvent("click", function(e) { $("setLocationButton").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
// check field // check field
const location = $("setLocation").value.trim(); const location = $("setLocation").value.trim();

View file

@ -32,7 +32,7 @@
} }
}).activate(); }).activate();
window.addEvent("domready", function() { window.addEvent("domready", () => {
const hashesList = new URI().getData("hashes").split("|"); const hashesList = new URI().getData("hashes").split("|");
const origValues = new URI().getData("orig").split("|"); const origValues = new URI().getData("orig").split("|");
@ -76,7 +76,7 @@
shareLimitChanged(); shareLimitChanged();
$("default").focus(); $("default").focus();
$("save").addEvent("click", function(e) { $("save").addEvent("click", (e) => {
new Event(e).stop(); new Event(e).stop();
if (!isFormValid()) { if (!isFormValid()) {

View file

@ -154,7 +154,7 @@
let submitted = false; let submitted = false;
$("uploadForm").addEventListener("submit", function() { $("uploadForm").addEventListener("submit", () => {
$("startTorrentHidden").value = $("startTorrent").checked ? "false" : "true"; $("startTorrentHidden").value = $("startTorrent").checked ? "false" : "true";
$("dlLimitHidden").value = $("dlLimitText").value.toInt() * 1024; $("dlLimitHidden").value = $("dlLimitText").value.toInt() * 1024;
@ -164,7 +164,7 @@
submitted = true; submitted = true;
}); });
$("upload_frame").addEventListener("load", function() { $("upload_frame").addEventListener("load", () => {
if (submitted) if (submitted)
window.parent.qBittorrent.Client.closeWindows(); window.parent.qBittorrent.Client.closeWindows();
}); });

View file

@ -16,32 +16,32 @@
(function() { (function() {
MochaUI.initializeTabs("aboutTabs"); MochaUI.initializeTabs("aboutTabs");
$("aboutAboutLink").addEvent("click", function() { $("aboutAboutLink").addEvent("click", () => {
$$(".aboutTabContent").addClass("invisible"); $$(".aboutTabContent").addClass("invisible");
$("aboutAboutContent").removeClass("invisible"); $("aboutAboutContent").removeClass("invisible");
}); });
$("aboutAuthorLink").addEvent("click", function() { $("aboutAuthorLink").addEvent("click", () => {
$$(".aboutTabContent").addClass("invisible"); $$(".aboutTabContent").addClass("invisible");
$("aboutAuthorContent").removeClass("invisible"); $("aboutAuthorContent").removeClass("invisible");
}); });
$("aboutSpecialThanksLink").addEvent("click", function() { $("aboutSpecialThanksLink").addEvent("click", () => {
$$(".aboutTabContent").addClass("invisible"); $$(".aboutTabContent").addClass("invisible");
$("aboutSpecialThanksContent").removeClass("invisible"); $("aboutSpecialThanksContent").removeClass("invisible");
}); });
$("aboutTranslatorsLink").addEvent("click", function() { $("aboutTranslatorsLink").addEvent("click", () => {
$$(".aboutTabContent").addClass("invisible"); $$(".aboutTabContent").addClass("invisible");
$("aboutTranslatorsContent").removeClass("invisible"); $("aboutTranslatorsContent").removeClass("invisible");
}); });
$("aboutLicenseLink").addEvent("click", function() { $("aboutLicenseLink").addEvent("click", () => {
$$(".aboutTabContent").addClass("invisible"); $$(".aboutTabContent").addClass("invisible");
$("aboutLicenseContent").removeClass("invisible"); $("aboutLicenseContent").removeClass("invisible");
}); });
$("aboutSoftwareUsedLink").addEvent("click", function() { $("aboutSoftwareUsedLink").addEvent("click", () => {
$$(".aboutTabContent").addClass("invisible"); $$(".aboutTabContent").addClass("invisible");
$("aboutSoftwareUsedContent").removeClass("invisible"); $("aboutSoftwareUsedContent").removeClass("invisible");
}); });

View file

@ -217,7 +217,7 @@
menu: "logTableMenu", menu: "logTableMenu",
actions: { actions: {
Clear: () => { Clear: () => {
tableInfo[currentSelectedTab].instance.selectedRowsIds().forEach(function(rowId) { tableInfo[currentSelectedTab].instance.selectedRowsIds().forEach((rowId) => {
tableInfo[currentSelectedTab].instance.removeRow(rowId); tableInfo[currentSelectedTab].instance.removeRow(rowId);
}); });
@ -420,7 +420,7 @@
new ClipboardJS(".copyLogDataToClipboard", { new ClipboardJS(".copyLogDataToClipboard", {
text: function() { text: function() {
const msg = []; const msg = [];
tableInfo[currentSelectedTab].instance.selectedRowsIds().each(function(rowId) { tableInfo[currentSelectedTab].instance.selectedRowsIds().each((rowId) => {
msg.push(tableInfo[currentSelectedTab].instance.rows.get(rowId).full_data[(currentSelectedTab === "main") ? "message" : "ip"]); msg.push(tableInfo[currentSelectedTab].instance.rows.get(rowId).full_data[(currentSelectedTab === "main") ? "message" : "ip"]);
}); });

View file

@ -1935,7 +1935,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
ifaces.push({ name: default_iface_name || default_iface, value: default_iface }); ifaces.push({ name: default_iface_name || default_iface, value: default_iface });
$("networkInterface").options.add(new Option("QBT_TR(Any interface)QBT_TR[CONTEXT=OptionsDialog]", "")); $("networkInterface").options.add(new Option("QBT_TR(Any interface)QBT_TR[CONTEXT=OptionsDialog]", ""));
ifaces.forEach(function(item, index) { ifaces.forEach((item, index) => {
$("networkInterface").options.add(new Option(item.name, item.value)); $("networkInterface").options.add(new Option(item.name, item.value));
}); });
$("networkInterface").setProperty("value", default_iface); $("networkInterface").setProperty("value", default_iface);
@ -1963,7 +1963,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$("optionalIPAddressToBind").options.add(new Option("QBT_TR(All addresses)QBT_TR[CONTEXT=OptionDialog]", "")); $("optionalIPAddressToBind").options.add(new Option("QBT_TR(All addresses)QBT_TR[CONTEXT=OptionDialog]", ""));
$("optionalIPAddressToBind").options.add(new Option("QBT_TR(All IPv4 addresses)QBT_TR[CONTEXT=OptionDialog]", "0.0.0.0")); $("optionalIPAddressToBind").options.add(new Option("QBT_TR(All IPv4 addresses)QBT_TR[CONTEXT=OptionDialog]", "0.0.0.0"));
$("optionalIPAddressToBind").options.add(new Option("QBT_TR(All IPv6 addresses)QBT_TR[CONTEXT=OptionDialog]", "::")); $("optionalIPAddressToBind").options.add(new Option("QBT_TR(All IPv6 addresses)QBT_TR[CONTEXT=OptionDialog]", "::"));
addresses.forEach(function(item, index) { addresses.forEach((item, index) => {
$("optionalIPAddressToBind").options.add(new Option(item, item)); $("optionalIPAddressToBind").options.add(new Option(item, item));
}); });
$("optionalIPAddressToBind").setProperty("value", default_addr); $("optionalIPAddressToBind").setProperty("value", default_addr);

View file

@ -20,35 +20,35 @@
// Tabs // Tabs
MochaUI.initializeTabs("preferencesTabs"); MochaUI.initializeTabs("preferencesTabs");
$("PrefBehaviorLink").addEvent("click", function(e) { $("PrefBehaviorLink").addEvent("click", (e) => {
$$(".PrefTab").addClass("invisible"); $$(".PrefTab").addClass("invisible");
$("BehaviorTab").removeClass("invisible"); $("BehaviorTab").removeClass("invisible");
}); });
$("PrefDownloadsLink").addEvent("click", function(e) { $("PrefDownloadsLink").addEvent("click", (e) => {
$$(".PrefTab").addClass("invisible"); $$(".PrefTab").addClass("invisible");
$("DownloadsTab").removeClass("invisible"); $("DownloadsTab").removeClass("invisible");
}); });
$("PrefConnectionLink").addEvent("click", function(e) { $("PrefConnectionLink").addEvent("click", (e) => {
$$(".PrefTab").addClass("invisible"); $$(".PrefTab").addClass("invisible");
$("ConnectionTab").removeClass("invisible"); $("ConnectionTab").removeClass("invisible");
}); });
$("PrefSpeedLink").addEvent("click", function(e) { $("PrefSpeedLink").addEvent("click", (e) => {
$$(".PrefTab").addClass("invisible"); $$(".PrefTab").addClass("invisible");
$("SpeedTab").removeClass("invisible"); $("SpeedTab").removeClass("invisible");
}); });
$("PrefBittorrentLink").addEvent("click", function(e) { $("PrefBittorrentLink").addEvent("click", (e) => {
$$(".PrefTab").addClass("invisible"); $$(".PrefTab").addClass("invisible");
$("BittorrentTab").removeClass("invisible"); $("BittorrentTab").removeClass("invisible");
}); });
$("PrefRSSLink").addEvent("click", function(e) { $("PrefRSSLink").addEvent("click", (e) => {
$$(".PrefTab").addClass("invisible"); $$(".PrefTab").addClass("invisible");
$("RSSTab").removeClass("invisible"); $("RSSTab").removeClass("invisible");
}); });
$("PrefWebUILink").addEvent("click", function(e) { $("PrefWebUILink").addEvent("click", (e) => {
$$(".PrefTab").addClass("invisible"); $$(".PrefTab").addClass("invisible");
$("WebUITab").removeClass("invisible"); $("WebUITab").removeClass("invisible");
}); });
$("PrefAdvancedLink").addEvent("click", function(e) { $("PrefAdvancedLink").addEvent("click", (e) => {
$$(".PrefTab").addClass("invisible"); $$(".PrefTab").addClass("invisible");
$("AdvancedTab").removeClass("invisible"); $("AdvancedTab").removeClass("invisible");
}); });

View file

@ -188,12 +188,12 @@
const setupSearchPluginTableEvents = function(enable) { const setupSearchPluginTableEvents = function(enable) {
if (enable) if (enable)
$$(".searchPluginsTableRow").each(function(target) { $$(".searchPluginsTableRow").each((target) => {
target.addEventListener("dblclick", enablePlugin, false); target.addEventListener("dblclick", enablePlugin, false);
target.addEventListener("contextmenu", updateSearchPluginsTableContextMenuOffset, true); target.addEventListener("contextmenu", updateSearchPluginsTableContextMenuOffset, true);
}); });
else else
$$(".searchPluginsTableRow").each(function(target) { $$(".searchPluginsTableRow").each((target) => {
target.removeEventListener("dblclick", enablePlugin, false); target.removeEventListener("dblclick", enablePlugin, false);
target.removeEventListener("contextmenu", updateSearchPluginsTableContextMenuOffset, true); target.removeEventListener("contextmenu", updateSearchPluginsTableContextMenuOffset, true);
}); });