64 lines
2.6 KiB
Smarty
64 lines
2.6 KiB
Smarty
{ifmodule RECAPTCHA__CLOUDFLARE}
|
|
<div class="wpj-captcha" data-sitekey="{findModule('recaptcha','site_cloudflare')}" data-action="{$action|default:"form"}" data-language="{$ctrl.active_language}"></div>
|
|
|
|
<script>
|
|
if (typeof wpjCaptchaLoaded === 'function') {
|
|
wpjCaptchaLoaded();
|
|
} else {
|
|
var wpjCaptchaLoaded = function () {
|
|
wpj.onReady.push(function () {
|
|
// Hm ... bohužel to musím opozdit o vteřinu, protože pokud nebyl daný kus HTML vidět, nerenderovalo se to správně.
|
|
// A když je to uvnitř focusu, spustí se JS když se script načte, ale je třeba spustit render až když se skutečně zobrazí
|
|
setTimeout(function () {
|
|
window.wpj.captcha.onWpjCaptchaLoad();
|
|
}, 1000);
|
|
});
|
|
};
|
|
}
|
|
</script>
|
|
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=wpjCaptchaLoaded" async defer></script>
|
|
{elsemodule}
|
|
{ifmodule RECAPTCHA__GCLOUD}
|
|
{$sitekey = findModule('recaptcha','gcloud_site')}
|
|
{$script_url = "https://www.google.com/recaptcha/enterprise.js?onload=recaptchaCallback&hl={$ctrl.active_language_code}&render=explicit"}
|
|
{$library = 'grecaptcha.enterprise'}
|
|
<div class="g-recaptcha" data-sitekey="{$sitekey}" data-action="LOGIN"></div>
|
|
{elsemodule}
|
|
{$unique_id=1|mt_rand:100}
|
|
{$sitekey = findModule('recaptcha','site')}
|
|
{$script_url = "https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&hl={$ctrl.active_language_code}&render=explicit"}
|
|
{$library = 'grecaptcha'}
|
|
<div class="g-recaptcha" id="recaptcha-{$unique_id}" data-sitekey="{$sitekey}"></div>
|
|
{/ifmodule}
|
|
<script>
|
|
if (typeof recaptchaCallback === 'function') {
|
|
recaptchaCallback();
|
|
} else {
|
|
var recaptchaCallback = function () {
|
|
if (typeof grecaptcha !== 'undefined') {
|
|
$('.g-recaptcha').each(function (index, el) {
|
|
if ($(this).is(':empty')) {
|
|
{$library}.render(el, {
|
|
'sitekey': '{$sitekey}'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
</script>
|
|
{if !$lazy}
|
|
<script src="{$script_url}" async defer></script>
|
|
{else}
|
|
{* je potreba zavolat loadRecaptchaScript() v sablone napr. po otevreni focusu *}
|
|
<script>
|
|
if (typeof loadRecaptchaScript === 'undefined') {
|
|
function loadRecaptchaScript() {
|
|
var url = '{$script_url}';
|
|
$.getScript(url);
|
|
}
|
|
}
|
|
</script>
|
|
{/if}
|
|
{/ifmodule}
|