1 var myPodium, |
1 var myPodium, |
2 myTweetSource, |
2 myTweetSource, |
3 myQueueManager; |
3 myQueueManager; |
|
4 |
|
5 var columnCounts, |
|
6 onlineTweets = [], |
|
7 dumpIsPaused = false; |
|
8 |
|
9 var MAX_TWEETS_BEFORE_DUMP = 20, |
|
10 TWEETS_TO_DUMP_AT_ONCE = 10; |
4 |
11 |
5 function updateLastTweetList() { |
12 function updateLastTweetList() { |
6 var _filtered = myTweetSource.afterDate(startHour), |
13 var _filtered = myTweetSource.afterDate(startHour), |
7 _txtFilter = $("#btv-cp-champ-filtre").val(), |
14 _txtFilter = $("#btv-cp-champ-filtre").val(), |
8 _reFilter = null; |
15 _reFilter = null; |
9 if (_txtFilter.length > 1) { |
16 if (_txtFilter.length > 1) { |
10 _filtered = _filtered.search(_txtFilter); |
17 _filtered = _filtered.search(_txtFilter); |
11 _reFilter = regexpFromText(_txtFilter); |
18 _reFilter = regexpFromText(_txtFilter); |
|
19 for (var _i = 0; _i < onlineTweets.length; _i++) { |
|
20 if (onlineTweets[_i].text.search(_reFilter) == -1) { |
|
21 $('#'+onlineTweets[_i].id_str).fadeTo(250, 0.1); |
|
22 } else { |
|
23 $('#'+onlineTweets[_i].id_str).fadeTo(250, 1); |
|
24 } |
|
25 } |
|
26 } else { |
|
27 for (var _i = 0; _i < onlineTweets.length; _i++) { |
|
28 $('#'+onlineTweets[_i].id_str).fadeTo(250, 1); |
|
29 } |
12 } |
30 } |
13 $('#btv-cp-liste-tweets-tout').html( |
31 $('#btv-cp-liste-tweets-tout').html( |
14 _filtered.reverse().slice(0,20).map(function(_t) { |
32 _filtered.reverse().slice(0,20).map(function(_t) { |
15 return '<li onclick="addTweetToSelection(\'' |
33 return '<li onclick="addTweetToSelection(\'' |
16 + _t.id_str |
34 + _t.id_str |
27 |
45 |
28 function addTweetToSelection(tweetId) { |
46 function addTweetToSelection(tweetId) { |
29 var _t = myTweetSource.tweetById(tweetId); |
47 var _t = myTweetSource.tweetById(tweetId); |
30 if (_t) { |
48 if (_t) { |
31 $("#btv-cp-liste-tweets-selection").prepend( |
49 $("#btv-cp-liste-tweets-selection").prepend( |
32 '<li onclick="showTweetOnScreen(\'' |
50 '<li><a title="Afficher sur l\'écran" href="#" onclick="showTweetOnScreen(\'' |
33 + _t.id_str |
51 + _t.id_str |
34 + '\'); return false;"><a title="Afficher sur l\'écran" href="#"><span class="btv-cp-tweet-date">' |
52 + '\'); return false;"><span class="btv-cp-tweet-date">' |
35 + _t.created_at.match(/\d+:\d+:\d+/)[0] |
53 + _t.created_at.match(/\d+:\d+:\d+/)[0] |
36 + '</span> <span class="btv-cp-tweet-from">@' |
54 + '</span> <span class="btv-cp-tweet-from">@' |
37 + _t.from_user |
55 + _t.from_user |
38 + '</span> <span class="btv-cp-tweet-text">' |
56 + '</span> <span class="btv-cp-tweet-text">' |
39 + _t.text |
57 + _t.text |
40 + '</span><div class="btv-cp-tweet-button btv-cp-tweet-show"></div></a></li>' |
58 + '</span><div class="btv-cp-tweet-button btv-cp-tweet-show"></div></a>' |
|
59 + '<a title="Supprimer de cette liste" href="#" onclick="$(this).parent().detach(); return false;"><div class="btv-cp-tweet-button btv-cp-tweet-remove"></div></a></li>' |
41 ); |
60 ); |
42 } |
61 } |
43 } |
62 } |
44 |
63 |
45 function showTweetOnScreen(tweetId) { |
64 function showTweetOnScreen(tweetId) { |
57 +'</p>').show(); |
76 +'</p>').show(); |
58 $(".btv-cp-hide-tweets").show(); |
77 $(".btv-cp-hide-tweets").show(); |
59 } |
78 } |
60 } |
79 } |
61 |
80 |
|
81 function showTooltip(_t, _x, _y) { |
|
82 $("#btv-tooltip").html('<img class="btv-tooltip-image" src="' |
|
83 + _t.profile_image_url |
|
84 + '" /><p class="btv-tooltip-name"><span>' |
|
85 + _t.from_user |
|
86 + '</span> (<span>' |
|
87 + _t.from_user_name |
|
88 +'</span>)</p><p>' |
|
89 + _t.text |
|
90 +'</p><div class="btv-tooltip-arrow"></div>').show().css({ |
|
91 "left": _x + "px", |
|
92 "top": _y + "px", |
|
93 }) |
|
94 } |
|
95 |
|
96 function hideTooltip() { |
|
97 $("#btv-tooltip").hide(); |
|
98 } |
|
99 |
|
100 function showControlPanel() { |
|
101 $("#btv-cp-container").dequeue().animate({ |
|
102 "left": 0 |
|
103 }); |
|
104 } |
|
105 |
|
106 function hideControlPanel() { |
|
107 $("#btv-cp-container").dequeue().animate({ |
|
108 "left": "-315px" |
|
109 }); |
|
110 } |
|
111 |
62 $(function() { |
112 $(function() { |
|
113 columnCounts = columnKeywords.map(function() { |
|
114 return 0; |
|
115 }) |
63 setInterval(function() { |
116 setInterval(function() { |
64 var _t = Math.floor((new Date() - startHour)/1000), |
117 var _t = Math.floor((new Date() - startHour)/1000), |
65 _s = _t % 60, |
118 _s = _t % 60, |
66 _m = Math.floor(_t/60) % 60, |
119 _m = Math.floor(_t/60) % 60, |
67 _h = Math.floor(_t/3600); |
120 _h = Math.floor(_t/3600); |
100 _cat = i; |
153 _cat = i; |
101 break; |
154 break; |
102 } |
155 } |
103 } |
156 } |
104 if (_cat != -1) { |
157 if (_cat != -1) { |
105 if (_cat == 2) { |
158 _t.cat = _cat; |
106 console.log(_t.text); |
159 columnCounts[_cat]++; |
|
160 onlineTweets.push(_t); |
|
161 createBallTweetForce(_t); |
|
162 if (!dumpIsPaused) { |
|
163 for (var _i = 0; _i < columnCounts.length; _i++) { |
|
164 if (columnCounts[_cat] > MAX_TWEETS_BEFORE_DUMP) { |
|
165 var toDel = onlineTweets.splice(0,TWEETS_TO_DUMP_AT_ONCE); |
|
166 |
|
167 for (var _j = 0; _j < toDel.length; _j++) { |
|
168 var _id = toDel[_j].id_str; |
|
169 world.DestroyBody(b2bod[_id]); |
|
170 |
|
171 $('#'+_id).fadeTo(500, 0, function() { |
|
172 $(this).remove(); |
|
173 }); |
|
174 } |
|
175 |
|
176 // Regenerate column counts |
|
177 columnCounts = columnKeywords.map(function() { |
|
178 return 0; |
|
179 }); |
|
180 for (var _k = 0; _k < onlineTweets.length; _k++) { |
|
181 columnCounts[onlineTweets[_k].cat]++; |
|
182 } |
|
183 break; |
|
184 } |
|
185 } |
107 } |
186 } |
108 _t.cat = _cat; |
187 } |
109 createBallTweetForce(_t); |
188 }); |
110 } |
189 |
111 }); |
190 $("#btv-cp-container").mouseover(showControlPanel).mouseout(hideControlPanel); |
112 |
191 |
113 $("#btv-cp-champ-filtre").keyup(function() { |
192 $("#btv-cp-champ-filtre").keyup(function() { |
114 updateLastTweetList(); |
193 updateLastTweetList(); |
115 }); |
194 }); |
116 $("#btv-cp-clear-filtre").click(function() { |
195 $("#btv-cp-clear-filtre").click(function() { |
128 } else { |
207 } else { |
129 $(this).addClass("btv-cp-status-pause"); |
208 $(this).addClass("btv-cp-status-pause"); |
130 $(this).removeClass("btv-cp-status-play"); |
209 $(this).removeClass("btv-cp-status-play"); |
131 } |
210 } |
132 }); |
211 }); |
|
212 $("#btv-cp-cont-pause-aval").click(function() { |
|
213 dumpIsPaused = !dumpIsPaused |
|
214 if (dumpIsPaused) { |
|
215 $(this).removeClass("btv-cp-status-pause"); |
|
216 $(this).addClass("btv-cp-status-play"); |
|
217 } else { |
|
218 $(this).addClass("btv-cp-status-pause"); |
|
219 $(this).removeClass("btv-cp-status-play"); |
|
220 } |
|
221 }); |
133 }); |
222 }); |