Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions web/public/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1118,13 +1118,12 @@ body.gated .nav-items button:not(#nav-account) {
color: var(--accent);
}
/* CrawlProof ad unit, docked at the top of the sheet (under the nav): zero
height until ad.js fills it, and never on the sign-in / account screens.
Filled only from mountAd() in app.js, the first time a home or settings
sheet opens. */
height until ad.js fills it, and only on the Settings sheet (data-ad).
Created only from mountAd() in app.js, the first time Settings opens. */
.ad-dock {
display: none;
}
#sheet:not([hidden]):not([data-screen="account"]) ~ .ad-dock {
#sheet[data-ad]:not([hidden]) ~ .ad-dock {
position: absolute;
left: 0;
right: 0;
Expand All @@ -1133,7 +1132,7 @@ body.gated .nav-items button:not(#nav-account) {
display: block;
color: var(--text);
}
body.nav-on #sheet:not([hidden]) ~ .ad-dock {
body.nav-on #sheet[data-ad]:not([hidden]) ~ .ad-dock {
top: var(--nav-h);
}
.cp-ad {
Expand All @@ -1147,9 +1146,9 @@ body.nav-on #sheet:not([hidden]) ~ .ad-dock {
.cp-ad[data-cp-filled] {
height: auto;
overflow: visible;
padding: 0.6rem 1rem;
padding: 0.5rem 1rem;
}
#sheet:not([hidden]):not([data-screen="account"]):has(~ .ad-dock .cp-ad[data-cp-filled]) {
#sheet[data-ad]:not([hidden]):has(~ .ad-dock .cp-ad[data-cp-filled]) {
padding-top: 4rem;
}

Expand Down
6 changes: 3 additions & 3 deletions web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
<!-- Setup and settings share one sheet. -->
<section id="sheet" class="sheet" hidden></section>

<!-- CrawlProof ad unit, docked at the top of a home/settings sheet (never in
the footer, never over the picture or on sign-in). -->
<div class="ad-dock"><aside id="cp-ad" class="cp-ad" data-cp-ad></aside></div>
<!-- CrawlProof text-link ad dock, filled by app.js on the Settings sheet only
(never on the home/setup screen, the footer, the picture or sign-in). -->
<div class="ad-dock"></div>

<!-- Footer, shown under the setup/settings sheet, never over the picture. The
server renders @profullstack/footer (copyright + webring) and then the
Expand Down
22 changes: 16 additions & 6 deletions web/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,7 @@ function openSetup(first = true) {
closeAll();
S.mode = 'sheet';
$('sheet').dataset.screen = 'settings';
delete $('sheet').dataset.ad;
syncNav();
const sheet = $('sheet');
sheet.hidden = false;
Expand Down Expand Up @@ -1579,6 +1580,8 @@ function openSettings() {
closeAll();
S.mode = 'sheet';
$('sheet').dataset.screen = 'settings';
// The only screen that carries the ad (never the home/setup screen).
$('sheet').dataset.ad = '1';
syncNav();
const sheet = $('sheet');
sheet.hidden = false;
Expand Down Expand Up @@ -1754,6 +1757,7 @@ function sheet(screen, html) {
S.mode = 'sheet';
const sh = $('sheet');
sh.dataset.screen = screen;
delete sh.dataset.ad;
sh.hidden = false;
sh.innerHTML = `<div class="card">${html}</div>`;
syncNav();
Expand Down Expand Up @@ -2204,18 +2208,24 @@ function navCurrent() {
return 'live';
}

// CrawlProof ad unit in the top-of-sheet ad dock (index.html). The element ships without
// a slot so ad.js's own DOMContentLoaded pass skips it; the first home or
// settings sheet sets the slot and asks ad.js to fill it, once. Bounded retry
// CrawlProof ad unit in the top-of-sheet ad dock (index.html): one low-profile
// text_link line, only on the Settings sheet, never on the home/setup screen.
// The page ships with an empty dock (no ad element in the homepage HTML); the
// first Settings sheet creates the unit and asks ad.js to fill it, once. Bounded retry
// while ad.js is still loading, so a blocker never leaves a timer running.
const AD_SLOT = 'c6fbcad1-a0a7-4bb1-b1af-5eb804047286';
let adMounted = false;
function mountAd() {
const el = $('cp-ad');
if (adMounted || !el) return;
const dock = document.querySelector('.ad-dock');
if (adMounted || !dock) return;
adMounted = true;
const el = document.createElement('aside');
el.id = 'cp-ad';
el.className = 'cp-ad';
el.setAttribute('data-cp-ad', '');
el.dataset.format = 'text_link';
el.dataset.slot = AD_SLOT;
dock.append(el);
let tries = 0;
const scan = () => {
if (window.crawlproofAds?.scan) window.crawlproofAds.scan();
Expand All @@ -2225,7 +2235,7 @@ function mountAd() {
}

function syncNav() {
if (S.mode === 'sheet' && $('sheet').dataset.screen !== 'account') mountAd();
if (S.mode === 'sheet' && $('sheet').dataset.ad) mountAd();
// Over any other view, the channel banner is clutter.
if (S.mode !== 'tv') $('banner').hidden = true;
const on = S.mode !== 'tv' || navPinned || navFocus >= 0;
Expand Down
Loading