"use strict"; document.querySelectorAll("[data-copy]").forEach(function (button) { button.addEventListener("click", function () { const target = document.getElementById(button.getAttribute("data-copy")); if (!target) return; const value = target.textContent; const complete = function () { button.textContent = "Copied"; window.setTimeout(function () { button.textContent = "Copy"; }, 1500); }; if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard.writeText(value).then(complete).catch(function () { button.textContent = "Copy failed"; }); return; } const field = document.createElement("textarea"); field.value = value; field.setAttribute("readonly", ""); field.style.position = "fixed"; field.style.opacity = "0"; document.body.appendChild(field); field.select(); document.execCommand("copy"); field.remove(); complete(); }); });