a50640c890
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
67 lines
7.9 KiB
JavaScript
67 lines
7.9 KiB
JavaScript
// Join / sign-in page: /join, /join/<token>[?v=<angle>] (2026-10-07, Instrument scheme). Email first, the code
|
|
// door creates the account, wallet later inside the Control Room. The sponsor cookie was set by the server when
|
|
// this page was served; ?v= only changes the hook copy. Uses IAP.requestCode from common.js for the sign-up guard
|
|
// (honeypot, form age, icon check) so the door stays the same one the engine protects.
|
|
(function () {
|
|
const $ = id => document.getElementById(id);
|
|
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
const framed = (() => { try { return window.top !== window.self; } catch (e) { return true; } })();
|
|
// hook angles (LinkSpin copy only; the legacy Faucet Wave / Tier One Ads angles fall back to the default)
|
|
const ANGLES = {
|
|
instant: { eyebrow: 'Same-transaction payouts', h: 'Paid before the page <em>reloads.</em>', lead: 'A verified contract on Polygon splits every ad package the moment it sells: half to the sponsor, 20 and 10 up the line, 20 to the platform. It lands in your own wallet in seconds, on a public ledger.', points: ['Nothing is held by the site. Nothing is promised for later.', 'Every payout is a transaction you can open and read.', 'Join free by email. Link a wallet only when you want to be paid.'], cta: 'See a payout land in seconds', sub: 'free account by email' },
|
|
free: { eyebrow: 'Costs nothing to try', h: 'One link. <em>Zero dollars.</em>', lead: 'Spin links, bridge and review pages, and an ad zone for your own site are free. View a few ads a day and you earn credits to run your own banner or text ad. Buy a package only if you want more.', points: ['Join with just an email. No password, no wallet today.', 'Your first spin link is live the second you make it.', 'Credits from viewing ads pay for your first campaign.'], cta: 'Start for free. No card, no wallet.', sub: 'type your email, get a code, that is the whole signup' },
|
|
ledger: { eyebrow: 'No back office', h: 'No back office. <em>No payday.</em>', lead: 'Your last program paid you on the 15th, if it paid you. Here every payout is a public transaction on Polygon you can read yourself, and the contract holds zero balance.', points: ['Every payout is public. Click it, read it, verify it.', 'The contract has no pause button and no owner power over money.', 'Join free by email. The ledger is one click from your dashboard.'], cta: 'Check the ledger yourself, then decide', sub: 'free account by email' },
|
|
two: { eyebrow: 'The referral side, exactly as coded', h: 'Two buyers open <em>level two.</em>', lead: 'Every direct buyer pays you half of their package from their very first purchase. Two qualifying buyers open level two at 20 percent. Five open level three at 10 percent. Constants in a verified contract.', points: ['Half of every direct purchase, instantly.', 'Level 2 at two qualifying buyers, level 3 at five.', 'Your invite link is live the moment you are in.'], cta: 'Start your line. Two buyers is the target.', sub: 'free account by email' },
|
|
adspend: { eyebrow: 'For marketers who buy traffic', h: 'You were buying <em>ads anyway.</em>', lead: 'Every ad dollar you ever spent went one direction: out. Here the ad spend in your line pays you, in the same transaction, on a public ledger. Banner, text and login ads, packages from $10.', points: ['Views are timed on the server, so a real person saw your ad.', 'Your ads run in the viewer, on member sites and across the partner network.', 'Rotate the pages you promote with one spin link, free.'], cta: 'Put your next ad dollar where it pays you back', sub: 'free account by email, see every rate before you buy' }
|
|
};
|
|
const v = (new URLSearchParams(location.search).get('v') || (document.cookie.match(/(?:^|; )iap\.angle=([^;]+)/) || [])[1] || '').toLowerCase();
|
|
const a = ANGLES[v];
|
|
if (a) {
|
|
document.body.classList.add('squeeze');
|
|
$('jnEyebrow').textContent = a.eyebrow; $('jnEyebrow').hidden = false; $('jnHead').innerHTML = a.h; $('jnLead').textContent = a.lead;
|
|
$('jnCapH').textContent = a.cta; $('jnCapSub').textContent = a.sub || '';
|
|
$('jnPoints').innerHTML = a.points.map(t => '<li>' + esc(t) + '</li>').join(''); $('jnPoints').hidden = false;
|
|
}
|
|
// ?name=First personalises the page (site-owner links): letters, spaces, hyphens, apostrophes only, 30 chars
|
|
const who = String(new URLSearchParams(location.search).get('name') || '').replace(/[^A-Za-zÀ-ɏ' -]/g, '').trim().slice(0, 30);
|
|
if (who) { $('jnCapH').textContent = who + ', this invitation is for you'; }
|
|
|
|
async function api(path, body) { const r = await (await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) })).json(); if (r.error) throw new Error(r.error); return r; }
|
|
const err = m => { const e = $('jnErr'); e.textContent = m || ''; e.hidden = !m; };
|
|
const busy = (btn, fn) => async ev => { if (ev && ev.preventDefault) ev.preventDefault(); if (btn.disabled) return; btn.disabled = true; err(''); try { await fn(); } catch (e) { err(e.message || 'Something went wrong.'); } finally { btn.disabled = false; } };
|
|
const codeOpts = () => ({ honeypot: $('jnWebsite'), host: $('jnCheck') });
|
|
let sponsorName = '';
|
|
const send = busy($('jnSend'), async () => {
|
|
const email = $('jnEmail').value.trim(); if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email)) throw new Error('That email address does not look right.');
|
|
const r = await IAP.requestCode(email, codeOpts());
|
|
$('jnCodeRow').hidden = false; $('jnCodeRow').style.display = 'flex'; $('jnSend').hidden = true;
|
|
if (r.devCode) $('jnCode').value = r.devCode;
|
|
if (sponsorName) { $('jnUnder').textContent = 'Joining under ' + sponsorName + '. Not who invited you? Open their invite link first, then come back for the code.'; $('jnUnder').hidden = false; }
|
|
$('jnCode').focus();
|
|
});
|
|
$('jnForm').addEventListener('submit', send);
|
|
$('jnResend').addEventListener('click', busy($('jnResend'), async () => { const r = await IAP.requestCode($('jnEmail').value.trim(), codeOpts()); if (r.devCode) $('jnCode').value = r.devCode; }));
|
|
$('jnVerify').addEventListener('click', busy($('jnVerify'), async () => {
|
|
const code = $('jnCode').value.trim(); if (code.length < 6) throw new Error('Enter the six digits from the email.');
|
|
await api('/api/auth/email/verify', { email: $('jnEmail').value.trim(), code, newsletter: !!$('jnNews').checked, followups: !!$('jnNews').checked });
|
|
const dest = '/links?welcome=1';
|
|
if (framed) window.open(dest, '_blank', 'noopener'); else location.href = dest;
|
|
}));
|
|
$('jnCode').addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); $('jnVerify').click(); } });
|
|
|
|
// sign-ups closed (test area): the door still signs existing members in, the copy says so
|
|
fetch('/api/config').then(r => r.json()).then(c => { if (c && c.signupsOpen === false) { $('jnShut').hidden = false; $('jnCapH').textContent = 'Sign in'; $('jnCapSub').textContent = 'sign-ups open soon'; } }).catch(() => {});
|
|
// the sponsor: the link opened most recently sets it; it locks at account creation
|
|
const linkTok = (location.pathname.match(/^\/join\/([^/?#]+)/) || [])[1] || '';
|
|
fetch('/api/sponsor' + (linkTok ? '?ref=' + encodeURIComponent(linkTok) : '')).then(r => r.json()).then(sp => {
|
|
if (sp && sp.invited && sp.name) {
|
|
sponsorName = sp.name;
|
|
$('sponName').textContent = sp.name + (sp.own ? ' (your own invite page; visitors see your name here)' : '');
|
|
$('sponAv').innerHTML = sp.avatarUrl ? '<img src="' + esc(sp.avatarUrl) + '" alt="">' : esc(String(sp.name).replace(/^@/, '').slice(0, 2).toUpperCase());
|
|
if (sp.cobrand && sp.bio) { $('sponBio').textContent = sp.bio; $('sponBio').hidden = false; }
|
|
$('spon').hidden = false;
|
|
}
|
|
}).catch(() => {});
|
|
fetch('/api/stats').then(r => r.json()).then(s => { if (s && s.onchainMembers > 1) { $('jnStatsText').textContent = s.onchainMembers.toLocaleString() + ' members on-chain so far'; $('jnStats').hidden = false; } }).catch(() => {});
|
|
})();
|