616e8e5878
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
76 lines
11 KiB
JavaScript
76 lines
11 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' },
|
|
links: { video: 'links', eyebrow: 'One link, every page you promote', h: 'Stop <em>juggling links.</em>', lead: 'One short link stands in for all of yours. Behind it, the pages you promote, served in turn by the weights you set, with hours, caps and a fallback. The link never changes, so every copy out in the world keeps working.', points: ['Weights, hours of the day, daily caps, a fallback.', 'A report by source, country and device; your tracker click id filled in.', 'Free. Try a spin on the home page with no account.'], cta: 'Make your first spin link', sub: 'free account by email' },
|
|
pages: { video: 'pages', eyebrow: 'Bridge pages in a minute', h: 'Point it at any offer. <em>Get a page.</em>', lead: 'Paste the address of the offer you promote. LinkSpin reads its headline and points, you add one line of angle, and you get a bridge, review or squeeze page on a clean pages domain. Leads are yours.', points: ['Bridge, review or squeeze. Your colours, a niche hero image.', 'Leads to your own list: CSV or webhook.', 'Put the page behind your spin link and send traffic by weight.'], cta: 'Scan an offer you already promote', sub: 'free account by email' },
|
|
zones: { video: 'zones', eyebrow: 'Your site pays you', h: 'One script tag. <em>Ad credits for every viewable view.</em>', lead: 'A zone is an ad slot on your own site in any of nine sizes. Member campaigns show first, then network ads, then a house banner. Viewable impressions pay you ad credits you spend on your own campaigns.', points: ['Viewable = half the banner on screen for one second. Bots never count.', 'Paid ads only on the site you declared.', 'Credits spend on your own banner or text campaign.'], cta: 'Add a zone, paste the tag', sub: 'free account by email' },
|
|
audiences: { video: 'audiences', eyebrow: 'Retargeting, built in', h: 'Reach your own visitors <em>again.</em>', lead: 'Everyone who views your pages or your zones is remembered for 30 days in an audience you own. Paste a pixel on any other site you control. Then show a campaign only to them, or never to them.', points: ['My visitors is automatic. Named audiences take one pixel line.', 'Show only to, or never show to, on any banner or text campaign.', 'Honest match: cookie plus a 24-hour fallback, nothing personal stored.'], cta: 'See your audiences', sub: 'free account by email' },
|
|
stack: { video: 'stack', eyebrow: 'Three tools, zero dollars', h: 'A rotator, a page builder, an ad slot. <em>Free.</em>', lead: 'Join with just an email and the whole stack is yours: spin links, bridge pages and a zone for your site. View a few ads a day and you earn credits for your first campaign. Buy a package only if you want more.', points: ['No wallet, no card, nothing to install.', 'Spin links, pages and zones never need a package.', 'Packages from $10 when you want more reach.'], cta: 'Start with the free stack', sub: 'type your email, get a code, that is the whole signup' },
|
|
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;
|
|
// the hook video (16:9 cut on Spaces) + a call to action that jumps to the email box
|
|
if (a.video) { const VID = 'https://coolify-saasytop.nyc3.digitaloceanspaces.com/linkspin/promo/'; const v = $('jnVideo'); v.src = VID + a.video + '.mp4'; v.poster = VID + a.video + '.jpg'; $('jnVideoWrap').hidden = false; }
|
|
$('jnCtaRow').hidden = false;
|
|
$('jnCta').addEventListener('click', e => { e.preventDefault(); const em = $('jnEmail'); em.scrollIntoView({ behavior: 'smooth', block: 'center' }); setTimeout(() => em.focus(), 450); });
|
|
}
|
|
// ?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(() => {});
|
|
})();
|