mirror of
https://github.com/He4eT/tabswitcher.git
synced 2026-05-04 17:07:23 +00:00
pages/search: enable fuzzy search
This commit is contained in:
parent
499bd4dceb
commit
b7de8393a7
2 changed files with 7 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import * as labels from './labels.js'
|
import * as labels from './labels.js'
|
||||||
|
const fuzzysort = window.fuzzysort
|
||||||
|
|
||||||
export const init = ({
|
export const init = ({
|
||||||
tabs: browserTabs,
|
tabs: browserTabs,
|
||||||
|
|
@ -42,17 +43,15 @@ export const init = ({
|
||||||
browserTabs.query({ currentWindow: true, active: false })
|
browserTabs.query({ currentWindow: true, active: false })
|
||||||
.then(shapeTabs)
|
.then(shapeTabs)
|
||||||
.then((tabs) => tabs.reverse())
|
.then((tabs) => tabs.reverse())
|
||||||
.then((tabs) => {
|
.then((tabs) => void (state.tabs = tabs))
|
||||||
void (state.tabs = tabs)
|
|
||||||
void (state.results = tabs)
|
|
||||||
})
|
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
const updateResults = () => {
|
const updateResults = () => {
|
||||||
state.results = state.query.length === 0
|
state.results = fuzzysort.go(state.query, state.tabs, {
|
||||||
? state.tabs
|
keys: ['label', 'title', 'url'],
|
||||||
: []
|
all: true,
|
||||||
|
}).map(({obj}) => obj)
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</main>
|
</main>
|
||||||
|
<script type="text/javascript" src="./vendor/fuzzysort.js"></script>
|
||||||
<script type='module' src='./search.js'></script>
|
<script type='module' src='./search.js'></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue