From cefd4c361f080336b659725a7f4780ccebddd1e7 Mon Sep 17 00:00:00 2001 From: Joshua Laymon Date: Thu, 21 Aug 2025 00:05:10 +0000 Subject: [PATCH] Update web/templates/search.html --- web/templates/search.html | 55 +++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/web/templates/search.html b/web/templates/search.html index e432b12..8eefa2c 100644 --- a/web/templates/search.html +++ b/web/templates/search.html @@ -52,9 +52,8 @@ {% if ran_search and result_count == 0 %}
NO RESULTS
-
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. - -That’s 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.
+ +
Looking for something witty…
{% endif %} @@ -87,12 +86,13 @@ That’s exactly how it feels scrolling through a list of illustrations—you kn - -
-

Illustration of the Day

-
-

Loading…

- + +
+

Illustration of the Day

+
+

Loading…

+ +
@@ -241,7 +241,31 @@ That’s 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. You’re 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 weren’t looking.`, + `It’s 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.`, + `It’s like looking for a matching sock. You find five that are “close enough,” but never the one you actually need.`, + `It’s 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 you’re late. You check the counter, pockets, and finally… the fridge. Next to the milk.`, + `It’s like walking around the house holding your phone in the air, trying to catch a Wi‑Fi signal that appears and vanishes at random.`, + `Imagine a giant library where you’re sure the book is “right here.” You scan up, down, left, right—then realize you’re in the wrong aisle.`, + `It’s like following GPS: “Turn left now!” You miss it, circle the block, and the voice keeps politely “recalculating.”`, + `It’s like trying to find an umbrella on a sunny day—no luck. The moment it pours, suddenly you own five.`, + `It’s 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 @@ That’s exactly how it feels scrolling through a list of illustrations—you kn } const seed = xorshift32(ymd ^ 0x9E3779B9); - // We don’t know ID gaps, so try a deterministic pseudo‑random - // 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 @@ That’s 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 @@ That’s 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 @@ That’s 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 today’s illustration.'; iotdOpenEl.style.display = 'none'; })();