Display item counter next to search form.
All checks were successful
deployment-on-pull-request / deployment (pull_request) Successful in 1m16s
All checks were successful
deployment-on-pull-request / deployment (pull_request) Successful in 1m16s
This commit is contained in:
parent
b9e87f09d5
commit
3d91fe8f3a
2 changed files with 30 additions and 1 deletions
|
@ -7,6 +7,11 @@ h1, h1 a {
|
||||||
color: #dfaa37; /* C4 Yellow */
|
color: #dfaa37; /* C4 Yellow */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#itemcount {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 1ch;
|
||||||
|
}
|
||||||
|
|
||||||
#map {
|
#map {
|
||||||
border: 1px solid #202020;
|
border: 1px solid #202020;
|
||||||
background: #4d4d4d;
|
background: #4d4d4d;
|
||||||
|
|
|
@ -36,6 +36,7 @@ function renderItems() {
|
||||||
container.appendChild(clone);
|
container.appendChild(clone);
|
||||||
};
|
};
|
||||||
loading.remove();
|
loading.remove();
|
||||||
|
updateCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLocString(items, item) {
|
function getLocString(items, item) {
|
||||||
|
@ -89,6 +90,29 @@ function search(e) {
|
||||||
elem.classList.add('filtered');
|
elem.classList.add('filtered');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCounter(){
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
for (const elem of document.getElementsByClassName('result')) {
|
||||||
|
if (!elem.matches('.filtered')) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(count) {
|
||||||
|
case 0:
|
||||||
|
document.getElementById('itemcount').textContent = `No items found.`;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
document.getElementById('itemcount').textContent = `${count} item found.`;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
document.getElementById('itemcount').textContent = `${count} items found.`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showhidden(e){
|
function showhidden(e){
|
||||||
|
@ -118,4 +142,4 @@ function showItem(e) {
|
||||||
|
|
||||||
function hideItem(e) {
|
function hideItem(e) {
|
||||||
clearMap();
|
clearMap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue