summaryrefslogtreecommitdiff
path: root/script.js
blob: afe5df216bc387aedec5a87ec829d8f85471cb36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const tbody = document.getElementById('tbody');

function newEl(tagname, content) {
	const cell = document.createElement(tagname);
	if (content instanceof Node)
		cell.appendChild(content);
	else
		cell.textContent = content;
	return cell;
}

function display(proposals) {
	proposals.forEach(proposal => {
		const row = document.createElement('tr');

		const statusCell = newEl('td', proposal.status);
		statusCell.className = 'status-' + proposal.status;
		row.appendChild(statusCell);

		let date = '???';
		if (proposal.status == 'voting' || proposal.status == 'approved' || proposal.status == 'rejected') {
			date = proposal.vote_start;
		} else if (proposal.status == 'proposed') {
			date = proposal.rfc_start;
		} else {
			date = proposal.draft_start;
		}
		row.appendChild(newEl('td', date));

		const link = newEl('a', proposal.name);
		link.href = 'https://wiki.openstreetmap.org/wiki/' + proposal.page_title.replaceAll(' ', '_');
		row.appendChild(newEl('td', link));
		row.appendChild(newEl('td', proposal.authors));

		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);
	}
})();