2024-10-22 00:36:13 +02:00
|
|
|
{{ $email := .Get 0 }}
|
|
|
|
{{ $parts := split $email "@" }}
|
|
|
|
{{ $name := index $parts 0 | base64Encode }}
|
|
|
|
{{ $domainParts := split (index $parts 1) "." }}
|
|
|
|
{{ $domain := delimit (first (sub (len $domainParts) 1) $domainParts) "." | base64Encode }}
|
|
|
|
{{ $tld := index $domainParts (sub (len $domainParts) 1) | base64Encode }}
|
|
|
|
|
|
|
|
<a href="#" class="protected-email"
|
|
|
|
data-name="{{ $name }}"
|
|
|
|
data-domain="{{ $domain }}"
|
|
|
|
data-tld="{{ $tld }}"
|
|
|
|
onclick="decodeEmail(this);return false;">
|
2024-10-22 00:39:44 +02:00
|
|
|
{{ T "email_protection" }}
|
2024-10-22 00:36:13 +02:00
|
|
|
</a>
|
|
|
|
|
|
|
|
{{ if not (.Page.Scratch.Get "protectedEmailJS") }}
|
2024-10-22 00:49:20 +02:00
|
|
|
{{ $.Page.Scratch.Set "recaptchaLoaded" true }}
|
2024-10-22 00:36:13 +02:00
|
|
|
<script>
|
|
|
|
function decodeEmail(element) {
|
|
|
|
const name = atob(element.getAttribute('data-name'));
|
|
|
|
const domain = atob(element.getAttribute('data-domain'));
|
|
|
|
const tld = atob(element.getAttribute('data-tld'));
|
|
|
|
|
|
|
|
const email = name + '@' + domain + '.' + tld;
|
|
|
|
element.href = 'mailto:' + email;
|
|
|
|
element.textContent = email;
|
|
|
|
|
|
|
|
// Remove the onclick attribute to prevent further obfuscation
|
|
|
|
element.onclick = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize all protected email links
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
document.querySelectorAll('.protected-email').forEach(function(link) {
|
|
|
|
link.style.cursor = 'pointer';
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{{ end }}
|