Bug -> try to fix bug
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user