Sindbad~EG File Manager
// let graphPaperIndex = 0; // obsolete:
// Now it's initialized by the Engine, which emits Javascript from sendGraphDocument to initialize it to the current graph paper of graphs[0]
const maxGraphPaperIndex = 22;
const minGraphPaperIndex = 0;
// Store references to all the SVG elements in an object (or you can initialize them when needed)
const svgElements = {};
for (let i = 0; i <= maxGraphPaperIndex; i++) {
const id = `sample${i}`;
svgElements[id] = document.getElementById(id);
}
function updateGraphPaperDisplay() {
const newID = `sample${graphPaperIndex}`;
const graphPaperDisplay = document.getElementById('graphPaperDisplay');
// Hide all child elements of 'graphPaperDisplay' to ensure only the current one is shown.
Array.from(graphPaperDisplay.children).forEach(child => {
child.style.display = "none";
});
const newChild = document.getElementById(newID);
if (newChild) {
// Make the new element visible.
newChild.style.display = "block";
}
}
function changeGraphPaperIndex(increment) {
// Change the graphPaperIndex, ensuring it stays within bounds
graphPaperIndex = Math.max(minGraphPaperIndex, Math.min(maxGraphPaperIndex, graphPaperIndex + increment));
updateGraphPaperDisplay();
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists