From 63c52784c7acc54b0b7b39ff3ca7763774e4ab9a Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 23 Apr 2009 02:22:00 +0000 Subject: Allowing XHR for Inbox/Outbox pages. --- js/util.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index 53e6eb792..13036f7ca 100644 --- a/js/util.js +++ b/js/util.js @@ -192,10 +192,8 @@ $(document).ready(function(){ $("#notice_action-submit").removeClass("disabled"); } }; - if (document.body.id != 'inbox' && document.body.id != 'outbox') { - $("#form_notice").ajaxForm(PostNotice); - $("#form_notice").each(addAjaxHidden); - } + $("#form_notice").ajaxForm(PostNotice); + $("#form_notice").each(addAjaxHidden); NoticeHover(); NoticeReply(); }); -- cgit v1.2.3-54-g00ecf From 2bdf192dabb9dfbbc889c3387bf5261a2d4166ce Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 23 Apr 2009 21:35:21 +0000 Subject: XHR alerts for server-side errors: 404, 502, 503, 504. There is also a 7 second timeout if the server doesn't get back with a response. --- js/util.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'js') diff --git a/js/util.js b/js/util.js index 13036f7ca..c7b1272c8 100644 --- a/js/util.js +++ b/js/util.js @@ -166,6 +166,25 @@ $(document).ready(function(){ $("#notice_action-submit").addClass("disabled"); return true; }, + timeout: 1000, + error: function (xhr, textStatus, errorThrown) { $("#form_notice").removeClass("processing"); + $("#notice_action-submit").removeAttr("disabled"); + $("#notice_action-submit").removeClass("disabled"); + + if (textStatus == "timeout") { + alert ("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists"); + } + else { + switch(xhr.status) { + default: case 404: + alert("Sorry! We had trouble sending your notice. Please report the problem to the site administrator if this happens again."); + break; + case 502: case 503: case 504: + alert("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists."); + break; + } + } + }, success: function(xml) { if ($("#error", xml).length > 0) { var result = document._importNode($("p", xml).get(0), true); result = result.textContent || result.innerHTML; -- cgit v1.2.3-54-g00ecf From 83ba1b0b5ef10dc1101ba35bcde4710fd13179cc Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 23 Apr 2009 21:51:49 +0000 Subject: The real 7 seconds (7000) timeout for XHR posting. --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index c7b1272c8..16422df57 100644 --- a/js/util.js +++ b/js/util.js @@ -166,7 +166,7 @@ $(document).ready(function(){ $("#notice_action-submit").addClass("disabled"); return true; }, - timeout: 1000, + timeout: 7000, error: function (xhr, textStatus, errorThrown) { $("#form_notice").removeClass("processing"); $("#notice_action-submit").removeAttr("disabled"); $("#notice_action-submit").removeClass("disabled"); -- cgit v1.2.3-54-g00ecf From 12867d114d8d40bf9a45b3e1eb9b0e50d736d333 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 24 Apr 2009 17:22:43 +0000 Subject: UI for server errors. --- js/util.js | 15 +++------------ theme/base/css/display.css | 11 +++++++++-- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index 16422df57..15a14625c 100644 --- a/js/util.js +++ b/js/util.js @@ -166,23 +166,14 @@ $(document).ready(function(){ $("#notice_action-submit").addClass("disabled"); return true; }, - timeout: 7000, error: function (xhr, textStatus, errorThrown) { $("#form_notice").removeClass("processing"); $("#notice_action-submit").removeAttr("disabled"); $("#notice_action-submit").removeClass("disabled"); - - if (textStatus == "timeout") { - alert ("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists"); + if ($(".error", xhr.responseXML).length > 0) { + $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true)); } else { - switch(xhr.status) { - default: case 404: - alert("Sorry! We had trouble sending your notice. Please report the problem to the site administrator if this happens again."); - break; - case 502: case 503: case 504: - alert("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists."); - break; - } + alert("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(xml) { if ($("#error", xml).length > 0) { diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 2fb1c007f..0bc2e68b6 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -86,7 +86,7 @@ border:0; .error, .success { -padding:4px 7px; +padding:4px 1.55%; border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; @@ -426,6 +426,7 @@ line-height:1; #form_notice fieldset { border:0; padding:0; +position:relative; } #form_notice legend { display:none; @@ -480,7 +481,13 @@ margin-bottom:7px; margin-left:18px; float:left; } - +#form_notice .error { +float:left; +clear:both; +width:96.9%; +margin-bottom:0; +line-height:1.618; +} /* entity_profile */ .entity_profile { -- cgit v1.2.3-54-g00ecf From 7405d9dfa684975309150537069a1268a67ed6be Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 26 Apr 2009 21:16:09 -0400 Subject: Don't add a node if it's already there Try not to double-add a node on Ajax submit. Normally not a big deal, but may happen if the CometPlugin (or in the future Strophe or other auto-update plugins) is enabled. --- js/util.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index 15a14625c..f15c4f2bb 100644 --- a/js/util.js +++ b/js/util.js @@ -188,11 +188,15 @@ $(document).ready(function(){ alert(result); } else { - $("#notices_primary .notices").prepend(document._importNode($("li", xml).get(0), true)); - $("#notices_primary .notice:first").css({display:"none"}); - $("#notices_primary .notice:first").fadeIn(2500); - NoticeHover(); - NoticeReply(); + li = $("li", xml).get(0); + id = li.id; + if ($("#"+li.id).length == 0) { + $("#notices_primary .notices").prepend(document._importNode(li, true)); + $("#notices_primary .notice:first").css({display:"none"}); + $("#notices_primary .notice:first").fadeIn(2500); + NoticeHover(); + NoticeReply(); + } } $("#notice_data-text").val(""); counter(); -- cgit v1.2.3-54-g00ecf