Files
oslstats/internal/embedfs/web/js/copytoclipboard.js
2026-02-04 18:57:33 +11:00

18 lines
504 B
JavaScript

function copyToClipboard(elementId, buttonId) {
const element = document.getElementById(elementId);
const button = document.getElementById(buttonId);
navigator.clipboard.writeText(element.innerText)
.then(() => {
const originalText = button.innerText;
button.innerText = 'Copied!';
setTimeout(() => {
button.innerText = originalText;
}, 2000);
})
.catch(err => {
console.error('Failed to copy:', err);
button.innerText = 'Failed';
});
}