Repository navigation
Expand file tree
/
Copy pathmembers.html
More file actions
198 lines (179 loc) · 9.37 KB
/
Copy pathmembers.html
File metadata and controls
198 lines (179 loc) · 9.37 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Home</title>
<!-- Bootstrap Style -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<!-- Custom Style -->
<link href="https://getbootstrap.com/docs/4.4/examples/offcanvas/offcanvas.css" rel="stylesheet">
<style>
.usGradient {
background: rgb(121,9,9);
background: linear-gradient(90deg, rgba(121,9,9,1) 0%, rgba(255,255,255,1) 80%, rgba(0,16,255,1) 100%);
}
.container {
width: 50%;
max-width: 680px;
padding: 0 15px;
}
</style>
</head>
<body class="bg-secondary">
<div class="collapse" id="navbarToggleExternalContent">
<div class="bg-dark p-4">
<a href="/" class="text-muted">Home</a>
<br>
<a href="/members" class="text-white">Members</a>
</div>
</div>
<nav class="navbar fixed-top navbar-dark bg-dark">
<a class="navbar-brand mr-auto mr-lg-0 text-white" href="/">CongressApp</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
<main role="main" class="container">
<div class="d-flex align-items-center p-3 my-3 text-white-50 rounded shadow-sm usGradient">
<img class="mr-3" src="/CongressSeal.svg" alt="" width="48" height="48">
<div class="lh-100">
<h6 class="mb-0 text-white lh-100">US Congress Members</h6>
<small>116th</small>
</div>
</div>
<div id="reps" class="my-3 p-3 bg-dark rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0 text-white">All Representatives(A-Z)</h6>
</div>
<div id="senators" class="my-3 p-3 bg-dark rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0 text-white">All Senators(A-Z)</h6>
</div>
</main>
<footer class="footer mt-auto py-3 bg-secondary">
<div class="container">
<span class="text-dark">Created By <a href="https://github.com/packwatcher">packwatcher</a> on Github</span>
</div>
</footer>
<!-- Bootstrap Scripts -->
<script src="/jquery-3.4.1.slim.min.js" crossorigin="anonymous"></script>
<script src="/popper.min.js" crossorigin="anonymous"></script>
<script src="/bootstrap.min.js" crossorigin="anonymous"></script>
<script>
fetch("/api/members/house")
.then(res => res.json())
.then(res => {
if(res.results[0].members.length >= 3) {
for(let i = 0; i < 3; i++) {
document.getElementById("reps").innerHTML += repElement(res.results[0].members[i])
}
document.getElementById("reps").innerHTML += viewAllElement("house")
}
})
const repElement = obj => `
<div class="media text-muted pt-3 border-bottom border-gray">
<svg class="bd-placeholder-img mr-2 rounded" width="32" height="32" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img">
<rect width="100%" height="100%" fill="#${getColor(obj.party)}"></rect>
<text x="50%" y="50%" fill="#007bff" dy=".3em"></text>
</svg>
<p class="media-body pb-3 mb-0 small lh-125 text-white">
<strong class="d-block text-white">${obj.short_title} ${obj.first_name} ${obj.last_name}</strong>
${obj.state}-${obj.district}
</p>
<a class="btn btn-primary btn-sm" href="/member#${obj.id}" role="button">More Info »</a>
</div>
`
fetch("/api/members/senate")
.then(res => res.json())
.then(res => {
if(res.results[0].members.length >= 3) {
for(let i = 0; i < 3; i++) {
document.getElementById("senators").innerHTML += senatorElement(res.results[0].members[i])
}
document.getElementById("senators").innerHTML += viewAllElement("senate")
}
})
const senatorElement = obj => `
<div class="media text-muted pt-3 border-bottom border-gray">
<svg class="bd-placeholder-img mr-2 rounded" width="32" height="32" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img">
<rect width="100%" height="100%" fill="#${getColor(obj.party)}"></rect>
<text x="50%" y="50%" fill="#007bff" dy=".3em"></text>
</svg>
<p class="media-body pb-3 mb-0 small lh-125 text-white">
<strong class="d-block text-white">${obj.short_title} ${obj.first_name} ${obj.last_name}</strong>
${obj.state}
</p>
<a class="btn btn-primary btn-sm" href="/member#${obj.id}" role="button">More Info »</a>
</div>
`
// fetch("/api/latest/bills")
// .then(res => res.json())
// .then(res => {
// if(res.num_results >= 3) {
// for(i = 0; i < 3; i++) {
// document.getElementById("latestBills").innerHTML += billElement(res.bills[i])
// }
// document.getElementById("latestBills").innerHTML += viewAllElement("reps")
// }
// })
// const billElement = obj => `
// <div class="media text-muted pt-3">
// <svg class="bd-placeholder-img mr-2 rounded" width="32" height="32" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img">
// <rect width="100%" height="100%" fill="#${getColor(obj.sponsor_party)}"></rect>
// <text x="50%" y="50%" fill="#007bff" dy=".3em"></text>
// </svg>
// <p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray text-white">
// <strong class="d-block text-white">${obj.sponsor_title} ${obj.sponsor_name}</strong>
// ${obj.short_title}
// </p>
// </div>
// `
// fetch("/api/latest/members")
// .then(res => res.json())
// .then(res => {
// if(res.num_results >= 3) {
// for(i = 0; i < 3; i++) {
// if(res.members[i].chamber === "House") {
// document.getElementById("latestMembers").innerHTML += houseProfile(res.members[i])
// }
// else if(res.members[i].chamber === "Senate") {
// document.getElementById("latestMembers").innerHTML += senateProfile(res.members[i])
// }
// }
// document.getElementById("latestMembers").innerHTML += viewAllElement("members")
// }
// })
// const senateProfile = obj => `
// <div class="media text-muted pt-3">
// <svg class="bd-placeholder-img mr-2 rounded" width="32" height="32" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img">
// <rect width="100%" height="100%" fill="#${getColor(obj.party)}"></rect>
// <text x="50%" y="50%" fill="#007bff" dy=".3em"></text>
// </svg>
// <p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray text-white">
// <strong class="d-block text-white">Sen. ${obj.first_name} ${obj.last_name}</strong>
// ${obj.state}
// </p>
// </div>
// `
// const houseProfile = obj => `
// <div class="media text-muted pt-3">
// <svg class="bd-placeholder-img mr-2 rounded" width="32" height="32" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img">
// <rect width="100%" height="100%" fill="#${getColor(obj.party)}"></rect>
// <text x="50%" y="50%" fill="#007bff" dy=".3em"></text>
// </svg>
// <p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray text-white">
// <strong class="d-block text-white">Rep. ${obj.first_name} ${obj.last_name}</strong>
// ${obj.state}-${obj.district}
// </p>
// </div>
// `
function getColor(party) {
if(party === "R") return "dc3545"
if(party === "D") return "007bff"
if(party === "I") return "6c757d"
}
const viewAllElement = type => `<small class="d-block text-right mt-3">
<a href="/members/${type}/all">View All</a>
</small>`
</script>
</body>
</html>