function copyShortUrl() { const shortUrl = document.getElementById('short-url'); navigator.clipboard.writeText(shortUrl.textContent) .then(() => { alert('Short URL copied to clipboard!'); }) .catch((error) => { console.error('Error copying short URL:', error); }); } function downloadQRCode() { var qrcode = document.getElementById("qrcode"); fetch(qrcode.src, { mode: "cors" }) .then(function (res) { return res.blob(); }) .then(function (blob) { var link = document.createElement("a"); link.href = URL.createObjectURL(blob); link.download = "qrcode.png"; link.click(); URL.revokeObjectURL(link.href); }); } function shortenAnotherLink() { window.location.href = "/"; } var qrcode = document.getElementById("qrcode"); qrcode.onload = function () { var qrcodeContainer = document.getElementById("qr-code-container"); qrcodeContainer.style.animation = "none"; qrcodeContainer.addEventListener("mouseenter", function () { qrcodeContainer.style.cursor = "pointer"; var qrcodeOverlay = document.getElementById("qrcode-overlay"); qrcodeOverlay.style.display = "flex"; }); qrcodeContainer.addEventListener("mouseleave", function () { const qrcodeOverlay = document.getElementById("qrcode-overlay"); qrcodeOverlay.style.display = "none"; }); qrcodeContainer.addEventListener("click", function () { downloadQRCode(); }); }; var copyButton = document.querySelector(".copy-button"); copyButton.addEventListener("click", function () { copyShortUrl(); });