diff -r 738594562e44 -r 4389fd4ae58f tweetcast/nodejs/client/js/script.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tweetcast/nodejs/client/js/script.js Tue Oct 25 09:20:07 2011 +0200 @@ -0,0 +1,336 @@ +var socket, + tlPaper, + twPaper, + tweetData = { + "tweetcount" : 0, + "position" : 0, + "followLast" : true, + "zoomLevel" : 3, + "timeLevel" : 2, + "tweets" : [], + "posIndex" : [], + "tlChanged" : true + }, + colors = { + 'positive' : "#1D973D", + 'reference' : "#C5A62D", + 'negative' : "#CE0A15", + 'question' : "#036AAE", + 'neutre' : "#585858" + }, + annotations = { + 'positive' : '++', + 'negative' : '--', + 'reference' : '==', + 'question' : '??' + }, + displaySplitting = [ + { + positions : [ 10, 20, 22, 24, 25, 26, 27, 28, 29, 31, 33, 43, 53 ], + classNames : [ 'icons fade', 'icons', 'quarter fade', 'quarter', 'half fade', 'half', 'full', 'half', 'half fade', 'quarter', 'quarter fade', 'icons', 'icons fade' ] + }, + { + positions : [ 1, 3, 5, 7, 13, 33, 53 ], + classNames : [ 'full', 'half', 'half fade', 'quarter', 'quarter fade', 'icons', 'icons fade' ] + } + ], + blockUpdate = false, + waitUpdate = true, + wheeldelta = 0; + +function placeHolder(className) { + return '
'; +} + +function tweetToHtml(tweet, className) { + html = '' + new Date(tweet.created_at).toLocaleTimeString() + '
'; + lastend = 0; + txt = ''; + entities = []; + for (var i in tweet.entities.hashtags) { + entities.push({ + "start" : tweet.entities.hashtags[i].indices[0], + "end" : tweet.entities.hashtags[i].indices[1], + "html" : '#' + tweet.entities.hashtags[i].text + '' + }); + } + for (var i in tweet.entities.urls) { + entities.push({ + "start" : tweet.entities.urls[i].indices[0], + "end" : tweet.entities.urls[i].indices[1], + "html" : '' + tweet.entities.urls[i].display_url + '' + }); + } + for (var i in tweet.entities.user_mentions) { + entities.push({ + "start" : tweet.entities.user_mentions[i].indices[0], + "end" : tweet.entities.user_mentions[i].indices[1], + "html" : '@' + tweet.entities.user_mentions[i].screen_name + '' + }); + } + entities.sort(function(a, b) { return a.start - b.start }); + for (var i in entities) { + txt += tweet.text.substring(lastend, entities[i].start) + entities[i].html; + lastend = entities[i].end; + } + txt += tweet.text.substring(lastend); + html += txt + '