1 // update the local timeline from a Comet server
4 var updater = function()
9 init: function(server, timeline)
11 _cometd = $.cometd; // Uses the default Comet object
12 _cometd.setLogLevel('debug');
14 _cometd.subscribe(timeline, receive);
15 $(window).unload(leave);
24 function receive(message)
28 // Don't add it if it already exists
30 if ($("#notice-"+id).length > 0) {
34 var noticeItem = makeNoticeItem(message.data);
35 $("#notices_primary .notices").prepend(noticeItem, true);
36 $("#notices_primary .notice:first").css({display:"none"});
37 $("#notices_primary .notice:first").fadeIn(2500);
42 function makeNoticeItem(data)
45 html = data['html'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
47 ni = "<li class=\"hentry notice\" id=\"notice-"+data['id']+"\">"+
48 "<div class=\"entry-title\">"+
49 "<span class=\"vcard author\">"+
50 "<a href=\""+user['profile_url']+"\" class=\"url\">"+
51 "<img src=\""+user['profile_image_url']+"\" class=\"avatar photo\" width=\"48\" height=\"48\" alt=\""+user['screen_name']+"\"/>"+
52 "<span class=\"nickname fn\">"+user['screen_name']+"</span>"+
55 "<p class=\"entry-content\">"+html+"</p>"+
57 "<div class=\"entry-content\">"+
58 "<dl class=\"timestamp\">"+
61 "<a rel=\"bookmark\" href=\""+data['url']+"\" >"+
62 "<abbr class=\"published\" title=\""+data['created_at']+"\">a few seconds ago</abbr>"+
66 "<dl class=\"device\">"+
68 "<dd>"+data['source']+"</dd>"+
71 "<div class=\"notice-options\">"+