(function(){ function copy(text, btn){ if(!text) return; navigator.clipboard.writeText(text).then(()=>{ const old=btn.dataset.label||btn.textContent; btn.dataset.label=old; btn.textContent='Copied ✓'; btn.disabled=true; setTimeout(()=>{btn.textContent=old; btn.disabled=false;},1500); }).catch(()=>{ btn.textContent='Copy failed'; setTimeout(()=>{btn.textContent=btn.dataset.label||'Copy';},1500); }); } document.querySelectorAll('.copy-btn').forEach(b=>b.addEventListener('click',()=>copy(b.getAttribute('data-copy'),b))); const idIn=document.getElementById('toolId'), link=document.getElementById('shareLink'), copyShare=document.getElementById('copyShare'); function url(){ const id=(idIn.value||'').replace(/\D/g,'').slice(0,15); return id?`https://rmcircle.team/join/${id}`:''; } function render(){ link.textContent=url()||'https://rmcircle.team/join/…'; } if(idIn){ idIn.addEventListener('input',render); render(); } if(copyShare){ copyShare.addEventListener('click',()=>{ const u=url(); if(!u){ idIn.focus(); return; } copy(u,copyShare); }); } })();