try to fix auto posting

This commit is contained in:
James Campos 2011-08-10 21:51:04 -07:00
parent 8894e35ece
commit 3e1f5b84d8
2 changed files with 23 additions and 13 deletions

View File

@ -1252,7 +1252,11 @@
anonymous empirically verified). cutoff 5 minutes before then, b/c posting
takes time.
*/
var captcha, captchas, cutoff, responseField;
var blank, captcha, captchas, cutoff, responseField;
blank = !$('textarea', qr.el).value && !$('input[type=file]', qr.el).files.length;
if (blank) {
return;
}
cutoff = Date.now() - 5 * HOUR + 5 * MINUTE;
captchas = $.get('captchas', []);
while (captcha = captchas.shift()) {
@ -1264,12 +1268,13 @@
responseField = $('#recaptcha_response_field', qr.el);
responseField.nextSibling.textContent = captchas.length + ' captchas';
if (!captcha) {
alert('You forgot to type in the verification.');
responseField.focus();
return;
}
$('#recaptcha_challenge_field', qr.el).value = captcha.challenge;
responseField.value = captcha.response;
qr.submit.call($('form', qr.el));
return true;
return qr.submit.call($('form', qr.el));
},
captchaNode: function(e) {
var target;
@ -1290,6 +1295,8 @@
if (!(blank || cooldown.duration)) {
return;
}
e.stopPropagation();
e.preventDefault();
$('#auto', qr.el).checked = true;
if (conf['Auto Hide QR']) {
$('#autohide', qr.el).checked = true;
@ -1414,9 +1421,7 @@
var id, isQR, op;
if ($('#recaptcha_response_field', qr.el).value === '') {
e.preventDefault();
if (!qr.autoPost()) {
alert('You forgot to type in the verification.');
}
qr.autoPost();
return;
}
if (conf['Auto Watch Reply'] && conf['Thread Watcher']) {

View File

@ -994,25 +994,28 @@ qr =
takes time.
###
blank = !$('textarea', qr.el).value and !$('input[type=file]', qr.el).files.length
return if blank
cutoff = Date.now() - 5*HOUR + 5*MINUTE
captchas = $.get 'captchas', []
while captcha = captchas.shift()
if captcha.time > cutoff
break
$.set 'captchas', captchas
responseField = $ '#recaptcha_response_field', qr.el
responseField.nextSibling.textContent = captchas.length + ' captchas'
return unless captcha
unless captcha
alert 'You forgot to type in the verification.'
responseField.focus()
return
$('#recaptcha_challenge_field', qr.el).value = captcha.challenge
responseField.value = captcha.response
qr.submit.call $ 'form', qr.el
true
captchaNode: (e) ->
return unless qr.el
{target} = e
@ -1026,6 +1029,9 @@ qr =
blank = !$('textarea', qr.el).value and !$('input[type=file]', qr.el).files.length
return unless blank or cooldown.duration
e.stopPropagation()
e.preventDefault()
$('#auto', qr.el).checked = true
$('#autohide', qr.el).checked = true if conf['Auto Hide QR']
@ -1156,8 +1162,7 @@ qr =
submit: (e) ->
if $('#recaptcha_response_field', qr.el).value is ''
e.preventDefault()
unless qr.autoPost()
alert 'You forgot to type in the verification.'
qr.autoPost()
return
if conf['Auto Watch Reply'] and conf['Thread Watcher']