mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-05 15:12:32 -06:00
Refactor var to let/const or this
This commit is contained in:
@@ -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 = '<a href="#" onclick="setCategoryFilter(' + hash + ');return false;">'
|
||||
const create_link = function(hash, text, count) {
|
||||
const html = '<a href="#" onclick="setCategoryFilter(' + hash + ');return false;">'
|
||||
+ '<img src="images/qbt-theme/inode-directory.svg"/>'
|
||||
+ escapeHtml(text) + ' (' + count + ')' + '</a>';
|
||||
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);
|
||||
|
||||
@@ -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: '<a href="javascript:torrentNewCategoryFN();"><img src="images/qbt-theme/list-add.svg" alt="QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget]"/> QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget]</a>'
|
||||
@@ -421,16 +421,16 @@ var TorrentsTableContextMenu = new Class({
|
||||
html: '<a href="javascript:torrentSetCategoryFN(0);"><img src="images/qbt-theme/edit-clear.svg" alt="QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget]"/> QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget]</a>'
|
||||
}));
|
||||
|
||||
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: '<a href="javascript:torrentSetCategoryFN(\'' + categoryHash + '\');"><img src="images/qbt-theme/inode-directory.svg"/> ' + escapeHtml(categoryName) + '</a>'
|
||||
});
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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, "<a target='_blank' href='$1'>$1</a>");
|
||||
}
|
||||
|
||||
function escapeHtml(str) {
|
||||
var div = document.createElement('div');
|
||||
const div = document.createElement('div');
|
||||
div.appendChild(document.createTextNode(str));
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
@@ -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]',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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'])
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user