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

@@ -47,4 +47,22 @@ $(window).on('beforeunload', function(){
// this makes sure that when user e.g. reloads the page or navigates away from the page, the note's content is saved
// 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);
};