summaryrefslogtreecommitdiff
path: root/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'script.js')
-rw-r--r--script.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/script.js b/script.js
index 67018f7..fce62e0 100644
--- a/script.js
+++ b/script.js
@@ -1,6 +1,25 @@
(async function(){
const res = await fetch('data.json');
- const data = await res.json();
+ const versions = await res.json();
- // TODO: implement search
+ const input = document.getElementById('search');
+ input.addEventListener('input', (e) => {
+ const query = e.target.value;
+ for (const [key, data] of Object.entries(versions)) {
+ const results = Object.values(data.features).filter(
+ feat => feat.title.toLowerCase().replaceAll('`', '').includes(query.toLowerCase())
+ );
+ const ul = document.createElement('ul');
+ for (const feat of results) {
+ const li = document.createElement('li');
+ const a = document.createElement('a');
+ a.textContent = feat.title;
+ a.innerHTML = a.innerHTML.replaceAll(/`(.+?)`/g, (_, x) => `<code>${x}</code>`);
+ a.href = feat.url;
+ li.appendChild(a);
+ ul.appendChild(li);
+ }
+ document.getElementById(key + '-list').replaceChildren(...ul.children);
+ }
+ });
})();