Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 283 lines (234 sloc) 8.833 kB
<%
#!/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 = 4
# 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"%>
Jump to Line
Something went wrong with that request. Please try again.