spidey / index.html
imspidey's picture
Update index.html
64e242a
<!DOCTYPE html>
<html>
<head>
<title>Image Index</title>
</head>
<body>
<h1>Image Index</h1>
<div id="image-container"></div>
<script>
// Get a reference to the image container
const imageContainer = document.getElementById("image-container");
// Replace "path/to/your/images" with the actual path to your image folder on the server
const imagePath = "images/";
// List of image file extensions to consider
const imageExtensions = ["jpg", "jpeg", "png", "gif"];
// Function to create image elements and add them to the container
function displayImages() {
fetch(imagePath)
.then(response => response.text())
.then(text => {
const parser = new DOMParser();
const doc = parser.parseFromString(text, "text/html");
const links = doc.querySelectorAll("a");
links.forEach(link => {
const href = link.getAttribute("href");
const extension = href.split('.').pop().toLowerCase();
if (imageExtensions.includes(extension)) {
const img = document.createElement("img");
img.src = imagePath + href;
img.alt = href;
imageContainer.appendChild(img);
}
});
});
}
// Call the function to display images
displayImages();
</script>
</body>
</html>