Added fuzzy search
This commit is contained in:
parent
b05b403e76
commit
457ffea197
19
index.html
19
index.html
@ -231,6 +231,7 @@
|
|||||||
<div id="current_data"></div>
|
<div id="current_data"></div>
|
||||||
</section>
|
</section>
|
||||||
<script src="components.js"></script>
|
<script src="components.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6"></script>
|
||||||
<script id="floGlobals">
|
<script id="floGlobals">
|
||||||
/* Constants for FLO blockchain operations !!Make sure to add this at begining!! */
|
/* Constants for FLO blockchain operations !!Make sure to add this at begining!! */
|
||||||
const floGlobals = {
|
const floGlobals = {
|
||||||
@ -985,15 +986,19 @@
|
|||||||
hidePopup()
|
hidePopup()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
document.getElementById('article_list__search').addEventListener('input', function(e) {
|
document.getElementById('article_list__search').addEventListener('input', function(e) {
|
||||||
const articles = floGlobals.appObjects["ContentCollaboration"]["ArticleLists"]
|
const allArticles = floGlobals.appObjects["ContentCollaboration"]["ArticleLists"]
|
||||||
const filteredArticles = {}
|
const filteredArticles = {}
|
||||||
for (let articleId in articles){
|
fuse.search(this.value.trim()).forEach(item => {
|
||||||
if(articles[articleId].toLowerCase().includes(this.value.trim().toLowerCase())){
|
filteredArticles[item.item.replace(/ /, '')] = item.item
|
||||||
filteredArticles[articleId] = articles[articleId]
|
})
|
||||||
}
|
if(this.value.trim() !== ''){
|
||||||
|
renderAllArticlesPreview(filteredArticles)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
renderAllArticlesPreview(allArticles)
|
||||||
}
|
}
|
||||||
renderAllArticlesPreview(filteredArticles)
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<script id="init_lib">
|
<script id="init_lib">
|
||||||
@ -10091,6 +10096,7 @@
|
|||||||
reactor.addEventListener("startUpErrorLog", log => console.error(log))
|
reactor.addEventListener("startUpErrorLog", log => console.error(log))
|
||||||
</script>
|
</script>
|
||||||
<script id="onLoadStartUp">
|
<script id="onLoadStartUp">
|
||||||
|
let fuse
|
||||||
function onLoadStartUp() {
|
function onLoadStartUp() {
|
||||||
showLoader()
|
showLoader()
|
||||||
//floDapps.addStartUpFunction('Sample', Promised Function)
|
//floDapps.addStartUpFunction('Sample', Promised Function)
|
||||||
@ -10104,6 +10110,7 @@
|
|||||||
cloudArticleApp.refreshMasterObject().then(result => {
|
cloudArticleApp.refreshMasterObject().then(result => {
|
||||||
cloudArticleApp.retrieveLatestContent(true);
|
cloudArticleApp.retrieveLatestContent(true);
|
||||||
buildAdminUI();
|
buildAdminUI();
|
||||||
|
fuse = new Fuse(Object.values(floGlobals.appObjects["ContentCollaboration"]["ArticleLists"]), {threshold: 0.3})
|
||||||
}).catch(error => console.error(error))
|
}).catch(error => console.error(error))
|
||||||
}).catch(error => console.error(error))
|
}).catch(error => console.error(error))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user