better query for donation product

This commit is contained in:
Seth Trowbridge 2025-10-31 10:09:42 -04:00
parent 7a6e916a86
commit 5e70327bd3

View File

@ -15,18 +15,16 @@ const Render=()=>
{ {
if(location.pathname === `/store/category/gifts/`) // if we are on the store category for the gifts page, add this tweak css and *keep going* if(location.pathname === `/store/category/gifts/`) // if we are on the store category for the gifts page, add this tweak css and *keep going*
{ {
mainNav.insertAdjacentHTML("afterend", `<style> mainNav.insertAdjacentHTML("afterend", `
<style>
.cards.cards-default .row .cards.cards-default .row
{ {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
.default-product .default-product
{ {
float: none; float: none;
width: 33%; width: 80%;
width:80%;
@media(min-width:625px) @media(min-width:625px)
{ {
width:50%; width:50%;
@ -35,30 +33,23 @@ const Render=()=>
{ {
width:33%; width:33%;
} }
box-sizing: border-box; box-sizing: border-box;
padding:0 1% 0 0; padding: 0 1% 0 0;
} }
} }
.card .card
{ {
.card-inner .card-inner
{ {
padding: 0; padding: 0;
.store-photo-wrapper .store-photo-wrapper
{ {
margin: 0; margin: 0;
} }
.store-description-wrapper .store-description-wrapper
{ {
padding: 1rem; padding: 1rem;
} }
& img & img
{ {
position: relative; position: relative;
@ -67,7 +58,6 @@ const Render=()=>
height: auto; height: auto;
max-height: unset; max-height: unset;
margin: 0; margin: 0;
@media(min-width:768px) @media(min-width:768px)
{ {
object-fit: cover; object-fit: cover;
@ -92,21 +82,25 @@ const mentionDonation =(imageURL)=>
const cacheName =()=> const cacheName =()=>
{ {
return fetch("/donate/").then(r=>r.text()).then(t=>{ return fetch("/donate/?_pjax=%23site-wrapper", {credentials:"omit", headers:{"x-pjax":"true"}}).then(r=>r.text()).then(t=>{
partStart = `<h3 class=look-inside-description_title>`; partStart = `<h3 class=look-inside-description_title>`;
partStop = `</h3>`; partStop = `</h3>`;
posStart = t.indexOf(partStart)+partStart.length; posStart = t.indexOf(partStart)+partStart.length;
posStop = t.indexOf(partStop, posStart); posStop = t.indexOf(partStop, posStart);
console.log(posStart, posStop);
const imageURL = t.substring(posStart, posStop); const imageURL = t.substring(posStart, posStop);
console.log("found donate image:", imageURL);
localStorage.setItem("ye-2025-product", JSON.stringify({name:imageURL, date:NOW.getTime()})) localStorage.setItem("ye-2025-product", JSON.stringify({name:imageURL, date:NOW.getTime()}))
return imageURL; return imageURL;
}); });
} }
let lookup = localStorage.getItem("ye-2025-product"); const lookup = localStorage.getItem("ye-2025-product");
if(!lookup) if(!lookup)
{ {
//console.log("fresh cache of name") console.log("fresh cache of name");
cacheName().then(mentionDonation); cacheName().then(mentionDonation);
} }
else else
@ -116,12 +110,12 @@ else
const elapsed = Math.abs(THEN - NOW); const elapsed = Math.abs(THEN - NOW);
if( elapsed > 2 * 60 * 60 * 1000) if( elapsed > 2 * 60 * 60 * 1000)
{ {
//console.log("cache stale, re-fetching name") console.log("cache stale, re-fetching name");
cacheName().then(mentionDonation); cacheName().then(mentionDonation);
} }
else else
{ {
//console.log("using cached name") console.log("using cached name");
mentionDonation(name); mentionDonation(name);
} }
} }