validatePost -> postInvalid
This commit is contained in:
parent
9cb6205aa3
commit
e85083cd1b
@ -1209,7 +1209,7 @@
|
|||||||
submit.disabled = false;
|
submit.disabled = false;
|
||||||
submit.value = 'Submit';
|
submit.value = 'Submit';
|
||||||
}
|
}
|
||||||
if (!qr.validatePost()) {
|
if (!qr.postInvalid()) {
|
||||||
return qr.submit.call($('form', qr.el));
|
return qr.submit.call($('form', qr.el));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1247,37 +1247,6 @@
|
|||||||
oldFile = $('#qr_form input[type=file]', qr.el);
|
oldFile = $('#qr_form input[type=file]', qr.el);
|
||||||
return $.replace(oldFile, file);
|
return $.replace(oldFile, file);
|
||||||
},
|
},
|
||||||
validatePost: function() {
|
|
||||||
var captcha, captchas, content, cutoff, responseField;
|
|
||||||
content = $('textarea', qr.el).value || $('input[type=file]', qr.el).files.length;
|
|
||||||
if (!content) {
|
|
||||||
return 'Error: No text entered.';
|
|
||||||
}
|
|
||||||
responseField = $('#recaptcha_response_field', qr.el);
|
|
||||||
if (responseField.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
captchas expire after 5 hours (couldn't find an official source, so
|
|
||||||
anonymous empirically verified). cutoff 5 minutes before then, b/c posting
|
|
||||||
takes time.
|
|
||||||
*/
|
|
||||||
cutoff = Date.now() - 5 * HOUR + 5 * MINUTE;
|
|
||||||
captchas = $.get('captchas', []);
|
|
||||||
while (captcha = captchas.shift()) {
|
|
||||||
if (captcha.time > cutoff) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$.set('captchas', captchas);
|
|
||||||
responseField.nextSibling.textContent = captchas.length + ' captchas';
|
|
||||||
if (!captcha) {
|
|
||||||
return 'You forgot to type in the verification.';
|
|
||||||
}
|
|
||||||
$('#recaptcha_challenge_field', qr.el).value = captcha.challenge;
|
|
||||||
responseField.value = captcha.response;
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
captchaNode: function(e) {
|
captchaNode: function(e) {
|
||||||
var target;
|
var target;
|
||||||
if (!qr.el) {
|
if (!qr.el) {
|
||||||
@ -1380,6 +1349,37 @@
|
|||||||
quote = $('a.quotejs:not(:first-child)', root);
|
quote = $('a.quotejs:not(:first-child)', root);
|
||||||
return $.bind(quote, 'click', qr.quote);
|
return $.bind(quote, 'click', qr.quote);
|
||||||
},
|
},
|
||||||
|
postInvalid: function() {
|
||||||
|
var captcha, captchas, content, cutoff, responseField;
|
||||||
|
content = $('textarea', qr.el).value || $('input[type=file]', qr.el).files.length;
|
||||||
|
if (!content) {
|
||||||
|
return 'Error: No text entered.';
|
||||||
|
}
|
||||||
|
responseField = $('#recaptcha_response_field', qr.el);
|
||||||
|
if (responseField.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
captchas expire after 5 hours (couldn't find an official source, so
|
||||||
|
anonymous empirically verified). cutoff 5 minutes before then, b/c posting
|
||||||
|
takes time.
|
||||||
|
*/
|
||||||
|
cutoff = Date.now() - 5 * HOUR + 5 * MINUTE;
|
||||||
|
captchas = $.get('captchas', []);
|
||||||
|
while (captcha = captchas.shift()) {
|
||||||
|
if (captcha.time > cutoff) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$.set('captchas', captchas);
|
||||||
|
responseField.nextSibling.textContent = captchas.length + ' captchas';
|
||||||
|
if (!captcha) {
|
||||||
|
return 'You forgot to type in the verification.';
|
||||||
|
}
|
||||||
|
$('#recaptcha_challenge_field', qr.el).value = captcha.challenge;
|
||||||
|
responseField.value = captcha.response;
|
||||||
|
return false;
|
||||||
|
},
|
||||||
quote: function(e) {
|
quote: function(e) {
|
||||||
var id, s, selection, selectionID, ta, text, _ref;
|
var id, s, selection, selectionID, ta, text, _ref;
|
||||||
if (e) {
|
if (e) {
|
||||||
@ -1414,7 +1414,7 @@
|
|||||||
},
|
},
|
||||||
submit: function(e) {
|
submit: function(e) {
|
||||||
var id, msg, op;
|
var id, msg, op;
|
||||||
if (msg = qr.validatePost()) {
|
if (msg = qr.postInvalid()) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
alert(msg);
|
alert(msg);
|
||||||
if (msg === 'You forgot to type in the verification.') {
|
if (msg === 'You forgot to type in the verification.') {
|
||||||
|
|||||||
@ -954,7 +954,7 @@ cooldown =
|
|||||||
for submit in submits
|
for submit in submits
|
||||||
submit.disabled = false
|
submit.disabled = false
|
||||||
submit.value = 'Submit'
|
submit.value = 'Submit'
|
||||||
unless qr.validatePost()
|
unless qr.postInvalid()
|
||||||
qr.submit.call $ 'form', qr.el
|
qr.submit.call $ 'form', qr.el
|
||||||
|
|
||||||
qr =
|
qr =
|
||||||
@ -989,35 +989,6 @@ qr =
|
|||||||
oldFile = $ '#qr_form input[type=file]', qr.el
|
oldFile = $ '#qr_form input[type=file]', qr.el
|
||||||
$.replace oldFile, file
|
$.replace oldFile, file
|
||||||
|
|
||||||
validatePost: ->
|
|
||||||
content = $('textarea', qr.el).value or $('input[type=file]', qr.el).files.length
|
|
||||||
return 'Error: No text entered.' unless content
|
|
||||||
|
|
||||||
responseField = $ '#recaptcha_response_field', qr.el
|
|
||||||
return if responseField.value
|
|
||||||
|
|
||||||
###
|
|
||||||
captchas expire after 5 hours (couldn't find an official source, so
|
|
||||||
anonymous empirically verified). cutoff 5 minutes before then, b/c posting
|
|
||||||
takes time.
|
|
||||||
###
|
|
||||||
|
|
||||||
cutoff = Date.now() - 5*HOUR + 5*MINUTE
|
|
||||||
captchas = $.get 'captchas', []
|
|
||||||
while captcha = captchas.shift()
|
|
||||||
if captcha.time > cutoff
|
|
||||||
break
|
|
||||||
$.set 'captchas', captchas
|
|
||||||
|
|
||||||
responseField.nextSibling.textContent = captchas.length + ' captchas'
|
|
||||||
|
|
||||||
return 'You forgot to type in the verification.' unless captcha
|
|
||||||
|
|
||||||
$('#recaptcha_challenge_field', qr.el).value = captcha.challenge
|
|
||||||
responseField.value = captcha.response
|
|
||||||
|
|
||||||
false
|
|
||||||
|
|
||||||
captchaNode: (e) ->
|
captchaNode: (e) ->
|
||||||
return unless qr.el
|
return unless qr.el
|
||||||
{target} = e
|
{target} = e
|
||||||
@ -1127,6 +1098,35 @@ qr =
|
|||||||
quote = $ 'a.quotejs:not(:first-child)', root
|
quote = $ 'a.quotejs:not(:first-child)', root
|
||||||
$.bind quote, 'click', qr.quote
|
$.bind quote, 'click', qr.quote
|
||||||
|
|
||||||
|
postInvalid: ->
|
||||||
|
content = $('textarea', qr.el).value or $('input[type=file]', qr.el).files.length
|
||||||
|
return 'Error: No text entered.' unless content
|
||||||
|
|
||||||
|
responseField = $ '#recaptcha_response_field', qr.el
|
||||||
|
return if responseField.value
|
||||||
|
|
||||||
|
###
|
||||||
|
captchas expire after 5 hours (couldn't find an official source, so
|
||||||
|
anonymous empirically verified). cutoff 5 minutes before then, b/c posting
|
||||||
|
takes time.
|
||||||
|
###
|
||||||
|
|
||||||
|
cutoff = Date.now() - 5*HOUR + 5*MINUTE
|
||||||
|
captchas = $.get 'captchas', []
|
||||||
|
while captcha = captchas.shift()
|
||||||
|
if captcha.time > cutoff
|
||||||
|
break
|
||||||
|
$.set 'captchas', captchas
|
||||||
|
|
||||||
|
responseField.nextSibling.textContent = captchas.length + ' captchas'
|
||||||
|
|
||||||
|
return 'You forgot to type in the verification.' unless captcha
|
||||||
|
|
||||||
|
$('#recaptcha_challenge_field', qr.el).value = captcha.challenge
|
||||||
|
responseField.value = captcha.response
|
||||||
|
|
||||||
|
false
|
||||||
|
|
||||||
quote: (e) ->
|
quote: (e) ->
|
||||||
e.preventDefault() if e
|
e.preventDefault() if e
|
||||||
|
|
||||||
@ -1157,7 +1157,7 @@ qr =
|
|||||||
$('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value
|
$('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value
|
||||||
|
|
||||||
submit: (e) ->
|
submit: (e) ->
|
||||||
if msg = qr.validatePost()
|
if msg = qr.postInvalid()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
alert msg
|
alert msg
|
||||||
if msg is 'You forgot to type in the verification.'
|
if msg is 'You forgot to type in the verification.'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user