|
169
|
1 |
/* |
|
|
2 |
* |
|
|
3 |
* Copyright 2010 Institut de recherche et d'innovation |
|
|
4 |
* contributor(s) : Samuel Huron |
|
|
5 |
* |
|
|
6 |
* contact@iri.centrepompidou.fr |
|
|
7 |
* http://www.iri.centrepompidou.fr |
|
|
8 |
* |
|
|
9 |
* This software is a computer program whose purpose is to show and add annotations on a video . |
|
|
10 |
* This software is governed by the CeCILL-C license under French law and |
|
|
11 |
* abiding by the rules of distribution of free software. You can use, |
|
|
12 |
* modify and/ or redistribute the software under the terms of the CeCILL-C |
|
|
13 |
* license as circulated by CEA, CNRS and INRIA at the following URL |
|
|
14 |
* "http://www.cecill.info". |
|
|
15 |
* |
|
|
16 |
* The fact that you are presently reading this means that you have had |
|
|
17 |
* knowledge of the CeCILL-C license and that you accept its terms. |
|
|
18 |
*/ |
|
|
19 |
// CHART TIMELINE / VERSION PROTOTYPE :: |
|
|
20 |
|
|
|
21 |
IriSP.PolemicWidget = function(Popcorn, config, Serializer) { |
|
|
22 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
|
23 |
|
|
|
24 |
this.RAWTweets; |
|
|
25 |
this.userPol = new Array(); |
|
|
26 |
this.userNoPol = new Array(); |
|
|
27 |
this.userst = new Array(); |
|
|
28 |
this.numberOfTweet = 0; |
|
|
29 |
this.Users; |
|
|
30 |
this.TweetPolemic; |
|
|
31 |
this.yMax = this.height; |
|
|
32 |
this.PaperSlider; |
|
|
33 |
this.heightOfChart; |
|
|
34 |
this.tweets = new Array(); |
|
|
35 |
|
|
|
36 |
// Make and define the Raphael area |
|
|
37 |
this.paper = Raphael(document.getElementById(this._id), config.width, config.height); |
|
|
38 |
|
|
|
39 |
}; |
|
|
40 |
|
|
|
41 |
IriSP.PolemicWidget.prototype = new IriSP.Widget(); |
|
|
42 |
|
|
|
43 |
IriSP.PolemicWidget.prototype.draw = function() { |
|
|
44 |
|
|
|
45 |
// variable |
|
|
46 |
// yMax |
|
|
47 |
var yCoef = 2; // coef for height of 1 tweet |
|
|
48 |
var frameSize = 5; // frame size |
|
|
49 |
var margin = 1; // marge between frame |
|
|
50 |
var lineSize = this.width; // timeline pixel width |
|
|
51 |
var nbrframes = lineSize/frameSize; // frame numbers |
|
|
52 |
var numberOfTweet = 0; // number of tweet overide later |
|
|
53 |
var duration = config.duration; // timescale width |
|
|
54 |
var frameLenght = lineSize/frameSize; // frame timescale |
|
|
55 |
var timeline; |
|
|
56 |
var colors = new Array("","#1D973D","#C5A62D","#CE0A15","#036AAE","#585858"); |
|
|
57 |
|
|
|
58 |
// array |
|
|
59 |
//var tweets = new Array(); |
|
|
60 |
var element = new Array(); |
|
|
61 |
var cluster = new Array(); |
|
|
62 |
var frames = new Array(frameLenght); |
|
|
63 |
var slices = new Array(); |
|
|
64 |
|
|
|
65 |
|
|
|
66 |
// Classes ======================================================================= |
|
|
67 |
var Frames = function(){ |
|
|
68 |
|
|
|
69 |
var Myclusters; |
|
|
70 |
var x; |
|
|
71 |
var y; |
|
|
72 |
var width; |
|
|
73 |
var height; |
|
|
74 |
}; |
|
|
75 |
Frames = function(json){ |
|
|
76 |
// make my clusters |
|
|
77 |
// ou Frame vide |
|
|
78 |
}; |
|
|
79 |
Frames.prototype.draw = function(){ |
|
|
80 |
}; |
|
|
81 |
Frames.prototype.zoom = function(){ |
|
|
82 |
}; |
|
|
83 |
Frames.prototype.inside = function(){ |
|
|
84 |
}; |
|
|
85 |
var Clusters = function(){ |
|
|
86 |
var Object; |
|
|
87 |
var yDist; |
|
|
88 |
var x; |
|
|
89 |
var y; |
|
|
90 |
var width; |
|
|
91 |
var height; |
|
|
92 |
}; |
|
|
93 |
Clusters = function(json){ |
|
|
94 |
// make my object |
|
|
95 |
}; |
|
|
96 |
var Tweet = function(){ |
|
|
97 |
}; |
|
|
98 |
// Classes ======================================================================= |
|
|
99 |
|
|
|
100 |
// trace function |
|
|
101 |
var traceNum = 0; |
|
|
102 |
function trace(msg,value){ |
|
|
103 |
traceNum += 1; |
|
|
104 |
__IriSP.jQuery("<div>"+traceNum+" - "+msg+" : "+value+"</div>").appendTo("#output"); |
|
|
105 |
} |
|
|
106 |
|
|
|
107 |
// Refactoring (parametere) ************************************************************ |
|
|
108 |
// color translastion |
|
|
109 |
var qTweet_0 =0; |
|
|
110 |
var qTweet_Q =0; |
|
|
111 |
var qTweet_REF=0; |
|
|
112 |
var qTweet_OK =0; |
|
|
113 |
var qTweet_KO =0; |
|
|
114 |
function colorTranslation(value){ |
|
|
115 |
if(value == "Q"){ |
|
|
116 |
qTweet_Q+=1; |
|
|
117 |
return 2; |
|
|
118 |
}else if(value =="REF"){ |
|
|
119 |
qTweet_REF+=1; |
|
|
120 |
return 4; |
|
|
121 |
}else if(value =="OK"){ |
|
|
122 |
qTweet_OK+=1; |
|
|
123 |
return 1; |
|
|
124 |
}else if(value =="KO"){ |
|
|
125 |
qTweet_KO+=1; |
|
|
126 |
return 3; |
|
|
127 |
}else if(value ==""){ |
|
|
128 |
qTweet_0+=1; |
|
|
129 |
return 5; |
|
|
130 |
} |
|
|
131 |
} |
|
|
132 |
|
|
|
133 |
|
|
|
134 |
// Refactoring (parametere) ************************************************************ |
|
|
135 |
// load tweets send in parameters |
|
|
136 |
__IriSP.jQuery.ajax({ |
|
|
137 |
dataType: "jsonp", |
|
|
138 |
url:config.metadata, |
|
|
139 |
success : function(json){ |
|
|
140 |
trace("load",""); |
|
|
141 |
// get current view (the first ???) |
|
|
142 |
view = json.views[0]; |
|
|
143 |
|
|
|
144 |
// the tweets are by definition of the second annotation type |
|
|
145 |
tweet_annot_type = null; |
|
|
146 |
if(typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) { |
|
|
147 |
tweet_annot_type = view.annotation_types[1]; |
|
|
148 |
} |
|
|
149 |
RAWTweets = json.annotations; |
|
|
150 |
|
|
|
151 |
__IriSP.jQuery.each(json.annotations, function(i,item) { |
|
|
152 |
|
|
|
153 |
var MyTime = Math.floor(item.begin/duration*lineSize); |
|
|
154 |
var Myframe = Math.floor(MyTime/lineSize*frameLenght); |
|
|
155 |
|
|
|
156 |
if (typeof(item.meta) !== "undefined" |
|
|
157 |
&& typeof(item.meta["id-ref"]) !== "undefined" |
|
|
158 |
&& item.meta["id-ref"] === tweet_annot_type) { |
|
|
159 |
|
|
|
160 |
var MyTJson = JSON.parse(item.meta['dc:source']['content']); |
|
|
161 |
|
|
|
162 |
if (item.content['polemics'] != undefined |
|
|
163 |
&& item.content['polemics'][0] != null) { |
|
|
164 |
|
|
|
165 |
|
|
|
166 |
//console.log(item.meta['dc:source']['content']); |
|
|
167 |
|
|
|
168 |
for(var j=0; j<item.content['polemics'].length; j++){ |
|
|
169 |
|
|
|
170 |
tweets[numberOfTweet] = { |
|
|
171 |
id:i, |
|
|
172 |
qualification:colorTranslation(item.content['polemics'][j]), |
|
|
173 |
yIndicator:MyTime, |
|
|
174 |
yframe:Myframe, |
|
|
175 |
title:item.content['title'], |
|
|
176 |
timeframe:item.begin, |
|
|
177 |
userId: MyTJson.id, |
|
|
178 |
userScreenName: MyTJson.screen_name, |
|
|
179 |
tsource:MyTJson |
|
|
180 |
}; |
|
|
181 |
numberOfTweet+=1; |
|
|
182 |
|
|
|
183 |
} |
|
|
184 |
} |
|
|
185 |
else { |
|
|
186 |
//trace("k = ",i); |
|
|
187 |
tweets[numberOfTweet] = { |
|
|
188 |
id:i, |
|
|
189 |
qualification:colorTranslation(""), |
|
|
190 |
yIndicator:MyTime, |
|
|
191 |
yframe:Myframe, |
|
|
192 |
title:item.content['title'], |
|
|
193 |
timeframe:item.begin, |
|
|
194 |
userId: MyTJson.id, |
|
|
195 |
userScreenName: MyTJson.screen_name, |
|
|
196 |
tsource:MyTJson |
|
|
197 |
|
|
|
198 |
}; |
|
|
199 |
numberOfTweet+=1; |
|
|
200 |
} |
|
|
201 |
|
|
|
202 |
} |
|
|
203 |
else { |
|
|
204 |
//trace("tweet qualification = ","null"); |
|
|
205 |
} |
|
|
206 |
}); |
|
|
207 |
|
|
|
208 |
DrawTweets (); |
|
|
209 |
if(numberOfTweet>0){Report();} |
|
|
210 |
|
|
|
211 |
} |
|
|
212 |
}); |
|
|
213 |
|
|
|
214 |
function pourcent(value,max){ |
|
|
215 |
var myPourcentage = Math.round(value/max*1000)/10; |
|
|
216 |
return myPourcentage; |
|
|
217 |
|
|
|
218 |
} |
|
|
219 |
function round2Dec(value){ |
|
|
220 |
var myValueRounded = Math.round(value*100)/100; |
|
|
221 |
return myValueRounded |
|
|
222 |
} |
|
|
223 |
|
|
|
224 |
|
|
|
225 |
function searchKeyValueArray(mykey,myvalue,myarray){ |
|
|
226 |
for(var i=0; i<myarray.length; i++) { |
|
|
227 |
if(myarray[i][mykey]==myvalue){ |
|
|
228 |
return i; |
|
|
229 |
console.log("trouvé !"); |
|
|
230 |
} |
|
|
231 |
} |
|
|
232 |
return true; |
|
|
233 |
} |
|
|
234 |
|
|
|
235 |
var tweetConversationel = new Array(); |
|
|
236 |
var tweetConversationelSP = 0; |
|
|
237 |
var tweetClient = new Array(); |
|
|
238 |
var tweetRetweet = new Array(); |
|
|
239 |
var maxRetweet |
|
|
240 |
function tweetRetweetCount(mytweet){ |
|
|
241 |
tweet = mytweet.tsource |
|
|
242 |
var retweetIsHere = false; |
|
|
243 |
var myRT = { |
|
|
244 |
id:'', |
|
|
245 |
tweet:tweet, |
|
|
246 |
total:1, |
|
|
247 |
SPtraine:'' |
|
|
248 |
} |
|
|
249 |
if(tweet.retweet_count>0){ |
|
|
250 |
for(var i=0; i<tweetRetweet.length; i++){ |
|
|
251 |
if(tweetRetweet[i].id==myRT.id){ |
|
|
252 |
myRT = tweetRetweet[i]; |
|
|
253 |
retweetIsHere=true; |
|
|
254 |
} |
|
|
255 |
} |
|
|
256 |
|
|
|
257 |
if (mytweet.qualification==5){ |
|
|
258 |
myTclient.numberNsp+=1; |
|
|
259 |
}else{ |
|
|
260 |
myTclient.numberSp+=1; |
|
|
261 |
} |
|
|
262 |
|
|
|
263 |
if(retweetIsHere==false){ |
|
|
264 |
tweetRetweet.push(myRT); |
|
|
265 |
}else{ |
|
|
266 |
myRT.total+=1; |
|
|
267 |
} |
|
|
268 |
|
|
|
269 |
} |
|
|
270 |
} |
|
|
271 |
function tweetRetweetReport(tweet){ |
|
|
272 |
|
|
|
273 |
} |
|
|
274 |
function tweetClientCount(tweet){ |
|
|
275 |
var myTclient = { |
|
|
276 |
client:tweet.tsource.source, |
|
|
277 |
numberNsp:0, |
|
|
278 |
numberSp:0, |
|
|
279 |
total:1, |
|
|
280 |
} |
|
|
281 |
var clientIsHere = false; |
|
|
282 |
for(var i=0; i<tweetClient.length; i++) { |
|
|
283 |
if (tweetClient[i].client==tweet.tsource.source){ |
|
|
284 |
clientIsHere = true; |
|
|
285 |
myTclient = tweetClient[i]; |
|
|
286 |
} |
|
|
287 |
} |
|
|
288 |
if (tweet.qualification==5){ |
|
|
289 |
myTclient.numberNsp+=1; |
|
|
290 |
}else{ |
|
|
291 |
myTclient.numberSp+=1; |
|
|
292 |
} |
|
|
293 |
if(clientIsHere==false){ |
|
|
294 |
tweetClient.push(myTclient); |
|
|
295 |
}else{ |
|
|
296 |
myTclient.total+=1 |
|
|
297 |
} |
|
|
298 |
} |
|
|
299 |
function tweetClientSort(a,b){ |
|
|
300 |
return (a.total < b.total)?1:-1; |
|
|
301 |
} |
|
|
302 |
function tweetClientReport(){ |
|
|
303 |
tweetClient.sort(tweetClientSort); |
|
|
304 |
console.log("_______________________________"); |
|
|
305 |
for(var i=0; i<tweetClient.length; i++) { |
|
|
306 |
if(tweetClient[i].total>1){ |
|
|
307 |
console.log("t: "+tweetClient[i].total+" / sp :"+tweetClient[i].numberSp+" : "+tweetClient[i].client); |
|
|
308 |
} |
|
|
309 |
} |
|
|
310 |
console.log(JSON.stringify(tweetClient)); |
|
|
311 |
} |
|
|
312 |
function conversationalCount(tweet){ |
|
|
313 |
if(tweet.tsource.entities.user_mentions.length>2){ |
|
|
314 |
if (tweet.qualification!=5){ |
|
|
315 |
tweetConversationelSP+=1; |
|
|
316 |
} |
|
|
317 |
var myTc = { |
|
|
318 |
polemique:tweet.qualification, |
|
|
319 |
user_mentions:tweet.tsource.entities.user_mentions, |
|
|
320 |
tsource:tweet |
|
|
321 |
} |
|
|
322 |
tweetConversationel.push(myTc); |
|
|
323 |
} |
|
|
324 |
} |
|
|
325 |
function conversationalReport(){ |
|
|
326 |
console.log("_______________________________"); |
|
|
327 |
console.log("tweets conversationel : "+tweetConversationel.length); |
|
|
328 |
console.log("tweets conversationel sp : "+pourcent(tweetConversationelSP,tweetConversationel.length)); |
|
|
329 |
console.log("tweets conversationel nsp: "+pourcent(tweetConversationel.length-tweetConversationelSP,tweetConversationel.length)); |
|
|
330 |
} |
|
|
331 |
function tweetsStats(){ |
|
|
332 |
for(var i=0; i<tweets.length; i++) { |
|
|
333 |
conversationalCount(tweets[i]) |
|
|
334 |
tweetClientCount(tweets[i]); |
|
|
335 |
//tweetRetweetCount(tweets[i]); |
|
|
336 |
} |
|
|
337 |
conversationalReport(); |
|
|
338 |
tweetClientReport(); |
|
|
339 |
} |
|
|
340 |
function numberUserUsePolemic(){ |
|
|
341 |
|
|
|
342 |
for(var i=0; i<tweets.length; i++) { |
|
|
343 |
if (tweets[i].qualification!=5){ |
|
|
344 |
var searchKeyValueArrayTest = searchKeyValueArray('userId',tweets[i].userId,userPol); |
|
|
345 |
if(searchKeyValueArrayTest==true){ |
|
|
346 |
myUser = userPol.push({ |
|
|
347 |
userId: tweets[i].userId, |
|
|
348 |
userScreenName: tweets[i].userScreenName, |
|
|
349 |
tweets:[] |
|
|
350 |
}); |
|
|
351 |
} |
|
|
352 |
}else{ |
|
|
353 |
var searchKeyValueArrayTest = searchKeyValueArray('userId',tweets[i].userId,userPol); |
|
|
354 |
if(searchKeyValueArrayTest==true){ |
|
|
355 |
myUser = userNoPol.push({ |
|
|
356 |
userId: tweets[i].userId, |
|
|
357 |
userScreenName: tweets[i].userScreenName, |
|
|
358 |
tweets:[] |
|
|
359 |
}); |
|
|
360 |
} |
|
|
361 |
} |
|
|
362 |
|
|
|
363 |
var searchKeyValueArrayTest = searchKeyValueArray('userId',tweets[i].userId,userst); |
|
|
364 |
//console.log(searchKeyValueArrayTest); |
|
|
365 |
if(searchKeyValueArrayTest==true){ |
|
|
366 |
//console.log("ici"); |
|
|
367 |
myUser = userst.push({ |
|
|
368 |
userId: tweets[i].userId, |
|
|
369 |
userScreenName: tweets[i].userScreenName, |
|
|
370 |
tweetsNP:[], |
|
|
371 |
tweetsSP:[], |
|
|
372 |
ecartNP:null, |
|
|
373 |
ecartSP:null |
|
|
374 |
}); |
|
|
375 |
if(tweets[i].qualification!=5){ |
|
|
376 |
userst[myUser-1].tweetsNP.push(tweets); |
|
|
377 |
}else { |
|
|
378 |
userst[myUser-1].tweetsSP.push(tweets); |
|
|
379 |
} |
|
|
380 |
}else{ |
|
|
381 |
if(tweets[searchKeyValueArrayTest].qualification!=5){ |
|
|
382 |
userst[searchKeyValueArrayTest].tweetsNP.push(tweets); |
|
|
383 |
}else { |
|
|
384 |
userst[searchKeyValueArrayTest].tweetsSP.push(tweets); |
|
|
385 |
} |
|
|
386 |
} |
|
|
387 |
} |
|
|
388 |
|
|
|
389 |
moyenneDeTweetsNPparUsers = (numberOfTweet-qTweet_0)/userNoPol.length |
|
|
390 |
moyenneDeTweetsSPparUsers = (numberOfTweet-qTweet_0)/userPol.length |
|
|
391 |
sommeDeMesCarreSP=0; |
|
|
392 |
sommeDeMesCarreNP=0; |
|
|
393 |
for(var i=0; i<userst.length; i++) { |
|
|
394 |
myEcartSP = Math.pow(userst[i].tweetsSP.length-moyenneDeTweetsSPparUsers,2); |
|
|
395 |
userst[i].ecartSP=myEcartSP; |
|
|
396 |
sommeDeMesCarreSP+=myEcartSP; |
|
|
397 |
|
|
|
398 |
myEcartNP = Math.pow(userst[i].tweetsNP.length-moyenneDeTweetsNPparUsers,2); |
|
|
399 |
userst[i].ecartNP=myEcartNP; |
|
|
400 |
sommeDeMesCarreNP+=myEcartNP; |
|
|
401 |
} |
|
|
402 |
varianceSP = sommeDeMesCarreSP/userst.length |
|
|
403 |
varianceNP = sommeDeMesCarreNP/userst.length |
|
|
404 |
|
|
|
405 |
SommeVariances = varianceNP + varianceSP; |
|
|
406 |
|
|
|
407 |
EcartTypeSP = Math.sqrt(varianceSP); |
|
|
408 |
EcartTypeNP = Math.sqrt(varianceNP); |
|
|
409 |
|
|
|
410 |
SommeEcart = EcartTypeSP + EcartTypeNP; |
|
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
|
414 |
|
|
|
415 |
console.log("user SP : "+userPol.length); |
|
|
416 |
console.log("user nSP : "+userNoPol.length); |
|
|
417 |
console.log("nbrTP / user SP : "+round2Dec(moyenneDeTweetsSPparUsers)); |
|
|
418 |
console.log("nbrT / user nSP : "+round2Dec(moyenneDeTweetsNPparUsers)); |
|
|
419 |
console.log("varianceSP : "+round2Dec(varianceSP)); |
|
|
420 |
console.log("varianceNP : "+round2Dec(varianceNP)); |
|
|
421 |
console.log("EcartTypeSP : "+round2Dec(EcartTypeSP)); |
|
|
422 |
console.log("EcartTypeNP : "+round2Dec(EcartTypeNP)); |
|
|
423 |
|
|
|
424 |
} |
|
|
425 |
function Report(){ |
|
|
426 |
console.log("_______________________________"); |
|
|
427 |
console.log("Total de tweets : "+numberOfTweet) |
|
|
428 |
console.log("Total de tweets P : "+(numberOfTweet-qTweet_0)+" "+ pourcent((numberOfTweet-qTweet_0),numberOfTweet)+" %") |
|
|
429 |
console.log("accord : "+qTweet_OK+" "+pourcent(qTweet_OK,numberOfTweet)+" %"); |
|
|
430 |
console.log("desaccord : "+qTweet_KO+" "+pourcent(qTweet_KO,numberOfTweet)+" %"); |
|
|
431 |
console.log("question : "+qTweet_Q+" "+pourcent(qTweet_Q,numberOfTweet)+" %"); |
|
|
432 |
console.log("reference : "+qTweet_REF+" "+pourcent(qTweet_REF,numberOfTweet)+" %"); |
|
|
433 |
console.log("sans polemic : "+qTweet_0+" "+pourcent(qTweet_0,numberOfTweet)+" %"); |
|
|
434 |
numberUserUsePolemic(); |
|
|
435 |
tweetsStats(); |
|
|
436 |
} |
|
|
437 |
// tweet Drawing (in raphael) |
|
|
438 |
function DrawTweets (){ |
|
|
439 |
// GROUPES TWEET ============================================ |
|
|
440 |
// Count nbr of cluster and tweet in a frame an save int in "frames" |
|
|
441 |
numberOfTweet = tweets.length; |
|
|
442 |
for(var i=0; i<nbrframes; i++) { |
|
|
443 |
for(var j=0; j<numberOfTweet; j++) { |
|
|
444 |
|
|
|
445 |
if (i==tweets[j].yframe){ |
|
|
446 |
|
|
|
447 |
var k = tweets[j].qualification; |
|
|
448 |
|
|
|
449 |
// make array for frame cluster |
|
|
450 |
if(frames[i]==undefined){ |
|
|
451 |
frames[i] = {id:i, |
|
|
452 |
qualifVol:new Array(), |
|
|
453 |
mytweetsID:new Array() |
|
|
454 |
}; |
|
|
455 |
} |
|
|
456 |
// add my tweet to frame |
|
|
457 |
frames[i].mytweetsID.push(tweets[j]); |
|
|
458 |
|
|
|
459 |
// count opinion by frame |
|
|
460 |
if( frames[i].qualifVol[k] == undefined){ |
|
|
461 |
frames[i].qualifVol[k] = 1; |
|
|
462 |
}else{ |
|
|
463 |
frames[i].qualifVol[k] += 1; |
|
|
464 |
} |
|
|
465 |
|
|
|
466 |
} |
|
|
467 |
} |
|
|
468 |
} |
|
|
469 |
|
|
|
470 |
// GROUPES TWEET ============================================ |
|
|
471 |
// max of tweet by Frame |
|
|
472 |
var max = 0; |
|
|
473 |
for(var i=0; i<nbrframes; i++) { |
|
|
474 |
var moy = 0; |
|
|
475 |
for (var j=0; j<6; j++){ |
|
|
476 |
if (frames[i]!=undefined){ |
|
|
477 |
if (frames[i].qualifVol[j]!=undefined){ |
|
|
478 |
moy += frames[i].qualifVol[j]; |
|
|
479 |
} |
|
|
480 |
} |
|
|
481 |
} |
|
|
482 |
//trace("frame "+i,moy); |
|
|
483 |
if (moy>max){max=moy;} |
|
|
484 |
} |
|
|
485 |
|
|
|
486 |
var tweetDrawed = new Array(); |
|
|
487 |
var TweetHeight = 5; |
|
|
488 |
|
|
|
489 |
// DRAW TWEETS ============================================ |
|
|
490 |
for(var i=0; i<nbrframes;i++) { |
|
|
491 |
var addEheight = 5; |
|
|
492 |
if (frames[i]!=undefined){ |
|
|
493 |
trace (i+" k=",frames[i].mytweetsID.length); |
|
|
494 |
// by type |
|
|
495 |
for (var j=6; j>-1; j--){ |
|
|
496 |
if (frames[i].qualifVol[j]!=undefined){ |
|
|
497 |
// show tweet by type |
|
|
498 |
for (var k=0; k<frames[i].mytweetsID.length; k++){ |
|
|
499 |
if (frames[i].mytweetsID[k].qualification==j){ |
|
|
500 |
var y=config.heightmax-addEheight; |
|
|
501 |
if(yMax>y){yMax=y;} |
|
|
502 |
e = paper.rect( i*frameSize, // x |
|
|
503 |
y, // y |
|
|
504 |
frameSize-margin, // width |
|
|
505 |
TweetHeight // height |
|
|
506 |
).attr({stroke:"#00","stroke-width":0.1, fill: colors[j]}); |
|
|
507 |
addEheight +=TweetHeight; |
|
|
508 |
e.time= frames[i].mytweetsID[k].timeframe; |
|
|
509 |
e.title= frames[i].mytweetsID[k].title; |
|
|
510 |
e.mouseover(function () { |
|
|
511 |
//this.attr({stroke:"#fff","stroke-width":5}); |
|
|
512 |
//this.toFront(); |
|
|
513 |
}).mouseout(function () { |
|
|
514 |
//this.attr({stroke:"#00","stroke-width":0.1}); |
|
|
515 |
}).mousedown(function () { |
|
|
516 |
__IriSP.MyApiPlayer.seek(this.time/1000); |
|
|
517 |
}); |
|
|
518 |
__IriSP.jQuery(e.node).attr('id', 't'+k+''); |
|
|
519 |
__IriSP.jQuery(e.node).attr('title', frames[i].mytweetsID[k].title); |
|
|
520 |
__IriSP.jQuery(e.node).attr('begin', frames[i].mytweetsID[k].timeframe); |
|
|
521 |
var tempPosition = {x:i*frameSize,y:config.heightmax-addEheight}; |
|
|
522 |
addTip(e.node, frames[i].mytweetsID[k].title,colors[j],tempPosition); |
|
|
523 |
//frames[i].mytweetsID.pop(); |
|
|
524 |
} |
|
|
525 |
} |
|
|
526 |
} |
|
|
527 |
} |
|
|
528 |
} |
|
|
529 |
|
|
|
530 |
} |
|
|
531 |
// DRAW UI :: resize border and bgd |
|
|
532 |
heightOfChart = (yMax-(config.height-yMax)); |
|
|
533 |
PaperBackground = paper.rect(0,yMax, this.width,heightOfChart).attr({fill:"#fff","stroke-width":0.1,opacity: 0.1}); |
|
|
534 |
PaperBorder = paper.rect(0,yMax,this.width,1).attr({fill:"#fff",stroke: "none",opacity: 1}); |
|
|
535 |
PaperSlider = paper.rect(0,20,1,heightOfChart).attr({fill:"#fc00ff",stroke: "none",opacity: 1}); |
|
|
536 |
|
|
|
537 |
// decalage |
|
|
538 |
tweetSelection = paper.rect(-100,-100,5,5).attr({fill:"#fff",stroke: "none",opacity: 1}); |
|
|
539 |
|
|
|
540 |
PaperSlider.toFront(); |
|
|
541 |
PaperBackground.toBack(); |
|
|
542 |
} |
|
|
543 |
|
|
|
544 |
if(typeof(PaperSlider) !== 'undefined' ) { |
|
|
545 |
PaperSlider.toFront(); |
|
|
546 |
} |
|
|
547 |
Report(); |
|
|
548 |
} |
|
|
549 |
|
|
|
550 |
|
|
|
551 |
// jQuery(document).mousemove(function(e){ |
|
|
552 |
// if (over){ |
|
|
553 |
// __IriSP.jQuery("#tip").css("left", e.pageX-106).css("top", e.pageY-160); |
|
|
554 |
// __IriSP.jQuery("#tipcolor").css("background-color", tipColor); |
|
|
555 |
// __IriSP.jQuery("#tiptext").text(tipText); |
|
|
556 |
// __IriSP.jQuery("#tip").show(); |
|
|
557 |
// }else{ |
|
|
558 |
// if (typeof(__IriSP) !== 'undefined' && typeof(__IriSP.jQuery) === 'function') { |
|
|
559 |
// __IriSP.jQuery("#tip").css("left", -10000).css("top", -100000); |
|
|
560 |
// //tweetSelection.attr({x:-100,y:-100}); |
|
|
561 |
// } |
|
|
562 |
// } |
|
|
563 |
// }); |
|
|
564 |
|
|
|
565 |
// var over = false; |
|
|
566 |
// var tipText = ""; |
|
|
567 |
// var tipColor = "#efefef"; |
|
|
568 |
// var tweetSelection; |
|
|
569 |
// var PaperSlider; |
|
|
570 |
|
|
|
571 |
// AddTip ****************************************************************************** |
|
|
572 |
function addTip(node, txt,color,tempPosition){ |
|
|
573 |
__IriSP.jQuery(node).mouseover(function(){ |
|
|
574 |
tipText = txt; |
|
|
575 |
//tip.hide();//fadeIn(0); |
|
|
576 |
tipColor = color; |
|
|
577 |
over = true; |
|
|
578 |
//tweetSelection.attr(tempPosition); |
|
|
579 |
//tweetSelection.toFront(); |
|
|
580 |
}).mouseout(function(){ |
|
|
581 |
//tip.show()//tip.fadeOut(0); |
|
|
582 |
over = false; |
|
|
583 |
}); |
|
|
584 |
|
|
|
585 |
|
|
|
586 |
} |
|
|
587 |
|
|
|
588 |
// jQuery(document).ready(function() { |
|
|
589 |
// if (typeof(__IriSP) !== 'undefined' && typeof(__IriSP.jQuery) === 'function') { |
|
|
590 |
// __IriSP.jQuery("#tip").hide(); |
|
|
591 |
// } |
|
|
592 |
// }); |
|
|
593 |
|
|
|
594 |
|