forked from leftypol/leftypol
quick-reply.js: move recaptcha rendering to function
This commit is contained in:
parent
4f61026842
commit
fccd0a16dd
1 changed files with 45 additions and 41 deletions
|
@ -136,6 +136,50 @@
|
|||
$dummyStuff = $('<div class="nonsense"></div>').appendTo($postForm);
|
||||
|
||||
$postForm.find('table tr').each(function() {
|
||||
function build_recaptcha() {
|
||||
// Just show the image, and have it interact with the real form.
|
||||
var $captchaimg = $td.find('#recaptcha_image img');
|
||||
|
||||
$captchaimg
|
||||
.removeAttr('id')
|
||||
.removeAttr('style')
|
||||
.addClass('recaptcha_image')
|
||||
.click(function() {
|
||||
$('#recaptcha_reload').click();
|
||||
});
|
||||
|
||||
// When we get a new captcha...
|
||||
$('#recaptcha_response_field').focus(function() {
|
||||
if ($captchaimg.attr('src') != $('#recaptcha_image img').attr('src')) {
|
||||
$captchaimg.attr('src', $('#recaptcha_image img').attr('src'));
|
||||
$postForm.find('input[name="recaptcha_challenge_field"]').val($('#recaptcha_challenge_field').val());
|
||||
$postForm.find('input[name="recaptcha_response_field"]').val('').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$postForm.submit(function() {
|
||||
setTimeout(function() {
|
||||
$('#recaptcha_reload').click();
|
||||
}, 200);
|
||||
});
|
||||
|
||||
// Make a new row for the response text
|
||||
var $newRow = $('<tr><td class="recaptcha-response" colspan="2"></td></tr>');
|
||||
$newRow.children().first().append(
|
||||
$td.find('input').removeAttr('style')
|
||||
);
|
||||
$newRow.find('#recaptcha_response_field')
|
||||
.removeAttr('id')
|
||||
.addClass('recaptcha_response_field')
|
||||
.attr('placeholder', $('#recaptcha_response_field').attr('placeholder'));
|
||||
|
||||
$('#recaptcha_response_field').addClass('recaptcha_response_field')
|
||||
|
||||
$td.replaceWith($('<td class="recaptcha" colspan="2"></td>').append($('<span></span>').append($captchaimg)));
|
||||
|
||||
$newRow.insertAfter(this);
|
||||
}
|
||||
|
||||
var $th = $(this).children('th:first');
|
||||
var $td = $(this).children('td:first');
|
||||
if ($th.length && $td.length) {
|
||||
|
@ -168,47 +212,7 @@
|
|||
|
||||
// reCAPTCHA
|
||||
if ($td.find('#recaptcha_widget_div').length) {
|
||||
// Just show the image, and have it interact with the real form.
|
||||
var $captchaimg = $td.find('#recaptcha_image img');
|
||||
|
||||
$captchaimg
|
||||
.removeAttr('id')
|
||||
.removeAttr('style')
|
||||
.addClass('recaptcha_image')
|
||||
.click(function() {
|
||||
$('#recaptcha_reload').click();
|
||||
});
|
||||
|
||||
// When we get a new captcha...
|
||||
$('#recaptcha_response_field').focus(function() {
|
||||
if ($captchaimg.attr('src') != $('#recaptcha_image img').attr('src')) {
|
||||
$captchaimg.attr('src', $('#recaptcha_image img').attr('src'));
|
||||
$postForm.find('input[name="recaptcha_challenge_field"]').val($('#recaptcha_challenge_field').val());
|
||||
$postForm.find('input[name="recaptcha_response_field"]').val('').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$postForm.submit(function() {
|
||||
setTimeout(function() {
|
||||
$('#recaptcha_reload').click();
|
||||
}, 200);
|
||||
});
|
||||
|
||||
// Make a new row for the response text
|
||||
var $newRow = $('<tr><td class="recaptcha-response" colspan="2"></td></tr>');
|
||||
$newRow.children().first().append(
|
||||
$td.find('input').removeAttr('style')
|
||||
);
|
||||
$newRow.find('#recaptcha_response_field')
|
||||
.removeAttr('id')
|
||||
.addClass('recaptcha_response_field')
|
||||
.attr('placeholder', $('#recaptcha_response_field').attr('placeholder'));
|
||||
|
||||
$('#recaptcha_response_field').addClass('recaptcha_response_field')
|
||||
|
||||
$td.replaceWith($('<td class="recaptcha" colspan="2"></td>').append($('<span></span>').append($captchaimg)));
|
||||
|
||||
$newRow.insertAfter(this);
|
||||
build_recaptcha();
|
||||
}
|
||||
|
||||
// Upload section
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue