Skip to content

Commit

Permalink
webapp: add ctrl-maj-f to search selection
Browse files Browse the repository at this point in the history
  • Loading branch information
aiooss-anssi committed Jul 15, 2024
1 parent dc04829 commit 6568dbf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions webapp/static/js/flowdisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class FlowDisplay {
this.tickLength = Number(appData.tickLength)

// On V key, switch view
document.addEventListener('keydown', e => {
if (e.target.tagName !== 'INPUT' && !e.ctrlKey && !e.altKey && e.code === 'KeyV') {
document.addEventListener('keyup', e => {
if (e.target.tagName !== 'INPUT' && !e.ctrlKey && !e.shiftKey && !e.altKey && e.code === 'KeyV') {
if (document.getElementById('display-raw-hex-tab').classList.contains('active')) {
document.getElementById('display-raw-utf8-tab').click()
} else {
Expand Down
14 changes: 14 additions & 0 deletions webapp/static/js/flowlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ class FlowList {
this.update()
})

// On CTRL-MAJ-F key, search selection
document.addEventListener('keyup', e => {
if (e.target.tagName !== 'INPUT' && e.ctrlKey && e.shiftKey && !e.altKey && e.code === 'KeyF') {
const sel = window.getSelection().toString()
if (sel) {
const url = new URL(document.location)
url.searchParams.set('search', sel)
window.history.pushState(null, '', url.href)
this.update()
}
e.preventDefault()
}
})

// On tags filter change, update URL then update flows list
document.getElementById('filter-tag').addEventListener('click', e => {
const tag = e.target.closest('a')?.dataset.tag
Expand Down
1 change: 1 addition & 0 deletions webapp/templates/index.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
</p>
<ul class="list-unstyled">
<li class="mb-1">Use <kbd>Left</kbd>, <kbd>Right</kbd> keys to quickly navigate flows.</li>
<li class="mb-1">Use <kbd>Ctrl+Maj+F</kbd> key to search current selection.</li>
<li class="mb-1">Use <kbd>V</kbd> key to quickly switch raw data view.</li>
<li class="mb-1">Use <kbd>T</kbd> key to switch color theme.</li>
</ul>
Expand Down

0 comments on commit 6568dbf

Please sign in to comment.