diff -r 978c4a0e0095 -r d473ebde73a3 client/js/tweetanim.js --- a/client/js/tweetanim.js Tue Feb 21 14:13:44 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,221 +0,0 @@ -var tweetQueue = []; -var isAnimating = false; -var countTweets = 0; -var isPlayingTweets = false; // auto start -var SPEED_TWEETS = 10; -var MAX_VOTES = 10; -var DUMP_TWEETS = 10; -var toDel = []; - -var current_tweet = null; -var current_past_tweet = 0; - -var ts = []; - -var candidats = Array(4); - -for(var h= 0; h < 4; h++) { - toDel[h] = []; -} - -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) { - - 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 = "
"; - htmlStr += " "; - htmlStr += "
"; - htmlStr += "
"; - htmlStr += " "+t.from_user+""; - htmlStr += " "+t.from_user_name+""; - htmlStr += "
"+t.text+"
"; - htmlStr += " "; - htmlStr += "
"; - - $('#tweet-container').html(htmlStr); - $('#nbr-mesure-show').html(countTweets); - $('#nbr-mesure-new').html(tweetQueue.length); - /* - if(tweetQueue.length>0) - document.getElementById('btn-tweet-next').style.visibility="visible"; - else - document.getElementById('btn-tweet-next').style.visibility="hidden"; -*/ - - if(anim) { - TweetAnim.animate(t, true); - - $('#'+tweetId).hover(function() { - $(this).stop(true, true).fadeIn(); - }, function() { - TweetAnim.animate(t, true); - }); - } - }, - - animate: function(t, doSshift) { - var tweetId = "tweet_anim_" + t.id_str; - - t.cat = t.from_user_id%4; - createBallTweetForce(t); - - - // Pour expérimenter le balayage de tout le podium - //setInterval(function() {defaultTweet.cat = b%4; createBallTweetForce(defaultTweet); b++;}, 500); - - - - isAnimating = false; - if(doSshift) - TweetAnim.shiftQueue(); - - - toDel[t.cat].push(t); - checkSilos(); - - - } -} - - -function getDefaultTweet() { - - var htmlStr = "
"; - htmlStr += " "; - htmlStr += "
"; - htmlStr += "
"; - htmlStr += " Bubble T"; - htmlStr += " tea or tweet ?"; - htmlStr += " "; - htmlStr += "
maintenant
"; - - return htmlStr; - -} - -function checkSilos() { - - for(var j=0; j<4; j++) { - if(toDel[j].length>MAX_VOTES) { - - var ids = toDel[j].shift(); - world.DestroyBody(b2bod[ids.id_str]); - - - $('#'+ids.id_str).delay(10).hide("slow").queue(function() { - $(this).remove(); - }); - } - } -} -/* - -function emptySilos() { - console.log("emptySilos"); - - var toDel2 = []; - var m =0; - - for(var k=0; k