-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
147 lines (137 loc) · 4.26 KB
/
script.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
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
google.maps.visualRefresh = true;
var map;
var infowindow = null;
function initialize() {
var mapOptions = {
zoom: 6,
center: new google.maps.LatLng(53.709714,-3.826675),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
function createHTML(result) {
HTMLtext = new Array();
$.each(result.establishments, function(ndx, val) {
html = "<div id='content'><h2>";
html += val.orgname;
html += "</h2>";
html += "<div class='proj-info'>";
html += "<table border='1'>";
for(var i=0; i<val.projects.length; ++i) {
html += "<tr><td colspan='2'><h3>";
html += val.projects[i].title;
html += "</h3></td></tr>";
html += "<tr class='funds'>";
html += "<td>";
html += "<b>";
html += "Amount";
html += "</b>";
html += "</td>";
html += "<td>";
html += val.projects[i].amount;
html += "</td>";
html += "</tr>";
html += "<tr class='funded by'>";
html += "<td>";
html += "<b>";
html += "Funded By"
html += "</b>";
html += "</td>";
html += "<td>";
html += val.projects[i].funder;
html += "</td>";
html += "</tr>";
if (val.projects[i].status) {
html += "<tr class='active'>";
html += "<td>";
html += "<b>";
html += "Project Status";
html += "</b>";
html += "</td>";
html += "<td>";
html += val.projects[i].status;
html += "</td>";
html += "</tr>";
}
html += "<tr class='start-date'>";
html += "<td>";
html += "<b>";
html += "Start Date";
html += "</b>";
html += "</td>";
html += "<td>";
html += val.projects[i].start;
html += "</td>";
html += "</tr>";
html += "<tr class='end-date'>";
html += "<td>";
html += "<b>";
html += "End Date";
html += "</b>";
html += "</td>";
html += "<td>";
html += val.projects[i].end;
html += "</td>";
html += "</tr>";
// html += "<tr class='abstract'>";
// html += "<td>";
// html += "<b>";
// html += "Abstract";
// html += "</b>";
// html += "</td>";
// html += "<td>";
// html += val.projects[i].abstract;
// html += "</td>";
// html += "</tr>";
}
html += "</table>";
html += "</div>";
html += "</div>";
HTMLtext[ndx] = html;
});
}
function placeMarkers(result) {
$.each(result.establishments, function(ndx, val) {
var myLatLng = new google.maps.LatLng(val.lat, val.lng);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
animation: google.maps.Animation.DROP,
title: val.orgname,
html: HTMLtext[ndx]
});
var contentString = "Some content";
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(this.html);
infowindow.open(map, this);
});
});
}
google.maps.event.addDomListener(window, 'load', initialize);
$(document).ready(function() {
$('#loading, #options').hide();
$('form').submit(function(e2) {
//console.log("Working up to here");
//$('#map-canvas').gmap('destroy');
e2.preventDefault();
$('#loading, #options').show();
$('#landing-slide').animate({left:'80%'}, 1000,'easeOutBounce', function(){
$('#landing-slide').animate({right:'80%'}, 1000,'easeOutBounce')
$.getJSON(
"/cgi-bin/everything.py",
{"term" : $('.input-text').val()},
function(result) {
$('#loading').hide();
createHTML(result);
placeMarkers(result);
infowindow = new google.maps.InfoWindow({
content: "loading..."
});
});
});
$('#hide').click(function() {
$('#landing-slide').hide();
});
});
});