mirror of
https://github.com/osmarks/meme-search-engine.git
synced 2024-11-10 22:09:54 +00:00
read from query strings
This commit is contained in:
parent
8abe384cd1
commit
c235217751
@ -86,7 +86,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
<div class="ctrlbar">
|
<div class="ctrlbar">
|
||||||
<input type="search" placeholder="Text Query" bind:value={query} on:keydown={handleKey} on:focus={newTextQuery}>
|
<input type="search" placeholder="Text Query" on:keydown={handleKey} on:focus={newTextQuery}>
|
||||||
<button on:click={pickFile}>Image Query</button>
|
<button on:click={pickFile}>Image Query</button>
|
||||||
<button on:click={runSearch} style="margin-left: auto">Search</button>
|
<button on:click={runSearch} style="margin-left: auto">Search</button>
|
||||||
</div>
|
</div>
|
||||||
@ -120,8 +120,8 @@
|
|||||||
let queryTerms = []
|
let queryTerms = []
|
||||||
|
|
||||||
const focusEl = el => el.focus()
|
const focusEl = el => el.focus()
|
||||||
const newTextQuery = () => {
|
const newTextQuery = (content="") => {
|
||||||
queryTerms.push({ type: "text", weight: 1, sign: "+", text: "" })
|
queryTerms.push({ type: "text", weight: 1, sign: "+", text: content })
|
||||||
queryTerms = queryTerms
|
queryTerms = queryTerms
|
||||||
}
|
}
|
||||||
const removeTerm = term => {
|
const removeTerm = term => {
|
||||||
@ -149,7 +149,6 @@
|
|||||||
let resultPromise
|
let resultPromise
|
||||||
let results
|
let results
|
||||||
let displayedResults = []
|
let displayedResults = []
|
||||||
let query = ""
|
|
||||||
const runSearch = async () => {
|
const runSearch = async () => {
|
||||||
if (!resultPromise) {
|
if (!resultPromise) {
|
||||||
let args = {}
|
let args = {}
|
||||||
@ -214,4 +213,10 @@
|
|||||||
pendingImageLoads -= 1
|
pendingImageLoads -= 1
|
||||||
redrawGrid()
|
redrawGrid()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const queryStringParams = new URLSearchParams(window.location.search)
|
||||||
|
if (queryStringParams.get("q")) {
|
||||||
|
newTextQuery(queryStringParams.get("q"))
|
||||||
|
runSearch()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user