Update web/templates/search.html

This commit is contained in:
Joshua Laymon 2025-08-21 00:05:10 +00:00
parent 7158d0ab5f
commit cefd4c361f

View File

@ -52,9 +52,8 @@
{% if ran_search and result_count == 0 %}
<div class="empty-state">
<div class="empty-title">NO RESULTS</div>
<div class="empty-subtitle">Looking for the right illustration can feel a lot like standing in front of your fridge at midnight. You open the door, expecting to see something amazing—leftover pizza, a slice of cake, maybe even some ice cream. Instead, you just stare at a jar of pickles, an old bag of shredded cheese, and half a bottle of ketchup. You close the door, sigh, then open it again five seconds later, hoping something new has magically appeared.
Thats exactly how it feels scrolling through a list of illustrations—you know something tasty has to be in there somewhere, but all you can find are pickles.</div>
<!-- Placeholder text; JS below will replace this with a random funny line -->
<div class="empty-subtitle">Looking for something witty…</div>
</div>
{% endif %}
@ -87,12 +86,13 @@ Thats exactly how it feels scrolling through a list of illustrations—you kn
</div>
</div>
<!-- ===== Illustration of the Day ===== -->
<div class="card" style="padding:0; margin:16px 0 12px;">
<h1 class="page-title iotd-title">Illustration of the Day</h1>
<div id="iotd-box" class="iotd-panel">
<p id="iotd-text" style="margin:0 0 12px;">Loading…</p>
<a id="iotd-open" href="#" class="btn btn-primary" style="display:none;">Open Illustration</a>
<!-- ===== Illustration of the Day ===== -->
<div class="card" style="padding:0; margin:16px 0 12px;">
<h1 class="page-title iotd-title">Illustration of the Day</h1>
<div id="iotd-box" class="iotd-panel">
<p id="iotd-text" style="margin:0 0 12px;">Loading…</p>
<a id="iotd-open" href="#" class="btn btn-primary" style="display:none;">Open Illustration</a>
</div>
</div>
</div>
@ -241,7 +241,31 @@ Thats exactly how it feels scrolling through a list of illustrations—you kn
}
});
/* ===============================
// ===============================
// No-results: show a random funny illustration
// ===============================
(function showRandomNoResults(){
const el = document.querySelector('.empty-state .empty-subtitle');
if (!el) return;
const messages = [
`Searching for an illustration is like opening the fridge at midnight. Youre hoping for cheesecake, but all you find is half a tomato and some wilted lettuce. You close the door, then open it again—because maybe cheesecake grew in there while you werent looking.`,
`Its like hunting for the TV remote. You check the couch, the floor, the freezer (why?)—then realize it was in your hand the whole time.`,
`Its like looking for a matching sock. You find five that are “close enough,” but never the one you actually need.`,
`Its like running into the store for peanut butter. You leave with bread, bananas, cereal, and gum—somehow no peanut butter.`,
`It feels like searching for your car keys when youre late. You check the counter, pockets, and finally… the fridge. Next to the milk.`,
`Its like walking around the house holding your phone in the air, trying to catch a WiFi signal that appears and vanishes at random.`,
`Imagine a giant library where youre sure the book is “right here.” You scan up, down, left, right—then realize youre in the wrong aisle.`,
`Its like following GPS: “Turn left now!” You miss it, circle the block, and the voice keeps politely “recalculating.”`,
`Its like trying to find an umbrella on a sunny day—no luck. The moment it pours, suddenly you own five.`,
`Its like a jigsaw with one missing piece. You check under the table, the box, even the dog—then find the piece stuck to your elbow.`
];
const pick = messages[Math.floor(Math.random() * messages.length)];
el.textContent = pick;
})();
/* ===============================
Illustration of the Day (client-only, deterministic)
=============================== */
(function illustrationOfTheDay(){
@ -268,14 +292,10 @@ Thats exactly how it feels scrolling through a list of illustrations—you kn
}
const seed = xorshift32(ymd ^ 0x9E3779B9);
// We dont know ID gaps, so try a deterministic pseudorandom
// permutation over a *generous* range and stop at the first 200.
const maxGuess = Math.max(100, Math.floor(total * 4)); // cast a wide net
const maxAttempts = Math.min(600, maxGuess); // cap network work
const maxGuess = Math.max(100, Math.floor(total * 4));
const maxAttempts = Math.min(600, maxGuess);
// Linear congruential generator style “index -> id” mapping (deterministic)
function idAt(i){
// multiplier is odd; modulus is implicit 2^32, then map to [1..maxGuess]
const v = (Math.imul(i + 1, 1103515245) + 12345 + seed) >>> 0;
return 1 + (v % maxGuess);
}
@ -296,7 +316,6 @@ Thats exactly how it feels scrolling through a list of illustrations—you kn
}
function extractSectionText(doc, label){
// Look for label “Illustration” / “Application” commonly used in your templates
const labels = doc.querySelectorAll('.section-label, .meta-label, h3, h4, strong');
for (const el of labels){
const t = (el.textContent || '').trim().toLowerCase();
@ -310,7 +329,6 @@ Thats exactly how it feels scrolling through a list of illustrations—you kn
}
}
}
// fallback
const alt = doc.querySelector('.lead-text, .section-body');
return alt ? (alt.textContent || '').trim() : '';
}
@ -335,7 +353,6 @@ Thats exactly how it feels scrolling through a list of illustrations—you kn
return;
}
}
// If nothing responded 200 within our attempts, fail gracefully
iotdTextEl.textContent = 'Unable to load todays illustration.';
iotdOpenEl.style.display = 'none';
})();