1 // add a notice encoded as JSON into the current timeline
6 receive: function(message)
10 // Don't add it if it already exists
12 if ($("#notice-"+id).length > 0) {
16 var noticeItem = RealtimeUpdate.makeNoticeItem(data);
17 $("#notices_primary .notices").prepend(noticeItem, true);
18 $("#notices_primary .notice:first").css({display:"none"});
19 $("#notices_primary .notice:first").fadeIn(1000);
24 makeNoticeItem: function(data)
27 html = data['html'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
28 source = data['source'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
30 ni = "<li class=\"hentry notice\" id=\"notice-"+data['id']+"\">"+
31 "<div class=\"entry-title\">"+
32 "<span class=\"vcard author\">"+
33 "<a href=\""+user['profile_url']+"\" class=\"url\">"+
34 "<img src=\""+user['profile_image_url']+"\" class=\"avatar photo\" width=\"48\" height=\"48\" alt=\""+user['screen_name']+"\"/>"+
35 "<span class=\"nickname fn\">"+user['screen_name']+"</span>"+
38 "<p class=\"entry-content\">"+html+"</p>"+
40 "<div class=\"entry-content\">"+
41 "<dl class=\"timestamp\">"+
44 "<a rel=\"bookmark\" href=\""+data['url']+"\" >"+
45 "<abbr class=\"published\" title=\""+data['created_at']+"\">a few seconds ago</abbr>"+
49 "<dl class=\"device\">"+
51 "<dd>"+source+"</dd>"+ // may have a link, I think
54 if (data['in_reply_to_status_id']) {
55 ni = ni+" <dl class=\"response\">"+
58 "<a href=\""+data['in_reply_to_status_url']+"\" rel=\"in-reply-to\">in reply to</a>"+
64 "<div class=\"notice-options\">";
67 var input = $("form#form_notice fieldset input#token");
68 var session_key = input.val();
69 ni = ni+RealtimeUpdate.makeFavoriteForm(data['id'], session_key);
70 ni = ni+RealtimeUpdate.makeReplyLink(data['id'], data['user']['screen_name']);
71 if (_userid == data['user']['id']) {
72 ni = ni+RealtimeUpdate.makeDeleteLink(data['id']);
81 makeFavoriteForm: function(id, session_key)
85 ff = "<form id=\"favor-"+id+"\" class=\"form_favor\" method=\"post\" action=\""+_favorurl+"\">"+
87 "<legend>Favor this notice</legend>"+ // XXX: i18n
88 "<input name=\"token-"+id+"\" type=\"hidden\" id=\"token-"+id+"\" value=\""+session_key+"\"/>"+
89 "<input name=\"notice\" type=\"hidden\" id=\"notice-n"+id+"\" value=\""+id+"\"/>"+
90 "<input type=\"submit\" id=\"favor-submit-"+id+"\" name=\"favor-submit-"+id+"\" class=\"submit\" value=\"Favor\" title=\"Favor this notice\"/>"+
96 makeReplyLink: function(id, nickname)
99 rl = "<dl class=\"notice_reply\">"+
100 "<dt>Reply to this notice</dt>"+
102 "<a href=\""+_replyurl+"?replyto="+nickname+"\" title=\"Reply to this notice\">Reply <span class=\"notice_id\">"+id+"</span>"+
109 makeDeleteLink: function(id)
112 delurl = _deleteurl.replace("0000000000", id);
114 dl = "<dl class=\"notice_delete\">"+
115 "<dt>Delete this notice</dt>"+
117 "<a href=\""+delurl+"\" title=\"Delete this notice\">Delete</a>"+