-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
25 lines (21 loc) · 884 Bytes
/
Copy pathscript.js
File metadata and controls
25 lines (21 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const pgpButton = document.querySelector("[data-pgp-button]");
const pgpPanel = document.querySelector("#pgp-panel");
const copyButton = document.querySelector("[data-copy-pgp]");
const pgpKey = document.querySelector("[data-pgp-key]");
const copyStatus = document.querySelector("[data-copy-status]");
pgpButton.addEventListener("click", () => {
const isOpen = !pgpPanel.hidden;
pgpPanel.hidden = isOpen;
pgpButton.setAttribute("aria-expanded", String(!isOpen));
if (!isOpen) {
pgpPanel.scrollIntoView({ behavior: "smooth", block: "nearest" });
}
});
copyButton.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(pgpKey.textContent.trim());
copyStatus.textContent = "Скопировано!";
} catch {
copyStatus.textContent = "Не получилось скопировать автоматически.";
}
});