diff --git a/keeper.js b/keeper.js index 236b194..1adffb4 100644 --- a/keeper.js +++ b/keeper.js @@ -54,9 +54,11 @@ function decide(now) { return { act: true, giftee: cands.length ? cands[0].address : chain.ZERO, candidates: cands.length, fundToday }; } +let otherBusy = () => false; // refuelspots.js signs with the same wallet: never two sends at once +function setOtherBusy(f) { otherBusy = f; } async function tick() { const c = cfgMod.get(); - if (running || !c.keeperEnabled || !process.env.KEEPER_KEY || !c.contract) return; + if (running || otherBusy() || !c.keeperEnabled || !process.env.KEEPER_KEY || !c.contract) return; running = true; try { await chain.tail(); // decide on fresh data @@ -93,4 +95,4 @@ function init() { } function statusInfo() { const c = cfgMod.get(); return { enabled: c.keeperEnabled && !!process.env.KEEPER_KEY, last: lastDecision, preview: decide(), log: store.keeperEntries().slice(-20).reverse() }; } -module.exports = { init, tick, decide, candidates, statusInfo, centralDay }; +module.exports = { init, tick, decide, candidates, statusInfo, centralDay, setOtherBusy, busy: () => running }; diff --git a/public/assets/line.css b/public/assets/line.css index ff22fe8..e7b29bc 100644 --- a/public/assets/line.css +++ b/public/assets/line.css @@ -48,3 +48,4 @@ nav .links a.active{color:var(--mint-ink);background:var(--mint)} .brand{display:flex;align-items:center;gap:11px;color:var(--ink);text-decoration:none!important;min-width:0} .brand img{flex:none;filter:drop-shadow(0 4px 14px rgba(155,123,255,.35))} .brand .logo{letter-spacing:-.02em} +.ls-pick{margin:6px 0 4px}.ls-pick .row{gap:8px} diff --git a/public/assets/my.js b/public/assets/my.js index bacafe0..ca1af16 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -42,9 +42,34 @@ el.innerHTML = head + '
' + 'Looking up your LinkSpin Banner Spins...
'; + const d = await BL.getJSON('/api/my/lsspins'); + if (d.error) { pick.innerHTML = '' + esc(d.error) + '
'; return; } + const make = 'make one on LinkSpin'; + if (!d.account) { pick.innerHTML = 'No LinkSpin account holds this wallet yet. Join LinkSpin (free) with the same email as InstantAdPay, link this wallet there, then ' + make + '.
'; return; } + if (!d.spins.length) { pick.innerHTML = 'You have no 468x60 Banner Spin yet: ' + make + ', then come back and tap the button again.
'; return; } + pick.innerHTML = 'Pick a 468x60 Banner Spin. Its rotating image and tracking link go on this spot, and LinkSpin reports clicks under your Downline Banners source.
'; + const row = pick.querySelector('.row'); + for (const sp of d.spins) { + const bt = document.createElement('button'); bt.className = 'btn sec small'; bt.textContent = sp.name + ' (' + sp.banners + ' banners' + (sp.paused ? ', paused' : '') + ')'; + bt.onclick = async () => { + BL.status('Connecting your Banner Spin...'); + const u = await BL.post('/api/my/lsspins/use', { spinId: sp.id }); + if (u.error || !u.use) return BL.status(u.error || 'Could not use that Banner Spin.', 'err'); + el.querySelector('[data-k=link]').value = u.use.link; el.querySelector('[data-k=img]').value = u.use.img; + el.querySelector('[data-a=save]').click(); + if (u.use.otherSource) BL.status('Saved. This Banner Spin already reports under another LinkSpin source, so clicks stay there.', 'ok'); + }; + row.appendChild(bt); + } + }; el.querySelector('[data-a=save]').onclick = async () => { const link = el.querySelector('[data-k=link]').value.trim(), img = el.querySelector('[data-k=img]').value.trim(); const body = { link }; if (img || !String(s.img || '').startsWith('/art/u/')) body.img = img; diff --git a/public/board.html b/public/board.html index 5b302e4..240384a 100644 --- a/public/board.html +++ b/public/board.html @@ -7,7 +7,7 @@ - +