Skip to content

Commit

Permalink
Fix filtering again
Browse files Browse the repository at this point in the history
  • Loading branch information
Heath123 committed Apr 13, 2021
1 parent 888ae16 commit 9cc4377
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions html/mainPage/js/filteringLogic.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
exports.packetFilteredByFilterBox = function (packet, filter, hiddenPackets, inverseFiltering, regexFilter) {
exports.packetFilteredByFilterBox = function (packet, filter, hiddenPackets, inverseFiltering, regexFilter,
sharedVars) {
if (hiddenPackets[packet.direction].includes(packet.meta.name)) {
return true
}

if (filter === '') {
if (sharedVars.lastFilter === '') {
return false
}

Expand All @@ -14,6 +15,7 @@ exports.packetFilteredByFilterBox = function (packet, filter, hiddenPackets, inv
filter = new RegExp(sharedVars.lastFilter)
} catch (err) {
// TODO: handle
console.error(err)
filter = new RegExp("")
}
}
Expand Down
7 changes: 4 additions & 3 deletions html/mainPage/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ function updateFiltering () {
regex = new RegExp(sharedVars.lastFilter)
} catch (err) {
// TODO: handle
console.error(err)
regex = new RegExp("")
}
}
sharedVars.allPacketsHTML.forEach(function (item, index, array) {
if (sharedVars.lastFilter === '' ||
!filteringLogic.packetFilteredByFilterBox(sharedVars.allPackets[index],
if (!filteringLogic.packetFilteredByFilterBox(sharedVars.allPackets[index],
regexFilter ? regex : sharedVars.lastFilter,
sharedVars.hiddenPackets,
inverseFiltering,
regexFilter)) {
regexFilter,
sharedVars)) {
// If it's hidden, show it
array[index] = [item[0].replace('filter-hidden', 'filter-shown')]
} else {
Expand Down
3 changes: 2 additions & 1 deletion html/mainPage/js/packetDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function formatTime (ms) {
exports.addPacketToDOM = function (packet) {
const isHidden = filteringLogic.packetFilteredByFilterBox(packet, sharedVars.lastFilter, sharedVars.hiddenPackets,
// TODO: cache these?
sharedVars.settings.getSetting('inverseFiltering'), sharedVars.settings.getSetting('regexFilter'))
sharedVars.settings.getSetting('inverseFiltering'), sharedVars.settings.getSetting('regexFilter'),
sharedVars)
sharedVars.allPacketsHTML.push([
`<li id="packet${packet.uid}" onclick="packetClick(${packet.uid})" class="packet ${packet.direction} ${isHidden ? 'filter-hidden' : 'filter-shown'}">
<div class="main-data">
Expand Down

0 comments on commit 9cc4377

Please sign in to comment.