MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
No edit summary
No edit summary
Line 12: Line 12:
   });
   });
}
}
const images = document.querySelectorAll('.dpImage');
const mainImage = document.querySelector('.mainImage');
let currentIndex = 0;
function showImage(index) {
  mainImage.innerHTML = images[index].innerHTML;
  images.forEach((image, i) => {
      if (i === index) {
        image.classList.add('selected');
      } else {
        image.classList.remove('selected');
      }
  });
}
function rotateImages() {
  showImage(currentIndex);
  currentIndex = (currentIndex + 1) % images.length;
}
setInterval(rotateImages, 5000); // Change the image every 5 seconds (adjust as needed)
showImage(currentIndex); // Initial display

Revision as of 13:52, 31 January 2024

/* Any JavaScript here will be loaded for all users on every page load. */


var coll = document.getElementsByClassName("collapsible");
var i;

for (i = 0; i < coll.length; i++) {
  coll[i].addEventListener("click", function() {
    this.classList.toggle("active");
    var content = this.nextElementSibling;
    $(content).toggle('fast');
  });
}

const images = document.querySelectorAll('.dpImage');
const mainImage = document.querySelector('.mainImage');
let currentIndex = 0;

function showImage(index) {
   mainImage.innerHTML = images[index].innerHTML;
   images.forEach((image, i) => {
      if (i === index) {
         image.classList.add('selected');
      } else {
         image.classList.remove('selected');
      }
   });
}

function rotateImages() {
   showImage(currentIndex);
   currentIndex = (currentIndex + 1) % images.length;
}

setInterval(rotateImages, 5000); // Change the image every 5 seconds (adjust as needed)
showImage(currentIndex); // Initial display