-
Notifications
You must be signed in to change notification settings - Fork 2
/
commitment-list.js
33 lines (30 loc) · 1.18 KB
/
commitment-list.js
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
/* global Papa */
document.addEventListener('DOMContentLoaded', () => {
const csv = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQ4l7bRcBIgwsEPGM_s9zF9csIeTgE2No_4tA6MuDCBUbfmWY_e9mAfzPpCJTsIK_hUzOyJ8CmdGMsX/pub?gid=2004051365&single=true&output=csv';
Papa.parse(csv, {
download: true,
header: true,
dynamicTyping: true,
complete: (results) => {
const repList = document.createElement('ul');
results.data.sort((a, b) => a.last_name.localeCompare(b.last_name));
results.data.filter((rep) => rep.commitments).forEach((rep) => {
const commitments = [
rep.committee_votes ? '1' : null,
rep.public_bills ? '2' : null,
rep.term_limits ? '3' : null,
].filter((i) => i);
repList.insertAdjacentHTML('beforeend', `
<li>
Rep. ${rep.first_name} ${rep.last_name}
(${rep.party ? `${rep.party[0]} - ` : ''}${rep.district}):
Amendment${commitments.length > 1 ? 's' : ''}
${commitments.join(', ')}
</li>
`);
});
document.querySelector('script[src*=commitment-list]')
.insertAdjacentElement('afterend', repList);
},
});
});