diff -r 7b76d97e3051 -r 1e47b1f9f42d client/js/main.js --- a/client/js/main.js Tue Feb 21 22:47:19 2012 +0100 +++ b/client/js/main.js Wed Feb 22 11:06:11 2012 +0100 @@ -109,6 +109,31 @@ }); } +function updatePodiumAndLabels(_counts) { + myPodium.update(_counts); + $("#podium-chiffres").html(_counts.map(function(_c) { + return '
  • ' + _c + '
  • ' + }).join("")); +} + +function getPodium() { + $.getJSON(serverUrl + + 'podium/' + + Math.floor(startHour/1000) + + '/' + + columnKeywords.map(function(_c) { + return encodeURIComponent(_c); + }).join(',') + + '?callback=?', + function(_data) { + var _counts = columnKeywords.map(function(_c) { + return _data.podium[_c] || 0; + }); + $("#btv-cp-nb-tweets").html(_data.total); + updatePodiumAndLabels(_counts); + }); +} + $(function() { columnCounts = columnKeywords.map(function() { return 0; @@ -124,6 +149,9 @@ }, 500); myPodium = new Btv_Podium([0,0,0,0], { minHeight: 50 }); + if (typeof serverUrl != "undefined") { + setInterval(getPodium, 2000); + } $("#podium-labels").html(columnKeywords.map(function(_w) { return '
  • ' + _w + '
  • ' @@ -132,19 +160,17 @@ myTweetSource = new Btv_TweetSource({ keywords: searchKeywords }); - myTweetSource.setOnNewTweets(function() { - var _filtered = this.afterDate(startHour); - $("#btv-cp-nb-tweets").html(_filtered.count()); - var _counts = []; - for (var _i = 0; _i < columnKeywords.length; _i++) { - _counts.push(_filtered.search(columnKeywords[_i]).count()); + updateLastTweetList(); + if (typeof serverUrl == "undefined") { + var _filtered = this.afterDate(startHour); + $("#btv-cp-nb-tweets").html(_filtered.count()); + var _counts = []; + for (var _i = 0; _i < columnKeywords.length; _i++) { + _counts.push(_filtered.search(columnKeywords[_i]).count()); + } + updatePodiumAndLabels(_counts); } - updateLastTweetList(); - myPodium.update(_counts); - $("#podium-chiffres").html(_counts.map(function(_c) { - return '
  • ' + _c + '
  • ' - }).join("")); }); myQueueManager = new Btv_TweetQueueManager(myTweetSource, function(_t) { var _cat = -1;