24 lines
834 B
JavaScript
24 lines
834 B
JavaScript
function revealEmail(element) {
|
|
const maskedEmail = element.getAttribute('data-email');
|
|
if (!maskedEmail) return;
|
|
|
|
if (element.classList.contains('revealed')) {
|
|
window.location.href = 'mailto:' + maskedEmail;
|
|
return;
|
|
}
|
|
|
|
element.classList.add('revealed');
|
|
|
|
const emailParts = maskedEmail.split('@');
|
|
if (emailParts.length === 2) {
|
|
element.innerHTML = '<i class="fas fa-envelope"></i> <a href="mailto:' + maskedEmail + '" style="color: inherit; text-decoration: none;">' + maskedEmail + '</a>';
|
|
}
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const emailElements = document.querySelectorAll('.email-protected');
|
|
emailElements.forEach(function(el) {
|
|
el.style.cursor = 'pointer';
|
|
el.title = '点击查看完整邮箱';
|
|
});
|
|
}); |