Last active
May 4, 2020 00:11
-
-
Save jasonclark/2585071 to your computer and use it in GitHub Desktop.
booklist javascript (jQuery) - calling google spreadsheet api, parsing response
This file contains 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
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
//source Google Sheets file is https://docs.google.com/spreadsheets/d/1rX4_fInsYS7vOGpnXm1UklZgvU27FXl3UYu9lx9RHHU/ | |
$(function listBooks() { | |
$.getJSON( "https://spreadsheets.google.com/feeds/list/1rX4_fInsYS7vOGpnXm1UklZgvU27FXl3UYu9lx9RHHU/1/public/full?alt=json", | |
function (data) { | |
$('div#book-list').append('<ul class="items"></ul>'); | |
$.each(data.feed.entry, function(i,entry) { | |
var item = '<span style="display:none">' + entry.id.$t + '</span>'; | |
item += '<img src="https://covers.openlibrary.org/b/isbn/' + entry.gsx$isbn.$t + '-S.jpg"/>'; | |
item += '<span class="meta"><a href="https://www.worldcat.org/isbn/' + entry.gsx$isbn.$t + '">' + entry.title.$t + '</a>'; | |
item += '<br/>Author: ' + entry.gsx$author.$t; | |
if (entry.gsx$notes.$t) { | |
item += '<br/>Description: ' + entry.gsx$notes.$t; | |
} | |
$('.items').append('<li>' + item + '</span></li>'); | |
}); | |
}); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure you would be able to use a non-public spreadsheet as the functions rely on generated RSS/ATOM feeds from a published sheet. More information about the Google Spreadsheet API can be found at https://developers.google.com/google-apps/spreadsheets/ but from what I'm reading there you will need to 'publish to web' to make this work. Good luck!