From b8e0094052a2947bbf9e40147050d18ae2d94420 Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Sun, 28 Jun 2026 23:55:39 +0800 Subject: url changes --- www/scripts/elements/share.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 www/scripts/elements/share.js (limited to 'www/scripts/elements') diff --git a/www/scripts/elements/share.js b/www/scripts/elements/share.js new file mode 100644 index 0000000..d6813ba --- /dev/null +++ b/www/scripts/elements/share.js @@ -0,0 +1,27 @@ +const shareBtn = document.getElementById("share-btn"); + +shareBtn.addEventListener("click", () => { + share(); +}); + +function share() { + const data = { + title: "altaf-creator", + text: document.title, + url: window.location, + }; + + iconChange(); + navigator.clipboard.writeText(window.location); + navigator.share(data); +} + +async function iconChange() { + shareBtn.firstChild.setAttribute("class", "fa-solid fa-copy"); + await sleep(2000); + shareBtn.firstChild.setAttribute("class", "fa-solid fa-share-nodes"); +} + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} -- cgit v1.2.3