forked from qiime/qiime_web_app
/
index.psp
executable file
·282 lines (234 loc) · 8.63 KB
/
index.psp
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
<%
#!/usr/bin/env python
__author__ = "Doug Wendel"
__copyright__ = "Copyright 2010, Qiime Web Analysis"
__credits__ = ["Doug Wendel"]
__license__ = "GPL"
__version__ = "1.0.0.dev"
__maintainer__ = ["Doug Wendel"]
__email__ = "wendel@colorado.edu"
__status__ = "Development"
from data_access_connections import data_access_factory
from enums import ServerConfig,DataAccessType
import os
from enums import FieldGrouping
from qiime.parse import parse_mapping_file
# Set variables
zoom_level = 5
# center of US
center_lat = 39.83389
center_long = -99.89150999999998
# our lab
#center_lat = 49.26123
#center_long = -123.1139299
tiny_markers = False
portal_type = 'americangut'
# Data Access
data_access = data_access_factory(ServerConfig.data_access_type)
ag_data_access = data_access_factory(ServerConfig.data_access_type,
'american_gut')
# Session variables
sess = Session.Session(req)
if 'username' in sess:
psp.redirect('logout.psp')
sess['portal_type'] = portal_type
sess['document_root'] = req.document_root() + '/americangut/'
sess['resources'] = {}
sess['resources']['barcode_images_fp'] = os.path.join('img', 'barcodes')
sess.set_timeout(604800)
sess.save()
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>American Gut</title>
<link rel="stylesheet" type="text/css" href="style/americangut.css">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="/qiime/js/StyledMarker.js"></script>
<script type="text/javascript" src="/qiime/js/qiime.js"></script>
<script type="text/javascript" src="/qiime/js/jquery_validate/lib/jquery.js"></script>
<script type="text/javascript" src="/qiime/js/jquery_validate/lib/jquery.metadata.js"></script>
<script type="text/javascript" src="/qiime/js/jquery_validate/jquery.validate.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
$("ul.topnav li span").click(function() { //When trigger is clicked...
//Following events are applied to the subnav itself (moving subnav up and down)
$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
$(this).parent().hover(function() {
}, function(){
$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
});
//Following events are applied to the trigger (Hover events for the trigger)
}).hover(function() {
$(this).addClass("subhover"); //On hover over, add class "subhover"
}, function(){ //On Hover Out
$(this).removeClass("subhover"); //On hover out, remove class "subhover"
});
});
function toggleSection(section_name)
{
div = document.getElementById(section_name);
header_name = section_name + '_header';
if (div.style.display == 'none')
{
$('#' + section_name).fadeIn('fast')
header_content = $('#' + header_name)[0].innerHTML
$('#' + header_name)[0].innerHTML = header_content.replace('+', '-');
window.scrollBy(0, 200);
}
else
{
$('#' + section_name).fadeOut('fast')
header_content = $('#' + header_name)[0].innerHTML
$('#' + header_name)[0].innerHTML = header_content.replace('-', '+');
}
}
function initialize()
{
var mapOptions =
{
<%
req.write('zoom: {0},'.format(zoom_level))
req.write('center: new google.maps.LatLng({0},{1}),'.format(center_lat, center_long))
# End if
%>
scrollwheel: false,
mapTypeId: google.maps.MapTypeId.TERRAIN,
mapTypeControl: false,
streetViewControl: false,
panControl: false
};
var stylez = [
{
featureType: "all",
elementType: "all",
stylers: [
{ saturation: -100 } // <-- THIS
]
}
];
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var mapType = new google.maps.StyledMapType(stylez, { name:"Grayscale" });
map.mapTypes.set('tehgrayz', mapType);
map.setMapTypeId('tehgrayz');
setMarkers(map, latlongs_db);
}
function setMarkers(map, locations)
{
for (var i = 0; i < locations.length; i++)
{
var loc = locations[i];
var myLatLng = new google.maps.LatLng(loc[1], loc[2]);
<%
if tiny_markers:
# Indent
%>
var marker = new google.maps.Marker({
position:myLatLng,
map: map,
clickable: false,
size:(10, 10),
color:"00ff00",
icon:'/qiime/img/blue_tiny.png'
});
<%
else:
# Indent
%>
var styleMaker1 = new StyledMarker({
styleIcon:new StyledIcon(StyledIconTypes.MARKER,{
size:(100,100),
color:loc[4]}),
position:myLatLng,
map:map,
title:loc[0]});
<%
# End if
%>
}
}
</script>
<%
# Write out the database of points
req.write('<script type="text/javascript">')
req.write('var latlongs_db = [')
result_list=[]
public_studies = data_access.getUserAndPublicStudyNames(12169, 1, portal_type)
statement = """
select distinct 'American Gut Participant', z.latitude, z.longitude
from ag_login agl
inner join zipcodes z
on agl.zip = z.zipcode
where agl.zip is not null
"""
con = data_access.getMetadataDatabaseConnection()
cur = con.cursor()
results = cur.execute(statement)
for i, val in enumerate(results):
if val[0] and val[1] and val[2]:
study_alias = str(val[0]).replace("'", "\\'")
result_list.append("\n['{0}',{1},{2},{3},'00B2EE']".format(study_alias, val[1], val[2], str(i+1)))
req.write('%s];' % ','.join(result_list))
req.write('window.onload=initialize;</script>')
%>
</head>
<body>
<div style="width:100%; height:100%; background-color:#000;">
<div id="map_canvas" style="width:100%; height:100%; opacity:0.7;"></div>
</div>
<div class="wrapper clearfix" style="position:absolute; top:10px; left:50px; opacity:0.9;">
<div class="header clearfix">
<img id="logo" src="img/ag_logo.jpg">
</div>
</div>
<div class="wrapper clearfix" style="position:absolute; top:120px; left:50px; opacity:0.9; width:260px;">
<br>
<div class="left menuwrapper" style="width:100%;">
<ul class="menu">
<li><a href="http://www.indiegogo.com/projects/american-gut"><img class="icon" src="/qiime/img/purchase_icon.png">Join the Project!</a></li>
<li><a href="http://americangut.org"><img class="icon" src="/qiime/img/what_icon.png">What is American Gut?</a></li>
</ul>
<%
# This is the location where the user directories are written
environment_vars=req.get_options()
output_dir='%s/user_data' % environment_vars['HOME']
link_path_dir = 'studies'
if form.has_key('username'):
user_data = ag_data_access.authenticateWebAppUser(form["username"], form["password"])
if (user_data):
sess['user_data'] = user_data
sess['username'] = user_data['name']
sess['supplied_kit_id'] = form["username"]
sess.save()
url = 'fusebox.psp?page=portal.psp'
req.write('<script language=\"javascript\">window.location="{0}";</script>'.format(url))
else:
req.write("<p style='color:#FF0000;'>Invalid username/password.</p>")
# end
%>
<!-- Login form div -->
<div>
<h3 style="margin-left:5px;">Participant Log In</h3>
<table width="100%">
<tr width="100%">
<td width="30%"></td>
<td width="30%">
<form method="post" action="index.psp">
<table width="100%">
<tr><td>Kit ID</td><td><input type="text" id="username" name="username"></td></tr>
<tr><td>Password</td><td><input type="password" id="password" name="password"></td></tr>
<tr><td colspan="2"><input type="submit" value="Log In"></tr>
<tr><td colspan="2"><a href="mailto:americangut@gmail.com?subject=AGLOGINHELP&body=Please%20add%20your%20KitID%20and%20any%20other%20relevant%20information" class="small_link">I'm having trouble logging in...</a></td></tr>
</table>
</form>
</td>
<td width="30%"></td>
</tr>
</table>
</div>
<!-- End login form div -->
</div>
<%@ include file="footer.psp"%>