This repository has been archived on 2026-08-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
pi-web/docs/site.js
T

22 lines
692 B
JavaScript

const copyButtons = document.querySelectorAll("[data-copy]");
for (const button of copyButtons) {
button.addEventListener("click", async () => {
const targetSelector = button.getAttribute("data-copy");
const target = targetSelector === null ? null : document.querySelector(targetSelector);
const text = target?.textContent?.replace(/^\s*\$ /gm, "").trim();
if (!text) return;
try {
await navigator.clipboard.writeText(text);
const original = button.textContent;
button.textContent = "Copied";
window.setTimeout(() => {
button.textContent = original;
}, 1400);
} catch {
button.textContent = "Select code";
}
});
}