Fixed a bug where input name captcha-verified was not sent.
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
const domain = element.getAttribute('data-domain');
|
||||
const token = element.getAttribute('data-token');
|
||||
const staticPath = element.getAttribute('data-static-path');
|
||||
const captchaVerifiedName = element.getAttribute('data-captcha-verified-name');
|
||||
|
||||
let windowCaptcha = null;
|
||||
|
||||
@@ -22,14 +21,14 @@
|
||||
shadow.appendChild(button);
|
||||
button.addEventListener('click', function () {
|
||||
if (windowCaptcha === null) {
|
||||
windowCaptcha = createWindowCaptcha(shadow, domain, token, captchaVerifiedName);
|
||||
windowCaptcha = createWindowCaptcha(shadow, domain, token, element);
|
||||
}
|
||||
windowCaptcha.style.display = 'block';
|
||||
actionGetCaptcha(windowCaptcha, domain, token, shadow, captchaVerifiedName);
|
||||
actionGetCaptcha(windowCaptcha, domain, token, shadow, element);
|
||||
});
|
||||
});
|
||||
|
||||
function createWindowCaptcha (shadow, domain, token, captchaVerifiedName) {
|
||||
function createWindowCaptcha (shadow, domain, token, element) {
|
||||
const windowCaptcha = document.createElement('div');
|
||||
windowCaptcha.classList.add('window-captcha');
|
||||
windowCaptcha.innerHTML = `<div class="window-captcha__content">
|
||||
@@ -50,7 +49,7 @@
|
||||
});
|
||||
|
||||
windowCaptcha.querySelector('button.window-captcha__reload').addEventListener('click', function () {
|
||||
actionGetCaptcha(windowCaptcha, domain, token, shadow, captchaVerifiedName);
|
||||
actionGetCaptcha(windowCaptcha, domain, token, shadow, element);
|
||||
});
|
||||
|
||||
return windowCaptcha;
|
||||
@@ -61,7 +60,7 @@
|
||||
windowCaptcha.style.display = 'none';
|
||||
}
|
||||
|
||||
function actionGetCaptcha(windowCaptcha, domain, token, shadow, captchaVerifiedName)
|
||||
function actionGetCaptcha(windowCaptcha, domain, token, shadow, element)
|
||||
{
|
||||
let bodyBlock = windowCaptcha.querySelector('div.window-captcha__content__body');
|
||||
if (bodyBlock.querySelectorAll('.loading').length > 0) {
|
||||
@@ -117,7 +116,7 @@
|
||||
});
|
||||
|
||||
bodyBlock.querySelector('.window-captcha__content__body__button').addEventListener('click', function () {
|
||||
checkingCaptcha(bodyBlock, domain, token, shadow, captchaVerifiedName);
|
||||
checkingCaptcha(bodyBlock, domain, token, shadow, element);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -125,7 +124,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
function checkingCaptcha (bodyBlock, domain, token, shadow, captchaVerifiedName) {
|
||||
function checkingCaptcha (bodyBlock, domain, token, shadow, element) {
|
||||
let button = bodyBlock.querySelector('button.window-captcha__content__body__button');
|
||||
if (button.querySelectorAll('.loading').length > 0) {
|
||||
return null;
|
||||
@@ -179,9 +178,15 @@
|
||||
}
|
||||
shadow.querySelector('button.button-open-window-captcha').remove();
|
||||
let captchaVerified = document.createElement('div');
|
||||
captchaVerified.innerHTML = `<span class="captcha-verified">Ура!!! Проверку прошли!</span><input type="hidden" name="${ captchaVerifiedName }" value="${ data.captcha_key }">`;
|
||||
captchaVerified.innerHTML = `<span class="captcha-verified">Ура!!! Проверку прошли!</span>`;
|
||||
shadow.appendChild(captchaVerified);
|
||||
shadow.querySelector('.window-captcha').remove();
|
||||
|
||||
const captchaVerifiedInput = document.createElement('input');
|
||||
captchaVerifiedInput.name = element.getAttribute('data-captcha-verified-name');
|
||||
captchaVerifiedInput.value = data.captcha_key;
|
||||
captchaVerifiedInput.type = 'hidden';
|
||||
element.appendChild(captchaVerifiedInput);
|
||||
})
|
||||
.catch(error => {
|
||||
setError('Произошла ошибка!', button)
|
||||
|
Reference in New Issue
Block a user