diff --git a/src/webui/www/private/css/style.css b/src/webui/www/private/css/style.css index 4387c43a2..0805fef60 100644 --- a/src/webui/www/private/css/style.css +++ b/src/webui/www/private/css/style.css @@ -409,6 +409,37 @@ a.propButton img { padding: 4px 4px 4px 25px; } +#torrentsFilterRegexBox { + display: none; +} + +#torrentsFilterRegexBox + label { + background-image: url("../images/regex.svg"); + background-position: center; + background-repeat: no-repeat; + background-size: 1.5em; + border: 1px solid var(--color-border-default); + border-radius: 4px; + display: inline-block; + height: 26px; + margin-bottom: -9px; + width: 26px; +} + +#torrentsFilterRegexBox:checked + label { + background-color: var(--color-background-default); + background-image: url("../images/regex.svg"); + background-position: center; + background-repeat: no-repeat; + background-size: 1.5em; + border: 1px solid var(--color-accent-blue); + border-radius: 4px; + display: inline-block; + height: 26px; + margin-bottom: -9px; + width: 26px; +} + #torrentFilesFilterToolbar { float: right; margin-right: 30px; diff --git a/src/webui/www/private/images/regex.svg b/src/webui/www/private/images/regex.svg new file mode 100644 index 000000000..323c23c50 --- /dev/null +++ b/src/webui/www/private/images/regex.svg @@ -0,0 +1 @@ + diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index 8ef335539..9db96fbca 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -130,6 +130,8 @@
+ +
diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 0abe49705..93039ab20 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -1460,6 +1460,9 @@ window.addEventListener("DOMContentLoaded", function() { torrentsTable.updateTable(); }, window.qBittorrent.Misc.FILTER_INPUT_DELAY); }); + $('torrentsFilterRegexBox').addEvent('change', () => { + torrentsTable.updateTable(); + }); $('transfersTabLink').addEvent('click', showTransfersTab); $('searchTabLink').addEvent('click', showSearchTab); diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index ce0e7d2eb..7f63b8295 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -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)) { diff --git a/src/webui/www/webui.qrc b/src/webui/www/webui.qrc index f3cad5044..1670730da 100644 --- a/src/webui/www/webui.qrc +++ b/src/webui/www/webui.qrc @@ -338,6 +338,7 @@ private/images/queued.svg private/images/ratio.svg private/images/reannounce.svg + private/images/regex.svg private/images/set-location.svg private/images/slider-area.gif private/images/slow.svg