Update web/templates/search.html
This commit is contained in:
+31
-14
@@ -52,9 +52,8 @@
|
|||||||
{% if ran_search and result_count == 0 %}
|
{% if ran_search and result_count == 0 %}
|
||||||
<div class="empty-state">
|
<div class="empty-state">
|
||||||
<div class="empty-title">NO RESULTS</div>
|
<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.
|
<!-- Placeholder text; JS below will replace this with a random funny line -->
|
||||||
|
<div class="empty-subtitle">Looking for something witty…</div>
|
||||||
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.</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -87,13 +86,14 @@ That’s exactly how it feels scrolling through a list of illustrations—you kn
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ===== Illustration of the Day ===== -->
|
<!-- ===== Illustration of the Day ===== -->
|
||||||
<div class="card" style="padding:0; margin:16px 0 12px;">
|
<div class="card" style="padding:0; margin:16px 0 12px;">
|
||||||
<h1 class="page-title iotd-title">Illustration of the Day</h1>
|
<h1 class="page-title iotd-title">Illustration of the Day</h1>
|
||||||
<div id="iotd-box" class="iotd-panel">
|
<div id="iotd-box" class="iotd-panel">
|
||||||
<p id="iotd-text" style="margin:0 0 12px;">Loading…</p>
|
<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>
|
<a id="iotd-open" href="#" class="btn btn-primary" style="display:none;">Open Illustration</a>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -241,6 +241,30 @@ 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)
|
Illustration of the Day (client-only, deterministic)
|
||||||
=============================== */
|
=============================== */
|
||||||
@@ -268,14 +292,10 @@ That’s exactly how it feels scrolling through a list of illustrations—you kn
|
|||||||
}
|
}
|
||||||
const seed = xorshift32(ymd ^ 0x9E3779B9);
|
const seed = xorshift32(ymd ^ 0x9E3779B9);
|
||||||
|
|
||||||
// We don’t know ID gaps, so try a deterministic pseudo‑random
|
const maxGuess = Math.max(100, Math.floor(total * 4));
|
||||||
// permutation over a *generous* range and stop at the first 200.
|
const maxAttempts = Math.min(600, maxGuess);
|
||||||
const maxGuess = Math.max(100, Math.floor(total * 4)); // cast a wide net
|
|
||||||
const maxAttempts = Math.min(600, maxGuess); // cap network work
|
|
||||||
|
|
||||||
// Linear congruential generator style “index -> id” mapping (deterministic)
|
|
||||||
function idAt(i){
|
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;
|
const v = (Math.imul(i + 1, 1103515245) + 12345 + seed) >>> 0;
|
||||||
return 1 + (v % maxGuess);
|
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){
|
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');
|
const labels = doc.querySelectorAll('.section-label, .meta-label, h3, h4, strong');
|
||||||
for (const el of labels){
|
for (const el of labels){
|
||||||
const t = (el.textContent || '').trim().toLowerCase();
|
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');
|
const alt = doc.querySelector('.lead-text, .section-body');
|
||||||
return alt ? (alt.textContent || '').trim() : '';
|
return alt ? (alt.textContent || '').trim() : '';
|
||||||
}
|
}
|
||||||
@@ -335,7 +353,6 @@ That’s exactly how it feels scrolling through a list of illustrations—you kn
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If nothing responded 200 within our attempts, fail gracefully
|
|
||||||
iotdTextEl.textContent = 'Unable to load today’s illustration.';
|
iotdTextEl.textContent = 'Unable to load today’s illustration.';
|
||||||
iotdOpenEl.style.display = 'none';
|
iotdOpenEl.style.display = 'none';
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user