Ad reporting + featured rotates one link + clear campaign form on submit
- Ad reporting (auto-approved ads need a safety valve): new reports.js store (dual-mode) + ad_reports table + POST /api/report-ad; a "⚠ report" control on served ad slots opens a reason prompt and notifies the admin by email (siteConfig.adminEmail / ADMIN_EMAIL). - Featured links now show ONE link at a time and cycle (true rotation), instead of listing all links at once. - Campaign form now clears EVERY field on submit (target/creative/title/etc.). A leftover target URL was carrying into the next campaign — the same reason a video short was saved with the wrong (massifly) CTA target. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+19
-3
@@ -96,6 +96,21 @@ window.IAP = (function () {
|
||||
return div;
|
||||
}
|
||||
// Render one served ad into #<elId>. Silent if no inventory.
|
||||
// report an ad (auto-approved ads need a member-facing flag → admin notified)
|
||||
function reportAd(campaignId) {
|
||||
if (!campaignId) return;
|
||||
const reason = (prompt('Report this ad. Reason: broken, inappropriate, spam, scam, or other', 'broken') || '').trim().toLowerCase();
|
||||
if (!reason) return;
|
||||
const note = prompt('Anything to add? (optional)') || '';
|
||||
fetch('/api/report-ad', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ campaignId, reason, note }) })
|
||||
.then(() => status('Thanks — this ad was reported to the admin for review.', 'ok'))
|
||||
.catch(() => status('Could not send the report. Try again.', 'bad'));
|
||||
}
|
||||
const reportTag = ad => ' <a class="ad-report small muted" href="#" data-cid="' + ad.id + '" style="margin-left:8px">⚠ report</a>';
|
||||
function wireReport(el) {
|
||||
const rl = el.querySelector('.ad-report');
|
||||
if (rl) rl.addEventListener('click', e => { e.preventDefault(); reportAd(Number(rl.dataset.cid)); });
|
||||
}
|
||||
async function adSlot(type, elId) {
|
||||
try {
|
||||
const { ad } = await (await fetch('/api/ads/slot?type=' + type)).json();
|
||||
@@ -104,13 +119,14 @@ window.IAP = (function () {
|
||||
if (ad.imageUrl) {
|
||||
el.innerHTML = '<a href="' + ad.targetUrl + '" target="_blank" rel="noopener nofollow">'
|
||||
+ '<img src="' + ad.imageUrl + '" alt="advertisement" style="max-width:100%;border-radius:8px"></a>'
|
||||
+ '<div class="small muted">member ad</div>';
|
||||
+ '<div class="small muted">member ad' + reportTag(ad) + '</div>';
|
||||
} else {
|
||||
el.innerHTML = '<a href="' + ad.targetUrl + '" target="_blank" rel="noopener nofollow"><b>' + ad.title + '</b>'
|
||||
+ (ad.body ? ' · ' + ad.body : '') + '</a> <span class="small muted">member ad</span>';
|
||||
+ (ad.body ? ' · ' + ad.body : '') + '</a> <span class="small muted">member ad' + reportTag(ad) + '</span>';
|
||||
}
|
||||
wireReport(el);
|
||||
el.hidden = false;
|
||||
} catch (e) {}
|
||||
}
|
||||
return { getConfig, fmtPol, fmtUsd, status, renderNav, refreshNavWallet, describeEvent, feedRow, adSlot, $ };
|
||||
return { getConfig, fmtPol, fmtUsd, status, renderNav, refreshNavWallet, describeEvent, feedRow, adSlot, reportAd, $ };
|
||||
})();
|
||||
|
||||
+18
-7
@@ -28,16 +28,24 @@
|
||||
return 'Fully qualified. Every level pays you, and you catch the pass-ups that under-qualified positions below you let slip. Keep sharing and keep your campaigns running.';
|
||||
}
|
||||
// featured rotation strip on the overview
|
||||
let featItems = [], featIdx = 0, featTimer = null;
|
||||
function renderOneFeatured() {
|
||||
if (!featItems.length) return;
|
||||
const i = featItems[featIdx % featItems.length];
|
||||
$('featStrip').innerHTML = '<a href="' + i.url + '" target="_blank" rel="noopener nofollow"><span>' + esc(i.title) + '</span>'
|
||||
+ (i.by ? '<span class="by">' + esc(i.by) + '</span>' : '') + '</a>';
|
||||
}
|
||||
async function loadFeatured() {
|
||||
try {
|
||||
const r = await (await fetch('/api/featured')).json();
|
||||
const card = $('featuredCard'); if (!card) return;
|
||||
if (!r.items || !r.items.length) { card.hidden = true; return; }
|
||||
card.hidden = false;
|
||||
featItems = r.items; featIdx = Math.floor(Math.random() * featItems.length);
|
||||
$('featSub').textContent = r.items.length + ' link' + (r.items.length === 1 ? '' : 's') + ' in rotation';
|
||||
$('featStrip').innerHTML = r.items.map(i =>
|
||||
'<a href="' + i.url + '" target="_blank" rel="noopener nofollow"><span>' + esc(i.title) + '</span>'
|
||||
+ (i.by ? '<span class="by">' + esc(i.by) + '</span>' : '') + '</a>').join('');
|
||||
renderOneFeatured(); // show ONE at a time (true rotation), cycle if more than one
|
||||
clearInterval(featTimer);
|
||||
if (featItems.length > 1) featTimer = setInterval(() => { featIdx++; renderOneFeatured(); }, 6000);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
@@ -665,11 +673,14 @@
|
||||
ctaLabel: isVideo ? $('cVideoCta').value : $('cCtaLabel').value,
|
||||
budget: isFeat ? (Number($('cFeatDays').value) * (lastRates.featuredPerDay || 40)) : Number($('cBudget').value) });
|
||||
IAP.status('Campaign is live. It starts serving right away.', 'ok');
|
||||
$('cName').value = ''; $('cBudget').value = '';
|
||||
$('cSoloEd').innerHTML = ''; $('cSoloRaw').value = ''; $('cCtaLabel').value = '';
|
||||
$('cVideoUrl').value = ''; $('cVideoTitle').value = ''; $('cVideoCta').value = '';
|
||||
// clear EVERY field so no target/creative carries into the next campaign
|
||||
['cName', 'cBudget', 'cTarget', 'cImage', 'cTitle', 'cBody', 'cCtaLabel',
|
||||
'cVideoUrl', 'cVideoTitle', 'cVideoCta', 'cVisitTitle', 'cVisitCount', 'cFeatTitle']
|
||||
.forEach(id => { if ($(id)) $(id).value = ''; });
|
||||
$('cSoloEd').innerHTML = ''; if ($('cSoloRaw')) $('cSoloRaw').value = '';
|
||||
$('cVideoInfo').textContent = ''; $('cVideoPrev').hidden = true; $('cVideoPrev').innerHTML = '';
|
||||
$('edMediaInfo').textContent = '';
|
||||
if ($('edMediaInfo')) $('edMediaInfo').textContent = '';
|
||||
cVidDims = null;
|
||||
await loadCampaigns();
|
||||
}));
|
||||
// defers the busy() lookup to click time (busy is declared below)
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20260906m"></script>
|
||||
<script src="/assets/common.js?v=20260907m"></script>
|
||||
<script src="/assets/contract.js?v=20260906m"></script>
|
||||
<script src="/assets/chat.js?v=20260906m"></script>
|
||||
</body>
|
||||
|
||||
+1
-1
@@ -437,7 +437,7 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script src="/assets/common.js?v=20260906m"></script>
|
||||
<script src="/assets/common.js?v=20260907m"></script>
|
||||
<script src="/assets/wallet.js?v=20260907f"></script>
|
||||
<script src="/assets/home.js?v=20260906m"></script>
|
||||
<script src="/assets/chat.js?v=20260906m"></script>
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
<div>InstantAdPay · <a href="/">how it works</a> · <a id="contractLink" href="#" target="_blank" rel="noopener">contract source ↗</a></div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20260906m"></script>
|
||||
<script src="/assets/common.js?v=20260907m"></script>
|
||||
<script src="/assets/ledger.js?v=20260906m"></script>
|
||||
<script src="/assets/chat.js?v=20260906m"></script>
|
||||
</body>
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Member area | InstantAdPay</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260907l">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260907m">
|
||||
</head>
|
||||
<body class="bo-body">
|
||||
|
||||
@@ -641,9 +641,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20260907l"></script>
|
||||
<script src="/assets/common.js?v=20260907m"></script>
|
||||
<script src="/assets/wallet.js?v=20260907f"></script>
|
||||
<script src="/assets/my.js?v=20260907l"></script>
|
||||
<script src="/assets/my.js?v=20260907m"></script>
|
||||
<script src="/assets/chat.js?v=20260907l"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@
|
||||
<p><a href="/ledger">← Back to the live ledger</a> · <a href="/contract">Read the contract review</a></p>
|
||||
</div>
|
||||
</section>
|
||||
<script src="/assets/common.js?v=20260906m"></script>
|
||||
<script src="/assets/common.js?v=20260907m"></script>
|
||||
<script src="/assets/tx.js?v=20260906m"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script src="/assets/common.js?v=20260906m"></script>
|
||||
<script src="/assets/common.js?v=20260907m"></script>
|
||||
<script src="/assets/wall.js?v=20260906m"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user