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

View File

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