diff --git a/public/assets/cr-shell.js b/public/assets/cr-shell.js index 4c2d010..dd311f2 100644 --- a/public/assets/cr-shell.js +++ b/public/assets/cr-shell.js @@ -11,13 +11,14 @@ window.CR = (function () { ['pages', 'Pages', '/pages', ''], ['zones', 'Zones', '/zones', ''], ['ads', 'Ads', '/ads', ''], + ['credits', 'Credits', '/credits', ''], ['reports', 'Reports', '/reports', ''], ['team', 'Team', '/team', ''], ['wallet', 'Wallet', '/wallet', ''], ]; // screens not built yet fall back to the classic dashboard pane so nothing is a dead end const FALLBACK = { pages: '/my#promo', zones: '/my#campaigns', team: '/my#line', wallet: '/my#wallet' }; - const BUILT = new Set(['links', 'pages', 'zones', 'ads', 'reports', 'team', 'wallet']); + const BUILT = new Set(['links', 'pages', 'zones', 'ads', 'credits', 'reports', 'team', 'wallet']); let ME = null, toastT; function toast(msg, bad) { let t = $('crToast'); if (!t) { t = document.createElement('div'); t.id = 'crToast'; t.className = 'toast'; t.setAttribute('role', 'status'); document.body.appendChild(t); } t.textContent = msg; t.classList.toggle('bad', !!bad); t.classList.add('on'); clearTimeout(toastT); toastT = setTimeout(() => t.classList.remove('on'), 2000); } 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; } @@ -115,7 +116,19 @@ window.CR = (function () { back.querySelector('#laGo').addEventListener('click', () => { back.remove(); done(); }); }); } - async function requireSession(onReady) { const m = await me(); whoPaint(m); if (m && m.signedIn) { strip(); await loginAd(); return onReady(m); } signInFlow(async r => { whoPaint(r); strip(); await loginAd(); onReady(r); }); } + // first run: a member needs a username before anything else (it becomes the invite link; permanent once set) + async function ensureUsername(m) { + if (!m || !m.signedIn || m.username) return m; + let suggest = ''; try { suggest = (await get('/api/my/username-suggest')).suggest || ''; } catch (e) {} + for (let i = 0; i < 3; i++) { + const v = await dialog({ title: 'Pick your username', text: 'This is how your team sees you and it becomes your invite link. It is permanent once saved. Letters, numbers and underscores, 3 to 20 characters.', fields: [{ k: 'username', label: 'Username', value: suggest, placeholder: 'yourname' }], ok: 'Save and continue', no: 'Later' }); + if (!v) return m; + try { await api('/api/my/profile', { username: String(v.username || '').trim() }); const fresh = await me(true); whoPaint(fresh); toast('Saved. Your invite link is /join/' + fresh.username); return fresh; } + catch (e) { toast(e.message, true); suggest = String(v.username || ''); } + } + return m; + } + async function requireSession(onReady) { let m = await me(); whoPaint(m); if (m && m.signedIn) { strip(); m = await ensureUsername(m); await loginAd(); return onReady(m); } signInFlow(async r => { whoPaint(r); strip(); await loginAd(); onReady(r); }); } // tiles with a sparkline and a delta chip (Instrument scheme, 2026-09-29): series = numbers oldest first function sparkline(series) { const s = (series || []).map(Number); if (s.length < 2 || !s.some(Boolean)) return ''; diff --git a/public/assets/credits-screen.js b/public/assets/credits-screen.js new file mode 100644 index 0000000..af9f07c --- /dev/null +++ b/public/assets/credits-screen.js @@ -0,0 +1,148 @@ +// LinkSpin Credits (2026-10-07): the buy screen inside the Control Room. Package picker from the catalog, the POL +// quote, connect/link a wallet, the on-chain purchase (ported from the classic /my#buy flow: sponsor hold, balance +// pre-flight, Trust Wallet heads-up), switch-on-payouts without buying, card on-ramp, purchases from the chain. +(function () { + const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt; + // wallet.js reports through IAP.status (the classic dashboard's status bar): route it to the shell's toast + if (window.IAP) IAP.status = (m, kind) => CR.toast(m, kind === 'bad'); + CR.mount({ active: 'credits', title: 'Credits', sub: 'loading' }); + const pol = wei => { try { return (Number(BigInt(String(wei || '0')) / 10000000000000000n) / 100).toFixed(2); } catch (e) { return '0.00'; } }; + const usd = c => '$' + (Number(c || 0) / 100).toLocaleString(undefined, { maximumFractionDigits: 2 }); + const NAMES = { 1000: 'Door', 2500: 'Most chosen', 5000: 'Builder', 10000: 'Growth', 25000: 'Leader', 50000: 'Network' }; + let CFG = null, ME = null, CAT = [], SEL = null, CAMP = null, DASH = null; + + function paintTiles() { + const avail = CAMP ? CAMP.availableCredits : 0, inLive = CAMP ? CAMP.inCampaigns : 0; + const addr = ME && ME.address, on = !!(ME && ME.memberId); + const bc = DASH ? (DASH.buyerCount || 0) : 0; + $('tiles').innerHTML = [ + CR.tile({ k: 'Credits available', v: fmt(avail), hi: true, note: CAMP ? 'earned ' + fmt(CAMP.earnedCredits) + ' · purchased ' + fmt(CAMP.purchasedCredits) : '' }), + CR.tile({ k: 'Working in live ads', v: fmt(inLive), note: CAMP ? (CAMP.campaigns || []).filter(c => c.status === 'live').length + ' live' : '' }), + CR.tile({ k: 'Wallet', v: addr ? addr.slice(0, 6) + '…' + addr.slice(-4) : 'not linked', note: on ? 'payouts on · member #' + ME.memberId : (addr ? 'payouts off' : 'needed to buy or be paid') }), + CR.tile({ k: 'Qualification', v: bc + ' of ' + (bc >= 5 ? 5 : bc >= 2 ? 5 : 2), note: bc >= 5 ? 'levels 2 and 3 open' : bc >= 2 ? 'level 2 open · 5 opens level 3' : 'buyers to open level 2' }) + ].join(''); + } + function paintPkgs() { + const live = CAT.filter(p => p.active !== false && p.exists !== false); + if (!live.length) { $('pkgs').innerHTML = '
No packages are on sale right now.
'; return; } + if (!SEL) SEL = (live.find(p => p.priceCents === 2500) || live[0]).id; + $('pkgs').innerHTML = live.map(p => '').join(''); + $('pkgs').querySelectorAll('.pk').forEach(b => b.addEventListener('click', () => { SEL = Number(b.dataset.id); paintPkgs(); paintQuote(); paintGoes(); })); + } + const sel = () => CAT.find(p => p.id === SEL); + function paintQuote() { + const p = sel(); if (!p) return; + if (p.costWei) { $('payPol').textContent = pol(p.costWei) + ' POL'; $('payUsd').textContent = '≈ ' + usd(p.priceCents) + ' + gas'; } + else { $('payPol').textContent = 'paused'; $('payUsd').textContent = 'price feed is catching up'; } + const rate = (p.costWei && p.priceCents) ? (p.priceCents / 100) / (Number(BigInt(p.costWei) / 1000000000000n) / 1e6) : 0; + $('rateLine').textContent = rate ? 'rate ' + rate.toFixed(4) + ' USD/POL · live from the oracle' : ''; + const addr = ME && ME.address; + $('buyBtn').disabled = !p.costWei; + $('buyBtn').textContent = addr ? 'Buy ' + usd(p.priceCents) + ' package' : 'Connect a wallet to buy'; + } + function paintGoes() { + const p = sel(); if (!p) return; + const d = p.priceCents / 100; const spName = ME && ME.sponsorName ? ('@' + String(ME.sponsorName).replace(/^@/, '')) : 'your sponsor'; + $('goesTitle').textContent = 'Where ' + usd(p.priceCents) + ' goes'; + $('goesRows').innerHTML = [ + ['Level 1 · ' + esc(spName), '$' + (d * 0.5).toFixed(2)], + ['Level 2 · upline if qualified', '$' + (d * 0.2).toFixed(2)], + ['Level 3 · upline if qualified', '$' + (d * 0.1).toFixed(2)], + ['Platform, two wallets', '$' + (d * 0.2).toFixed(2)] + ].map(([k, v]) => '
' + k + '' + v + '
').join('') + + '

A pass-up goes to the next qualified member above, else to the platform. Nothing is ever held for later.

'; + } + function paintWallet() { + const addr = ME && ME.address, on = !!(ME && ME.memberId); + $('walletMeta').textContent = addr ? (on ? 'payouts on' : 'linked · payouts off') : 'none linked'; + $('walletBox').innerHTML = addr + ? '
' + esc(addr) + '
' + + (on ? '
Payouts on. Every package your people buy pays this wallet in the same transaction.
' + : '
Linked, but payouts are off until this wallet is on the contract. Buying a package does that. So does the free activation below (gas only).
') + + '
Open on the explorer
' + : '
Link the wallet that should receive your payouts. One free signature, no transaction. SafePal is the recommended wallet; MetaMask, Phantom and any WalletConnect wallet work too.
Wallet guide
'; + const lb = $('linkBtn'); if (lb) lb.addEventListener('click', () => guard(lb, linkWallet)); + const ab = $('activateBtn'); if (ab) ab.addEventListener('click', () => guard(ab, activate)); + const rb = $('relinkBtn'); if (rb) rb.addEventListener('click', () => guard(rb, async () => { await IAPWallet.disconnect(); CR.toast('Disconnected. Reloading so you can pick another wallet.'); setTimeout(() => location.reload(), 800); })); + } + function paintBuys(E) { + const buys = E && Array.isArray(E.purchases) ? E.purchases : []; + $('buysMeta').textContent = buys.length + (buys.length === 1 ? ' purchase' : ' purchases') + ' · every row links to the transaction'; + $('buyRows').innerHTML = buys.length ? buys.slice(0, 50).map(x => { + const ts = Number(x.ts || x.time || 0); const when = ts ? new Date(ts * (ts > 1e12 ? 1 : 1000)).toLocaleString() : ''; + const pkg = x.priceCents ? usd(x.priceCents) : (x.package || x.product || ('#' + (x.productId || ''))); + const paid = x.amountWei || x.valueWei || x.paidWei ? pol(x.amountWei || x.valueWei || x.paidWei) + ' POL' : ''; + const tx = x.tx || x.hash || ''; + return '
' + esc(when) + '' + esc(String(pkg)) + '' + esc(paid) + '' + (tx ? '' + esc(tx.slice(0, 10)) + '…' + esc(tx.slice(-6)) + '' : '') + '
'; + }).join('') : '
Nothing yet. Your first package shows here with its transaction, what you paid in POL, and who in your line was paid.
'; + } + async function guard(btn, fn) { if (btn.disabled) return; btn.disabled = true; try { await fn(); } catch (e) { CR.toast((e && e.message) || 'Something went wrong.', true); } finally { btn.disabled = false; } } + + // a named sponsor that cannot be paid right now: hold the transaction and say why (never credit the company by default) + function holdText(sp) { + const who = sp.sponsorName ? ('@' + String(sp.sponsorName).replace(/^@/, '')) : 'your sponsor'; + if (sp.sponsorBlocked === 'claim' && sp.claim) return (sp.claim.nobody ? 'Nobody above you on LinkSpin has a wallet yet, so there is no one for the contract to pay. ' : who + ' has not linked a wallet on LinkSpin yet. ') + 'Your first purchase waits until ' + (sp.claim.deadline ? new Date(sp.claim.deadline).toLocaleDateString() : 'they do') + ', then it goes ahead with the nearest member above who has one. Nothing was charged.'; + if (sp.sponsorBlocked === 'notActivated') return who + ' has not switched on payouts yet, so this purchase would credit the company instead of them. Ask them to switch on payouts first (one free transaction).'; + if (sp.sponsorBlocked === 'rpc') return 'Could not confirm your sponsor on the chain just now. Try again in a minute; nothing was charged.'; + return 'Your sponsor link could not be matched to a member. Message support before buying so ' + who + ' gets credit.'; + } + async function linkWallet() { CR.toast('Check your wallet for the free link signature…'); await IAPWallet.signIn(); CR.toast('Wallet linked. Earnings pay there from now on.'); await load(); } + async function activate() { + const me = await CR.me(true); if (me.sponsorBlocked) { $('holdBox').textContent = holdText(me); $('holdBox').hidden = false; return; } + CR.toast('Confirm the free activation in your wallet…'); + const r = await IAPWallet.activate(me.sponsorId || 0); + if (!r.receipt || r.receipt.status !== '0x1') throw new Error('Transaction reverted. Check the explorer.'); + CR.toast('Payouts are on. Your invite link is live.'); await load(); + } + async function buy() { + const p = sel(); if (!p || !p.costWei) return; + $('holdBox').hidden = true; + let me = await CR.me(true); + if (!me.address) { CR.toast('Link your wallet first: one quick signature…'); await IAPWallet.signIn(); me = await CR.me(true); } + const want = String(me.address || '').toLowerCase(); if (!want) throw new Error('No wallet linked.'); + await IAPWallet.connect(); + let cur = String(await IAPWallet.activeAddress() || '').toLowerCase(); + if (cur !== want) { CR.toast('Pick ' + want.slice(0, 6) + '…' + want.slice(-4) + ' in your wallet\'s account picker…'); cur = String(await IAPWallet.pickAccount() || '').toLowerCase(); } + if (cur !== want) throw new Error('Your wallet connected as ' + cur.slice(0, 6) + '…' + cur.slice(-4) + ' but your linked wallet is ' + want.slice(0, 6) + '…' + want.slice(-4) + '. Switch accounts in the wallet app and try again.'); + const sp = await CR.get('/api/sponsor'); + if (!me.memberId && sp.sponsorBlocked) { $('holdBox').textContent = holdText(sp); $('holdBox').hidden = false; return; } + try { // pre-flight: the POL has to be there; Trust Wallet refuses transactions that spend most of a balance + const need = BigInt(p.costWei) + BigInt(p.costWei) / 50n; + const bal = await IAPWallet.balance(want); + if (bal < need) { CR.toast('That wallet holds ' + pol(bal.toString()) + ' POL, but this package needs about ' + pol(need.toString()) + ' POL plus a little for gas. Top it up and try again.', true); return; } + const pct = Number(need * 100n / bal); + if (/trust/i.test(IAPWallet.walletName() || '') && pct > 55) { + const ok = await CR.dialog({ title: 'Heads up for Trust Wallet', text: 'This purchase uses about ' + pct + '% of the POL in your wallet, and Trust Wallet refuses transactions that spend most of a balance. Add some POL first, or continue and see if it lets it through.', ok: 'Continue' }); + if (!ok) return; + } + } catch (e) { /* balance read failed: let the wallet decide */ } + CR.toast('Confirm the purchase in your wallet…'); + const r = await IAPWallet.buy(Number(p.id), sp.sponsorId || 0, p.costWei); + if (!r.receipt || r.receipt.status !== '0x1') throw new Error('Transaction reverted. Nothing was charged beyond gas.'); + CR.toast('Settled on-chain. Your credits are in Ads now.'); + await load(); + } + $('buyBtn').addEventListener('click', () => guard($('buyBtn'), buy)); + $('cardBtn').addEventListener('click', () => guard($('cardBtn'), async () => { + const p = sel(); const need = p && p.costWei ? Math.max(10, Math.ceil(Number(BigInt(p.costWei) / 1000000000000000000n)) + 3) : 30; + const q = '/api/moonpay-url?pol=' + need + (ME && ME.address ? '&address=' + encodeURIComponent(ME.address) : ''); + const r = await CR.get(q); if (!r.url) throw new Error('The card on-ramp is not available right now.'); + window.open(r.url, '_blank', 'noopener'); CR.toast('MoonPay opened in a new tab. POL lands straight in your own wallet.'); + })); + + async function load() { + try { [CFG, ME] = await Promise.all([CR.get('/api/config'), CR.me(true)]); } catch (e) { CR.sub('could not load'); return; } + let cat = null, E = null; + try { [cat, CAMP, DASH, E] = await Promise.all([CR.get('/api/catalog'), CR.get('/api/my/campaigns'), CR.get('/api/my/dashboard'), CR.get('/api/my/activity')]); } catch (e) {} + CAT = (cat && cat.products) || []; + CR.sub((CAMP ? fmt(CAMP.availableCredits) + ' free to spend · ' + fmt(CAMP.inCampaigns) + ' in live ads' : '') + (CAT[0] && CAT[0].costWei ? '' : ' · price feed catching up')); + paintTiles(); paintPkgs(); paintQuote(); paintGoes(); paintWallet(); paintBuys(E); + const spName = ME.sponsorName ? ('@' + String(ME.sponsorName).replace(/^@/, '')) : null; + $('sponsorLine').innerHTML = spName + ? 'Your sponsor ' + esc(spName) + ' is placed on the contract. The moment you confirm, half of the package lands in their wallet and the rest splits as shown. Credits appear in Ads right away.' + : 'No sponsor is recorded on your account. Your purchase still works; the sponsor share goes to the platform position. If someone invited you, open their invite link first.'; + if (ME.sponsorBlocked) { $('holdBox').textContent = holdText(ME); $('holdBox').hidden = false; } + } + CR.requireSession(load); +})(); diff --git a/public/assets/join.js b/public/assets/join.js index 8e62f65..41cf64d 100644 --- a/public/assets/join.js +++ b/public/assets/join.js @@ -1,112 +1,66 @@ -// Invite / lead-capture page: /join/[?v=] -// Email first (code sign-in creates the account), wallet later inside the -// member area. The angle only changes the hook copy; the sponsor cookie was -// set by the server when this page was served. +// Join / sign-in page: /join, /join/[?v=] (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 LEG = (brand, seg) => seg === 'adv' - ? { eyebrow: 'For former ' + brand + ' advertisers', h: 'Your next ad budget pays you back.', - lead: brand + ' is closed. The people who bought ads there are exactly who LinkSpin was built for: real ad packages from $5, seven formats, and every package in your line paid out by a verified contract on Polygon in the same transaction.', - points: ['Welcome-back credits land the moment your account exists: enough to run a real banner or text campaign today, on us.', 'Seven formats: banners, text ads, login ads, solo ads to member inboxes, video, featured links and verified visits. Views are timed on the server, so a real person saw your ad.', 'When anyone in your line buys ads, the contract pays you in that same transaction. Public on Polygonscan, nothing held, nothing to withdraw.'], - cta: 'Claim your welcome-back credits', sub: 'Free account by email. No password, no wallet today. Use the email you had on ' + brand + ': the credits are tied to it.', video: false } - : { eyebrow: 'For former ' + brand + ' members', h: 'Same daily habit. Real payouts on-chain.', - lead: 'You viewed ads on ' + brand + '. Here you view ads to earn credits, run your own campaign with them for free, and when anyone in your line buys ads you are paid in POL to your own wallet in the same transaction.', - points: ['Welcome-back credits on day one, so your first campaign runs before you have viewed a single ad.', 'Join with just an email. No password, no wallet today. Link a wallet later, only when you want payouts switched on.', 'Every payout is a public transaction on Polygon. Nothing is held, so there is nothing to withdraw and nothing to wait for.'], - cta: 'Claim your welcome-back credits', sub: 'Free account by email. Use the email you had on ' + brand + ': the credits are tied to it.', video: false }; + 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 = { - 'fw-adv': LEG('Faucet Wave', 'adv'), 'fw-earn': LEG('Faucet Wave', 'earn'), 't1-adv': LEG('Tier One Ads', 'adv'), 't1-earn': LEG('Tier One Ads', 'earn'), - instant: { eyebrow: 'Same-transaction payouts', h: 'Paid before the page reloads.', lead: 'What if your commission landed before the thank-you page finished loading? On LinkSpin that is not a metaphor. A smart contract on Polygon splits every ad package the moment it sells.', - points: ['A verified contract splits every package in the same transaction it sells: 50 percent to the sponsor, 20 and 10 up the line, 20 to the platform.', 'It lands in your own wallet in seconds. There is no balance to withdraw because nothing is ever held.', 'Every payment is public on Polygonscan, so you can check the claim before you spend a dollar.'], - cta: 'See a payout land in seconds', sub: 'Free account by email. No password, no wallet today. Your invite link is live the moment you are in.' }, - adspend: { eyebrow: 'For marketers who buy traffic', h: 'You were buying ads anyway.', 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. Seven formats, dwell-timed views, packages from $5.', - points: ['Seven formats: banners, text ads, login ads, solo ads to member inboxes, video, featured links and verified visits.', 'Views are timed on the server, so a real person saw your ad. Banners and text also run across a partner ad network.', 'When anyone in your line buys ads, the contract pays you in that same transaction.'], - cta: 'Put your next ad dollar where it pays you back', sub: 'Free account by email. See every format and the live rates before you buy anything.' }, - free: { eyebrow: 'Costs nothing to try', h: 'Watch first. Spend never.', lead: 'Join free, view a few ads, earn credits, and run your first campaign for zero dollars. Upgrade only if you want more reach.', - points: ['Join with just an email. No password, no wallet today.', 'View a few ads each day and earn credits you can spend on your own banner or text campaign.', 'Buy a package only if you want more reach. They start at $5, and every payout on them is public.'], - cta: 'Start for free. No card, no wallet.', sub: 'Type your email and we send a 6-digit code. That is the whole signup.' }, - ledger: { eyebrow: 'No back office', h: 'No back office. No payday.', 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 nothing is ever held.', - points: ['Every payout is a public transaction on Polygon. Click it, read it, verify it yourself.', 'The contract holds zero balance. It splits and sends in the same transaction, with no pause switch and no upgrade path.', 'No back office means nobody can delay, reverse or review your commission.'], - cta: 'Check the ledger yourself, then decide', sub: 'Free account by email. The public ledger and the verified contract are one click from your dashboard.' }, - two: { eyebrow: 'The referral side, exactly as coded', h: 'Two buyers open level two.', lead: 'Every direct buyer pays you 50 percent from their first package. Two qualifying buyers open level two, five open level three. Written as constants in a verified contract.', - points: ['Every direct buyer pays you 50 percent from their very first package.', 'Two qualifying buyers open level two at 20 percent. Five open level three at 10 percent. Constants in a verified contract.', 'Until a level opens, its share climbs to the next qualified member above, so the plan rewards the people who build.'], - cta: 'Start your line. Two buyers is the target.', sub: 'Free account by email. Your invite link and the team-building plays are waiting inside.' } + instant: { eyebrow: 'Same-transaction payouts', h: 'Paid before the page reloads.', 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. Zero dollars.', 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. No payday.', 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 level two.', 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 ads anyway.', 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' } }; - // ?name=First personalises the page (site-owner links, Marty 2026-09-12): letters, spaces, hyphens, - // apostrophes only, 30 chars. On the company placement links it says the top spot is reserved. - const who = String(new URLSearchParams(location.search).get('name') || '').replace(/[^A-Za-z\u00C0-\u024F' -]/g, '').trim().slice(0, 30); - if (who) { - const top = /^\/join\/(company|top)$/i.test(location.pathname); - const h = $('jnHello'); - if (h) { h.textContent = who + (top ? ', your spot directly under the company at the top is reserved for you. Activate with the $20 package to claim it.' : ', this invitation is for you.'); h.hidden = false; } - } - const v = new URLSearchParams(location.search).get('v') || (document.cookie.match(/(?:^|; )iap\.angle=([^;]+)/) || [])[1] || ''; - const a = v && ANGLES[v]; + 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'); // server sets it too; this covers cached HTML - $('jnEyebrow').textContent = '· ' + a.eyebrow; $('jnHead').innerHTML = a.h; $('jnLead').textContent = a.lead; - if (a.cta) { $('jnCapH').textContent = a.cta; $('jnCapSub').textContent = a.sub || ''; } - // the matching hook video + this angle's three points replace the worked example - const VID = 'https://coolify-saasytop.nyc3.digitaloceanspaces.com/promo/'; - const vid = $('jnVideo'); - if (a.video === false) vid.hidden = true; else { vid.src = VID + v + '.mp4'; vid.poster = VID + v + '.jpg'; } - $('jnPoints').innerHTML = (a.points || []).map(t => '
  • ' + t.replace(/[&<>]/g, c => ({ '&': '&', '<': '<', '>': '>' }[c])) + '
  • ').join(''); - $('jnMock').hidden = true; $('jnAngle').hidden = false; $('jnPoints').hidden = false; + 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 => '
  • ' + esc(t) + '
  • ').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; - } + 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; }; - function busy(btn, fn) { - return async () => { if (btn.disabled) return; btn.disabled = true; err(''); try { await fn(); } catch (e) { err(e.message || 'Something went wrong.'); } finally { btn.disabled = false; } }; - } + 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 r = await IAP.requestCode($('jnEmail').value, codeOpts()); - $('jnCodeRow').hidden = false; $('jnVerify').hidden = false; $('jnSend').hidden = true; $('jnResend').hidden = false; + 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; - // the last thing they see before the account is created: who they are joining under 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; } - IAP.status(r.sent ? 'Code sent. Check your inbox (and spam, the first time).' : 'Dev mode: code filled in.', 'ok'); $('jnCode').focus(); }); - $('jnSend').addEventListener('click', send); - $('jnResend').addEventListener('click', busy($('jnResend'), async () => { - const r = await IAP.requestCode($('jnEmail').value, codeOpts()); - if (r.devCode) $('jnCode').value = r.devCode; - IAP.status('Fresh code sent.', 'ok'); - })); + $('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 () => { - await api('/api/auth/email/verify', { email: $('jnEmail').value, code: $('jnCode').value, newsletter: !!$('jnNews').checked, followups: !!$('jnNews').checked }); - IAP.status('You are in. Taking you to your dashboard…', 'ok'); - location.href = '/my?welcome=1'; // dashboard runs the username step + welcome tour on arrival + 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; })); - $('jnEmail').addEventListener('keydown', e => { if (e.key === 'Enter') ($('jnVerify').hidden ? $('jnSend') : $('jnVerify')).click(); }); - $('jnCode').addEventListener('keydown', e => { if (e.key === 'Enter') $('jnVerify').click(); }); + $('jnCode').addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); $('jnVerify').click(); } }); - // sponsor line (the link opened most recently sets the sponsor; it locks at account creation) - let sponsorName = ''; + // 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; - $('jnSponName').textContent = sp.name + (sp.own ? ' (this is your own invite page; visitors see your name here)' : ''); - if (sp.avatarUrl) { $('jnSponImg').src = sp.avatarUrl; $('jnSponImg').hidden = false; } - if (sp.cobrand && sp.bio && $('jnSponBio')) { $('jnSponBio').textContent = sp.bio; $('jnSponBio').hidden = false; $('jnSpon').classList.add('cobrand'); } - $('jnSpon').hidden = false; + $('sponName').textContent = sp.name + (sp.own ? ' (your own invite page; visitors see your name here)' : ''); + $('sponAv').innerHTML = sp.avatarUrl ? '' : 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(() => {}); - // package ladder (dollar constants + live POL quote) - const NAMES = { 1: 'Micro', 2: 'Activation', 3: 'Builder', 4: 'Growth', 5: 'Leader' }; - fetch('/api/catalog').then(r => r.json()).then(c => { - const wrap = $('jnLadder'); if (!wrap || !c.products) return; - wrap.innerHTML = c.products.filter(p => p.active !== false).map(p => - '
    ' + (NAMES[p.id] || 'Package ' + p.id) + '
    ' + IAP.fmtUsd(p.priceCents) + '
    ' + Number(p.creditAmount).toLocaleString() + ' credits
    ' - + (p.costWei ? '
    ' + IAP.fmtPol(p.costWei) + ' POL now
    ' : '') + '
    ').join(''); - }).catch(() => {}); - fetch('/api/stats').then(r => r.json()).then(s => { - if (s && s.onchainMembers) $('jnStats').textContent = s.onchainMembers.toLocaleString() + (s.onchainMembers === 1 ? ' member' : ' members') + ' on-chain so far.'; - }).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(() => {}); })(); diff --git a/public/banners/linkspin-og-1200x630.png b/public/banners/linkspin-og-1200x630.png index 4c6ed2c..6d2f9ce 100644 Binary files a/public/banners/linkspin-og-1200x630.png and b/public/banners/linkspin-og-1200x630.png differ diff --git a/public/credits.html b/public/credits.html new file mode 100644 index 0000000..f56c829 --- /dev/null +++ b/public/credits.html @@ -0,0 +1,86 @@ + + + + + + +Credits · LinkSpin + + + + + +
    +
    +
    +
    +
    +
    +

    Buy a package

    priced in dollars · settled in POL at the live rate · one transaction
    +
    +
    loading packages…
    +
    + you pay· + +
    +
    + + + SafePal recommended. MetaMask, Phantom and WalletConnect wallets also work. +
    + +

    Loading your sponsor…

    +
    +
    +
    +

    Your purchases

    every row links to the transaction
    +
    WhenPackagePaidTransaction
    +
    +
    credits appear in Ads the moment the transaction settles · nothing is held by the site
    +
    +
    +
    +
    +

    Where it goes

    same transaction
    +
    +
    +
    +

    Your wallet

    +
    +
    +
    +

    Earn instead

    free credits
    +
    +
    View 5 ads, claim 5 creditsAds →
    +
    Run a zone on your siteZones →
    +
    Sign-in ad, once a dayautomatic
    +
    +
    +
    +
    +
    +
    + + + + + + diff --git a/public/join.html b/public/join.html index 5d39ea0..7cdae44 100644 --- a/public/join.html +++ b/public/join.html @@ -2,162 +2,92 @@ - -You're invited | LinkSpin - +Join LinkSpin + + + + + - + -
    -
    - LinkSpin - Already a member? Sign in +
    +
    + LinkSpin + + already a member? the same form signs you in
    +
    -
    - -

    LinkSpin · Advertise and earn on Polygon

    - -

    Advertise and earn.
    Paid on-chain, instantly.

    -

    Every ad package splits to real wallets in the same transaction it sells. No pending payouts, no withdraw button, and every payment is public.

    -
    - -
    -
    -
    -

    This wallet

    loading
    Connecting a wallet and buying a package use the wallet screen in the classic dashboard until the on-chain flow moves into this shell.
    +

    This wallet

    loading
    Linking a wallet and buying a package live on the Credits screen.

    How you get paid

    Every package splits in the same transaction: 50% direct sponsor, 20% level 2, 10% level 3, 20% platform. Nothing is held by the site, ever. Your sponsor is paid the moment your purchase settles.
    diff --git a/server.js b/server.js index 1c85b8f..911e67e 100644 --- a/server.js +++ b/server.js @@ -332,12 +332,12 @@ async function handleUpload(req, res, who) { const JOIN_ALIASES = { company: 'martbost', top: 'martbost' }; // neutral partner links -> the top position const JOIN_ANGLES = { // legacy bridge pages (/from/): former members of Marty's closed EvolutionScript sites - 'fw-adv': { t: 'Your next ad budget pays you back.', d: 'Faucet Wave closed. LinkSpin was built for the people who bought ads there: packages from $5, seven formats, every package in your line paid out on Polygon in the same transaction. Welcome-back credits waiting.', url: SITE_URL + '/from/faucetwave?seg=advertiser' }, + 'fw-adv': { t: 'Your next ad budget pays you back.', d: 'Faucet Wave closed. LinkSpin was built for the people who bought ads there: packages from $10, banner, text and login ads, every package in your line paid out on Polygon in the same transaction. Welcome-back credits waiting.', url: SITE_URL + '/from/faucetwave?seg=advertiser' }, 'fw-earn': { t: 'Same daily habit. Real payouts on-chain.', d: 'You viewed ads on Faucet Wave. Here you view ads to earn credits, run your own campaign free, and get paid in POL to your own wallet when your line buys ads. Welcome-back credits waiting.', url: SITE_URL + '/from/faucetwave' }, - 't1-adv': { t: 'Your next ad budget pays you back.', d: 'Tier One Ads closed. LinkSpin was built for the people who bought ads there: packages from $5, seven formats, every package in your line paid out on Polygon in the same transaction. Welcome-back credits waiting.', url: SITE_URL + '/from/tieroneads?seg=advertiser' }, + 't1-adv': { t: 'Your next ad budget pays you back.', d: 'Tier One Ads closed. LinkSpin was built for the people who bought ads there: packages from $10, banner, text and login ads, every package in your line paid out on Polygon in the same transaction. Welcome-back credits waiting.', url: SITE_URL + '/from/tieroneads?seg=advertiser' }, 't1-earn': { t: 'Same daily habit. Real payouts on-chain.', d: 'You viewed ads on Tier One Ads. Here you view ads to earn credits, run your own campaign free, and get paid in POL to your own wallet when your line buys ads. Welcome-back credits waiting.', url: SITE_URL + '/from/tieroneads' }, instant: { t: 'Paid before the page reloads.', d: 'A smart contract on Polygon splits every ad package the moment it sells. Same transaction, real wallets, public ledger. Join free by email.' }, - adspend: { t: 'You were buying ads anyway.', d: 'Here the ad spend in your line pays you, in the same transaction, on a public ledger. Seven formats, packages from $5. Join free.' }, + adspend: { t: 'You were buying ads anyway.', d: '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. Join free.' }, free: { t: 'Watch first. Spend never.', d: 'Join free, view a few ads, earn credits, run your first campaign for zero dollars. Every payout public on Polygon.' }, ledger: { t: 'No back office. No payday.', d: 'Every payout is a public transaction on Polygon you can read yourself. Nothing is ever held. Join free by email.' }, two: { t: 'Two buyers open level two.', d: 'Every direct buyer pays you 50 percent from their first package. Two qualifying buyers open level two, five open level three. Written in a verified contract.' } @@ -3004,6 +3004,8 @@ const server = http.createServer(async (req, res) => { if (p === '/ads') return sendFile(res, path.join(PUBLIC_DIR, 'ads.html')); if (p === '/team') return sendFile(res, path.join(PUBLIC_DIR, 'team.html')); if (p === '/wallet') return sendFile(res, path.join(PUBLIC_DIR, 'wallet.html')); + if (p === '/credits') return sendFile(res, path.join(PUBLIC_DIR, 'credits.html')); // Control Room: buy packages, link wallet, payouts on (2026-10-07) + if (p === '/join') return serveJoinPage(res, '', '', null, []); // bare join: sponsor from the cookie if any (home-page CTAs) if (p === '/admin') return sendFile(res, path.join(PUBLIC_DIR, 'admin.html')); if (p === '/shorts') return sendFile(res, path.join(PUBLIC_DIR, 'shorts.html')); if (p === '/plays') return sendFile(res, path.join(PUBLIC_DIR, 'plays.html'));