case "bgImage":
const imagePaths = getImagePathsFromDirectory('images\\');
let currentImageIndex = 0;
document.body.style.backgroundImage = `url('${imagePaths[currentImageIndex].replace(/\\/g, "/")}')`;
setInterval(function() {
currentImageIndex = (currentImageIndex + 1) % imagePaths.length;
document.body.style.backgroundImage = `url('${imagePaths[currentImageIndex].replace(/\\/g, "/")}}')`;
}, 3 * 60 * 1000);
break`
function getImagePathsFromDirectory(directoryPath) {
const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif'];
const imagePaths = [];
const directoryReader = new FileReader();
directoryReader.readAsArrayBuffer(new Blob([directoryPath], { type: "text/plain" }));
directoryReader.onloadend = function() {
const entries = directoryReader.result;
for (let i = 0; i < entries.length; i++) {
const entry = entries[i];
const fileExtension = entry.name.split('.').pop().toLowerCase();
if (imageExtensions.includes('.' + fileExtension)) {
imagePaths.push(entry.fullPath);
}
}
};
return imagePaths;
}
I try to allow the background img to change every 3 min but fail
pls send feed back on my errors so i can improve