// // Smooth scrolling when opening and closing the details element for value block // // Set expanded value block to a variable const valueBlock = document.getElementById("value-expanded"); const bodyTop = document.getElementById("top"); // Watch for the details element to be toggled document.querySelector('.value-block').addEventListener('toggle', function() { if (this.open) { // Scroll to contents of value block when it is opened setTimeout(() => { valueBlock.scrollIntoView({ behavior: "smooth" }); }, 150); } }); // // Copy crypto wallet addresses to clipboard when clicked // // Set wallet addresses to variables const btcadd = document.getElementById("btcwall").textContent; const ethadd = document.getElementById("ethwall").textContent; const dogeadd = document.getElementById("dogewall").textContent; // Watch for click on BTC wallet address document.getElementById("btcwall").addEventListener("click", function(){ // Copy BTC address to clipboard navigator.clipboard.writeText(btcadd); // Display alert to confirm the address was added to clipboard alert("BTC address copied to clipboard"); }); // Watch for click on ETH wallet address document.getElementById("ethwall").addEventListener("click", function(){ // Copy ETH address to clipboard navigator.clipboard.writeText(ethadd); // Display alert to confirm the address was added to clipboard alert("ETH address copied to clipboard"); }); // Watch for click on DOGE wallet address document.getElementById("dogewall").addEventListener("click", function(){ // Copy DOGE address to clipboard navigator.clipboard.writeText(dogeadd); // Display alert to confirm the address was added to clipboard alert("DOGE address copied to clipboard"); }); // // Display crypto QR code when link is clicked // // Prevent clicks on QR codes from functioning document.querySelector("#btc-qr-link a").addEventListener("click", function(event){ event.preventDefault() }); document.querySelector("#eth-qr-link a").addEventListener("click", function(event){ event.preventDefault() }); document.querySelector("#doge-qr-link a").addEventListener("click", function(event){ event.preventDefault() }); // Watch for click on BTC QR code link document.querySelector("#btc-qr-link a").addEventListener("click", function(){ // Hide all other QR codes if (document.contains(document.querySelector("#eth-js-qr"))) { document.querySelector("#eth-js-qr").remove(); } if (document.contains(document.querySelector("#doge-js-qr"))) { document.querySelector("#doge-js-qr").remove(); } // Display BTC QR code if (document.contains(document.querySelector("#btc-js-qr"))) { document.querySelector("#btc-js-qr").remove(); } else { document.querySelector("#btcwall").insertAdjacentHTML("afterend", ""); setTimeout(() => { document.querySelector("#btc-qr-link").scrollIntoView({ behavior: "smooth" }); }, 150); } }); // Watch for click on ETH QR code link document.querySelector("#eth-qr-link a").addEventListener("click", function(){ // Hide all other QR codes if (document.contains(document.querySelector("#btc-js-qr"))) { document.querySelector("#btc-js-qr").remove(); } if (document.contains(document.querySelector("#doge-js-qr"))) { document.querySelector("#doge-js-qr").remove(); } // Display ETH QR code if (document.contains(document.querySelector("#eth-js-qr"))) { document.querySelector("#eth-js-qr").remove(); } else { document.querySelector("#ethwall").insertAdjacentHTML("afterend", ""); setTimeout(() => { document.querySelector("#eth-qr-link").scrollIntoView({ behavior: "smooth" }); }, 150); } }); // Watch for click on DOGE QR code link document.querySelector("#doge-qr-link a").addEventListener("click", function(){ // Hide all other QR codes if (document.contains(document.querySelector("#btc-js-qr"))) { document.querySelector("#btc-js-qr").remove(); } if (document.contains(document.querySelector("#eth-js-qr"))) { document.querySelector("#eth-js-qr").remove(); } // Display DOGE QR code if (document.contains(document.querySelector("#doge-js-qr"))) { document.querySelector("#doge-js-qr").remove(); } else { document.querySelector("#dogewall").insertAdjacentHTML("afterend", ""); setTimeout(() => { document.querySelector("#doge-qr-link").scrollIntoView({ behavior: "smooth" }); }, 150); } }); // An attempt at replacing the browser alert with something nicer // Watch for click on BTC wallet address //document.getElementById("btcwall").addEventListener("click", function(){ // // Copy BTC address to clipboard // navigator.clipboard.writeText(btcadd); // // Display alert to confirm the address was added to clipboard // btcwall.insertAdjacentHTML("afterend", "\"\"Copied to Clipboard"); // setTimeout(() => { // document.querySelector("#btc-js-copy").remove(); // }, 10000); //});