From dc63bd5e64c03100520b21ac7eaf9fb486f2d964 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Sun, 28 Feb 2021 15:39:19 +0800 Subject: [PATCH] feat: set q parameter when searching This makes refershes work. --- static/bundle.js | 12 ++++++++++-- website/bundle.js | 10 +++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/static/bundle.js b/static/bundle.js index 2567de3..2e6ce06 100644 --- a/static/bundle.js +++ b/static/bundle.js @@ -1,7 +1,15 @@ +function setQueryParam(s) { + let params = URLSearchParams(window.location.search) + params.set("q", s); + var newRelativePathQuery = window.location.pathname + '?' + params.toString(); + history.pushState(null, '', newRelativePathQuery); +} + function searchTriggered() { let searchbox = document.getElementById("searchbox"); let query = searchbox.value - searchFor(query); + searchFor(query) + setQueryParam(query) passQueryToResultpage(query) } @@ -31,4 +39,4 @@ function passQueryToResultpage(query) { type: "query", query: query }, '*'); -} \ No newline at end of file +} diff --git a/website/bundle.js b/website/bundle.js index 9f74c23..1b4b667 100644 --- a/website/bundle.js +++ b/website/bundle.js @@ -186,9 +186,17 @@ async function checkIfIpfsGateway(gatewayURL) { } } +function setQueryParam(s) { + let params = URLSearchParams(window.location.search) + params.set("q", s); + var newRelativePathQuery = window.location.pathname + '?' + params.toString(); + history.pushState(null, '', newRelativePathQuery); +} + function searchTriggered() { let searchbox = document.getElementById("searchbox"); let querytokens = searchbox.value.split(" "); + passQueryToResultpage(searchbox.value) querytokens = querytokens.map(querytoken => { return stemmer(querytoken); }); @@ -610,4 +618,4 @@ async function getDocumentForId(docid) { let doc = inxFetcher.combinedIndex.get(docid); doc["id"] = docid; return inxFetcher.combinedIndex.get(docid); -} \ No newline at end of file +}