Hide copy to clipboard button if browser API is not available

This commit is contained in:
Glenn de Haan
2025-09-08 23:04:04 +02:00
parent 4b215541b2
commit 2fe4576c90

View File

@@ -508,18 +508,22 @@
spinnerCreate.style.display = '';
});
shareButtons.forEach((el) => {
el.addEventListener('click', async () => {
try {
await navigator.clipboard.writeText(el.dataset.code);
copyNotification.style.display = '';
if(typeof navigator.clipboard !== 'undefined') {
el.addEventListener('click', async () => {
try {
await navigator.clipboard.writeText(el.dataset.code);
copyNotification.style.display = '';
setTimeout(() => {
copyNotification.style.display = 'none';
}, 5000);
} catch (error) {
console.error(error.message);
}
});
setTimeout(() => {
copyNotification.style.display = 'none';
}, 5000);
} catch (error) {
console.error(error.message);
}
});
} else {
el.classList.add('hidden');
}
});
removeButtons.forEach((el) => {
el.addEventListener('click', async () => {