more modest ux
This commit is contained in:
+13
-2
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user