diff options
author | Martin Fischer <martin@push-f.com> | 2022-07-12 13:28:25 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2022-07-12 13:28:25 +0200 |
commit | 88d6a52f239c8dc706eeee337fae4972de5a9936 (patch) | |
tree | fe368c752e3e575e0dbd8e88ceae61597344249f /script.js | |
parent | bbe6d4740723315fc91b0298ab8a0a6292fa4ac7 (diff) |
implement ?author filtering
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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); + } })(); |