diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-27 10:50:56 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-27 12:54:12 +0100 |
commit | 68224ab860f92aec2325ccc1745703779964c240 (patch) | |
tree | f5afe3d34bf00bad84f6b638879148a98523c21c | |
parent | d2eeb1d48dbeced8b3d1d1796dbc908511bc2a2f (diff) |
search: make search hide empty versions
-rw-r--r-- | script.js | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -6,6 +6,12 @@ input.addEventListener('input', (e) => { const query = e.target.value; for (const [key, data] of Object.entries(versions)) { + const heading = document.getElementById(key); + + if (data.features == undefined) { + heading.hidden = query.length != 0; + continue; + } const results = Object.values(data.features).filter( feat => feat.title.toLowerCase().replaceAll('`', '').includes(query.toLowerCase()) ); @@ -19,7 +25,10 @@ li.appendChild(a); ul.appendChild(li); } - document.getElementById(key + '-list').replaceChildren(...ul.children); + const list = document.getElementById(key + '-list'); + list.replaceChildren(...ul.children); + list.hidden = results.length == 0; + heading.hidden = results.length == 0; } }); })(); |