Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

Commit

Permalink
fixed tutorial/tweetloading
Browse files Browse the repository at this point in the history
  • Loading branch information
lucahammer committed Dec 31, 2015
1 parent 9201c96 commit e9a763b
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions default/main/templates/bit/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("<table class='ratings'></table>")
}
if (first == true && loggedIn == false) {
$("div.demo__card-cont").replaceWith('<div class="demo__card-cont"><a class="btn btn-lg btn-block btn-social btn-twitter" href="https://wischwasch2.appspot.com/signin/twitter/?next=https%3A%2F%2Fwischwasch2.appspot.com%2F&amp;remember=true" title="" rel="nofollow"><span class="fa fa-twitter"></span>Sign in with Twitter</a></div>')
}
if (first == false && loggedIn == true) {
$("div.demo__card-cont").replaceWith('<div class="demo__card-cont"><div class="holder"><div class="circle"></div><div class="circle"></div><div class="circle"></div><div class="circle"></div><div class="circle"></div></div></div>');
$.getJSON('tweets.json', function(data) {
//console.log("got new tweets");
newCards = '<div class="demo__card-cont">';
Expand All @@ -89,7 +104,7 @@
}).fail( function(data, textStatus, error) {
console.error("getJSON failed, status: " + textStatus + ", error: "+error);
});
};
}};


var animating = false;
Expand All @@ -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;
Expand Down Expand Up @@ -138,9 +155,7 @@
cardsCounter++;
if (cardsCounter === numOfCards) {
cardsCounter = 0;
ratings = [];
$("div.demo__card-cont").replaceWith('<div class="demo__card-cont"><div class="holder"><div class="circle"></div><div class="circle"></div><div class="circle"></div><div class="circle"></div><div class="circle"></div></div></div>');
//$(".demo__card").removeClass("below");
//$(".demo__card").removeClass("below");
replaceCards(); //loads new deck of cards
}
}, 300);
Expand Down

0 comments on commit e9a763b

Please sign in to comment.