Display message when a form is ratelimited.

This commit is contained in:
Max Goodman
2012-10-28 00:38:29 -07:00
parent 54d6ae3ef7
commit 7fd0c04956
3 changed files with 19 additions and 6 deletions

View File

@@ -178,6 +178,7 @@ Note: there are a couple of places outside of your subreddit where someone can c
an_error_occurred = _("an error occurred"),
an_error_occurred_friendly = _("an error occurred. please try again later!"),
rate_limit = _("please wait a few seconds and try again."),
)
class StringHandler(object):

View File

@@ -169,8 +169,16 @@ $.request = function(op, parameters, worker_in, block, type,
var action = op;
var worker = worker_in;
if (rate_limit(op) || (window != window.top && !reddit.cnameframe && !reddit.external_frame))
return;
if (rate_limit(op)) {
if (errorhandler) {
errorhandler('ratelimit')
}
return
}
if (window != window.top && !reddit.cnameframe && !reddit.external_frame) {
return
}
/* we have a lock if we are not blocking or if we have gotten a lock */
var have_lock = !$.with_default(block, false) || acquire_ajax_lock(action);

View File

@@ -98,10 +98,14 @@ function get_form_fields(form, fields, filter_func) {
};
function form_error(form) {
return function(r) {
$(form).find(".status")
.html("an error occurred while posting " +
"(status: " + r.status + ")").end();
return function(req) {
var msg
if (req == 'ratelimit') {
msg = r.strings.rate_limit
} else {
msg = 'an error occurred while posting (status: ' + req.status + ')'
}
$(form).find('.status').text(msg)
}
}