blob: c6eefb4475bf2cd1f247b956e10fbcda92452e77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// update the local timeline from a Comet server
//
var updater = function()
{
var _cometd;
return {
init: function(server, timeline)
{
_cometd = $.cometd; // Uses the default Comet object
_cometd.setLogLevel('debug');
_cometd.init(server);
_cometd.subscribe(timeline, receive);
$(window).unload(leave);
}
}
function leave()
{
_cometd.disconnect();
}
function receive(message)
{
var noticeItem = makeNoticeItem(message.data);
$("#notices_primary .notices").prepend(noticeItem, true);
$("#notices_primary .notice:first").css({display:"none"});
$("#notices_primary .notice:first").fadeIn(2500);
NoticeHover();
NoticeReply();
}
function makeNoticeItem(data)
{
user = data['user'];
ni = "<li class=\"hentry notice\" id=\"notice-"+data['id']+"\">"+
"<div class=\"entry-title\">"+
"<span class=\"vcard author\">"+
"<a href=\""+user['profile_url']+"\" class=\"url\">"+
"<img src=\""+user['profile_image_url']+"\" class=\"avatar photo\" width=\"48\" height=\"48\" alt=\""+user['screen_name']+"\"/>"+
"<span class=\"nickname fn\">"+user['screen_name']+"</span>"+
"</a>"+
"</span>"+
"<p class=\"entry-content\">"+data['text']+"</p>"+
"</div>"+
"<div class=\"entry-content\">"+
"<dl class=\"timestamp\">"+
"<dt>Published</dt>"+
"<dd>"+
"<a rel=\"bookmark\" href=\""+data['url']+"\" >"+
"<abbr class=\"published\" title=\""+data['created_at']+"\">a few seconds ago</abbr>"+
"</a> "+
"</dd>"+
"</dl>"+
"<dl class=\"device\">"+
"<dt>From</dt> "+
"<dd>"+data['source']+"</dd>"+
"</dl>"+
"</div>"+
"<div class=\"notice-options\">"+
"</div>"+
"</li>";
return ni;
}
}();
|