summaryrefslogtreecommitdiff
path: root/js/util.js
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-05-25 22:47:23 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-05-25 22:47:23 -0400
commit76aa85fe5ef408cecf7c40c0c56d58ff9ac9fcbb (patch)
treef2bd52d08e421f934bc8466ab1ecb4facbbcc6a5 /js/util.js
parentb140bcdee4b1f4c8f2f34a89a9c5c51e7ecfe826 (diff)
parent68d90bcab04713d53cf3731d45729a617e68a2fa (diff)
Merge branch '0.8.x' into stats
Conflicts: README
Diffstat (limited to 'js/util.js')
-rw-r--r--js/util.js45
1 files changed, 37 insertions, 8 deletions
diff --git a/js/util.js b/js/util.js
index 81139744f..31d9eb4f5 100644
--- a/js/util.js
+++ b/js/util.js
@@ -17,6 +17,10 @@
*/
$(document).ready(function(){
+ $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; });
+ }, url:$(this).attr('href') + '/ajax'}); return false; });
+ $('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; });
+
// count character on keyup
function counter(event){
var maxLength = 140;
@@ -166,19 +170,45 @@ $(document).ready(function(){
$("#notice_action-submit").addClass("disabled");
return true;
},
- success: function(xml) { if ($("#error", xml).length > 0 || $("#command_result", xml).length > 0) {
+ timeout: '60000',
+ 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 {
+ if ($(".error", xhr.responseXML).length > 0) {
+ $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true));
+ }
+ else {
+ 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) {
var result = document._importNode($("p", xml).get(0), true);
result = result.textContent || result.innerHTML;
alert(result);
}
else {
- $("#notices_primary .notices").prepend(document._importNode($("li", xml).get(0), true));
+ if ($("#command_result", xml).length > 0) {
+ var result = document._importNode($("p", xml).get(0), true);
+ result = result.textContent || result.innerHTML;
+ alert(result);
+ }
+ else {
+ li = $("li", xml).get(0);
+ 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();
- $("#notices_primary .notice:first").css({display:"none"});
- $("#notices_primary .notice:first").fadeIn(2500);
- NoticeHover();
- NoticeReply();
+ counter();
}
$("#form_notice").removeClass("processing");
$("#notice_action-submit").removeAttr("disabled");
@@ -187,7 +217,6 @@ $(document).ready(function(){
};
$("#form_notice").ajaxForm(PostNotice);
$("#form_notice").each(addAjaxHidden);
-
NoticeHover();
NoticeReply();
});