Files
martbost 7182746883 Tools: Text-a-friend section (SMS + WhatsApp + messenger share, per angle)
5 SMS-sized low-pressure messages (general moving link + one per angle video,
each carrying the matching ?v= landing link) with one-tap launchers: sms: body
pre-fill, wa.me text pre-fill, t.me/share with the member''s Mini App invite
(angle-matched), Copy for Messenger/IG. Hrefs rebuilt on personalization.
Chatbot canned answer + AI prompt synced.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-23 07:46:36 -05:00

74 lines
3.9 KiB
JavaScript

(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/…'; }
// ---- personalization: every asset carries the member's own invite link ----
// Replaces BARE https://rmcircle.team mentions (not /contract, /v/…, /banners/…)
// in both the copy payloads and the visible previews. ID comes from ?id=
// (dashboard hand-off), then localStorage, then the "Your link" box.
const BARE=/https:\/\/rmcircle\.team(?![\w./-])/g;
// YOURID marks Telegram Mini App links (t.me/...?startapp=YOURID[_angle]).
function fill(text,mine,id){
let out=text;
if(mine)out=out.replace(BARE,mine);
if(id)out=out.replace(/YOURID/g,id);
return out;
}
function personalize(){
const id=(idIn&&idIn.value||'').replace(/\D/g,'').slice(0,15);
const mine=id?`https://rmcircle.team/join/${id}`:null;
document.querySelectorAll('.copy-btn').forEach(b=>{
if(b.dataset.orig===undefined)b.dataset.orig=b.getAttribute('data-copy')||'';
b.setAttribute('data-copy', fill(b.dataset.orig,mine,id));
});
document.querySelectorAll('pre.swipe').forEach(p=>{
if(p.dataset.orig===undefined)p.dataset.orig=p.textContent;
p.textContent=fill(p.dataset.orig,mine,id);
});
const note=document.getElementById('personalNote');
if(note){
if(mine){ note.style.display='block'; const s=note.querySelector('strong'); if(s)s.textContent='#'+id; const l=note.querySelector('.pnl'); if(l)l.textContent=mine; }
else note.style.display='none';
}
// Text-a-friend share buttons: rebuild launcher hrefs from the (already
// personalized) message in the card's swipe block. SMS/WhatsApp carry the
// full text with the website angle link; Telegram shares the member's
// t.me Mini App invite (matching angle) with a short lead-in.
document.querySelectorAll('.share-row').forEach(row=>{
const card=row.closest('.tool-card');
const pre=card&&card.querySelector('pre.swipe');
const msg=pre?pre.textContent:'';
const enc=encodeURIComponent(msg);
row.querySelectorAll('a.share-sms').forEach(a=>{a.href='sms:?&body='+enc;});
row.querySelectorAll('a.share-wa').forEach(a=>{a.href='https://wa.me/?text='+enc;});
row.querySelectorAll('a.share-tg').forEach(a=>{
const angle=row.dataset.angle||'';
const tgu=id?('https://t.me/RMCircleBot/join?startapp='+id+(angle?'_'+angle:'')):'https://rmcircle.team';
a.href='https://t.me/share/url?url='+encodeURIComponent(tgu)+'&text='+encodeURIComponent(row.dataset.tglead||'');
});
});
if(id){ try{localStorage.setItem('rmc.toolsId',id);}catch(e){} }
}
(function initId(){
if(!idIn)return;
const q=new URLSearchParams(location.search).get('id');
let id=(q&&/^\d{1,15}$/.test(q))?q:'';
if(!id){ try{const s=localStorage.getItem('rmc.toolsId'); if(s&&/^\d{1,15}$/.test(s))id=s;}catch(e){} }
if(id&&!idIn.value)idIn.value=id;
})();
if(idIn){ idIn.addEventListener('input',function(){render();personalize();}); render(); }
if(copyShare){ copyShare.addEventListener('click',()=>{ const u=url(); if(!u){ idIn.focus(); return; } copy(u,copyShare); }); }
personalize();
})();