first commit
This commit is contained in:
19
index.js
Normal file
19
index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user