diff --git a/source/assets/email.js b/source/assets/email.js index 90007c7..b084a41 100644 --- a/source/assets/email.js +++ b/source/assets/email.js @@ -1,15 +1,17 @@ // This code de-obfuscates my email and displays it on screen when the button is clicked // It's not a perfect solution, but it should stop be enough to stop email scraping + // Email encoded in base64. This might be changed in the future to prevent scraping targeting base64 strings -var email = "Y29udGFjdEBvd2Vucnlhbi51cwo="; -document.addEventListener("DOMContentLoaded", function () { +const email = "Y29udGFjdEBvd2Vucnlhbi51cwo="; +document.addEventListener("DOMContentLoaded", () => { // Get document elements - var button = document.querySelector("#emailButton"); - var emailDiv = document.querySelector("#email"); + const button = document.querySelector("#emailButton"); + const emailDiv = document.querySelector("#email"); + // Decode the email string and insert a mailto link into the DOM, then disable the button - button.addEventListener("click", function () { - var decodedEmail = atob(email); - emailDiv.insertAdjacentHTML("beforeend", "
").concat(decodedEmail, "
")); + button.addEventListener("click", () => { + const decodedEmail = atob(email); + emailDiv.insertAdjacentHTML("beforeend", `
${decodedEmail}
`); button.disabled = true; }); -}); +}); \ No newline at end of file diff --git a/source/assets/email.ts b/source/assets/email.ts deleted file mode 100644 index 2b27654..0000000 --- a/source/assets/email.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This code de-obfuscates my email and displays it on screen when the button is clicked -// It's not a perfect solution, but it should stop be enough to stop email scraping - -// Email encoded in base64. This might be changed in the future to prevent scraping targeting base64 strings -const email: string = "Y29udGFjdEBvd2Vucnlhbi51cwo="; -document.addEventListener("DOMContentLoaded", () => { - // Get document elements - const button: HTMLButtonElement = document.querySelector("#emailButton"); - const emailDiv: HTMLDivElement = document.querySelector("#email"); - - // Decode the email string and insert a mailto link into the DOM, then disable the button - button.addEventListener("click", () => { - const decodedEmail: string = atob(email); - emailDiv.insertAdjacentHTML("beforeend", `
${decodedEmail}
`); - button.disabled = true; - }) -}); \ No newline at end of file diff --git a/source/assets/utils.js b/source/assets/utils.js index b67268f..9507b2b 100644 --- a/source/assets/utils.js +++ b/source/assets/utils.js @@ -1,7 +1,8 @@ // Some useful functions used throughout my code + // Based on this SO answer https://stackoverflow.com/a/35880730/9523246 function lazyLoadCSS(url) { - var css = document.createElement('link'); + const css = document.createElement('link'); css.href = url; css.rel = 'stylesheet'; css.type = 'text/css'; diff --git a/source/assets/utils.ts b/source/assets/utils.ts deleted file mode 100644 index 306d63f..0000000 --- a/source/assets/utils.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Some useful functions used throughout my code - -// Based on this SO answer https://stackoverflow.com/a/35880730/9523246 -function lazyLoadCSS(url: string): void { - const css: HTMLLinkElement = document.createElement('link'); - css.href = url; - css.rel = 'stylesheet'; - css.type = 'text/css'; - document.getElementsByTagName('head')[0].appendChild(css); -}