tweetcast/nodejs/client/js/script.js
changeset 335 5f83c21dee69
parent 334 b7f05d66b620
child 336 d60efd677b50
equal deleted inserted replaced
334:b7f05d66b620 335:5f83c21dee69
     9         "timeLevel" : 2,
     9         "timeLevel" : 2,
    10         "tweets" : [],
    10         "tweets" : [],
    11         "posIndex" : [],
    11         "posIndex" : [],
    12         "tlChanged" : true
    12         "tlChanged" : true
    13     },
    13     },
    14     colors = {
       
    15         'positive' : "#1D973D",
       
    16         'reference' : "#C5A62D",
       
    17         'negative' : "#CE0A15",
       
    18         'question' : "#036AAE",
       
    19         'neutre' : "#585858"
       
    20     },
       
    21     annotations = {
       
    22         'positive' : '++',
       
    23         'negative' : '--',
       
    24         'reference' : '==',
       
    25         'question' : '??'
       
    26     },
       
    27     displaySplitting = [
    14     displaySplitting = [
    28         {
    15         {
    29             positions : [ 10, 20, 22, 24, 25, 26, 27, 28, 29, 31, 33, 43, 53 ],
    16             positions : [ 10, 20, 22, 24, 25, 26, 27, 28, 29, 31, 33, 43, 53 ],
    30             classNames : [ 'icons fade', 'icons', 'quarter fade', 'quarter', 'half fade', 'half', 'full', 'half', 'half fade', 'quarter', 'quarter fade', 'icons', 'icons fade' ]
    17             classNames : [ 'icons fade', 'icons', 'quarter fade', 'quarter', 'half fade', 'half', 'full', 'half', 'half fade', 'quarter', 'quarter fade', 'icons', 'icons fade' ]
    31         },
    18         },
    49 	}
    36 	}
    50 	html += '>';
    37 	html += '>';
    51 	if (tweet.annotations.length) {
    38 	if (tweet.annotations.length) {
    52 	    html += '<div class="annotations">';
    39 	    html += '<div class="annotations">';
    53 	    for (var i in tweet.annotations) {
    40 	    for (var i in tweet.annotations) {
    54     		html += '<div class="annotation ' + tweet.annotations[i] + '" style="width :' + (100/tweet.annotations.length) + '%"></div>';
    41     		html += '<div class="annotation" style="width:' + (100/tweet.annotations.length) + '%; background:' + annotations[tweet.annotations[i]].colors.tweet + '"></div>';
    55     	}
    42     	}
    56     	html += '</div>';
    43     	html += '</div>';
    57 	}
    44 	}
    58 	html += '<div class="twmain">';
    45 	html += '<div class="twmain">';
    59 	a_user = '<a href="http://twitter.com/' + tweet.user.screen_name + '" target="_blank" title="' + tweet.user.name + '">';
    46 	a_user = '<a href="http://twitter.com/' + tweet.user.screen_name + '" target="_blank" title="' + tweet.user.name + '">';
   238         if (i && !(new Date(tweetData.timeline[i].start).valueOf() % 1800000)) {
   225         if (i && !(new Date(tweetData.timeline[i].start).valueOf() % 1800000)) {
   239             tlPaper.path("M0 "+posY+"L165 "+posY).attr({"stroke":"#ccc"});
   226             tlPaper.path("M0 "+posY+"L165 "+posY).attr({"stroke":"#ccc"});
   240             tlPaper.text(165, posY, new Date(tweetData.timeline[i].start).toLocaleTimeString()).attr({ "text-anchor" : "start", "font-size": "12px" });
   227             tlPaper.text(165, posY, new Date(tweetData.timeline[i].start).toLocaleTimeString()).attr({ "text-anchor" : "start", "font-size": "12px" });
   241         }
   228         }
   242         var anz = {
   229         var anz = {
   243             "neutre" :tweetData.timeline[i].tweets
   230             "default" :tweetData.timeline[i].tweets
   244         };
   231         };
   245         for (var j in tweetData.timeline[i].annotations) {
   232         for (var j in tweetData.timeline[i].annotations) {
   246             anz.neutre -= tweetData.timeline[i].annotations[j];
   233             anz.default -= tweetData.timeline[i].annotations[j];
   247             anz[j] = tweetData.timeline[i].annotations[j];
   234             anz[j] = tweetData.timeline[i].annotations[j];
   248         }
   235         }
   249         var posX = 0;
   236         var posX = 0;
   250         for (var j in anz) {
   237         for (var j in anz) {
   251             var largX = scaleX * anz[j];
   238             var largX = scaleX * anz[j];
   252             tlPaper.rect(posX, 600 - scaleY * (i+1), largX, scaleY).attr({"stroke": "none", "fill": colors[j]});
   239             tlPaper.rect(posX, 600 - scaleY * (i+1), largX, scaleY).attr({"stroke": "none", "fill": annotations[j].colors.timeline});
   253             posX += largX;
   240             posX += largX;
   254         }
   241         }
   255     }
   242     }
   256     
   243     
   257     drawTimeWindow();
   244     drawTimeWindow();