If the page doesn't have .notices, silently skip the notice XHR response

This commit is contained in:
Sarven Capadisli 2009-12-02 23:13:15 +01:00
parent 5f0c6f3eaa
commit 7b550f386a
1 changed files with 33 additions and 29 deletions

View File

@ -214,37 +214,41 @@ var SN = { // StatusNet
self.close(); self.close();
} }
if ($('#'+SN.C.S.CommandResult, data).length > 0) { var notices = $("#notices_primary .notices");
result = document._importNode($('p', data)[0], true);
result = result.textContent || result.innerHTML; if (notices.length > 0) {
form.append('<p class="success">'+result+'</p>'); if ($('#'+SN.C.S.CommandResult, data).length > 0) {
} result = document._importNode($('p', data)[0], true);
else { result = result.textContent || result.innerHTML;
notice = document._importNode($('li', data)[0], true); form.append('<p class="success">'+result+'</p>');
if ($('#'+notice.id).length === 0) { }
var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).val(); else {
var notice_irt = '#notices_primary #notice-'+notice_irt_value; notice = document._importNode($('li', data)[0], true);
if($('body')[0].id == 'conversation') { if ($('#'+notice.id).length === 0) {
if(notice_irt_value.length > 0 && $(notice_irt+' .notices').length < 1) { var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).val();
$(notice_irt).append('<ul class="notices"></ul>'); var notice_irt = '#notices_primary #notice-'+notice_irt_value;
if($('body')[0].id == 'conversation') {
if(notice_irt_value.length > 0 && $(notice_irt+' .notices').length < 1) {
$(notice_irt).append('<ul class="notices"></ul>');
}
$($(notice_irt+' .notices')[0]).append(notice);
} }
$($(notice_irt+' .notices')[0]).append(notice); else {
} notices.prepend(notice);
else { }
$("#notices_primary .notices").prepend(notice); $('#'+notice.id).css({display:'none'});
} $('#'+notice.id).fadeIn(2500);
$('#'+notice.id).css({display:'none'}); SN.U.NoticeWithAttachment($('#'+notice.id));
$('#'+notice.id).fadeIn(2500); SN.U.NoticeReplyTo($('#'+notice.id));
SN.U.NoticeWithAttachment($('#'+notice.id)); SN.U.FormXHR($('#'+notice.id+' .form_favor'));
SN.U.NoticeReplyTo($('#'+notice.id)); }
SN.U.FormXHR($('#'+notice.id+' .form_favor')); }
} $('#'+form_id+' #'+SN.C.S.NoticeDataText).val('');
$('#'+form_id+' #'+SN.C.S.NoticeDataAttach).val('');
$('#'+form_id+' #'+SN.C.S.NoticeInReplyTo).val('');
$('#'+form_id+' #'+SN.C.S.NoticeDataAttachSelected).remove();
SN.U.FormNoticeEnhancements($('#'+form_id));
} }
$('#'+form_id+' #'+SN.C.S.NoticeDataText).val('');
$('#'+form_id+' #'+SN.C.S.NoticeDataAttach).val('');
$('#'+form_id+' #'+SN.C.S.NoticeInReplyTo).val('');
$('#'+form_id+' #'+SN.C.S.NoticeDataAttachSelected).remove();
SN.U.FormNoticeEnhancements($('#'+form_id));
} }
}, },
complete: function(xhr, textStatus) { complete: function(xhr, textStatus) {