more modest ux

This commit is contained in:
2026-07-18 21:00:33 +02:00
parent 399f539b4f
commit 4a5ebc726e
5 changed files with 53 additions and 20 deletions
+13 -2
View File
@@ -53,8 +53,19 @@
reveal.textContent = visible ? 'Hide' : 'Reveal';
});
copy.addEventListener('click', async () => {
await navigator.clipboard.writeText(secret.dataset.secret);
copy.textContent = 'Copied';
try {
await navigator.clipboard.writeText(secret.dataset.secret);
copy.textContent = 'Copied';
} catch (_) {
const field = document.createElement('textarea');
field.value = secret.dataset.secret;
field.style.position = 'fixed';
field.style.opacity = '0';
document.body.appendChild(field);
field.select();
copy.textContent = document.execCommand('copy') ? 'Copied' : 'Select and copy';
field.remove();
}
window.setTimeout(() => copy.textContent = 'Copy', 1400);
});
</script>