WebUI: enforce string quotes coding style

This commit is contained in:
Chocobo1
2024-05-27 22:50:17 +08:00
parent 6d073771ca
commit cb90b6769c
58 changed files with 3522 additions and 3514 deletions

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
@@ -46,7 +46,7 @@ window.qBittorrent.Cache = (() => {
const keys = Reflect.ownKeys(obj);
for (const key of keys) {
const value = obj[key];
if ((value && (typeof value === 'object')) || (typeof value === 'function'))
if ((value && (typeof value === "object")) || (typeof value === "function"))
deepFreeze(value);
}
Object.freeze(obj);
@@ -57,8 +57,8 @@ window.qBittorrent.Cache = (() => {
init() {
new Request.JSON({
url: 'api/v2/app/buildInfo',
method: 'get',
url: "api/v2/app/buildInfo",
method: "get",
noCache: true,
onSuccess: (responseJSON) => {
if (!responseJSON)
@@ -84,11 +84,11 @@ window.qBittorrent.Cache = (() => {
// }
init(obj = {}) {
new Request.JSON({
url: 'api/v2/app/preferences',
method: 'get',
url: "api/v2/app/preferences",
method: "get",
noCache: true,
onFailure: (xhr) => {
if (typeof obj.onFailure === 'function')
if (typeof obj.onFailure === "function")
obj.onFailure(xhr);
},
onSuccess: (responseJSON, responseText) => {
@@ -98,7 +98,7 @@ window.qBittorrent.Cache = (() => {
deepFreeze(responseJSON);
this.#m_store = responseJSON;
if (typeof obj.onSuccess === 'function')
if (typeof obj.onSuccess === "function")
obj.onSuccess(responseJSON, responseText);
}
}).send();
@@ -114,19 +114,19 @@ window.qBittorrent.Cache = (() => {
// onSuccess: () => {}
// }
set(obj) {
if (typeof obj !== 'object')
throw new Error('`obj` is not an object.');
if (typeof obj.data !== 'object')
throw new Error('`data` is not an object.');
if (typeof obj !== "object")
throw new Error("`obj` is not an object.");
if (typeof obj.data !== "object")
throw new Error("`data` is not an object.");
new Request({
url: 'api/v2/app/setPreferences',
method: 'post',
url: "api/v2/app/setPreferences",
method: "post",
data: {
'json': JSON.stringify(obj.data)
"json": JSON.stringify(obj.data)
},
onFailure: (xhr) => {
if (typeof obj.onFailure === 'function')
if (typeof obj.onFailure === "function")
obj.onFailure(xhr);
},
onSuccess: (responseText, responseXML) => {
@@ -140,7 +140,7 @@ window.qBittorrent.Cache = (() => {
}
deepFreeze(this.#m_store);
if (typeof obj.onSuccess === 'function')
if (typeof obj.onSuccess === "function")
obj.onSuccess(responseText, responseXML);
}
}).send();
@@ -148,12 +148,12 @@ window.qBittorrent.Cache = (() => {
}
class QbtVersionCache {
#m_store = '';
#m_store = "";
init() {
new Request({
url: 'api/v2/app/version',
method: 'get',
url: "api/v2/app/version",
method: "get",
noCache: true,
onSuccess: (responseText) => {
if (!responseText)

File diff suppressed because it is too large Load Diff

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -54,9 +54,9 @@ window.qBittorrent.ContextMenu = (function() {
//options
options: {
actions: {},
menu: 'menu_id',
menu: "menu_id",
stopEvent: true,
targets: 'body',
targets: "body",
offsets: {
x: 0,
y: 0
@@ -79,14 +79,14 @@ window.qBittorrent.ContextMenu = (function() {
//fx
this.fx = new Fx.Tween(this.menu, {
property: 'opacity',
property: "opacity",
duration: this.options.fadeSpeed,
onComplete: function() {
if (this.getStyle('opacity')) {
this.setStyle('visibility', 'visible');
if (this.getStyle("opacity")) {
this.setStyle("visibility", "visible");
}
else {
this.setStyle('visibility', 'hidden');
this.setStyle("visibility", "hidden");
}
}.bind(this.menu)
});
@@ -96,9 +96,9 @@ window.qBittorrent.ContextMenu = (function() {
//hide the menu
this.menu.setStyles({
'position': 'absolute',
'top': '-900000px',
'display': 'block'
"position": "absolute",
"top": "-900000px",
"display": "block"
});
},
@@ -107,13 +107,13 @@ window.qBittorrent.ContextMenu = (function() {
const scrollableMenuMaxHeight = document.documentElement.clientHeight * 0.75;
if (this.menu.hasClass('scrollableMenu'))
this.menu.setStyle('max-height', scrollableMenuMaxHeight);
if (this.menu.hasClass("scrollableMenu"))
this.menu.setStyle("max-height", scrollableMenuMaxHeight);
// draw the menu off-screen to know the menu dimensions
this.menu.setStyles({
left: '-999em',
top: '-999em'
left: "-999em",
top: "-999em"
});
// position the menu
@@ -130,16 +130,16 @@ window.qBittorrent.ContextMenu = (function() {
this.menu.setStyles({
left: xPosMenu,
top: yPosMenu,
position: 'absolute',
'z-index': '2000'
position: "absolute",
"z-index": "2000"
});
// position the sub-menu
const uls = this.menu.getElementsByTagName('ul');
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);
if (ul.hasClass("scrollableMenu"))
ul.setStyle("max-height", scrollableMenuMaxHeight);
const rectParent = ul.parentNode.getBoundingClientRect();
const xPosOrigin = rectParent.left;
const yPosOrigin = rectParent.bottom;
@@ -154,26 +154,26 @@ window.qBittorrent.ContextMenu = (function() {
if (yPos < 0)
yPos = 0;
ul.setStyles({
'margin-left': xPos - xPosOrigin,
'margin-top': yPos - yPosOrigin
"margin-left": xPos - xPosOrigin,
"margin-top": yPos - yPosOrigin
});
}
},
setupEventListeners: function(elem) {
elem.addEvent('contextmenu', function(e) {
elem.addEvent("contextmenu", function(e) {
this.triggerMenu(e, elem);
}.bind(this));
elem.addEvent('click', function(e) {
elem.addEvent("click", function(e) {
this.hide();
}.bind(this));
elem.addEvent('touchstart', function(e) {
elem.addEvent("touchstart", function(e) {
this.hide();
this.touchStartAt = performance.now();
this.touchStartEvent = e;
}.bind(this));
elem.addEvent('touchend', function(e) {
elem.addEvent("touchend", function(e) {
const now = performance.now();
const touchStartAt = this.touchStartAt;
const touchStartEvent = this.touchStartEvent;
@@ -190,8 +190,8 @@ window.qBittorrent.ContextMenu = (function() {
addTarget: function(t) {
// prevent long press from selecting this text
t.style.setProperty('user-select', 'none');
t.style.setProperty('-webkit-user-select', 'none');
t.style.setProperty("user-select", "none");
t.style.setProperty("-webkit-user-select", "none");
this.targets[this.targets.length] = t;
this.setupEventListeners(t);
@@ -220,18 +220,18 @@ window.qBittorrent.ContextMenu = (function() {
}.bind(this), this);
/* menu items */
this.menu.getElements('a').each(function(item) {
item.addEvent('click', function(e) {
this.menu.getElements("a").each(function(item) {
item.addEvent("click", function(e) {
e.preventDefault();
if (!item.hasClass('disabled')) {
this.execute(item.get('href').split('#')[1], $(this.options.element));
this.fireEvent('click', [item, e]);
if (!item.hasClass("disabled")) {
this.execute(item.get("href").split("#")[1], $(this.options.element));
this.fireEvent("click", [item, e]);
}
}.bind(this));
}, this);
//hide on body click
$(document.body).addEvent('click', function() {
$(document.body).addEvent("click", function() {
this.hide();
}.bind(this));
},
@@ -243,40 +243,40 @@ window.qBittorrent.ContextMenu = (function() {
if (lastShownContextMenu && (lastShownContextMenu !== this))
lastShownContextMenu.hide();
this.fx.start(1);
this.fireEvent('show');
this.fireEvent("show");
lastShownContextMenu = this;
return this;
},
//hide the menu
hide: function(trigger) {
if (lastShownContextMenu && (lastShownContextMenu.menu.style.visibility !== 'hidden')) {
if (lastShownContextMenu && (lastShownContextMenu.menu.style.visibility !== "hidden")) {
this.fx.start(0);
//this.menu.fade('out');
this.fireEvent('hide');
this.fireEvent("hide");
}
return this;
},
setItemChecked: function(item, checked) {
this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity =
checked ? '1' : '0';
this.menu.getElement("a[href$=" + item + "]").firstChild.style.opacity =
checked ? "1" : "0";
return this;
},
getItemChecked: function(item) {
return this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity !== '0';
return this.menu.getElement("a[href$=" + item + "]").firstChild.style.opacity !== "0";
},
//hide an item
hideItem: function(item) {
this.menu.getElement('a[href$=' + item + ']').parentNode.addClass('invisible');
this.menu.getElement("a[href$=" + item + "]").parentNode.addClass("invisible");
return this;
},
//show an item
showItem: function(item) {
this.menu.getElement('a[href$=' + item + ']').parentNode.removeClass('invisible');
this.menu.getElement("a[href$=" + item + "]").parentNode.removeClass("invisible");
return this;
},
@@ -323,37 +323,37 @@ window.qBittorrent.ContextMenu = (function() {
selectedRows.forEach((item, index) => {
const data = torrentsTable.rows.get(item).full_data;
if (data['seq_dl'] !== true)
if (data["seq_dl"] !== true)
all_are_seq_dl = false;
else
there_are_seq_dl = true;
if (data['f_l_piece_prio'] !== true)
if (data["f_l_piece_prio"] !== true)
all_are_f_l_piece_prio = false;
else
there_are_f_l_piece_prio = true;
if (data['progress'] !== 1.0) // not downloaded
if (data["progress"] !== 1.0) // not downloaded
all_are_downloaded = false;
else if (data['super_seeding'] !== true)
else if (data["super_seeding"] !== true)
all_are_super_seeding = false;
if ((data['state'] !== 'stoppedUP') && (data['state'] !== 'stoppedDL'))
if ((data["state"] !== "stoppedUP") && (data["state"] !== "stoppedDL"))
all_are_stopped = false;
else
there_are_stopped = true;
if (data['force_start'] !== true)
if (data["force_start"] !== true)
all_are_force_start = false;
else
there_are_force_start = true;
if (data['auto_tmm'] === true)
if (data["auto_tmm"] === true)
there_are_auto_tmm = true;
else
all_are_auto_tmm = false;
const torrentTags = data['tags'].split(', ');
const torrentTags = data["tags"].split(", ");
for (const tag of torrentTags) {
const count = tagCount.get(tag);
tagCount.set(tag, ((count !== undefined) ? (count + 1) : 1));
@@ -363,71 +363,71 @@ window.qBittorrent.ContextMenu = (function() {
// hide renameFiles when more than 1 torrent is selected
if (selectedRows.length === 1) {
const data = torrentsTable.rows.get(selectedRows[0]).full_data;
let metadata_downloaded = !((data['state'] === 'metaDL') || (data['state'] === 'forcedMetaDL') || (data['total_size'] === -1));
let metadata_downloaded = !((data["state"] === "metaDL") || (data["state"] === "forcedMetaDL") || (data["total_size"] === -1));
// hide renameFiles when metadata hasn't been downloaded yet
metadata_downloaded
? this.showItem('renameFiles')
: this.hideItem('renameFiles');
? this.showItem("renameFiles")
: this.hideItem("renameFiles");
}
else {
this.hideItem('renameFiles');
this.hideItem("renameFiles");
}
if (all_are_downloaded) {
this.hideItem('downloadLimit');
this.menu.getElement('a[href$=uploadLimit]').parentNode.addClass('separator');
this.hideItem('sequentialDownload');
this.hideItem('firstLastPiecePrio');
this.showItem('superSeeding');
this.setItemChecked('superSeeding', all_are_super_seeding);
this.hideItem("downloadLimit");
this.menu.getElement("a[href$=uploadLimit]").parentNode.addClass("separator");
this.hideItem("sequentialDownload");
this.hideItem("firstLastPiecePrio");
this.showItem("superSeeding");
this.setItemChecked("superSeeding", all_are_super_seeding);
}
else {
const show_seq_dl = (all_are_seq_dl || !there_are_seq_dl);
const show_f_l_piece_prio = (all_are_f_l_piece_prio || !there_are_f_l_piece_prio);
if (!show_seq_dl && show_f_l_piece_prio)
this.menu.getElement('a[href$=firstLastPiecePrio]').parentNode.addClass('separator');
this.menu.getElement("a[href$=firstLastPiecePrio]").parentNode.addClass("separator");
else
this.menu.getElement('a[href$=firstLastPiecePrio]').parentNode.removeClass('separator');
this.menu.getElement("a[href$=firstLastPiecePrio]").parentNode.removeClass("separator");
if (show_seq_dl)
this.showItem('sequentialDownload');
this.showItem("sequentialDownload");
else
this.hideItem('sequentialDownload');
this.hideItem("sequentialDownload");
if (show_f_l_piece_prio)
this.showItem('firstLastPiecePrio');
this.showItem("firstLastPiecePrio");
else
this.hideItem('firstLastPiecePrio');
this.hideItem("firstLastPiecePrio");
this.setItemChecked('sequentialDownload', all_are_seq_dl);
this.setItemChecked('firstLastPiecePrio', all_are_f_l_piece_prio);
this.setItemChecked("sequentialDownload", all_are_seq_dl);
this.setItemChecked("firstLastPiecePrio", all_are_f_l_piece_prio);
this.showItem('downloadLimit');
this.menu.getElement('a[href$=uploadLimit]').parentNode.removeClass('separator');
this.hideItem('superSeeding');
this.showItem("downloadLimit");
this.menu.getElement("a[href$=uploadLimit]").parentNode.removeClass("separator");
this.hideItem("superSeeding");
}
this.showItem('start');
this.showItem('stop');
this.showItem('forceStart');
this.showItem("start");
this.showItem("stop");
this.showItem("forceStart");
if (all_are_stopped)
this.hideItem('stop');
this.hideItem("stop");
else if (all_are_force_start)
this.hideItem('forceStart');
this.hideItem("forceStart");
else if (!there_are_stopped && !there_are_force_start)
this.hideItem('start');
this.hideItem("start");
if (!all_are_auto_tmm && there_are_auto_tmm) {
this.hideItem('autoTorrentManagement');
this.hideItem("autoTorrentManagement");
}
else {
this.showItem('autoTorrentManagement');
this.setItemChecked('autoTorrentManagement', all_are_auto_tmm);
this.showItem("autoTorrentManagement");
this.setItemChecked("autoTorrentManagement", all_are_auto_tmm);
}
const contextTagList = $('contextTagList');
const contextTagList = $("contextTagList");
tagList.forEach((tag, tagHash) => {
const checkbox = contextTagList.getElement(`a[href="#Tag/${tagHash}"] input[type="checkbox"]`);
const count = tagCount.get(tag.name);
@@ -439,12 +439,12 @@ window.qBittorrent.ContextMenu = (function() {
},
updateCategoriesSubMenu: function(categoryList) {
const contextCategoryList = $('contextCategoryList');
const contextCategoryList = $("contextCategoryList");
contextCategoryList.getChildren().each(c => c.destroy());
contextCategoryList.appendChild(new Element('li', {
contextCategoryList.appendChild(new Element("li", {
html: '<a href="javascript:torrentNewCategoryFN();"><img src="images/list-add.svg" alt="QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget]"/> QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget]</a>'
}));
contextCategoryList.appendChild(new Element('li', {
contextCategoryList.appendChild(new Element("li", {
html: '<a href="javascript:torrentSetCategoryFN(0);"><img src="images/edit-clear.svg" alt="QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget]"/> QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget]</a>'
}));
@@ -458,11 +458,11 @@ window.qBittorrent.ContextMenu = (function() {
let first = true;
for (const { categoryName, categoryHash } of sortedCategories) {
const el = new Element('li', {
const el = new Element("li", {
html: `<a href="javascript:torrentSetCategoryFN(${categoryHash});"><img src="images/view-categories.svg"/>${window.qBittorrent.Misc.escapeHtml(categoryName)}</a>`
});
if (first) {
el.addClass('separator');
el.addClass("separator");
first = false;
}
contextCategoryList.appendChild(el);
@@ -470,21 +470,21 @@ window.qBittorrent.ContextMenu = (function() {
},
updateTagsSubMenu: function(tagList) {
const contextTagList = $('contextTagList');
const contextTagList = $("contextTagList");
while (contextTagList.firstChild !== null)
contextTagList.removeChild(contextTagList.firstChild);
contextTagList.appendChild(new Element('li', {
contextTagList.appendChild(new Element("li", {
html: '<a href="javascript:torrentAddTagsFN();">'
+ '<img src="images/list-add.svg" alt="QBT_TR(Add...)QBT_TR[CONTEXT=TransferListWidget]"/>'
+ ' QBT_TR(Add...)QBT_TR[CONTEXT=TransferListWidget]'
+ '</a>'
+ " QBT_TR(Add...)QBT_TR[CONTEXT=TransferListWidget]"
+ "</a>"
}));
contextTagList.appendChild(new Element('li', {
contextTagList.appendChild(new Element("li", {
html: '<a href="javascript:torrentRemoveAllTagsFN();">'
+ '<img src="images/edit-clear.svg" alt="QBT_TR(Remove All)QBT_TR[CONTEXT=TransferListWidget]"/>'
+ ' QBT_TR(Remove All)QBT_TR[CONTEXT=TransferListWidget]'
+ '</a>'
+ " QBT_TR(Remove All)QBT_TR[CONTEXT=TransferListWidget]"
+ "</a>"
}));
const sortedTags = [];
@@ -496,13 +496,13 @@ window.qBittorrent.ContextMenu = (function() {
for (let i = 0; i < sortedTags.length; ++i) {
const { tagName, tagHash } = sortedTags[i];
const el = new Element('li', {
const el = new Element("li", {
html: `<a href="#Tag/${tagHash}" onclick="event.preventDefault(); torrentSetTagsFN(${tagHash}, !event.currentTarget.getElement('input[type=checkbox]').checked);">`
+ '<input type="checkbox" onclick="this.checked = !this.checked;"> ' + window.qBittorrent.Misc.escapeHtml(tagName)
+ '</a>'
+ "</a>"
});
if (i === 0)
el.addClass('separator');
el.addClass("separator");
contextTagList.appendChild(el);
}
}
@@ -513,19 +513,19 @@ window.qBittorrent.ContextMenu = (function() {
updateMenuItems: function() {
const id = Number(this.options.element.id);
if ((id !== CATEGORIES_ALL) && (id !== CATEGORIES_UNCATEGORIZED)) {
this.showItem('editCategory');
this.showItem('deleteCategory');
this.showItem("editCategory");
this.showItem("deleteCategory");
if (useSubcategories) {
this.showItem('createSubcategory');
this.showItem("createSubcategory");
}
else {
this.hideItem('createSubcategory');
this.hideItem("createSubcategory");
}
}
else {
this.hideItem('editCategory');
this.hideItem('deleteCategory');
this.hideItem('createSubcategory');
this.hideItem("editCategory");
this.hideItem("deleteCategory");
this.hideItem("createSubcategory");
}
}
});
@@ -535,9 +535,9 @@ window.qBittorrent.ContextMenu = (function() {
updateMenuItems: function() {
const id = Number(this.options.element.id);
if ((id !== TAGS_ALL) && (id !== TAGS_UNTAGGED))
this.showItem('deleteTag');
this.showItem("deleteTag");
else
this.hideItem('deleteTag');
this.hideItem("deleteTag");
}
});
@@ -552,10 +552,10 @@ window.qBittorrent.ContextMenu = (function() {
return i;
};
this.showItem('Enabled');
this.setItemChecked('Enabled', this.options.element.getChildren("td")[enabledColumnIndex()].get("html") === "Yes");
this.showItem("Enabled");
this.setItemChecked("Enabled", this.options.element.getChildren("td")[enabledColumnIndex()].get("html") === "Yes");
this.showItem('Uninstall');
this.showItem("Uninstall");
}
});
@@ -563,66 +563,66 @@ window.qBittorrent.ContextMenu = (function() {
Extends: ContextMenu,
updateMenuItems: function() {
let selectedRows = window.qBittorrent.Rss.rssFeedTable.selectedRowsIds();
this.menu.getElement('a[href$=newSubscription]').parentNode.addClass('separator');
this.menu.getElement("a[href$=newSubscription]").parentNode.addClass("separator");
switch (selectedRows.length) {
case 0:
// remove separator on top of newSubscription entry to avoid double line
this.menu.getElement('a[href$=newSubscription]').parentNode.removeClass('separator');
this.menu.getElement("a[href$=newSubscription]").parentNode.removeClass("separator");
// menu when nothing selected
this.hideItem('update');
this.hideItem('markRead');
this.hideItem('rename');
this.hideItem('delete');
this.showItem('newSubscription');
this.showItem('newFolder');
this.showItem('updateAll');
this.hideItem('copyFeedURL');
this.hideItem("update");
this.hideItem("markRead");
this.hideItem("rename");
this.hideItem("delete");
this.showItem("newSubscription");
this.showItem("newFolder");
this.showItem("updateAll");
this.hideItem("copyFeedURL");
break;
case 1:
if (selectedRows[0] === 0) {
// menu when "unread" feed selected
this.showItem('update');
this.showItem('markRead');
this.hideItem('rename');
this.hideItem('delete');
this.showItem('newSubscription');
this.hideItem('newFolder');
this.hideItem('updateAll');
this.hideItem('copyFeedURL');
this.showItem("update");
this.showItem("markRead");
this.hideItem("rename");
this.hideItem("delete");
this.showItem("newSubscription");
this.hideItem("newFolder");
this.hideItem("updateAll");
this.hideItem("copyFeedURL");
}
else if (window.qBittorrent.Rss.rssFeedTable.rows[selectedRows[0]].full_data.dataUid === '') {
else if (window.qBittorrent.Rss.rssFeedTable.rows[selectedRows[0]].full_data.dataUid === "") {
// menu when single folder selected
this.showItem('update');
this.showItem('markRead');
this.showItem('rename');
this.showItem('delete');
this.showItem('newSubscription');
this.showItem('newFolder');
this.hideItem('updateAll');
this.hideItem('copyFeedURL');
this.showItem("update");
this.showItem("markRead");
this.showItem("rename");
this.showItem("delete");
this.showItem("newSubscription");
this.showItem("newFolder");
this.hideItem("updateAll");
this.hideItem("copyFeedURL");
}
else {
// menu when single feed selected
this.showItem('update');
this.showItem('markRead');
this.showItem('rename');
this.showItem('delete');
this.showItem('newSubscription');
this.hideItem('newFolder');
this.hideItem('updateAll');
this.showItem('copyFeedURL');
this.showItem("update");
this.showItem("markRead");
this.showItem("rename");
this.showItem("delete");
this.showItem("newSubscription");
this.hideItem("newFolder");
this.hideItem("updateAll");
this.showItem("copyFeedURL");
}
break;
default:
// menu when multiple items selected
this.showItem('update');
this.showItem('markRead');
this.hideItem('rename');
this.showItem('delete');
this.hideItem('newSubscription');
this.hideItem('newFolder');
this.hideItem('updateAll');
this.showItem('copyFeedURL');
this.showItem("update");
this.showItem("markRead");
this.hideItem("rename");
this.showItem("delete");
this.hideItem("newSubscription");
this.hideItem("newFolder");
this.hideItem("updateAll");
this.showItem("copyFeedURL");
break;
}
}
@@ -639,12 +639,12 @@ window.qBittorrent.ContextMenu = (function() {
// draw the menu off-screen to know the menu dimensions
this.menu.setStyles({
left: '-999em',
top: '-999em'
left: "-999em",
top: "-999em"
});
// position the menu
let xPosMenu = e.page.x + this.options.offsets.x - $('rssdownloaderpage').offsetLeft;
let yPosMenu = e.page.y + this.options.offsets.y - $('rssdownloaderpage').offsetTop;
let xPosMenu = e.page.x + this.options.offsets.x - $("rssdownloaderpage").offsetLeft;
let yPosMenu = e.page.y + this.options.offsets.y - $("rssdownloaderpage").offsetTop;
if ((xPosMenu + this.menu.offsetWidth) > document.documentElement.clientWidth)
xPosMenu -= this.menu.offsetWidth;
if ((yPosMenu + this.menu.offsetHeight) > document.documentElement.clientHeight)
@@ -655,31 +655,31 @@ window.qBittorrent.ContextMenu = (function() {
this.menu.setStyles({
left: xPosMenu,
top: yPosMenu,
position: 'absolute',
'z-index': '2000'
position: "absolute",
"z-index": "2000"
});
},
updateMenuItems: function() {
let selectedRows = window.qBittorrent.RssDownloader.rssDownloaderRulesTable.selectedRowsIds();
this.showItem('addRule');
this.showItem("addRule");
switch (selectedRows.length) {
case 0:
// menu when nothing selected
this.hideItem('deleteRule');
this.hideItem('renameRule');
this.hideItem('clearDownloadedEpisodes');
this.hideItem("deleteRule");
this.hideItem("renameRule");
this.hideItem("clearDownloadedEpisodes");
break;
case 1:
// menu when single item selected
this.showItem('deleteRule');
this.showItem('renameRule');
this.showItem('clearDownloadedEpisodes');
this.showItem("deleteRule");
this.showItem("renameRule");
this.showItem("clearDownloadedEpisodes");
break;
default:
// menu when multiple items selected
this.showItem('deleteRule');
this.hideItem('renameRule');
this.showItem('clearDownloadedEpisodes');
this.showItem("deleteRule");
this.hideItem("renameRule");
this.showItem("clearDownloadedEpisodes");
break;
}
}

View File

@@ -21,7 +21,7 @@
* THE SOFTWARE.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -40,8 +40,8 @@ window.qBittorrent.Download = (function() {
const getCategories = function() {
new Request.JSON({
url: 'api/v2/torrents/categories',
method: 'get',
url: "api/v2/torrents/categories",
method: "get",
noCache: true,
onSuccess: function(data) {
if (data) {
@@ -49,9 +49,9 @@ window.qBittorrent.Download = (function() {
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);
option.set("value", category.name);
option.set("html", category.name);
$("categorySelect").appendChild(option);
}
}
}
@@ -62,36 +62,36 @@ window.qBittorrent.Download = (function() {
const pref = window.parent.qBittorrent.Cache.preferences.get();
defaultSavePath = pref.save_path;
$('savepath').setProperty('value', defaultSavePath);
$('startTorrent').checked = !pref.add_stopped_enabled;
$('addToTopOfQueue').checked = pref.add_to_top_of_queue;
$("savepath").setProperty("value", defaultSavePath);
$("startTorrent").checked = !pref.add_stopped_enabled;
$("addToTopOfQueue").checked = pref.add_to_top_of_queue;
if (pref.auto_tmm_enabled === 1) {
$('autoTMM').selectedIndex = 1;
$('savepath').disabled = true;
$("autoTMM").selectedIndex = 1;
$("savepath").disabled = true;
}
else {
$('autoTMM').selectedIndex = 0;
$("autoTMM").selectedIndex = 0;
}
if (pref.torrent_stop_condition === "MetadataReceived") {
$('stopCondition').selectedIndex = 1;
$("stopCondition").selectedIndex = 1;
}
else if (pref.torrent_stop_condition === "FilesChecked") {
$('stopCondition').selectedIndex = 2;
$("stopCondition").selectedIndex = 2;
}
else {
$('stopCondition').selectedIndex = 0;
$("stopCondition").selectedIndex = 0;
}
if (pref.torrent_content_layout === "Subfolder") {
$('contentLayout').selectedIndex = 1;
$("contentLayout").selectedIndex = 1;
}
else if (pref.torrent_content_layout === "NoSubfolder") {
$('contentLayout').selectedIndex = 2;
$("contentLayout").selectedIndex = 2;
}
else {
$('contentLayout').selectedIndex = 0;
$("contentLayout").selectedIndex = 0;
}
};
@@ -101,37 +101,37 @@ window.qBittorrent.Download = (function() {
item.nextElementSibling.value = "";
item.nextElementSibling.select();
if ($('autoTMM').selectedIndex === 1)
$('savepath').value = defaultSavePath;
if ($("autoTMM").selectedIndex === 1)
$("savepath").value = defaultSavePath;
}
else {
item.nextElementSibling.hidden = true;
const text = item.options[item.selectedIndex].textContent;
item.nextElementSibling.value = text;
if ($('autoTMM').selectedIndex === 1) {
if ($("autoTMM").selectedIndex === 1) {
const categoryName = item.value;
const category = categories[categoryName];
let savePath = defaultSavePath;
if (category !== undefined)
savePath = (category['savePath'] !== "") ? category['savePath'] : `${defaultSavePath}/${categoryName}`;
$('savepath').value = savePath;
savePath = (category["savePath"] !== "") ? category["savePath"] : `${defaultSavePath}/${categoryName}`;
$("savepath").value = savePath;
}
}
};
const changeTMM = function(item) {
if (item.selectedIndex === 1) {
$('savepath').disabled = true;
$("savepath").disabled = true;
const categorySelect = $('categorySelect');
const categorySelect = $("categorySelect");
const categoryName = categorySelect.options[categorySelect.selectedIndex].value;
const category = categories[categoryName];
$('savepath').value = (category === undefined) ? "" : category['savePath'];
$("savepath").value = (category === undefined) ? "" : category["savePath"];
}
else {
$('savepath').disabled = false;
$('savepath').value = defaultSavePath;
$("savepath").disabled = false;
$("savepath").value = defaultSavePath;
}
};

File diff suppressed because it is too large Load Diff

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
// This file is the JavaScript implementation of base/utils/fs.cpp
@@ -44,15 +44,15 @@ window.qBittorrent.Filesystem = (function() {
};
};
const PathSeparator = '/';
const PathSeparator = "/";
/**
* Returns the file extension part of a file name.
*/
const fileExtension = function(filename) {
const pointIndex = filename.lastIndexOf('.');
const pointIndex = filename.lastIndexOf(".");
if (pointIndex === -1)
return '';
return "";
return filename.substring(pointIndex + 1);
};
@@ -66,7 +66,7 @@ window.qBittorrent.Filesystem = (function() {
const folderName = function(filepath) {
const slashIndex = filepath.lastIndexOf(PathSeparator);
if (slashIndex === -1)
return '';
return "";
return filepath.substring(0, slashIndex);
};

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -152,7 +152,7 @@ window.qBittorrent.Misc = (function() {
valid: false
};
if (typeof versionString !== 'string')
if (typeof versionString !== "string")
return failure;
const tryToNumber = (str) => {
@@ -160,7 +160,7 @@ window.qBittorrent.Misc = (function() {
return (isNaN(num) ? str : num);
};
const ver = versionString.split('.', 4).map(val => tryToNumber(val));
const ver = versionString.split(".", 4).map(val => tryToNumber(val));
return {
valid: true,
major: ver[0],
@@ -171,7 +171,7 @@ window.qBittorrent.Misc = (function() {
};
const escapeHtml = function(str) {
const div = document.createElement('div');
const div = document.createElement("div");
div.appendChild(document.createTextNode(str));
const escapedString = div.innerHTML;
div.remove();
@@ -179,7 +179,7 @@ window.qBittorrent.Misc = (function() {
};
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#parameters
const naturalSortCollator = new Intl.Collator(undefined, { numeric: true, usage: 'sort' });
const naturalSortCollator = new Intl.Collator(undefined, { numeric: true, usage: "sort" });
const safeTrim = function(value) {
try {
@@ -207,8 +207,8 @@ window.qBittorrent.Misc = (function() {
const containsAllTerms = function(text, terms) {
const textToSearch = text.toLowerCase();
return terms.every(function(term) {
const isTermRequired = (term[0] === '+');
const isTermExcluded = (term[0] === '-');
const isTermRequired = (term[0] === "+");
const isTermExcluded = (term[0] === "-");
if (isTermRequired || isTermExcluded) {
// ignore lonely +/-
if (term.length === 1)

View File

@@ -36,7 +36,7 @@
it in the onContentLoaded function of the new window.
----------------------------------------------------------------- */
'use strict';
"use strict";
const LocalPreferences = new window.qBittorrent.LocalPreferences.LocalPreferencesClass();
@@ -96,34 +96,34 @@ let exportTorrentFN = function() {};
const initializeWindows = function() {
saveWindowSize = function(windowId) {
const size = $(windowId).getSize();
LocalPreferences.set('window_' + windowId + '_width', size.x);
LocalPreferences.set('window_' + windowId + '_height', size.y);
LocalPreferences.set("window_" + windowId + "_width", size.x);
LocalPreferences.set("window_" + windowId + "_height", size.y);
};
loadWindowWidth = function(windowId, defaultValue) {
return LocalPreferences.get('window_' + windowId + '_width', defaultValue);
return LocalPreferences.get("window_" + windowId + "_width", defaultValue);
};
loadWindowHeight = function(windowId, defaultValue) {
return LocalPreferences.get('window_' + windowId + '_height', defaultValue);
return LocalPreferences.get("window_" + windowId + "_height", defaultValue);
};
function addClickEvent(el, fn) {
['Link', 'Button'].each(function(item) {
["Link", "Button"].each(function(item) {
if ($(el + item)) {
$(el + item).addEvent('click', fn);
$(el + item).addEvent("click", fn);
}
});
}
addClickEvent('download', function(e) {
addClickEvent("download", function(e) {
new Event(e).stop();
showDownloadPage();
});
showDownloadPage = function(urls) {
const id = 'downloadPage';
let contentUri = new URI('download.html');
const id = "downloadPage";
let contentUri = new URI("download.html");
if (urls && (urls.length > 0)) {
contentUri.setData("urls", urls.map(encodeURIComponent).join("|"));
@@ -132,9 +132,9 @@ const initializeWindows = function() {
new MochaUI.Window({
id: id,
title: "QBT_TR(Download from URLs)QBT_TR[CONTEXT=downloadFromURL]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: contentUri.toString(),
addClass: 'windowFrame', // fixes iframe scrolling on iOS Safari
addClass: "windowFrame", // fixes iframe scrolling on iOS Safari
scrollbars: true,
maximizable: false,
closable: true,
@@ -149,19 +149,19 @@ const initializeWindows = function() {
updateMainData();
};
addClickEvent('preferences', function(e) {
addClickEvent("preferences", function(e) {
new Event(e).stop();
const id = 'preferencesPage';
const id = "preferencesPage";
new MochaUI.Window({
id: id,
title: "QBT_TR(Options)QBT_TR[CONTEXT=OptionsDialog]",
loadMethod: 'xhr',
loadMethod: "xhr",
toolbar: true,
contentURL: new URI("views/preferences.html").toString(),
require: {
css: ['css/Tabs.css']
css: ["css/Tabs.css"]
},
toolbarURL: 'views/preferencesToolbar.html',
toolbarURL: "views/preferencesToolbar.html",
maximizable: false,
closable: true,
paddingVertical: 0,
@@ -174,15 +174,15 @@ const initializeWindows = function() {
});
});
addClickEvent('upload', function(e) {
addClickEvent("upload", function(e) {
new Event(e).stop();
const id = 'uploadPage';
const id = "uploadPage";
new MochaUI.Window({
id: id,
title: "QBT_TR(Upload local torrent)QBT_TR[CONTEXT=HttpServer]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("upload.html").toString(),
addClass: 'windowFrame', // fixes iframe scrolling on iOS Safari
addClass: "windowFrame", // fixes iframe scrolling on iOS Safari
scrollbars: true,
maximizable: false,
paddingVertical: 0,
@@ -198,9 +198,9 @@ const initializeWindows = function() {
globalUploadLimitFN = function() {
new MochaUI.Window({
id: 'uploadLimitPage',
id: "uploadLimitPage",
title: "QBT_TR(Global Upload Speed Limit)QBT_TR[CONTEXT=MainWindow]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("uploadlimit.html").setData("hashes", "global").toString(),
scrollbars: false,
resizable: false,
@@ -216,9 +216,9 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'uploadLimitPage',
id: "uploadLimitPage",
title: "QBT_TR(Torrent Upload Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("uploadlimit.html").setData("hashes", hashes.join("|")).toString(),
scrollbars: false,
resizable: false,
@@ -257,9 +257,9 @@ const initializeWindows = function() {
// if all torrents have same share ratio, display that share ratio. else use the default
const orig = torrentsHaveSameShareRatio ? shareRatio : "";
new MochaUI.Window({
id: 'shareRatioPage',
id: "shareRatioPage",
title: "QBT_TR(Torrent Upload/Download Ratio Limiting)QBT_TR[CONTEXT=UpDownRatioDialog]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("shareratio.html").setData("hashes", hashes.join("|")).setData("orig", orig).toString(),
scrollbars: false,
maximizable: false,
@@ -275,8 +275,8 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/toggleSequentialDownload',
method: 'post',
url: "api/v2/torrents/toggleSequentialDownload",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -289,8 +289,8 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/toggleFirstLastPiecePrio',
method: 'post',
url: "api/v2/torrents/toggleFirstLastPiecePrio",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -303,8 +303,8 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/setSuperSeeding',
method: 'post',
url: "api/v2/torrents/setSuperSeeding",
method: "post",
data: {
value: val,
hashes: hashes.join("|")
@@ -318,10 +318,10 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/setForceStart',
method: 'post',
url: "api/v2/torrents/setForceStart",
method: "post",
data: {
value: 'true',
value: "true",
hashes: hashes.join("|")
}
}).send();
@@ -331,9 +331,9 @@ const initializeWindows = function() {
globalDownloadLimitFN = function() {
new MochaUI.Window({
id: 'downloadLimitPage',
id: "downloadLimitPage",
title: "QBT_TR(Global Download Speed Limit)QBT_TR[CONTEXT=MainWindow]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("downloadlimit.html").setData("hashes", "global").toString(),
scrollbars: false,
resizable: false,
@@ -346,11 +346,11 @@ const initializeWindows = function() {
};
StatisticsLinkFN = function() {
const id = 'statisticspage';
const id = "statisticspage";
new MochaUI.Window({
id: id,
title: 'QBT_TR(Statistics)QBT_TR[CONTEXT=StatsDialog]',
loadMethod: 'xhr',
title: "QBT_TR(Statistics)QBT_TR[CONTEXT=StatsDialog]",
loadMethod: "xhr",
contentURL: new URI("views/statistics.html").toString(),
maximizable: false,
padding: 10,
@@ -366,9 +366,9 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'downloadLimitPage',
id: "downloadLimitPage",
title: "QBT_TR(Torrent Download Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("downloadlimit.html").setData("hashes", hashes.join("|")).toString(),
scrollbars: false,
resizable: false,
@@ -385,9 +385,9 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'confirmDeletionPage',
id: "confirmDeletionPage",
title: "QBT_TR(Remove torrent(s))QBT_TR[CONTEXT=confirmDeletionDlg]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("confirmdeletion.html").setData("hashes", hashes.join("|")).setData("deleteFiles", deleteFiles).toString(),
scrollbars: false,
resizable: true,
@@ -400,7 +400,7 @@ const initializeWindows = function() {
}
};
addClickEvent('delete', function(e) {
addClickEvent("delete", function(e) {
new Event(e).stop();
deleteFN();
});
@@ -409,8 +409,8 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/stop',
method: 'post',
url: "api/v2/torrents/stop",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -423,8 +423,8 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/start',
method: 'post',
url: "api/v2/torrents/start",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -443,8 +443,8 @@ const initializeWindows = function() {
enable = true;
});
new Request({
url: 'api/v2/torrents/setAutoManagement',
method: 'post',
url: "api/v2/torrents/setAutoManagement",
method: "post",
data: {
hashes: hashes.join("|"),
enable: enable
@@ -458,8 +458,8 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/recheck',
method: 'post',
url: "api/v2/torrents/recheck",
method: "post",
data: {
hashes: hashes.join("|"),
}
@@ -472,8 +472,8 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/reannounce',
method: 'post',
url: "api/v2/torrents/reannounce",
method: "post",
data: {
hashes: hashes.join("|"),
}
@@ -489,10 +489,10 @@ const initializeWindows = function() {
const row = torrentsTable.rows[hash];
new MochaUI.Window({
id: 'setLocationPage',
id: "setLocationPage",
title: "QBT_TR(Set location)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
contentURL: new URI("setlocation.html").setData("hashes", hashes.join('|')).setData("path", encodeURIComponent(row.full_data.save_path)).toString(),
loadMethod: "iframe",
contentURL: new URI("setlocation.html").setData("hashes", hashes.join("|")).setData("path", encodeURIComponent(row.full_data.save_path)).toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@@ -511,9 +511,9 @@ const initializeWindows = function() {
const row = torrentsTable.rows[hash];
if (row) {
new MochaUI.Window({
id: 'renamePage',
id: "renamePage",
title: "QBT_TR(Rename)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("rename.html").setData("hash", hash).setData("name", row.full_data.name).toString(),
scrollbars: false,
resizable: true,
@@ -534,11 +534,11 @@ const initializeWindows = function() {
const row = torrentsTable.rows[hash];
if (row) {
new MochaUI.Window({
id: 'multiRenamePage',
id: "multiRenamePage",
title: "QBT_TR(Renaming)QBT_TR[CONTEXT=TransferListWidget]",
data: { hash: hash, selectedRows: [] },
loadMethod: 'xhr',
contentURL: 'rename_files.html',
loadMethod: "xhr",
contentURL: "rename_files.html",
scrollbars: false,
resizable: true,
maximizable: false,
@@ -546,7 +546,7 @@ const initializeWindows = function() {
paddingHorizontal: 0,
width: 800,
height: 420,
resizeLimit: { 'x': [800], 'y': [420] }
resizeLimit: { "x": [800], "y": [420] }
});
}
}
@@ -557,10 +557,10 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'newCategoryPage',
id: "newCategoryPage",
title: "QBT_TR(New Category)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
contentURL: new URI("newcategory.html").setData("action", action).setData("hashes", hashes.join('|')).toString(),
loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", action).setData("hashes", hashes.join("|")).toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@@ -579,10 +579,10 @@ const initializeWindows = function() {
const categoryName = category_list.has(categoryHash)
? category_list.get(categoryHash).name
: '';
: "";
new Request({
url: 'api/v2/torrents/setCategory',
method: 'post',
url: "api/v2/torrents/setCategory",
method: "post",
data: {
hashes: hashes.join("|"),
category: categoryName
@@ -593,9 +593,9 @@ const initializeWindows = function() {
createCategoryFN = function() {
const action = "create";
new MochaUI.Window({
id: 'newCategoryPage',
id: "newCategoryPage",
title: "QBT_TR(New Category)QBT_TR[CONTEXT=CategoryFilterWidget]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", action).toString(),
scrollbars: false,
resizable: true,
@@ -612,9 +612,9 @@ const initializeWindows = function() {
const action = "createSubcategory";
const categoryName = category_list.get(categoryHash).name + "/";
new MochaUI.Window({
id: 'newSubcategoryPage',
id: "newSubcategoryPage",
title: "QBT_TR(New Category)QBT_TR[CONTEXT=CategoryFilterWidget]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", action).setData("categoryName", categoryName).toString(),
scrollbars: false,
resizable: true,
@@ -631,10 +631,10 @@ const initializeWindows = function() {
const action = "edit";
const category = category_list.get(categoryHash);
new MochaUI.Window({
id: 'editCategoryPage',
id: "editCategoryPage",
title: "QBT_TR(Edit Category)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
contentURL: new URI('newcategory.html').setData("action", action).setData("categoryName", category.name).setData("savePath", category.savePath).toString(),
loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", action).setData("categoryName", category.name).setData("savePath", category.savePath).toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@@ -649,8 +649,8 @@ const initializeWindows = function() {
removeCategoryFN = function(categoryHash) {
const categoryName = category_list.get(categoryHash).name;
new Request({
url: 'api/v2/torrents/removeCategories',
method: 'post',
url: "api/v2/torrents/removeCategories",
method: "post",
data: {
categories: categoryName
}
@@ -661,26 +661,26 @@ const initializeWindows = function() {
deleteUnusedCategoriesFN = function() {
const categories = [];
category_list.forEach((category, hash) => {
if (torrentsTable.getFilteredTorrentsNumber('all', hash, TAGS_ALL, TRACKERS_ALL) === 0)
if (torrentsTable.getFilteredTorrentsNumber("all", hash, TAGS_ALL, TRACKERS_ALL) === 0)
categories.push(category.name);
});
new Request({
url: 'api/v2/torrents/removeCategories',
method: 'post',
url: "api/v2/torrents/removeCategories",
method: "post",
data: {
categories: categories.join('\n')
categories: categories.join("\n")
}
}).send();
setCategoryFilter(CATEGORIES_ALL);
};
startTorrentsByCategoryFN = function(categoryHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash, TAGS_ALL, TRACKERS_ALL);
const hashes = torrentsTable.getFilteredTorrentsHashes("all", categoryHash, TAGS_ALL, TRACKERS_ALL);
if (hashes.length) {
new Request({
url: 'api/v2/torrents/start',
method: 'post',
url: "api/v2/torrents/start",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -690,11 +690,11 @@ const initializeWindows = function() {
};
stopTorrentsByCategoryFN = function(categoryHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash, TAGS_ALL, TRACKERS_ALL);
const hashes = torrentsTable.getFilteredTorrentsHashes("all", categoryHash, TAGS_ALL, TRACKERS_ALL);
if (hashes.length) {
new Request({
url: 'api/v2/torrents/stop',
method: 'post',
url: "api/v2/torrents/stop",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -704,12 +704,12 @@ const initializeWindows = function() {
};
deleteTorrentsByCategoryFN = function(categoryHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash, TAGS_ALL, TRACKERS_ALL);
const hashes = torrentsTable.getFilteredTorrentsHashes("all", categoryHash, TAGS_ALL, TRACKERS_ALL);
if (hashes.length) {
new MochaUI.Window({
id: 'confirmDeletionPage',
id: "confirmDeletionPage",
title: "QBT_TR(Remove torrent(s))QBT_TR[CONTEXT=confirmDeletionDlg]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("confirmdeletion.html").setData("hashes", hashes.join("|")).toString(),
scrollbars: false,
resizable: true,
@@ -727,9 +727,9 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'newTagPage',
id: "newTagPage",
title: "QBT_TR(Add Tags)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("newtag.html").setData("action", action).setData("hashes", hashes.join("|")).toString(),
scrollbars: false,
resizable: true,
@@ -747,10 +747,10 @@ const initializeWindows = function() {
if (hashes.length <= 0)
return;
const tagName = tagList.has(tagHash) ? tagList.get(tagHash).name : '';
const tagName = tagList.has(tagHash) ? tagList.get(tagHash).name : "";
new Request({
url: (isSet ? 'api/v2/torrents/addTags' : 'api/v2/torrents/removeTags'),
method: 'post',
url: (isSet ? "api/v2/torrents/addTags" : "api/v2/torrents/removeTags"),
method: "post",
data: {
hashes: hashes.join("|"),
tags: tagName,
@@ -762,8 +762,8 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: ('api/v2/torrents/removeTags'),
method: 'post',
url: ("api/v2/torrents/removeTags"),
method: "post",
data: {
hashes: hashes.join("|"),
}
@@ -774,9 +774,9 @@ const initializeWindows = function() {
createTagFN = function() {
const action = "create";
new MochaUI.Window({
id: 'newTagPage',
id: "newTagPage",
title: "QBT_TR(New Tag)QBT_TR[CONTEXT=TagFilterWidget]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("newtag.html").setData("action", action).toString(),
scrollbars: false,
resizable: true,
@@ -792,8 +792,8 @@ const initializeWindows = function() {
removeTagFN = function(tagHash) {
const tagName = tagList.get(tagHash).name;
new Request({
url: 'api/v2/torrents/deleteTags',
method: 'post',
url: "api/v2/torrents/deleteTags",
method: "post",
data: {
tags: tagName
}
@@ -804,25 +804,25 @@ const initializeWindows = function() {
deleteUnusedTagsFN = function() {
const tags = [];
tagList.forEach((tag, hash) => {
if (torrentsTable.getFilteredTorrentsNumber('all', CATEGORIES_ALL, hash, TRACKERS_ALL) === 0)
if (torrentsTable.getFilteredTorrentsNumber("all", CATEGORIES_ALL, hash, TRACKERS_ALL) === 0)
tags.push(tag.name);
});
new Request({
url: 'api/v2/torrents/deleteTags',
method: 'post',
url: "api/v2/torrents/deleteTags",
method: "post",
data: {
tags: tags.join(',')
tags: tags.join(",")
}
}).send();
setTagFilter(TAGS_ALL);
};
startTorrentsByTagFN = function(tagHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, tagHash, TRACKERS_ALL);
const hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, tagHash, TRACKERS_ALL);
if (hashes.length) {
new Request({
url: 'api/v2/torrents/start',
method: 'post',
url: "api/v2/torrents/start",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -832,11 +832,11 @@ const initializeWindows = function() {
};
stopTorrentsByTagFN = function(tagHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, tagHash, TRACKERS_ALL);
const hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, tagHash, TRACKERS_ALL);
if (hashes.length) {
new Request({
url: 'api/v2/torrents/stop',
method: 'post',
url: "api/v2/torrents/stop",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -846,12 +846,12 @@ const initializeWindows = function() {
};
deleteTorrentsByTagFN = function(tagHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, tagHash, TRACKERS_ALL);
const hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, tagHash, TRACKERS_ALL);
if (hashes.length) {
new MochaUI.Window({
id: 'confirmDeletionPage',
id: "confirmDeletionPage",
title: "QBT_TR(Remove torrent(s))QBT_TR[CONTEXT=confirmDeletionDlg]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("confirmdeletion.html").setData("hashes", hashes.join("|")).toString(),
scrollbars: false,
resizable: true,
@@ -869,10 +869,10 @@ const initializeWindows = function() {
let hashes = [];
switch (trackerHashInt) {
case TRACKERS_ALL:
hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, TAGS_ALL, TRACKERS_ALL);
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_ALL);
break;
case TRACKERS_TRACKERLESS:
hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
break;
default: {
const uniqueTorrents = new Set();
@@ -888,8 +888,8 @@ const initializeWindows = function() {
if (hashes.length > 0) {
new Request({
url: 'api/v2/torrents/start',
method: 'post',
url: "api/v2/torrents/start",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -903,10 +903,10 @@ const initializeWindows = function() {
let hashes = [];
switch (trackerHashInt) {
case TRACKERS_ALL:
hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, TAGS_ALL, TRACKERS_ALL);
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_ALL);
break;
case TRACKERS_TRACKERLESS:
hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
break;
default: {
const uniqueTorrents = new Set();
@@ -922,8 +922,8 @@ const initializeWindows = function() {
if (hashes.length) {
new Request({
url: 'api/v2/torrents/stop',
method: 'post',
url: "api/v2/torrents/stop",
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -937,10 +937,10 @@ const initializeWindows = function() {
let hashes = [];
switch (trackerHashInt) {
case TRACKERS_ALL:
hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, TAGS_ALL, TRACKERS_ALL);
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_ALL);
break;
case TRACKERS_TRACKERLESS:
hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
break;
default: {
const uniqueTorrents = new Set();
@@ -956,9 +956,9 @@ const initializeWindows = function() {
if (hashes.length) {
new MochaUI.Window({
id: 'confirmDeletionPage',
id: "confirmDeletionPage",
title: "QBT_TR(Remove torrent(s))QBT_TR[CONTEXT=confirmDeletionDlg]",
loadMethod: 'iframe',
loadMethod: "iframe",
contentURL: new URI("confirmdeletion.html").setData("hashes", hashes.join("|")).toString(),
scrollbars: false,
resizable: true,
@@ -1068,13 +1068,13 @@ const initializeWindows = function() {
}
};
addClickEvent('stopAll', (e) => {
addClickEvent("stopAll", (e) => {
new Event(e).stop();
if (confirm('QBT_TR(Would you like to stop all torrents?)QBT_TR[CONTEXT=MainWindow]')) {
if (confirm("QBT_TR(Would you like to stop all torrents?)QBT_TR[CONTEXT=MainWindow]")) {
new Request({
url: 'api/v2/torrents/stop',
method: 'post',
url: "api/v2/torrents/stop",
method: "post",
data: {
hashes: "all"
}
@@ -1083,13 +1083,13 @@ const initializeWindows = function() {
}
});
addClickEvent('startAll', (e) => {
addClickEvent("startAll", (e) => {
new Event(e).stop();
if (confirm('QBT_TR(Would you like to start all torrents?)QBT_TR[CONTEXT=MainWindow]')) {
if (confirm("QBT_TR(Would you like to start all torrents?)QBT_TR[CONTEXT=MainWindow]")) {
new Request({
url: 'api/v2/torrents/start',
method: 'post',
url: "api/v2/torrents/start",
method: "post",
data: {
hashes: "all"
}
@@ -1098,15 +1098,15 @@ const initializeWindows = function() {
}
});
['stop', 'start', 'recheck'].each(function(item) {
["stop", "start", "recheck"].each(function(item) {
addClickEvent(item, function(e) {
new Event(e).stop();
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
hashes.each(function(hash, index) {
new Request({
url: 'api/v2/torrents/' + item,
method: 'post',
url: "api/v2/torrents/" + item,
method: "post",
data: {
hashes: hash
}
@@ -1117,7 +1117,7 @@ const initializeWindows = function() {
});
});
['decreasePrio', 'increasePrio', 'topPrio', 'bottomPrio'].each(function(item) {
["decreasePrio", "increasePrio", "topPrio", "bottomPrio"].each(function(item) {
addClickEvent(item, function(e) {
new Event(e).stop();
setQueuePositionFN(item);
@@ -1128,8 +1128,8 @@ const initializeWindows = function() {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new Request({
url: 'api/v2/torrents/' + cmd,
method: 'post',
url: "api/v2/torrents/" + cmd,
method: "post",
data: {
hashes: hashes.join("|")
}
@@ -1138,19 +1138,19 @@ const initializeWindows = function() {
}
};
addClickEvent('about', function(e) {
addClickEvent("about", function(e) {
new Event(e).stop();
const id = 'aboutpage';
const id = "aboutpage";
new MochaUI.Window({
id: id,
title: 'QBT_TR(About qBittorrent)QBT_TR[CONTEXT=AboutDialog]',
loadMethod: 'xhr',
title: "QBT_TR(About qBittorrent)QBT_TR[CONTEXT=AboutDialog]",
loadMethod: "xhr",
contentURL: new URI("views/about.html").toString(),
require: {
css: ['css/Tabs.css']
css: ["css/Tabs.css"]
},
toolbar: true,
toolbarURL: 'views/aboutToolbar.html',
toolbarURL: "views/aboutToolbar.html",
padding: 10,
width: loadWindowWidth(id, 550),
height: loadWindowHeight(id, 360),
@@ -1160,25 +1160,25 @@ const initializeWindows = function() {
});
});
addClickEvent('logout', function(e) {
addClickEvent("logout", function(e) {
new Event(e).stop();
new Request({
url: 'api/v2/auth/logout',
method: 'post',
url: "api/v2/auth/logout",
method: "post",
onSuccess: function() {
window.location.reload(true);
}
}).send();
});
addClickEvent('shutdown', function(e) {
addClickEvent("shutdown", function(e) {
new Event(e).stop();
if (confirm('QBT_TR(Are you sure you want to quit qBittorrent?)QBT_TR[CONTEXT=MainWindow]')) {
if (confirm("QBT_TR(Are you sure you want to quit qBittorrent?)QBT_TR[CONTEXT=MainWindow]")) {
new Request({
url: 'api/v2/app/shutdown',
method: 'post',
url: "api/v2/app/shutdown",
method: "post",
onSuccess: function() {
const shutdownMessage = 'QBT_TR(%1 has been shutdown)QBT_TR[CONTEXT=HttpServer]'.replace("%1", window.qBittorrent.Client.mainTitle());
const shutdownMessage = "QBT_TR(%1 has been shutdown)QBT_TR[CONTEXT=HttpServer]".replace("%1", window.qBittorrent.Client.mainTitle());
document.write(`<!doctype html><html lang="${LANG}"><head> <meta charset="UTF-8"> <meta name="color-scheme" content="light dark"> <title>${shutdownMessage}</title> <style>* {font-family: Arial, Helvetica, sans-serif;}</style></head><body> <h1 style="text-align: center;">${shutdownMessage}</h1></body></html>`);
document.close();
window.stop();
@@ -1189,8 +1189,8 @@ const initializeWindows = function() {
});
// Deactivate menu header links
$$('a.returnFalse').each(function(el) {
el.addEvent('click', function(e) {
$$("a.returnFalse").each(function(el) {
el.addEvent("click", function(e) {
new Event(e).stop();
});
});

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -51,35 +51,35 @@ window.qBittorrent.PiecesBar = (() => {
const PiecesBar = new Class({
initialize(pieces, parameters) {
const vals = {
'id': 'piecesbar_' + (piecesBarUniqueId++),
'width': 0,
'height': 0,
'downloadingColor': 'hsl(110deg 94% 27%)', // @TODO palette vars not supported for this value, apply average
'haveColor': 'hsl(210deg 55% 55%)', // @TODO palette vars not supported for this value, apply average
'borderSize': 1,
'borderColor': 'var(--color-border-default)'
"id": "piecesbar_" + (piecesBarUniqueId++),
"width": 0,
"height": 0,
"downloadingColor": "hsl(110deg 94% 27%)", // @TODO palette vars not supported for this value, apply average
"haveColor": "hsl(210deg 55% 55%)", // @TODO palette vars not supported for this value, apply average
"borderSize": 1,
"borderColor": "var(--color-border-default)"
};
if (parameters && (typeOf(parameters) === 'object'))
if (parameters && (typeOf(parameters) === "object"))
Object.append(vals, parameters);
vals.height = Math.max(vals.height, 12);
const obj = new Element('div', {
'id': vals.id,
'class': 'piecesbarWrapper',
'styles': {
'border': vals.borderSize.toString() + 'px solid ' + vals.borderColor,
'height': vals.height.toString() + 'px',
const obj = new Element("div", {
"id": vals.id,
"class": "piecesbarWrapper",
"styles": {
"border": vals.borderSize.toString() + "px solid " + vals.borderColor,
"height": vals.height.toString() + "px",
}
});
obj.vals = vals;
obj.vals.pieces = [pieces, []].pick();
obj.vals.canvas = new Element('canvas', {
'id': vals.id + '_canvas',
'class': 'piecesbarCanvas',
'width': (vals.width - (2 * vals.borderSize)).toString(),
'height': '1' // will stretch vertically to take up the height of the parent
obj.vals.canvas = new Element("canvas", {
"id": vals.id + "_canvas",
"class": "piecesbarCanvas",
"width": (vals.width - (2 * vals.borderSize)).toString(),
"height": "1" // will stretch vertically to take up the height of the parent
});
obj.appendChild(obj.vals.canvas);
@@ -124,7 +124,7 @@ window.qBittorrent.PiecesBar = (() => {
this.vals.canvas.width = width - (2 * this.vals.borderSize);
const canvas = this.vals.canvas;
const ctx = canvas.getContext('2d');
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
const imageWidth = canvas.width;
@@ -246,7 +246,7 @@ window.qBittorrent.PiecesBar = (() => {
function drawStatus(ctx, start, width, statusValues) {
// mix the colors by using transparency and a composite mode
ctx.globalCompositeOperation = 'lighten';
ctx.globalCompositeOperation = "lighten";
if (statusValues[STATUS_DOWNLOADING]) {
ctx.globalAlpha = statusValues[STATUS_DOWNLOADING];

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -43,60 +43,60 @@ window.qBittorrent.ProgressBar = (function() {
const ProgressBar = new Class({
initialize: function(value, parameters) {
const vals = {
'id': 'progressbar_' + (ProgressBars++),
'value': [value, 0].pick(),
'width': 0,
'height': 0,
'darkbg': 'var(--color-background-blue)',
'darkfg': 'var(--color-text-white)',
'lightbg': 'var(--color-background-default)',
'lightfg': 'var(--color-text-default)'
"id": "progressbar_" + (ProgressBars++),
"value": [value, 0].pick(),
"width": 0,
"height": 0,
"darkbg": "var(--color-background-blue)",
"darkfg": "var(--color-text-white)",
"lightbg": "var(--color-background-default)",
"lightfg": "var(--color-text-default)"
};
if (parameters && (typeOf(parameters) === 'object'))
if (parameters && (typeOf(parameters) === "object"))
Object.append(vals, parameters);
if (vals.height < 12)
vals.height = 12;
const obj = new Element('div', {
'id': vals.id,
'class': 'progressbar_wrapper',
'styles': {
'border': '1px solid var(--color-border-default)',
'width': vals.width,
'height': vals.height,
'position': 'relative',
'margin': '0 auto'
const obj = new Element("div", {
"id": vals.id,
"class": "progressbar_wrapper",
"styles": {
"border": "1px solid var(--color-border-default)",
"width": vals.width,
"height": vals.height,
"position": "relative",
"margin": "0 auto"
}
});
obj.vals = vals;
obj.vals.value = [value, 0].pick();
obj.vals.dark = new Element('div', {
'id': vals.id + '_dark',
'class': 'progressbar_dark',
'styles': {
'width': vals.width,
'height': vals.height,
'background': vals.darkbg,
'color': vals.darkfg,
'position': 'absolute',
'text-align': 'center',
'left': 0,
'top': 0,
'line-height': vals.height
obj.vals.dark = new Element("div", {
"id": vals.id + "_dark",
"class": "progressbar_dark",
"styles": {
"width": vals.width,
"height": vals.height,
"background": vals.darkbg,
"color": vals.darkfg,
"position": "absolute",
"text-align": "center",
"left": 0,
"top": 0,
"line-height": vals.height
}
});
obj.vals.light = new Element('div', {
'id': vals.id + '_light',
'class': 'progressbar_light',
'styles': {
'width': vals.width,
'height': vals.height,
'background': vals.lightbg,
'color': vals.lightfg,
'position': 'absolute',
'text-align': 'center',
'left': 0,
'top': 0,
'line-height': vals.height
obj.vals.light = new Element("div", {
"id": vals.id + "_light",
"class": "progressbar_light",
"styles": {
"width": vals.width,
"height": vals.height,
"background": vals.lightbg,
"color": vals.lightfg,
"position": "absolute",
"text-align": "center",
"left": 0,
"top": 0,
"line-height": vals.height
}
});
obj.appendChild(obj.vals.dark);
@@ -127,19 +127,19 @@ window.qBittorrent.ProgressBar = (function() {
this.vals.value = value;
this.vals.dark.empty();
this.vals.light.empty();
this.vals.dark.appendText(value.round(1).toFixed(1) + '%');
this.vals.light.appendText(value.round(1).toFixed(1) + '%');
this.vals.dark.appendText(value.round(1).toFixed(1) + "%");
this.vals.light.appendText(value.round(1).toFixed(1) + "%");
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)');
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)");
}
function ProgressBar_setWidth(value) {
if (this.vals.width !== value) {
this.vals.width = value;
this.setStyle('width', value);
this.vals.dark.setStyle('width', value);
this.vals.light.setStyle('width', value);
this.setStyle("width", value);
this.vals.dark.setStyle("width", value);
this.vals.light.setStyle("width", value);
this.setValue(this.vals.value);
}
}
@@ -150,10 +150,10 @@ window.qBittorrent.ProgressBar = (function() {
return;
if (!obj.parentNode)
return setTimeout('ProgressBar_checkForParent("' + id + '")', 1);
obj.setStyle('width', '100%');
obj.setStyle("width", "100%");
const w = obj.offsetWidth;
obj.vals.dark.setStyle('width', w);
obj.vals.light.setStyle('width', w);
obj.vals.dark.setStyle("width", w);
obj.vals.light.setStyle("width", w);
obj.vals.width = w;
obj.setValue(obj.vals.value);
}

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -107,8 +107,8 @@ window.qBittorrent.PropFiles = (function() {
const checkbox = e.target;
const priority = checkbox.checked ? FilePriority.Normal : FilePriority.Ignored;
const id = checkbox.get('data-id');
const fileId = checkbox.get('data-file-id');
const id = checkbox.get("data-id");
const fileId = checkbox.get("data-file-id");
const rows = getAllChildren(id, fileId);
@@ -119,8 +119,8 @@ window.qBittorrent.PropFiles = (function() {
const fileComboboxChanged = function(e) {
const combobox = e.target;
const priority = combobox.value;
const id = combobox.get('data-id');
const fileId = combobox.get('data-file-id');
const id = combobox.get("data-id");
const fileId = combobox.get("data-file-id");
const rows = getAllChildren(id, fileId);
@@ -129,24 +129,24 @@ window.qBittorrent.PropFiles = (function() {
};
const isDownloadCheckboxExists = function(id) {
return ($('cbPrio' + id) !== null);
return ($("cbPrio" + id) !== null);
};
const createDownloadCheckbox = function(id, fileId, checked) {
const checkbox = new Element('input');
checkbox.set('type', 'checkbox');
checkbox.set('id', 'cbPrio' + id);
checkbox.set('data-id', id);
checkbox.set('data-file-id', fileId);
checkbox.set('class', 'DownloadedCB');
checkbox.addEvent('click', fileCheckboxClicked);
const checkbox = new Element("input");
checkbox.set("type", "checkbox");
checkbox.set("id", "cbPrio" + id);
checkbox.set("data-id", id);
checkbox.set("data-file-id", fileId);
checkbox.set("class", "DownloadedCB");
checkbox.addEvent("click", fileCheckboxClicked);
updateCheckbox(checkbox, checked);
return checkbox;
};
const updateDownloadCheckbox = function(id, checked) {
const checkbox = $('cbPrio' + id);
const checkbox = $("cbPrio" + id);
updateCheckbox(checkbox, checked);
};
@@ -165,41 +165,41 @@ window.qBittorrent.PropFiles = (function() {
};
const isPriorityComboExists = function(id) {
return ($('comboPrio' + id) !== null);
return ($("comboPrio" + id) !== null);
};
const createPriorityOptionElement = function(priority, selected, html) {
const elem = new Element('option');
elem.set('value', priority.toString());
elem.set('html', html);
const elem = new Element("option");
elem.set("value", priority.toString());
elem.set("html", html);
if (selected)
elem.selected = true;
return elem;
};
const createPriorityCombo = function(id, fileId, selectedPriority) {
const select = new Element('select');
select.set('id', 'comboPrio' + id);
select.set('data-id', id);
select.set('data-file-id', fileId);
select.addClass('combo_priority');
select.addEvent('change', fileComboboxChanged);
const select = new Element("select");
select.set("id", "comboPrio" + id);
select.set("data-id", id);
select.set("data-file-id", fileId);
select.addClass("combo_priority");
select.addEvent("change", fileComboboxChanged);
createPriorityOptionElement(FilePriority.Ignored, (FilePriority.Ignored === selectedPriority), 'QBT_TR(Do not download)QBT_TR[CONTEXT=PropListDelegate]').injectInside(select);
createPriorityOptionElement(FilePriority.Normal, (FilePriority.Normal === selectedPriority), 'QBT_TR(Normal)QBT_TR[CONTEXT=PropListDelegate]').injectInside(select);
createPriorityOptionElement(FilePriority.High, (FilePriority.High === selectedPriority), 'QBT_TR(High)QBT_TR[CONTEXT=PropListDelegate]').injectInside(select);
createPriorityOptionElement(FilePriority.Maximum, (FilePriority.Maximum === selectedPriority), 'QBT_TR(Maximum)QBT_TR[CONTEXT=PropListDelegate]').injectInside(select);
createPriorityOptionElement(FilePriority.Ignored, (FilePriority.Ignored === selectedPriority), "QBT_TR(Do not download)QBT_TR[CONTEXT=PropListDelegate]").injectInside(select);
createPriorityOptionElement(FilePriority.Normal, (FilePriority.Normal === selectedPriority), "QBT_TR(Normal)QBT_TR[CONTEXT=PropListDelegate]").injectInside(select);
createPriorityOptionElement(FilePriority.High, (FilePriority.High === selectedPriority), "QBT_TR(High)QBT_TR[CONTEXT=PropListDelegate]").injectInside(select);
createPriorityOptionElement(FilePriority.Maximum, (FilePriority.Maximum === selectedPriority), "QBT_TR(Maximum)QBT_TR[CONTEXT=PropListDelegate]").injectInside(select);
// "Mixed" priority is for display only; it shouldn't be selectable
const mixedPriorityOption = createPriorityOptionElement(FilePriority.Mixed, (FilePriority.Mixed === selectedPriority), 'QBT_TR(Mixed)QBT_TR[CONTEXT=PropListDelegate]');
mixedPriorityOption.set('disabled', true);
const mixedPriorityOption = createPriorityOptionElement(FilePriority.Mixed, (FilePriority.Mixed === selectedPriority), "QBT_TR(Mixed)QBT_TR[CONTEXT=PropListDelegate]");
mixedPriorityOption.set("disabled", true);
mixedPriorityOption.injectInside(select);
return select;
};
const updatePriorityCombo = function(id, selectedPriority) {
const combobox = $('comboPrio' + id);
const combobox = $("comboPrio" + id);
if (parseInt(combobox.value) !== selectedPriority)
selectComboboxPriority(combobox, selectedPriority);
@@ -224,7 +224,7 @@ window.qBittorrent.PropFiles = (function() {
const rowIds = [];
const fileIds = [];
let priority = FilePriority.Ignored;
const checkbox = $('tristate_cb');
const checkbox = $("tristate_cb");
if (checkbox.state === "checked") {
setCheckboxUnchecked(checkbox);
@@ -261,7 +261,7 @@ window.qBittorrent.PropFiles = (function() {
};
const updateGlobalCheckbox = function() {
const checkbox = $('tristate_cb');
const checkbox = $("tristate_cb");
if (isAllCheckboxesChecked())
setCheckboxChecked(checkbox);
else if (isAllCheckboxesUnchecked())
@@ -288,7 +288,7 @@ window.qBittorrent.PropFiles = (function() {
};
const isAllCheckboxesChecked = function() {
const checkboxes = $$('input.DownloadedCB');
const checkboxes = $$("input.DownloadedCB");
for (let i = 0; i < checkboxes.length; ++i) {
if (!checkboxes[i].checked)
return false;
@@ -297,7 +297,7 @@ window.qBittorrent.PropFiles = (function() {
};
const isAllCheckboxesUnchecked = function() {
const checkboxes = $$('input.DownloadedCB');
const checkboxes = $$("input.DownloadedCB");
for (let i = 0; i < checkboxes.length; ++i) {
if (checkboxes[i].checked)
return false;
@@ -311,12 +311,12 @@ window.qBittorrent.PropFiles = (function() {
clearTimeout(loadTorrentFilesDataTimer);
new Request({
url: 'api/v2/torrents/filePrio',
method: 'post',
url: "api/v2/torrents/filePrio",
method: "post",
data: {
'hash': current_hash,
'id': fileIds.join('|'),
'priority': priority
"hash": current_hash,
"id": fileIds.join("|"),
"priority": priority
},
onComplete: function() {
loadTorrentFilesDataTimer = loadTorrentFilesData.delay(1000);
@@ -327,7 +327,7 @@ window.qBittorrent.PropFiles = (function() {
ids.forEach(function(_id) {
torrentFilesTable.setIgnored(_id, ignore);
const combobox = $('comboPrio' + _id);
const combobox = $("comboPrio" + _id);
if (combobox !== null)
selectComboboxPriority(combobox, priority);
});
@@ -337,8 +337,8 @@ window.qBittorrent.PropFiles = (function() {
let loadTorrentFilesDataTimer;
const loadTorrentFilesData = function() {
if ($('prop_files').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
if ($("prop_files").hasClass("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) {
// Tab changed, don't do anything
return;
}
@@ -355,10 +355,10 @@ window.qBittorrent.PropFiles = (function() {
current_hash = new_hash;
loadedNewTorrent = true;
}
const 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,
method: 'get',
method: "get",
noCache: true,
onComplete: function() {
clearTimeout(loadTorrentFilesDataTimer);
@@ -427,7 +427,7 @@ window.qBittorrent.PropFiles = (function() {
pathItems.pop(); // remove last item (i.e. file name)
let parent = rootNode;
pathItems.forEach(function(folderName) {
if (folderName === '.unwanted')
if (folderName === ".unwanted")
return;
let folderNode = null;
@@ -517,7 +517,7 @@ window.qBittorrent.PropFiles = (function() {
const rowIds = [];
const fileIds = [];
selectedRows.forEach(function(rowId) {
const elem = $('comboPrio' + rowId);
const elem = $("comboPrio" + rowId);
rowIds.push(rowId);
fileIds.push(elem.get("data-file-id"));
});
@@ -549,11 +549,11 @@ window.qBittorrent.PropFiles = (function() {
const path = node.path;
new MochaUI.Window({
id: 'renamePage',
id: "renamePage",
title: "QBT_TR(Renaming)QBT_TR[CONTEXT=TorrentContentTreeView]",
loadMethod: 'iframe',
contentURL: 'rename_file.html?hash=' + hash + '&isFolder=' + node.isFolder
+ '&path=' + encodeURIComponent(path),
loadMethod: "iframe",
contentURL: "rename_file.html?hash=" + hash + "&isFolder=" + node.isFolder
+ "&path=" + encodeURIComponent(path),
scrollbars: false,
resizable: true,
maximizable: false,
@@ -566,11 +566,11 @@ window.qBittorrent.PropFiles = (function() {
const multiFileRename = function(hash) {
new MochaUI.Window({
id: 'multiRenamePage',
id: "multiRenamePage",
title: "QBT_TR(Renaming)QBT_TR[CONTEXT=TorrentContentTreeView]",
data: { hash: hash, selectedRows: torrentFilesTable.selectedRows },
loadMethod: 'xhr',
contentURL: 'rename_files.html',
loadMethod: "xhr",
contentURL: "rename_files.html",
scrollbars: false,
resizable: true,
maximizable: false,
@@ -578,13 +578,13 @@ window.qBittorrent.PropFiles = (function() {
paddingHorizontal: 0,
width: 800,
height: 420,
resizeLimit: { 'x': [800], 'y': [420] }
resizeLimit: { "x": [800], "y": [420] }
});
};
const torrentFilesContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
targets: '#torrentFilesTableDiv tr',
menu: 'torrentFilesMenu',
targets: "#torrentFilesTableDiv tr",
menu: "torrentFilesMenu",
actions: {
Rename: function(element, ref) {
const hash = torrentsTable.getCurrentTorrentID();
@@ -618,20 +618,20 @@ window.qBittorrent.PropFiles = (function() {
},
onShow: function() {
if (is_seed)
this.hideItem('FilePrio');
this.hideItem("FilePrio");
else
this.showItem('FilePrio');
this.showItem("FilePrio");
}
});
torrentFilesTable.setup('torrentFilesTableDiv', 'torrentFilesTableFixedHeaderDiv', torrentFilesContextMenu);
torrentFilesTable.setup("torrentFilesTableDiv", "torrentFilesTableFixedHeaderDiv", torrentFilesContextMenu);
// inject checkbox into table header
const tableHeaders = $$('#torrentFilesTableFixedHeaderDiv .dynamicTableHeader th');
const tableHeaders = $$("#torrentFilesTableFixedHeaderDiv .dynamicTableHeader th");
if (tableHeaders.length > 0) {
const checkbox = new Element('input');
checkbox.set('type', 'checkbox');
checkbox.set('id', 'tristate_cb');
checkbox.addEvent('click', switchCheckboxState);
const checkbox = new Element("input");
checkbox.set("type", "checkbox");
checkbox.set("id", "tristate_cb");
checkbox.addEvent("click", switchCheckboxState);
const checkboxTH = tableHeaders[0];
checkbox.injectInside(checkboxTH);
@@ -639,14 +639,14 @@ window.qBittorrent.PropFiles = (function() {
// default sort by name column
if (torrentFilesTable.getSortedColumn() === null)
torrentFilesTable.setSortedColumn('name');
torrentFilesTable.setSortedColumn("name");
// listen for changes to torrentFilesFilterInput
let torrentFilesFilterInputTimer = -1;
$('torrentFilesFilterInput').addEvent('input', () => {
$("torrentFilesFilterInput").addEvent("input", () => {
clearTimeout(torrentFilesFilterInputTimer);
const value = $('torrentFilesFilterInput').get("value");
const value = $("torrentFilesFilterInput").get("value");
torrentFilesTable.setFilter(value);
torrentFilesFilterInputTimer = setTimeout(() => {
@@ -668,7 +668,7 @@ window.qBittorrent.PropFiles = (function() {
* Show/hide a node's row
*/
const _hideNode = function(node, shouldHide) {
const span = $('filesTablefileName' + node.rowId);
const span = $("filesTablefileName" + node.rowId);
// span won't exist if row has been filtered out
if (span === null)
return;
@@ -683,7 +683,7 @@ window.qBittorrent.PropFiles = (function() {
* Update a node's collapsed state and icon
*/
const _updateNodeState = function(node, isCollapsed) {
const span = $('filesTablefileName' + node.rowId);
const span = $("filesTablefileName" + node.rowId);
// span won't exist if row has been filtered out
if (span === null)
return;
@@ -701,7 +701,7 @@ window.qBittorrent.PropFiles = (function() {
};
const _isCollapsed = function(node) {
const span = $('filesTablefileName' + node.rowId);
const span = $("filesTablefileName" + node.rowId);
if (span === null)
return true;

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -42,42 +42,42 @@ window.qBittorrent.PropGeneral = (function() {
const piecesBar = new window.qBittorrent.PiecesBar.PiecesBar([], {
height: 16
});
$('progress').appendChild(piecesBar);
$("progress").appendChild(piecesBar);
const clearData = function() {
$('time_elapsed').set('html', '');
$('eta').set('html', '');
$('nb_connections').set('html', '');
$('total_downloaded').set('html', '');
$('total_uploaded').set('html', '');
$('dl_speed').set('html', '');
$('up_speed').set('html', '');
$('dl_limit').set('html', '');
$('up_limit').set('html', '');
$('total_wasted').set('html', '');
$('seeds').set('html', '');
$('peers').set('html', '');
$('share_ratio').set('html', '');
$('popularity').set('html', '');
$('reannounce').set('html', '');
$('last_seen').set('html', '');
$('total_size').set('html', '');
$('pieces').set('html', '');
$('created_by').set('html', '');
$('addition_date').set('html', '');
$('completion_date').set('html', '');
$('creation_date').set('html', '');
$('torrent_hash_v1').set('html', '');
$('torrent_hash_v2').set('html', '');
$('save_path').set('html', '');
$('comment').set('html', '');
$("time_elapsed").set("html", "");
$("eta").set("html", "");
$("nb_connections").set("html", "");
$("total_downloaded").set("html", "");
$("total_uploaded").set("html", "");
$("dl_speed").set("html", "");
$("up_speed").set("html", "");
$("dl_limit").set("html", "");
$("up_limit").set("html", "");
$("total_wasted").set("html", "");
$("seeds").set("html", "");
$("peers").set("html", "");
$("share_ratio").set("html", "");
$("popularity").set("html", "");
$("reannounce").set("html", "");
$("last_seen").set("html", "");
$("total_size").set("html", "");
$("pieces").set("html", "");
$("created_by").set("html", "");
$("addition_date").set("html", "");
$("completion_date").set("html", "");
$("creation_date").set("html", "");
$("torrent_hash_v1").set("html", "");
$("torrent_hash_v2").set("html", "");
$("save_path").set("html", "");
$("comment").set("html", "");
piecesBar.clear();
};
let loadTorrentDataTimer;
const loadTorrentData = function() {
if ($('prop_general').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
if ($("prop_general").hasClass("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) {
// Tab changed, don't do anything
return;
}
@@ -88,18 +88,18 @@ window.qBittorrent.PropGeneral = (function() {
loadTorrentDataTimer = loadTorrentData.delay(5000);
return;
}
const url = new URI('api/v2/torrents/properties?hash=' + current_id);
const url = new URI("api/v2/torrents/properties?hash=" + current_id);
new Request.JSON({
url: url,
method: 'get',
method: "get",
noCache: true,
onFailure: function() {
$('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]');
$("error_div").set("html", "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]");
clearTimeout(loadTorrentDataTimer);
loadTorrentDataTimer = loadTorrentData.delay(10000);
},
onSuccess: function(data) {
$('error_div').set('html', '');
$("error_div").set("html", "");
if (data) {
// Update Torrent data
@@ -108,109 +108,109 @@ window.qBittorrent.PropGeneral = (function() {
.replace("%1", window.qBittorrent.Misc.friendlyDuration(data.time_elapsed))
.replace("%2", window.qBittorrent.Misc.friendlyDuration(data.seeding_time))
: window.qBittorrent.Misc.friendlyDuration(data.time_elapsed);
$('time_elapsed').set('html', timeElapsed);
$("time_elapsed").set("html", timeElapsed);
$('eta').set('html', window.qBittorrent.Misc.friendlyDuration(data.eta, window.qBittorrent.Misc.MAX_ETA));
$("eta").set("html", window.qBittorrent.Misc.friendlyDuration(data.eta, window.qBittorrent.Misc.MAX_ETA));
const nbConnections = "QBT_TR(%1 (%2 max))QBT_TR[CONTEXT=PropertiesWidget]"
.replace("%1", data.nb_connections)
.replace("%2", ((data.nb_connections_limit < 0) ? "∞" : data.nb_connections_limit));
$('nb_connections').set('html', nbConnections);
$("nb_connections").set("html", nbConnections);
const totalDownloaded = "QBT_TR(%1 (%2 this session))QBT_TR[CONTEXT=PropertiesWidget]"
.replace("%1", window.qBittorrent.Misc.friendlyUnit(data.total_downloaded))
.replace("%2", window.qBittorrent.Misc.friendlyUnit(data.total_downloaded_session));
$('total_downloaded').set('html', totalDownloaded);
$("total_downloaded").set("html", totalDownloaded);
const totalUploaded = "QBT_TR(%1 (%2 this session))QBT_TR[CONTEXT=PropertiesWidget]"
.replace("%1", window.qBittorrent.Misc.friendlyUnit(data.total_uploaded))
.replace("%2", window.qBittorrent.Misc.friendlyUnit(data.total_uploaded_session));
$('total_uploaded').set('html', totalUploaded);
$("total_uploaded").set("html", totalUploaded);
const dlSpeed = "QBT_TR(%1 (%2 avg.))QBT_TR[CONTEXT=PropertiesWidget]"
.replace("%1", window.qBittorrent.Misc.friendlyUnit(data.dl_speed, true))
.replace("%2", window.qBittorrent.Misc.friendlyUnit(data.dl_speed_avg, true));
$('dl_speed').set('html', dlSpeed);
$("dl_speed").set("html", dlSpeed);
const upSpeed = "QBT_TR(%1 (%2 avg.))QBT_TR[CONTEXT=PropertiesWidget]"
.replace("%1", window.qBittorrent.Misc.friendlyUnit(data.up_speed, true))
.replace("%2", window.qBittorrent.Misc.friendlyUnit(data.up_speed_avg, true));
$('up_speed').set('html', upSpeed);
$("up_speed").set("html", upSpeed);
const dlLimit = (data.dl_limit === -1)
? "∞"
: window.qBittorrent.Misc.friendlyUnit(data.dl_limit, true);
$('dl_limit').set('html', dlLimit);
$("dl_limit").set("html", dlLimit);
const upLimit = (data.up_limit === -1)
? "∞"
: window.qBittorrent.Misc.friendlyUnit(data.up_limit, true);
$('up_limit').set('html', upLimit);
$("up_limit").set("html", upLimit);
$('total_wasted').set('html', window.qBittorrent.Misc.friendlyUnit(data.total_wasted));
$("total_wasted").set("html", window.qBittorrent.Misc.friendlyUnit(data.total_wasted));
const seeds = "QBT_TR(%1 (%2 total))QBT_TR[CONTEXT=PropertiesWidget]"
.replace("%1", data.seeds)
.replace("%2", data.seeds_total);
$('seeds').set('html', seeds);
$("seeds").set("html", seeds);
const peers = "QBT_TR(%1 (%2 total))QBT_TR[CONTEXT=PropertiesWidget]"
.replace("%1", data.peers)
.replace("%2", data.peers_total);
$('peers').set('html', peers);
$("peers").set("html", peers);
$('share_ratio').set('html', data.share_ratio.toFixed(2));
$("share_ratio").set("html", data.share_ratio.toFixed(2));
$('popularity').set('html', data.popularity.toFixed(2));
$("popularity").set("html", data.popularity.toFixed(2));
$('reannounce').set('html', window.qBittorrent.Misc.friendlyDuration(data.reannounce));
$("reannounce").set("html", window.qBittorrent.Misc.friendlyDuration(data.reannounce));
const lastSeen = (data.last_seen >= 0)
? new Date(data.last_seen * 1000).toLocaleString()
: "QBT_TR(Never)QBT_TR[CONTEXT=PropertiesWidget]";
$('last_seen').set('html', lastSeen);
$("last_seen").set("html", lastSeen);
const totalSize = (data.total_size >= 0) ? window.qBittorrent.Misc.friendlyUnit(data.total_size) : "";
$('total_size').set('html', totalSize);
$("total_size").set("html", totalSize);
const pieces = (data.pieces_num >= 0)
? "QBT_TR(%1 x %2 (have %3))QBT_TR[CONTEXT=PropertiesWidget]"
.replace("%1", data.pieces_num)
.replace("%2", window.qBittorrent.Misc.friendlyUnit(data.piece_size))
.replace("%3", data.pieces_have)
: '';
$('pieces').set('html', pieces);
: "";
$("pieces").set("html", pieces);
$('created_by').set('text', data.created_by);
$("created_by").set("text", data.created_by);
const additionDate = (data.addition_date >= 0)
? new Date(data.addition_date * 1000).toLocaleString()
: "QBT_TR(Unknown)QBT_TR[CONTEXT=HttpServer]";
$('addition_date').set('html', additionDate);
$("addition_date").set("html", additionDate);
const completionDate = (data.completion_date >= 0)
? new Date(data.completion_date * 1000).toLocaleString()
: "";
$('completion_date').set('html', completionDate);
$("completion_date").set("html", completionDate);
const creationDate = (data.creation_date >= 0)
? new Date(data.creation_date * 1000).toLocaleString()
: "";
$('creation_date').set('html', creationDate);
$("creation_date").set("html", creationDate);
const torrentHashV1 = (data.infohash_v1 !== "")
? data.infohash_v1
: "QBT_TR(N/A)QBT_TR[CONTEXT=PropertiesWidget]";
$('torrent_hash_v1').set('html', torrentHashV1);
$("torrent_hash_v1").set("html", torrentHashV1);
const torrentHashV2 = (data.infohash_v2 !== "")
? data.infohash_v2
: "QBT_TR(N/A)QBT_TR[CONTEXT=PropertiesWidget]";
$('torrent_hash_v2').set('html', torrentHashV2);
$("torrent_hash_v2").set("html", torrentHashV2);
$('save_path').set('html', data.save_path);
$("save_path").set("html", data.save_path);
$('comment').set('html', window.qBittorrent.Misc.parseHtmlLinks(window.qBittorrent.Misc.escapeHtml(data.comment)));
$("comment").set("html", window.qBittorrent.Misc.parseHtmlLinks(window.qBittorrent.Misc.escapeHtml(data.comment)));
}
else {
clearData();
@@ -220,18 +220,18 @@ window.qBittorrent.PropGeneral = (function() {
}
}).send();
const piecesUrl = new URI('api/v2/torrents/pieceStates?hash=' + current_id);
const piecesUrl = new URI("api/v2/torrents/pieceStates?hash=" + current_id);
new Request.JSON({
url: piecesUrl,
method: 'get',
method: "get",
noCache: true,
onFailure: function() {
$('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]');
$("error_div").set("html", "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]");
clearTimeout(loadTorrentDataTimer);
loadTorrentDataTimer = loadTorrentData.delay(10000);
},
onSuccess: function(data) {
$('error_div').set('html', '');
$("error_div").set("html", "");
if (data) {
piecesBar.setPieces(data);

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -45,8 +45,8 @@ window.qBittorrent.PropPeers = (function() {
let show_flags = true;
const loadTorrentPeersData = function() {
if ($('prop_peers').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
if ($("prop_peers").hasClass("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) {
syncTorrentPeersLastResponseId = 0;
torrentPeersTable.clear();
return;
@@ -59,45 +59,45 @@ window.qBittorrent.PropPeers = (function() {
loadTorrentPeersTimer = loadTorrentPeersData.delay(window.qBittorrent.Client.getSyncMainDataInterval());
return;
}
const url = new URI('api/v2/sync/torrentPeers');
url.setData('rid', syncTorrentPeersLastResponseId);
url.setData('hash', current_hash);
const url = new URI("api/v2/sync/torrentPeers");
url.setData("rid", syncTorrentPeersLastResponseId);
url.setData("hash", current_hash);
new Request.JSON({
url: url,
method: 'get',
method: "get",
noCache: true,
onComplete: function() {
clearTimeout(loadTorrentPeersTimer);
loadTorrentPeersTimer = loadTorrentPeersData.delay(window.qBittorrent.Client.getSyncMainDataInterval());
},
onSuccess: function(response) {
$('error_div').set('html', '');
$("error_div").set("html", "");
if (response) {
const 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 (const key in response['peers']) {
response['peers'][key]['rowId'] = key;
if (response["rid"])
syncTorrentPeersLastResponseId = response["rid"];
if (response["peers"]) {
for (const key in response["peers"]) {
response["peers"][key]["rowId"] = key;
torrentPeersTable.updateRowData(response['peers'][key]);
torrentPeersTable.updateRowData(response["peers"][key]);
}
}
if (response['peers_removed']) {
response['peers_removed'].each(function(hash) {
if (response["peers_removed"]) {
response["peers_removed"].each(function(hash) {
torrentPeersTable.removeRow(hash);
});
}
torrentPeersTable.updateTable(full_update);
torrentPeersTable.altRow();
if (response['show_flags']) {
if (show_flags !== response['show_flags']) {
show_flags = response['show_flags'];
torrentPeersTable.columns['country'].force_hide = !show_flags;
torrentPeersTable.updateColumn('country');
if (response["show_flags"]) {
if (show_flags !== response["show_flags"]) {
show_flags = response["show_flags"];
torrentPeersTable.columns["country"].force_hide = !show_flags;
torrentPeersTable.updateColumn("country");
}
}
}
@@ -114,8 +114,8 @@ window.qBittorrent.PropPeers = (function() {
};
const torrentPeersContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
targets: '#torrentPeersTableDiv',
menu: 'torrentPeersMenu',
targets: "#torrentPeersTableDiv",
menu: "torrentPeersMenu",
actions: {
addPeer: function(element, ref) {
const hash = torrentsTable.getCurrentTorrentID();
@@ -123,10 +123,10 @@ window.qBittorrent.PropPeers = (function() {
return;
new MochaUI.Window({
id: 'addPeersPage',
id: "addPeersPage",
title: "QBT_TR(Add Peers)QBT_TR[CONTEXT=PeersAdditionDialog]",
loadMethod: 'iframe',
contentURL: 'addpeers.html?hash=' + hash,
loadMethod: "iframe",
contentURL: "addpeers.html?hash=" + hash,
scrollbars: false,
resizable: false,
maximizable: false,
@@ -141,13 +141,13 @@ window.qBittorrent.PropPeers = (function() {
if (selectedPeers.length === 0)
return;
if (confirm('QBT_TR(Are you sure you want to permanently ban the selected peers?)QBT_TR[CONTEXT=PeerListWidget]')) {
if (confirm("QBT_TR(Are you sure you want to permanently ban the selected peers?)QBT_TR[CONTEXT=PeerListWidget]")) {
new Request({
url: 'api/v2/transfer/banPeers',
method: 'post',
url: "api/v2/transfer/banPeers",
method: "post",
data: {
hash: torrentsTable.getCurrentTorrentID(),
peers: selectedPeers.join('|')
peers: selectedPeers.join("|")
}
}).send();
}
@@ -161,23 +161,23 @@ window.qBittorrent.PropPeers = (function() {
const selectedPeers = torrentPeersTable.selectedRowsIds();
if (selectedPeers.length >= 1) {
this.showItem('copyPeer');
this.showItem('banPeer');
this.showItem("copyPeer");
this.showItem("banPeer");
}
else {
this.hideItem('copyPeer');
this.hideItem('banPeer');
this.hideItem("copyPeer");
this.hideItem("banPeer");
}
}
});
new ClipboardJS('#CopyPeerInfo', {
new ClipboardJS("#CopyPeerInfo", {
text: function(trigger) {
return torrentPeersTable.selectedRowsIds().join("\n");
}
});
torrentPeersTable.setup('torrentPeersTableDiv', 'torrentPeersTableFixedHeaderDiv', torrentPeersContextMenu);
torrentPeersTable.setup("torrentPeersTableDiv", "torrentPeersTableFixedHeaderDiv", torrentPeersContextMenu);
return exports();
})();

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -45,8 +45,8 @@ window.qBittorrent.PropTrackers = (function() {
let loadTrackersDataTimer;
const loadTrackersData = function() {
if ($('prop_trackers').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
if ($("prop_trackers").hasClass("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) {
// Tab changed, don't do anything
return;
}
@@ -61,10 +61,10 @@ window.qBittorrent.PropTrackers = (function() {
torrentTrackersTable.clear();
current_hash = new_hash;
}
const 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,
method: 'get',
method: "get",
noCache: true,
onComplete: function() {
clearTimeout(loadTrackersDataTimer);
@@ -126,8 +126,8 @@ window.qBittorrent.PropTrackers = (function() {
};
const torrentTrackersContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
targets: '#torrentTrackersTableDiv',
menu: 'torrentTrackersMenu',
targets: "#torrentTrackersTableDiv",
menu: "torrentTrackersMenu",
actions: {
AddTracker: function(element, ref) {
addTrackerFN();
@@ -152,14 +152,14 @@ window.qBittorrent.PropTrackers = (function() {
});
if (containsStaticTracker || (selectedTrackers.length === 0)) {
this.hideItem('EditTracker');
this.hideItem('RemoveTracker');
this.hideItem('CopyTrackerUrl');
this.hideItem("EditTracker");
this.hideItem("RemoveTracker");
this.hideItem("CopyTrackerUrl");
}
else {
this.showItem('EditTracker');
this.showItem('RemoveTracker');
this.showItem('CopyTrackerUrl');
this.showItem("EditTracker");
this.showItem("RemoveTracker");
this.showItem("CopyTrackerUrl");
}
}
});
@@ -168,10 +168,10 @@ window.qBittorrent.PropTrackers = (function() {
if (current_hash.length === 0)
return;
new MochaUI.Window({
id: 'trackersPage',
id: "trackersPage",
title: "QBT_TR(Add trackers)QBT_TR[CONTEXT=TrackersAdditionDialog]",
loadMethod: 'iframe',
contentURL: 'addtrackers.html?hash=' + current_hash,
loadMethod: "iframe",
contentURL: "addtrackers.html?hash=" + current_hash,
scrollbars: true,
resizable: false,
maximizable: false,
@@ -192,10 +192,10 @@ window.qBittorrent.PropTrackers = (function() {
const trackerUrl = encodeURIComponent(element.childNodes[1].innerText);
new MochaUI.Window({
id: 'trackersPage',
id: "trackersPage",
title: "QBT_TR(Tracker editing)QBT_TR[CONTEXT=TrackerListWidget]",
loadMethod: 'iframe',
contentURL: 'edittracker.html?hash=' + current_hash + '&url=' + trackerUrl,
loadMethod: "iframe",
contentURL: "edittracker.html?hash=" + current_hash + "&url=" + trackerUrl,
scrollbars: true,
resizable: false,
maximizable: false,
@@ -216,8 +216,8 @@ window.qBittorrent.PropTrackers = (function() {
const selectedTrackers = torrentTrackersTable.selectedRowsIds();
new Request({
url: 'api/v2/torrents/removeTrackers',
method: 'post',
url: "api/v2/torrents/removeTrackers",
method: "post",
data: {
hash: current_hash,
urls: selectedTrackers.join("|")
@@ -228,13 +228,13 @@ window.qBittorrent.PropTrackers = (function() {
}).send();
};
new ClipboardJS('#CopyTrackerUrl', {
new ClipboardJS("#CopyTrackerUrl", {
text: function(trigger) {
return torrentTrackersTable.selectedRowsIds().join("\n");
}
});
torrentTrackersTable.setup('torrentTrackersTableDiv', 'torrentTrackersTableFixedHeaderDiv', torrentTrackersContextMenu);
torrentTrackersTable.setup("torrentTrackersTableDiv", "torrentTrackersTableFixedHeaderDiv", torrentTrackersContextMenu);
return exports();
})();

View File

@@ -26,7 +26,7 @@
* exception statement from your version.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -64,9 +64,9 @@ window.qBittorrent.PropWebseeds = (function() {
},
updateRow: function(tr, row) {
const tds = tr.getElements('td');
const tds = tr.getElements("td");
for (let i = 0; i < row.length; ++i) {
tds[i].set('html', row[i]);
tds[i].set("html", row[i]);
}
return true;
},
@@ -79,11 +79,11 @@ window.qBittorrent.PropWebseeds = (function() {
return;
}
//this.removeRow(id);
const tr = new Element('tr');
const tr = new Element("tr");
this.rows.set(url, tr);
for (let i = 0; i < row.length; ++i) {
const td = new Element('td');
td.set('html', row[i]);
const td = new Element("td");
td.set("html", row[i]);
td.injectInside(tr);
}
tr.injectInside(this.table);
@@ -94,8 +94,8 @@ window.qBittorrent.PropWebseeds = (function() {
let loadWebSeedsDataTimer;
const loadWebSeedsData = function() {
if ($('prop_webseeds').hasClass('invisible')
|| $('propertiesPanel_collapseToggle').hasClass('panel-expand')) {
if ($("prop_webseeds").hasClass("invisible")
|| $("propertiesPanel_collapseToggle").hasClass("panel-expand")) {
// Tab changed, don't do anything
return;
}
@@ -110,18 +110,18 @@ window.qBittorrent.PropWebseeds = (function() {
wsTable.removeAllRows();
current_hash = new_hash;
}
const 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,
method: 'get',
method: "get",
noCache: true,
onFailure: function() {
$('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]');
$("error_div").set("html", "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]");
clearTimeout(loadWebSeedsDataTimer);
loadWebSeedsDataTimer = loadWebSeedsData.delay(20000);
},
onSuccess: function(webseeds) {
$('error_div').set('html', '');
$("error_div").set("html", "");
if (webseeds) {
// Update WebSeeds data
webseeds.each(function(webseed) {
@@ -146,7 +146,7 @@ window.qBittorrent.PropWebseeds = (function() {
};
const wsTable = new webseedsDynTable();
wsTable.setup($('webseedsTable'));
wsTable.setup($("webseedsTable"));
return exports();
})();

View File

@@ -1,4 +1,4 @@
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -19,7 +19,7 @@ window.qBittorrent.MultiRename = (function() {
};
const RenameFiles = new Class({
hash: '',
hash: "",
selectedFiles: [],
matchedFiles: [],
@@ -86,7 +86,7 @@ window.qBittorrent.MultiRename = (function() {
return input.substring(0, start) + replacement + input.substring(end);
};
const replaceGroup = (input, search, replacement, escape, stripEscape = true) => {
let result = '';
let result = "";
let i = 0;
while (i < input.length) {
// Check if the current index contains the escape string
@@ -135,7 +135,7 @@ window.qBittorrent.MultiRename = (function() {
// Setup regex search
const regexEscapeExp = new RegExp(/[/\-\\^$*+?.()|[\]{}]/g);
const standardSearch = new RegExp(this._inner_search.replace(regexEscapeExp, '\\$&'), regexFlags);
const standardSearch = new RegExp(this._inner_search.replace(regexEscapeExp, "\\$&"), regexFlags);
let regexSearch;
try {
regexSearch = new RegExp(this._inner_search, regexFlags);
@@ -195,21 +195,21 @@ window.qBittorrent.MultiRename = (function() {
for (let g = 0; g < match.length; ++g) {
let group = match[g];
if (!group) { continue; }
replacement = replaceGroup(replacement, `$${g}`, group, '\\', false);
replacement = replaceGroup(replacement, `$${g}`, group, "\\", false);
}
// Replace named groups
for (let namedGroup in match.groups) {
replacement = replaceGroup(replacement, `$${namedGroup}`, match.groups[namedGroup], '\\', false);
replacement = replaceGroup(replacement, `$${namedGroup}`, match.groups[namedGroup], "\\", false);
}
// Replace auxiliary variables
for (let v = 'dddddddd'; v !== ''; v = v.substring(1)) {
let fileCount = fileEnumeration.toString().padStart(v.length, '0');
replacement = replaceGroup(replacement, `$${v}`, fileCount, '\\', false);
for (let v = "dddddddd"; v !== ""; v = v.substring(1)) {
let fileCount = fileEnumeration.toString().padStart(v.length, "0");
replacement = replaceGroup(replacement, `$${v}`, fileCount, "\\", false);
}
// Remove empty $ variable
replacement = replaceGroup(replacement, '$', '', '\\');
replacement = replaceGroup(replacement, "$", "", "\\");
const wholeMatch = match[0];
const index = match['index'];
const index = match["index"];
renamed = replaceBetween(renamed, index + offset, index + offset + wholeMatch.length, replacement);
}
@@ -243,8 +243,8 @@ window.qBittorrent.MultiRename = (function() {
? parentPath + window.qBittorrent.Filesystem.PathSeparator + newName
: newName;
let renameRequest = new Request({
url: isFolder ? 'api/v2/torrents/renameFolder' : 'api/v2/torrents/renameFile',
method: 'post',
url: isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile",
method: "post",
data: {
hash: this.hash,
oldPath: oldPath,

View File

@@ -21,7 +21,7 @@
* THE SOFTWARE.
*/
'use strict';
"use strict";
if (window.qBittorrent === undefined) {
window.qBittorrent = {};
@@ -91,10 +91,10 @@ window.qBittorrent.Search = (function() {
const init = function() {
// load "Search in" preference from local storage
$('searchInTorrentName').set('value', (LocalPreferences.get('search_in_filter') === "names") ? "names" : "everywhere");
$("searchInTorrentName").set("value", (LocalPreferences.get("search_in_filter") === "names") ? "names" : "everywhere");
const searchResultsTableContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
targets: '.searchTableRow',
menu: 'searchResultsTableMenu',
targets: ".searchTableRow",
menu: "searchResultsTableMenu",
actions: {
Download: downloadSearchTorrent,
OpenDescriptionUrl: openSearchTorrentDescriptionUrl
@@ -105,32 +105,32 @@ window.qBittorrent.Search = (function() {
}
});
searchResultsTable = new window.qBittorrent.DynamicTable.SearchResultsTable();
searchResultsTable.setup('searchResultsTableDiv', 'searchResultsTableFixedHeaderDiv', searchResultsTableContextMenu);
searchResultsTable.setup("searchResultsTableDiv", "searchResultsTableFixedHeaderDiv", searchResultsTableContextMenu);
getPlugins();
// listen for changes to searchInNameFilter
let searchInNameFilterTimer = -1;
$('searchInNameFilter').addEvent('input', () => {
$("searchInNameFilter").addEvent("input", () => {
clearTimeout(searchInNameFilterTimer);
searchInNameFilterTimer = setTimeout(() => {
searchInNameFilterTimer = -1;
const value = $('searchInNameFilter').get("value");
const value = $("searchInNameFilter").get("value");
searchText.filterPattern = value;
searchFilterChanged();
}, window.qBittorrent.Misc.FILTER_INPUT_DELAY);
});
new Keyboard({
defaultEventType: 'keydown',
defaultEventType: "keydown",
events: {
'Enter': function(e) {
"Enter": function(e) {
// accept enter key as a click
new Event(e).stop();
const elem = e.event.srcElement;
if (elem.className.contains("searchInputField")) {
$('startSearchButton').click();
$("startSearchButton").click();
return;
}
@@ -144,14 +144,14 @@ window.qBittorrent.Search = (function() {
}).activate();
// restore search tabs
const searchJobs = JSON.parse(LocalPreferences.get('search_jobs', '[]'));
const searchJobs = JSON.parse(LocalPreferences.get("search_jobs", "[]"));
for (const { id, pattern } of searchJobs) {
createSearchTab(id, pattern);
}
};
const numSearchTabs = function() {
return $('searchTabs').getElements('li').length;
return $("searchTabs").getElements("li").length;
};
const getSearchIdFromTab = function(tab) {
@@ -160,38 +160,38 @@ window.qBittorrent.Search = (function() {
const createSearchTab = function(searchId, pattern) {
const newTabId = `${searchTabIdPrefix}${searchId}`;
const tabElem = new Element('a', {
const tabElem = new Element("a", {
text: pattern,
});
const closeTabElem = new Element('img', {
alt: 'QBT_TR(Close tab)QBT_TR[CONTEXT=SearchWidget]',
title: 'QBT_TR(Close tab)QBT_TR[CONTEXT=SearchWidget]',
src: 'images/application-exit.svg',
width: '8',
height: '8',
style: 'padding-right: 7px; margin-bottom: -1px; margin-left: -5px',
onclick: 'qBittorrent.Search.closeSearchTab(this)',
const closeTabElem = new Element("img", {
alt: "QBT_TR(Close tab)QBT_TR[CONTEXT=SearchWidget]",
title: "QBT_TR(Close tab)QBT_TR[CONTEXT=SearchWidget]",
src: "images/application-exit.svg",
width: "8",
height: "8",
style: "padding-right: 7px; margin-bottom: -1px; margin-left: -5px",
onclick: "qBittorrent.Search.closeSearchTab(this)",
});
closeTabElem.inject(tabElem, 'top');
tabElem.appendChild(getStatusIconElement('QBT_TR(Searching...)QBT_TR[CONTEXT=SearchJobWidget]', 'images/queued.svg'));
$('searchTabs').appendChild(new Element('li', {
closeTabElem.inject(tabElem, "top");
tabElem.appendChild(getStatusIconElement("QBT_TR(Searching...)QBT_TR[CONTEXT=SearchJobWidget]", "images/queued.svg"));
$("searchTabs").appendChild(new Element("li", {
id: newTabId,
class: 'selected',
class: "selected",
html: tabElem.outerHTML,
}));
// unhide the results elements
if (numSearchTabs() >= 1) {
$('searchResultsNoSearches').style.display = "none";
$('searchResultsFilters').style.display = "block";
$('searchResultsTableContainer').style.display = "block";
$('searchTabsToolbar').style.display = "block";
$("searchResultsNoSearches").style.display = "none";
$("searchResultsFilters").style.display = "block";
$("searchResultsTableContainer").style.display = "block";
$("searchTabsToolbar").style.display = "block";
}
// reinitialize tabs
$('searchTabs').getElements('li').removeEvents('click');
$('searchTabs').getElements('li').addEvent('click', function(e) {
$('startSearchButton').set('text', 'QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]');
$("searchTabs").getElements("li").removeEvents("click");
$("searchTabs").getElements("li").addEvent("click", function(e) {
$("startSearchButton").set("text", "QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]");
setActiveTab(this);
});
@@ -220,7 +220,7 @@ window.qBittorrent.Search = (function() {
const closeSearchTab = function(el) {
const tab = el.parentElement.parentElement;
const searchId = getSearchIdFromTab(tab);
const isTabSelected = tab.hasClass('selected');
const isTabSelected = tab.hasClass("selected");
const newTabToSelect = isTabSelected ? tab.nextSibling || tab.previousSibling : null;
const currentSearchId = getSelectedSearchId();
@@ -233,34 +233,34 @@ window.qBittorrent.Search = (function() {
tab.destroy();
new Request({
url: new URI('api/v2/search/delete'),
method: 'post',
url: new URI("api/v2/search/delete"),
method: "post",
data: {
id: searchId
},
}).send();
const searchJobs = JSON.parse(LocalPreferences.get('search_jobs', '[]'));
const searchJobs = JSON.parse(LocalPreferences.get("search_jobs", "[]"));
const jobIndex = searchJobs.findIndex((job) => job.id === searchId);
if (jobIndex >= 0) {
searchJobs.splice(jobIndex, 1);
LocalPreferences.set('search_jobs', JSON.stringify(searchJobs));
LocalPreferences.set("search_jobs", JSON.stringify(searchJobs));
}
if (numSearchTabs() === 0) {
resetSearchState();
resetFilters();
$('numSearchResultsVisible').set('html', 0);
$('numSearchResultsTotal').set('html', 0);
$('searchResultsNoSearches').style.display = "block";
$('searchResultsFilters').style.display = "none";
$('searchResultsTableContainer').style.display = "none";
$('searchTabsToolbar').style.display = "none";
$("numSearchResultsVisible").set("html", 0);
$("numSearchResultsTotal").set("html", 0);
$("searchResultsNoSearches").style.display = "block";
$("searchResultsFilters").style.display = "none";
$("searchResultsTableContainer").style.display = "none";
$("searchTabsToolbar").style.display = "none";
}
else if (isTabSelected && newTabToSelect) {
setActiveTab(newTabToSelect);
$('startSearchButton').set('text', 'QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]');
$("startSearchButton").set("text", "QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]");
}
};
@@ -302,7 +302,7 @@ window.qBittorrent.Search = (function() {
saveCurrentTabState();
MochaUI.selected(tab, 'searchTabs');
MochaUI.selected(tab, "searchTabs");
const state = searchState.get(searchId);
let rowsToSelect = [];
@@ -319,32 +319,32 @@ window.qBittorrent.Search = (function() {
// restore filters
searchText.pattern = state.searchPattern;
searchText.filterPattern = state.filterPattern;
$('searchInNameFilter').set("value", state.filterPattern);
$("searchInNameFilter").set("value", state.filterPattern);
searchSeedsFilter.min = state.seedsFilter.min;
searchSeedsFilter.max = state.seedsFilter.max;
$('searchMinSeedsFilter').set('value', state.seedsFilter.min);
$('searchMaxSeedsFilter').set('value', state.seedsFilter.max);
$("searchMinSeedsFilter").set("value", state.seedsFilter.min);
$("searchMaxSeedsFilter").set("value", state.seedsFilter.max);
searchSizeFilter.min = state.sizeFilter.min;
searchSizeFilter.minUnit = state.sizeFilter.minUnit;
searchSizeFilter.max = state.sizeFilter.max;
searchSizeFilter.maxUnit = state.sizeFilter.maxUnit;
$('searchMinSizeFilter').set('value', state.sizeFilter.min);
$('searchMinSizePrefix').set('value', state.sizeFilter.minUnit);
$('searchMaxSizeFilter').set('value', state.sizeFilter.max);
$('searchMaxSizePrefix').set('value', state.sizeFilter.maxUnit);
$("searchMinSizeFilter").set("value", state.sizeFilter.min);
$("searchMinSizePrefix").set("value", state.sizeFilter.minUnit);
$("searchMaxSizeFilter").set("value", state.sizeFilter.max);
$("searchMaxSizePrefix").set("value", state.sizeFilter.maxUnit);
const currentSearchPattern = $('searchPattern').getProperty('value').trim();
const currentSearchPattern = $("searchPattern").getProperty("value").trim();
if (state.running && (state.searchPattern === currentSearchPattern)) {
// allow search to be stopped
$('startSearchButton').set('text', 'QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]');
$("startSearchButton").set("text", "QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]");
searchPatternChanged = false;
}
searchResultsTable.setSortedColumn(state.sort.column, state.sort.reverse);
$('searchInTorrentName').set('value', state.searchIn);
$("searchInTorrentName").set("value", state.searchIn);
}
// must restore all filters before calling updateTable
@@ -356,76 +356,76 @@ window.qBittorrent.Search = (function() {
searchResultsTable.reselectRows(rowsToSelect);
}
$('numSearchResultsVisible').set('html', searchResultsTable.getFilteredAndSortedRows().length);
$('numSearchResultsTotal').set('html', searchResultsTable.getRowIds().length);
$("numSearchResultsVisible").set("html", searchResultsTable.getFilteredAndSortedRows().length);
$("numSearchResultsTotal").set("html", searchResultsTable.getRowIds().length);
setupSearchTableEvents(true);
};
const getStatusIconElement = function(text, image) {
return new Element('img', {
return new Element("img", {
alt: text,
title: text,
src: image,
class: 'statusIcon',
width: '10',
height: '10',
style: 'margin-bottom: -2px; margin-left: 7px',
class: "statusIcon",
width: "10",
height: "10",
style: "margin-bottom: -2px; margin-left: 7px",
});
};
const updateStatusIconElement = function(searchId, text, image) {
const searchTab = $(`${searchTabIdPrefix}${searchId}`);
if (searchTab) {
const statusIcon = searchTab.getElement('.statusIcon');
statusIcon.set('alt', text);
statusIcon.set('title', text);
statusIcon.set('src', image);
const statusIcon = searchTab.getElement(".statusIcon");
statusIcon.set("alt", text);
statusIcon.set("title", text);
statusIcon.set("src", image);
}
};
const startSearch = function(pattern, category, plugins) {
searchPatternChanged = false;
const url = new URI('api/v2/search/start');
const url = new URI("api/v2/search/start");
new Request.JSON({
url: url,
method: 'post',
method: "post",
data: {
pattern: pattern,
category: category,
plugins: plugins
},
onSuccess: function(response) {
$('startSearchButton').set('text', 'QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]');
$("startSearchButton").set("text", "QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]");
const searchId = response.id;
createSearchTab(searchId, pattern);
const searchJobs = JSON.parse(LocalPreferences.get('search_jobs', '[]'));
const searchJobs = JSON.parse(LocalPreferences.get("search_jobs", "[]"));
searchJobs.push({ id: searchId, pattern: pattern });
LocalPreferences.set('search_jobs', JSON.stringify(searchJobs));
LocalPreferences.set("search_jobs", JSON.stringify(searchJobs));
}
}).send();
};
const stopSearch = function(searchId) {
const url = new URI('api/v2/search/stop');
const url = new URI("api/v2/search/stop");
new Request({
url: url,
method: 'post',
method: "post",
data: {
id: searchId
},
onSuccess: function(response) {
resetSearchState(searchId);
// not strictly necessary to do this when the tab is being closed, but there's no harm in it
updateStatusIconElement(searchId, 'QBT_TR(Search aborted)QBT_TR[CONTEXT=SearchJobWidget]', 'images/task-reject.svg');
updateStatusIconElement(searchId, "QBT_TR(Search aborted)QBT_TR[CONTEXT=SearchJobWidget]", "images/task-reject.svg");
}
}).send();
};
const getSelectedSearchId = function() {
const selectedTab = $('searchTabs').getElement('li.selected');
const selectedTab = $("searchTabs").getElement("li.selected");
return selectedTab ? getSearchIdFromTab(selectedTab) : null;
};
@@ -434,9 +434,9 @@ window.qBittorrent.Search = (function() {
const state = searchState.get(currentSearchId);
const isSearchRunning = state && state.running;
if (!isSearchRunning || searchPatternChanged) {
const pattern = $('searchPattern').getProperty('value').trim();
let category = $('categorySelect').getProperty('value');
const plugins = $('pluginsSelect').getProperty('value');
const pattern = $("searchPattern").getProperty("value").trim();
let category = $("categorySelect").getProperty("value");
const plugins = $("pluginsSelect").getProperty("value");
if (!pattern || !category || !plugins)
return;
@@ -493,13 +493,13 @@ window.qBittorrent.Search = (function() {
};
const manageSearchPlugins = function() {
const id = 'searchPlugins';
const id = "searchPlugins";
if (!$(id))
new MochaUI.Window({
id: id,
title: "QBT_TR(Search plugins)QBT_TR[CONTEXT=PluginSelectDlg]",
loadMethod: 'xhr',
contentURL: 'views/searchplugins.html',
loadMethod: "xhr",
contentURL: "views/searchplugins.html",
scrollbars: false,
maximizable: false,
paddingVertical: 0,
@@ -526,15 +526,15 @@ window.qBittorrent.Search = (function() {
const onSearchPatternChanged = function() {
const currentSearchId = getSelectedSearchId();
const state = searchState.get(currentSearchId);
const currentSearchPattern = $('searchPattern').getProperty('value').trim();
const currentSearchPattern = $("searchPattern").getProperty("value").trim();
// start a new search if pattern has changed, otherwise allow the search to be stopped
if (state && (state.searchPattern === currentSearchPattern)) {
searchPatternChanged = false;
$('startSearchButton').set('text', 'QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]');
$("startSearchButton").set("text", "QBT_TR(Stop)QBT_TR[CONTEXT=SearchEngineWidget]");
}
else {
searchPatternChanged = true;
$('startSearchButton').set('text', 'QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]');
$("startSearchButton").set("text", "QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]");
}
};
@@ -568,7 +568,7 @@ window.qBittorrent.Search = (function() {
};
const resetSearchState = function(searchId) {
$('startSearchButton').set('text', 'QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]');
$("startSearchButton").set("text", "QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]");
const state = searchState.get(searchId);
if (state) {
state.running = false;
@@ -595,10 +595,10 @@ window.qBittorrent.Search = (function() {
categoryHtml.splice(1, 0, option.outerHTML);
}
$('categorySelect').set('html', categoryHtml.join(""));
$("categorySelect").set("html", categoryHtml.join(""));
};
const selectedPlugin = $('pluginsSelect').get("value");
const selectedPlugin = $("pluginsSelect").get("value");
if ((selectedPlugin === "all") || (selectedPlugin === "enabled")) {
const uniqueCategories = {};
@@ -626,8 +626,8 @@ window.qBittorrent.Search = (function() {
const getPlugins = function() {
new Request.JSON({
url: new URI('api/v2/search/plugins'),
method: 'get',
url: new URI("api/v2/search/plugins"),
method: "get",
noCache: true,
onSuccess: function(response) {
if (response !== prevSearchPluginsResponse) {
@@ -643,9 +643,9 @@ window.qBittorrent.Search = (function() {
const searchPluginsEmpty = (searchPlugins.length === 0);
if (!searchPluginsEmpty) {
$('searchResultsNoPlugins').style.display = "none";
$("searchResultsNoPlugins").style.display = "none";
if (numSearchTabs() === 0) {
$('searchResultsNoSearches').style.display = "block";
$("searchResultsNoSearches").style.display = "block";
}
// sort plugins alphabetically
@@ -664,12 +664,12 @@ window.qBittorrent.Search = (function() {
pluginsHtml.splice(2, 0, "<option disabled>──────────</option>");
}
$('pluginsSelect').set('html', pluginsHtml.join(""));
$("pluginsSelect").set("html", pluginsHtml.join(""));
$('searchPattern').setProperty('disabled', searchPluginsEmpty);
$('categorySelect').setProperty('disabled', searchPluginsEmpty);
$('pluginsSelect').setProperty('disabled', searchPluginsEmpty);
$('startSearchButton').setProperty('disabled', searchPluginsEmpty);
$("searchPattern").setProperty("disabled", searchPluginsEmpty);
$("categorySelect").setProperty("disabled", searchPluginsEmpty);
$("pluginsSelect").setProperty("disabled", searchPluginsEmpty);
$("startSearchButton").setProperty("disabled", searchPluginsEmpty);
if (window.qBittorrent.SearchPlugins !== undefined)
window.qBittorrent.SearchPlugins.updateTable();
@@ -689,67 +689,67 @@ window.qBittorrent.Search = (function() {
};
const resetFilters = function() {
searchText.filterPattern = '';
$('searchInNameFilter').set('value', '');
searchText.filterPattern = "";
$("searchInNameFilter").set("value", "");
searchSeedsFilter.min = 0;
searchSeedsFilter.max = 0;
$('searchMinSeedsFilter').set('value', searchSeedsFilter.min);
$('searchMaxSeedsFilter').set('value', searchSeedsFilter.max);
$("searchMinSeedsFilter").set("value", searchSeedsFilter.min);
$("searchMaxSeedsFilter").set("value", searchSeedsFilter.max);
searchSizeFilter.min = 0.00;
searchSizeFilter.minUnit = 2; // B = 0, KiB = 1, MiB = 2, GiB = 3, TiB = 4, PiB = 5, EiB = 6
searchSizeFilter.max = 0.00;
searchSizeFilter.maxUnit = 3;
$('searchMinSizeFilter').set('value', searchSizeFilter.min);
$('searchMinSizePrefix').set('value', searchSizeFilter.minUnit);
$('searchMaxSizeFilter').set('value', searchSizeFilter.max);
$('searchMaxSizePrefix').set('value', searchSizeFilter.maxUnit);
$("searchMinSizeFilter").set("value", searchSizeFilter.min);
$("searchMinSizePrefix").set("value", searchSizeFilter.minUnit);
$("searchMaxSizeFilter").set("value", searchSizeFilter.max);
$("searchMaxSizePrefix").set("value", searchSizeFilter.maxUnit);
};
const getSearchInTorrentName = function() {
return $('searchInTorrentName').get('value') === "names" ? "names" : "everywhere";
return $("searchInTorrentName").get("value") === "names" ? "names" : "everywhere";
};
const searchInTorrentName = function() {
LocalPreferences.set('search_in_filter', getSearchInTorrentName());
LocalPreferences.set("search_in_filter", getSearchInTorrentName());
searchFilterChanged();
};
const searchSeedsFilterChanged = function() {
searchSeedsFilter.min = $('searchMinSeedsFilter').get('value');
searchSeedsFilter.max = $('searchMaxSeedsFilter').get('value');
searchSeedsFilter.min = $("searchMinSeedsFilter").get("value");
searchSeedsFilter.max = $("searchMaxSeedsFilter").get("value");
searchFilterChanged();
};
const searchSizeFilterChanged = function() {
searchSizeFilter.min = $('searchMinSizeFilter').get('value');
searchSizeFilter.minUnit = $('searchMinSizePrefix').get('value');
searchSizeFilter.max = $('searchMaxSizeFilter').get('value');
searchSizeFilter.maxUnit = $('searchMaxSizePrefix').get('value');
searchSizeFilter.min = $("searchMinSizeFilter").get("value");
searchSizeFilter.minUnit = $("searchMinSizePrefix").get("value");
searchSizeFilter.max = $("searchMaxSizeFilter").get("value");
searchSizeFilter.maxUnit = $("searchMaxSizePrefix").get("value");
searchFilterChanged();
};
const searchSizeFilterPrefixChanged = function() {
if ((Number($('searchMinSizeFilter').get('value')) !== 0) || (Number($('searchMaxSizeFilter').get('value')) !== 0))
if ((Number($("searchMinSizeFilter").get("value")) !== 0) || (Number($("searchMaxSizeFilter").get("value")) !== 0))
searchSizeFilterChanged();
};
const searchFilterChanged = function() {
searchResultsTable.updateTable();
$('numSearchResultsVisible').set('html', searchResultsTable.getFilteredAndSortedRows().length);
$("numSearchResultsVisible").set("html", searchResultsTable.getFilteredAndSortedRows().length);
};
const setupSearchTableEvents = function(enable) {
if (enable)
$$(".searchTableRow").each(function(target) {
target.addEventListener('dblclick', downloadSearchTorrent, false);
target.addEventListener("dblclick", downloadSearchTorrent, false);
});
else
$$(".searchTableRow").each(function(target) {
target.removeEventListener('dblclick', downloadSearchTorrent, false);
target.removeEventListener("dblclick", downloadSearchTorrent, false);
});
};
@@ -757,10 +757,10 @@ window.qBittorrent.Search = (function() {
const state = searchState.get(searchId);
const maxResults = 500;
const url = new URI('api/v2/search/results');
const url = new URI("api/v2/search/results");
new Request.JSON({
url: url,
method: 'get',
method: "get",
noCache: true,
data: {
id: searchId,
@@ -771,7 +771,7 @@ window.qBittorrent.Search = (function() {
if ((response.status === 400) || (response.status === 404)) {
// bad params. search id is invalid
resetSearchState(searchId);
updateStatusIconElement(searchId, 'QBT_TR(An error occurred during search...)QBT_TR[CONTEXT=SearchJobWidget]', 'images/error.svg');
updateStatusIconElement(searchId, "QBT_TR(An error occurred during search...)QBT_TR[CONTEXT=SearchJobWidget]", "images/error.svg");
}
else {
clearTimeout(state.loadResultsTimer);
@@ -779,13 +779,13 @@ window.qBittorrent.Search = (function() {
}
},
onSuccess: function(response) {
$('error_div').set('html', '');
$("error_div").set("html", "");
const state = searchState.get(searchId);
// check if user stopped the search prior to receiving the response
if (!state.running) {
clearTimeout(state.loadResultsTimer);
updateStatusIconElement(searchId, 'QBT_TR(Search aborted)QBT_TR[CONTEXT=SearchJobWidget]', 'images/task-reject.svg');
updateStatusIconElement(searchId, "QBT_TR(Search aborted)QBT_TR[CONTEXT=SearchJobWidget]", "images/task-reject.svg");
return;
}
@@ -823,8 +823,8 @@ window.qBittorrent.Search = (function() {
searchResultsTable.updateRowData(row);
}
$('numSearchResultsVisible').set('html', searchResultsTable.getFilteredAndSortedRows().length);
$('numSearchResultsTotal').set('html', searchResultsTable.getRowIds().length);
$("numSearchResultsVisible").set("html", searchResultsTable.getFilteredAndSortedRows().length);
$("numSearchResultsTotal").set("html", searchResultsTable.getRowIds().length);
searchResultsTable.updateTable();
searchResultsTable.altRow();
@@ -834,7 +834,7 @@ window.qBittorrent.Search = (function() {
if ((response.status === "Stopped") && (state.rowId >= response.total)) {
resetSearchState(searchId);
updateStatusIconElement(searchId, 'QBT_TR(Search has finished)QBT_TR[CONTEXT=SearchJobWidget]', 'images/task-complete.svg');
updateStatusIconElement(searchId, "QBT_TR(Search has finished)QBT_TR[CONTEXT=SearchJobWidget]", "images/task-complete.svg");
return;
}
}
@@ -851,7 +851,7 @@ window.qBittorrent.Search = (function() {
state.loadResultsTimer = loadSearchResultsData.delay(500, this, searchId);
};
new ClipboardJS('.copySearchDataToClipboard', {
new ClipboardJS(".copySearchDataToClipboard", {
text: function(trigger) {
switch (trigger.id) {
case "copySearchTorrentName":

View File

@@ -26,16 +26,16 @@
* exception statement from your version.
*/
'use strict';
"use strict";
MochaUI.extend({
addUpLimitSlider: function(hashes) {
if ($('uplimitSliderarea')) {
if ($("uplimitSliderarea")) {
// Get global upload limit
let maximum = 500;
new Request({
url: 'api/v2/transfer/uploadLimit',
method: 'get',
url: "api/v2/transfer/uploadLimit",
method: "get",
data: {},
onSuccess: function(data) {
if (data) {
@@ -52,42 +52,42 @@ MochaUI.extend({
}
// Get torrents upload limit
// And create slider
if (hashes[0] === 'global') {
if (hashes[0] === "global") {
let up_limit = maximum;
if (up_limit < 0)
up_limit = 0;
maximum = 10000;
new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
new Slider($("uplimitSliderarea"), $("uplimitSliderknob"), {
steps: maximum,
offset: 0,
initialStep: up_limit.round(),
onChange: function(pos) {
if (pos > 0) {
$('uplimitUpdatevalue').value = pos;
$('upLimitUnit').style.visibility = "visible";
$("uplimitUpdatevalue").value = pos;
$("upLimitUnit").style.visibility = "visible";
}
else {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
$("uplimitUpdatevalue").value = "∞";
$("upLimitUnit").style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (up_limit === 0) {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
$("uplimitUpdatevalue").value = "∞";
$("upLimitUnit").style.visibility = "hidden";
}
else {
$('uplimitUpdatevalue').value = up_limit.round();
$('upLimitUnit').style.visibility = "visible";
$("uplimitUpdatevalue").value = up_limit.round();
$("upLimitUnit").style.visibility = "visible";
}
}
else {
new Request.JSON({
url: 'api/v2/torrents/uploadLimit',
method: 'post',
url: "api/v2/torrents/uploadLimit",
method: "post",
data: {
hashes: hashes.join('|')
hashes: hashes.join("|")
},
onSuccess: function(data) {
if (data) {
@@ -99,29 +99,29 @@ MochaUI.extend({
}
if (up_limit < 0)
up_limit = 0;
new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
new Slider($("uplimitSliderarea"), $("uplimitSliderknob"), {
steps: maximum,
offset: 0,
initialStep: (up_limit / 1024.0).round(),
onChange: function(pos) {
if (pos > 0) {
$('uplimitUpdatevalue').value = pos;
$('upLimitUnit').style.visibility = "visible";
$("uplimitUpdatevalue").value = pos;
$("upLimitUnit").style.visibility = "visible";
}
else {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
$("uplimitUpdatevalue").value = "∞";
$("upLimitUnit").style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (up_limit === 0) {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
$("uplimitUpdatevalue").value = "∞";
$("upLimitUnit").style.visibility = "hidden";
}
else {
$('uplimitUpdatevalue').value = (up_limit / 1024.0).round();
$('upLimitUnit').style.visibility = "visible";
$("uplimitUpdatevalue").value = (up_limit / 1024.0).round();
$("upLimitUnit").style.visibility = "visible";
}
}
}
@@ -133,12 +133,12 @@ MochaUI.extend({
},
addDlLimitSlider: function(hashes) {
if ($('dllimitSliderarea')) {
if ($("dllimitSliderarea")) {
// Get global upload limit
let maximum = 500;
new Request({
url: 'api/v2/transfer/downloadLimit',
method: 'get',
url: "api/v2/transfer/downloadLimit",
method: "get",
data: {},
onSuccess: function(data) {
if (data) {
@@ -155,42 +155,42 @@ MochaUI.extend({
}
// Get torrents download limit
// And create slider
if (hashes[0] === 'global') {
if (hashes[0] === "global") {
let dl_limit = maximum;
if (dl_limit < 0)
dl_limit = 0;
maximum = 10000;
new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
new Slider($("dllimitSliderarea"), $("dllimitSliderknob"), {
steps: maximum,
offset: 0,
initialStep: dl_limit.round(),
onChange: function(pos) {
if (pos > 0) {
$('dllimitUpdatevalue').value = pos;
$('dlLimitUnit').style.visibility = "visible";
$("dllimitUpdatevalue").value = pos;
$("dlLimitUnit").style.visibility = "visible";
}
else {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
$("dllimitUpdatevalue").value = "∞";
$("dlLimitUnit").style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (dl_limit === 0) {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
$("dllimitUpdatevalue").value = "∞";
$("dlLimitUnit").style.visibility = "hidden";
}
else {
$('dllimitUpdatevalue').value = dl_limit.round();
$('dlLimitUnit').style.visibility = "visible";
$("dllimitUpdatevalue").value = dl_limit.round();
$("dlLimitUnit").style.visibility = "visible";
}
}
else {
new Request.JSON({
url: 'api/v2/torrents/downloadLimit',
method: 'post',
url: "api/v2/torrents/downloadLimit",
method: "post",
data: {
hashes: hashes.join('|')
hashes: hashes.join("|")
},
onSuccess: function(data) {
if (data) {
@@ -202,29 +202,29 @@ MochaUI.extend({
}
if (dl_limit < 0)
dl_limit = 0;
new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
new Slider($("dllimitSliderarea"), $("dllimitSliderknob"), {
steps: maximum,
offset: 0,
initialStep: (dl_limit / 1024.0).round(),
onChange: function(pos) {
if (pos > 0) {
$('dllimitUpdatevalue').value = pos;
$('dlLimitUnit').style.visibility = "visible";
$("dllimitUpdatevalue").value = pos;
$("dlLimitUnit").style.visibility = "visible";
}
else {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
$("dllimitUpdatevalue").value = "∞";
$("dlLimitUnit").style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (dl_limit === 0) {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
$("dllimitUpdatevalue").value = "∞";
$("dlLimitUnit").style.visibility = "hidden";
}
else {
$('dllimitUpdatevalue').value = (dl_limit / 1024.0).round();
$('dlLimitUnit').style.visibility = "visible";
$("dllimitUpdatevalue").value = (dl_limit / 1024.0).round();
$("dlLimitUnit").style.visibility = "visible";
}
}
}