' + el + '>';
+ return html;
+}
+
+function tlIdFromPos(x, y, outside) {
+ if (!twCx.tlOnDisplay || !twCx.tlOnDisplay.length) {
+ return;
+ }
+ var ligne = Math.min( twCx.tlOnDisplay.length - 1, Math.max( 0, Math.floor(( twCx.tlHeight - y ) / twCx.scaleY) ) ),
+ colonne = Math.floor(( x - twCx.deltaX ) / twCx.scaleX ),
+ l = 0;
+ if (colonne >= twCx.tlOnDisplay[ligne].totalTweets || colonne < 0 ) {
+ if (outside) {
+ colonne = Math.min( twCx.tlOnDisplay[ligne].totalTweets - 1, Math.max( 0, colonne ));
+ } else {
+ return null;
+ }
+ }
+ for (var i in twCx.tlOnDisplay[ligne].displayData) {
+ var nl = l + twCx.tlOnDisplay[ligne].displayData[i].length;
+ if (colonne < nl) {
+ return {
+ "id" : twCx.tlOnDisplay[ligne].displayData[i][colonne - l],
+ "annotation" : i
+ }
+ }
+ l = nl;
+ }
+}
+
+function tlPosTweet(tweet, annotation) {
+ if (!twCx.tweets) {
+ return;
+ }
+ var x,
+ y,
+ dt = tweet.date_value,
+ ann = ( annotation ? annotation : ( tweet.annotations && tweet.annotations.length ? tweet.annotations[0] : 'default' ) );
+ for (var i = 0; i < twCx.tlOnDisplay.length; i++) {
+ if (twCx.tlOnDisplay[i].end > dt) {
+ y = twCx.tlHeight - (i + .5) * twCx.scaleY;
+ var l = 0;
+ for (var j in twCx.tlOnDisplay[i].displayData) {
+ if (j == ann) {
+ var p = _(twCx.tlOnDisplay[i].displayData[j]).indexOf(tweet.id);
+ if (p != -1) {
+ x = twCx.deltaX + twCx.scaleX * ( p + l + .5 );
+ }
+ break;
+ }
+ l += twCx.tlOnDisplay[i].displayData[j].length;
+ }
+ break;
+ }
+ }
+ return ( x && y ? { "x" : x, "y" : y } : null);
+}
+
+function rolloverTweet(tweetid, showPopup, annotation) {
+ var t = tweetById(tweetid);
+ if (!t) {
+ return;
+ }
+ var p = tlPosTweet(t, annotation);
+ if (!p) {
+ return;
+ }
+ var ptl = $("#timeline").offset();
+ if (showPopup) {
+ $("#hovercontent").html(tweetToHtml(t, 'full', 'div'));
+ $("#hovertweet").css({
+ "left" : parseInt(ptl.left + p.x) + "px",
+ "top" : parseInt(ptl.top + p.y),
+ "display" : "block"});
+ } else {
+ $("#hovertweet").hide();
+ }
+ for (var i in twCx.relHover) {
+ twCx.relHover[i].remove();
+ }
+ twCx.relHover = drawTweetArcs(t, p, '#303030');
+ twCx.relHover.push(drawTweetPos(p, '#ffffff'));
+}
+
+function drawTweetPos(pos, color) {
+ var rel = twCx.tlPaper.rect(pos.x - .5 * twCx.scaleX, pos.y - .5 * twCx.scaleY, twCx.scaleX, twCx.scaleY);
+ rel.attr({ "stroke" : color, "fill" : color, "fill-opacity" : .25 });
+ return rel;
+}
+
+function drawTweetArcs(tweet, pos, color) {
+
+ var res = [];
+
+ function tweetAndArc(a, b, aorb) {
+ if (a && b) {
+ res.push(drawTweetPos(aorb ? a : b, color));
+ var aa = twCx.tlPaper.path(arc(a,b))
+ .attr({ "stroke" : color, "stroke-width" : 1.5, "stroke-opacity" : .8 });
+ res.push(aa);
+ }
+ }
+
+ if (tweet.retweeted_status_id) {
+ var t = tweetById(tweet.retweeted_status_id);
+ if (t) {
+ tweetAndArc(pos, tlPosTweet(t));
+ }
+ }
+
+ if (tweet.in_reply_to_status_id) {
+ var t = tweetById(tweet.in_reply_to_status_id);
+ if (t) {
+ tweetAndArc(pos, tlPosTweet(t));
+ }
+ }
+
+ if (tweet.backRefs) {
+ for (var i in tweet.backRefs) {
+ var t = tweetById(tweet.backRefs[i].referenced_by_id);
+ if (t) {
+ tweetAndArc(tlPosTweet(t), pos, true);
+ }
+ }
+ }
+
+ return res;
+}
+
+function mouseoverkw() {
+ var _jel = $(this),
+ _off = _jel.offset();
+ _jel.css({
+ color: "#0099ff"
+ });
+ $("#hoverkw")
+ .css({
+ "left" : _off.left + "px",
+ "top" : ( parseInt(_off.top) + ~~ (_jel.height() / 2) ) + "px",
+ "display" : "block"
+ })
+ .attr("kw", _jel.text());
+}
+
+function mouseoutkw() {
+ $("#hoverkw").hide();
+ $(this).css({
+ color: "#000000"
+ });
+}
+
+function makeTagCloud(tab, div) {
+ var minfreq = _(tab).min( function(a) { return a.freq} ).freq,
+ maxfreq = Math.max(minfreq + .1, _(tab).max( function(a) { return a.freq} ).freq),
+ echfreq = 8 / Math.sqrt( maxfreq - minfreq ),
+ html = '';
+ _(tab).each(function(_j) {
+ var maxann = 0,
+ ann = "default";
+ for (var k in _j.annotations) {
+ if (_j.annotations[k] == maxann) {
+ ann = "default";
+ }
+ if (_j.annotations[k] > maxann) {
+ ann = k;
+ maxann = _j.annotations[k];
+ }
+ }
+ if (ann == "default") {
+ var coul = '';
+ } else {
+ var c = getColor(ann, .6),
+ coul = "background: rgba(" + [ Math.floor(c.r), Math.floor(c.g), Math.floor(c.b), ( _j.annotations[ann] / _j.freq )].join(',') + ")";
+ }
+ var fontsize = Math.floor( ( 12 + Math.sqrt( _j.freq - minfreq ) * echfreq ) );
+ html += '