From e9a763bf511802ae14d132c7396a1b244dfca5ee Mon Sep 17 00:00:00 2001 From: Luca Hammer Date: Thu, 31 Dec 2015 18:48:10 +0100 Subject: [PATCH] fixed tutorial/tweetloading --- default/main/templates/bit/script.html | 29 +++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/default/main/templates/bit/script.html b/default/main/templates/bit/script.html index b03e4c4..14123c6 100644 --- a/default/main/templates/bit/script.html +++ b/default/main/templates/bit/script.html @@ -20,6 +20,7 @@ /* Inspired by Tinder and Nikolay Talanov http://codepen.io/suez/*/ var first = true; var ratings = []; + var loggedIn = false; function Rating(a,p,n) { this.a = a; @@ -66,12 +67,26 @@ } $(document).ready(function() { - - function replaceCards(){ - if (first == true){ + if($("span.fa-sign-in").length){ + loggedIn = false; + } + else{ + loggedIn = true; + } + + function replaceCards(){ + + + if (first == true && loggedIn == true){ first = false; + ratings = []; $("table.ratings").replaceWith("
") } + if (first == true && loggedIn == false) { + $("div.demo__card-cont").replaceWith('
Sign in with Twitter
') + } + if (first == false && loggedIn == true) { + $("div.demo__card-cont").replaceWith('
'); $.getJSON('tweets.json', function(data) { //console.log("got new tweets"); newCards = '
'; @@ -89,7 +104,7 @@ }).fail( function(data, textStatus, error) { console.error("getJSON failed, status: " + textStatus + ", error: "+error); }); - }; + }}; var animating = false; @@ -99,6 +114,8 @@ var pullDeltaX = 0; var deg = 0; var $card, $cardReject, $cardLike; + if (loggedIn == true){ + replaceCards();} function pullChange() { //What happens while moving a card animating = true; @@ -138,9 +155,7 @@ cardsCounter++; if (cardsCounter === numOfCards) { cardsCounter = 0; - ratings = []; - $("div.demo__card-cont").replaceWith('
'); - //$(".demo__card").removeClass("below"); + //$(".demo__card").removeClass("below"); replaceCards(); //loads new deck of cards } }, 300);