Bug -> try to fix bug

This commit is contained in:
2026-04-10 11:54:03 +03:30
parent b292bc0cd8
commit 119b3d2db4

View File

@@ -93,7 +93,7 @@ document.addEventListener('DOMContentLoaded', () => {
/* ── Shared helper ── */
function copyToClipboard(text, btn, successLabel, defaultLabel) {
navigator.clipboard.writeText(text).then(() => {
const doSuccess = () => {
const span = btn.querySelector('span') || btn;
btn.classList.add('copied');
span.textContent = successLabel;
@@ -101,6 +101,21 @@ document.addEventListener('DOMContentLoaded', () => {
btn.classList.remove('copied');
span.textContent = defaultLabel;
}, 2000);
});
};
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(doSuccess);
} else {
const ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.focus();
ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
doSuccess();
}
}
});