-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (27 loc) · 876 Bytes
/
Copy pathscript.js
File metadata and controls
29 lines (27 loc) · 876 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
29
document.addEventListener('DOMContentLoaded', () => {
const toast = document.getElementById('toast');
// Helper: Show Toast
function showToast(message) {
if (!toast) return;
toast.textContent = message;
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 2500);
}
// Handle generic copy buttons
const copyButtons = document.querySelectorAll('.copy-btn');
copyButtons.forEach((btn) => {
btn.addEventListener('click', (e) => {
e.preventDefault();
const textToCopy = btn.getAttribute('data-copy');
if (textToCopy) {
navigator.clipboard.writeText(textToCopy).then(() => {
showToast('Скопировано в буфер обмена!');
}).catch(() => {
showToast('Ошибка при копировании');
});
}
});
});
});