Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A quick proof-of-concept to use Google Sheets as a backend.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script>
<script>
(function () {
var key = "1HwGVE-MqVmeLwcfljmBmuTD55arVxsElG3C2urJadAw";
var url = "https://spreadsheets.google.com/feeds/list/" + key + "/od6/public/values?alt=json";
var render = function (entries) {
var $ul = $("ul");
_.each(entries, function (entry) {
$ul.append($("<li>").text(entry.name + ": " + entry.anotherattribute));
});
};
$.ajax(url, {
success: function (data) {
var entries = data.feed.entry;
render(_.map(entries, function (entry) {
var object = {};
_.each(entry, function (value, key) {
if (key.indexOf("gsx$") == 0) {
object[key.substr(4)] = value.$t;
}
});
return object;
}));
}
});
})();
</script>
</head>
<body>
<h1>Sheets POC</h1>
<p>This site loads entries from a google spreadsheet, and shows them below. Simple proof-of-concept.</p>
<ul class="js-entries">
</ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.