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