diff -r 303081a52dbf -r d41e19b3b043 client/js/tweetanim.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/js/tweetanim.js Sun Feb 19 22:53:19 2012 +0100 @@ -0,0 +1,209 @@ +var tweetQueue = []; +var isAnimating = false; +var countTweets = 0; +var isPlayingTweets = false; // auto start +var SPEED_TWEETS = 10; +var MAX_VOTES = 25; +var DUMP_TWEETS = 10; +var toDel = []; + +var current_tweet = null; +var current_past_tweet = 0; + +var ts = []; + +var b = 0; + +var defaultTweet = { + created_at: "Sun, 19 Feb 2012 19:12:15 +0000", + date_value: 1329678735000, + from_user: "chateaudeau", + from_user_id: 164810536, + from_user_id_str: "164810536", + from_user_name: "Olivia Duchâteau", + geo: null, + id: 171311150900854800, + id_str: "171311150900854784", + iso_language_code: "fr", + profile_image_url: "http://a2.twimg.com/profile_images/1481618117/clip_image00212_normal.jpg", + profile_image_url_https: "https://si0.twimg.com/profile_images/1481618117/clip_image00212_normal.jpg", + source: "<a href="http://phnxapp.com" rel="nofollow">phnx</a>", + text: "RT @LeProf_Higgins: Le carton rouge à Sarkozy, on a eu l'idée avant MLP mais le mien sera rouge, puis rose, mais pas brun !", + to_user: null, + to_user_id: null, + to_user_id_str: null, + to_user_name: null, +}; + +var TweetAnim = { + + init: function() { + + var html = getDefaultTweet(); + $('#tweet-container').fadeOut(0).html(html).fadeIn(2000, function() { + $(this).fadeOut(500, function() { + isPlayingTweets=true; + $(this).html("").fadeIn(); + }); + }); + + + + }, + queueTweet: function(t) { + console.log("Queued " + t.text); + tweetQueue.push({t: t, anim: true}); + $('#nbr-mesure-new').html(tweetQueue.length); + /* + if(tweetQueue.length>0) + document.getElementById('btn-tweet-next').style.visibility="visible"; + */ + }, + + shiftQueue: function() { + if(tweetQueue.length==0) { + $('#tweet-container').html(getDefaultTweet()); + } + if((tweetQueue.length>0) && (!isAnimating)) { + countTweets++; + isAnimating = true; + var q = tweetQueue.shift(); + this.showTweet(q.t, q.anim); + + } + + }, + + skipQueue: function() { + + if((tweetQueue.length>0) && (current_tweet!=null)) { + countTweets++; + isAnimating = true; + $('#tweet_anim_'+ current_tweet.id_str).dequeue(); + TweetAnim.animate(current_tweet, true); + var q = tweetQueue.shift(); + this.showTweet(q.t, true); + } + }, + + showTweet: function(t, anim) { + + var tweetId = "tweet_anim_" + t.id_str; + var imgId = "img_" + t.id_str; + + if(anim) + current_tweet = t; + + var htmlStr = "