-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
40 lines (36 loc) · 1.34 KB
/
Copy pathscripts.js
File metadata and controls
40 lines (36 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function revealEmail() {
// Email is encoded to prevent bot scraping
const parts = ['career', 'ben-riley', 'com'];
const email = parts[0] + '@' + parts[1] + '.' + parts[2];
const emailLink = document.getElementById('email-link');
const printEmail = document.getElementById('print-email');
// Always populate the print email span (even if not visible)
if (!printEmail.textContent) {
printEmail.textContent = email;
}
// First click: Show the email address
if (emailLink.textContent === 'Email Me') {
emailLink.textContent = email;
emailLink.style.transform = 'scale(1.05)';
setTimeout(() => {
emailLink.style.transform = 'scale(1)';
}, 200);
} else {
// Second click: Open email client
emailLink.href = 'mailto:' + email;
emailLink.onclick = null; // Remove click handler after second click
// Trigger the mailto link
window.location.href = 'mailto:' + email;
}
}
// Populate email for print on page load
document.addEventListener('DOMContentLoaded', function() {
const parts = ['career', 'ben-riley', 'com'];
const email = parts[0] + '@' + parts[1] + '.' + parts[2];
const printEmail = document.getElementById('print-email');
if (printEmail) {
// Add email text after the icon
const textNode = document.createTextNode(' ' + email);
printEmail.appendChild(textNode);
}
});