Skip to content

Commit

Permalink
added shuffle on reload to the featured bar
Browse files Browse the repository at this point in the history
  • Loading branch information
BobHasNoSoul authored Nov 4, 2023
1 parent 0b4eeb4 commit 9c0112d
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,54 @@ done

# Close the HTML file and add JavaScript for automatic slideshow
cat <<EOL >> slideshow.html
<script>
<script>
// Function to shuffle an array
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
var slides = document.querySelectorAll(".slide");
var shuffledIndexes = Array.from({ length: slides.length }, (_, i) => i);
// Shuffle the indexes
shuffleArray(shuffledIndexes);
var currentSlide = 0;
function showSlide(index) {
for (var i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slides[shuffledIndexes[index]].style.display = "block";
countdown = 10; // Reset countdown for each slide
}
function nextSlide() {
currentSlide = (currentSlide + 1) % slides.length;
showSlide(currentSlide);
}
showSlide(currentSlide);
// Initial call for the first slide
var countdown = 10;
var timer = document.querySelector(".timer");
timer.innerHTML = countdown;
function updateTimer() {
countdown--;
timer.innerHTML = countdown;
if (countdown <= 0) {
nextSlide();
}
}
// Timer for slide transition
setInterval(updateTimer, 1000);
function reloadParent(url) {
// Change the parent window's location to the specified URL
top.location.href = url;
Expand Down

0 comments on commit 9c0112d

Please sign in to comment.