mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-24 21:55:52 +00:00
113 lines
4.3 KiB
JavaScript
113 lines
4.3 KiB
JavaScript
$(document).ready(() => {
|
|
// Add two new constiables for arrow buttons
|
|
const leftArrow = document.getElementById("leftArrow");
|
|
const rightArrow = document.getElementById("rightArrow");
|
|
// Handle arrow button clicks
|
|
function handleArrowClick(direction) {
|
|
// Get the current data index
|
|
const currentIndex = parseInt(modal.getAttribute("data-index"));
|
|
|
|
// Calculate the new index based on the direction
|
|
const newIndex = direction === "left" ? currentIndex - 1 : currentIndex + 1;
|
|
|
|
// Update the modal content with the new data
|
|
updateModalContent(useCaseData[newIndex]);
|
|
|
|
// Update the modal's data-index attribute
|
|
modal.setAttribute("data-index", newIndex);
|
|
|
|
// Show or hide the arrow buttons based on the new index
|
|
leftArrow.style.display = newIndex === 0 ? "none" : "block";
|
|
rightArrow.style.display =
|
|
newIndex === useCaseData.length - 1 ? "none" : "block";
|
|
}
|
|
|
|
// Add click event listeners for arrow buttons
|
|
leftArrow.addEventListener("click", () => handleArrowClick("left"));
|
|
rightArrow.addEventListener("click", () => handleArrowClick("right"));
|
|
const modal = document.getElementById("myModal");
|
|
const openModalBtns = document.querySelectorAll("li.open-modal");
|
|
const useCaseData = [];
|
|
|
|
// Populate the useCaseData array with data from the li elements
|
|
openModalBtns.forEach(function (btn) {
|
|
const id = btn.getAttribute("data-id");
|
|
const title = btn.getAttribute("data-title");
|
|
const description = btn.getAttribute("data-description");
|
|
const number = btn.getAttribute("data-number");
|
|
const src = btn.getAttribute("data-src");
|
|
|
|
useCaseData.push({ id, title, number, src, description });
|
|
});
|
|
|
|
// Get the elements in the modal that will be updated
|
|
const modalImage = document.querySelector(".modal .section-image");
|
|
const modalTextDescription = document.querySelector(
|
|
".modal .section-text-description"
|
|
);
|
|
const modalTextTitle = document.querySelector(".modal .section-text-title");
|
|
const modalLogos = document.querySelector(".modal .section-logos");
|
|
// Add a function to update the modal content
|
|
function updateModalContent({ id, title, number, src, description, index }) {
|
|
const arrowContainer = document.getElementById("arrows-container");
|
|
modalImage.src = src;
|
|
modalImage.alt = title + " logo";
|
|
modalTextDescription.textContent = description;
|
|
modalTextTitle.textContent = title;
|
|
modalLogos.textContent = "Group of logos for " + title + " here...";
|
|
if (id === "infrastructure") {
|
|
arrowContainer.style.justifyContent = "end";
|
|
} else {
|
|
arrowContainer.style.justifyContent = "space-between";
|
|
}
|
|
}
|
|
openModalBtns.forEach(function (btn, index) {
|
|
btn.onclick = function () {
|
|
const arrowContainer = document.getElementById("arrows-container");
|
|
// Read the data-* attributes from the clicked li
|
|
const id = btn.getAttribute("data-id");
|
|
const title = btn.getAttribute("data-title");
|
|
const description = btn.getAttribute("data-description");
|
|
const number = btn.getAttribute("data-number");
|
|
const src = btn.getAttribute("data-src");
|
|
// Update the modal content with the data from the clicked li
|
|
modalImage.id = id;
|
|
modalImage.alt = title + " logo";
|
|
modalTextDescription.textContent = description;
|
|
modalTextTitle.textContent = title;
|
|
modalLogos.textContent = "Group of logos for " + title + " here...";
|
|
|
|
// Set the data index on the modal
|
|
modal.setAttribute("data-index", index);
|
|
|
|
// Update the modal content with the data from the clicked li
|
|
updateModalContent({ id, title, number, src, description, index });
|
|
|
|
// Show or hide the arrow buttons based on the index
|
|
leftArrow.style.display = index === 0 ? "none" : "block";
|
|
rightArrow.style.display =
|
|
index === useCaseData.length - 1 ? "none" : "block";
|
|
|
|
modal.style.display = "block";
|
|
|
|
if (id === 'infrastructure') {
|
|
arrowContainer.style.justifyContent = "end";
|
|
} else {
|
|
arrowContainer.style.justifyContent = "space-between";
|
|
}
|
|
};
|
|
});
|
|
|
|
window.onclick = function (event) {
|
|
if (event.target == modal) {
|
|
modal.style.display = "none";
|
|
}
|
|
};
|
|
|
|
document.addEventListener("keydown", function (event) {
|
|
if (event.key === "Escape") {
|
|
modal.style.display = "none";
|
|
}
|
|
});
|
|
});
|