Campaign scheduling (start/end, solo send-from), scheduled NAS push + end sweep, views-by-hour chart
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+29
-5
@@ -614,13 +614,13 @@
|
||||
tbl.className = 'tablewrap';
|
||||
tbl.innerHTML = '<table><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions delivered by Network Ad Space across the wider network (banner and text ads only)">Network views</th><th class="num">Clicks</th>'
|
||||
+ '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>'
|
||||
+ r.campaigns.map(c => '<tr><td><b>' + c.name + '</b></td>'
|
||||
+ '<td>' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + '</td>'
|
||||
+ r.campaigns.map(c => '<tr><td><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + '</td>'
|
||||
+ '<td>' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + schedChips(c) + '</td>'
|
||||
+ '<td class="num">' + c.imps.toLocaleString() + '</td>'
|
||||
+ '<td class="num">' + (['banner', 'text'].includes(c.type) ? (c.impsNas || 0).toLocaleString() : '<span class="muted small" title="only banner and text ads syndicate to the network">n/a</span>') + '</td>'
|
||||
+ '<td class="num">' + c.clicks + (r.clickSources && r.clickSources[c.id] ? '<div class="muted small" style="white-space:nowrap" title="where the clicks happened">' + Object.entries(r.clickSources[c.id]).sort((a, b) => b[1] - a[1]).map(([k, v]) => esc(k) + ' ' + v).join(' · ') + (c.impsNas ? ' · network: see Network views' : '') + '</div>' : '') + '</td>'
|
||||
+ '<td class="num">' + c.spent + '</td><td class="num">' + c.budget + '</td>'
|
||||
+ '<td>' + (c.status === 'out' ? '<span class="badge amber">budget spent</span>' : c.status) + '</td>'
|
||||
+ '<td>' + (c.status === 'out' ? '<span class="badge amber">budget spent</span>' : c.status === 'done' ? '<span class="muted">ended</span>' : c.scheduled ? '<span class="badge">scheduled</span>' : c.status) + '</td>'
|
||||
+ '<td>' + (c.status === 'active' ? '<button class="btn small sec" data-camp="' + c.id + '" data-act="pause">Pause</button>'
|
||||
: c.status === 'paused' ? '<button class="btn small sec" data-camp="' + c.id + '" data-act="resume">Resume</button>' : '')
|
||||
+ ' <button class="btn small sec" data-topup="' + c.id + '">Buy more views</button>'
|
||||
@@ -712,6 +712,8 @@
|
||||
$('cVideoRow').hidden = t !== 'video';
|
||||
$('cFeaturedRow').hidden = t !== 'featured';
|
||||
$('cVisitsRow').hidden = t !== 'visits';
|
||||
if ($('cSchedRow')) { $('cSchedRow').hidden = t === 'featured'; $('cStartLbl').textContent = t === 'solo' ? 'Send from (optional)' : 'Start (optional)';
|
||||
$('cSchedHint').textContent = t === 'solo' ? 'Deliveries to member inboxes begin at the time you pick, so you can land when people are reading. Leave empty to start now.' : 'Leave both empty to start now and run until the budget is spent. Times are your local time. Anything left when a campaign ends goes back to Available.'; }
|
||||
// fixed-cost types derive their spend (featured = day slots, visits = flat pack),
|
||||
// so hide the free-form Budget field for them to avoid confusion
|
||||
$('cBudgetRow').hidden = (t === 'featured' || t === 'visits');
|
||||
@@ -810,12 +812,15 @@
|
||||
days: Number($('cFeatDays').value), startDay: featStartDay,
|
||||
count: Number($('cVisitCount').value),
|
||||
dailyCap: ($('cDailyCap') && (t === 'banner' || t === 'text')) ? Number($('cDailyCap').value) || 0 : 0,
|
||||
startsAt: ($('cStartAt') && $('cStartAt').value && !isFeat) ? new Date($('cStartAt').value).getTime() : 0,
|
||||
endsAt: ($('cEndAt') && $('cEndAt').value && !isFeat) ? new Date($('cEndAt').value).getTime() : 0,
|
||||
ctaLabel: isVideo ? $('cVideoCta').value : $('cCtaLabel').value,
|
||||
budget: isFeat ? (Number($('cFeatDays').value) * (lastRates.featuredPerDay || 40)) : t === 'visits' ? (Number($('cVisitCount').value) * (lastRates.visitCostPerVisit || 3)) : Number($('cBudget').value) });
|
||||
IAP.status('Campaign is live. It starts serving right away.', 'ok');
|
||||
const schedStart = ($('cStartAt') && $('cStartAt').value && !isFeat) ? new Date($('cStartAt').value) : null;
|
||||
IAP.status(schedStart && schedStart.getTime() > Date.now() ? 'Campaign saved. It starts serving ' + schedStart.toLocaleString([], { dateStyle: 'medium', timeStyle: 'short' }) + '.' : 'Campaign is live. It starts serving right away.', 'ok');
|
||||
// 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', 'cDailyCap']
|
||||
'cVideoUrl', 'cVideoTitle', 'cVideoCta', 'cVisitTitle', 'cVisitCount', 'cFeatTitle', 'cDailyCap', 'cStartAt', 'cEndAt']
|
||||
.forEach(id => { if ($(id)) $(id).value = ''; });
|
||||
$('cSoloEd').innerHTML = ''; if ($('cSoloRaw')) $('cSoloRaw').value = '';
|
||||
$('cVideoInfo').textContent = ''; $('cVideoPrev').hidden = true; $('cVideoPrev').innerHTML = '';
|
||||
@@ -1016,6 +1021,25 @@
|
||||
}));
|
||||
} catch (e) {}
|
||||
}
|
||||
// schedule chips on the campaign table (local time) + by-hour view bars
|
||||
const fmtWhen = ms => new Date(ms).toLocaleString([], { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' });
|
||||
function schedChips(c) {
|
||||
const now = Date.now(); let s = '';
|
||||
if (c.starts && c.starts > now) s += ' <span class="muted small">starts ' + fmtWhen(c.starts) + '</span>';
|
||||
if (c.expires && c.type !== 'featured') s += ' <span class="muted small">' + (c.expires > now ? 'ends ' : 'ended ') + fmtWhen(c.expires) + '</span>';
|
||||
return s;
|
||||
}
|
||||
function hourBars(utc) {
|
||||
if (!utc || !utc.some(n => n)) return '';
|
||||
// rotate the 24 UTC buckets into the viewer's local hours
|
||||
const local = new Array(24).fill(0);
|
||||
for (let h = 0; h < 24; h++) local[new Date(Date.UTC(2000, 0, 1, h)).getHours()] += utc[h];
|
||||
const max = Math.max(...local);
|
||||
const lab = h => (h % 12 || 12) + (h < 12 ? 'am' : 'pm');
|
||||
return '<div class="hbars" title="on-site views by hour of day, your local time, last 7 days">' + local.map((n, h) =>
|
||||
'<i style="height:' + Math.max(2, Math.round(n / max * 18)) + 'px" title="' + lab(h) + ': ' + n + '"></i>').join('')
|
||||
+ '</div><div class="muted small" style="font-size:10px">views by hour · last 7 days · your time</div>';
|
||||
}
|
||||
// ── link stats: views, joins, buyers per angle ──
|
||||
async function loadLinkStats() {
|
||||
try {
|
||||
|
||||
@@ -629,6 +629,9 @@ img{max-width:100%}
|
||||
.promo-strip{display:flex;justify-content:space-between;align-items:center;gap:14px;flex-wrap:wrap;padding:16px 20px}
|
||||
.angle-list{display:flex;flex-direction:column;gap:8px}
|
||||
.hp-field{position:absolute;left:-9999px;top:auto;width:1px;height:1px;opacity:0;overflow:hidden}
|
||||
.hbars{display:flex;align-items:flex-end;gap:2px;height:20px;margin-top:6px;width:120px}
|
||||
.hbars i{flex:1 1 0;background:var(--mint);opacity:.75;border-radius:1px 1px 0 0;min-width:2px}
|
||||
.hbars i:hover{opacity:1}
|
||||
.icon-check{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 12px}
|
||||
.icon-check .ic-btn{font-size:26px;line-height:1;padding:10px 14px;border-radius:12px;border:1px solid var(--line-strong);background:var(--panel);cursor:pointer}
|
||||
.icon-check .ic-btn:hover{border-color:var(--mint)}
|
||||
|
||||
+9
-2
@@ -5,7 +5,7 @@
|
||||
<title>Member area | InstantAdPay</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260911b">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260911c">
|
||||
</head>
|
||||
<body class="bo-body">
|
||||
|
||||
@@ -438,6 +438,13 @@
|
||||
<p id="cBudgetRow"><input id="cBudget" type="number" placeholder="Budget (credits)" min="10" style="width:100%"></p>
|
||||
<p id="cCapRow" style="grid-column:1/-1"><input id="cDailyCap" type="number" placeholder="Daily cap in credits (optional) — paces the budget across days" min="10" style="width:100%">
|
||||
<span class="small muted">Network Ad Space can deliver a lot of impressions fast. A daily cap spreads a banner or text budget over days instead of hours.</span></p>
|
||||
<div id="cSchedRow" style="grid-column:1/-1">
|
||||
<div style="display:flex;gap:10px;flex-wrap:wrap">
|
||||
<label class="small muted" style="flex:1 1 200px;display:block"><span id="cStartLbl">Start (optional)</span><input id="cStartAt" type="datetime-local" style="width:100%;margin-top:4px"></label>
|
||||
<label class="small muted" style="flex:1 1 200px;display:block">End (optional)<input id="cEndAt" type="datetime-local" style="width:100%;margin-top:4px"></label>
|
||||
</div>
|
||||
<span class="small muted" id="cSchedHint">Leave both empty to start now and run until the budget is spent. Times are your local time. Anything left when a campaign ends goes back to Available.</span>
|
||||
</div>
|
||||
</div>
|
||||
<p><input id="cTarget" placeholder="Target URL (https://…)" autocomplete="off" style="width:100%"></p>
|
||||
<p class="small muted" style="margin-top:-6px">Banner and text targets are shown full screen in the
|
||||
@@ -884,7 +891,7 @@
|
||||
<script src="/assets/common.js?v=20260911a"></script>
|
||||
<script src="/assets/wallet.js?v=20260910a"></script>
|
||||
<script src="/assets/promo.js?v=20260911a"></script>
|
||||
<script src="/assets/my.js?v=20260911a"></script>
|
||||
<script src="/assets/my.js?v=20260911b"></script>
|
||||
<script src="/assets/chat.js?v=20260907l"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user