| author | Raphael Velt <raph.velt@gmail.com> |
| Tue, 18 Oct 2011 16:19:08 +0200 | |
| changeset 326 | c28048fb63b4 |
| parent 325 | 7d9c576bfaac |
| child 331 | 03c69425efa6 |
| child 336 | d60efd677b50 |
| permissions | -rw-r--r-- |
| 314 | 1 |
var socket, |
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
2 |
paper, |
|
325
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
3 |
tweetData = { |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
4 |
"tweetcount" : 0, |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
5 |
"position" : -1, |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
6 |
"zoomLevel" : 3, |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
7 |
"timeLevel" : 2 |
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
8 |
}, |
|
325
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
9 |
zoomLevels = [ |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
10 |
{ |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
11 |
"description" : "160 tweets per page", |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
12 |
"className" : "icons", |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
13 |
"displayCount" : 160 |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
14 |
}, |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
15 |
{ |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
16 |
"description" : "24 tweets per page", |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
17 |
"className" : "quarter", |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
18 |
"displayCount" : 24 |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
19 |
}, |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
20 |
{ |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
21 |
"description" : "12 tweets per page", |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
22 |
"className" : "half", |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
23 |
"displayCount" : 12 |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
24 |
}, |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
25 |
{ |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
26 |
"description" : "6 tweets per page", |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
27 |
"className" : "full", |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
28 |
"displayCount" : 6 |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
29 |
} |
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
30 |
], |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
31 |
colors = { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
32 |
'positive' : "#1D973D", |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
33 |
'reference' : "#C5A62D", |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
34 |
'negative' : "#CE0A15", |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
35 |
'question' : "#036AAE" |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
36 |
}, |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
37 |
timeWindow; |
| 314 | 38 |
|
39 |
function tweetToHtml(tweet) { |
|
|
325
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
40 |
html = '<li class="tweet ' + zoomLevels[tweetData.zoomLevel].className; |
| 314 | 41 |
for (var i in tweet.annotations) { |
42 |
html += ' a_' + tweet.annotations[i] |
|
43 |
} |
|
44 |
html += '" id="tweet_' + tweet.id + '">'; |
|
45 |
a_user = '<a href="http://twitter.com/' + tweet.user.screen_name + '" target="_blank" title="' + tweet.user.name + '">'; |
|
46 |
if (tweet.user.profile_image_url) { |
|
47 |
html += a_user + '<img class="tweet_profile_image" src="' + tweet.user.profile_image_url + '" /></a>'; |
|
48 |
} |
|
|
325
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
49 |
html += '<h4>' + a_user + '@' + tweet.user.screen_name + '</a></h4><p class="tweet_created_at">' + new Date(tweet.created_at).toLocaleTimeString() + '</p><p>'; |
| 314 | 50 |
lastend = 0; |
51 |
txt = ''; |
|
52 |
entities = []; |
|
53 |
for (var i in tweet.entities.hashtag) { |
|
54 |
entities.push({ |
|
55 |
"start" : tweet.entities.hashtag[i].indices[0], |
|
56 |
"end" : tweet.entities.hashtag[i].indices[1], |
|
57 |
"html" : '<a href="http://twitter.com/search?q=%23' + tweet.entities.hashtag[i].text + '" target="_blank">#' + tweet.entities.hashtag[i].text + '</a>' |
|
58 |
}); |
|
59 |
} |
|
60 |
for (var i in tweet.entities.urls) { |
|
61 |
entities.push({ |
|
62 |
"start" : tweet.entities.urls[i].indices[0], |
|
63 |
"end" : tweet.entities.urls[i].indices[1], |
|
64 |
"html" : '<a href="' + tweet.entities.urls[i].expanded_url + '" target="_blank">' + tweet.entities.urls[i].display_url + '</a>' |
|
65 |
}); |
|
66 |
} |
|
67 |
for (var i in tweet.entities.user_mentions) { |
|
68 |
entities.push({ |
|
69 |
"start" : tweet.entities.user_mentions[i].indices[0], |
|
70 |
"end" : tweet.entities.user_mentions[i].indices[1], |
|
71 |
"html" : '<a href="http://twitter.com/' + tweet.entities.user_mentions[i].screen_name + '" target="_blank" title="' + tweet.entities.user_mentions[i].name + '">@' + tweet.entities.user_mentions[i].screen_name + '</a>' |
|
72 |
}); |
|
73 |
} |
|
74 |
entities.sort(function(a, b) { return a.start - b.start }); |
|
75 |
for (var i in entities) { |
|
76 |
txt += tweet.text.substring(lastend, entities[i].start) + entities[i].html; |
|
77 |
lastend = entities[i].end; |
|
78 |
} |
|
79 |
txt += tweet.text.substring(lastend); |
|
80 |
html += txt + '</p></li>'; |
|
81 |
return html; |
|
82 |
} |
|
83 |
||
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
84 |
function displayTweets() { |
|
325
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
85 |
var to = tweetData.position + 1, |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
86 |
from = Math.max(0, to - zoomLevels[tweetData.zoomLevel].displayCount); |
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
87 |
socket.emit('getTweets',{ "from": from, "to": to, "callback" : "display" }); |
|
325
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
88 |
} |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
89 |
|
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
90 |
function setZoom(level) { |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
91 |
tweetData.zoomLevel = Math.max(0, Math.min( zoomLevels.length - 1 , level ) ); |
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
92 |
displayTweets(); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
93 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
94 |
|
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
95 |
function setTimeZoom(level) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
96 |
tweetData.timeLevel = Math.max(0, Math.min( 3, level )); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
97 |
getTimeline(); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
98 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
99 |
|
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
100 |
function getTimeline() { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
101 |
socket.emit('getTimeline',{"level":tweetData.timeLevel}); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
102 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
103 |
|
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
104 |
function showTimeWindow() { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
105 |
if (timeWindow) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
106 |
timeWindow.remove(); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
107 |
timeWindow = null; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
108 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
109 |
if (tweetData.tweetsOnDisplay && tweetData.timelineOnDisplay) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
110 |
var dtfintl = new Date ( tweetData.timelineOnDisplay[ tweetData.timelineOnDisplay.length - 1 ].end ), |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
111 |
dtdebtl = new Date ( tweetData.timelineOnDisplay[0].start ), |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
112 |
dtfintw = new Date( tweetData.tweetsOnDisplay[0].created_at ), |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
113 |
dtdebtw = new Date( tweetData.tweetsOnDisplay[ tweetData.tweetsOnDisplay.length - 1 ].created_at ), |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
114 |
scaleY = 600 / ( dtfintl - dtdebtl ); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
115 |
timeWindow = paper.rect( 0, scaleY * ( dtfintl - dtfintw ), 600, scaleY * ( dtfintw - dtdebtw )).attr({"stroke":"#000080","fill":"#8080ff","fill-opacity":.2}); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
116 |
} |
| 314 | 117 |
} |
118 |
||
119 |
$(document).ready(function() { |
|
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
120 |
paper = Raphael("timeline", 160, 600); |
| 314 | 121 |
socket = io.connect('http://' + S_IO_HOST + ':' + S_IO_PORT ); |
|
325
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
122 |
socket.on('tweetSummary', function (data) { |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
123 |
if (tweetData.position == tweetData.tweetcount - 1) { |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
124 |
tweetData.position = data.tweetcount - 1; |
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
125 |
displayTweets(); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
126 |
getTimeline(); |
|
325
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
127 |
} |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
128 |
tweetData.tweetcount = data.tweetcount; |
|
7d9c576bfaac
Some changes - added multi-zoom level on client
Raphael Velt <raph.velt@gmail.com>
parents:
314
diff
changeset
|
129 |
}); |
| 314 | 130 |
socket.on('tweets', function (data) { |
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
131 |
switch (data.callback) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
132 |
case "display": |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
133 |
tweetData.tweetsOnDisplay = data.tweets; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
134 |
tweetData.tweetsOnDisplay.reverse(); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
135 |
html = ''; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
136 |
for (var i in tweetData.tweetsOnDisplay) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
137 |
html += tweetToHtml(tweetData.tweetsOnDisplay[i]); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
138 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
139 |
$("#tweetlist").html(html); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
140 |
showTimeWindow(); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
141 |
break; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
142 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
143 |
}); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
144 |
socket.on('timeline', function (data) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
145 |
tweetData.timelineOnDisplay = data.timeline; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
146 |
paper.clear(); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
147 |
timeWindow = null; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
148 |
var max = 0; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
149 |
for (var i in data.timeline) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
150 |
max = Math.max(max, data.timeline[i].tweets.length); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
151 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
152 |
var scaleX = 160 / max, |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
153 |
scaleY = 600 / data.timeline.length, |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
154 |
tmptw = []; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
155 |
for (var i = 0; i < tweetData.tweetcount; i++) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
156 |
tmptw.push({}); |
| 314 | 157 |
} |
|
326
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
158 |
for (var i = 0; i < data.timeline.length; i++) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
159 |
for (var j = 0; j < data.timeline[i].tweets.length; j++) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
160 |
var coul = "#585858"; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
161 |
for (var k in data.timeline[i].annotations) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
162 |
if (data.timeline[i].annotations[k].indexOf(data.timeline[i].tweets[j]) != -1) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
163 |
coul = colors[k]; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
164 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
165 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
166 |
tmptw[data.timeline[i].tweets[j]].y = i; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
167 |
tmptw[data.timeline[i].tweets[j]].x = j; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
168 |
paper.rect(scaleX * j + (scaleX > 3 ? .5 : 0), 600 - ((i+1) * scaleY) + (scaleY > 3 ? .5 : 0), scaleX - (scaleX > 3 ? 1 : 0), scaleY - (scaleY > 3 ? 1 : 0)).attr({"stroke":"none","fill":coul}); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
169 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
170 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
171 |
for (var i = 0; i < data.arcs.length; i++) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
172 |
var x1 = scaleX * (tmptw[data.arcs[i].from].x + .5), |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
173 |
x2 = scaleX * (tmptw[data.arcs[i].to].x + .5), |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
174 |
y1 = 600 - scaleY * (tmptw[data.arcs[i].from].y + .5), |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
175 |
y2 = 600 - scaleY * (tmptw[data.arcs[i].to].y + .5), |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
176 |
d = "M"+x1+" "+y1+"C"; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
177 |
if (y1 == y2) { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
178 |
d += x1+" "+(y1 - 60)+" "+x2+" "+(y2 - 60); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
179 |
} else { |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
180 |
d += (x1 + 60)+" "+y1+" "+(x2 + 60)+" "+y2; |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
181 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
182 |
paper.path(d+" "+x2+" "+y2); |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
183 |
} |
|
c28048fb63b4
Added visual timeline feature to node client
Raphael Velt <raph.velt@gmail.com>
parents:
325
diff
changeset
|
184 |
showTimeWindow(); |
| 314 | 185 |
}); |
186 |
}); |