tweetcast/nodejs/client/js/script.js
author Raphael Velt <raph.velt@gmail.com>
Fri, 28 Oct 2011 18:48:14 +0200
changeset 341 cab5c9e10f90
parent 340 a99a04556e3b
child 342 60b8281442b8
permissions -rw-r--r--
Optimized sqlite access
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     1
var socket,
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     2
    tlPaper,
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     3
    twPaper,
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     4
    tweetData = {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     5
        "tweetcount" : 0,
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     6
        "position" : 0,
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
     7
        "feedMode" : true,
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     8
        "followLast" : true,
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     9
        "zoomLevel" : 3,
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    10
        "timeLevel" : 2,
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    11
        "tweets" : [],
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    12
        "posIndex" : [],
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    13
        "tlChanged" : true,
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    14
        "tlLevelChanged" : true,
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    15
        "blockUpdate" : false,
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    16
        "waitUpdate" : true,
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    17
        "htmlBuffer" : '',
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    18
        "wheelDelta" : 0
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    19
    },
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    20
    displaySplitting = [
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    21
        {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    22
            positions : [ 10, 20, 22, 24, 25, 26, 27, 28, 29, 31, 33, 43, 53 ],
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    23
            classNames : [ 'icons fade', 'icons', 'quarter fade', 'quarter', 'half fade', 'half', 'full', 'half', 'half fade', 'quarter', 'quarter fade', 'icons', 'icons fade' ]
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    24
        },
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    25
        {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    26
            positions : [ 1, 3, 5, 7, 13, 33, 53 ],
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    27
            classNames : [ 'full', 'half', 'half fade', 'quarter', 'quarter fade', 'icons', 'icons fade' ]
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    28
        }
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    29
    ];
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    30
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    31
function placeHolder(className) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    32
    return '<li class="placeholder ' + className + '"></li>';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    33
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    34
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    35
function getLinkedTweets() {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    36
    socket.emit('linkedTweets',{"tweetpos":tweetData.position});
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    37
}
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    38
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    39
function changeMode() {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    40
    if (tweetData.feedMode) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    41
        getLinkedTweets();
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    42
    } else {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    43
        tweetData.feedMode = true;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    44
        updateDisplay();
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    45
    }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    46
}
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    47
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    48
function clicTweet(tweetPos) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    49
    if (tweetPos != tweetData.position) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    50
        tweetData.position = tweetPos;
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    51
        if (tweetData.feedMode) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    52
            tweetData.followLast = (tweetData.position == tweetData.tweetcount);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    53
        } else {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    54
            getLinkedTweets();
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    55
        }
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    56
        return false;
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    57
    } else {
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
    58
        changeMode();
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    59
    }
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    60
}
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    61
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    62
function tweetToHtml(tweet, className) {
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    63
    if (!tweet) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    64
        return placeHolder(className);
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    65
    }
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
    66
	html = '<li class="tweet ' + className + '" id="tweet_' + tweet.pos + '" onclick="return clicTweet(' + tweet.pos + ')"';
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    67
	if (tweetData.followLast && tweet.pos == tweetData.position) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    68
	    html += ' style="display: none"';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    69
	}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    70
	html += '>';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    71
	if (tweet.annotations.length) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    72
	    html += '<div class="annotations">';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    73
	    for (var i in tweet.annotations) {
335
5f83c21dee69 Created conf.js file, shared between server & client
Raphael Velt <raph.velt@gmail.com>
parents: 334
diff changeset
    74
    		html += '<div class="annotation" style="width:' + (100/tweet.annotations.length) + '%; background:' + annotations[tweet.annotations[i]].colors.tweet + '"></div>';
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    75
    	}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    76
    	html += '</div>';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    77
	}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    78
	html += '<div class="twmain">';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    79
	a_user = '<a href="http://twitter.com/' + tweet.user.screen_name + '" target="_blank" title="' + tweet.user.name + '">';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    80
	if (tweet.user.profile_image_url) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    81
		html += a_user + '<img class="profile_image" src="' + tweet.user.profile_image_url + '" /></a>';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    82
	}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    83
	html += '<h4>' + a_user + '@' + tweet.user.screen_name + '</a></h4><p class="created_at">' + new Date(tweet.created_at).toLocaleTimeString() + '</p><p class="tweet_text">';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    84
	lastend = 0;
