mirror of
https://github.com/ivabus/www
synced 2024-11-25 09:45: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>
|
<hr>
|
||||||
<section>
|
<section id="noResult" class="no-results">
|
||||||
<div class="container black-bg">
|
<div class="container black-bg">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col two-boxes-up two-boxes-down">
|
<div class="col two-boxes-up two-boxes-down">
|
||||||
|
@ -10,3 +10,12 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.no-results {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.no-results.show {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -24,6 +24,7 @@
|
||||||
{{- partial "package-thumbnail.html" .}}
|
{{- partial "package-thumbnail.html" .}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
{{- partial "no-results-found.html" }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
@ -120,6 +121,7 @@
|
||||||
|
|
||||||
const onSearch = debounce(() => {
|
const onSearch = debounce(() => {
|
||||||
const searchInput = document.getElementById('searchTermDesktop');
|
const searchInput = document.getElementById('searchTermDesktop');
|
||||||
|
const noResult = document.getElementById('noResult');
|
||||||
if (searchInput.value) {
|
if (searchInput.value) {
|
||||||
const term = searchInput.value;
|
const term = searchInput.value;
|
||||||
const packages = getPackageThumbs();
|
const packages = getPackageThumbs();
|
||||||
|
@ -130,16 +132,25 @@
|
||||||
});
|
});
|
||||||
const grid = document.getElementById('packageGrid');
|
const grid = document.getElementById('packageGrid');
|
||||||
grid.textContent = '';
|
grid.textContent = '';
|
||||||
|
let searchCount = 0;
|
||||||
for(const sp of sortedPackages) {
|
for(const sp of sortedPackages) {
|
||||||
const score = getMatchScore(term, sp.dataset);
|
const score = getMatchScore(term, sp.dataset);
|
||||||
if (score > 20) {
|
if (score > 20) {
|
||||||
sp.classList.remove('hidden');
|
sp.classList.remove('hidden');
|
||||||
|
searchCount++;
|
||||||
} else {
|
} else {
|
||||||
sp.classList.add('hidden');
|
sp.classList.add('hidden');
|
||||||
}
|
}
|
||||||
grid.appendChild(sp);
|
grid.appendChild(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (searchCount) {
|
||||||
|
noResult.classList.remove('show');
|
||||||
|
} else {
|
||||||
|
noResult.classList.add('show');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
noResult.classList.remove('show');
|
||||||
sortPackages();
|
sortPackages();
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
Loading…
Reference in a new issue