better query for donation product
This commit is contained in:
parent
7a6e916a86
commit
5e70327bd3
@ -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*
|
||||
{
|
||||
mainNav.insertAdjacentHTML("afterend", `<style>
|
||||
mainNav.insertAdjacentHTML("afterend", `
|
||||
<style>
|
||||
.cards.cards-default .row
|
||||
{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.default-product
|
||||
{
|
||||
float: none;
|
||||
width: 33%;
|
||||
|
||||
width:80%;
|
||||
width: 80%;
|
||||
@media(min-width:625px)
|
||||
{
|
||||
width:50%;
|
||||
@ -35,30 +33,23 @@ const Render=()=>
|
||||
{
|
||||
width:33%;
|
||||
}
|
||||
|
||||
box-sizing: border-box;
|
||||
padding:0 1% 0 0;
|
||||
padding: 0 1% 0 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
.card
|
||||
{
|
||||
.card-inner
|
||||
{
|
||||
padding: 0;
|
||||
|
||||
.store-photo-wrapper
|
||||
{
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.store-description-wrapper
|
||||
{
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
& img
|
||||
{
|
||||
position: relative;
|
||||
@ -67,7 +58,6 @@ const Render=()=>
|
||||
height: auto;
|
||||
max-height: unset;
|
||||
margin: 0;
|
||||
|
||||
@media(min-width:768px)
|
||||
{
|
||||
object-fit: cover;
|
||||
@ -92,21 +82,25 @@ const mentionDonation =(imageURL)=>
|
||||
|
||||
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>`;
|
||||
partStop = `</h3>`;
|
||||
posStart = t.indexOf(partStart)+partStart.length;
|
||||
posStop = t.indexOf(partStop, posStart);
|
||||
|
||||
|
||||
console.log(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()}))
|
||||
return imageURL;
|
||||
});
|
||||
}
|
||||
|
||||
let lookup = localStorage.getItem("ye-2025-product");
|
||||
const lookup = localStorage.getItem("ye-2025-product");
|
||||
if(!lookup)
|
||||
{
|
||||
//console.log("fresh cache of name")
|
||||
console.log("fresh cache of name");
|
||||
cacheName().then(mentionDonation);
|
||||
}
|
||||
else
|
||||
@ -116,12 +110,12 @@ else
|
||||
const elapsed = Math.abs(THEN - NOW);
|
||||
if( elapsed > 2 * 60 * 60 * 1000)
|
||||
{
|
||||
//console.log("cache stale, re-fetching name")
|
||||
console.log("cache stale, re-fetching name");
|
||||
cacheName().then(mentionDonation);
|
||||
}
|
||||
else
|
||||
{
|
||||
//console.log("using cached name")
|
||||
console.log("using cached name");
|
||||
mentionDonation(name);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user