-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (26 loc) · 867 Bytes
/
script.js
File metadata and controls
28 lines (26 loc) · 867 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
26
27
28
// Copy-to-clipboard for the disclaimer block
document.querySelector('.copy-btn').addEventListener('click', async function () {
const text = document.querySelector('.disclaimer-content').textContent;
const btn = this;
try {
await navigator.clipboard.writeText(text);
btn.textContent = 'Copied!';
btn.classList.add('copied');
} catch {
// Fallback for older browsers
const textarea = document.createElement('textarea');
textarea.value = text;
textarea.style.position = 'fixed';
textarea.style.opacity = '0';
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
btn.textContent = 'Copied!';
btn.classList.add('copied');
}
setTimeout(function () {
btn.textContent = 'Copy';
btn.classList.remove('copied');
}, 2000);
});