' + (c.created ? new Date(c.created).toLocaleDateString() : '') + '
'
+ + '
').join('')
+ + '
'
+ + '
Archived campaigns keep every number they earned. They serve nothing and reserve nothing, so their unspent credits are back in your Available balance. Restore brings one back, paused.
').join('') + '';
el.appendChild(tbl);
pageList('camps', tbl, 'tbody tr');
+ renderArchived(el, r);
const note = document.createElement('p'); note.className = 'muted small';
note.textContent = 'Credits you put into a campaign are set aside the moment you start it, so your Available number drops right away and the campaign spends from its own budget. Featured links and verified-visit packs are paid in full up front; a featured run is sold by the day, so use Extend run to keep it going. Whatever a campaign has not spent comes back to Available when it ends.';
el.appendChild(note);
@@ -950,6 +976,20 @@
try { await api('/api/my/campaigns/' + b.dataset.camp + '/' + b.dataset.act); await loadCampaigns(); }
catch (e) { IAP.status(e.message, 'bad'); }
}));
+ el.querySelectorAll('[data-arch]').forEach(b => b.addEventListener('click', async () => {
+ const left = Number(b.dataset.archleft) || 0;
+ const ok = await IAP.confirmBox(
+ 'It stops appearing in this list but keeps every number it earned, in the Archived section below.'
+ + (left ? ' Its ' + left.toLocaleString() + ' unspent credits go straight back to your Available balance.' : '')
+ + ' You can restore it at any time.',
+ { title: 'Archive ' + b.dataset.archname, ok: 'Archive it', cancel: 'Keep it here' });
+ if (!ok) return;
+ b.disabled = true;
+ try { const x = await api('/api/my/campaigns/' + b.dataset.arch + '/archive');
+ IAP.status('Archived.' + (x.freed ? ' ' + Number(x.freed).toLocaleString() + ' credits released.' : ''), 'ok');
+ await loadCampaigns(); loadDashboard(); }
+ catch (e) { IAP.status(e.message, 'bad'); b.disabled = false; }
+ }));
el.querySelectorAll('button[data-topup]').forEach(b => b.addEventListener('click', async () => {
const n = await IAP.ask({ title: 'Add credits', text: 'How many credits to add to this campaign? More credits buy more views. They are set aside now and spend as views are delivered; anything unspent comes back when the campaign ends.', type: 'number', placeholder: 'e.g. 100', ok: 'Add credits' });
if (!n) return;
diff --git a/public/my.html b/public/my.html
index aadded7..303dc29 100644
--- a/public/my.html
+++ b/public/my.html
@@ -1073,7 +1073,7 @@
-
+