1
1
Fork 0
This repository has been archived on 2024-01-04. You can view files and clone it, but cannot push or open issues or pull requests.
blueheartforever-web/js/memories.js

31 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-10-28 18:03:39 -05:00
// I don't know if this will work, but we can try..... -fs64
// https://codingartistweb.com/2022/06/testimonial-slider-using-javascript/ heavily modified from this -64
console.info("Loading memories.js...");
let memories = "../conf/memories.json" // File containing the memories
let cm = 0; // (C)urrent (m)emory
let l = memories.length; // Total file length
console.info(`Found ${l} memory keys!`);
let memoriesBox = document.getElementById("memoriesBox");
let nxtBtn = document.getElementById("next");
let bckBtn = document.getElementById("prev");
// Get our memeoriesBox and buttons from HTML elements on the HTML page
nxtBtn.addEventListener("click", () => {
cm = (l + cm + 1) % l;
displayMemory();
}); // Switch to the next memory
nxtBtn.addEventListener("click", () => {
cm = (l + cm - 1) % l;
displayMemory();
}); // Switch back to the previous memory, nopony tell anyone else that we copied this :^) -64
let displayMemory = () => {
displayMemory.innerHTML = `
<h2>${memoriesBox[cm].name}</h2>
<p>${memoriesBox[cm].memory}</p>
`;
};
window.onload = displayMemory;
console.info("Done!");