ldc-groupe/resources/views/components/front/pages/contact/contact-form-script.blade.php
2026-05-28 17:00:54 +02:00

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