341
cab5c9e10f90 Optimized sqlite access
Raphael Velt <raph.velt@gmail.com>
parents: 340
diff changeset
    85
	txt = tweet.text.replace(/(https?:[0-9a-zA-Z\/\-_\.~&?=]+)/g,'<a href="$1" target="_blank">$1</a>').replace(/@([0-9a-zA-Z_]+)/g,'<a href="http://twitter.com/$1" target="_blank">@$1</a>');
cab5c9e10f90 Optimized sqlite access
Raphael Velt <raph.velt@gmail.com>
parents: 340
diff changeset
    86
/*	txt = '';
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    87
	entities = [];
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    88
	for (var i in tweet.entities.hashtags) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    89
	    entities.push({
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    90
	        "start" : tweet.entities.hashtags[i].indices[0],
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    91
	        "end" : tweet.entities.hashtags[i].indices[1],
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    92
	        "html" : '<a href="http://twitter.com/search?q=%23' + tweet.entities.hashtags[i].text + '" target="_blank">#' + tweet.entities.hashtags[i].text + '</a>'
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    93
	    });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    94
	}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    95
	for (var i in tweet.entities.urls) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    96
	    entities.push({
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    97
	        "start" : tweet.entities.urls[i].indices[0],
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    98
	        "end" : tweet.entities.urls[i].indices[1],
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    99
	        "html" : '<a href="' + tweet.entities.urls[i].expanded_url + '" target="_blank">' + tweet.entities.urls[i].display_url + '</a>'
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   100
	    });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   101
	}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   102
	for (var i in tweet.entities.user_mentions) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   103
	    entities.push({
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   104
	        "start" : tweet.entities.user_mentions[i].indices[0],
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   105
	        "end" : tweet.entities.user_mentions[i].indices[1],
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   106
	        "html" : '<a href="http://twitter.com/' + tweet.entities.user_mentions[i].screen_name + '" target="_blank" title="' + tweet.entities.user_mentions[i].name + '">@' + tweet.entities.user_mentions[i].screen_name + '</a>'
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   107
	    });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   108
	}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   109
 	entities.sort(function(a, b) { return a.start - b.start });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   110
    for (var i in entities) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   111
 		txt += tweet.text.substring(lastend, entities[i].start) + entities[i].html;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   112
        lastend = entities[i].end;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   113
    }
341
cab5c9e10f90 Optimized sqlite access
Raphael Velt <raph.velt@gmail.com>
parents: 340
diff changeset
   114
	txt += tweet.text.substring(lastend); */
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   115
	html += txt + '</p></li></div>';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   116
	return html;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   117
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   118
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   119
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   120
function getUpdate() {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   121
    tweetData.posToDisplay = [];
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   122
    if (tweetData.feedMode) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   123
        if (tweetData.followLast) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   124
            tweetData.position = tweetData.tweetcount;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   125
            for (var i = tweetData.tweetcount; i >= tweetData.tweetcount - 52; i--) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   126
                tweetData.posToDisplay.push( i > 0 ? i : -1 );
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   127
            }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   128
            tweetData.end = tweetData.tweetcount;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   129
            tweetData.start = Math.max(1, tweetData.end - 52);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   130
        } else {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   131
            for (var i = tweetData.position + 26; i >= tweetData.position - 26; i--) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   132
                tweetData.posToDisplay.push( i > 0 && i <= tweetData.tweetcount ? i : -1 );
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   133
            }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   134
            tweetData.end = Math.min(tweetData.tweetcount, tweetData.position + 26 );
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   135
            tweetData.start = Math.max(1, tweetData.position - 26);
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   136
        }
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   137
        if ($("#modeselector").text() != "Mode flux") {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   138
            $("#modeselector").html("Mode Flux").css({"color":"#000000","background":"#ffffff"});
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   139
            $("#tweetlist").css({"background":"#ffffff"});
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   140
        }
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   141
    } else {
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   142
        tweetData.linkedTweets.referenced_by.sort(function(a,b) { return b.pos - a.pos });
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   143
        tweetData.linkedTweets.referencing.sort(function(a,b) { return b.pos - a.pos });
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   144
        for (var i in tweetData.linkedTweets.referenced_by) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   145
            tweetData.posToDisplay.push(tweetData.linkedTweets.referenced_by[i].pos);
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   146
        }
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   147
        tweetData.posToDisplay.push(tweetData.position);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   148
        for (var i in tweetData.linkedTweets.referencing) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   149
            tweetData.posToDisplay.push(tweetData.linkedTweets.referencing[i].pos);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   150
        }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   151
        if ($("#modeselector").text() != "Conversation") {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   152
            $("#modeselector").html("Conversation").css({"color":"#ffffff","background":"#000080"});
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   153
            $("#tweetlist").css({"background":"#000080"});
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   154
        }
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   155
    }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   156
    var tweetsToGet = [];
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   157
    for (var i in tweetData.posToDisplay) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   158
        if (tweetData.posToDisplay[i] != -1 && !tweetByPos(tweetData.posToDisplay[i])) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   159
            tweetsToGet.push(tweetData.posToDisplay[i]);
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   160
        }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   161
    }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   162
    if (tweetsToGet.length) {
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   163
//        console.log('We need to get '+tweetsToGet.join(','));
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   164
        socket.emit('updateTweets', {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   165
            "tweets" : tweetsToGet
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   166
        });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   167
    } else {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   168
        drawTweetList();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   169
    }
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   170
/*        html = '';
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   171
        for (var i in tweetData.linkedTweets.referenced_by) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   172
            console.log(tweetData.linkedTweets.referenced_by[i]);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   173
            html += tweetToHtml(tweetData.linkedTweets.referenced_by[i].tweet,'half');
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   174
        }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   175
        html += tweetToHtml(tweetByPos(tweetData.position),'full');
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   176
        for (var i in tweetData.linkedTweets.referencing) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   177
            console.log(tweetData.linkedTweets.referencing[i]);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   178
            html += tweetToHtml(tweetData.linkedTweets.referencing[i].tweet,'half');
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   179
        }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   180
        if (tweetData.htmlBuffer != html) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   181
            $("#tweetlist").html(html);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   182
            tweetData.htmlBuffer = html;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   183
        } */
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   184
    if (tweetData.tlChanged || tweetData.tlLevelChanged) {
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   185
        socket.emit('updateTimeline', {
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   186
            "level" : tweetData.timeLevel,
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   187
            "full" : tweetData.tlLevelChanged
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   188
        });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   189
    } else {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   190
        drawTimeLine();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   191
    }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   192
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   193
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   194
function addTweet(tweet) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   195
    if (tweetData.posIndex.indexOf(tweet.pos) == -1) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   196
        tweetData.tweets.push(tweet);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   197
        tweetData.posIndex.push(tweet.pos);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   198
    }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   199
}
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   200
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   201
function tweetByPos(pos) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   202
    var index = tweetData.posIndex.indexOf(pos);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   203
    return (index == -1 ? false : tweetData.tweets[index]);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   204
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   205
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   206
function delayedUpdate() {
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   207
    tweetData.blockUpdate = false;
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   208
    if (tweetData.waitUpdate) {
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   209
        updateDisplay();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   210
    }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   211
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   212
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   213
function updateDisplay() {
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   214
    if (tweetData.blockUpdate) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   215
        tweetData.waitUpdate = true;
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   216
    } else {
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   217
        tweetData.waitUpdate = false;
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   218
        getUpdate();
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   219
        tweetData.blockUpdate = true;
341
cab5c9e10f90 Optimized sqlite access
Raphael Velt <raph.velt@gmail.com>
parents: 340
diff changeset
   220
        setTimeout(delayedUpdate, 100);
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   221
    }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   222
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   223
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   224
function setTimeZoom(level) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   225
    if (level >= 0 && level <= 4) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   226
        tweetData.timeLevel = level;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   227
        tweetData.tlChanged = true;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   228
        updateDisplay();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   229
    }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   230
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   231
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   232
function drawTweetList() {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   233
    html = '';
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   234
    var i = 0;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   235
    while (i < tweetData.posIndex.length) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   236
        if (tweetData.posToDisplay.indexOf(tweetData.posIndex[i]) == -1) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   237
            tweetData.posIndex.splice(i,1);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   238
            tweetData.tweets.splice(i,1);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   239
        } else {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   240
            i++;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   241
        }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   242
    }
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   243
    if (tweetData.feedMode) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   244
        for (var i in tweetData.posToDisplay) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   245
            var ds = displaySplitting[tweetData.followLast ? 1 : 0];
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   246
            for (var j in ds.positions) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   247
                if (ds.positions[j] > i) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   248
                    var className = ds.classNames[j];
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   249
                    break;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   250
                }
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   251
            }
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   252
            html += ( tweetData.posToDisplay[i] != -1 ? tweetToHtml(tweetByPos(tweetData.posToDisplay[i]), className) : placeHolder(className) );
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   253
        }
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   254
    } else {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   255
        for (var i in tweetData.posToDisplay) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   256
            html += tweetToHtml(tweetByPos(tweetData.posToDisplay[i]), (tweetData.posToDisplay[i] == tweetData.position ? 'full' : 'half' ));
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   257
        }
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   258
    }
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   259
    if (tweetData.htmlBuffer != html) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   260
        $("#tweetlist").html(html);
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   261
        tweetData.htmlBuffer = html;
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   262
    }
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   263
    if (tweetData.followLast) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   264
        $("#tweet_" + tweetData.position).fadeIn(500);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   265
    }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   266
    drawTimeWindow();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   267
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   268
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   269
function drawTimeWindow() {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   270
    twPaper.clear();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   271
    if (!tweetData.timeline || !tweetData.timeline.length) return;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   272
    
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   273
    var dtfintl = tweetData.timeline[ tweetData.timeline.length - 1 ].end,
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   274
        dtdebtl = tweetData.timeline[0].start,
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   275
        scY = 600 / ( dtfintl - dtdebtl );
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   276
    if (tweetData.feedMode) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   277
        var dtfintw = new Date( tweetByPos( tweetData.end ).created_at ),
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   278
            dtdebtw = new Date( tweetByPos( tweetData.start ).created_at ),
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   279
            rTop = scY * ( dtfintl - dtfintw ),
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   280
            rHeight = scY * ( dtfintw - dtdebtw );
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   281
        if (rHeight > 0) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   282
            twPaper.rect( 0, rTop, 300, rHeight).attr({"stroke":"none","fill":"#8080ff","fill-opacity":.2});
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   283
        } 
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   284
    } else {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   285
        for (var i in tweetData.posToDisplay) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   286
            if (tweetData.posToDisplay[i] != -1) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   287
                var tw = tweetByPos(tweetData.posToDisplay[i]);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   288
                if (tw) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   289
                    var dtcour = new Date( tw.created_at ),
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   290
                        posY = scY * ( dtfintl - dtcour );
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   291
                    twPaper.path("M0 "+posY+"L300 "+posY).attr({"stroke":"#88f"});
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   292
                }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   293
            }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   294
        }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   295
    }
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   296
    var dtcour = new Date( tweetByPos( tweetData.position ).created_at ),
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   297
        posY = scY * ( dtfintl - dtcour ); 
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   298
    twPaper.path("M0 "+posY+"L300 "+posY).attr({"stroke":"#ff0"});
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   299
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   300
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   301
function drawTimeLine() {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   302
    tlPaper.clear();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   303
    if (!tweetData.timeline || !tweetData.timeline.length) return;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   304
    tweetData.tlTweetRects = [];
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   305
    var scaleY = 600 / tweetData.timeline.length,
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   306
        max = 0;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   307
    for (var i = 0; i < tweetData.timeline.length; i++) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   308
        max = Math.max(max, tweetData.timeline[i].tweets);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   309
    }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   310
    var scaleX = 160 / max;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   311
    
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   312
    // dessin de l'axe vertical
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   313
    
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   314
    tlPaper.path("M160 0L160 600").attr({"stroke":"#ccc"});
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   315
    
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   316
    // dessin de la date de début
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   317
    
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   318
    tlPaper.text(165, 592, new Date(tweetData.timeline[0].start).toLocaleTimeString()).attr({ "text-anchor" : "start", "font-size": "12px" });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   319
    
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   320
    // dessin de la date de fin
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   321
    
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   322
    tlPaper.text(165, 7, new Date(tweetData.timeline[tweetData.timeline.length - 1].end).toLocaleTimeString()).attr({ "text-anchor" : "start", "font-size": "12px" });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   323
    for (var i = 0; i < tweetData.timeline.length; i++) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   324
        var posY = 600 - (i * scaleY);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   325
        
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   326
        // Si on est à une demi-heure, on trace un axe secondaire + heure
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   327
        
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   328
        if (i && !(new Date(tweetData.timeline[i].start).valueOf() % 1800000)) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   329
            tlPaper.path("M0 "+posY+"L165 "+posY).attr({"stroke":"#ccc"});
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   330
            tlPaper.text(165, posY, new Date(tweetData.timeline[i].start).toLocaleTimeString()).attr({ "text-anchor" : "start", "font-size": "12px" });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   331
        }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   332
        var anz = {
335
5f83c21dee69 Created conf.js file, shared between server & client
Raphael Velt <raph.velt@gmail.com>
parents: 334
diff changeset
   333
            "default" :tweetData.timeline[i].tweets
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   334
        };
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   335
        for (var j in tweetData.timeline[i].annotations) {
335
5f83c21dee69 Created conf.js file, shared between server & client
Raphael Velt <raph.velt@gmail.com>
parents: 334
diff changeset
   336
            anz.default -= tweetData.timeline[i].annotations[j];
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   337
            anz[j] = tweetData.timeline[i].annotations[j];
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   338
        }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   339
        var posX = 0;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   340
        for (var j in anz) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   341
            var largX = scaleX * anz[j];
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   342
            if (largX > 0) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   343
                tlPaper.rect(posX, 600 - scaleY * (i+1), largX, scaleY).attr({"stroke": "none", "fill": annotations[j].colors.timeline});
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   344
                posX += largX;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   345
            }
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   346
        }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   347
    }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   348
    
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   349
    drawTimeWindow();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   350
}
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   351
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   352
$(document).ready(function() {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   353
    tlPaper = Raphael("timeline", 220, 600);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   354
    twPaper = Raphael("timewindow", 220, 600);
334
b7f05d66b620 Minor changes
Raphael Velt <raph.velt@gmail.com>
parents: 333
diff changeset
   355
    socket = io.connect('http://' + document.location.hostname );
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   356
    socket.on('tweetSummary', function (data) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   357
        if (tweetData.tweetcount != data.tweetcount) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   358
            tweetData.tweetcount = data.tweetcount;
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   359
            tweetData.tlLevelChanged = true;
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   360
            updateDisplay();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   361
        }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   362
    });
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   363
    socket.on('tweetPosByDate', function (data) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   364
        tweetData.position = data.tweetpos;
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   365
        tweetData.feedMode = true;
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   366
        tweetData.followLast = (tweetData.position == tweetData.tweetcount);
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   367
        updateDisplay();
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   368
    });
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   369
    socket.on('tweets', function (data) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   370
        for (var i in data) {
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   371
            addTweet(data[i]);
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   372
        }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   373
        drawTweetList();
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   374
    });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   375
    socket.on('timeline', function (data) {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   376
        tweetData.tlChanged = false;
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   377
        if (data.full) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   378
            tweetData.timeline = data.data;
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   379
        } else {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   380
            if (tweetData.timeline[tweetData.timeline.length - 1].start == data.data[0].start) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   381
                tweetData.timeline[tweetData.timeline.length - 1] = data.data[0];
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   382
            } else {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   383
                tweetData.timeline.push(data.data[0]);
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   384
            }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   385
        }
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   386
        while (tweetData.length > 50) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   387
            tweetData.splice(0,1);
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   388
        }
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   389
        drawTimeLine();
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   390
    });
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   391
    socket.on('linkedTweets', function(data) {
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   392
        tweetData.followLast = false;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   393
        tweetData.feedMode = false;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   394
        tweetData.position = data.tweetpos;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   395
        tweetData.linkedTweets = data;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   396
        updateDisplay();
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   397
    });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   398
    $("#tweetlist").mousewheel(function(e, d) {
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   399
        tweetData.wheelDelta += d;
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   400
        if (Math.abs(tweetData.wheelDelta) >= 1) {
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   401
            if (tweetData.feedMode) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   402
                tweetData.position = Math.min( tweetData.tweetcount, Math.max(1, parseInt(tweetData.wheelDelta) + tweetData.position ) );
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   403
                tweetData.followLast = (tweetData.position == tweetData.tweetcount);
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   404
                updateDisplay();
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   405
            } else {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   406
                if (tweetData.wheelDelta > 0) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   407
                    if (tweetData.linkedTweets.referenced_by.length) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   408
                        tweetData.position = tweetData.linkedTweets.referenced_by[tweetData.linkedTweets.referenced_by.length - 1].pos;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   409
                        getLinkedTweets();
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   410
                    }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   411
                } else {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   412
                    if (tweetData.linkedTweets.referencing.length) {
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   413
                        tweetData.position = tweetData.linkedTweets.referencing[0].pos;
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   414
                        getLinkedTweets();
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   415
                    }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   416
                }
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   417
            }
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   418
            tweetData.wheelDelta = 0;
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   419
        }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   420
        return false;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   421
    });
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   422
    $("#timewindow").mousewheel(function(e, d) {
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   423
        tweetData.wheelDelta += d;
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   424
        if (Math.abs(tweetData.wheelDelta) >= 1) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   425
            if (tweetData.wheelDelta > 0) {
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   426
                setTimeZoom(tweetData.timeLevel + 1);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   427
            } else {
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   428
                setTimeZoom(tweetData.timeLevel - 1);
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   429
            }
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   430
            tweetData.wheelDelta = 0;
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   431
        }
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   432
        return false;
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   433
    });
339
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   434
    $("#timewindow").click(function(evt) {
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   435
        var offsetY = evt.pageY - $(this).offset().top,
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   436
            dtfintl = tweetData.timeline[ tweetData.timeline.length - 1 ].end,
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   437
            dtdebtl = tweetData.timeline[0].start,
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   438
            clicTime = dtdebtl + (1 - ( offsetY / 600 ) ) * ( dtfintl - dtdebtl );
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   439
        socket.emit('tweetPosByDate',{ date: clicTime });
6a073c4a8578 Minor changes and bug fixes
Raphael Velt <raph.velt@gmail.com>
parents: 336
diff changeset
   440
    });
340
a99a04556e3b Added conversation mode
Raphael Velt <raph.velt@gmail.com>
parents: 339
diff changeset
   441
    $("#modeselector").click(changeMode);
333
4389fd4ae58f Reorganisation branche node
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   442
});