forked from amy-usds/covid-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse-test.html
53 lines (34 loc) · 1.46 KB
/
parse-test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html>
<body>
<p id="food">Test</p>
<h1>Tabletop.js test</h1>
<table id="food"></table>
<p>View the <a href="https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AmYzu_s7QHsmdDNZUzRlYldnWTZCLXdrMXlYQzVxSFE&output=html" target="_blank">source sheet</a>. Get Tabletop.js <a href="https://github.com/jsoma/tabletop" target="_blank">here</a>.</p>
<script src='https://cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.5.1/tabletop.min.js'></script>
<script type='text/javascript'>
// https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AmYzu_s7QHsmdDNZUzRlYldnWTZCLXdrMXlYQzVxSFE&output=html
// Note - in a newer Google Sheets URL, the "key" is between the slashes
// 1ReMXiz9K7p70yglhq1BAFsaIfUalSzq30wiXtT61GFw is the "key" from: https://docs.google.com/spreadsheets/d/1ReMXiz9K7p70yglhq1BAFsaIfUalSzq30wiXtT61GFw/pubhtml
var public_spreadsheet_url = '2PACX-1vSjFNAjqYlHd1OU6RC8zy0WqJabWYRofAIscsdiLxxp86xLdInHv3PFMBQwb69YRXmq2ygicM-aH6tp';
function init() {
Tabletop.init( { key: public_spreadsheet_url,
callback: showInfo,
simpleSheet: true } );
}
function showInfo(data) {
var html = "<tr>";
// double for-loops to do rows, cells in a table
for ( i = 0; i < data.length; i++ ) {
for ( prop in data[i] ) {
html += "<td>" + data[i][prop] + "</td>";
}
html += "</tr><tr>";
}
document.getElementById("food").innerHTML = html;
}
// call the function
init();
</script>
</body>
</html>