AMPERION_Webpage/layouts/partials/script.html
2025-09-02 14:04:22 +02:00

141 lines
4.3 KiB
HTML

<!-- JS Plugins + Main script -->
{{ $scripts := slice }}
{{ range site.Params.plugins.js}}
{{ if findRE "^http" .link }}
<script src="{{ .link | relURL }}" type="application/javascript" {{.attributes | safeHTMLAttr}}></script>
{{ else }}
{{ $scripts = $scripts | append (resources.Get .link) }}
{{ end }}
{{ end }}
{{ $scripts := $scripts | append (resources.Get "js/script.js" | minify) }}
{{ $scripts := $scripts | resources.Concat "js/script.js" | minify | fingerprint "sha512" }}
<script crossorigin="anonymous" defer="defer" integrity="{{ $scripts.Data.Integrity }}" type="application/javascript">{{$scripts.Content | safeJS}}</script>
<!-- Cookie-Manager -->
<script src="/tarteaucitron/tarteaucitron.js"></script>
<!-- hCaptcha Custom-Service (MUSS VOR init DEFINIERT SEIN) -->
<script>
(function() {
function renderAllHC() {
try {
var nodes = document.querySelectorAll('.h-captcha');
if (!nodes.length) return;
if (!window.hcaptcha || !window.hcaptcha.render) {
setTimeout(renderAllHC, 200);
return;
}
nodes.forEach(function(el) {
if (el.getAttribute('data-hc-rendered') === '1') return;
var sitekey = el.getAttribute('data-sitekey');
if (!sitekey) {
el.innerHTML = '<div style="color:#b00020;font-size:13px;padding:8px 0;">hCaptcha: data-sitekey fehlt.</div>';
return;
}
try {
window.hcaptcha.render(el, {
sitekey: sitekey,
theme: el.getAttribute('data-theme') || 'light',
size: el.getAttribute('data-size') || 'normal'
});
el.setAttribute('data-hc-rendered', '1');
} catch (e) {
el.innerHTML = '<div style="color:#b00020;font-size:13px;padding:8px 0;">hCaptcha Render-Fehler: ' + (e && e.message ? e.message : e) + '</div>';
}
});
} catch(e) {}
}
// globaler Callback für die API
window.__hcRenderAll = renderAllHC;
// hCaptcha als Tarteaucitron-Service
tarteaucitron.services.hcaptcha = {
key: 'hcaptcha',
type: 'other',
name: 'hCaptcha',
needConsent: true,
cookies: [],
uri: 'https://www.hcaptcha.com/privacy',
js: function () {
if (!document.getElementById('hcaptcha-api')) {
var s = document.createElement('script');
s.id = 'hcaptcha-api';
s.src = 'https://hcaptcha.com/1/api.js?render=explicit&onload=__hcRenderAll';
s.async = true;
s.defer = true;
s.onerror = function() {
document.querySelectorAll('.h-captcha').forEach(function(el){
el.innerHTML = '<div style="color:#b00020;font-size:13px;padding:8px 0;">hCaptcha API geblockt (CSP/Blocker?).</div>';
});
};
document.head.appendChild(s);
} else {
__hcRenderAll();
}
},
fallback: function () {
tarteaucitron.fallback(['h-captcha'], tarteaucitron.engage('hcaptcha'));
}
};
})();
</script>
<!-- Tarteaucitron initialisieren -->
<script type="text/javascript">
tarteaucitron.init({
"privacyUrl": "/datenschutz",
"bodyPosition": "top",
"hashtag": "#tarteaucitron",
"cookieName": "tarteaucitron",
"orientation": "middle",
"groupServices": true,
"showDetailsOnClick": false,
"serviceDefaultState": "wait",
"showAlertSmall": false,
"cookieslist": false,
"closePopup": false,
"showIcon": true,
"iconPosition": "BottomRight",
"adblocker": false,
"DenyAllCta": false,
"AcceptAllCta": true,
"highPrivacy": true,
"alwaysNeedConsent": false,
"handleBrowserDNTRequest": false,
"removeCredit": false,
"moreInfoLink": true,
"useExternalCss": false,
"useExternalJs": false,
"mandatory": false,
"mandatoryCta": false,
"googleConsentMode": true,
"bingConsentMode": true,
"softConsentMode": false,
"dataLayer": false,
"serverSide": false,
"partnersList": true
});
</script>
<!-- Matomo + hCaptcha in die Queue (NACH init) -->
<script>
tarteaucitron.user.matomoId = 2;
tarteaucitron.user.matomoHost = 'https://matomo.amperion.at/';
tarteaucitron.user.matomoDontTrackPageView = false; // bei Bedarf true
tarteaucitron.user.matomoFullTracking = true; // bei Bedarf false
(tarteaucitron.job = tarteaucitron.job || []).push('matomocloud');
(tarteaucitron.job = tarteaucitron.job || []).push('hcaptcha');
</script>