36 |
36 |
37 function getColor(annotation, lum) { |
37 function getColor(annotation, lum) { |
38 return Raphael.hsl2rgb(annotations[annotation].colors.h, annotations[annotation].colors.s, lum); |
38 return Raphael.hsl2rgb(annotations[annotation].colors.h, annotations[annotation].colors.s, lum); |
39 } |
39 } |
40 |
40 |
|
41 function tweetPopup(url) { |
|
42 var popW = 550, |
|
43 popH = 350, |
|
44 scrW = screen.width, |
|
45 scrH = screen.height, |
|
46 posX = Math.round((scrW/2)-(popW/2)), |
|
47 posY = (scrH > popH ? Math.round((scrH/2)-(popH/2)) : 0); |
|
48 window.open(url, |
|
49 '', |
|
50 'left=' + posX + ',top=' + posY + ',width=' + popW + ',height=' + popH + ',personalbar=0,toolbar=0,scrollbars=1,resizable=1'); |
|
51 } |
|
52 |
41 function arc(source, target) { |
53 function arc(source, target) { |
42 var x3 = .3 * target.y - .3 * source.y + .8 * source.x + .2 * target.x; |
54 var x3 = .3 * target.y - .3 * source.y + .8 * source.x + .2 * target.x; |
43 var y3 = .8 * source.y + .2 * target.y - .3 * target.x + .3 * source.x; |
55 var y3 = .8 * source.y + .2 * target.y - .3 * target.x + .3 * source.x; |
44 var x4 = .3 * target.y - .3 * source.y + .2 * source.x + .8 * target.x; |
56 var x4 = .3 * target.y - .3 * source.y + .2 * source.x + .8 * target.x; |
45 var y4 = .2 * source.y + .8 * target.y - .3 * target.x + .3 * source.x; |
57 var y4 = .2 * source.y + .8 * target.y - .3 * target.x + .3 * source.x; |
274 html += '<div class="annotation" style="width:' + (100/tweet.annotations.length) + '%; background:' + getColor(tweet.annotations[i], (className == 'icons' ? .4 : .85)).hex + '"></div>'; |
286 html += '<div class="annotation" style="width:' + (100/tweet.annotations.length) + '%; background:' + getColor(tweet.annotations[i], (className == 'icons' ? .4 : .85)).hex + '"></div>'; |
275 } |
287 } |
276 html += '</div>'; |
288 html += '</div>'; |
277 } |
289 } |
278 html += '<div class="twmain">'; |
290 html += '<div class="twmain">'; |
279 a_user = '<a href="http://twitter.com/' + tweet.user.screen_name + '" var target="_blank">'; |
291 var a_user = '<a href="http://twitter.com/' + tweet.user.screen_name + '" onclick="filtrerTexte(\'@' + tweet.user.screen_name + '\'); return false;" target="_blank">'; |
280 html += '<div class="around_img">' + a_user + '<img class="profile_image" src="' + tweet.user.profile_image_url + '" /></a>'; |
292 html += '<div class="around_img">' + a_user + '<img class="profile_image" src="' + tweet.user.profile_image_url + '" /></a>'; |
281 if (className == 'full') { |
293 if (className == 'full') { |
282 html += '<p class="created_at">' + new Date(tweet.date_value).toTimeString().substr(0,8) + '</p>'; |
294 html += '<p class="created_at">' + new Date(tweet.date_value).toTimeString().substr(0,8) + '</a></p>'; |
283 } |
295 } |
284 html += '</div>'; |
296 html += '</div>'; |
285 if (className != 'icons') { |
297 if (className != 'icons') { |
286 lastend = 0; |
298 lastend = 0; |
287 var txt = '', |
299 var txt = '', |
288 entities = []; |
300 entities = []; |
289 for (var i in tweet.entities.hashtags) { |
301 for (var i in tweet.entities.hashtags) { |
290 entities.push({ |
302 entities.push({ |
291 "start" : tweet.entities.hashtags[i].indices[0], |
303 "start" : tweet.entities.hashtags[i].indices[0], |
292 "end" : tweet.entities.hashtags[i].indices[1], |
304 "end" : tweet.entities.hashtags[i].indices[1], |
293 "link" : '<a href="http://twitter.com/search?q=%23' + tweet.entities.hashtags[i].text + '" target="_blank">', |
305 "link" : '<a href="http://twitter.com/search?q=%23' + tweet.entities.hashtags[i].text + '" onclick="filtrerTexte(\'#' + tweet.entities.hashtags[i].text + '\'); return false;" target="_blank">', |
294 "text" : '#' + tweet.entities.hashtags[i].text |
306 "text" : '#' + tweet.entities.hashtags[i].text |
295 }); |
307 }); |
296 } |
308 } |
297 for (var i in tweet.entities.urls) { |
309 for (var i in tweet.entities.urls) { |
298 var linkurl = ( tweet.entities.urls[i].expanded_url ? tweet.entities.urls[i].expanded_url : tweet.entities.urls[i].url ), |
310 var linkurl = ( tweet.entities.urls[i].expanded_url ? tweet.entities.urls[i].expanded_url : tweet.entities.urls[i].url ), |
309 } |
321 } |
310 for (var i in tweet.entities.user_mentions) { |
322 for (var i in tweet.entities.user_mentions) { |
311 entities.push({ |
323 entities.push({ |
312 "start" : tweet.entities.user_mentions[i].indices[0], |
324 "start" : tweet.entities.user_mentions[i].indices[0], |
313 "end" : tweet.entities.user_mentions[i].indices[1], |
325 "end" : tweet.entities.user_mentions[i].indices[1], |
314 "link" : '<a href="http://twitter.com/' + tweet.entities.user_mentions[i].screen_name + '" target="_blank">', |
326 "link" : '<a href="http://twitter.com/' + tweet.entities.user_mentions[i].screen_name + '" onclick="filtrerTexte(\'@' + tweet.entities.user_mentions[i].screen_name + '\'); return false;" target="_blank">', |
315 "text" : '@' + tweet.entities.user_mentions[i].screen_name |
327 "text" : '@' + tweet.entities.user_mentions[i].screen_name |
316 }); |
328 }); |
317 } |
329 } |
318 entities.sort(function(a, b) { return a.start - b.start }); |
330 entities.sort(function(a, b) { return a.start - b.start }); |
319 for (var i in entities) { |
331 for (var i in entities) { |
321 lastend = entities[i].end; |
333 lastend = entities[i].end; |
322 } |
334 } |
323 txt += highlight( tweet.text.substring(lastend) ); |
335 txt += highlight( tweet.text.substring(lastend) ); |
324 html += '<p class="tweet_text"><b>' + a_user + highlight('@' + tweet.user.screen_name) + '</a>' + ( className == 'full' ? ' (' + tweet.user.name + ')</b><br />' : '</b> : ') + txt + '</p>'; |
336 html += '<p class="tweet_text"><b>' + a_user + highlight('@' + tweet.user.screen_name) + '</a>' + ( className == 'full' ? ' (' + tweet.user.name + ')</b><br />' : '</b> : ') + txt + '</p>'; |
325 if (className == 'full' && el == 'li') { |
337 if (className == 'full' && el == 'li') { |
326 html += '<div class="tweet_actions"><a href="http://twitter.com/intent/tweet?in_reply_to=' + tweet.id + '" target="_blank">répondre</a> · '; |
338 html += '<div class="tweet_actions"><a href="http://twitter.com/' + tweet.user.screen_name + '/status/' + tweet.id + '" onclick="tweetPopup(this.href); return false;" target="_blank">afficher tweet</a> - '; |
327 html += '<a href="http://twitter.com/intent/retweet?tweet_id=' + tweet.id + '" target="_blank">retweeter</a> · '; |
339 html += '<a href="http://twitter.com/intent/tweet?in_reply_to=' + tweet.id + '" onclick="tweetPopup(this.href); return false;" target="_blank">répondre</a> · '; |
328 html += '<a href="http://twitter.com/intent/favorite?tweet_id=' + tweet.id + '" target="_blank">favori</a></div>'; |
340 html += '<a href="http://twitter.com/intent/retweet?tweet_id=' + tweet.id + '" onclick="tweetPopup(this.href); return false;" target="_blank">retweeter</a> · '; |
|
341 html += '<a href="http://twitter.com/intent/favorite?tweet_id=' + tweet.id + '" onclick="tweetPopup(this.href); return false;" target="_blank">favori</a></div>'; |
329 } |
342 } |
330 } |
343 } |
331 html += '</div></' + el + '>'; |
344 html += '</div></' + el + '>'; |
332 return html; |
345 return html; |
333 } |
346 } |