Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    7
    Member #
    38270

    Adapting\Javascript\Image Gallery

    Hello everyone !

    Im trying to adapting an image gallery script....

    The below 'show' function is appearing twice but with different names.....because I dont

    know javascript ...I did that.....and it is working as I wish...............

    The only think that I need now is:

    - "That when the page is loaded".....need to show 'imagem-001.jpg' instead of 'imagem-

    000.jpg' !

    Could someone give a hand ?

    The link to see the adapted script is: here

    The .js code is down below:

    ----------------------------
    //GLOBALS

    var nl = "\n"; // new line, for nice code :-)

    var imgFolder = 'imagens_grandes'; //folder with subfolders that contain big images
    var smallFolder = 'imagens_pequenas'; //folder with subfolders that contain small images (thumbnails)

    var imgName = 'imagem'; //image name (e.g. the first image is photo-001 - or if you change name to "image" then the first image name is image-001)

    var imgExt = 'jpg'; //extension (filetype) for big images
    var smallExt = 'gif'; //extension (filetype) for small images

    var setColumns = 5; // how many columns per page
    var setRows = 0; // how many rows to skip before scroll starts, check and adjust manually
    var setHeight = 76+10+10; // this is important for scroller: max small image (thumbnail) height + <td> padding-top + <td> padding-bottom (see css file)

    //GLOBALS - GALLERY FOLDERS ('<folder>', <number of images>)

    var setFolders = Array (
    Array('Museu_Leonardo_Da_Vinci',11)
    );

    //GALLERY FUNCTIONS

    function leadingZero(getImage){

    if (getImage < 10)setImage = "00" + getImage;
    if (getImage > 9 && getImage < 100)setImage = "0" + getImage;
    if (getImage > 99)setImage = getImage;

    return setImage;
    }
    function initGallery(){

    showGallery(0,setFolders[0][1],setFolders[0][0]);

    }
    function showMenu(){

    returnData = '<tr><td id="menu" colspan="'+ setColumns +'"> | ';

    for (getFolder = 0; getFolder < setFolders.length; getFolder++){
    returnData += '<a href="javascript:showGallery(0,'+setFolders[getFolder][1]+',\''+setFolders[getFolder][0]+'\')">'+setFolders[getFolder][0]+'</a> | ';
    }

    returnData += '</td></tr>'+nl;

    return returnData;

    }
    function showGallery(getImage,maxImages,setFolder){

    setImage = leadingZero(getImage);

    if(getImage == 0) {
    getImage = 1;
    }

    imgNxt = getImage + 1;
    imgPre = getImage - 1;

    if (imgNxt > maxImages)imgNxt = 1;
    if (imgPre < 1)imgPre = maxImages;

    returnData = '<table>'+nl;
    returnData += '<tr id="selector">'+nl;
    returnData += '<td><a href="javascript:showImage('+ imgPre +','+ maxImages +',\''+ setFolder +'\')">previous</a></td>'+nl;
    returnData += '<td align="center"><a href="javascript:window.close();">close</a></td>'+nl;
    returnData += '<td align="right"><a href="javascript:showImage('+ imgNxt +','+ maxImages +',\''+ setFolder +'\')">next</a></td>'+nl;
    returnData += '</tr>'+nl;
    returnData += '<tr><td colspan="3"><a href="javascript:showGallery('+ getImage +','+ maxImages +',\''+ setFolder +'\')"><img src="'+ imgFolder +'/'+ setFolder +'/'+ imgName +'-'+ setImage +'.'+ imgExt +'"></a></td></tr>'+nl;
    returnData += '<tr id="selector"><td colspan="3">'+ getImage +' / '+ maxImages +'</td></tr>'+nl;
    returnData += '</table>'+nl;

    writeData(returnData,0);
    }
    function showImage(getImage,maxImages,setFolder){

    setImage = leadingZero(getImage);

    imgNxt = getImage + 1;
    imgPre = getImage - 1;

    if (imgNxt > maxImages)imgNxt = 1;
    if (imgPre < 1)imgPre = maxImages;

    returnData = '<table>'+nl;
    returnData += '<tr id="selector">'+nl;
    returnData += '<td><a href="javascript:showImage('+ imgPre +','+ maxImages +',\''+ setFolder +'\')">previous</a></td>'+nl;
    returnData += '<td align="center"><a href="javascript:showGallery('+ getImage +','+ maxImages +',\''+ setFolder +'\')">close</a></td>'+nl;
    returnData += '<td align="right"><a href="javascript:showImage('+ imgNxt +','+ maxImages +',\''+ setFolder +'\')">next</a></td>'+nl;
    returnData += '</tr>'+nl;
    returnData += '<tr><td colspan="3"><a href="javascript:showGallery('+ getImage +','+ maxImages +',\''+ setFolder +'\')"><img src="'+ imgFolder +'/'+ setFolder +'/'+ imgName +'-'+ setImage +'.'+ imgExt +'"></a></td></tr>'+nl;
    returnData += '<tr id="selector"><td colspan="3">'+ getImage +' / '+ maxImages +'</td></tr>'+nl;
    returnData += '</table>'+nl;

    writeData(returnData,0);
    }
    function writeData(returnData,setScroll){

    document.getElementById('gallery').innerHTML = returnData;
    scrollTo(0,setScroll);

    }

    //START

    initGallery();
    ----------------------------
    Last edited by carloswebwdfn; Apr 22nd, 2015 at 05:53 AM.

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Tags for this Thread

All times are GMT -6. The time now is 09:28 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com