mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
WebUI: enforce string quotes coding style
This commit is contained in:
parent
6d073771ca
commit
cb90b6769c
58 changed files with 3522 additions and 3514 deletions
|
@ -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":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue