Skip to content

Commit

Permalink
Apply @Chocobo1's suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
HamletDuFromage committed Mar 18, 2024
1 parent af261e6 commit f1a5f57
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/webui/www/private/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -413,27 +413,27 @@ a.propButton img {
display: none;
}

#torrentsFilterRegexBox+label {
#torrentsFilterRegexBox + label {
background-image: url("../images/regex.svg");
background-position: center;
background-repeat: no-repeat;
background-size: 1.5em;
border-radius: 4px;
border: 1px solid var(--color-border-default);
border-radius: 4px;
display: inline-block;
height: 26px;
margin-bottom: -9px;
width: 26px;
}

#torrentsFilterRegexBox:checked+label {
#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-radius: 4px;
border: 1px solid var(--color-accent-blue);
border-radius: 4px;
display: inline-block;
height: 26px;
margin-bottom: -9px;
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ <h1 class="applicationTitle">qBittorrent Web User Interface <span class="version
<div id="torrentsFilterToolbar">
<input type="text" id="torrentsFilterInput" placeholder="QBT_TR(Filter torrent list...)QBT_TR[CONTEXT=MainWindow]" autocorrect="off" autocapitalize="none" />
<input type="checkbox" id="torrentsFilterRegexBox">
<label for="torrentsFilterRegexBox">
<label for="torrentsFilterRegexBox"></label>
</div>
</div>
</div>
Expand Down
6 changes: 1 addition & 5 deletions src/webui/www/private/scripts/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1461,11 +1461,7 @@ window.addEventListener("DOMContentLoaded", function() {
}, window.qBittorrent.Misc.FILTER_INPUT_DELAY);
});
$('torrentsFilterRegexBox').addEvent('change', () => {
clearTimeout(torrentsFilterInputTimer);
torrentsFilterInputTimer = setTimeout(() => {
torrentsFilterInputTimer = -1;
torrentsTable.updateTable();
}, window.qBittorrent.Misc.FILTER_INPUT_DELAY);
torrentsTable.updateTable();
});

$('transfersTabLink').addEvent('click', showTransfersTab);
Expand Down
21 changes: 9 additions & 12 deletions src/webui/www/private/scripts/dynamicTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1438,15 +1438,16 @@ window.qBittorrent.DynamicTable = (function() {
}

if ((filterTerms !== undefined) && (filterTerms !== null)) {
if (Array.isArray(filterTerms)) {
if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(name, filterTerms))
if (filterTerms instanceof RegExp) {
if (!filterTerms.test(name))
return false;
}
else { // regex search
if (!filterTerms.test(name))
else {
if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(name, filterTerms))
return false;
}
}

return true;
},

Expand Down Expand Up @@ -1477,15 +1478,11 @@ window.qBittorrent.DynamicTable = (function() {
const filteredRows = [];

const rows = this.rows.getValues();
const torrentsFilterRegex = $('torrentsFilterRegexBox').checked;
const useRegex = $('torrentsFilterRegexBox').checked;
const filterText = $('torrentsFilterInput').value.trim().toLowerCase();
let filterTerms;
if (torrentsFilterRegex) {
filterTerms = (filterText.length > 0) ? new RegExp(filterText) : null;
}
else {
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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/webui.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@
<file>private/images/queued.svg</file>
<file>private/images/ratio.svg</file>
<file>private/images/reannounce.svg</file>
<file>private/images/regex.svg</file>
<file>private/images/set-location.svg</file>
<file>private/images/slider-area.gif</file>
<file>private/images/slow.svg</file>
Expand All @@ -358,7 +359,6 @@
<file>private/images/torrent-start.svg</file>
<file>private/images/torrent-stop.svg</file>
<file>private/images/trackers.svg</file>
<file>private/images/regex.svg</file>
<file>private/images/upload.svg</file>
<file>private/images/view-categories.svg</file>
<file>private/images/view-refresh.svg</file>
Expand Down

0 comments on commit f1a5f57

Please sign in to comment.