nyc-bookstores/node_modules/tabletop/examples/proxy/index.html

53 lines
1.9 KiB
HTML
Raw Normal View History

2013-05-27 20:45:59 +00:00
<!DOCTYPE html>
<html>
<body>
<div id="table_info"></div>
<div id="explanation"></div>
<h2>Let's talk about cats</h2>
<ul id="cats"></ul>
<h2>Let's learn a thing or two</h2>
<ul id="courses"></ul>
<!-- Don't need jQuery for Tabletop, but using it for this example -->
<script type="text/javascript" src="../common/jquery.js"></script>
<script type="text/javascript" src="../../src/tabletop.js"></script>
<script type="text/javascript">
var public_spreadsheet_url = 'https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AmYzu_s7QHsmdE5OcDE1SENpT1g2R2JEX2tnZ3ZIWHc&output=html';
$(document).ready( function() {
Tabletop.init( { key: public_spreadsheet_url,
callback: showInfo,
proxy: 'https://s3.amazonaws.com/flatware-live',
debug: true } )
})
function showInfo(data, tabletop) {
$("#table_info").text("We found the tables " + tabletop.model_names.join(", "));
$.each( tabletop.sheets(), function(i, sheet) {
$("#table_info").append("<p>" + sheet.name + " has " + sheet.column_names.join(", ") + "</p>");
});
$.each( tabletop.sheets("Cats").all(), function(i, cat) {
var cat_li = $('<li><h4>' + cat.name + '</h4></li>')
cat_li.append(cat.description);
cat_li.appendTo("#cats");
})
$.each( tabletop.sheets("Courses").all(), function(i, course) {
var cat_li = $('<li><h4>' + course.title + '</h4></li>')
cat_li.append(course.description);
cat_li.append("<p>Cost: $" + course.cost + "</p>");
cat_li.appendTo("#courses");
})
}
document.write("The published spreadsheet is located at <a target='_new' href='" + public_spreadsheet_url + "'>" + public_spreadsheet_url + "</a>");
</script>
</body>
</html>