added the autosuggest to the results page. Fixed up a few issues.

This commit is contained in:
Alexandra
2024-10-24 06:09:47 -06:00
parent ad8c5a2cbf
commit 64bc7eda04
2 changed files with 7 additions and 2 deletions

View File

@@ -29,9 +29,11 @@ _ / / / _ /_/ /_ / _ / / __/ / / / /_
</pre>
</a>
<input type="hidden" name="s" id="searchSettings">
<input type="text" class="w-50 form-control bg-dark text-white ml-2" name="q" value="<%= query %>"">
<input id="search" type="text" class="w-50 form-control bg-dark text-white ml-2" name="q" value="<%= query %>"">
<button type="submit" class="btn btn-secondary ml-2">Search</button>
</div>
<ul class="SuggestionList col-sm-12" id="suggestionList" style="width: 50%;left: 195px;"></ul>
</div>
<p class="m-2">Found <%= results.items.length %> result<%= results.items.length != 1 ? 's': '' %> in <%= results.elapsed %> seconds. <%= indexing ? "Indexing in progress, if the list is missing something please try reloading in a few minutes" : "" %></p>
</form>

View File

@@ -157,6 +157,7 @@
listElem.addEventListener('click', (e) => {
searchElem.value = listElem.innerText
suggestionList.style.display = 'none'
selectedSuggestion = null
totalSuggestions = 0
})
listElem.addEventListener('mouseover', (e) => {
@@ -187,7 +188,7 @@
searchElem.addEventListener('keyup', function (e) {
if(e.key === 'Escape'){
return
}
}
if(e.key === 'ArrowUp'){
if(!totalSuggestions) return
if(typeof selectedSuggestion != 'number'){
@@ -263,6 +264,8 @@
clearSelects()
document.getElementById('search').value = document.getElementById(suggestId).innerText
selectedSuggestion = null
suggestionList.style.display = 'none'
totalSugges tions = 0
}
function clearSelects(){
let suggestionList = document.getElementById('suggestionList')