Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Promises example, plus removing nsp for npm audit success
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoma committed Oct 6, 2019
1 parent 8381c92 commit 43663e7
Show file tree
Hide file tree
Showing 3 changed files with 593 additions and 690 deletions.
31 changes: 31 additions & 0 deletions examples/simple/promise.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<body>

<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() {
Tabletop.init( {
key: public_spreadsheet_url,
simpleSheet: true
})
.then(showInfo)
}

window.addEventListener('DOMContentLoaded', init)

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>
Loading

0 comments on commit 43663e7

Please sign in to comment.