From 88d6a52f239c8dc706eeee337fae4972de5a9936 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Tue, 12 Jul 2022 13:28:25 +0200 Subject: implement ?author filtering --- script.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'script.js') diff --git a/script.js b/script.js index 0c17abf..afe5df2 100644 --- a/script.js +++ b/script.js @@ -9,9 +9,8 @@ function newEl(tagname, content) { return cell; } -(async function() { - const data = await (await fetch('proposals.json')).json(); - data.forEach(proposal => { +function display(proposals) { + proposals.forEach(proposal => { const row = document.createElement('tr'); const statusCell = newEl('td', proposal.status); @@ -35,4 +34,15 @@ function newEl(tagname, content) { tbody.appendChild(row); }); +} + +(async function() { + const proposals = await (await fetch('proposals.json')).json(); + + const authorFilter = new URLSearchParams(location.search).get('author'); + if (authorFilter) { + display(proposals.filter(p => p.authors && p.authors.includes(authorFilter))); + } else { + display(proposals); + } })(); -- cgit v1.2.3