Permalink
Browse files

Uses JSON instead of Tabletop so Google will hopefully stop throttlin…

…g us
  • Loading branch information...
ktbee committed Aug 4, 2017
1 parent 4dd2989 commit d62c299f4a43874fdb814ab5c228e9b40994f6b4
Showing with 19 additions and 15 deletions.
  1. +19 −14 js/app.js
  2. +0 −1 tips/index.html
View
@@ -1,5 +1,5 @@
$(document).ready(function($) {
var tabletopData;
var googleSheetJSON;
// This is a click event that allows us to trigger the randomize data funtion
$('.js--next-suggestion').on('click', function(event) {
@@ -9,32 +9,37 @@ $(document).ready(function($) {
opacity: 0
}, 500, 'easeOutExpo',
function() {
randomizeData(tabletopData);
randomizeData(googleSheetJSON);
$('.animate-content').transition({ opacity: 1 });
});
});
// This initially gets the data from the spreadheet and transforms it into an object
function getCardData() {
Tabletop.init( { key: 'https://docs.google.com/spreadsheets/d/1ZqCUv_Ps0lHS0_I8Onk_xcdP9ThUS2ALtmxre5o7h5Q/pub?output=csv',
callback: function(data, tabletop) {
tabletopData = data;
randomizeData(tabletopData);
if($('.beating-hearts-baby').length) {
$('body').removeClass('beating-hearts-baby');
}
},
simpleSheet: true } );
$.getJSON('https://spreadsheets.google.com/feeds/list/1ZqCUv_Ps0lHS0_I8Onk_xcdP9ThUS2ALtmxre5o7h5Q/od6/public/values?alt=json',
function(data){
googleSheetJSON = data.feed.entry;
randomizeData(googleSheetJSON);
});
if($('.beating-hearts-baby').length) {
$('body').removeClass('beating-hearts-baby');
}
}
// Randomize
function randomizeData(data) {
var dbRow = Math.random() * (data.length - 1) + 1;
dbRow = Math.round(dbRow);
var suggestionData = data[dbRow];
var jsonRow = data[dbRow];
var suggestionData = {
type: data[dbRow].gsx$type.$t,
name: data[dbRow].gsx$name.$t,
suggestion: data[dbRow].gsx$suggestion.$t,
comment: data[dbRow].gsx$comment.$t,
};
var elements = ['type', 'name', 'suggestion', 'comment'];
// Grab the content and put 'er in
View
@@ -67,7 +67,6 @@ <h1 class="suggestion" id="suggestion"></h1>
</div>
</div>
<button class="next-suggestion js--next-suggestion">Next suggestion</button>
<script src='https://cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.5.1/tabletop.min.js'></script>
<script type="text/javascript" src="../js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../js/jquery.transit.js"></script>
<script type="text/javascript" src="../js/app.js"></script>

0 comments on commit d62c299

Please sign in to comment.