Created
September 8, 2015 22:38
-
-
Save adunkman/ddd00f8132d4567e5eae to your computer and use it in GitHub Desktop.
A quick proof-of-concept to use Google Sheets as a backend.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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