Difference between revisions of "MediaWiki:Common.js"

m
m
Line 11: Line 11:
 
function currentDiv(n) {
 
function currentDiv(n) {
 
   showDivs(slideIndex = n);
 
   showDivs(slideIndex = n);
}
 
 
function stopVideos() {
 
var videos = document.querySelectorAll('iframe, video');
 
Array.prototype.forEach.call(videos, function (video) {
 
if (video.tagName.toLowerCase() === 'video') {
 
video.pause();
 
} else {
 
var src = video.src;
 
video.src = src;
 
}
 
});
 
 
}
 
}
  
 
function showDivs(n) {
 
function showDivs(n) {
  stopVideos();
 
 
   var i;
 
   var i;
 
   var x = document.getElementsByClassName("vslide");
 
   var x = document.getElementsByClassName("vslide");

Revision as of 12:38, 26 July 2023

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


var slideIndex = 1;
showDivs(slideIndex);

function plusDivs(n) {
  showDivs(slideIndex += n);
}

function currentDiv(n) {
  showDivs(slideIndex = n);
}

function showDivs(n) {
  var i;
  var x = document.getElementsByClassName("vslide");
  var dots = document.getElementsByClassName("vscap");
  if (n > x.length) {slideIndex = 1}    
  if (n < 1) {slideIndex = x.length}
  for (i = 0; i < x.length; i++) {
    x[i].style.display = "none";
  }
  for (i = 0; i < dots.length; i++) {
    dots[i].className = dots[i].className.replace(" btn-special", "");
  }
  x[slideIndex-1].style.display = "block";  
  dots[slideIndex-1].className += " btn-special";
}