Add regex toggle for WebUI torrent filtering

PR #20566.
This commit is contained in:
HamletDuFromage 2024-03-24 06:44:57 +01:00 committed by GitHub
parent ce013f132f
commit 5c67c5a77d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 52 additions and 4 deletions

View file

@ -1437,9 +1437,16 @@ window.qBittorrent.DynamicTable = (function() {
}
}
if ((filterTerms !== undefined) && (filterTerms !== null)
&& (filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(name, filterTerms))
return false;
if ((filterTerms !== undefined) && (filterTerms !== null)) {
if (filterTerms instanceof RegExp) {
if (!filterTerms.test(name))
return false;
}
else {
if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(name, filterTerms))
return false;
}
}
return true;
},
@ -1471,8 +1478,11 @@ window.qBittorrent.DynamicTable = (function() {
const filteredRows = [];
const rows = this.rows.getValues();
const useRegex = $('torrentsFilterRegexBox').checked;
const filterText = $('torrentsFilterInput').value.trim().toLowerCase();
const filterTerms = (filterText.length > 0) ? filterText.split(" ") : null;
const filterTerms = (filterText.length > 0)
? (useRegex ? new RegExp(filterText) : filterText.split(" "))
: null;
for (let i = 0; i < rows.length; ++i) {
if (this.applyFilter(rows[i], selected_filter, selected_category, selectedTag, selectedTracker, filterTerms)) {