fuzzy search

This commit is contained in:
azivner 2017-09-10 11:50:17 -04:00
parent 1f19c9cd0d
commit 19561191f6
3 changed files with 31 additions and 2 deletions

View file

@ -93,7 +93,7 @@
</form>
</div>
<div id="jumpToNoteDialog" title="Jumpt to note" style="display: none;">
<div id="jumpToNoteDialog" title="Jump to note" style="display: none;">
<form id="jumpToNoteForm">
<div class="form-group">
<label for="jumpToNoteAutocomplete">Jump to note</label>
@ -139,6 +139,8 @@
<script src="stat/lib/jquery.ui-contextmenu.min.js"></script>
<script src="stat/lib/fuse.min.js"></script>
<!-- https://github.com/ricmoo/aes-js -->
<script src="stat/lib/aes.js"></script>
<!-- https://github.com/emn178/js-sha256 -->

View file

@ -48,3 +48,21 @@ $(window).on('beforeunload', function(){
// this sends the request asynchronously and doesn't wait for result
saveNoteIfChanged();
});
// Overrides the default autocomplete filter function to search for matched on atleast 1 word in each of the input term's words
$.ui.autocomplete.filter = function (array, terms) {
const options = {
shouldSort: true,
threshold: 0.6,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: [
"value"
]
};
const fuse = new Fuse(array, options); // "list" is the item array
return fuse.search(terms);
};

9
static/lib/fuse.min.js vendored Normal file

File diff suppressed because one or more lines are too long