Created
April 7, 2014 07:36
-
-
Save cheneytsai/10016156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Proof of Concept: Water Projects" /> | |
<script type="text/javascript" src="https://www.google.com/jsapi"></script> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" /> | |
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script> | |
<meta charset="utf-8"> | |
<title>Example: Water Project Cards</title> | |
</head> | |
<body> | |
<!--Nav Bar--> | |
<nav class="navbar navbar-default navbar-fixed-top" role="navigation"> | |
<div class="container"> | |
<h4>Water Projects</h4> | |
</div> | |
</nav> | |
<!--Main Stuff--> | |
<div class="main-content"> | |
<div class="container"> | |
<!--Project Cards go in Here--> | |
<div class="row" id="card-holder"> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load the Visualization API | |
google.load('visualization', '1.0', | |
{ | |
'packages':['table'] | |
}); | |
// Call a function when API has loaded | |
google.setOnLoadCallback(getQuery); | |
function getQuery() { | |
var query = new google.visualization.Query( | |
'https://docs.google.com/spreadsheet/ccc?key=0AjENGhln_vxfdFlOSzNUVGxhejN6WFdiRG5uOUlxYnc#gid=0'); | |
query.send(drawCards); | |
} | |
function drawCards(response) { | |
var dataTable = response.getDataTable(); | |
var dataObj = $.parseJSON(dataTable.toJSON()); | |
//Iterate on Each Row | |
dataObj.rows.forEach(function(row) { | |
var id = "<h5>ID: " + row.c[0].v + "</h5>"; | |
var country = "<h5>Country: " + row.c[1].v + "</h5>"; | |
var partner = "<h5>Partner: " + row.c[2].v + "</h5>"; | |
var newCard = $('<div class="col-md-4"><div class="card">' + id + country + partner + '</div></div>'); | |
$('#card-holder').append(newCard); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.main-content { | |
padding-top: 50px; | |
} | |
.card { | |
padding: 10px; | |
margin: 40px 0px 0px 0px; | |
border: 1px solid #AAA; | |
height: 400px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment