web/res/js-tweetcast/live-polemic.js
author Raphael Velt <raph.velt@gmail.com>
Fri, 16 Dec 2011 19:17:47 +0100
changeset 423 9bd7cd237153
parent 420 eb7c2cff1816
child 424 e67c4b18a16b
permissions -rw-r--r--
Added Knowtex Frame Support
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     1
var socket,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     2
    tlPaper,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     3
    twCx = {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     4
        followLast : true,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     5
        position : "0",
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     6
        date_levels : [
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     7
            3600 * 1000,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     8
            15 * 60 * 1000,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     9
            5 * 60 * 1000,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    10
            60 * 1000
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    11
        ],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    12
        timeLevel : 1,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    13
        deltaX : 40,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    14
        tlWidth : 150,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    15
        tlHeight : 480,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    16
        globalWords : {},
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    17
        refMouse : { x : 0, y : 0},
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    18
        refPosTl : { x : 0, y : 0},
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    19
        tlMouseMoved : false,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    20
        tlMouseClicked : false,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    21
        filtre : null
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    22
        },
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    23
    tlBuffer = '',
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    24
    relHover = [],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    25
    wheelDelta = 0,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    26
    scrollEnabled = false,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    27
    scrollExtent = 8000 - 480,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    28
    lastScrollPos = 0,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    29
    rx_url = /https?:\/\/[0-9a-zA-Z\.%\/-_]+/g,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    30
    rx_word = /[^ \.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    31
    stop_list = [ 'and', 'avec', 'aux', 'car', 'comme', 'dans', 'donc', 'des', 'elle', 'est', 'être', 'eux', 'ils', 'les', 'leur', 'leurs', 'mes', 'mon', 'tes', 'ton', 'notre', 'nos', 'nous', 'ont', 'pas', 'que', 'qui', 'sont', 'the', 'une', 'votre', 'vos', 'vous' ],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    32
    l10n = { "rechercher" : "Rechercher" };
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    33
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    34
function getColor(annotation, lum) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    35
    return Raphael.hsl2rgb(annotations[annotation].colors.h, annotations[annotation].colors.s, lum);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    36
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    37
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    38
function tweetPopup(url) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    39
    var popW = 550,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    40
        popH = 350,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    41
        scrW = screen.width,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    42
        scrH = screen.height,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    43
        posX = Math.round((scrW/2)-(popW/2)),
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    44
        posY = (scrH > popH ? Math.round((scrH/2)-(popH/2)) : 0);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    45
    window.open(url,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    46
        '',
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    47
        'left=' + posX + ',top=' + posY + ',width=' + popW + ',height=' + popH + ',personalbar=0,toolbar=0,scrollbars=1,resizable=1');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    48
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    49
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    50
function arc(source, target) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    51
    var x3 = .3 * target.y - .3 * source.y + .8 * source.x + .2 * target.x;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    52
    var y3 = .8 * source.y + .2 * target.y - .3 * target.x + .3 * source.x;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    53
    var x4 = .3 * target.y - .3 * source.y + .2 * source.x + .8 * target.x;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    54
    var y4 = .2 * source.y + .8 * target.y - .3 * target.x + .3 * source.x;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    55
    return "M" + source.x + " " + source.y + "C" + [x3, y3, x4, y4, target.x, target.y].join(" ");
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    56
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    57
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    58
function addTweet(tweet) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    59
    function backRef(source_id, target_id, type) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    60
        var target = tweetById(target_id);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    61
        if (target) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    62
            var brobj = {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    63
                "referenced_by_id" : source_id,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    64
                "type" : type
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    65
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    66
            if (target.backRefs) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    67
                target.backRefs.push(brobj);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    68
            } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    69
                target.backRefs = [ brobj ]
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    70
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    71
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    72
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    73
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    74
    if (twCx.idIndex.indexOf(tweet.id) != -1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    75
        return;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    76
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    77
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    78
    var txt_date = tweet.created_at;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    79
    if (navigator.userAgent.search(/MSIE/) != -1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    80
        txt_date = txt_date.replace(/( \+)/, ' UTC$1');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    81
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    82
    tweet.date_value = Date.parse(txt_date);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    83
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    84
    var tab = tweet.text.match(/\&\#[0-9]+\;/g);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    85
    for (var i in tab) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    86
        var n = parseInt(tab[i].substr(2));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    87
        if (n != NaN) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    88
            tweet.text = tweet.text.replace(tab[i], String.fromCharCode(n));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    89
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    90
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    91
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    92
    var ann = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    93
    for (var j in annotations) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    94
        if (j != "default") {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    95
            for (var k in annotations[j].keywords) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    96
                if (tweet.text.search(annotations[j].keywords[k]) != -1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    97
                    ann.push(j);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    98
                    break;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    99
                }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   100
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   101
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   102
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   103
    tweet.annotations = ann;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   104
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   105
    if (tweet.in_reply_to_status_id) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   106
        backRef( tweet.id, tweet.in_reply_to_status_id, "reply" );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   107
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   108
    if (tweet.retweeted_status) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   109
        backRef( tweet.id,  tweet.retweeted_status.id, "retweet" );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   110
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   111
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   112
    var localWords = []
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   113
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   114
    var tab = tweet.text.replace(rx_url,'').match(rx_word);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   115
    for (var i in tab) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   116
        var word = tab[i].toLowerCase();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   117
        if (stop_list.indexOf(word) == -1 && tracking_keywords.indexOf(word) == -1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   118
            if (twCx.globalWords[word]) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   119
                twCx.globalWords[word]++;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   120
            } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   121
                twCx.globalWords[word] = 1;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   122
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   123
            localWords.push(word);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   124
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   125
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   126
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   127
    tweet.words = localWords;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   128
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   129
    var p = twCx.idIndex.length;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   130
    while (p && tweet.id < twCx.idIndex[p-1]) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   131
        p--;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   132
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   133
    twCx.tweets.splice(p, 0, tweet);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   134
    twCx.idIndex.splice(p, 0, tweet.id);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   135
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   136
    if (!twCx.timeline.length) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   137
        twCx.timeline = [ populateDateStruct(0, twCx.date_levels[0] * parseInt(tweet.date_value / twCx.date_levels[0])) ]
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   138
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   139
    while (tweet.date_value > twCx.timeline[twCx.timeline.length - 1].end) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   140
        twCx.timeline.push( populateDateStruct(0, twCx.timeline[twCx.timeline.length - 1].end) );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   141
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   142
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   143
    insertIntoDateStruct(twCx.timeline, tweet);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   144
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   145
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   146
function getSliceContent(slice) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   147
    if (slice.slices) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   148
        var result = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   149
        for (var i in slice.slices) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   150
            result = result.concat(getSliceContent(slice.slices[i]));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   151
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   152
    } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   153
        var result = slice.tweets;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   154
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   155
    return result;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   156
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   157
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   158
function flattenDateStruct(slices, target_level) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   159
    var current_level = slices[0].level,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   160
        result = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   161
    if (current_level < target_level) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   162
        if (slices[0].slices) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   163
            for (var i in slices) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   164
                result = result.concat(flattenDateStruct(slices[i].slices, target_level));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   165
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   166
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   167
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   168
    else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   169
        for (var i in slices) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   170
            result.push({
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   171
                "start" : slices[i].start,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   172
                "end" : slices[i].end,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   173
                "tweets" : getSliceContent(slices[i])
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   174
            });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   175
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   176
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   177
    return result;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   178
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   179
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   180
function trimFDS() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   181
    var slices = flattenDateStruct(twCx.timeline, twCx.timeLevel);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   182
    while (slices[0].tweets.length == 0) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   183
        slices.splice(0,1);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   184
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   185
    while (slices[slices.length - 1].tweets.length == 0) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   186
        slices.pop();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   187
    }    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   188
    var centralTweet = ( twCx.centralTweet ? twCx.centralTweet : twCx.tweets[twCx.tweets.length - 1] ),
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   189
        delta = 30 * twCx.date_levels[twCx.timeLevel],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   190
        centre = Math.min(slices[slices.length - 1].end - delta , Math.max(slices[0].start + delta, centralTweet.date_value)),
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   191
        min = centre - delta,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   192
        max = centre + delta;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   193
    while (slices[0].start < min) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   194
        slices.splice(0,1);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   195
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   196
    while (slices[slices.length - 1].end > max) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   197
        slices.pop();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   198
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   199
    return slices;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   200
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   201
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   202
function populateDateStruct(level, start) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   203
    var end = start + twCx.date_levels[level],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   204
        struct = {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   205
            "level" : level,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   206
            "start" : start,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   207
            "end" : end
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   208
        };
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   209
    if (level < twCx.date_levels.length - 1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   210
        struct.slices = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   211
        var newstart = start;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   212
        while (newstart < end) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   213
            struct.slices.push(populateDateStruct(level + 1, newstart));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   214
            newstart += twCx.date_levels[level + 1];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   215
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   216
    } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   217
        struct.tweets = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   218
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   219
    return struct;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   220
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   221
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   222
function insertIntoDateStruct(slices, tweet) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   223
    var creadate = tweet.date_value;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   224
    for (var i in slices) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   225
        if (creadate < slices[i].end) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   226
            if (slices[i].slices) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   227
                insertIntoDateStruct(slices[i].slices, tweet);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   228
            } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   229
                slices[i].tweets.push(tweet.id);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   230
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   231
            break;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   232
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   233
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   234
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   235
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   236
function placeHolder(className) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   237
    return '<li class="placeholder ' + className + '"></li>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   238
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   239
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   240
function tweetById(tweetid) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   241
    var pos = twCx.idIndex.indexOf(tweetid);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   242
    return (pos == -1) ? false : twCx.tweets[pos];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   243
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   244
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   245
function selectTweet(tweetid) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   246
    twCx.position = tweetid;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   247
    twCx.followLast = (twCx.position == twCx.idIndex[twCx.tweets.length - 1]);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   248
    updateDisplay();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   249
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   250
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   251
function goToPos(nPos) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   252
    twCx.position = twCx.currentIdIndex[Math.min( twCx.currentIdIndex.length - 1, Math.max(0, nPos ) )];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   253
    twCx.followLast = (!twCx.filtre && nPos == twCx.tweets.length - 1);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   254
    updateDisplay();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   255
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   256
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   257
function movePos(delta) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   258
    goToPos( delta + twCx.currentIdIndex.indexOf(twCx.position) );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   259
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   260
423
9bd7cd237153 Added Knowtex Frame Support
Raphael Velt <raph.velt@gmail.com>
parents: 420
diff changeset
   261
function ktxHighlightTweet(tweet) {
9bd7cd237153 Added Knowtex Frame Support
Raphael Velt <raph.velt@gmail.com>
parents: 420
diff changeset
   262
    var _gF = $("#graphFrame");
9bd7cd237153 Added Knowtex Frame Support
Raphael Velt <raph.velt@gmail.com>
parents: 420
diff changeset
   263
    if ( _gF.is(":visible") && _gF.attr("src").indexOf("labs.knowtex.com") != -1 ) {
9bd7cd237153 Added Knowtex Frame Support
Raphael Velt <raph.velt@gmail.com>
parents: 420
diff changeset
   264
        _gF.attr("src",'http://labs.knowtex.com/enmi2011/#carto::user=' + tweet.user.screen_name + '&time=' + ~~(tweet.date_value/1000));
9bd7cd237153 Added Knowtex Frame Support
Raphael Velt <raph.velt@gmail.com>
parents: 420
diff changeset
   265
    }
9bd7cd237153 Added Knowtex Frame Support
Raphael Velt <raph.velt@gmail.com>
parents: 420
diff changeset
   266
}
9bd7cd237153 Added Knowtex Frame Support
Raphael Velt <raph.velt@gmail.com>
parents: 420
diff changeset
   267
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   268
function tweetToHtml(tweet, className, elName) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   269
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   270
    function highlight(texte) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   271
        return ( twCx.filtre ? texte.replace(twCx.filtre, '<span class="highlight">$1</span>' ) : texte );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   272
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   273
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   274
    if (!tweet) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   275
        return placeHolder(className);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   276
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   277
    var el = (elName ? elName : 'li');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   278
    var html = '<' + el + ' class="tweet ' + className + '" id="tweet_' + tweet.id + '"';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   279
    if (className != 'full') {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   280
        html += ' onclick="selectTweet(\'' + tweet.id + '\'); return false;"';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   281
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   282
    html += ' onmouseover="rolloverTweet(\'' + tweet.id + "', " + ( className == 'icons' ) + ');"';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   283
    if (twCx.followLast && className == 'full' && el == 'li') {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   284
        html += ' style="display: none"';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   285
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   286
    html += '>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   287
    if (tweet.annotations.length) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   288
        html += '<div class="annotations">';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   289
        for (var i in tweet.annotations) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   290
            html += '<div class="annotation" style="width:' + (100/tweet.annotations.length) + '%; background:' + getColor(tweet.annotations[i], (className == 'icons' ? .4 : .85)).hex + '"></div>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   291
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   292
        html += '</div>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   293
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   294
    html += '<div class="twmain">';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   295
    var a_user = '<a href="http://twitter.com/' + tweet.user.screen_name + '"  onclick="filtrerTexte(\'@' + tweet.user.screen_name + '\'); return false;" target="_blank">';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   296
    html += '<div class="around_img">' + a_user + '<img class="profile_image" src="' + tweet.user.profile_image_url + '" /></a>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   297
    if (className == 'full') {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   298
        html += '<p class="created_at">' + new Date(tweet.date_value).toTimeString().substr(0,8) + '</a></p>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   299
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   300
    html += '</div>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   301
    if (className != 'icons') {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   302
        lastend = 0;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   303
        var txt = '',
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   304
            entities = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   305
        for (var i in tweet.entities.hashtags) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   306
            entities.push({
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   307
                "start" : tweet.entities.hashtags[i].indices[0],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   308
                "end" : tweet.entities.hashtags[i].indices[1],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   309
                "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">',
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   310
                "text" : '#' + tweet.entities.hashtags[i].text
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   311
            });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   312
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   313
        for (var i in tweet.entities.urls) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   314
            var linkurl = ( tweet.entities.urls[i].expanded_url ? tweet.entities.urls[i].expanded_url : tweet.entities.urls[i].url ),
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   315
                dispurl = linkurl.replace(/https?:\/\//,'');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   316
            if (linkurl.search(/https?:\/\//) == -1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   317
                linkurl = 'http://' + linkurl;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   318
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   319
            entities.push({
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   320
                "start" : tweet.entities.urls[i].indices[0],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   321
                "end" : tweet.entities.urls[i].indices[1],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   322
                "link" : '<a href="' + linkurl  + '" target="_blank">',
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   323
                "text" : dispurl
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   324
            });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   325
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   326
        for (var i in tweet.entities.user_mentions) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   327
            entities.push({
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   328
                "start" : tweet.entities.user_mentions[i].indices[0],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   329
                "end" : tweet.entities.user_mentions[i].indices[1],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   330
                "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">',
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   331
                "text" : '@' + tweet.entities.user_mentions[i].screen_name
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   332
            });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   333
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   334
        entities.sort(function(a, b) { return a.start - b.start });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   335
        for (var i in entities) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   336
            txt += highlight( tweet.text.substring(lastend, entities[i].start) ) + entities[i].link + highlight( entities[i].text ) + '</a>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   337
            lastend = entities[i].end;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   338
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   339
        txt += highlight( tweet.text.substring(lastend) );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   340
        html += '<p class="tweet_text"><b>' + a_user + highlight('@' + tweet.user.screen_name) + '</a>' + ( className == 'full' ? ' (' + tweet.user.name + ')</b><br />' : '</b> : ') + txt + '</p>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   341
        if (className == 'full' && el == 'li') {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   342
            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> - ';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   343
            html += '<a href="http://twitter.com/intent/tweet?in_reply_to=' + tweet.id + '" onclick="tweetPopup(this.href); return false;" target="_blank">répondre</a> · ';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   344
            html += '<a href="http://twitter.com/intent/retweet?tweet_id=' + tweet.id + '" onclick="tweetPopup(this.href); return false;" target="_blank">retweeter</a> · ';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   345
            html += '<a href="http://twitter.com/intent/favorite?tweet_id=' + tweet.id + '" onclick="tweetPopup(this.href); return false;" target="_blank">favori</a></div>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   346
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   347
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   348
    html += '</div></' + el + '>';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   349
    return html;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   350
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   351
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   352
function tlIdFromPos(x, y, outside) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   353
    if (!twCx.tlOnDisplay) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   354
        return;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   355
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   356
    var ligne = Math.min( twCx.tlOnDisplay.length - 1, Math.max( 0, Math.floor(( twCx.tlHeight - y ) / twCx.scaleY) ) ),
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   357
        colonne = Math.floor(( x - twCx.deltaX ) / twCx.scaleX ),
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   358
        l = 0;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   359
    if (colonne >= twCx.tlOnDisplay[ligne].totalTweets || colonne < 0 ) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   360
        if (outside) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   361
            colonne = Math.min( twCx.tlOnDisplay[ligne].totalTweets - 1, Math.max( 0, colonne ));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   362
        } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   363
            return null;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   364
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   365
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   366
    for (var i in twCx.tlOnDisplay[ligne].displayData) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   367
        var nl = l + twCx.tlOnDisplay[ligne].displayData[i].length;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   368
        if (colonne < nl) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   369
            return {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   370
                "id" : twCx.tlOnDisplay[ligne].displayData[i][colonne - l],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   371
                "annotation" : i
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   372
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   373
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   374
        l = nl;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   375
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   376
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   377
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   378
function tlPosTweet(tweet, annotation) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   379
    if (!twCx.tweets) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   380
        return;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   381
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   382
    var x,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   383
        y,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   384
        dt = tweet.date_value,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   385
        ann = ( annotation ? annotation : ( tweet.annotations.length ? tweet.annotations[0] : 'default' ) );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   386
    for (var i = 0; i < twCx.tlOnDisplay.length; i++) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   387
        if (twCx.tlOnDisplay[i].end > dt) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   388
            y = twCx.tlHeight - (i + .5) * twCx.scaleY;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   389
            var l = 0;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   390
            for (var j in twCx.tlOnDisplay[i].displayData) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   391
                if (j == ann) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   392
                    var p = twCx.tlOnDisplay[i].displayData[j].indexOf(tweet.id);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   393
                    if (p != -1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   394
                        x = twCx.deltaX + twCx.scaleX * ( p + l + .5 );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   395
                    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   396
                    break;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   397
                }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   398
                l += twCx.tlOnDisplay[i].displayData[j].length;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   399
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   400
            break;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   401
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   402
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   403
    return ( x && y ? { "x" : x, "y" : y } : null);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   404
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   405
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   406
function rolloverTweet(tweetid, showPopup, annotation) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   407
    var t = tweetById(tweetid);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   408
    if (!t) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   409
        return;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   410
    }
423
9bd7cd237153 Added Knowtex Frame Support
Raphael Velt <raph.velt@gmail.com>
parents: 420
diff changeset
   411
    ktxHighlightTweet(t);
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   412
    var p = tlPosTweet(t, annotation);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   413
    if (!p) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   414
        return;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   415
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   416
    var ptl = $("#timeline").offset();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   417
    if (showPopup) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   418
        $("#hovercontent").html(tweetToHtml(t, 'full', 'div'));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   419
        $("#hovertweet").css({
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   420
            "left" : parseInt(ptl.left + p.x) + "px",
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   421
            "top" : parseInt(ptl.top + p.y),
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   422
            "display" : "block"});
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   423
    } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   424
        $("#hovertweet").hide();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   425
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   426
    for (var i in relHover) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   427
        relHover[i].remove();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   428
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   429
    relHover = drawTweetArcs(t, p, '#303030');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   430
    relHover.push(drawTweetPos(p, '#ffffff'));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   431
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   432
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   433
function drawTweetPos(pos, color) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   434
    var rel = tlPaper.rect(pos.x - .5 * twCx.scaleX, pos.y - .5 * twCx.scaleY, twCx.scaleX, twCx.scaleY);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   435
    rel.attr({ "stroke" : color, "fill" : color, "fill-opacity" : .25 });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   436
    return rel;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   437
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   438
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   439
function drawTweetArcs(tweet, pos, color) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   440
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   441
    var res = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   442
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   443
    function tweetAndArc(a, b, aorb) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   444
        if (a && b) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   445
            res.push(drawTweetPos(aorb ? a : b, color));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   446
            var aa = tlPaper.path(arc(a,b))
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   447
                .attr({ "stroke" : color, "stroke-width" : 1.5, "stroke-opacity" : .8 });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   448
            res.push(aa);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   449
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   450
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   451
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   452
    if (tweet.retweeted_status) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   453
        var t = tweetById(tweet.retweeted_status.id);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   454
        if (t) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   455
            tweetAndArc(pos, tlPosTweet(t));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   456
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   457
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   458
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   459
    if (tweet.in_reply_to_status_id) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   460
        var t = tweetById(tweet.in_reply_to_status_id);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   461
        if (t) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   462
            tweetAndArc(pos, tlPosTweet(t));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   463
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   464
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   465
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   466
    if (tweet.backRefs) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   467
        for (var i in tweet.backRefs) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   468
            var t = tweetById(tweet.backRefs[i].referenced_by_id);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   469
            if (t) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   470
            tweetAndArc(tlPosTweet(t), pos, true);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   471
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   472
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   473
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   474
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   475
    return res;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   476
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   477
407
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   478
function mouseoverkw() {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   479
    var _jel = $(this),
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   480
        _off = _jel.offset();
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   481
    _jel.css({
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   482
        color: "#0099ff"
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   483
    });
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   484
    $("#hoverkw")
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   485
        .css({
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   486
            "left" : _off.left + "px",
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   487
            "top" : ( parseInt(_off.top) + ~~ (_jel.height() / 2) )  + "px",
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   488
            "display" : "block"
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   489
        })
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   490
        .attr("kw", _jel.text());
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   491
}
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   492
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   493
function mouseoutkw() {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   494
    $("#hoverkw").hide();
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   495
    $(this).css({
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   496
        color: "#000000"
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   497
    });
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   498
}
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   499
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   500
function makeTagCloud(tab, div) {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   501
    var minfreq = _(tab).min( function(a) { return a.freq} ).freq,
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   502
        maxfreq = Math.max(minfreq + .1, _(tab).max( function(a) { return a.freq} ).freq),
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   503
        echfreq = 8 / Math.sqrt( maxfreq - minfreq ),
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   504
        html = '';
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   505
    _(tab).each(function(_j) {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   506
        var maxann = 0,
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   507
            ann = "default";
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   508
        for (var k in _j.annotations) {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   509
            if (_j.annotations[k] == maxann) {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   510
                ann = "default";
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   511
            }
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   512
            if (_j.annotations[k] > maxann) {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   513
                ann = k;
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   514
                maxann = _j.annotations[k];
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   515
            }
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   516
        }
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   517
        if (ann == "default") {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   518
            var coul = '';
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   519
        } else {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   520
            var c = getColor(ann, .6),
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   521
                coul = "background: rgba(" + [ Math.floor(c.r), Math.floor(c.g), Math.floor(c.b), ( _j.annotations[ann] / _j.freq )].join(',') + ")";
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   522
        }
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   523
        var fontsize = Math.floor( ( 12 + Math.sqrt( _j.freq - minfreq ) * echfreq ) );
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   524
        html += '<span style="line-height: ' + (8 + fontsize) + 'px; font-size: ' + fontsize + 'px;' + coul + '">' + _j.word + '</span> ';
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   525
    });
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   526
    $(div).html(html);
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   527
    $(div + " span")
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   528
        .mouseover(mouseoverkw)
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   529
        .mouseout(mouseoutkw)
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   530
        .click(function() {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   531
            $("#hoverkw").toggle();
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   532
        });
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   533
}
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   534
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   535
function updateDisplay() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   536
    if (!twCx.tweets) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   537
        return;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   538
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   539
    if (twCx.filtre) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   540
        var tweets = twCx.tweets.filter(function(tweet) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   541
            var mention = '@' + tweet.user.screen_name;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   542
            return ( tweet.text.search(twCx.filtre) != -1 ) || ( mention.search(twCx.filtre) != -1 );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   543
        });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   544
        $("#inp_q").val(twCx.filtreTexte + ' (' + tweets.length + ' tweets)');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   545
        if (tweets.length) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   546
            var idIndex = tweets.map(function(tweet) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   547
                return tweet.id;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   548
            });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   549
            var p = idIndex.indexOf(twCx.position);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   550
            if (p == -1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   551
                for (p = idIndex.length - 1; p > 0 && idIndex[p] > twCx.position; p--) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   552
                }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   553
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   554
            twCx.position = idIndex[p];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   555
            twCx.currentIdIndex = idIndex;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   556
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   557
        
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   558
    } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   559
        twCx.currentIdIndex = twCx.idIndex;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   560
        var tweets = twCx.tweets;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   561
        var p = twCx.idIndex.indexOf(twCx.position);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   562
        if (p == -1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   563
            p = (twCx.followLast ? twCx.idIndex.length - 1 : 0);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   564
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   565
    }
408
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   566
    
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   567
    
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   568
    if (suggested_keywords && suggested_keywords.length) {
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   569
        var _skw = suggested_keywords.map(function(_e) {
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   570
            return {
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   571
                "word" : _e,
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   572
                "rgxp" : new RegExp(_e, "im"),
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   573
                "freq" : 0,
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   574
                "annotations" : {}
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   575
            }
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   576
        })
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   577
    }
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   578
    
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   579
    var l = tweets.length,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   580
        lines = 0,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   581
        ppy = 0,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   582
        html = '',
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   583
        tweetsOnDisplay = [],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   584
        localWords = {};
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   585
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   586
    function pushTweet(tp, className) {
408
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   587
        
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   588
        if (tp < l && tp >= 0) {
408
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   589
            
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   590
            if (_skw) {
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   591
                _(_skw).each(function(_k) {
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   592
                    if (tweets[tp].text.search(_k.rgxp) != -1) {
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   593
                        _k.freq++;
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   594
                        _(tweets[tp].annotations).each(function(_a) {
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   595
                            _k.annotations[_a] = 1 + ( _k.annotations[_a] || 0 )
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   596
                        })
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   597
                    }
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   598
                });
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   599
            }
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   600
            
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   601
            html += tweetToHtml(tweets[tp], className);
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   602
            
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   603
            tweetsOnDisplay.push(tp);
408
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   604
            
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   605
            for (var i in tweets[tp].words) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   606
                var w = tweets[tp].words[i];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   607
                if (localWords[w]) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   608
                    localWords[w].freq++
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   609
                } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   610
                    localWords[w] = {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   611
                        "freq" : 1,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   612
                        "annotations" : {}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   613
                    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   614
                    for (var j in annotations) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   615
                        if (j != 'default') {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   616
                            localWords[w].annotations[j] = 0;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   617
                        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   618
                    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   619
                }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   620
                for (var j in tweets[tp].annotations) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   621
                    localWords[w].annotations[tweets[tp].annotations[j]]++;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   622
                }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   623
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   624
        } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   625
            html += placeHolder(className);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   626
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   627
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   628
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   629
    if (l) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   630
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   631
        lastScrollPos = Math.floor( scrollExtent * ( 1 - ( p / l ) ) );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   632
        $("#scrollcont").scrollTop(lastScrollPos);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   633
        
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   634
        if (l > p + 18) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   635
            lines++;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   636
            ppy += 20;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   637
            for (var i = p + 31; i >= p + 18; i--) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   638
                pushTweet(i, 'icons');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   639
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   640
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   641
        if (l > p + 4) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   642
            lines++;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   643
            ppy += 20;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   644
            for (var i = p + 17; i >= p + 4; i--) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   645
                pushTweet(i, 'icons');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   646
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   647
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   648
        for (var k = 3; k >= 1; k--) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   649
            if (l > p + k) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   650
                ppy += 47;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   651
                lines++;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   652
                pushTweet(p + k, 'half');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   653
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   654
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   655
        pushTweet(p, 'full');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   656
        var n = p - 1;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   657
        for (var i = 0; i < Math.min(6, Math.max(3, 6 - lines)); i++) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   658
            if (n < 0) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   659
                break;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   660
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   661
            pushTweet(n, 'half');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   662
            n--;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   663
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   664
        for (var i = 0; i < 14 * Math.min(4, Math.max(2, 7 - lines)); i++) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   665
            if (n < 0) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   666
                break;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   667
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   668
            pushTweet(n, 'icons');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   669
            n--;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   670
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   671
        if (html != tlBuffer) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   672
            $("#tweetlist").html(html);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   673
            $(".tweet.full").fadeIn();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   674
            tlBuffer = html;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   675
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   676
        
408
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   677
        if (_skw) {
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   678
            makeTagCloud(_skw, "#suggkw");
4141c5821c98 Improvements on PT live client
Raphael Velt <raph.velt@gmail.com>
parents: 407
diff changeset
   679
        }
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   680
        /* Recherche des mots pertinents correspondant à la sélection */
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   681
        
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   682
        var tab = _(localWords).map(function(v, k) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   683
            return {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   684
                "word": k,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   685
                "freq" : v.freq,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   686
                "annotations" : v.annotations,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   687
                "score" : v.freq / Math.log( 2 + twCx.globalWords[j] )
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   688
            };
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   689
        }).filter(function(v) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   690
            return v.freq > 1;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   691
        });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   692
        
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   693
        if (tab.length) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   694
            
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   695
            tab = _(tab).sortBy( function(a) { return ( - a.score ) }).slice(0,20);
407
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   696
            makeTagCloud(tab,"#motscles");
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   697
        } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   698
            $("#motscles").html('');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   699
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   700
        twCx.centralTweet = tweets[p];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   701
    } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   702
        $("#tweetlist").html('');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   703
        tlBuffer = '';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   704
        $("#motscles").html('');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   705
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   706
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   707
    twCx.tlOnDisplay = trimFDS();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   708
    twCx.scaleY = twCx.tlHeight / twCx.tlOnDisplay.length;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   709
    var maxTweets = 0,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   710
        startTl = 0,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   711
        endTl = twCx.tlOnDisplay.length - 1;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   712
    if (l) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   713
        var startTw = tweets[tweetsOnDisplay[tweetsOnDisplay.length - 1]].date_value,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   714
            endTw = tweets[tweetsOnDisplay[0]].date_value;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   715
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   716
    for (var i = 0; i < twCx.tlOnDisplay.length; i++) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   717
        if (l) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   718
            if (startTw >= twCx.tlOnDisplay[i].start && startTw < twCx.tlOnDisplay[i].end) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   719
                startTl = i;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   720
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   721
            if (endTw >= twCx.tlOnDisplay[i].start && endTw < twCx.tlOnDisplay[i].end) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   722
                endTl = i;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   723
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   724
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   725
        var displayData = {};
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   726
        for (var j in annotations) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   727
            displayData[j] = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   728
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   729
        for (var j in twCx.tlOnDisplay[i].tweets) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   730
            var tweetid = twCx.tlOnDisplay[i].tweets[j],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   731
                tweet = tweetById(tweetid);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   732
            if (tweet) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   733
                if (tweet.annotations.length) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   734
                    for (var k in tweet.annotations) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   735
                        displayData[tweet.annotations[k]].push(tweetid);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   736
                    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   737
                } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   738
                    displayData['default'].push(tweetid);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   739
                }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   740
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   741
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   742
        var nbT = 0;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   743
        for (var j in displayData) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   744
            nbT += displayData[j].length;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   745
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   746
        maxTweets = Math.max(maxTweets, nbT);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   747
        twCx.tlOnDisplay[i].displayData = displayData;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   748
        twCx.tlOnDisplay[i].totalTweets = nbT;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   749
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   750
    twCx.scaleX = ( twCx.tlWidth - twCx.deltaX ) / maxTweets;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   751
    tlPaper.clear();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   752
    relHover = null;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   753
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   754
    // Dessin de la correspondance liste-timeline
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   755
    if (l) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   756
        var startY = twCx.tlHeight - startTl * twCx.scaleY,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   757
            endY = twCx.tlHeight - ( endTl + 1 ) * twCx.scaleY,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   758
            path = "M0 " + twCx.tlHeight + "C" + .7*twCx.deltaX + " " + twCx.tlHeight + " " + .3*twCx.deltaX + " " + startY + " " + twCx.deltaX + " " + startY + "L" + twCx.tlWidth + " " + startY + "L" + twCx.tlWidth + " " + endY + "L" + twCx.deltaX + " " + endY + "C" + .3*twCx.deltaX + " " + endY + " " + .7*twCx.deltaX + " 0 0 0";
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   759
        tlPaper.path( path ).attr({ "stroke" : "none", "fill" : "#000080", "opacity" : .2 });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   760
    }   
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   761
    // dessin de la date de début
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   762
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   763
    tlPaper.text(twCx.deltaX / 2, twCx.tlHeight - 7, new Date(twCx.tlOnDisplay[0].start).toTimeString().substr(0,5))
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   764
        .attr({ "text-anchor" : "middle", "font-size": "9px" });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   765
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   766
    // dessin de la date de fin
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   767
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   768
    tlPaper.text(twCx.deltaX / 2, 7, new Date(twCx.tlOnDisplay[twCx.tlOnDisplay.length - 1].end).toTimeString().substr(0,5))
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   769
        .attr({ "text-anchor" : "middle", "font-size": "9px" });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   770
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   771
    for (var i = 0; i < twCx.tlOnDisplay.length; i++) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   772
        var n = 0,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   773
            posY = twCx.tlHeight - ( i + 1 ) * twCx.scaleY;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   774
        for (var j in twCx.tlOnDisplay[i].displayData) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   775
            var ll = twCx.tlOnDisplay[i].displayData[j].length;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   776
            if (ll > 0) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   777
                tlPaper.rect( twCx.deltaX + n * twCx.scaleX, posY, ll * twCx.scaleX, twCx.scaleY )
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   778
                    .attr({"stroke" : "none", "fill" : getColor(j, .4).hex });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   779
                n += ll;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   780
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   781
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   782
        
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   783
        // Si on est à une demi-heure, on trace un axe secondaire + heure
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   784
        
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   785
        if (i < twCx.tlOnDisplay.length - 1 && !(twCx.tlOnDisplay[i].end % 1800000)) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   786
            tlPaper.path("M0 "+posY+"L" + twCx.tlWidth +" "+posY).attr({"stroke":"#ccc"});
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   787
            tlPaper.text(twCx.deltaX / 2, posY, new Date(twCx.tlOnDisplay[i].end).toTimeString().substr(0,5)).attr({ "text-anchor" : "middle", "font-size": "9px" });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   788
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   789
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   790
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   791
    // dessin du tweet courant
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   792
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   793
    if (l) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   794
        
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   795
        if (twCx.filtre) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   796
            for (var i = 0; i < tweets.length; i++) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   797
                if (i != p) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   798
                    var pos = tlPosTweet(tweets[i]);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   799
                    if (pos) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   800
                        drawTweetPos(pos, "#ffccff");
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   801
                    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   802
                }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   803
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   804
            
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   805
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   806
        
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   807
        var posp = tlPosTweet(tweets[p]);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   808
        if (posp) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   809
            
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   810
            drawTweetPos(posp, "#ffff00");
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   811
            var yy = posp.y - .5 * twCx.scaleY,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   812
                path = "M0 " + ppy + "C" + ( .7 * twCx.deltaX ) + " " + ppy + " " + ( .2 * twCx.deltaX ) + " " + yy + " " + ( twCx.deltaX ) + " " + yy + "L" + ( posp.x - .5 * twCx.scaleX ) + " " + yy;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   813
            yy = posp.y + .5 * twCx.scaleY;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   814
            ppy += 117;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   815
            path += "L" + ( posp.x - .5 * twCx.scaleX ) + " " + yy + "L" + twCx.deltaX + " " + yy + "C"  + ( .2 * twCx.deltaX ) + " " + yy + " " + ( .7 * twCx.deltaX ) + " " + ppy + " 0 " + ppy;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   816
            tlPaper.path( path ).attr({"stroke":"#ffff00", "fill" : "#ffff00", "fill-opacity" : .15});
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   817
            
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   818
            drawTweetArcs(tweets[p], posp, '#800080');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   819
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   820
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   821
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   822
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   823
function filtrerAnnotation(annotation) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   824
    if (annotations[annotation]) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   825
        effectuerFiltrage(annotations[annotation].display_name,
407
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   826
            new RegExp( "(" + annotations[annotation].keywords.map(function(a) { return a.source }).join("|") + ")", "gim" ) );
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   827
    } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   828
        effectuerFiltrage('', null)
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   829
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   830
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   831
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   832
function filtrerTexte(valeur) {
407
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   833
    effectuerFiltrage( valeur, valeur ? new RegExp("(" + valeur.replace(/(\W)/g, '\\$1') + ")" ,'gim') : null );
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   834
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   835
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   836
function effectuerFiltrage(filtreTexte, tabRegexp) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   837
    $("#recherche_annot").slideUp();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   838
    $("#inp_q").val(filtreTexte).attr("class","rechercheCourante");
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   839
    twCx.filtreTexte = filtreTexte;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   840
    twCx.filtre = tabRegexp;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   841
    twCx.followLast = !tabRegexp && (twCx.position == twCx.idIndex[twCx.idIndex.length - 1]);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   842
    updateDisplay();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   843
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   844
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   845
function clicTl(evt) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   846
    var o = $("#timeline").offset();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   847
    if (twCx.tlMouseClicked && twCx.tlMouseMoved) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   848
        var twid = tlIdFromPos(evt.pageX - o.left + twCx.refPosTl.x - twCx.refMouse.x, evt.pageY - o.top + twCx.refPosTl.y - twCx.refMouse.y, true);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   849
        if (twid) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   850
            selectTweet(twid.id);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   851
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   852
    } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   853
        var twid = tlIdFromPos(evt.pageX - o.left, evt.pageY - o.top, twCx.tlMouseClicked);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   854
        if (twCx.tlMouseMoved && !twCx.tlMouseClicked) { 
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   855
            if (twid) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   856
                rolloverTweet(twid.id, true, twid.annotation);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   857
            } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   858
                $("#hovertweet").hide();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   859
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   860
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   861
        if (twCx.tlMouseClicked && !twCx.tlMouseMoved) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   862
            if (twid) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   863
                selectTweet(twid.id);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   864
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   865
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   866
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   867
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   868
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   869
function loadTweets(tweets, append) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   870
    if (!append) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   871
        twCx.timeline = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   872
        twCx.idIndex = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   873
        twCx.tweets = [];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   874
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   875
    for (var i in tweets) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   876
        addTweet(tweets[i]);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   877
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   878
    if (twCx.followLast) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   879
        twCx.position = twCx.idIndex[twCx.tweets.length - 1];
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   880
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   881
    updateDisplay();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   882
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   883
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   884
function focusOutRecherche() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   885
    $("#recherche_annot").slideUp();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   886
    var inpq = $("#inp_q"),
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   887
        val = inpq.val();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   888
    if (val == '' || val == twCx.filtreTexte) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   889
        if (twCx.filtre) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   890
            inpq.attr("class", "rechercheCourante").val(twCx.filtreTexte);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   891
        } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   892
            inpq.attr("class", "greyed").val(l10n.rechercher);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   893
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   894
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   895
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   896
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   897
function chaineTimeZoom() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   898
    var chaine = "",
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   899
        t = twCx.date_levels[twCx.timeLevel],
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   900
        h = 3600*1000,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   901
        m = 60*1000,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   902
        s = 1000,
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   903
        heures = Math.floor(t/h);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   904
    if (heures) { chaine += heures + ' h. ' };
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   905
    t -= (heures * h);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   906
    var minutes = Math.floor(t/m);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   907
    if (minutes) { chaine += minutes + ' min. ' };
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   908
    t -= (minutes * m);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   909
    if (t) { chaine += Math.floor(t/s) + ' sec.' }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   910
    $("#time_scale").html(chaine);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   911
    $("#time_zoomout").attr("class",(twCx.timeLevel == 0 ? "inactive" : ""));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   912
    $("#time_zoomin").attr("class",(twCx.timeLevel == twCx.date_levels.length - 1 ? "inactive" : ""));
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   913
}
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   914
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   915
$(document).ready(function() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   916
    tlPaper = Raphael("timeline", twCx.tlWidth, twCx.tlHeight);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   917
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   918
    connectTweets();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   919
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   920
    var html = '';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   921
    for (var j in annotations) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   922
        if (j != "default") {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   923
            html += '<a href="#" style="background: ' + getColor(j, .7).hex + ';" onclick=filtrerAnnotation(\'' + j + '\'); return false;">' + annotations[j].display_name + '</a> '
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   924
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   925
    }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   926
    $("#rech_list_annot").html(html);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   927
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   928
    chaineTimeZoom();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   929
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   930
    $("#tweetlist").mousewheel(function(e, d) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   931
        wheelDelta += d;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   932
        if (Math.abs(wheelDelta) >= 1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   933
            movePos( parseInt(wheelDelta) );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   934
            wheelDelta = 0;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   935
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   936
        return false;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   937
    });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   938
    $("#timeline").mousewheel(function(e, d) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   939
        wheelDelta += d;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   940
        if (Math.abs(wheelDelta) >= 1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   941
            if (wheelDelta > 0) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   942
                tl = Math.min(twCx.date_levels.length - 1, twCx.timeLevel + 1);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   943
            } else {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   944
                tl = Math.max(0, twCx.timeLevel - 1);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   945
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   946
            if (tl != twCx.timeLevel) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   947
                twCx.timeLevel = tl;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   948
                chaineTimeZoom();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   949
                updateDisplay();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   950
            }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   951
            wheelDelta = 0;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   952
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   953
        return false;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   954
    });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   955
    $("#time_zoomin").click(function() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   956
        if (twCx.timeLevel < twCx.date_levels.length - 1) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   957
            twCx.timeLevel++;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   958
            chaineTimeZoom();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   959
            updateDisplay();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   960
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   961
    });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   962
    $("#time_zoomout").click(function() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   963
        if (twCx.timeLevel > 0) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   964
            twCx.timeLevel--;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   965
            chaineTimeZoom();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   966
            updateDisplay();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   967
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   968
    });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   969
    $("#timeline, #tweetlist").mouseout(function() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   970
        twCx.tlMouseClicked = false;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   971
        twCx.tlMouseMoved = false;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   972
        $("#hovertweet").hide();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   973
    });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   974
    $("#timeline").mousemove(function(evt) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   975
        twCx.tlMouseMoved = true;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   976
        clicTl(evt);
407
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   977
    }).mousedown(function(evt) {
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   978
        twCx.tlMouseClicked = true;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   979
        twCx.tlMouseMoved = false;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   980
        var o = $(this).offset();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   981
        twCx.refMouse = { x : evt.pageX - o.left, y : evt.pageY - o.top };
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   982
        twCx.refPosTl = tlPosTweet(tweetById(twCx.position)) || twCx.refMouse;
407
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   983
    }).mouseup(function(evt) {
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   984
        clicTl(evt);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   985
        twCx.tlMouseClicked = false;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   986
        twCx.tlMouseMoved = false;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   987
    });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   988
    $("#inp_q").focus(function() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   989
        $("#recherche_annot").slideDown();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   990
        $(this).val($(this).val().replace(/ \(.+\)$/, ''))
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   991
        if ($(this).hasClass("greyed")) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   992
            $(this).val("");
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   993
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   994
        $(this).attr("class","");
407
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
   995
    }).focusout(function() {
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   996
        focusOutRecherche();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   997
    });
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   998
    $("#inp_reset").click(function() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   999
        $("#inp_q").val('');
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1000
        if (twCx.filtre) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1001
            twCx.filtre = null;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1002
            updateDisplay();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1003
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1004
        twCx.filtreTexte = '';
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1005
        focusOutRecherche();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1006
        return false;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1007
    })
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1008
    $("#recherche").submit(function(evt) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1009
        evt.preventDefault();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1010
        if (!$("#inp_q").hasClass("greyed")) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1011
            var valeur = $("#inp_q").val();
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1012
            filtrerTexte(valeur);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1013
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1014
        return false;
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1015
    });
407
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1016
    $("#hoverkw").mouseover(function() {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1017
        $(this).dequeue().show();
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1018
    }).mouseout(function() {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1019
        $(this).hide();
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1020
    });
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1021
    
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1022
    $("#hkwsearch").click(function() {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1023
        var _hkw = $("#hoverkw");
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1024
        filtrerTexte(_hkw.attr("kw"));
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1025
        _hkw.hide();
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1026
        return false;
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1027
    });
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1028
    $("#hkwtweet").click(function() {
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1029
        var _hkw = $("#hoverkw");
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1030
        add_grammar(_hkw.attr("kw"));
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1031
        _hkw.hide();
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1032
        return false;
5ab44abc46df Correction Live-client
Raphael Velt <raph.velt@gmail.com>
parents: 406
diff changeset
  1033
    });
406
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1034
    
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1035
    setInterval(function() {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1036
        var sc = $("#scrollcont");
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1037
        if (sc.scrollTop() != lastScrollPos && twCx.tweets) {
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1038
            var p = Math.floor( twCx.currentIdIndex.length * ( 1 - sc.scrollTop() / scrollExtent ) );
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1039
            goToPos(p);
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1040
        }
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1041
        
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1042
    }, 100)
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1043
});
86b62b98fea7 Polemic Tweet client now uses rv's live system
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
  1044
