Lets look at the sample source files: HTML File |
Script File |
Description File
A completely functional gallery HTML page can be as
simple as this:
or even this:
Now lets break that up into it's components. First up we have the settings. I put the settings in the HTML file so you can use the same script for multiple galleries and have different settings for each one.
This gets updated and placed into the head area of the HTML file:
You don't have to have all the comments in the settings, you can reduce them like so:
We reference the file that controls the images being displayed next. Copy this line to the head area of the HTML file, then update the "src=" to where you placed the simple.js file on your server. You can rename the file if you want, it won't cause any problems.
If you have Descriptions generated and turned on in the options, we can now reference the file that contains those. Copy this line to the head area of the HTML file, then update the "src=" to where you placed the file containing the descriptions. If you don't want descriptions, don't bother to include this file.
I put the descriptions in a seperate file so it doesn't get downloaded completely each and every time a new image is loaded. This would mostly benefit larger galleries with long descriptions.
We need to update the image when the page loads, so we make sure the body tag has an onload parameter on it like so:
Navigation links. You can customize these as you wish.
The script works by adding the number you specify to the current image number, then displays that image number. If the number is not within the valid range, it loops back to the beginning or end of the valid range. That is why I have the "first" link setup like it is, 999999 is larger than the valid range, so it loops back to the first image in the range. The "last" link is just the reverse of the "first" link.
Image numbers. This is a placeholder div the script uses to display the image numbers if you have them enabled in the settings. This div doesn't need to be included if you have the image numbers disabled. The ID needs to match the ID in the settings, and the ID must be unique for the entire HTML file.
The basic output is similar to "1 of 22"
Placeholder image. This is a 1x1px transparant image that acts as a placeholder. The script updates the source of the image depending on which image you are currently asking it to load. I also put a link around the image so you can just click on it to go to the next one.
Download the transparant image
here. (Right click and save as.)
Description. This is a placeholder div the script uses to display the image description if you have them generated and enabled in the settings. This div doesn't need to be included if you have the descriptions disabled. The ID needs to match the ID in the settings, and the ID must be unique for the entire HTML file.
Lets look at the sample source files:
HTML File | Script File |
Description File
This is the javascript file that controls the image gallery.
You can download this file
here. (Right click and save as.)
I have added comments below to help explain what the script is doing:
Lets look at the sample source files:
HTML File |
Script File | Description File
This is pretty self explanatory, you declare an array and incriment the number. The number must be equal to the number of the image the description is for. If there are images you don't want to have any descriptions, you can leave the variable empty like d[10] through d[15]. if you don't make an empty variable here, the description for the image will read "undefined" instead of nothing.
This file is not necessary to generate if you have the descriptions disabled in the settings.