From af0f905e2487bd00a0c888f1ddc704fb8ce44731 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 7 Dec 2009 09:55:12 +0000 Subject: If the XHR error suggests that the xhr.status is 0 (i.e., it didn't receive an XHR object as expected), threat it as a success like HTTP 20x or 30x because the notice most likely went through. jquery.form.js (for file uploads) and meteor.js both use an iframe and they (somehow) appear to be in conflict. Notice always goes through, however, xhr.status is 0. Further investigation is needed. --- js/util.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index 73fcf37be..259d56659 100644 --- a/js/util.js +++ b/js/util.js @@ -192,12 +192,13 @@ var SN = { // StatusNet form.append(document._importNode($('.'+SN.C.S.Error, xhr.responseXML)[0], true)); } else { - if(jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) < 0) { - form.append('

(Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.

'); } } } -- cgit v1.2.3-54-g00ecf From c9b6a90c99691089e8552fb3094e6432766233ed Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 7 Dec 2009 10:08:07 +0000 Subject: Use .resetForm() instead of manually setting notice form's control values to null --- js/util.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index 259d56659..c6e546bd0 100644 --- a/js/util.js +++ b/js/util.js @@ -249,9 +249,7 @@ var SN = { // StatusNet form.append('

'+result_title+'

'); } } - $('#'+form_id+' #'+SN.C.S.NoticeDataText).val(''); - $('#'+form_id+' #'+SN.C.S.NoticeDataAttach).val(''); - $('#'+form_id+' #'+SN.C.S.NoticeInReplyTo).val(''); + $('#'+form_id).resetForm(); $('#'+form_id+' #'+SN.C.S.NoticeDataAttachSelected).remove(); SN.U.FormNoticeEnhancements($('#'+form_id)); } -- cgit v1.2.3-54-g00ecf From 5a55b5a3ce2247ae37bad840a797b00748732f47 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 7 Dec 2009 10:10:17 +0000 Subject: Fixed missing " for element attribute --- js/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index c6e546bd0..972c97d12 100644 --- a/js/util.js +++ b/js/util.js @@ -185,7 +185,7 @@ var SN = { // StatusNet $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled, SN.C.S.Disabled); if (textStatus == 'timeout') { - form.append('

Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.

'); } else { if ($('.'+SN.C.S.Error, xhr.responseXML).length > 0) { @@ -198,7 +198,7 @@ var SN = { // StatusNet SN.U.FormNoticeEnhancements($('#'+form_id)); } else { - form.append('

(Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.

'); } } } -- cgit v1.2.3-54-g00ecf From c4f329ed54dbaca99fe1589f0c8d715e875743e5 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 7 Dec 2009 10:26:29 +0000 Subject: Added form_response class to XHR notice posts --- js/util.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'js/util.js') diff --git a/js/util.js b/js/util.js index 972c97d12..ed6a781f7 100644 --- a/js/util.js +++ b/js/util.js @@ -184,8 +184,9 @@ var SN = { // StatusNet form.removeClass(SN.C.S.Processing); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled, SN.C.S.Disabled); + $('#'+form_id+' .form_response').remove(); if (textStatus == 'timeout') { - form.append('

Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.

'); + form.append('

Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.

'); } else { if ($('.'+SN.C.S.Error, xhr.responseXML).length > 0) { @@ -198,17 +199,18 @@ var SN = { // StatusNet SN.U.FormNoticeEnhancements($('#'+form_id)); } else { - form.append('

(Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.

'); + form.append('

(Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.

'); } } } }, success: function(data, textStatus) { + $('#'+form_id+' .form_response').remove(); var result; if ($('#'+SN.C.S.Error, data).length > 0) { result = document._importNode($('p', data)[0], true); result = result.textContent || result.innerHTML; - form.append('

'+result+'

'); + form.append('

'+result+'

'); } else { if($('body')[0].id == 'bookmarklet') { @@ -218,7 +220,7 @@ var SN = { // StatusNet if ($('#'+SN.C.S.CommandResult, data).length > 0) { result = document._importNode($('p', data)[0], true); result = result.textContent || result.innerHTML; - form.append('

'+result+'

'); + form.append('

'+result+'

'); } else { var notices = $('#notices_primary .notices'); @@ -246,7 +248,7 @@ var SN = { // StatusNet else { result = document._importNode($('title', data)[0], true); result_title = result.textContent || result.innerHTML; - form.append('

'+result_title+'

'); + form.append('

'+result_title+'

'); } } $('#'+form_id).resetForm(); -- cgit v1.2.3-54-g00ecf