mirror of
https://github.com/ivabus/www
synced 2024-11-25 07:05:06 +03:00
display results empty
This commit is contained in:
parent
fedd75155b
commit
1f77245138
2 changed files with 21 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<hr>
|
||||
<section>
|
||||
<section id="noResult" class="no-results">
|
||||
<div class="container black-bg">
|
||||
<div class="row">
|
||||
<div class="col two-boxes-up two-boxes-down">
|
||||
|
@ -10,3 +10,12 @@
|
|||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
|
||||
<style>
|
||||
.no-results {
|
||||
display: none;
|
||||
}
|
||||
.no-results.show {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -24,6 +24,7 @@
|
|||
{{- partial "package-thumbnail.html" .}}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{- partial "no-results-found.html" }}
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
@ -120,6 +121,7 @@
|
|||
|
||||
const onSearch = debounce(() => {
|
||||
const searchInput = document.getElementById('searchTermDesktop');
|
||||
const noResult = document.getElementById('noResult');
|
||||
if (searchInput.value) {
|
||||
const term = searchInput.value;
|
||||
const packages = getPackageThumbs();
|
||||
|
@ -130,16 +132,25 @@
|
|||
});
|
||||
const grid = document.getElementById('packageGrid');
|
||||
grid.textContent = '';
|
||||
let searchCount = 0;
|
||||
for(const sp of sortedPackages) {
|
||||
const score = getMatchScore(term, sp.dataset);
|
||||
if (score > 20) {
|
||||
sp.classList.remove('hidden');
|
||||
searchCount++;
|
||||
} else {
|
||||
sp.classList.add('hidden');
|
||||
}
|
||||
grid.appendChild(sp);
|
||||
}
|
||||
|
||||
if (searchCount) {
|
||||
noResult.classList.remove('show');
|
||||
} else {
|
||||
noResult.classList.add('show');
|
||||
}
|
||||
} else {
|
||||
noResult.classList.remove('show');
|
||||
sortPackages();
|
||||
}
|
||||
}, 300);
|
||||
|
|
Loading…
Reference in a new issue