From 7e3481f0f104bae1b99adf56088064ffa391e132 Mon Sep 17 00:00:00 2001 From: buttle Date: Wed, 24 Nov 2021 13:14:36 +0100 Subject: [PATCH] adds local site data search --- src/components/search.vue | 15 ++++++++++++--- src/store.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/components/search.vue b/src/components/search.vue index 3cba903..f885e8e 100644 --- a/src/components/search.vue +++ b/src/components/search.vue @@ -27,7 +27,7 @@ This file is part of ArciveList. diff --git a/src/store.js b/src/store.js index 318f8df..434de07 100644 --- a/src/store.js +++ b/src/store.js @@ -30,6 +30,7 @@ const store = new Vuex.Store({ state.page_count = state.page_count +1 }, setFilteredSites(state, filtered_site_ids) { + console.log('filtered_site_ids') console.log(filtered_site_ids) var sites = [] for (const [site_id, weight] of Object.entries(filtered_site_ids)) { @@ -61,6 +62,34 @@ const store = new Vuex.Store({ getPageCount: state => { return state.page_count }, + searchLocalSiteData: state => { + var result = {} + if (state.search_text==="") { + return result + } + for (let site in state.sites) { + var weight = 0 + var found = state.sites[site].summary.toLowerCase().search(state.search_text.toLowerCase()) + if (found != -1) { + weight = weight +1 + } + var found = state.sites[site].collection.toLowerCase().search(state.search_text.toLowerCase()) + if (found != -1) { + weight = weight +1 + } + var found = state.sites[site].currator.toLowerCase().search(state.search_text.toLowerCase()) + if (found != -1) { + weight = weight +1 + } + if (weight > 0) { + var id = state.sites[site].id + result[id] = weight + } + } + console.log('load search') + console.log(result) + return result + }, } })