Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rpared committed Apr 3, 2024
1 parent 8d0be2b commit 813b375
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions script/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,55 @@ fetchData().then(([data, fetchHtml]) => {
footerButtons.forEach((button, index) => {
button.addEventListener("click", () => toggleFooter(index));
});

//PBT PopUp-----------------------------------------------
let hasShownPopup = false;
let pbtPopup = () => {
let pbt = document.createElement("div");

if (language == "eng") {
pbt.innerHTML = `
<div class="pbt-popup-container"><button class="pbt-close-btn">x</button><a href="https://plantbasedtreaty.org/" target="_blanc"><img style="border-radius:16px; box-shadow: 0 0 10px #000" src="images/PBT_PopUp.gif" alt="Sign the Plant Based Treaty"></a></div>
`;
} else if (language == "spa") {
pbt.innerHTML = `
<div class="pbt-popup-container"><button class="pbt-close-btn">x</button><a href="https://plantbasedtreaty.org/" target="_blanc"><img style="border-radius:16px; box-shadow: 0 0 10px #000" src="images/PBT_PopUp_spa.gif" alt="Firma el Plant Based Treaty"></a></div>
`;
}
pbt.classList.add("pbt-popup");

const imgPBT = pbt.querySelector("img");
imgPBT.onload = function () {
if (!hasShownPopup) {
setTimeout(pbtDisplayPopup, 1000);
}
};
function pbtDisplayPopup() {
console.log("popup triggerred");

hasShownPopup = true;
console.log(hasShownPopup);
// Close button functionality
pbt
.querySelector(".pbt-close-btn")
.addEventListener("click", function () {
document.body.removeChild(pbt);
});

// Detect all clicks on the document
document.addEventListener("click", function (event) {
// If user clicks inside the element, do nothing
if (event.target.closest(".pbt-popup-container")) return;
// If user clicks outside the element, hide it!
document.body.removeChild(pbt);
});

document.body.appendChild(pbt); // Append the element to the body
}
};
setTimeout(pbtPopup, 60000);
}

indexStuff();
});
// export { indexStuff };

0 comments on commit 813b375

Please sign in to comment.