summaryrefslogtreecommitdiff
path: root/script.js
blob: b8edbb41eab49695c51028a89d3c03aaf1fff4a7 (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
49
50
51
52
53
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 || proposal.page_title);
		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) {
		// The first letter of MediaWiki usernames is case-insensitive.
		const firstChar = authorFilter.charAt(0);
		const rest = authorFilter.slice(1);
		const lowercase = firstChar.toLowerCase() + rest;
		const uppercase = firstChar.toUpperCase() + rest;
		display(proposals.filter(p => p.authors && (p.authors.includes(lowercase) || p.authors.includes(uppercase))));
	} else {
		display(proposals);
	}
})();