window.addEventListener('load', slideShow, false);
function slideShow() {
/* GLOBALS **********************************************************************************************/
var globals = {
slideDelay: 4000, // The time interval between consecutive slides.
fadeDelay: 35, // The time interval between individual opacity changes. This should always be much smaller than slideDelay.
wrapperID: "second", // The ID of the <div> element that contains all of the <img> elements to be shown as a slide show.
buttonID: "slideShowButton", // The ID of the <button> element that toggles the slide show on and off.
buttonStartText: "Start Slides", // Text used in the slide show toggle button.
buttonStopText: "Stop Slides", // Text used in the slide show toggle button.
wrapperObject: null, // Will contain a reference to the <div> element that contains all of the <img> elements to be shown as a slide show.
buttonObject: null, // If present, will contain a reference to the <button> element that toggles the slide show on and off. The initial assumption is that there is no such button element (hence the false value).
slideImages: [], // Will contain all of the slide image objects.
slideShowID: null, // A setInterval() ID value used to stop the slide show.
slideShowRunning: true, // Used to record when the slide show is running and when it's not. The slide show is always initially running.
slideIndex: 0 // The index of the current slide image.
}
/* MAIN *************************************************************************************************/
initializeGlobals();
if (insufficientSlideShowMarkup()) {
return; // Insufficient slide show markup - exit now.
}
// Assert: there's at least one slide image.
if (globals.slideImages.length == 1) {
return; // The solo slide image is already being displayed - exit now.
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.