tabletop
Version:
**Tabletop.js** takes a Google Spreadsheet and makes it easily accessible through JavaScript. With zero dependencies!
32 lines (25 loc) • 1.19 kB
HTML
<html>
<body>
<p id="food">Waiting for 3 seconds...</p>
<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_s7QHsmdDNZUzRlYldnWTZCLXdrMXlYQzVxSFE&output=html';
var tabletop = Tabletop.init( { key: public_spreadsheet_url,
callback: showInfo,
wait: true,
simpleSheet: true } )
setTimeout(function() {
console.log("Fetching")
tabletop.fetch()
}, 3000)
function showInfo(data) {
// data comes through as a simple array since simpleSheet is turned on
alert("Successfully processed " + data.length + " rows!")
document.getElementById("food").innerHTML = "<strong>Foods:</strong> " + [ data[0].Name, data[1].Name, data[2].Name ].join(", ");
console.log(data);
}
document.write("The published spreadsheet is located at <a target='_new' href='" + public_spreadsheet_url + "'>" + public_spreadsheet_url + "</a>");
</script>
</body>
</html>