-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
22 lines (19 loc) · 790 Bytes
/
script.js
File metadata and controls
22 lines (19 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
document.addEventListener('DOMContentLoaded', () => {
const copyButtons = document.querySelectorAll('.copy-btn');
copyButtons.forEach(btn => {
btn.addEventListener('click', () => {
const command = btn.getAttribute('data-cmd');
navigator.clipboard.writeText(command).then(() => {
const originalText = btn.textContent;
btn.textContent = 'Copied!';
btn.style.backgroundColor = '#27ae60';
setTimeout(() => {
btn.textContent = originalText;
btn.style.backgroundColor = '';
}, 2000);
}).catch(err => {
console.error('Copy failed', err);
});
});
});
});