420
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1045
if (connect_type == "socketio") {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1046
    document.write('<script type="text/javascript" src="' + source_address + '/socket.io/socket.io.js"><' + '/script>');
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1047
}
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1048
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1049
function connectTweets() {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1050
    switch (connect_type) {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1051
        case "socketio" :
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1052
            socket = io.connect( source_address );
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1053
            socket.on("initial_data", function(data) {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1054
                loadTweets(data.tweets)
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1055
            });
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1056
            socket.on("update", function(data) {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1057
                if (!twCx.tweets) {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1058
                    return;
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1059
                }
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1060
                loadTweets(data.new_tweets, true);
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1061
            });
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1062
            break;
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1063
            
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1064
        case "gevent" :
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1065
            $.getJSON( source_address + '/?callback=?', function(data) {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1066
                loadTweets(data.tweets)
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1067
            } );
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1068
            
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1069
            setInterval(function() {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1070
                if (!twCx.tweets) {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1071
                    return;
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1072
                }
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1073
                $.getJSON( source_address + '/?after_id=' + twCx.tweets[twCx.tweets.length - 1].id + '&callback=?', function(data) {
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1074
                    loadTweets(data.tweets, true);
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1075
                });
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1076
            }, 1000);
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1077
            break;
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1078
        
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1079
        case "standalone" :
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1080
            $.getScript( source_address );
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1081
    }
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1082
}
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1083
eb7c2cff1816 Modifs pour ENMI
Raphael Velt <raph.velt@gmail.com>
parents: 412
diff changeset
  1084