forked from WashDems-Public/Data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
endorsements.html
298 lines (222 loc) · 10.4 KB
/
endorsements.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!DOCTYPE html>
<html>
<head>
<title>Local Democratic Party Endorsements</title>
<script type="text/javascript">
function toggleDisplay (dv) {
// alert(dv.id.toString());
if (document.getElementById(dv.id.toString()).style.display == "none") {
document.getElementById(dv.id.toString()).style.display = "inline";
} else {
document.getElementById(dv.id.toString()).style.display = "none";
}
// alert(dv.style.value);
}
function getOrgHTMLfromJSONObject(objOrg) {
var strReturn = "";
strReturn += objOrg.orgShort.toString();
// Try to wrap org full name in URL IF URL length > 0
try {
if (objOrg.orgEndorsements2016.length > 0) {
strReturn = "<a href='" + objOrg.orgEndorsements2016 + "' target='_blank'>" + strReturn + "</a>";
}
} catch (err) {
}
return strReturn;
} // end get org HTML from JSON object
function getOrgsByType(OrgType) {
// document.getElementById('pLocalOrgs').innerHTML = 'Loading requested data...';
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
var DONE = this.DONE || 4;
if (this.readyState === DONE){
var dataObj = JSON.parse(request.responseText);
var strOrgsList = "";
// for each org
for (i = 0; i < dataObj.length; i++ ){
if (dataObj[i].orgType.toString() == OrgType) {
if (strOrgsList.length > 0) {
strOrgsList += " | ";
}
strOrgsList += getOrgHTMLfromJSONObject(dataObj[i]);
}
} // next org
// alert (strOrgsList);
if (OrgType == "County") {
document.getElementById('pLocalCountyOrgs').innerHTML = strOrgsList;
}
if (OrgType == "LD") {
document.getElementById('pLocalLDOrgs').innerHTML = strOrgsList;
}
return strOrgsList;
}
};
request.open('GET', 'orgs.json', true);
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); // Tells server that this call is made for ajax purposes.
request.send(null); // No data needs to be sent along with the request.
// return "Rendering data...";
} // end get orgs by type
function changeText() {
document.getElementById('pInfo').innerHTML = 'Loading requested data...';
// Don't use these
var strCountyOrgs = getOrgsByType("County");
var strLDOrgs = getOrgsByType("LD");
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
var DONE = this.DONE || 4;
if (this.readyState === DONE){
// alert(this.readyState);
// alert(request.responseText);
var dataObj = JSON.parse(request.responseText);
var strNav = ""
var strInfo = "";
var tmpCandidate;
// for each group, write a header
for (iGroup = 0; iGroup < dataObj.length; iGroup++ ) {
// Skip WA Leg and County
/*
if ( (dataObj[iGroup].groupLevelID == "WALeg") || (dataObj[iGroup].groupLevelID == "County") ) {
iGroup++;
}
*/
// if the nav string has something already, add a spacer
if (strNav.length > 0) { strNav += " | "; }
// Add the group level name to the nav
strNav += "<a href='#" + dataObj[iGroup].groupLevelID + "'>" + dataObj[iGroup].groupLevelName + "</a>";
strInfo += "<a name='" + dataObj[iGroup].groupLevelID + "'>" + "<h2>" + dataObj[iGroup].groupLevelName + "</h2>" + "</a>";
// If the groupDisplay value is set to "collapsed"
try {
if (dataObj[iGroup].groupDisplay == "collapsed") {
strInfo += "<div onClick='javascript:toggleDisplay(dv" + dataObj[iGroup].groupLevelID + ");'>" + "Click to expand / collapse" + "</div>";
strInfo += "<div id='dv" + dataObj[iGroup].groupLevelID + "' style='display:none'>";
}
} catch (err) { }
// If county or LD, point to further down
if ( (dataObj[iGroup].groupLevelID == "WALeg") || (dataObj[iGroup].groupLevelID == "County") || (dataObj[iGroup].groupLevelID == "CountyInitiatives") ) {
strInfo += "<p>For these endorsements, visit your <a href='#local'>local County and LD Democratic organizations</a></p>";
}
try {
// for each position write a smaller header
for (iPosition = 0; iPosition < dataObj[iGroup].positions.length; iPosition++) {
strInfo += "<h3>" + dataObj[iGroup].positions[iPosition].posName + "</h3>";
strInfo += "<table>";
// for each candidate write their info
for (iCandidate = 0; iCandidate < dataObj[iGroup].positions[iPosition].candidates.length ; iCandidate++) {
tmpCandidate = dataObj[iGroup].positions[iPosition].candidates[iCandidate];
strInfo += "<tr>";
// Candidate photo (square)
if ( tmpCandidate.candPhotoURL.length > 0 ) {
strInfo += "<td rowspan='2'>";
strInfo += "<img src='" + tmpCandidate.candPhotoURL + "' height='80px' width='80px' alt='Photo of " + tmpCandidate.candName + "' />";
strInfo += "</td>";
} else { strInfo += "<td rowspan='2'></td>"; }
// Candidate website
strInfo += "<td colspan='3' style='font-size:larger; vertical-align:top'><a href='" + tmpCandidate.candWeb + "' target='_blank'><b>" + tmpCandidate.candName + "</b><a/></td>";
strInfo += "</tr><tr>";
// Twitter alias
if ( tmpCandidate.candTwAlias.length > 0 ) {
strInfo += "<td><a href='https://twitter.com/" + tmpCandidate.candTwAlias + "' target='_blank'>@" + tmpCandidate.candTwAlias + "</a></td>";
} else { strInfo += "<td></td>"; }
// Facebook page
if ( tmpCandidate.candFbPage.length > 0 ) {
strInfo += "<td><a href='" + tmpCandidate.candFbPage + "' target='_blank'>" + "Facebook" + "</a></td>";
} else { strInfo += "<td></td>"; }
/* Hide volunteer link
if ( tmpCandidate.candVol.length > 0 ) {
strInfo += "<td><a href='" + tmpCandidate.candVol + "' target='_blank'>" + "Volunteer" + "</a></td>";
} else { strInfo += "<td></td>"; }
*/
/* Hide donate link
if ( tmpCandidate.candDonate.length > 0 ) {
strInfo += "<td><a href='" + tmpCandidate.candDonate + "' target='_blank'>" + "Donate" + "</a></td>";
} else { strInfo += "<td></td>"; }
*/
// Show endorsements link if present
try {
strInfo += "<td>";
if ( tmpCandidate.candEndorsements.length > 0 ) {
strInfo += "<td><a href='" + tmpCandidate.candEndorsements + "' target='_blank'>" + "Endorsements" + "</a></td>";
} else { strInfo += "<td></td>"; }
strInfo += "</td>";
} catch (err) {
strInfo += "<td></td>";
}
strInfo += "</tr>";
} // next candidate for this position
strInfo += "</table>";
} // next position in this group
} catch (err) {
}
// If the groupDisplay value is set to "collapsed"
try {
if (dataObj[iGroup].groupDisplay == "collapsed") {
strInfo += "</div>";
}
} catch (err) { }
} // next group
document.getElementById('pNav').innerHTML = strNav + " | <a href='#local'>More</a>";
document.getElementById('pInfo').innerHTML = strInfo;
}
};
request.open('GET', 'endorsements.json', true);
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); // Tells server that this call is made for ajax purposes.
request.send(null); // No data needs to be sent along with the request.
document.getElementById('pInfo').innerHTML = 'Rendering requested data...';
}
</script>
</head>
<body onload="changeText()" style="font-family:Arial">
<h1>Local Democratic Party Endorsements</h1>
<p style="font-size:smaller">We're thrilled to have <a href="http://www.JayInslee.com/" target='_blank'>Governor Jay Inslee</a> and <a href="http://www.pattymurray.com/" target='_blank'>U.S. Sen. Patty Murray</a> leading our ticket.</p>
<p style="font-size:smaller">
Local <a href="http://www.wa-democrats.org/local/county" target='_blank'>county</a> and <a href="http://www.wa-democrats.org/local/ldo" target='_blank'>legislative district</a>
Democratic party organizations have endorsed Gov. Inslee, Sen. Murray, other candidates and ballot measures.
Use this endorsement page to learn who your fellow Democrats support and then
<a href="http://www.wa-democrats.org/volunteer" target='_blank'>sign up to contribute your energy and skills</a> to helping
Democrats win in November.
</p>
<p style="font-size:smaller">We can’t defeat Trump, win statewide, re-take the State Senate and maintain the State House without you. </p>
<p style="font-size:smaller"><a href="http://www.wa-democrats.org/volunteer" target='_blank'>Sign up to volunteer</a>, and push our Democrats up and down the ballot to victory!</p>
<p id="pNav">Loading data...</p>
<p id="pInfo">Loading data...</p>
<a name="local"><h2>State Legislature, County, and more</h2></a>
<p>For more local endorsements, visit your local County and LD Democratic organizations:</p>
<ul>
<li>
<p id="pLocalCountyOrgs">Loading data...</p>
</li>
<li>
<p id="pLocalLDOrgs">Loading data...</p>
</li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>
Paid for by the Washington State Democrats<br />
PO Box 4027, Seattle, WA 98194, (206) 583-0664<br />
Chair Jaxon Ravens, <a href="http://www.wa-democrats.org" target='_blank'>http://www.wa-democrats.org</a><br />
Not authorized by any candidate or candidate's committee<br />
</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>