mirror of
https://github.com/alexankitty/Myrient-Search-Engine.git
synced 2026-01-15 16:33:15 -03:00
added the autosuggest to the results page. Fixed up a few issues.
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user