Skip to content

Commit

Permalink
Fix filtering options (fixes #23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Heath123 committed Apr 13, 2021
1 parent 4906787 commit 888ae16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions html/mainPage/js/filteringLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ exports.packetFilteredByFilterBox = function (packet, filter, hiddenPackets, inv

const comparisonString = packet.hexIdString + ' ' + packet.meta.name + ' ' + JSON.stringify(packet.data)

if (regexFilter && typeof filter === 'string') {
try {
filter = new RegExp(sharedVars.lastFilter)
} catch (err) {
// TODO: handle
filter = new RegExp("")
}
}

let result
if (regexFilter) {
result = filter.test(comparisonString)
Expand Down
4 changes: 3 additions & 1 deletion html/mainPage/js/packetDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ function formatTime (ms) {
}

exports.addPacketToDOM = function (packet) {
const isHidden = filteringLogic.packetFilteredByFilterBox(packet, sharedVars.lastFilter, sharedVars.hiddenPackets)
const isHidden = filteringLogic.packetFilteredByFilterBox(packet, sharedVars.lastFilter, sharedVars.hiddenPackets,
// TODO: cache these?
sharedVars.settings.getSetting('inverseFiltering'), sharedVars.settings.getSetting('regexFilter'))
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 888ae16

Please sign in to comment.