Files
DocumentationVaultWarden/index.js
2026-04-02 10:57:35 -04:00

20 lines
757 B
JavaScript

document.addEventListener('DOMContentLoaded', function(){
const copyBtn = document.getElementById('copy-url');
const vaultLink = document.getElementById('vault-link');
if(copyBtn && vaultLink){
copyBtn.addEventListener('click', async ()=>{
try{
await navigator.clipboard.writeText(vaultLink.href);
copyBtn.textContent = 'Copied!';
setTimeout(()=> copyBtn.textContent = 'Copy', 1800);
}catch(e){
const ta = document.createElement('textarea');
ta.value = vaultLink.href; document.body.appendChild(ta); ta.select();
try{ document.execCommand('copy'); copyBtn.textContent='Copied!'}catch(err){alert('Copy failed; please copy manually.')}
ta.remove(); setTimeout(()=> copyBtn.textContent = 'Copy',1800);
}
});
}
});