diff --git a/public/assets/js/script.js b/public/assets/js/script.js index c5514e8..83cc78d 100644 --- a/public/assets/js/script.js +++ b/public/assets/js/script.js @@ -32,9 +32,11 @@ const interactions = { // Remove transition CSS when finished. Wonky resize effects otherwise setTimeout(() => menu.style.removeProperty("transition"),transition + 1); }, + // Open page defined with data-value as a card newCard: (event) => { const module = import("./modules/Modals.mjs"); const interactions = { + // Like newCard() except it closes the previous card getContact: (event) => { const service = event.target.dataset.value; module.then(modals => { @@ -43,19 +45,25 @@ const interactions = { card.openPage(service); }); }, + // Copy text defined in data-value to clipboard and play animation copyText: (event) => { - event.target.classList.add("copied"); - const copied = document.createElement("p"); - copied.innerText = "copied!"; - event.target.appendChild(copied); - - setTimeout(() => { - event.target.classList.remove("copied"); - destroy(copied); - },1000); + const copy = navigator.clipboard.writeText(event.target.dataset.value); + copy.then(() => { + event.target.classList.add("copied"); + const copied = document.createElement("p"); + copied.innerText = "copied!"; + event.target.appendChild(copied); + + // Reset button state + setTimeout(() => { + event.target.classList.remove("copied"); + destroy(copied); + },1000); + }); } }; + // Create card and open the specified page asynchronously module.then(modals => { const card = new modals.Card(interactions); card.openPage(event.target.dataset.value); @@ -67,5 +75,5 @@ const interactions = { const theme = window.matchMedia("(prefers-color-scheme: dark)"); theme.addEventListener("change",updateTheme); -new Interaction(interactions,document.body); +new Interaction(interactions,document.body); // Initialize default interactions updateTheme(); \ No newline at end of file diff --git a/public/assets/pages/contact_email.html b/public/assets/pages/contact_email.html index 28ed9dd..a0be5ff 100644 --- a/public/assets/pages/contact_email.html +++ b/public/assets/pages/contact_email.html @@ -59,7 +59,7 @@

hello@victorwesterlund.com

You can also here to send a mail directly from your mail app

-
+

copy email

\ No newline at end of file diff --git a/public/assets/pages/contact_signal.html b/public/assets/pages/contact_signal.html index 4c7992a..9e9191f 100644 --- a/public/assets/pages/contact_signal.html +++ b/public/assets/pages/contact_signal.html @@ -68,9 +68,9 @@ } -

+4670-2452459

+

+4670-245-2459

Signal is a free and encrypted message platform with apps for all major platforms.

-
+

copy number

\ No newline at end of file