30 lines
1.3 KiB
PHP
30 lines
1.3 KiB
PHP
@push('scripts')
|
|
<script nonce="{{ $nonce }}">
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const formId = @json($formId);
|
|
const initFormCaptcha = () => {
|
|
const newDiv = document.createElement("div");
|
|
newDiv.classList.add('g-recaptcha');
|
|
document.getElementById('r_captcha').appendChild(newDiv);
|
|
};
|
|
window.__CN_Recaptcha = function() {
|
|
initFormCaptcha();
|
|
(function(d, t) {
|
|
let g = d.createElement(t),
|
|
s = d.getElementsByTagName(t)[0];
|
|
g.src =
|
|
'https://www.google.com/recaptcha/api.js?render=explicit&onload=__CN_Recaptcha_Loaded';
|
|
s.parentNode.insertBefore(g, s)
|
|
}(document, 'script'));
|
|
};
|
|
window.__CN_Recaptcha_Reset = function() {
|
|
document.querySelector('#r_captcha > div')?.remove();
|
|
};
|
|
window.__CN_Recaptcha_Loaded = function() {
|
|
grecaptcha.render(document.querySelector('#r_captcha > div'), {
|
|
'sitekey': '{{ config('services.google.recaptcha.public') }}'
|
|
});
|
|
};
|
|
});
|
|
</script>
|
|
@endpush
|