mirror of
https://github.com/alvierahman90/gronk.git
synced 2024-12-23 04:21:58 +00:00
Add a max no. results input
This commit is contained in:
parent
1386679c49
commit
7bda685927
@ -9,11 +9,12 @@ const fuse = new Fuse(data, {
|
||||
})
|
||||
|
||||
const searchBar = document.getElementById('search')
|
||||
const resultsMax = document.getElementById('resultsMax')
|
||||
const results = document.getElementById('results')
|
||||
|
||||
function callback() {
|
||||
results.innerHTML = ''
|
||||
fuse.search(searchBar.value).slice(0,15).forEach(r => {
|
||||
fuse.search(searchBar.value).slice(0, parseInt(resultsMax.value)).forEach(r => {
|
||||
wrapper = document.createElement('div')
|
||||
wrapper.className = "article"
|
||||
|
||||
@ -64,4 +65,5 @@ function callback() {
|
||||
}
|
||||
|
||||
searchBar.addEventListener('keyup', callback)
|
||||
resultsMax.addEventListener('keyup', callback)
|
||||
callback()
|
||||
|
12
styles.css
12
styles.css
@ -73,13 +73,19 @@ blockquote * {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#search {
|
||||
#searchWrapper > input {
|
||||
padding: 1em;
|
||||
margin: 1em 0 1em 0;
|
||||
margin: 1em 0.5em 1em 0.5em;
|
||||
font-size: 1em;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#searchWrapper {
|
||||
display: flex
|
||||
}
|
||||
|
||||
#search { flex-grow: 9 }
|
||||
|
||||
#results {
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
@ -12,11 +12,14 @@ These are my personal notes. Correctness is not guaranteed.
|
||||
Browse <a href="/notes">here</a> or by tag <a href="/.tags">here</a>.
|
||||
</p>
|
||||
|
||||
<div id="searchWrapper">
|
||||
<input placeholder="Search" id="search">
|
||||
<input type="number" id="resultsMax" min="0" value="5">
|
||||
</div>
|
||||
<div id="results">
|
||||
</div>
|
||||
|
||||
<p style="font-size: 0.7em;"> page generated by <a href="https://github.com/alvierahman90/notes2web">notes2web</a></p>
|
||||
<p class="smallText"> page generated by <a href="https://github.com/alvierahman90/notes2web">notes2web</a></p>
|
||||
|
||||
<script src="/fuse.js"> </script>
|
||||
<script> const data = $data$ </script>
|
||||
|
Loading…
Reference in New Issue
Block a user