tabletop
Version:
**Tabletop.js** takes a Google Spreadsheet and makes it easily accessible through JavaScript. With zero dependencies!
35 lines (28 loc) • 1.37 kB
HTML
<html>
<body>
<p>Food sorted by 'Name' column, reversed:</p>
<p id="food"></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';
function init() {
// because we're using orderby: 'name' it will sort by the 'name' column
// and reverse: true will reverse that sort, so it should be in reverse
// alphabetical order
Tabletop.init( { key: public_spreadsheet_url,
callback: showInfo,
simpleSheet: true,
orderby: 'Name',
reverse: true } );
}
window.addEventListener('DOMContentLoaded', init)
function showInfo(data) {
// data comes through as a simple array since simpleSheet is turned on
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>