MediaWiki:TextSlideShow/code.js

// Author: Charles Terry // Company: JCPM Industries // Email: ct.jcpm@gmail.com /*jslint browser:true, this:true */ /*global $

// Get All slideshows on the page var slideshows = document.getElementsByClassName("WikiPlus-Slideshow");

// Convert HTML collection into an Array var listHold = []; slideshows = listHold.slice.call(slideshows);

// Code applied to each slideshow on the page var num = 0; slideshows.forEach(function {    "use strict";    // Get Slideshow Time    var time = slideshows[num].className.split("-")[4];

// Get each individual slide var quotearray = slideshows[num].getElementsByTagName("P");

// Convert HTML collection into an Array var slideHold = []; quotearray = slideHold.slice.call(quotearray);

// Get Quotes var quotes = []; var quotenum = 0; quotearray.forEach(function {        var thisquote = quotearray[quotenum].innerHTML;        quotes.push(thisquote);        quotenum += 1;    });

//Show default slide var id = slideshows[num]; $(id).html(quotes[0]);

// Cycle between slides var i = 1; setInterval(function {        $(id).html(quotes[i]);        if (i === quotes.length - 1) {            i = 0;        } else {            i += 1;        }    }, time * 1000);

num += 1; });