Repository navigation
Expand file tree
/
Copy pathside_bar.js
More file actions
107 lines (91 loc) · 3.83 KB
/
Copy pathside_bar.js
File metadata and controls
107 lines (91 loc) · 3.83 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
/***********************************************
* Accordion Content script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
// Callback for tapping the menu committees
function getCom(committee_id) {
$("#selection_list").empty();
$.ajax({
type: 'get',
url: 'http://services.sunlightlabs.com/api/committees.get.json?apikey=de9c6b058ea542a4a5aab1d845d56c83&id=' + committee_id + '&jsonp=comdetails_callback',
dataType: 'jsonp',
success: comdetails_callback
});
}
function comdetails_callback(jsonData) {
var cidArray = new Array();
var members = jsonData.response.committee.members;
for (var i = 0; i < members.length; i++) {
var legislator = members[i].legislator;
cidArray.push(legislator.crp_id);
};
select_cand_ids(cidArray);
}
function generateCommitteeHTML(raceType) {
var obj;
if (raceType == "senate") {
obj = get_senate_list();
} else {
obj = get_house_list();
}
obj = obj.response;
for (f = 0; f < obj.committees.length; f++) {
var a = document.createElement ("a");
a.setAttribute("href",'javascript:getCom(\"'+obj.committees[f].committee.id+'\")');
a.setAttribute("id",obj.committees[f].committee.id);
var committeename = obj.committees[f].committee.name;
var firstsubstring = committeename.substring(0,19)
if (raceType == "senate") {
if (firstsubstring == "Senate Committee on") {
committeename = committeename.substring(20)
} else if (firstsubstring == "Senate Select Commi") {
committeename = committeename.substring(27)
} else if (firstsubstring == "Senate Special Comm") {
committeename = committeename.substring(27)
} else if (firstsubstring == "Senate Commission on") {
committeename = committeename.substring(21)
}
} else {
if (firstsubstring == "House Committee on ") {
committeename = committeename.substring(19)
} else if (firstsubstring == "House Permanent Sel") {
committeename = committeename.substring(35)
}
}
committeename = committeename.substring(0,38)
a.appendChild (document.createTextNode (committeename));
if (obj.committees[f].committee.subcommittees) {
a.setAttribute("class","menuitem submenuheader");
document.getElementsByClassName("glossymenu")[0].appendChild(a);
var subcommittees = obj.committees[f].committee.subcommittees;
var div = document.createElement ("div");
div.setAttribute("class","submenu");
var ul = document.createElement("ul");
for (var i = subcommittees.length - 1; i >= 0; i--) {
var subcommittee = subcommittees[i];
var sub_li = document.createElement ("li");
var sub_a = document.createElement ("a");
sub_a.setAttribute("href",'javascript:getCom(\"' + subcommittee.committee.id + '\")');
sub_a.setAttribute("class","subcl");
sub_a.appendChild (document.createTextNode (subcommittee.committee.name));
sub_li.appendChild(sub_a);
ul.appendChild(sub_li);
}
div.appendChild(ul);
document.getElementsByClassName("glossymenu")[0].appendChild(div);
} else {
a.setAttribute("class","menuitem");
document.getElementsByClassName("glossymenu")[0].appendChild(a);
}
}
// NOTE: I did this fricken crazy generation because
// the ddaccordion does not work in a function and if you
// just have it outside when you clear the div because you are
// switching senate/house the + signs disappear.
var headID = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = 'accordianinit.js';
headID.appendChild(newScript);
}