MediaWiki:Common.js

MediaWiki interface page
Revision as of 13:52, 31 January 2024 by Jan.vales (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* 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