diff --git a/src/webui/www/private/addtrackers.html b/src/webui/www/private/addtrackers.html
index 10b77dc1f..a482f3464 100644
--- a/src/webui/www/private/addtrackers.html
+++ b/src/webui/www/private/addtrackers.html
@@ -32,7 +32,7 @@
$('trackersUrls').focus();
$('addTrackersButton').addEvent('click', function(e) {
new Event(e).stop();
- var hash = new URI().getData('hash');
+ const hash = new URI().getData('hash');
new Request({
url: 'api/v2/torrents/addTrackers',
method: 'post',
diff --git a/src/webui/www/private/confirmdeletion.html b/src/webui/www/private/confirmdeletion.html
index f078ccb47..34334ebd4 100644
--- a/src/webui/www/private/confirmdeletion.html
+++ b/src/webui/www/private/confirmdeletion.html
@@ -10,8 +10,8 @@
diff --git a/src/webui/www/private/rename.html b/src/webui/www/private/rename.html
index bc507b06a..a4b92a56c 100644
--- a/src/webui/www/private/rename.html
+++ b/src/webui/www/private/rename.html
@@ -30,7 +30,7 @@
}).activate();
window.addEvent('domready', function() {
- var name = new URI().getData('name');
+ const name = new URI().getData('name');
// set text field to current value
if (name)
$('rename').value = decodeURIComponent(name);
@@ -39,11 +39,11 @@
$('renameButton').addEvent('click', function(e) {
new Event(e).stop();
// check field
- var name = $('rename').value.trim();
+ const name = $('rename').value.trim();
if (name === null || name === "")
return false;
- var hash = new URI().getData('hash');
+ const hash = new URI().getData('hash');
if (hash) {
new Request({
url: 'api/v2/torrents/rename',
diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js
index fae7a211c..25229ea70 100644
--- a/src/webui/www/private/scripts/client.js
+++ b/src/webui/www/private/scripts/client.js
@@ -24,36 +24,36 @@
'use strict';
-var torrentsTable = new TorrentsTable();
-var torrentTrackersTable = new TorrentTrackersTable();
-var torrentPeersTable = new TorrentPeersTable();
-var torrentFilesTable = new TorrentFilesTable();
-var searchResultsTable = new SearchResultsTable();
-var searchPluginsTable = new SearchPluginsTable();
+this.torrentsTable = new TorrentsTable();
+const torrentTrackersTable = new TorrentTrackersTable();
+const torrentPeersTable = new TorrentPeersTable();
+const torrentFilesTable = new TorrentFilesTable();
+const searchResultsTable = new SearchResultsTable();
+const searchPluginsTable = new SearchPluginsTable();
-var updatePropertiesPanel = function() {};
+let updatePropertiesPanel = function() {};
-var updateTorrentData = function() {};
-var updateTrackersData = function() {};
-var updateTorrentPeersData = function() {};
-var updateWebSeedsData = function() {};
-var updateTorrentFilesData = function() {};
+let updateTorrentData = function() {};
+let updateTrackersData = function() {};
+let updateTorrentPeersData = function() {};
+let updateWebSeedsData = function() {};
+let updateTorrentFilesData = function() {};
-var updateMainData = function() {};
-var alternativeSpeedLimits = false;
-var queueing_enabled = true;
-var serverSyncMainDataInterval = 1500;
-var customSyncMainDataInterval = null;
+this.updateMainData = function() {};
+let alternativeSpeedLimits = false;
+let queueing_enabled = true;
+let serverSyncMainDataInterval = 1500;
+let customSyncMainDataInterval = null;
-var clipboardEvent;
+let clipboardEvent;
-var CATEGORIES_ALL = 1;
-var CATEGORIES_UNCATEGORIZED = 2;
+const CATEGORIES_ALL = 1;
+const CATEGORIES_UNCATEGORIZED = 2;
-var category_list = {};
+let category_list = {};
-var selected_category = CATEGORIES_ALL;
-var setCategoryFilter = function() {};
+let selected_category = CATEGORIES_ALL;
+let setCategoryFilter = function() {};
const TAGS_ALL = 1;
const TAGS_UNTAGGED = 2;
@@ -63,11 +63,11 @@ let tagList = {};
let selectedTag = TAGS_ALL;
let setTagFilter = function() {};
-var selected_filter = getLocalStorageItem('selected_filter', 'all');
-var setFilter = function() {};
-var toggleFilterDisplay = function() {};
+let selected_filter = getLocalStorageItem('selected_filter', 'all');
+let setFilter = function() {};
+let toggleFilterDisplay = function() {};
-var loadSelectedCategory = function() {
+const loadSelectedCategory = function() {
selected_category = getLocalStorageItem('selected_category', CATEGORIES_ALL);
};
loadSelectedCategory();
@@ -78,9 +78,9 @@ const loadSelectedTag = function() {
loadSelectedTag();
function genHash(string) {
- var hash = 0;
- for (var i = 0; i < string.length; ++i) {
- var c = string.charCodeAt(i);
+ let hash = 0;
+ for (let i = 0; i < string.length; ++i) {
+ const c = string.charCodeAt(i);
hash = (c + hash * 31) | 0;
}
return hash;
@@ -111,9 +111,9 @@ const qbtVersion = function() {
window.addEvent('load', function() {
- var saveColumnSizes = function() {
- var filters_width = $('Filters').getSize().x;
- var properties_height_rel = $('propertiesPanel').getSize().y / Window.getSize().y;
+ const saveColumnSizes = function() {
+ const filters_width = $('Filters').getSize().x;
+ const properties_height_rel = $('propertiesPanel').getSize().y / Window.getSize().y;
localStorage.setItem('filters_width', filters_width);
localStorage.setItem('properties_height_rel', properties_height_rel);
};
@@ -131,8 +131,8 @@ window.addEvent('load', function() {
});*/
MochaUI.Desktop.initialize();
- var buildTransfersTab = function() {
- var filt_w = localStorage.getItem('filters_width');
+ const buildTransfersTab = function() {
+ let filt_w = localStorage.getItem('filters_width');
if ($defined(filt_w))
filt_w = filt_w.toInt();
else
@@ -151,7 +151,7 @@ window.addEvent('load', function() {
});
};
- var buildSearchTab = function() {
+ const buildSearchTab = function() {
new MochaUI.Column({
id: 'searchTabColumn',
placement: 'main',
@@ -202,11 +202,11 @@ window.addEvent('load', function() {
};
toggleFilterDisplay = function(filter) {
- var element = filter + "FilterList";
+ const element = filter + "FilterList";
localStorage.setItem('filter_' + filter + "_collapsed", !$(element).hasClass("invisible"));
$(element).toggleClass("invisible")
- var parent = $(element).getParent(".filterWrapper");
- var toggleIcon = $(parent).getChildren(".filterTitle img");
+ const parent = $(element).getParent(".filterWrapper");
+ const toggleIcon = $(parent).getChildren(".filterTitle img");
if (toggleIcon)
toggleIcon[0].toggleClass("rotate");
};
@@ -232,7 +232,7 @@ window.addEvent('load', function() {
initializeWindows();
// Show Top Toolbar is enabled by default
- var showTopToolbar = true;
+ let showTopToolbar = true;
if (localStorage.getItem('show_top_toolbar') !== null)
showTopToolbar = localStorage.getItem('show_top_toolbar') == "true";
if (!showTopToolbar) {
@@ -241,7 +241,7 @@ window.addEvent('load', function() {
}
// Show Status Bar is enabled by default
- var showStatusBar = true;
+ let showStatusBar = true;
if (localStorage.getItem('show_status_bar') !== null)
showStatusBar = localStorage.getItem('show_status_bar') === "true";
if (!showStatusBar) {
@@ -249,12 +249,12 @@ window.addEvent('load', function() {
$('desktopFooterWrapper').addClass('invisible');
}
- var speedInTitle = localStorage.getItem('speed_in_browser_title_bar') == "true";
+ let speedInTitle = localStorage.getItem('speed_in_browser_title_bar') == "true";
if (!speedInTitle)
$('speedInBrowserTitleBarLink').firstChild.style.opacity = '0';
// After showing/hiding the toolbar + status bar
- var showSearchEngine = localStorage.getItem('show_search_engine') === "true";
+ let showSearchEngine = localStorage.getItem('show_search_engine') === "true";
if (!showSearchEngine) {
// uncheck menu option
$('showSearchEngineLink').firstChild.style.opacity = '0';
@@ -265,13 +265,13 @@ window.addEvent('load', function() {
// After Show Top Toolbar
MochaUI.Desktop.setDesktopSize();
- var syncMainDataLastResponseId = 0;
- var serverState = {};
+ let syncMainDataLastResponseId = 0;
+ const serverState = {};
- var removeTorrentFromCategoryList = function(hash) {
+ const removeTorrentFromCategoryList = function(hash) {
if (hash === null || hash === "")
return false;
- var removed = false;
+ let removed = false;
Object.each(category_list, function(category) {
if (Object.contains(category.torrents, hash)) {
removed = true;
@@ -281,15 +281,15 @@ window.addEvent('load', function() {
return removed;
};
- var addTorrentToCategoryList = function(torrent) {
- var category = torrent['category'];
+ const addTorrentToCategoryList = function(torrent) {
+ const category = torrent['category'];
if (typeof category === 'undefined')
return false;
if (category.length === 0) { // Empty category
removeTorrentFromCategoryList(torrent['hash']);
return true;
}
- var categoryHash = genHash(category);
+ const categoryHash = genHash(category);
if (category_list[categoryHash] === null) // This should not happen
category_list[categoryHash] = {
name: category,
@@ -339,11 +339,11 @@ window.addEvent('load', function() {
return added;
};
- var updateFilter = function(filter, filterTitle) {
+ const updateFilter = function(filter, filterTitle) {
$(filter + '_filter').firstChild.childNodes[1].nodeValue = filterTitle.replace('%1', torrentsTable.getFilteredTorrentsNumber(filter, CATEGORIES_ALL, TAGS_ALL));
};
- var updateFiltersList = function() {
+ const updateFiltersList = function() {
updateFilter('all', 'QBT_TR(All (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
updateFilter('downloading', 'QBT_TR(Downloading (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
updateFilter('seeding', 'QBT_TR(Seeding (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
@@ -355,17 +355,17 @@ window.addEvent('load', function() {
updateFilter('errored', 'QBT_TR(Errored (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
};
- var updateCategoryList = function() {
- var categoryList = $('categoryFilterList');
+ const updateCategoryList = function() {
+ const categoryList = $('categoryFilterList');
if (!categoryList)
return;
categoryList.empty();
- var create_link = function(hash, text, count) {
- var html = ''
+ const create_link = function(hash, text, count) {
+ const html = ''
+ '
'
+ escapeHtml(text) + ' (' + count + ')' + '';
- var el = new Element('li', {
+ const el = new Element('li', {
id: hash,
html: html
});
@@ -373,8 +373,8 @@ window.addEvent('load', function() {
return el;
};
- var all = torrentsTable.getRowIds().length;
- var uncategorized = 0;
+ const all = torrentsTable.getRowIds().length;
+ let uncategorized = 0;
Object.each(torrentsTable.rows, function(row) {
if (row['full_data'].category.length === 0)
uncategorized += 1;
@@ -382,27 +382,27 @@ window.addEvent('load', function() {
categoryList.appendChild(create_link(CATEGORIES_ALL, 'QBT_TR(All)QBT_TR[CONTEXT=CategoryFilterModel]', all));
categoryList.appendChild(create_link(CATEGORIES_UNCATEGORIZED, 'QBT_TR(Uncategorized)QBT_TR[CONTEXT=CategoryFilterModel]', uncategorized));
- var sortedCategories = [];
+ const sortedCategories = [];
Object.each(category_list, function(category) {
sortedCategories.push(category.name);
});
sortedCategories.sort();
Object.each(sortedCategories, function(categoryName) {
- var categoryHash = genHash(categoryName);
- var categoryCount = category_list[categoryHash].torrents.length;
+ const categoryHash = genHash(categoryName);
+ const categoryCount = category_list[categoryHash].torrents.length;
categoryList.appendChild(create_link(categoryHash, categoryName, categoryCount));
});
highlightSelectedCategory();
};
- var highlightSelectedCategory = function() {
- var categoryList = $('categoryFilterList');
+ const highlightSelectedCategory = function() {
+ const categoryList = $('categoryFilterList');
if (!categoryList)
return;
- var childrens = categoryList.childNodes;
- for (var i = 0; i < childrens.length; ++i) {
+ const childrens = categoryList.childNodes;
+ for (let i = 0; i < childrens.length; ++i) {
if (childrens[i].id == selected_category)
childrens[i].className = "selectedFilter";
else
@@ -464,16 +464,16 @@ window.addEvent('load', function() {
children[i].className = (children[i].id === selectedTag) ? "selectedFilter" : "";
};
- var syncMainDataTimer;
- var syncMainData = function() {
- var url = new URI('api/v2/sync/maindata');
+ let syncMainDataTimer;
+ const syncMainData = function() {
+ const url = new URI('api/v2/sync/maindata');
url.setData('rid', syncMainDataLastResponseId);
new Request.JSON({
url: url,
noCache: true,
method: 'get',
onFailure: function() {
- var errorDiv = $('error_div');
+ const errorDiv = $('error_div');
if (errorDiv)
errorDiv.set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]');
clearTimeout(syncMainDataTimer);
@@ -483,10 +483,10 @@ window.addEvent('load', function() {
$('error_div').set('html', '');
if (response) {
clearTimeout(torrentsFilterInputTimer);
- var torrentsTableSelectedRows;
- var update_categories = false;
+ let torrentsTableSelectedRows;
+ let update_categories = false;
let updateTags = false;
- var full_update = (response['full_update'] === true);
+ const full_update = (response['full_update'] === true);
if (full_update) {
torrentsTableSelectedRows = torrentsTable.selectedRowsIds();
torrentsTable.clear();
@@ -497,9 +497,9 @@ window.addEvent('load', function() {
syncMainDataLastResponseId = response['rid'];
}
if (response['categories']) {
- for (var key in response['categories']) {
- var category = response['categories'][key];
- var categoryHash = genHash(key);
+ for (const key in response['categories']) {
+ const category = response['categories'][key];
+ const categoryHash = genHash(key);
if (category_list[categoryHash] !== undefined) {
// only the save path can change for existing categories
category_list[categoryHash].savePath = category.savePath;
@@ -516,7 +516,7 @@ window.addEvent('load', function() {
}
if (response['categories_removed']) {
response['categories_removed'].each(function(category) {
- var categoryHash = genHash(category);
+ const categoryHash = genHash(category);
delete category_list[categoryHash];
});
update_categories = true;
@@ -541,8 +541,8 @@ window.addEvent('load', function() {
updateTags = true;
}
if (response['torrents']) {
- var updateTorrentList = false;
- for (var key in response['torrents']) {
+ let updateTorrentList = false;
+ for (const key in response['torrents']) {
response['torrents'][key]['hash'] = key;
response['torrents'][key]['rowId'] = key;
if (response['torrents'][key]['state'])
@@ -570,8 +570,8 @@ window.addEvent('load', function() {
torrentsTable.updateTable(full_update);
torrentsTable.altRow();
if (response['server_state']) {
- var tmp = response['server_state'];
- for (var k in tmp)
+ const tmp = response['server_state'];
+ for (const k in tmp)
serverState[k] = tmp[k];
processServerState();
}
@@ -601,8 +601,8 @@ window.addEvent('load', function() {
syncMainDataTimer = syncMainData.delay(100);
};
- var processServerState = function() {
- var transfer_info = friendlyUnit(serverState.dl_info_speed, true);
+ const processServerState = function() {
+ let transfer_info = friendlyUnit(serverState.dl_info_speed, true);
if (serverState.dl_rate_limit > 0)
transfer_info += " [" + friendlyUnit(serverState.dl_rate_limit, true) + "]";
transfer_info += " (" + friendlyUnit(serverState.dl_info_data, false) + ")";
@@ -674,7 +674,7 @@ window.addEvent('load', function() {
serverSyncMainDataInterval = Math.max(serverState.refresh_interval, 500);
};
- var updateAltSpeedIcon = function(enabled) {
+ const updateAltSpeedIcon = function(enabled) {
if (enabled)
$('alternativeSpeedLimits').src = "images/slow.svg";
else
@@ -768,7 +768,7 @@ window.addEvent('load', function() {
// main window tabs
- var showTransfersTab = function() {
+ const showTransfersTab = function() {
$("filtersColumn").removeClass("invisible");
$("filtersColumn_handle").removeClass("invisible");
$("mainColumn").removeClass("invisible");
@@ -780,35 +780,35 @@ window.addEvent('load', function() {
hideSearchTab();
};
- var hideTransfersTab = function() {
+ const hideTransfersTab = function() {
$("filtersColumn").addClass("invisible");
$("filtersColumn_handle").addClass("invisible");
$("mainColumn").addClass("invisible");
MochaUI.Desktop.resizePanels();
};
- var showSearchTab = function() {
+ const showSearchTab = function() {
$("searchTabColumn").removeClass("invisible");
customSyncMainDataInterval = 30000;
hideTransfersTab();
};
- var hideSearchTab = function() {
+ const hideSearchTab = function() {
$("searchTabColumn").addClass("invisible");
MochaUI.Desktop.resizePanels();
};
- var addMainWindowTabsEventListener = function() {
+ const addMainWindowTabsEventListener = function() {
$('transfersTabLink').addEvent('click', showTransfersTab);
$('searchTabLink').addEvent('click', showSearchTab);
};
- var removeMainWindowTabsEventListener = function() {
+ const removeMainWindowTabsEventListener = function() {
$('transfersTabLink').removeEvent('click', showTransfersTab);
$('searchTabLink').removeEvent('click', showSearchTab);
};
- var addSearchPanel = function() {
+ const addSearchPanel = function() {
new MochaUI.Panel({
id: 'SearchPanel',
title: 'Search',
@@ -847,7 +847,7 @@ window.addEvent('load', function() {
onResize: saveColumnSizes,
height: null
});
- var prop_h = localStorage.getItem('properties_height_rel');
+ let prop_h = localStorage.getItem('properties_height_rel');
if ($defined(prop_h))
prop_h = prop_h.toFloat() * Window.getSize().y;
else
@@ -927,11 +927,11 @@ window.addEvent('load', function() {
height: prop_h
});
- var prevTorrentsFilterValue;
- var torrentsFilterInputTimer = null;
+ let prevTorrentsFilterValue;
+ let torrentsFilterInputTimer = null;
// listen for changes to torrentsFilterInput
$('torrentsFilterInput').addEvent('input', function() {
- var value = $('torrentsFilterInput').get("value");
+ const value = $('torrentsFilterInput').get("value");
if (value !== prevTorrentsFilterValue) {
prevTorrentsFilterValue = value;
clearTimeout(torrentsFilterInputTimer);
diff --git a/src/webui/www/private/scripts/contextmenu.js b/src/webui/www/private/scripts/contextmenu.js
index b6677a346..fc39b5aa0 100644
--- a/src/webui/www/private/scripts/contextmenu.js
+++ b/src/webui/www/private/scripts/contextmenu.js
@@ -28,8 +28,8 @@
'use strict';
-var lastShownContexMenu = null;
-var ContextMenu = new Class({
+let lastShownContexMenu = null;
+const ContextMenu = new Class({
//implements
Implements: [Options, Events],
@@ -87,7 +87,7 @@ var ContextMenu = new Class({
adjustMenuPosition: function(e) {
this.updateMenuItems();
- var scrollableMenuMaxHeight = document.documentElement.clientHeight * 0.75;
+ const scrollableMenuMaxHeight = document.documentElement.clientHeight * 0.75;
if (this.menu.hasClass('scrollableMenu'))
this.menu.setStyle('max-height', scrollableMenuMaxHeight);
@@ -99,8 +99,8 @@ var ContextMenu = new Class({
});
// position the menu
- var xPosMenu = e.page.x + this.options.offsets.x;
- var yPosMenu = e.page.y + this.options.offsets.y;
+ let xPosMenu = e.page.x + this.options.offsets.x;
+ let yPosMenu = e.page.y + this.options.offsets.y;
if (xPosMenu + this.menu.offsetWidth > document.documentElement.clientWidth)
xPosMenu -= this.menu.offsetWidth;
if (yPosMenu + this.menu.offsetHeight > document.documentElement.clientHeight)
@@ -117,16 +117,16 @@ var ContextMenu = new Class({
});
// position the sub-menu
- var uls = this.menu.getElementsByTagName('ul');
- for (var i = 0; i < uls.length; ++i) {
- var ul = uls[i];
+ const uls = this.menu.getElementsByTagName('ul');
+ for (let i = 0; i < uls.length; ++i) {
+ const ul = uls[i];
if (ul.hasClass('scrollableMenu'))
ul.setStyle('max-height', scrollableMenuMaxHeight);
- var rectParent = ul.parentNode.getBoundingClientRect();
- var xPosOrigin = rectParent.left;
- var yPosOrigin = rectParent.bottom;
- var xPos = xPosOrigin + rectParent.width - 1;
- var yPos = yPosOrigin - rectParent.height - 1;
+ const rectParent = ul.parentNode.getBoundingClientRect();
+ const xPosOrigin = rectParent.left;
+ const yPosOrigin = rectParent.bottom;
+ let xPos = xPosOrigin + rectParent.width - 1;
+ let yPos = yPosOrigin - rectParent.height - 1;
if (xPos + ul.offsetWidth > document.documentElement.clientWidth)
xPos -= (ul.offsetWidth + rectParent.width - 2);
if (yPos + ul.offsetHeight > document.documentElement.clientHeight)
@@ -277,27 +277,27 @@ var ContextMenu = new Class({
}
});
-var TorrentsTableContextMenu = new Class({
+const TorrentsTableContextMenu = new Class({
Extends: ContextMenu,
updateMenuItems: function() {
- var all_are_seq_dl = true;
- var there_are_seq_dl = false;
- var all_are_f_l_piece_prio = true;
- var there_are_f_l_piece_prio = false;
- var all_are_downloaded = true;
- var all_are_paused = true;
- var there_are_paused = false;
- var all_are_force_start = true;
- var there_are_force_start = false;
- var all_are_super_seeding = true;
- var all_are_auto_tmm = true;
- var there_are_auto_tmm = false;
+ let all_are_seq_dl = true;
+ let there_are_seq_dl = false;
+ let all_are_f_l_piece_prio = true;
+ let there_are_f_l_piece_prio = false;
+ let all_are_downloaded = true;
+ let all_are_paused = true;
+ let there_are_paused = false;
+ let all_are_force_start = true;
+ let there_are_force_start = false;
+ let all_are_super_seeding = true;
+ let all_are_auto_tmm = true;
+ let there_are_auto_tmm = false;
const tagsSelectionState = Object.clone(tagList);
- var h = torrentsTable.selectedRowsIds();
+ const h = torrentsTable.selectedRowsIds();
h.each(function(item, index) {
- var data = torrentsTable.rows.get(item).full_data;
+ const data = torrentsTable.rows.get(item).full_data;
if (data['seq_dl'] !== true)
all_are_seq_dl = false;
@@ -342,12 +342,12 @@ var TorrentsTableContextMenu = new Class({
}
});
- var show_seq_dl = true;
+ let show_seq_dl = true;
if (!all_are_seq_dl && there_are_seq_dl)
show_seq_dl = false;
- var show_f_l_piece_prio = true;
+ let show_f_l_piece_prio = true;
if (!all_are_f_l_piece_prio && there_are_f_l_piece_prio)
show_f_l_piece_prio = false;
@@ -412,7 +412,7 @@ var TorrentsTableContextMenu = new Class({
},
updateCategoriesSubMenu: function(category_list) {
- var categoryList = $('contextCategoryList');
+ const categoryList = $('contextCategoryList');
categoryList.empty();
categoryList.appendChild(new Element('li', {
html: '
QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget]'
@@ -421,16 +421,16 @@ var TorrentsTableContextMenu = new Class({
html: '
QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget]'
}));
- var sortedCategories = [];
+ const sortedCategories = [];
Object.each(category_list, function(category) {
sortedCategories.push(category.name);
});
sortedCategories.sort();
- var first = true;
+ let first = true;
Object.each(sortedCategories, function(categoryName) {
- var categoryHash = genHash(categoryName);
- var el = new Element('li', {
+ const categoryHash = genHash(categoryName);
+ const el = new Element('li', {
html: '
' + escapeHtml(categoryName) + ''
});
if (first) {
@@ -479,10 +479,10 @@ var TorrentsTableContextMenu = new Class({
}
});
-var CategoriesFilterContextMenu = new Class({
+const CategoriesFilterContextMenu = new Class({
Extends: ContextMenu,
updateMenuItems: function() {
- var id = this.options.element.id;
+ const id = this.options.element.id;
if ((id != CATEGORIES_ALL) && (id != CATEGORIES_UNCATEGORIZED)) {
this.showItem('editCategory');
this.showItem('deleteCategory');
@@ -505,13 +505,13 @@ const TagsFilterContextMenu = new Class({
}
});
-var SearchPluginsTableContextMenu = new Class({
+const SearchPluginsTableContextMenu = new Class({
Extends: ContextMenu,
updateMenuItems: function() {
- var enabledColumnIndex = function(text) {
- var columns = $("searchPluginsTableFixedHeaderRow").getChildren("th");
- for (var i = 0; i < columns.length; ++i)
+ const enabledColumnIndex = function(text) {
+ const columns = $("searchPluginsTableFixedHeaderRow").getChildren("th");
+ for (let i = 0; i < columns.length; ++i)
if (columns[i].get("html") === "Enabled")
return i;
};
diff --git a/src/webui/www/private/scripts/download.js b/src/webui/www/private/scripts/download.js
index ed5d665a8..067105c4e 100644
--- a/src/webui/www/private/scripts/download.js
+++ b/src/webui/www/private/scripts/download.js
@@ -23,10 +23,10 @@
'use strict';
-var categories = {};
-var defaultSavePath = "";
+let categories = {};
+let defaultSavePath = "";
-var getCategories = function() {
+const getCategories = function() {
new Request.JSON({
url: 'api/v2/torrents/categories',
noCache: true,
@@ -34,9 +34,9 @@ var getCategories = function() {
onSuccess: function(data) {
if (data) {
categories = data;
- for (var i in data) {
- var category = data[i];
- var option = new Element("option");
+ for (const i in data) {
+ const category = data[i];
+ const option = new Element("option");
option.set('value', category.name);
option.set('html', category.name);
$('categorySelect').appendChild(option);
@@ -46,7 +46,7 @@ var getCategories = function() {
}).send();
};
-var getPreferences = function() {
+const getPreferences = function() {
new Request.JSON({
url: 'api/v2/app/preferences',
method: 'get',
@@ -74,7 +74,7 @@ var getPreferences = function() {
}).send();
};
-var changeCategorySelect = function(item) {
+const changeCategorySelect = function(item) {
if (item.value == "\\other") {
item.nextElementSibling.hidden = false;
item.nextElementSibling.value = "";
@@ -85,13 +85,13 @@ var changeCategorySelect = function(item) {
}
else {
item.nextElementSibling.hidden = true;
- var text = item.options[item.selectedIndex].innerHTML;
+ const text = item.options[item.selectedIndex].innerHTML;
item.nextElementSibling.value = text;
if ($('autoTMM').selectedIndex == 1) {
- var categoryName = item.value;
- var category = categories[categoryName];
- var savePath = defaultSavePath;
+ const categoryName = item.value;
+ const category = categories[categoryName];
+ let savePath = defaultSavePath;
if (category !== undefined)
savePath = (category['savePath'] !== "") ? category['savePath'] : (defaultSavePath + categoryName);
$('savepath').value = savePath;
@@ -99,13 +99,13 @@ var changeCategorySelect = function(item) {
}
};
-var changeTMM = function(item) {
+const changeTMM = function(item) {
if (item.selectedIndex == 1) {
$('savepath').disabled = true;
- var categorySelect = $('categorySelect');
- var categoryName = categorySelect.options[categorySelect.selectedIndex].value;
- var category = categories[categoryName];
+ const categorySelect = $('categorySelect');
+ const categoryName = categorySelect.options[categorySelect.selectedIndex].value;
+ const category = categories[categoryName];
$('savepath').value = (category === undefined) ? "" : category['savePath'];
}
else {
diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js
index 57ff3a743..2c7615196 100644
--- a/src/webui/www/private/scripts/dynamicTable.js
+++ b/src/webui/www/private/scripts/dynamicTable.js
@@ -33,10 +33,10 @@
'use strict';
-var DynamicTableHeaderContextMenuClass = null;
-var ProgressColumnWidth = -1;
+let DynamicTableHeaderContextMenuClass = null;
+let ProgressColumnWidth = -1;
-var DynamicTable = new Class({
+const DynamicTable = new Class({
initialize: function() {},
@@ -62,7 +62,7 @@ var DynamicTable = new Class({
},
setupCommonEvents: function() {
- var scrollFn = function() {
+ const scrollFn = function() {
$(this.dynamicTableFixedHeaderDivId).getElements('table')[0].style.left = -$(this.dynamicTableDivId).scrollLeft + 'px';
}.bind(this);
@@ -70,14 +70,14 @@ var DynamicTable = new Class({
// if the table exists within a panel
if ($(this.dynamicTableDivId).getParent('.panel')) {
- var resizeFn = function() {
- var panel = $(this.dynamicTableDivId).getParent('.panel');
- var h = panel.getBoundingClientRect().height - $(this.dynamicTableFixedHeaderDivId).getBoundingClientRect().height;
+ const resizeFn = function() {
+ const panel = $(this.dynamicTableDivId).getParent('.panel');
+ let h = panel.getBoundingClientRect().height - $(this.dynamicTableFixedHeaderDivId).getBoundingClientRect().height;
$(this.dynamicTableDivId).style.height = h + 'px';
// Workaround due to inaccurate calculation of elements heights by browser
- var n = 2;
+ let n = 2;
while (panel.clientWidth != panel.offsetWidth && n > 0) { // is panel vertical scrollbar visible ?
--n;
@@ -94,8 +94,8 @@ var DynamicTable = new Class({
// Workaround. Resize event is called not always (for example it isn't called when browser window changes it's size)
- var checkResizeFn = function() {
- var panel = $(this.dynamicTableDivId).getParent('.panel');
+ const checkResizeFn = function() {
+ const panel = $(this.dynamicTableDivId).getParent('.panel');
if (this.lastPanelHeight != panel.getBoundingClientRect().height) {
this.lastPanelHeight = panel.getBoundingClientRect().height;
panel.fireEvent('resize');
@@ -110,7 +110,7 @@ var DynamicTable = new Class({
this.currentHeaderAction = '';
this.canResize = false;
- var resetElementBorderStyle = function(el, side) {
+ const resetElementBorderStyle = function(el, side) {
if (side === 'left' || side !== 'right') {
el.setStyle('border-left-style', '');
el.setStyle('border-left-color', '');
@@ -123,9 +123,9 @@ var DynamicTable = new Class({
}
};
- var mouseMoveFn = function(e) {
- var brect = e.target.getBoundingClientRect();
- var mouseXRelative = e.event.clientX - brect.left;
+ const mouseMoveFn = function(e) {
+ const brect = e.target.getBoundingClientRect();
+ const mouseXRelative = e.event.clientX - brect.left;
if (this.currentHeaderAction === '') {
if (brect.width - mouseXRelative < 5) {
this.resizeTh = e.target;
@@ -143,9 +143,9 @@ var DynamicTable = new Class({
}
}
if (this.currentHeaderAction === 'drag') {
- var previousVisibleSibling = e.target.getPrevious('[class=""]');
- var borderChangeElement = previousVisibleSibling;
- var changeBorderSide = 'right';
+ const previousVisibleSibling = e.target.getPrevious('[class=""]');
+ let borderChangeElement = previousVisibleSibling;
+ let changeBorderSide = 'right';
if (mouseXRelative > brect.width / 2) {
borderChangeElement = e.target;
@@ -178,18 +178,18 @@ var DynamicTable = new Class({
this.lastClientX = e.event.clientX;
}.bind(this);
- var mouseOutFn = function(e) {
+ const mouseOutFn = function(e) {
resetElementBorderStyle(e.target);
}.bind(this);
- var onBeforeStart = function(el) {
+ const onBeforeStart = function(el) {
this.clickedTh = el;
this.currentHeaderAction = 'start';
this.dragMovement = false;
this.dragStartX = this.lastClientX;
}.bind(this);
- var onStart = function(el, event) {
+ const onStart = function(el, event) {
if (this.canResize) {
this.currentHeaderAction = 'resize';
this.startWidth = this.resizeTh.getStyle('width').toFloat();
@@ -200,9 +200,9 @@ var DynamicTable = new Class({
}
}.bind(this);
- var onDrag = function(el, event) {
+ const onDrag = function(el, event) {
if (this.currentHeaderAction === 'resize') {
- var width = this.startWidth + (event.page.x - this.dragStartX);
+ let width = this.startWidth + (event.page.x - this.dragStartX);
if (width < 16)
width = 16;
this.columns[this.resizeTh.columnName].width = width;
@@ -210,16 +210,16 @@ var DynamicTable = new Class({
}
}.bind(this);
- var onComplete = function(el, event) {
+ const onComplete = function(el, event) {
resetElementBorderStyle(this.lastHoverTh);
el.setStyle('background-color', '');
if (this.currentHeaderAction === 'resize')
localStorage.setItem('column_' + this.resizeTh.columnName + '_width_' + this.dynamicTableDivId, this.columns[this.resizeTh.columnName].width);
if ((this.currentHeaderAction === 'drag') && (el !== this.lastHoverTh)) {
this.saveColumnsOrder();
- var val = localStorage.getItem('columns_order_' + this.dynamicTableDivId).split(',');
+ const val = localStorage.getItem('columns_order_' + this.dynamicTableDivId).split(',');
val.erase(el.columnName);
- var pos = val.indexOf(this.lastHoverTh.columnName);
+ let pos = val.indexOf(this.lastHoverTh.columnName);
if (this.dropSide === 'right') ++pos;
val.splice(pos, 0, el.columnName);
localStorage.setItem('columns_order_' + this.dynamicTableDivId, val.join(','));
@@ -238,15 +238,15 @@ var DynamicTable = new Class({
this.currentHeaderAction = '';
}.bind(this);
- var onCancel = function(el) {
+ const onCancel = function(el) {
this.currentHeaderAction = '';
this.setSortedColumn(el.columnName);
}.bind(this);
- var ths = this.fixedTableHeader.getElements('th');
+ const ths = this.fixedTableHeader.getElements('th');
- for (var i = 0; i < ths.length; ++i) {
- var th = ths[i];
+ for (let i = 0; i < ths.length; ++i) {
+ const th = ths[i];
th.addEvent('mousemove', mouseMoveFn);
th.addEvent('mouseout', mouseOutFn);
th.makeResizable({
@@ -268,7 +268,7 @@ var DynamicTable = new Class({
DynamicTableHeaderContextMenuClass = new Class({
Extends: ContextMenu,
updateMenuItems: function() {
- for (var i = 0; i < this.dynamicTable.columns.length; ++i) {
+ for (let i = 0; i < this.dynamicTable.columns.length; ++i) {
if (this.dynamicTable.columns[i].caption === '')
continue;
if (this.dynamicTable.columns[i].visible !== '0')
@@ -290,28 +290,28 @@ var DynamicTable = new Class({
setupHeaderMenu: function() {
this.setupDynamicTableHeaderContextMenuClass();
- var menuId = this.dynamicTableDivId + '_headerMenu';
+ const menuId = this.dynamicTableDivId + '_headerMenu';
- var ul = new Element('ul', {
+ const ul = new Element('ul', {
id: menuId,
class: 'contextMenu scrollableMenu'
});
- var createLi = function(columnName, text) {
- var html = '
' + escapeHtml(text) + '';
+ const createLi = function(columnName, text) {
+ const html = '
' + escapeHtml(text) + '';
return new Element('li', {
html: html
});
};
- var actions = {};
+ const actions = {};
- var onMenuItemClicked = function(element, ref, action) {
+ const onMenuItemClicked = function(element, ref, action) {
this.showColumn(action, this.columns[action].visible === '0');
}.bind(this);
- for (var i = 0; i < this.columns.length; ++i) {
- var text = this.columns[i].caption;
+ for (let i = 0; i < this.columns.length; ++i) {
+ const text = this.columns[i].caption;
if (text === '')
continue;
ul.appendChild(createLi(this.columns[i].name, text));
@@ -336,7 +336,7 @@ var DynamicTable = new Class({
initColumns: function() {},
newColumn: function(name, style, caption, defaultWidth, defaultVisible) {
- var column = {};
+ const column = {};
column['name'] = name;
column['title'] = name;
column['visible'] = getLocalStorageItem('column_' + name + '_visible_' + this.dynamicTableDivId, defaultVisible ? '1' : '0');
@@ -371,25 +371,25 @@ var DynamicTable = new Class({
},
loadColumnsOrder: function() {
- var columnsOrder = [];
- var val = localStorage.getItem('columns_order_' + this.dynamicTableDivId);
+ const columnsOrder = [];
+ const val = localStorage.getItem('columns_order_' + this.dynamicTableDivId);
if (val === null || val === undefined) return;
val.split(',').forEach(function(v) {
if ((v in this.columns) && (!columnsOrder.contains(v)))
columnsOrder.push(v);
}.bind(this));
- for (var i = 0; i < this.columns.length; ++i)
+ for (let i = 0; i < this.columns.length; ++i)
if (!columnsOrder.contains(this.columns[i].name))
columnsOrder.push(this.columns[i].name);
- for (i = 0; i < this.columns.length; ++i)
+ for (let i = 0; i < this.columns.length; ++i)
this.columns[i] = this.columns[columnsOrder[i]];
},
saveColumnsOrder: function() {
- var val = '';
- for (var i = 0; i < this.columns.length; ++i) {
+ let val = '';
+ for (let i = 0; i < this.columns.length; ++i) {
if (i > 0)
val += ',';
val += this.columns[i].name;
@@ -403,10 +403,10 @@ var DynamicTable = new Class({
},
updateHeader: function(header) {
- var ths = header.getElements('th');
+ const ths = header.getElements('th');
- for (var i = 0; i < ths.length; ++i) {
- var th = ths[i];
+ for (let i = 0; i < ths.length; ++i) {
+ const th = ths[i];
th._this = this;
th.setAttribute('title', this.columns[i].caption);
th.innerHTML = this.columns[i].caption;
@@ -421,19 +421,19 @@ var DynamicTable = new Class({
},
getColumnPos: function(columnName) {
- for (var i = 0; i < this.columns.length; ++i)
+ for (let i = 0; i < this.columns.length; ++i)
if (this.columns[i].name == columnName)
return i;
return -1;
},
updateColumn: function(columnName) {
- var pos = this.getColumnPos(columnName);
- var visible = ((this.columns[pos].visible != '0') && !this.columns[pos].force_hide);
- var ths = this.hiddenTableHeader.getElements('th');
- var fths = this.fixedTableHeader.getElements('th');
- var trs = this.tableBody.getElements('tr');
- var style = 'width: ' + this.columns[pos].width + 'px;' + this.columns[pos].style;
+ const pos = this.getColumnPos(columnName);
+ const visible = ((this.columns[pos].visible != '0') && !this.columns[pos].force_hide);
+ const ths = this.hiddenTableHeader.getElements('th');
+ const fths = this.fixedTableHeader.getElements('th');
+ const trs = this.tableBody.getElements('tr');
+ const style = 'width: ' + this.columns[pos].width + 'px;' + this.columns[pos].style;
ths[pos].setAttribute('style', style);
fths[pos].setAttribute('style', style);
@@ -441,13 +441,13 @@ var DynamicTable = new Class({
if (visible) {
ths[pos].removeClass('invisible');
fths[pos].removeClass('invisible');
- for (var i = 0; i < trs.length; ++i)
+ for (let i = 0; i < trs.length; ++i)
trs[i].getElements('td')[pos].removeClass('invisible');
}
else {
ths[pos].addClass('invisible');
fths[pos].addClass('invisible');
- for (var j = 0; j < trs.length; ++j)
+ for (let j = 0; j < trs.length; ++j)
trs[j].getElements('td')[pos].addClass('invisible');
}
if (this.columns[pos].onResize !== null) {
@@ -461,7 +461,7 @@ var DynamicTable = new Class({
setSortedColumn: function(column) {
if (column != this.sortedColumn) {
- var oldColumn = this.sortedColumn;
+ const oldColumn = this.sortedColumn;
this.sortedColumn = column;
this.reverseSort = '0';
this.setSortedColumnIcon(column, oldColumn, false);
@@ -477,14 +477,14 @@ var DynamicTable = new Class({
},
setSortedColumnIcon: function(newColumn, oldColumn, isReverse) {
- var getCol = function(headerDivId, colName) {
- var colElem = $$("#" + headerDivId + " .column_" + colName);
+ const getCol = function(headerDivId, colName) {
+ const colElem = $$("#" + headerDivId + " .column_" + colName);
if (colElem.length == 1)
return colElem[0];
return null;
};
- var colElem = getCol(this.dynamicTableFixedHeaderDivId, newColumn);
+ const colElem = getCol(this.dynamicTableFixedHeaderDivId, newColumn);
if (colElem !== null) {
colElem.addClass('sorted');
if (isReverse)
@@ -492,7 +492,7 @@ var DynamicTable = new Class({
else
colElem.removeClass('reverse');
}
- var oldColElem = getCol(this.dynamicTableFixedHeaderDivId, oldColumn);
+ const oldColElem = getCol(this.dynamicTableFixedHeaderDivId, oldColumn);
if (oldColElem !== null) {
oldColElem.removeClass('sorted');
oldColElem.removeClass('reverse');
@@ -513,7 +513,7 @@ var DynamicTable = new Class({
if (!MUI.ieLegacySupport)
return;
- var trs = this.tableBody.getElements('tr');
+ const trs = this.tableBody.getElements('tr');
trs.each(function(el, i) {
if (i % 2) {
el.addClass('alt');
@@ -527,9 +527,9 @@ var DynamicTable = new Class({
selectAll: function() {
this.deselectAll();
- var trs = this.tableBody.getElements('tr');
- for (var i = 0; i < trs.length; ++i) {
- var tr = trs[i];
+ const trs = this.tableBody.getElements('tr');
+ for (let i = 0; i < trs.length; ++i) {
+ const tr = trs[i];
this.selectedRows.push(tr.rowId);
if (!tr.hasClass('selected'))
tr.addClass('selected');
@@ -559,8 +559,8 @@ var DynamicTable = new Class({
return;
}
- var select = false;
- var that = this;
+ let select = false;
+ const that = this;
this.tableBody.getElements('tr').each(function(tr) {
if ((tr.rowId == rowId1) || (tr.rowId == rowId2)) {
select = !select;
@@ -584,7 +584,7 @@ var DynamicTable = new Class({
},
setRowClass: function() {
- var that = this;
+ const that = this;
this.tableBody.getElements('tr').each(function(tr) {
if (that.isRowSelected(tr.rowId))
tr.addClass('selected');
@@ -596,8 +596,8 @@ var DynamicTable = new Class({
onSelectedRowChanged: function() {},
updateRowData: function(data) {
- var rowId = data['rowId'];
- var row;
+ const rowId = data['rowId'];
+ let row;
if (!this.rows.has(rowId)) {
row = {};
@@ -610,23 +610,23 @@ var DynamicTable = new Class({
row['data'] = data;
- for (var x in data)
+ for (const x in data)
row['full_data'][x] = data[x];
},
getFilteredAndSortedRows: function() {
- var filteredRows = [];
+ const filteredRows = [];
- var rows = this.rows.getValues();
+ const rows = this.rows.getValues();
- for (var i = 0; i < rows.length; ++i) {
+ for (let i = 0; i < rows.length; ++i) {
filteredRows.push(rows[i]);
filteredRows[rows[i].rowId] = rows[i];
}
filteredRows.sort(function(row1, row2) {
- var column = this.columns[this.sortedColumn];
- var res = column.compareRows(row1, row2);
+ const column = this.columns[this.sortedColumn];
+ const res = column.compareRows(row1, row2);
if (this.reverseSort == '0')
return res;
else
@@ -636,8 +636,8 @@ var DynamicTable = new Class({
},
getTrByRowId: function(rowId) {
- var trs = this.tableBody.getElements('tr');
- for (var i = 0; i < trs.length; ++i)
+ const trs = this.tableBody.getElements('tr');
+ for (let i = 0; i < trs.length; ++i)
if (trs[i].rowId == rowId)
return trs[i];
return null;
@@ -647,26 +647,26 @@ var DynamicTable = new Class({
if (fullUpdate === undefined)
fullUpdate = false;
- var rows = this.getFilteredAndSortedRows();
+ const rows = this.getFilteredAndSortedRows();
- for (var i = 0; i < this.selectedRows.length; ++i)
+ for (let i = 0; i < this.selectedRows.length; ++i)
if (!(this.selectedRows[i] in rows)) {
this.selectedRows.splice(i, 1);
--i;
}
- var trs = this.tableBody.getElements('tr');
+ const trs = this.tableBody.getElements('tr');
- for (var rowPos = 0; rowPos < rows.length; ++rowPos) {
- var rowId = rows[rowPos]['rowId'];
- var tr_found = false;
- for (var j = rowPos; j < trs.length; ++j)
+ for (let rowPos = 0; rowPos < rows.length; ++rowPos) {
+ const rowId = rows[rowPos]['rowId'];
+ let tr_found = false;
+ for (let j = rowPos; j < trs.length; ++j)
if (trs[j]['rowId'] == rowId) {
tr_found = true;
if (rowPos == j)
break;
trs[j].inject(trs[rowPos], 'before');
- var tmpTr = trs[j];
+ const tmpTr = trs[j];
trs.splice(j, 1);
trs.splice(rowPos, 0, tmpTr);
break;
@@ -674,7 +674,7 @@ var DynamicTable = new Class({
if (tr_found) // row already exists in the table
this.updateRow(trs[rowPos], fullUpdate);
else { // else create a new row in the table
- var tr = new Element('tr');
+ const tr = new Element('tr');
tr['rowId'] = rows[rowPos]['rowId'];
@@ -716,8 +716,8 @@ var DynamicTable = new Class({
this.setupTr(tr);
- for (var k = 0; k < this.columns.length; ++k) {
- var td = new Element('td');
+ for (let k = 0; k < this.columns.length; ++k) {
+ const td = new Element('td');
if ((this.columns[k].visible == '0') || this.columns[k].force_hide)
td.addClass('invisible');
td.injectInside(tr);
@@ -741,7 +741,7 @@ var DynamicTable = new Class({
}
}
- rowPos = rows.length;
+ let rowPos = rows.length;
while ((rowPos < trs.length) && (trs.length > 0)) {
trs[trs.length - 1].dispose();
@@ -752,11 +752,11 @@ var DynamicTable = new Class({
setupTr: function(tr) {},
updateRow: function(tr, fullUpdate) {
- var row = this.rows.get(tr.rowId);
- var data = row[fullUpdate ? 'full_data' : 'data'];
+ const row = this.rows.get(tr.rowId);
+ const data = row[fullUpdate ? 'full_data' : 'data'];
- var tds = tr.getElements('td');
- for (var i = 0; i < this.columns.length; ++i) {
+ const tds = tr.getElements('td');
+ for (let i = 0; i < this.columns.length; ++i) {
if (data.hasOwnProperty(this.columns[i].dataProperties[0]))
this.columns[i].updateTd(tds[i], row);
}
@@ -765,7 +765,7 @@ var DynamicTable = new Class({
removeRow: function(rowId) {
this.selectedRows.erase(rowId);
- var tr = this.getTrByRowId(rowId);
+ const tr = this.getTrByRowId(rowId);
if (tr !== null) {
tr.dispose();
this.rows.erase(rowId);
@@ -777,7 +777,7 @@ var DynamicTable = new Class({
clear: function() {
this.deselectAll();
this.rows.empty();
- var trs = this.tableBody.getElements('tr');
+ const trs = this.tableBody.getElements('tr');
while (trs.length > 0) {
trs[trs.length - 1].dispose();
trs.pop();
@@ -793,7 +793,7 @@ var DynamicTable = new Class({
},
});
-var TorrentsTable = new Class({
+const TorrentsTable = new Class({
Extends: DynamicTable,
initColumns: function() {
@@ -843,7 +843,7 @@ var TorrentsTable = new Class({
// state_icon
this.columns['state_icon'].updateTd = function(td, row) {
- var state = this.getRowValue(row);
+ let state = this.getRowValue(row);
// normalize states
switch (state) {
case "forcedDL":
@@ -881,10 +881,10 @@ var TorrentsTable = new Class({
break; // do nothing
}
- var img_path = 'images/skin/' + state + '.svg';
+ const img_path = 'images/skin/' + state + '.svg';
if (td.getChildren('img').length) {
- var img = td.getChildren('img')[0];
+ const img = td.getChildren('img')[0];
if (img.src.indexOf(img_path) < 0) {
img.set('src', img_path);
img.set('title', state);
@@ -900,10 +900,10 @@ var TorrentsTable = new Class({
// status
this.columns['status'].updateTd = function(td, row) {
- var state = this.getRowValue(row);
+ const state = this.getRowValue(row);
if (!state) return;
- var status;
+ let status;
switch (state) {
case "downloading":
status = "QBT_TR(Downloading)QBT_TR[CONTEXT=TransferListDelegate]";
@@ -973,8 +973,8 @@ var TorrentsTable = new Class({
};
this.columns['priority'].compareRows = function(row1, row2) {
- var row1_val = this.getRowValue(row1);
- var row2_val = this.getRowValue(row2);
+ let row1_val = this.getRowValue(row1);
+ let row2_val = this.getRowValue(row2);
if (row1_val < 1)
row1_val = 1000000;
if (row2_val < 1)
@@ -1003,13 +1003,13 @@ var TorrentsTable = new Class({
// progress
this.columns['progress'].updateTd = function(td, row) {
- var progress = this.getRowValue(row);
- var progressFormated = (progress * 100).round(1);
+ const progress = this.getRowValue(row);
+ let progressFormated = (progress * 100).round(1);
if (progressFormated == 100.0 && progress != 1.0)
progressFormated = 99.9;
if (td.getChildren('div').length) {
- var div = td.getChildren('div')[0];
+ const div = td.getChildren('div')[0];
if (td.resized) {
td.resized = false;
div.setWidth(ProgressColumnWidth - 5);
@@ -1028,11 +1028,11 @@ var TorrentsTable = new Class({
};
this.columns['progress'].onResize = function(columnName) {
- var pos = this.getColumnPos(columnName);
- var trs = this.tableBody.getElements('tr');
+ const pos = this.getColumnPos(columnName);
+ const trs = this.tableBody.getElements('tr');
ProgressColumnWidth = -1;
- for (var i = 0; i < trs.length; ++i) {
- var td = trs[i].getElements('td')[pos];
+ for (let i = 0; i < trs.length; ++i) {
+ const td = trs[i].getElements('td')[pos];
if (ProgressColumnWidth < 0)
ProgressColumnWidth = td.offsetWidth;
td.resized = true;
@@ -1042,20 +1042,20 @@ var TorrentsTable = new Class({
// num_seeds
this.columns['num_seeds'].updateTd = function(td, row) {
- var num_seeds = this.getRowValue(row, 0);
- var num_complete = this.getRowValue(row, 1);
- var html = num_seeds;
+ const num_seeds = this.getRowValue(row, 0);
+ const num_complete = this.getRowValue(row, 1);
+ let html = num_seeds;
if (num_complete != -1)
html += ' (' + num_complete + ')';
td.set('html', html);
td.set('title', html);
};
this.columns['num_seeds'].compareRows = function(row1, row2) {
- var num_seeds1 = this.getRowValue(row1, 0);
- var num_complete1 = this.getRowValue(row1, 1);
+ const num_seeds1 = this.getRowValue(row1, 0);
+ const num_complete1 = this.getRowValue(row1, 1);
- var num_seeds2 = this.getRowValue(row2, 0);
- var num_complete2 = this.getRowValue(row2, 1);
+ const num_seeds2 = this.getRowValue(row2, 0);
+ const num_complete2 = this.getRowValue(row2, 1);
if (num_complete1 < num_complete2)
return -1;
@@ -1091,8 +1091,8 @@ var TorrentsTable = new Class({
// ratio
this.columns['ratio'].updateTd = function(td, row) {
- var ratio = this.getRowValue(row);
- var html = null;
+ const ratio = this.getRowValue(row);
+ let html = null;
if (ratio == -1)
html = '∞';
else
@@ -1106,20 +1106,20 @@ var TorrentsTable = new Class({
// added on
this.columns['added_on'].updateTd = function(td, row) {
- var date = new Date(this.getRowValue(row) * 1000).toLocaleString();
+ const date = new Date(this.getRowValue(row) * 1000).toLocaleString();
td.set('html', date);
td.set('title', date);
};
// completion_on
this.columns['completion_on'].updateTd = function(td, row) {
- var val = this.getRowValue(row);
+ const val = this.getRowValue(row);
if ((val === 0xffffffff) || (val < 0)) {
td.set('html', '');
td.set('title', '');
}
else {
- var date = new Date(this.getRowValue(row) * 1000).toLocaleString();
+ const date = new Date(this.getRowValue(row) * 1000).toLocaleString();
td.set('html', date);
td.set('title', date);
}
@@ -1130,7 +1130,7 @@ var TorrentsTable = new Class({
// dl_limit, up_limit
this.columns['dl_limit'].updateTd = function(td, row) {
- var speed = this.getRowValue(row);
+ const speed = this.getRowValue(row);
if (speed === 0) {
td.set('html', '∞');
td.set('title', '∞');
@@ -1163,7 +1163,7 @@ var TorrentsTable = new Class({
// last_activity
this.columns['last_activity'].updateTd = function(td, row) {
- var val = this.getRowValue(row);
+ const val = this.getRowValue(row);
if (val < 1) {
td.set('html', '∞');
td.set('title', '∞');
@@ -1184,10 +1184,10 @@ var TorrentsTable = new Class({
},
applyFilter: function(row, filterName, categoryHash, tagHash, filterTerms) {
- var state = row['full_data'].state;
- var name = row['full_data'].name.toLowerCase();
- var inactive = false;
- var r;
+ const state = row['full_data'].state;
+ const name = row['full_data'].name.toLowerCase();
+ let inactive = false;
+ let r;
switch (filterName) {
case 'downloading':
@@ -1227,7 +1227,7 @@ var TorrentsTable = new Class({
break;
}
- var categoryHashInt = parseInt(categoryHash);
+ const categoryHashInt = parseInt(categoryHash);
if (!isNaN(categoryHashInt)) {
switch (categoryHashInt) {
case CATEGORIES_ALL:
@@ -1265,7 +1265,7 @@ var TorrentsTable = new Class({
}
if (filterTerms) {
- for (var i = 0; i < filterTerms.length; ++i) {
+ for (let i = 0; i < filterTerms.length; ++i) {
if (name.indexOf(filterTerms[i]) === -1)
return false;
}
@@ -1275,19 +1275,19 @@ var TorrentsTable = new Class({
},
getFilteredTorrentsNumber: function(filterName, categoryHash, tagHash) {
- var cnt = 0;
- var rows = this.rows.getValues();
+ let cnt = 0;
+ const rows = this.rows.getValues();
- for (var i = 0; i < rows.length; ++i)
+ for (let i = 0; i < rows.length; ++i)
if (this.applyFilter(rows[i], filterName, categoryHash, tagHash, null)) ++cnt;
return cnt;
},
getFilteredTorrentsHashes: function(filterName, categoryHash, tagHash) {
- var rowsHashes = [];
- var rows = this.rows.getValues();
+ const rowsHashes = [];
+ const rows = this.rows.getValues();
- for (var i = 0; i < rows.length; ++i)
+ for (let i = 0; i < rows.length; ++i)
if (this.applyFilter(rows[i], filterName, categoryHash, tagHash, null))
rowsHashes.push(rows[i]['rowId']);
@@ -1295,13 +1295,13 @@ var TorrentsTable = new Class({
},
getFilteredAndSortedRows: function() {
- var filteredRows = [];
+ const filteredRows = [];
- var rows = this.rows.getValues();
- var filterText = $('torrentsFilterInput').value.trim().toLowerCase();
- var filterTerms = (filterText.length > 0) ? filterText.split(" ") : null;
+ const rows = this.rows.getValues();
+ const filterText = $('torrentsFilterInput').value.trim().toLowerCase();
+ const filterTerms = (filterText.length > 0) ? filterText.split(" ") : null;
- for (var i = 0; i < rows.length; ++i) {
+ for (let i = 0; i < rows.length; ++i) {
if (this.applyFilter(rows[i], selected_filter, selected_category, selectedTag, filterTerms)) {
filteredRows.push(rows[i]);
filteredRows[rows[i].rowId] = rows[i];
@@ -1309,8 +1309,8 @@ var TorrentsTable = new Class({
}
filteredRows.sort(function(row1, row2) {
- var column = this.columns[this.sortedColumn];
- var res = column.compareRows(row1, row2);
+ const column = this.columns[this.sortedColumn];
+ const res = column.compareRows(row1, row2);
if (this.reverseSort == '0')
return res;
else
@@ -1324,8 +1324,8 @@ var TorrentsTable = new Class({
e.stop();
this._this.deselectAll();
this._this.selectRow(this.rowId);
- var row = this._this.rows.get(this.rowId);
- var state = row['full_data'].state;
+ const row = this._this.rows.get(this.rowId);
+ const state = row['full_data'].state;
if (~state.indexOf('paused'))
startFN();
else
@@ -1344,7 +1344,7 @@ var TorrentsTable = new Class({
}
});
-var TorrentPeersTable = new Class({
+const TorrentPeersTable = new Class({
Extends: DynamicTable,
initColumns: function() {
@@ -1372,8 +1372,8 @@ var TorrentPeersTable = new Class({
// country
this.columns['country'].updateTd = function(td, row) {
- var country = this.getRowValue(row, 0);
- var country_code = this.getRowValue(row, 1);
+ const country = this.getRowValue(row, 0);
+ const country_code = this.getRowValue(row, 1);
if (!country_code) {
if (td.getChildren('img').length)
@@ -1381,10 +1381,10 @@ var TorrentPeersTable = new Class({
return;
}
- var img_path = 'images/flags/' + country_code + '.svg';
+ const img_path = 'images/flags/' + country_code + '.svg';
if (td.getChildren('img').length) {
- var img = td.getChildren('img')[0];
+ const img = td.getChildren('img')[0];
img.set('src', img_path);
img.set('class', 'flags');
img.set('alt', country);
@@ -1402,13 +1402,13 @@ var TorrentPeersTable = new Class({
// ip
this.columns['ip'].compareRows = function(row1, row2) {
- var ip1 = this.getRowValue(row1);
- var ip2 = this.getRowValue(row2);
+ const ip1 = this.getRowValue(row1);
+ const ip2 = this.getRowValue(row2);
- var a = ip1.split(".");
- var b = ip2.split(".");
+ const a = ip1.split(".");
+ const b = ip2.split(".");
- for (var i = 0; i < 4; ++i) {
+ for (let i = 0; i < 4; ++i) {
if (a[i] != b[i])
return a[i] - b[i];
}
@@ -1419,8 +1419,8 @@ var TorrentPeersTable = new Class({
// progress, relevance
this.columns['progress'].updateTd = function(td, row) {
- var progress = this.getRowValue(row);
- var progressFormated = (progress * 100).round(1);
+ const progress = this.getRowValue(row);
+ let progressFormated = (progress * 100).round(1);
if (progressFormated == 100.0 && progress != 1.0)
progressFormated = 99.9;
progressFormated += "%";
@@ -1433,7 +1433,7 @@ var TorrentPeersTable = new Class({
// dl_speed, up_speed
this.columns['dl_speed'].updateTd = function(td, row) {
- var speed = this.getRowValue(row);
+ const speed = this.getRowValue(row);
if (speed === 0) {
td.set('html', '');
td.set('title', '');
@@ -1474,7 +1474,7 @@ var TorrentPeersTable = new Class({
}
});
-var SearchResultsTable = new Class({
+const SearchResultsTable = new Class({
Extends: DynamicTable,
initColumns: function() {
@@ -1488,18 +1488,18 @@ var SearchResultsTable = new Class({
},
initColumnsFunctions: function() {
- var displayText = function(td, row) {
- var value = escapeHtml(this.getRowValue(row));
+ const displayText = function(td, row) {
+ const value = escapeHtml(this.getRowValue(row));
td.set('html', value);
td.set('title', value);
}
- var displaySize = function(td, row) {
+ const displaySize = function(td, row) {
const size = friendlyUnit(this.getRowValue(row), false);
td.set('html', size);
td.set('title', size);
}
- var displayNum = function(td, row) {
- var value = escapeHtml(this.getRowValue(row));
+ const displayNum = function(td, row) {
+ const value = escapeHtml(this.getRowValue(row));
const formattedValue = (value === "-1") ? "Unknown" : value;
td.set('html', formattedValue);
td.set('title', formattedValue);
@@ -1513,9 +1513,9 @@ var SearchResultsTable = new Class({
},
getFilteredAndSortedRows: function() {
- var containsAll = function(text, searchTerms) {
+ const containsAll = function(text, searchTerms) {
text = text.toLowerCase();
- for (var i = 0; i < searchTerms.length; ++i) {
+ for (let i = 0; i < searchTerms.length; ++i) {
if (text.indexOf(searchTerms[i].toLowerCase()) === -1)
return false;
}
@@ -1523,12 +1523,12 @@ var SearchResultsTable = new Class({
return true;
};
- var getSizeFilters = function() {
- var minSize = (searchSizeFilter.min > 0.00) ? (searchSizeFilter.min * Math.pow(1024, searchSizeFilter.minUnit)) : 0.00;
- var maxSize = (searchSizeFilter.max > 0.00) ? (searchSizeFilter.max * Math.pow(1024, searchSizeFilter.maxUnit)) : 0.00;
+ const getSizeFilters = function() {
+ let minSize = (searchSizeFilter.min > 0.00) ? (searchSizeFilter.min * Math.pow(1024, searchSizeFilter.minUnit)) : 0.00;
+ let maxSize = (searchSizeFilter.max > 0.00) ? (searchSizeFilter.max * Math.pow(1024, searchSizeFilter.maxUnit)) : 0.00;
if ((minSize > maxSize) && (maxSize > 0.00)) {
- var tmp = minSize;
+ const tmp = minSize;
minSize = maxSize;
maxSize = tmp;
}
@@ -1539,12 +1539,12 @@ var SearchResultsTable = new Class({
}
};
- var getSeedsFilters = function() {
- var minSeeds = (searchSeedsFilter.min > 0) ? searchSeedsFilter.min : 0;
- var maxSeeds = (searchSeedsFilter.max > 0) ? searchSeedsFilter.max : 0;
+ const getSeedsFilters = function() {
+ let minSeeds = (searchSeedsFilter.min > 0) ? searchSeedsFilter.min : 0;
+ let maxSeeds = (searchSeedsFilter.max > 0) ? searchSeedsFilter.max : 0;
if ((minSeeds > maxSeeds) && (maxSeeds > 0)) {
- var tmp = minSeeds;
+ const tmp = minSeeds;
minSeeds = maxSeeds;
maxSeeds = tmp;
}
@@ -1555,17 +1555,17 @@ var SearchResultsTable = new Class({
}
};
- var filteredRows = [];
- var rows = this.rows.getValues();
- var searchTerms = searchPattern.toLowerCase().split(" ");
- var filterTerms = searchFilterPattern.toLowerCase().split(" ");
- var sizeFilters = getSizeFilters();
- var seedsFilters = getSeedsFilters();
- var searchInTorrentName = $('searchInTorrentName').get('value') === "names";
+ let filteredRows = [];
+ const rows = this.rows.getValues();
+ const searchTerms = searchPattern.toLowerCase().split(" ");
+ const filterTerms = searchFilterPattern.toLowerCase().split(" ");
+ const sizeFilters = getSizeFilters();
+ const seedsFilters = getSeedsFilters();
+ const searchInTorrentName = $('searchInTorrentName').get('value') === "names";
if (searchInTorrentName || filterTerms.length || (searchSizeFilter.min > 0.00) || (searchSizeFilter.max > 0.00)) {
- for (var i = 0; i < rows.length; ++i) {
- var row = rows[i];
+ for (let i = 0; i < rows.length; ++i) {
+ const row = rows[i];
if (searchInTorrentName && !containsAll(row.full_data.fileName, searchTerms)) continue;
if (filterTerms.length && !containsAll(row.full_data.fileName, filterTerms)) continue;
@@ -1582,8 +1582,8 @@ var SearchResultsTable = new Class({
}
filteredRows.sort(function(row1, row2) {
- var column = this.columns[this.sortedColumn];
- var res = column.compareRows(row1, row2);
+ const column = this.columns[this.sortedColumn];
+ const res = column.compareRows(row1, row2);
if (this.reverseSort == '0')
return res;
else
@@ -1598,7 +1598,7 @@ var SearchResultsTable = new Class({
}
});
-var SearchPluginsTable = new Class({
+const SearchPluginsTable = new Class({
Extends: DynamicTable,
initColumns: function() {
@@ -1611,7 +1611,7 @@ var SearchPluginsTable = new Class({
},
initColumnsFunctions: function() {
- var displayText = function(td, row) {
+ const displayText = function(td, row) {
const value = escapeHtml(this.getRowValue(row));
td.set('html', value);
td.set('title', value);
@@ -1621,7 +1621,7 @@ var SearchPluginsTable = new Class({
this.columns['version'].updateTd = displayText;
this.columns['url'].updateTd = displayText;
this.columns['enabled'].updateTd = function(td, row) {
- var value = this.getRowValue(row);
+ const value = this.getRowValue(row);
if (value) {
td.set('html', "Yes");
td.set('title', "Yes");
@@ -1642,7 +1642,7 @@ var SearchPluginsTable = new Class({
}
});
-var TorrentTrackersTable = new Class({
+const TorrentTrackersTable = new Class({
Extends: DynamicTable,
initColumns: function() {
@@ -1657,7 +1657,7 @@ var TorrentTrackersTable = new Class({
},
});
-var TorrentFilesTable = new Class({
+const TorrentFilesTable = new Class({
Extends: DynamicTable,
initColumns: function() {
@@ -1673,26 +1673,26 @@ var TorrentFilesTable = new Class({
},
initColumnsFunctions: function() {
- var displaySize = function(td, row) {
+ const displaySize = function(td, row) {
const size = friendlyUnit(this.getRowValue(row), false);
td.set('html', size);
td.set('title', size);
}
- var displayPercentage = function(td, row) {
+ const displayPercentage = function(td, row) {
const value = friendlyPercentage(this.getRowValue(row));
td.set('html', value);
td.set('title', value);
};
this.columns['checked'].updateTd = function(td, row) {
- var id = row.rowId;
- var value = this.getRowValue(row);
+ const id = row.rowId;
+ const value = this.getRowValue(row);
if (isDownloadCheckboxExists(id)) {
updateDownloadCheckbox(id, value);
}
else {
- var treeImg = new Element('img', {
+ const treeImg = new Element('img', {
src: 'images/L.gif',
style: 'margin-bottom: -2px'
});
@@ -1703,10 +1703,10 @@ var TorrentFilesTable = new Class({
this.columns['size'].updateTd = displaySize;
this.columns['progress'].updateTd = function(td, row) {
- var id = row.rowId;
- var value = this.getRowValue(row);
+ const id = row.rowId;
+ const value = this.getRowValue(row);
- var progressBar = $('pbf_' + id);
+ const progressBar = $('pbf_' + id);
if (progressBar === null) {
td.adopt(new ProgressBar(value.toFloat(), {
'id': 'pbf_' + id,
@@ -1719,8 +1719,8 @@ var TorrentFilesTable = new Class({
};
this.columns['priority'].updateTd = function(td, row) {
- var id = row.rowId;
- var value = this.getRowValue(row);
+ const id = row.rowId;
+ const value = this.getRowValue(row);
if (isPriorityComboExists(id))
updatePriorityCombo(id, value);
diff --git a/src/webui/www/private/scripts/misc.js b/src/webui/www/private/scripts/misc.js
index 212b663e1..537b7c908 100644
--- a/src/webui/www/private/scripts/misc.js
+++ b/src/webui/www/private/scripts/misc.js
@@ -32,7 +32,7 @@
* JS counterpart of the function in src/misc.cpp
*/
function friendlyUnit(value, isSpeed) {
- var units = [
+ const units = [
"QBT_TR(B)QBT_TR[CONTEXT=misc]",
"QBT_TR(KiB)QBT_TR[CONTEXT=misc]",
"QBT_TR(MiB)QBT_TR[CONTEXT=misc]",
@@ -45,7 +45,7 @@ function friendlyUnit(value, isSpeed) {
if ((value === undefined) || (value === null) || (value < 0))
return "QBT_TR(Unknown)QBT_TR[CONTEXT=misc]";
- var i = 0;
+ let i = 0;
while (value >= 1024.0 && i < 6) {
value /= 1024.0;
++i;
@@ -57,12 +57,12 @@ function friendlyUnit(value, isSpeed) {
else return 3; // TiB, PiB, EiB
}
- var ret;
+ let ret;
if (i === 0)
ret = value + " " + units[i];
else {
- var precision = friendlyUnitPrecision(i);
- var offset = Math.pow(10, precision);
+ const precision = friendlyUnitPrecision(i);
+ const offset = Math.pow(10, precision);
// Don't round up
ret = (Math.floor(offset * value) / offset).toFixed(precision) + " " + units[i];
}
@@ -76,21 +76,21 @@ function friendlyUnit(value, isSpeed) {
* JS counterpart of the function in src/misc.cpp
*/
function friendlyDuration(seconds) {
- var MAX_ETA = 8640000;
+ const MAX_ETA = 8640000;
if (seconds < 0 || seconds >= MAX_ETA)
return "∞";
if (seconds === 0)
return "0";
if (seconds < 60)
return "QBT_TR(< 1m)QBT_TR[CONTEXT=misc]";
- var minutes = seconds / 60;
+ let minutes = seconds / 60;
if (minutes < 60)
return "QBT_TR(%1m)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(minutes));
- var hours = minutes / 60;
+ let hours = minutes / 60;
minutes = minutes % 60;
if (hours < 24)
return "QBT_TR(%1h %2m)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes));
- var days = hours / 24;
+ const days = hours / 24;
hours = hours % 24;
if (days < 100)
return "QBT_TR(%1d %2h)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(days)).replace("%2", parseInt(hours));
@@ -98,7 +98,7 @@ function friendlyDuration(seconds) {
}
function friendlyPercentage(value) {
- var percentage = (value * 100).round(1);
+ let percentage = (value * 100).round(1);
if (isNaN(percentage) || (percentage < 0))
percentage = 0;
if (percentage > 100)
@@ -141,12 +141,12 @@ if (!Date.prototype.toISOString) {
* JS counterpart of the function in src/misc.cpp
*/
function parseHtmlLinks(text) {
- var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
+ const exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp, "$1");
}
function escapeHtml(str) {
- var div = document.createElement('div');
+ const div = document.createElement('div');
div.appendChild(document.createTextNode(str));
return div.innerHTML;
}
diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js
index d5b633781..f4b48daa9 100644
--- a/src/webui/www/private/scripts/mocha-init.js
+++ b/src/webui/www/private/scripts/mocha-init.js
@@ -53,43 +53,43 @@ if (typeof localStorage == 'undefined') {
}
function getLocalStorageItem(name, defaultVal) {
- var val = localStorage.getItem(name);
+ let val = localStorage.getItem(name);
if (val === null || val === undefined)
val = defaultVal;
return val;
}
-var saveWindowSize = function() {};
-var loadWindowWidth = function() {};
-var loadWindowHeight = function() {};
-var showDownloadPage = function() {};
-var globalUploadLimitFN = function() {};
-var uploadLimitFN = function() {};
-var shareRatioFN = function() {};
-var toggleSequentialDownloadFN = function() {};
-var toggleFirstLastPiecePrioFN = function() {};
-var setSuperSeedingFN = function() {};
-var setForceStartFN = function() {};
-var globalDownloadLimitFN = function() {};
-var StatisticsLinkFN = function() {};
-var downloadLimitFN = function() {};
-var deleteFN = function() {};
-var pauseFN = function() {};
-var startFN = function() {};
-var autoTorrentManagementFN = function() {};
-var recheckFN = function() {};
-var reannounceFN = function() {};
-var setLocationFN = function() {};
-var renameFN = function() {};
-var torrentNewCategoryFN = function() {};
-var torrentSetCategoryFN = function() {};
-var createCategoryFN = function() {};
-var editCategoryFN = function() {};
-var removeCategoryFN = function() {};
-var deleteUnusedCategoriesFN = function() {};
-var startTorrentsByCategoryFN = function() {};
-var pauseTorrentsByCategoryFN = function() {};
-var deleteTorrentsByCategoryFN = function() {};
+let saveWindowSize = function() {};
+let loadWindowWidth = function() {};
+let loadWindowHeight = function() {};
+let showDownloadPage = function() {};
+let globalUploadLimitFN = function() {};
+let uploadLimitFN = function() {};
+let shareRatioFN = function() {};
+let toggleSequentialDownloadFN = function() {};
+let toggleFirstLastPiecePrioFN = function() {};
+let setSuperSeedingFN = function() {};
+let setForceStartFN = function() {};
+let globalDownloadLimitFN = function() {};
+let StatisticsLinkFN = function() {};
+let downloadLimitFN = function() {};
+let deleteFN = function() {};
+let pauseFN = function() {};
+let startFN = function() {};
+let autoTorrentManagementFN = function() {};
+let recheckFN = function() {};
+let reannounceFN = function() {};
+let setLocationFN = function() {};
+let renameFN = function() {};
+let torrentNewCategoryFN = function() {};
+let torrentSetCategoryFN = function() {};
+let createCategoryFN = function() {};
+let editCategoryFN = function() {};
+let removeCategoryFN = function() {};
+let deleteUnusedCategoriesFN = function() {};
+let startTorrentsByCategoryFN = function() {};
+let pauseTorrentsByCategoryFN = function() {};
+let deleteTorrentsByCategoryFN = function() {};
let torrentAddTagsFN = function() {};
let torrentSetTagsFN = function() {};
let torrentRemoveAllTagsFN = function() {};
@@ -99,14 +99,14 @@ let deleteUnusedTagsFN = function() {};
let startTorrentsByTagFN = function() {};
let pauseTorrentsByTagFN = function() {};
let deleteTorrentsByTagFN = function() {};
-var copyNameFN = function() {};
-var copyMagnetLinkFN = function() {};
-var copyHashFN = function() {};
-var setQueuePositionFN = function() {};
+let copyNameFN = function() {};
+let copyMagnetLinkFN = function() {};
+let copyHashFN = function() {};
+let setQueuePositionFN = function() {};
-var initializeWindows = function() {
+const initializeWindows = function() {
saveWindowSize = function(windowId) {
- var size = $(windowId).getSize();
+ const size = $(windowId).getSize();
localStorage.setItem('window_' + windowId + '_width', size.x);
localStorage.setItem('window_' + windowId + '_height', size.y);
};
@@ -133,8 +133,8 @@ var initializeWindows = function() {
});
showDownloadPage = function(urls) {
- var id = 'downloadPage';
- var contentUrl = 'download.html';
+ const id = 'downloadPage';
+ let contentUrl = 'download.html';
if (urls && urls.length)
contentUrl += '?urls=' + urls.join("|");
@@ -160,7 +160,7 @@ var initializeWindows = function() {
addClickEvent('preferences', function(e) {
new Event(e).stop();
- var id = 'preferencesPage';
+ const id = 'preferencesPage';
new MochaUI.Window({
id: id,
title: "QBT_TR(Options)QBT_TR[CONTEXT=OptionsDialog]",
@@ -185,7 +185,7 @@ var initializeWindows = function() {
addClickEvent('upload', function(e) {
new Event(e).stop();
- var id = 'uploadPage';
+ const id = 'uploadPage';
new MochaUI.Window({
id: id,
title: "QBT_TR(Upload local torrent)QBT_TR[CONTEXT=HttpServer]",
@@ -222,7 +222,7 @@ var initializeWindows = function() {
};
uploadLimitFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'uploadLimitPage',
@@ -241,16 +241,16 @@ var initializeWindows = function() {
};
shareRatioFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
- var shareRatio = null;
- var torrentsHaveSameShareRatio = true;
+ let shareRatio = null;
+ let torrentsHaveSameShareRatio = true;
// check if all selected torrents have same share ratio
- for (var i = 0; i < hashes.length; ++i) {
- var hash = hashes[i];
- var row = torrentsTable.rows[hash].full_data;
- var origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.max_ratio + "|" + row.max_seeding_time;
+ for (let i = 0; i < hashes.length; ++i) {
+ const hash = hashes[i];
+ const row = torrentsTable.rows[hash].full_data;
+ const origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.max_ratio + "|" + row.max_seeding_time;
// initialize value
if (shareRatio === null)
@@ -263,7 +263,7 @@ var initializeWindows = function() {
}
// if all torrents have same share ratio, display that share ratio. else use the default
- var orig = torrentsHaveSameShareRatio ? shareRatio : "";
+ const orig = torrentsHaveSameShareRatio ? shareRatio : "";
new MochaUI.Window({
id: 'shareRatioPage',
title: "QBT_TR(Torrent Upload/Download Ratio Limiting)QBT_TR[CONTEXT=UpDownRatioDialog]",
@@ -280,7 +280,7 @@ var initializeWindows = function() {
};
toggleSequentialDownloadFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/toggleSequentialDownload',
@@ -294,7 +294,7 @@ var initializeWindows = function() {
};
toggleFirstLastPiecePrioFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/toggleFirstLastPiecePrio',
@@ -308,7 +308,7 @@ var initializeWindows = function() {
};
setSuperSeedingFN = function(val) {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/setSuperSeeding',
@@ -323,7 +323,7 @@ var initializeWindows = function() {
};
setForceStartFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/setForceStart',
@@ -354,7 +354,7 @@ var initializeWindows = function() {
};
StatisticsLinkFN = function() {
- var id = 'statisticspage';
+ const id = 'statisticspage';
new MochaUI.Window({
id: id,
title: 'QBT_TR(Statistics)QBT_TR[CONTEXT=StatsDialog]',
@@ -371,7 +371,7 @@ var initializeWindows = function() {
};
downloadLimitFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'downloadLimitPage',
@@ -390,7 +390,7 @@ var initializeWindows = function() {
};
deleteFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'confirmDeletionPage',
@@ -414,7 +414,7 @@ var initializeWindows = function() {
});
pauseFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/pause',
@@ -428,7 +428,7 @@ var initializeWindows = function() {
};
startFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/resume',
@@ -442,11 +442,11 @@ var initializeWindows = function() {
};
autoTorrentManagementFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
- var enable = false;
+ let enable = false;
hashes.each(function(hash, index) {
- var row = torrentsTable.rows[hash];
+ const row = torrentsTable.rows[hash];
if (!row.full_data.auto_tmm)
enable = true;
});
@@ -463,7 +463,7 @@ var initializeWindows = function() {
};
recheckFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/recheck',
@@ -477,7 +477,7 @@ var initializeWindows = function() {
};
reannounceFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/reannounce',
@@ -491,11 +491,11 @@ var initializeWindows = function() {
};
setLocationFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
- var hash = hashes[0];
- var row = torrentsTable.rows[hash];
- var path = encodeURIComponent(row.full_data.save_path);
+ const hash = hashes[0];
+ const row = torrentsTable.rows[hash];
+ const path = encodeURIComponent(row.full_data.save_path);
new MochaUI.Window({
id: 'setLocationPage',
title: "QBT_TR(Set location)QBT_TR[CONTEXT=TransferListWidget]",
@@ -513,10 +513,10 @@ var initializeWindows = function() {
};
renameFN = function() {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length == 1) {
- var hash = hashes[0];
- var row = torrentsTable.rows[hash];
+ const hash = hashes[0];
+ const row = torrentsTable.rows[hash];
if (row) {
new MochaUI.Window({
id: 'renamePage',
@@ -536,8 +536,8 @@ var initializeWindows = function() {
};
torrentNewCategoryFN = function() {
- var action = "set";
- var hashes = torrentsTable.selectedRowsIds();
+ const action = "set";
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'newCategoryPage',
@@ -556,10 +556,10 @@ var initializeWindows = function() {
};
torrentSetCategoryFN = function(categoryHash) {
- var categoryName = '';
+ let categoryName = '';
if (categoryHash != 0)
categoryName = category_list[categoryHash].name;
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/setCategory',
@@ -573,7 +573,7 @@ var initializeWindows = function() {
};
createCategoryFN = function() {
- var action = "create";
+ const action = "create";
new MochaUI.Window({
id: 'newCategoryPage',
title: "QBT_TR(New Category)QBT_TR[CONTEXT=CategoryFilterWidget]",
@@ -591,9 +591,9 @@ var initializeWindows = function() {
};
editCategoryFN = function(categoryHash) {
- var action = "edit";
- var categoryName = category_list[categoryHash].name;
- var savePath = category_list[categoryHash].savePath;
+ const action = "edit";
+ const categoryName = category_list[categoryHash].name;
+ const savePath = category_list[categoryHash].savePath;
new MochaUI.Window({
id: 'editCategoryPage',
title: "QBT_TR(Edit Category)QBT_TR[CONTEXT=TransferListWidget]",
@@ -611,7 +611,7 @@ var initializeWindows = function() {
};
removeCategoryFN = function(categoryHash) {
- var categoryName = category_list[categoryHash].name;
+ const categoryName = category_list[categoryHash].name;
new Request({
url: 'api/v2/torrents/removeCategories',
method: 'post',
@@ -623,8 +623,8 @@ var initializeWindows = function() {
};
deleteUnusedCategoriesFN = function() {
- var categories = [];
- for (var hash in category_list) {
+ const categories = [];
+ for (const hash in category_list) {
if (torrentsTable.getFilteredTorrentsNumber('all', hash, TAGS_ALL) === 0)
categories.push(category_list[hash].name);
}
@@ -639,7 +639,7 @@ var initializeWindows = function() {
};
startTorrentsByCategoryFN = function(categoryHash) {
- var hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash, TAGS_ALL);
+ const hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash, TAGS_ALL);
if (hashes.length) {
new Request({
url: 'api/v2/torrents/resume',
@@ -653,7 +653,7 @@ var initializeWindows = function() {
};
pauseTorrentsByCategoryFN = function(categoryHash) {
- var hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash, TAGS_ALL);
+ const hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash, TAGS_ALL);
if (hashes.length) {
new Request({
url: 'api/v2/torrents/pause',
@@ -667,7 +667,7 @@ var initializeWindows = function() {
};
deleteTorrentsByCategoryFN = function(categoryHash) {
- var hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash, TAGS_ALL);
+ const hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash, TAGS_ALL);
if (hashes.length) {
new MochaUI.Window({
id: 'confirmDeletionPage',
@@ -827,12 +827,12 @@ var initializeWindows = function() {
};
copyNameFN = function() {
- var selectedRows = torrentsTable.selectedRowsIds();
- var names = [];
+ const selectedRows = torrentsTable.selectedRowsIds();
+ const names = [];
if (selectedRows.length) {
- var rows = torrentsTable.getFilteredAndSortedRows();
- for (var i = 0; i < selectedRows.length; ++i) {
- var hash = selectedRows[i];
+ const rows = torrentsTable.getFilteredAndSortedRows();
+ for (let i = 0; i < selectedRows.length; ++i) {
+ const hash = selectedRows[i];
names.push(rows[hash].full_data.name);
}
}
@@ -840,12 +840,12 @@ var initializeWindows = function() {
};
copyMagnetLinkFN = function() {
- var selectedRows = torrentsTable.selectedRowsIds();
- var magnets = [];
+ const selectedRows = torrentsTable.selectedRowsIds();
+ const magnets = [];
if (selectedRows.length) {
- var rows = torrentsTable.getFilteredAndSortedRows();
- for (var i = 0; i < selectedRows.length; ++i) {
- var hash = selectedRows[i];
+ const rows = torrentsTable.getFilteredAndSortedRows();
+ for (let i = 0; i < selectedRows.length; ++i) {
+ const hash = selectedRows[i];
magnets.push(rows[hash].full_data.magnet_uri);
}
}
@@ -873,7 +873,7 @@ var initializeWindows = function() {
['pause', 'resume', 'recheck'].each(function(item) {
addClickEvent(item, function(e) {
new Event(e).stop();
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
hashes.each(function(hash, index) {
new Request({
@@ -897,7 +897,7 @@ var initializeWindows = function() {
});
setQueuePositionFN = function(cmd) {
- var hashes = torrentsTable.selectedRowsIds();
+ const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/' + cmd,
@@ -912,7 +912,7 @@ var initializeWindows = function() {
addClickEvent('about', function(e) {
new Event(e).stop();
- var id = 'aboutpage';
+ const id = 'aboutpage';
new MochaUI.Window({
id: id,
title: 'QBT_TR(About qBittorrent)QBT_TR[CONTEXT=AboutDialog]',
diff --git a/src/webui/www/private/scripts/progressbar.js b/src/webui/www/private/scripts/progressbar.js
index c0ad50b2f..959c78be5 100644
--- a/src/webui/www/private/scripts/progressbar.js
+++ b/src/webui/www/private/scripts/progressbar.js
@@ -28,9 +28,9 @@
'use strict';
-var ProgressBar = new Class({
+const ProgressBar = new Class({
initialize: function(value, parameters) {
- var vals = {
+ const vals = {
'id': 'progressbar_' + (ProgressBars++),
'value': $pick(value, 0),
'width': 0,
@@ -42,7 +42,7 @@ var ProgressBar = new Class({
};
if (parameters && $type(parameters) == 'object') $extend(vals, parameters);
if (vals.height < 12) vals.height = 12;
- var obj = new Element('div', {
+ const obj = new Element('div', {
'id': vals.id,
'class': 'progressbar_wrapper',
'styles': {
@@ -110,7 +110,7 @@ function ProgressBar_setValue(value) {
this.vals.light.empty();
this.vals.dark.appendText(value.round(1).toFixed(1) + '%');
this.vals.light.appendText(value.round(1).toFixed(1) + '%');
- var r = parseInt(this.vals.width * (value / 100));
+ const r = parseInt(this.vals.width * (value / 100));
this.vals.dark.setStyle('clip', 'rect(0,' + r + 'px,' + this.vals.height + 'px,0)');
this.vals.light.setStyle('clip', 'rect(0,' + this.vals.width + 'px,' + this.vals.height + 'px,' + r + 'px)');
}
@@ -126,15 +126,15 @@ function ProgressBar_setWidth(value) {
}
function ProgressBar_checkForParent(id) {
- var obj = $(id);
+ const obj = $(id);
if (!obj) return;
if (!obj.parentNode) return setTimeout('ProgressBar_checkForParent("' + id + '")', 1);
obj.setStyle('width', '100%');
- var w = obj.offsetWidth;
+ const w = obj.offsetWidth;
obj.vals.dark.setStyle('width', w);
obj.vals.light.setStyle('width', w);
obj.vals.width = w;
obj.setValue(obj.vals.value);
}
-var ProgressBars = 0;
+let ProgressBars = 0;
diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js
index 8ef02e61b..1f4debd2d 100644
--- a/src/webui/www/private/scripts/prop-files.js
+++ b/src/webui/www/private/scripts/prop-files.js
@@ -28,10 +28,10 @@
'use strict';
-var is_seed = true;
-var current_hash = "";
+let is_seed = true;
+this.current_hash = "";
-var FilePriority = {
+const FilePriority = {
"Ignored": 0,
"Normal": 1,
"High": 6,
@@ -39,7 +39,7 @@ var FilePriority = {
"Mixed": -1
};
-var normalizePriority = function(priority) {
+const normalizePriority = function(priority) {
switch (priority) {
case FilePriority.Ignored:
case FilePriority.Normal:
@@ -52,30 +52,30 @@ var normalizePriority = function(priority) {
}
};
-var fileCheckboxChanged = function(e) {
- var checkbox = e.target;
- var priority = checkbox.checked ? FilePriority.Normal : FilePriority.Ignored;
- var id = checkbox.get('data-id');
+const fileCheckboxChanged = function(e) {
+ const checkbox = e.target;
+ const priority = checkbox.checked ? FilePriority.Normal : FilePriority.Ignored;
+ const id = checkbox.get('data-id');
setFilePriority(id, priority);
setGlobalCheckboxState();
return true;
};
-var fileComboboxChanged = function(e) {
- var combobox = e.target;
- var newPriority = combobox.value;
- var id = combobox.get('data-id');
+const fileComboboxChanged = function(e) {
+ const combobox = e.target;
+ const newPriority = combobox.value;
+ const id = combobox.get('data-id');
setFilePriority(id, newPriority);
};
-var isDownloadCheckboxExists = function(id) {
+const isDownloadCheckboxExists = function(id) {
return ($('cbPrio' + id) !== null);
};
-var createDownloadCheckbox = function(id, download) {
- var checkbox = new Element('input');
+const createDownloadCheckbox = function(id, download) {
+ const checkbox = new Element('input');
checkbox.set('type', 'checkbox');
if (download)
checkbox.set('checked', 'checked');
@@ -86,17 +86,17 @@ var createDownloadCheckbox = function(id, download) {
return checkbox;
};
-var updateDownloadCheckbox = function(id, download) {
- var checkbox = $('cbPrio' + id);
+const updateDownloadCheckbox = function(id, download) {
+ const checkbox = $('cbPrio' + id);
checkbox.checked = download;
};
-var isPriorityComboExists = function(id) {
+const isPriorityComboExists = function(id) {
return ($('comboPrio' + id) !== null);
};
-var createPriorityOptionElement = function(priority, selected, html) {
- var elem = new Element('option');
+const createPriorityOptionElement = function(priority, selected, html) {
+ const elem = new Element('option');
elem.set('value', priority.toString());
elem.set('html', html);
if (selected)
@@ -104,8 +104,8 @@ var createPriorityOptionElement = function(priority, selected, html) {
return elem;
};
-var createPriorityCombo = function(id, selectedPriority) {
- var select = new Element('select');
+const createPriorityCombo = function(id, selectedPriority) {
+ const select = new Element('select');
select.set('id', 'comboPrio' + id);
select.set('data-id', id);
select.set('disabled', is_seed);
@@ -120,8 +120,8 @@ var createPriorityCombo = function(id, selectedPriority) {
return select;
};
-var updatePriorityCombo = function(id, selectedPriority) {
- var combobox = $('comboPrio' + id);
+const updatePriorityCombo = function(id, selectedPriority) {
+ const combobox = $('comboPrio' + id);
if (parseInt(combobox.value) !== selectedPriority)
selectComboboxPriority(combobox, selectedPriority);
@@ -130,10 +130,10 @@ var updatePriorityCombo = function(id, selectedPriority) {
combobox.disabled = is_seed;
};
-var selectComboboxPriority = function(combobox, priority) {
- var options = combobox.options;
- for (var i = 0; i < options.length; ++i) {
- var option = options[i];
+const selectComboboxPriority = function(combobox, priority) {
+ const options = combobox.options;
+ for (let i = 0; i < options.length; ++i) {
+ const option = options[i];
if (parseInt(option.value) === priority)
option.setAttribute('selected', '');
else
@@ -143,9 +143,9 @@ var selectComboboxPriority = function(combobox, priority) {
combobox.value = priority;
};
-var switchCheckboxState = function() {
- var rows = [];
- var priority = FilePriority.Ignored;
+const switchCheckboxState = function() {
+ const rows = [];
+ let priority = FilePriority.Ignored;
if ($('tristate_cb').state === "checked") {
setGlobalCheckboxUnchecked();
@@ -169,7 +169,7 @@ var switchCheckboxState = function() {
setFilePriority(rows, priority);
};
-var setGlobalCheckboxState = function() {
+const setGlobalCheckboxState = function() {
if (isAllCheckboxesChecked())
setGlobalCheckboxChecked();
else if (isAllCheckboxesUnchecked())
@@ -178,44 +178,44 @@ var setGlobalCheckboxState = function() {
setGlobalCheckboxPartial();
};
-var setGlobalCheckboxChecked = function() {
+const setGlobalCheckboxChecked = function() {
$('tristate_cb').state = "checked";
$('tristate_cb').indeterminate = false;
$('tristate_cb').checked = true;
};
-var setGlobalCheckboxUnchecked = function() {
+const setGlobalCheckboxUnchecked = function() {
$('tristate_cb').state = "unchecked";
$('tristate_cb').indeterminate = false;
$('tristate_cb').checked = false;
};
-var setGlobalCheckboxPartial = function() {
+const setGlobalCheckboxPartial = function() {
$('tristate_cb').state = "partial";
$('tristate_cb').indeterminate = true;
};
-var isAllCheckboxesChecked = function() {
- var checkboxes = $$('input.DownloadedCB');
- for (var i = 0; i < checkboxes.length; ++i) {
+const isAllCheckboxesChecked = function() {
+ const checkboxes = $$('input.DownloadedCB');
+ for (let i = 0; i < checkboxes.length; ++i) {
if (!checkboxes[i].checked)
return false;
}
return true;
};
-var isAllCheckboxesUnchecked = function() {
- var checkboxes = $$('input.DownloadedCB');
- for (var i = 0; i < checkboxes.length; ++i) {
+const isAllCheckboxesUnchecked = function() {
+ const checkboxes = $$('input.DownloadedCB');
+ for (let i = 0; i < checkboxes.length; ++i) {
if (checkboxes[i].checked)
return false;
}
return true;
};
-var setFilePriority = function(id, priority) {
+const setFilePriority = function(id, priority) {
if (current_hash === "") return;
- var ids = Array.isArray(id) ? id : [id];
+ const ids = Array.isArray(id) ? id : [id];
clearTimeout(loadTorrentFilesDataTimer);
new Request({
@@ -232,20 +232,20 @@ var setFilePriority = function(id, priority) {
}).send();
ids.forEach(function(_id) {
- var combobox = $('comboPrio' + _id);
+ const combobox = $('comboPrio' + _id);
if (combobox !== null)
selectComboboxPriority(combobox, priority);
});
};
-var loadTorrentFilesDataTimer;
-var loadTorrentFilesData = function() {
+let loadTorrentFilesDataTimer;
+const loadTorrentFilesData = function() {
if ($('prop_files').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
// Tab changed, don't do anything
return;
}
- var new_hash = torrentsTable.getCurrentTorrentHash();
+ const new_hash = torrentsTable.getCurrentTorrentHash();
if (new_hash === "") {
torrentFilesTable.clear();
clearTimeout(loadTorrentFilesDataTimer);
@@ -256,7 +256,7 @@ var loadTorrentFilesData = function() {
torrentFilesTable.clear();
current_hash = new_hash;
}
- var url = new URI('api/v2/torrents/files?hash=' + current_hash);
+ const url = new URI('api/v2/torrents/files?hash=' + current_hash);
new Request.JSON({
url: url,
noCache: true,
@@ -266,19 +266,19 @@ var loadTorrentFilesData = function() {
loadTorrentFilesDataTimer = loadTorrentFilesData.delay(5000);
},
onSuccess: function(files) {
- var selectedFiles = torrentFilesTable.selectedRowsIds();
+ const selectedFiles = torrentFilesTable.selectedRowsIds();
if (!files) {
torrentFilesTable.clear();
return;
}
- var i = 0;
+ let i = 0;
files.each(function(file) {
if (i === 0)
is_seed = file.is_seed;
- var row = {
+ const row = {
rowId: i,
checked: (file.priority !== FilePriority.Ignored),
name: escapeHtml(file.name),
@@ -307,35 +307,35 @@ var loadTorrentFilesData = function() {
}).send();
};
-var updateTorrentFilesData = function() {
+updateTorrentFilesData = function() {
clearTimeout(loadTorrentFilesDataTimer);
loadTorrentFilesData();
};
-var torrentFilesContextMenu = new ContextMenu({
+const torrentFilesContextMenu = new ContextMenu({
targets: '#torrentFilesTableDiv tr',
menu: 'torrentFilesMenu',
actions: {
FilePrioIgnore: function(element, ref) {
- var selectedRows = torrentFilesTable.selectedRowsIds();
+ const selectedRows = torrentFilesTable.selectedRowsIds();
if (selectedRows.length === 0) return;
setFilePriority(selectedRows, FilePriority.Ignored);
},
FilePrioNormal: function(element, ref) {
- var selectedRows = torrentFilesTable.selectedRowsIds();
+ const selectedRows = torrentFilesTable.selectedRowsIds();
if (selectedRows.length === 0) return;
setFilePriority(selectedRows, FilePriority.Normal);
},
FilePrioHigh: function(element, ref) {
- var selectedRows = torrentFilesTable.selectedRowsIds();
+ const selectedRows = torrentFilesTable.selectedRowsIds();
if (selectedRows.length === 0) return;
setFilePriority(selectedRows, FilePriority.High);
},
FilePrioMaximum: function(element, ref) {
- var selectedRows = torrentFilesTable.selectedRowsIds();
+ const selectedRows = torrentFilesTable.selectedRowsIds();
if (selectedRows.length === 0) return;
setFilePriority(selectedRows, FilePriority.Maximum);
@@ -357,14 +357,14 @@ var torrentFilesContextMenu = new ContextMenu({
torrentFilesTable.setup('torrentFilesTableDiv', 'torrentFilesTableFixedHeaderDiv', torrentFilesContextMenu);
// inject checkbox into table header
-var tableHeaders = $$('#torrentFilesTableFixedHeaderDiv .dynamicTableHeader th');
+const tableHeaders = $$('#torrentFilesTableFixedHeaderDiv .dynamicTableHeader th');
if (tableHeaders.length > 0) {
- var checkbox = new Element('input');
+ const checkbox = new Element('input');
checkbox.set('type', 'checkbox');
checkbox.set('id', 'tristate_cb');
checkbox.addEvent('click', switchCheckboxState);
- var checkboxTH = tableHeaders[0];
+ const checkboxTH = tableHeaders[0];
checkbox.injectInside(checkboxTH);
}
diff --git a/src/webui/www/private/scripts/prop-general.js b/src/webui/www/private/scripts/prop-general.js
index 4f7b03fc7..2349c6b7a 100644
--- a/src/webui/www/private/scripts/prop-general.js
+++ b/src/webui/www/private/scripts/prop-general.js
@@ -28,7 +28,7 @@
'use strict';
-var clearData = function() {
+const clearData = function() {
$('time_elapsed').set('html', '');
$('eta').set('html', '');
$('nb_connections').set('html', '');
@@ -55,14 +55,14 @@ var clearData = function() {
$('comment').set('html', '');
};
-var loadTorrentDataTimer;
-var loadTorrentData = function() {
+let loadTorrentDataTimer;
+const loadTorrentData = function() {
if ($('prop_general').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
// Tab changed, don't do anything
return;
}
- var current_hash = torrentsTable.getCurrentTorrentHash();
+ const current_hash = torrentsTable.getCurrentTorrentHash();
if (current_hash === "") {
clearData();
clearTimeout(loadTorrentDataTimer);
@@ -71,7 +71,7 @@ var loadTorrentData = function() {
}
// Display hash
$('torrent_hash').set('html', current_hash);
- var url = new URI('api/v2/torrents/properties?hash=' + current_hash);
+ const url = new URI('api/v2/torrents/properties?hash=' + current_hash);
new Request.JSON({
url: url,
noCache: true,
@@ -84,7 +84,7 @@ var loadTorrentData = function() {
onSuccess: function(data) {
$('error_div').set('html', '');
if (data) {
- var temp;
+ let temp;
// Update Torrent data
if (data.seeding_time > 0)
temp = "QBT_TR(%1 (%2 this session))QBT_TR[CONTEXT=PropertiesWidget]"
@@ -193,7 +193,7 @@ var loadTorrentData = function() {
}).send();
};
-var updateTorrentData = function() {
+updateTorrentData = function() {
clearTimeout(loadTorrentDataTimer);
loadTorrentData();
};
diff --git a/src/webui/www/private/scripts/prop-peers.js b/src/webui/www/private/scripts/prop-peers.js
index 99fce5c79..164077492 100644
--- a/src/webui/www/private/scripts/prop-peers.js
+++ b/src/webui/www/private/scripts/prop-peers.js
@@ -28,17 +28,17 @@
'use strict';
-var loadTorrentPeersTimer;
-var syncTorrentPeersLastResponseId = 0;
-var show_flags = true;
-var loadTorrentPeersData = function() {
+let loadTorrentPeersTimer;
+let syncTorrentPeersLastResponseId = 0;
+let show_flags = true;
+const loadTorrentPeersData = function() {
if ($('prop_peers').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
syncTorrentPeersLastResponseId = 0;
torrentPeersTable.clear();
return;
}
- var current_hash = torrentsTable.getCurrentTorrentHash();
+ const current_hash = torrentsTable.getCurrentTorrentHash();
if (current_hash === "") {
syncTorrentPeersLastResponseId = 0;
torrentPeersTable.clear();
@@ -46,7 +46,7 @@ var loadTorrentPeersData = function() {
loadTorrentPeersTimer = loadTorrentPeersData.delay(getSyncMainDataInterval());
return;
}
- var url = new URI('api/v2/sync/torrentPeers');
+ const url = new URI('api/v2/sync/torrentPeers');
url.setData('rid', syncTorrentPeersLastResponseId);
url.setData('hash', current_hash);
new Request.JSON({
@@ -60,13 +60,13 @@ var loadTorrentPeersData = function() {
onSuccess: function(response) {
$('error_div').set('html', '');
if (response) {
- var full_update = (response['full_update'] === true);
+ const full_update = (response['full_update'] === true);
if (full_update)
torrentPeersTable.clear();
if (response['rid'])
syncTorrentPeersLastResponseId = response['rid'];
if (response['peers']) {
- for (var key in response['peers']) {
+ for (const key in response['peers']) {
response['peers'][key]['rowId'] = key;
if (response['peers'][key]['client'])
diff --git a/src/webui/www/private/scripts/prop-trackers.js b/src/webui/www/private/scripts/prop-trackers.js
index 2b530bb27..2aace0505 100644
--- a/src/webui/www/private/scripts/prop-trackers.js
+++ b/src/webui/www/private/scripts/prop-trackers.js
@@ -28,16 +28,16 @@
'use strict';
-var current_hash = "";
+this.current_hash = "";
-var loadTrackersDataTimer;
-var loadTrackersData = function() {
+let loadTrackersDataTimer;
+const loadTrackersData = function() {
if ($('prop_trackers').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
// Tab changed, don't do anything
return;
}
- var new_hash = torrentsTable.getCurrentTorrentHash();
+ const new_hash = torrentsTable.getCurrentTorrentHash();
if (new_hash === "") {
torrentTrackersTable.clear();
clearTimeout(loadTrackersDataTimer);
@@ -48,7 +48,7 @@ var loadTrackersData = function() {
torrentTrackersTable.clear();
current_hash = new_hash;
}
- var url = new URI('api/v2/torrents/trackers?hash=' + current_hash);
+ const url = new URI('api/v2/torrents/trackers?hash=' + current_hash);
new Request.JSON({
url: url,
noCache: true,
@@ -58,13 +58,13 @@ var loadTrackersData = function() {
loadTrackersDataTimer = loadTrackersData.delay(10000);
},
onSuccess: function(trackers) {
- var selectedTrackers = torrentTrackersTable.selectedRowsIds();
+ const selectedTrackers = torrentTrackersTable.selectedRowsIds();
torrentTrackersTable.clear();
if (trackers) {
trackers.each(function(tracker) {
- var url = escapeHtml(tracker.url);
- var status;
+ const url = escapeHtml(tracker.url);
+ let status;
switch (tracker.status) {
case 0:
status = "QBT_TR(Disabled)QBT_TR[CONTEXT=TrackerListWidget]";
@@ -83,7 +83,7 @@ var loadTrackersData = function() {
break;
}
- var row = {
+ const row = {
rowId: url,
tier: tracker.tier,
url: url,
@@ -108,12 +108,12 @@ var loadTrackersData = function() {
}).send();
};
-var updateTrackersData = function() {
+updateTrackersData = function() {
clearTimeout(loadTrackersDataTimer);
loadTrackersData();
};
-var torrentTrackersContextMenu = new ContextMenu({
+const torrentTrackersContextMenu = new ContextMenu({
targets: '#torrentTrackersTableDiv',
menu: 'torrentTrackersMenu',
actions: {
@@ -134,8 +134,8 @@ var torrentTrackersContextMenu = new ContextMenu({
y: 2
},
onShow: function() {
- var selectedTrackers = torrentTrackersTable.selectedRowsIds();
- var containsStaticTracker = selectedTrackers.some(function(tracker) {
+ const selectedTrackers = torrentTrackersTable.selectedRowsIds();
+ const containsStaticTracker = selectedTrackers.some(function(tracker) {
return (tracker.indexOf("** [") === 0);
});
@@ -152,7 +152,7 @@ var torrentTrackersContextMenu = new ContextMenu({
}
});
-var addTrackerFN = function() {
+const addTrackerFN = function() {
if (current_hash.length === 0) return;
new MochaUI.Window({
id: 'trackersPage',
@@ -173,10 +173,10 @@ var addTrackerFN = function() {
});
};
-var editTrackerFN = function(element) {
+const editTrackerFN = function(element) {
if (current_hash.length === 0) return;
- var trackerUrl = encodeURIComponent(element.childNodes[1].innerText);
+ const trackerUrl = encodeURIComponent(element.childNodes[1].innerText);
new MochaUI.Window({
id: 'trackersPage',
title: "QBT_TR(Tracker editing)QBT_TR[CONTEXT=TrackerListWidget]",
@@ -196,10 +196,10 @@ var editTrackerFN = function(element) {
});
};
-var removeTrackerFN = function(element) {
+const removeTrackerFN = function(element) {
if (current_hash.length === 0) return;
- var selectedTrackers = torrentTrackersTable.selectedRowsIds();
+ const selectedTrackers = torrentTrackersTable.selectedRowsIds();
new Request({
url: 'api/v2/torrents/removeTrackers',
method: 'post',
diff --git a/src/webui/www/private/scripts/prop-webseeds.js b/src/webui/www/private/scripts/prop-webseeds.js
index 4a6507a3d..bf270bfa0 100644
--- a/src/webui/www/private/scripts/prop-webseeds.js
+++ b/src/webui/www/private/scripts/prop-webseeds.js
@@ -28,7 +28,7 @@
'use strict';
-var webseedsDynTable = new Class({
+const webseedsDynTable = new Class({
initialize: function() {},
@@ -39,7 +39,7 @@ var webseedsDynTable = new Class({
removeRow: function(url) {
if (this.rows.has(url)) {
- var tr = this.rows.get(url);
+ const tr = this.rows.get(url);
tr.dispose();
this.rows.erase(url);
return true;
@@ -54,25 +54,25 @@ var webseedsDynTable = new Class({
},
updateRow: function(tr, row) {
- var tds = tr.getElements('td');
- for (var i = 0; i < row.length; ++i) {
+ const tds = tr.getElements('td');
+ for (let i = 0; i < row.length; ++i) {
tds[i].set('html', row[i]);
}
return true;
},
insertRow: function(row) {
- var url = row[0];
+ const url = row[0];
if (this.rows.has(url)) {
- var tableRow = this.rows.get(url);
+ const tableRow = this.rows.get(url);
this.updateRow(tableRow, row);
return;
}
//this.removeRow(id);
- var tr = new Element('tr');
+ const tr = new Element('tr');
this.rows.set(url, tr);
- for (var i = 0; i < row.length; ++i) {
- var td = new Element('td');
+ for (let i = 0; i < row.length; ++i) {
+ const td = new Element('td');
td.set('html', row[i]);
td.injectInside(tr);
}
@@ -80,16 +80,16 @@ var webseedsDynTable = new Class({
},
});
-var current_hash = "";
+this.current_hash = "";
-var loadWebSeedsDataTimer;
-var loadWebSeedsData = function() {
+let loadWebSeedsDataTimer;
+const loadWebSeedsData = function() {
if ($('prop_webseeds').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
// Tab changed, don't do anything
return;
}
- var new_hash = torrentsTable.getCurrentTorrentHash();
+ const new_hash = torrentsTable.getCurrentTorrentHash();
if (new_hash === "") {
wsTable.removeAllRows();
clearTimeout(loadWebSeedsDataTimer);
@@ -100,7 +100,7 @@ var loadWebSeedsData = function() {
wsTable.removeAllRows();
current_hash = new_hash;
}
- var url = new URI('api/v2/torrents/webseeds?hash=' + current_hash);
+ const url = new URI('api/v2/torrents/webseeds?hash=' + current_hash);
new Request.JSON({
url: url,
noCache: true,
@@ -115,7 +115,7 @@ var loadWebSeedsData = function() {
if (webseeds) {
// Update WebSeeds data
webseeds.each(function(webseed) {
- var row = [];
+ const row = [];
row.length = 1;
row[0] = webseed.url;
wsTable.insertRow(row);
@@ -130,10 +130,10 @@ var loadWebSeedsData = function() {
}).send();
};
-var updateWebSeedsData = function() {
+updateWebSeedsData = function() {
clearTimeout(loadWebSeedsDataTimer);
loadWebSeedsData();
};
-var wsTable = new webseedsDynTable();
+const wsTable = new webseedsDynTable();
wsTable.setup($('webseedsTable'));
diff --git a/src/webui/www/private/scripts/speedslider.js b/src/webui/www/private/scripts/speedslider.js
index 634dcc370..4dec6b75b 100644
--- a/src/webui/www/private/scripts/speedslider.js
+++ b/src/webui/www/private/scripts/speedslider.js
@@ -31,17 +31,17 @@
MochaUI.extend({
addUpLimitSlider: function(hashes) {
if ($('uplimitSliderarea')) {
- var windowOptions = MochaUI.Windows.windowOptions;
- var sliderFirst = true;
+ const windowOptions = MochaUI.Windows.windowOptions;
+ const sliderFirst = true;
// Get global upload limit
- var maximum = 500;
- var req = new Request({
+ let maximum = 500;
+ const req = new Request({
url: 'api/v2/transfer/uploadLimit',
method: 'post',
data: {},
onSuccess: function(data) {
if (data) {
- var tmp = data.toInt();
+ const tmp = data.toInt();
if (tmp > 0) {
maximum = tmp / 1024.0;
}
@@ -55,10 +55,10 @@ MochaUI.extend({
// Get torrents upload limit
// And create slider
if (hashes[0] == 'global') {
- var up_limit = maximum;
+ let up_limit = maximum;
if (up_limit < 0) up_limit = 0;
maximum = 10000;
- var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
+ const mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: up_limit.round(),
@@ -84,7 +84,7 @@ MochaUI.extend({
}
}
else {
- var req = new Request.JSON({
+ const req = new Request.JSON({
url: 'api/v2/torrents/uploadLimit',
noCache : true,
method: 'post',
@@ -93,14 +93,14 @@ MochaUI.extend({
},
onSuccess: function(data) {
if (data) {
- var up_limit = data[hashes[0]];
- for(var key in data)
+ let up_limit = data[hashes[0]];
+ for(const key in data)
if (up_limit != data[key]) {
up_limit = 0;
break;
}
if (up_limit < 0) up_limit = 0;
- var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
+ const mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: (up_limit / 1024.0).round(),
@@ -135,17 +135,17 @@ MochaUI.extend({
addDlLimitSlider: function(hashes) {
if ($('dllimitSliderarea')) {
- var windowOptions = MochaUI.Windows.windowOptions;
- var sliderFirst = true;
+ const windowOptions = MochaUI.Windows.windowOptions;
+ const sliderFirst = true;
// Get global upload limit
- var maximum = 500;
- var req = new Request({
+ let maximum = 500;
+ const req = new Request({
url: 'api/v2/transfer/downloadLimit',
method: 'post',
data: {},
onSuccess: function(data) {
if (data) {
- var tmp = data.toInt();
+ const tmp = data.toInt();
if (tmp > 0) {
maximum = tmp / 1024.0;
}
@@ -159,10 +159,10 @@ MochaUI.extend({
// Get torrents download limit
// And create slider
if (hashes[0] == 'global') {
- var dl_limit = maximum;
+ let dl_limit = maximum;
if (dl_limit < 0) dl_limit = 0;
maximum = 10000;
- var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
+ const mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: dl_limit.round(),
@@ -188,7 +188,7 @@ MochaUI.extend({
}
}
else {
- var req = new Request.JSON({
+ const req = new Request.JSON({
url: 'api/v2/torrents/downloadLimit',
noCache : true,
method: 'post',
@@ -197,14 +197,14 @@ MochaUI.extend({
},
onSuccess: function(data) {
if (data) {
- var dl_limit = data[hashes[0]];
- for(var key in data)
+ let dl_limit = data[hashes[0]];
+ for(const key in data)
if (dl_limit != data[key]) {
dl_limit = 0;
break;
}
if (dl_limit < 0) dl_limit = 0;
- var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
+ const mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: (dl_limit / 1024.0).round(),
diff --git a/src/webui/www/private/search.html b/src/webui/www/private/search.html
index e158d9962..2ff92d075 100644
--- a/src/webui/www/private/search.html
+++ b/src/webui/www/private/search.html
@@ -153,42 +153,42 @@