|
10
|
1 |
var myPodium, |
|
|
2 |
myTweetSource, |
|
|
3 |
myQueueManager; |
|
|
4 |
|
|
|
5 |
function updateLastTweetList() { |
|
|
6 |
var _filtered = myTweetSource.afterDate(startHour), |
|
|
7 |
_txtFilter = $("#btv-cp-champ-filtre").val(), |
|
|
8 |
_reFilter = null; |
|
|
9 |
if (_txtFilter.length > 1) { |
|
|
10 |
_filtered = _filtered.search(_txtFilter); |
|
|
11 |
_reFilter = regexpFromText(_txtFilter); |
|
|
12 |
} |
|
|
13 |
$('#btv-cp-liste-tweets-tout').html( |
|
|
14 |
_filtered.reverse().slice(0,20).map(function(_t) { |
|
|
15 |
return '<li onclick="addTweetToSelection(\'' |
|
|
16 |
+ _t.id_str |
|
|
17 |
+ '\'); return false;"><a title="Ajouter à la sélection" href="#"><span class="btv-cp-tweet-date">' |
|
|
18 |
+ _t.created_at.match(/\d+:\d+:\d+/)[0] |
|
|
19 |
+ '</span> <span class="btv-cp-tweet-from">' |
|
|
20 |
+ ( _reFilter ? ('@' + _t.from_user).replace(_reFilter, '<span class="btv-cp-highlight">$1</span>') : ('@' + _t.from_user) ) |
|
|
21 |
+ '</span> <span class="btv-cp-tweet-text">' |
|
|
22 |
+ ( _reFilter ? _t.text.replace(_reFilter, '<span class="btv-cp-highlight">$1</span>') : _t.text ) |
|
|
23 |
+ '</span><div class="btv-cp-tweet-button btv-cp-tweet-add"></div></a></li>' |
|
|
24 |
}).join('') |
|
|
25 |
); |
|
|
26 |
} |
|
|
27 |
|
|
|
28 |
function addTweetToSelection(tweetId) { |
|
|
29 |
var _t = myTweetSource.tweetById(tweetId); |
|
|
30 |
if (_t) { |
|
|
31 |
$("#btv-cp-liste-tweets-selection").prepend( |
|
13
|
32 |
'<li><a title="Afficher sur l\'écran" href="#" onclick="showTweetOnScreen(\'' |
|
|
33 |
+ _t.id_str |
|
|
34 |
+ '\'); return false;"><span class="btv-cp-tweet-date">' |
|
|
35 |
+ _t.created_at.match(/\d+:\d+:\d+/)[0] |
|
|
36 |
+ '</span> <span class="btv-cp-tweet-from">@' |
|
|
37 |
+ _t.from_user |
|
|
38 |
+ '</span> <span class="btv-cp-tweet-text">' |
|
|
39 |
+ _t.text |
|
|
40 |
+ '</span><div class="btv-cp-tweet-button btv-cp-tweet-show"></div></a><a class="btv-cp-tweet-remove" href="#" onclick="$(this).parent().detach(); return false;">×</a></li>' |
|
10
|
41 |
); |
|
|
42 |
} |
|
|
43 |
} |
|
|
44 |
|
|
|
45 |
function showTweetOnScreen(tweetId) { |
|
|
46 |
var _t = myTweetSource.tweetById(tweetId); |
|
|
47 |
console.log(_t); |
|
|
48 |
if (_t) { |
|
|
49 |
$("#btv-bigtweet").html('<img class="btv-bigtweet-image" src="' |
|
|
50 |
+ _t.profile_image_url |
|
|
51 |
+ '" /><p class="btv-bigtweet-screen-name">' |
|
|
52 |
+ _t.from_user |
|
|
53 |
+ '</p><p class="btv-bigtweet-name">' |
|
|
54 |
+ _t.from_user_name |
|
|
55 |
+'</p><p class="btv-bigtweet-text">' |
|
|
56 |
+ _t.text |
|
|
57 |
+'</p>').show(); |
|
|
58 |
$(".btv-cp-hide-tweets").show(); |
|
|
59 |
} |
|
|
60 |
} |
|
|
61 |
|
|
|
62 |
$(function() { |
|
|
63 |
setInterval(function() { |
|
|
64 |
var _t = Math.floor((new Date() - startHour)/1000), |
|
|
65 |
_s = _t % 60, |
|
|
66 |
_m = Math.floor(_t/60) % 60, |
|
|
67 |
_h = Math.floor(_t/3600); |
|
|
68 |
$("#btv-cp-temps").html( |
|
|
69 |
_h + ':' + (_m < 10 ? '0' : '') + _m + ':' + (_s < 10 ? '0' : '') + _s |
|
|
70 |
) |
|
|
71 |
}, 500); |
|
|
72 |
myPodium = new Btv_Podium([0,0,0,0], { minHeight: 50 }); |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
$("#podium-labels").html(columnKeywords.map(function(_w) { |
|
|
76 |
return '<li>' + _w + '</li>' |
|
|
77 |
}).join("")); |
|
|
78 |
|
|
|
79 |
myTweetSource = new Btv_TweetSource({ |
|
|
80 |
keywords: searchKeywords |
|
|
81 |
}); |
|
|
82 |
|
|
|
83 |
myTweetSource.setOnNewTweets(function() { |
|
|
84 |
var _filtered = this.afterDate(startHour); |
|
|
85 |
$("#btv-cp-nb-tweets").html(_filtered.count()); |
|
|
86 |
var _counts = []; |
|
|
87 |
for (var _i = 0; _i < columnKeywords.length; _i++) { |
|
|
88 |
_counts.push(_filtered.search(columnKeywords[_i]).count()); |
|
|
89 |
} |
|
|
90 |
updateLastTweetList(); |
|
|
91 |
myPodium.update(_counts); |
|
|
92 |
$("#podium-chiffres").html(_counts.map(function(_c) { |
|
|
93 |
return '<li>' + _c + '</li>' |
|
|
94 |
}).join("")); |
|
|
95 |
}); |
|
|
96 |
myQueueManager = new Btv_TweetQueueManager(myTweetSource, function(_t) { |
|
|
97 |
var _cat = -1; |
|
|
98 |
for (var i = 0; i < columnKeywords.length; i++) { |
|
|
99 |
if (_t.text.search(regexpFromText(columnKeywords[i])) != -1) { |
|
|
100 |
_cat = i; |
|
|
101 |
break; |
|
|
102 |
} |
|
|
103 |
} |
|
|
104 |
if (_cat != -1) { |
|
|
105 |
if (_cat == 2) { |
|
|
106 |
console.log(_t.text); |
|
|
107 |
} |
|
|
108 |
_t.cat = _cat; |
|
|
109 |
createBallTweetForce(_t); |
|
|
110 |
} |
|
|
111 |
}); |
|
|
112 |
|
|
|
113 |
$("#btv-cp-champ-filtre").keyup(function() { |
|
|
114 |
updateLastTweetList(); |
|
|
115 |
}); |
|
|
116 |
$("#btv-cp-clear-filtre").click(function() { |
|
|
117 |
$("#btv-cp-champ-filtre").val(""); |
|
|
118 |
updateLastTweetList(); |
|
|
119 |
return false; |
|
|
120 |
}); |
|
|
121 |
$("#btv-bigtweet, .btv-cp-hide-tweets").click(function() { |
|
|
122 |
$("#btv-bigtweet, .btv-cp-hide-tweets").hide(); |
|
|
123 |
}); |
|
|
124 |
$("#btv-cp-cont-pause-amont").click(function() { |
|
|
125 |
if (myQueueManager.playPause()) { |
|
|
126 |
$(this).removeClass("btv-cp-status-pause"); |
|
|
127 |
$(this).addClass("btv-cp-status-play"); |
|
|
128 |
} else { |
|
|
129 |
$(this).addClass("btv-cp-status-pause"); |
|
|
130 |
$(this).removeClass("btv-cp-status-play"); |
|
|
131 |
} |
|
|
132 |
}); |
|
|
133 |
}); |