Files
yourprogrambuilder/public/assets/packet.js
T
martbost a8a1a8eec7 YourProgramBuilder, the Seed Bed (Marty 2026-11-17: "keep fleshing it out"): STAGING build
Plant a program free (referral link with {id}, link check green / yellow / red, daily recheck, reports), members save their
referral IDs in its packet, a sponsor-first link (member page / ?r= / the hub sponsor line, then the planter), the sprout meter
to REVIEW_SAVES (DEFAULT 25) -> Marty's review queue -> approved packets exported for the CTB builder / DownlineHydra wild heads
with every saved ID. Dormant old programs confirmed by their owner, old-link redirects (oldrefs), Spotlight on YPBShop (NOT
deployed; DEFAULT $10 / 1,000 views, 20/5/5/5/5, company 60), verified views with Spotlight delivery, trust pack (ledger,
contract, toasts, Telegram card, terms / disclaimer / privacy, TrustClickz only), network footer row, chatbot, promo kit,
Guides, PolHunter slot, LinkSpin tracked-link and zone hooks, AI writer through the hub. Seed-catalog look from the approved
mockup. Tests: qa/unit.test.cjs 33/33, qa/e2e.mjs 121/121 on a local anvil chain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:30:59 -06:00

41 lines
3.6 KiB
JavaScript

// A packet: the card, Save my ID (network members), whose link a visitor gets, the report button, recent savers, the Spotlight strip.
(async function () {
const $ = YPB.$, esc = YPB.esc;
const id = Number((location.pathname.match(/^\/p\/(\d+)/) || [])[1]);
const c = await YPB.getConfig().catch(() => ({}));
const d = await YPB.wire('packet', '&id=' + id).catch(() => ({ error: 'x' }));
if (d.error || !d.packet) { $('pk').innerHTML = '<p class="note err">' + esc(d.error || 'That packet is not in the Seed Bed right now.') + '</p>'; return; }
const x = d.packet;
document.title = x.name + ' | YourProgramBuilder';
$('pk').innerHTML = YPB.packetCard(x, { place: 'packet', extra: '<p style="font-size:13px">Link checked ' + esc(YPB.when(x.checkedAt)) + '. Planted ' + esc(YPB.when(x.sownAt)) + (x.planter ? ' by @' + esc(x.planter) : '') + '. ' + YPB.n(x.clicks) + ' verified clicks.' + (x.contract ? ' Contract: <span class="mono">' + esc(x.contract) + '</span>' + (c.explorer ? ' (<a href="' + esc(c.explorer) + '/address/' + esc(x.contract) + '" target="_blank" rel="noopener">look it up</a>)' : '') : '') + '</p>' });
const who = x.linkFallback === null ? '@' + esc(x.linkBy) + '\'s link (the nearest person in your line who saved an ID).' : x.linkFallback === 'planter' ? 'The planter\'s link' + (x.linkBy ? ' (@' + esc(x.linkBy) + ')' : '') + ': nobody in your line has saved an ID yet.' : 'The program\'s home page: no ID saved yet.';
$('linkWho').innerHTML = 'You get ' + who;
$('visitBtn').dataset.go = x.id; $('visitBtn').dataset.p = 'packet'; $('visitBtn').href = YPB.goHref(x.id, 'packet');
YPB.decorate();
if (x.recent && x.recent.length) { $('savers').hidden = false; $('saverList').textContent = x.recent.map(n => '@' + n).join(', '); }
YPB.spotRow($('spots'), d);
const me = await YPB.getJSON('/api/me');
if (!me.signedIn) { $('saveSignin').hidden = false; if (c.joinUrl) $('joinLink').href = c.joinUrl; $('saveSignin').querySelector('a').href = '/sso/start?mode=go&to=' + encodeURIComponent(location.pathname); }
else if (x.own) { $('save').querySelector('p').textContent = 'You planted this packet: your ID is the planter\'s ID. Change it on My packets.'; }
else {
$('saveForm').hidden = false;
$('idHint').textContent = 'letters, numbers and . _ - @ + only';
if (d.mySave) { $('refId').value = d.mySave.refId; $('track').checked = d.mySave.track; $('removeBtn').hidden = false; $('saveBtn').textContent = 'Update my ID'; }
const send = async refId => {
YPB.status('Saving...', '');
const r = await YPB.post('/api/my/save', { packetId: x.id, refId, track: $('track').checked });
if (r.error) return YPB.status(r.error + (r.join ? ' ' : ''), 'err');
if (r.removed) { YPB.status('Your ID was removed from this packet.', 'ok'); $('removeBtn').hidden = true; $('refId').value = ''; return; }
YPB.status('Saved. Your link: ' + r.link + '. This packet has ' + r.saves + ' of ' + r.need + ' saved IDs' + (r.review ? ' and is now in the review queue.' : '.'), 'ok');
$('removeBtn').hidden = false; $('saveBtn').textContent = 'Update my ID';
};
$('saveForm').onsubmit = e => { e.preventDefault(); send($('refId').value.trim()); };
$('removeBtn').onclick = () => send('');
}
$('reportForm').onsubmit = async e => {
e.preventDefault();
const r = await YPB.post('/api/report', { packetId: x.id, reason: $('reason').value, note: $('reportNote').value });
YPB.status(r.error || (r.already ? 'You already reported this packet. Thank you.' : 'Thank you. A person will look at it.'), r.error ? 'err' : 'ok', 'reportStatus');
};
})();