mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
parent
c65c40a5cb
commit
b829a0c687
@ -1268,12 +1268,9 @@ const TorrentsTable = new Class({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterTerms) {
|
if ((filterTerms !== undefined) && (filterTerms !== null)
|
||||||
for (let i = 0; i < filterTerms.length; ++i) {
|
&& (filterTerms.length > 0) && !containsAllTerms(name, filterTerms))
|
||||||
if (name.indexOf(filterTerms[i]) === -1)
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -1517,16 +1514,6 @@ const SearchResultsTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getFilteredAndSortedRows: function() {
|
getFilteredAndSortedRows: function() {
|
||||||
const containsAll = function(text, searchTerms) {
|
|
||||||
text = text.toLowerCase();
|
|
||||||
for (let i = 0; i < searchTerms.length; ++i) {
|
|
||||||
if (text.indexOf(searchTerms[i].toLowerCase()) === -1)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getSizeFilters = function() {
|
const getSizeFilters = function() {
|
||||||
let minSize = (searchSizeFilter.min > 0.00) ? (searchSizeFilter.min * Math.pow(1024, searchSizeFilter.minUnit)) : 0.00;
|
let minSize = (searchSizeFilter.min > 0.00) ? (searchSizeFilter.min * Math.pow(1024, searchSizeFilter.minUnit)) : 0.00;
|
||||||
let maxSize = (searchSizeFilter.max > 0.00) ? (searchSizeFilter.max * Math.pow(1024, searchSizeFilter.maxUnit)) : 0.00;
|
let maxSize = (searchSizeFilter.max > 0.00) ? (searchSizeFilter.max * Math.pow(1024, searchSizeFilter.maxUnit)) : 0.00;
|
||||||
@ -1571,8 +1558,8 @@ const SearchResultsTable = new Class({
|
|||||||
for (let i = 0; i < rows.length; ++i) {
|
for (let i = 0; i < rows.length; ++i) {
|
||||||
const row = rows[i];
|
const row = rows[i];
|
||||||
|
|
||||||
if (searchInTorrentName && !containsAll(row.full_data.fileName, searchTerms)) continue;
|
if (searchInTorrentName && !containsAllTerms(row.full_data.fileName, searchTerms)) continue;
|
||||||
if ((filterTerms.length > 0) && !containsAll(row.full_data.fileName, filterTerms)) continue;
|
if ((filterTerms.length > 0) && !containsAllTerms(row.full_data.fileName, filterTerms)) continue;
|
||||||
if ((sizeFilters.min > 0.00) && (row.full_data.fileSize < sizeFilters.min)) continue;
|
if ((sizeFilters.min > 0.00) && (row.full_data.fileSize < sizeFilters.min)) continue;
|
||||||
if ((sizeFilters.max > 0.00) && (row.full_data.fileSize > sizeFilters.max)) continue;
|
if ((sizeFilters.max > 0.00) && (row.full_data.fileSize > sizeFilters.max)) continue;
|
||||||
if ((seedsFilters.min > 0) && (row.full_data.nbSeeders < seedsFilters.min)) continue;
|
if ((seedsFilters.min > 0) && (row.full_data.nbSeeders < seedsFilters.min)) continue;
|
||||||
@ -1907,12 +1894,7 @@ const TorrentFilesTable = new Class({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lowercaseName = node.name.toLowerCase();
|
if (containsAllTerms(node.name, filterTerms)) {
|
||||||
const matchesFilter = filterTerms.every(function(term) {
|
|
||||||
return (lowercaseName.indexOf(term) !== -1);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (matchesFilter) {
|
|
||||||
const row = this.getRow(node);
|
const row = this.getRow(node);
|
||||||
filteredRows.push(row);
|
filteredRows.push(row);
|
||||||
return true;
|
return true;
|
||||||
|
@ -167,3 +167,37 @@ function toFixedPointString(number, digits) {
|
|||||||
const power = Math.pow(10, digits);
|
const power = Math.pow(10, digits);
|
||||||
return (Math.floor(power * number) / power).toFixed(digits);
|
return (Math.floor(power * number) / power).toFixed(digits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {String} text the text to search
|
||||||
|
* @param {Array<String>} terms terms to search for within the text
|
||||||
|
* @returns {Boolean} true if all terms match the text, false otherwise
|
||||||
|
*/
|
||||||
|
function containsAllTerms(text, terms) {
|
||||||
|
const textToSearch = text.toLowerCase();
|
||||||
|
for (let i = 0; i < terms.length; ++i) {
|
||||||
|
const term = terms[i].trim().toLowerCase();
|
||||||
|
if ((term[0] === '-')) {
|
||||||
|
// ignore lonely -
|
||||||
|
if (term.length === 1)
|
||||||
|
continue;
|
||||||
|
// disallow any text after -
|
||||||
|
if (textToSearch.indexOf(term.substring(1)) !== -1)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if ((term[0] === '+')) {
|
||||||
|
// ignore lonely +
|
||||||
|
if (term.length === 1)
|
||||||
|
continue;
|
||||||
|
// require any text after +
|
||||||
|
if (textToSearch.indexOf(term.substring(1)) === -1)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (textToSearch.indexOf(term) === -1){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user