-
Notifications
You must be signed in to change notification settings - Fork 0
/
specificBill.html
217 lines (196 loc) · 10.2 KB
/
specificBill.html
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<!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 id="bill" class="mb-0 text-white lh-100"></h6>
<small>116th US Congress</small>
</div>
</div>
<div id="info" class="my-3 p-3 bg-dark rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0 text-white">Info</h6>
<div class="media text-muted border-bottom border-gray d-flex align-items-center">
<div class="d-flex justify-content-center align-items-center" style="height: 50px; width: 50px;">
<i data-feather="tag"></i>
</div>
<p id="title" class="media-body small lh-125 text-white" style="margin-top: 10px; margin-bottom: 10px;">
<strong class="d-block text-white">Title: </strong>
</p>
</div>
<div class="media text-muted border-bottom border-gray d-flex align-items-center">
<div class="d-flex justify-content-center align-items-center" style="height: 50px; width: 50px;">
<i data-feather="user"></i>
</div>
<p id="sponsor" class="media-body small lh-125 text-white" style="margin-top: 10px; margin-bottom: 10px;">
<strong class="d-block text-white">Sponsor: </strong>
</p>
</div>
<div class="media text-muted border-bottom border-gray d-flex align-items-center">
<div class="d-flex justify-content-center align-items-center" style="height: 50px; width: 50px;">
<i data-feather="users"></i>
</div>
<p id="cosponsorsParent" class="media-body small lh-125 text-white" style="margin-top: 10px; margin-bottom: 10px;">
<strong id="cosponsors" class="d-block text-white"></strong>
</p>
</div>
<div class="media text-muted border-bottom border-gray d-flex align-items-center">
<div class="d-flex justify-content-center align-items-center" style="height: 50px; width: 50px;">
<i data-feather="upload"></i>
</div>
<p id="introduced" class="media-body small lh-125 text-white" style="margin-top: 10px; margin-bottom: 10px;">
<strong id="introduced" class="d-block text-white">Introduced On: </strong>
</p>
</div>
<div class="media text-muted border-bottom border-gray d-flex align-items-center">
<div class="d-flex justify-content-center align-items-center" style="height: 50px; width: 50px;">
<i data-feather="file-text"></i>
</div>
<br>
<p id="summary" class="media-body small lh-2500 text-white" style="margin-top: 10px; margin-bottom: 10px;">
<strong class="d-block text-white">Summary: </strong>
</p>
<br>
</div>
</div>
<div id="votes" class="my-3 p-3 bg-dark rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0 text-white">Votes</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 src="https://unpkg.com/feather-icons"></script>
<script>
feather.replace()
fetch(`/api/bill/${window.location.hash.slice(1)}`)
.then(res => res.json())
.then(res => res.results[0])
.then(res => {
cosponsorPartyData = []
let csData = ""
document.getElementById("bill").innerText = res.bill
document.getElementById("title").innerHTML += res.short_title
document.getElementById("sponsor").innerHTML += `${res.sponsor_title} ${res.sponsor}`
let cosponsorsArr = Object.entries(res.cosponsors_by_party)
console.log(cosponsorsArr)
cosponsorsArr.forEach(party => {
cosponsorPartyData.push(`${party[1]} ${getParty(party[0])}`)
})
document.getElementById("cosponsors").innerHTML += `${res.cosponsors} Cosponsors` + document.getElementById("cosponsorsParent").innerHTML
document.getElementById("cosponsorsParent").innerHTML += cosponsorPartyData.join(" | ")
document.getElementById("introduced").innerHTML += res.introduced_date
if(res.summary === "") {
document.getElementById("summary").innerHTML += "N/A"
}
else {
document.getElementById("summary").innerHTML += res.summary
}
res.votes.forEach(vote => {
if(vote.result === "Passed") document.getElementById("votes").innerHTML += passedElement(vote)
if(vote.result === "Failed") document.getElementById("votes").innerHTML += failedElement(vote)
})
feather.replace()
})
function getName(memberObj) {
if(memberObj.middle_name !== null) return `${memberObj.roles[0].short_title} ${memberObj.first_name} ${memberObj.middle_name} ${memberObj.last_name}`
return `${memberObj.roles[0].short_title} ${memberObj.first_name} ${memberObj.last_name}`
}
function getFullStateInfo(memberInfo) {
if(memberInfo.roles[0].short_title.startsWith("Rep")) return `${memberInfo.roles[0].state}-${memberInfo.roles[0].district}${getEnding(memberInfo.roles[0].district)}`
else if(memberInfo.roles[0].short_title.startsWith("Sen")) return memberInfo.roles[0].state
}
function getEnding(num) {
if(num % 10 === 1) return "st"
if(num % 10 === 2) return "nd"
if(num % 10 === 3) return "rd"
return "th"
}
function getGender(gender) {
if(gender === "M") return "Male"
if(gender === "F") return "Female"
}
function getParty(party) {
if(party === "R") return "Republican"
if(party === "D" || party === "ID") return "Democratic"
if(party === "I") return "Independent"
}
const socialElement = (type, username) => `
<div class="media text-muted border-bottom border-gray d-flex align-items-center">
<div class="d-flex justify-content-center align-items-center" style="height: 50px; width: 50px;">
<i data-feather="${type}"></i>
</div>
<p class="media-body mb-0 small lh-125 text-white">
<strong class="d-block text-white">${username}</strong>
</p>
</div>
`
const passedElement = obj => `
<div class="media text-muted border-bottom border-gray d-flex align-items-center">
<div class="d-flex justify-content-center align-items-center" style="height: 75px; width: 50px;">
<i data-feather="check-square"></i>
</div>
<p class="media-body mb-0 small lh-150 text-white">
<strong id="question" class="d-block text-white">${obj.question}</strong>
${obj.date} ${obj.time}
<br>
${obj.result}: ${obj.total_yes}/${obj.total_yes + obj.total_no + obj.total_not_voting}
</p>
</div>
`
const failedElement = obj => `
<div class="media text-muted border-bottom border-gray d-flex align-items-center">
<div class="d-flex justify-content-center align-items-center" style="height: 75px; width: 50px;">
<i data-feather="x-square"></i>
</div>
<p class="media-body mb-0 small lh-150 text-white">
<strong id="question" class="d-block text-white">${obj.question}</strong>
${obj.date} ${obj.time}
<br>
${obj.result}: ${obj.total_yes}/${obj.total_yes + obj.total_no + obj.total_not_voting}
</p>
</div>
`
</script>
</body>
</html>