Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    functions execute first time, fail to execute after that

    page: http://www.therabbitshome.com/

    To reproduce the problem:

    1. Click "BROWSE GALLERIES". Now click "(2010 - 2011) GALLERY 1". This calls functions inPrevPage() and inNextPage(); "<< PREVIOUS PAGE" and "NEXT PAGE >>" enter toward the top, as expected.

    2. Now click "(2011 -) GALLERY 2". This calls outPrevPage() and outNextPage(); "<< PREVIOUS PAGE" and "NEXT PAGE >>" disappear back where they came from, as expected.

    3. Now click "(2010 - 2011) GALLERY 1" again. inPrevPage() and inNextPage() should execute again, and the two images should come back in. But they don't.

    The execution of these functions is controlled by if...else statements that test whether or not a current gallery is open. To debug the problem, I've added some debugging text in red at the left side of the page and the 0's and 1's reflect changes to the variables' values. As you can see, the conditions are identical the first and second time you click "(2010 - 2011) GALLERY 1", so the functions should execute likewise in each case.

    The relevant code:

    Code:
    function clickGallery1() {
        if (infoIs==1) {return;}
        else if (linksIs==1) {return;}
        else {
            if (gallery2Is==1) {
                gallery1Is=1;
                gallery2Is=0;
                gallery1Page1Is=1;
                gallery1Page2Is=0;
                setTimeout(inPrevPage,1000);
                setTimeout(inNextPage,1000);
    
    ...
    
            }
            else if (designbinIs==1) {
                gallery1Is=1;
                designbinIs=0;
                gallery1Page1Is=1;
                gallery1Page2Is=0;
                setTimeout(inPrevPage,1000);
                setTimeout(inNextPage,1000);
    
    ...
    
            }
            else if (gallery1Is==0) {
                gallery1Is=1;
                gallery1Page1Is=1;
                gallery1Page2Is=0;
                inPrevPage();
                inNextPage();
    
    ...
    
            }
            else {return;}
        }
    }
    function clickGallery2() {
        if (infoIs==1) {return;}
        else if (linksIs==1) {return;}
        else {
            if (gallery1Is==1) {
                if (gallery1Page1Is==1) {
                    gallery2Is=1;
                    gallery1Is=0;
                    outPrevPage();
                    outNextPage();
    
    ...
    
                }
                else {
                    gallery2Is=1;
                    gallery1Is=0;
                    outPrevPage();
                    outNextPage();
    
    ...
    
                }
            }
            else if (designbinIs==1) {
                gallery2Is=1;
                designbinIs=0;
    
    ...
    
            }
            else if (gallery2Is==0) {
                gallery2Is=1;
    
    ...
    
            }
            else {return;}
        }
    }
    function clickDesignbin() {
        if (infoIs==1) {return;}
        else if (linksIs==1) {return;}
        else {
            if (gallery1Is==1) {
                if (gallery1Page1Is==1) {
                    designbinIs=1;
                    gallery1Is=0;
                    outPrevPage();
                    outNextPage();
    
    ...
    
                }
                else {
                    designbinIs=1;
                    gallery1Is=0;
                    outPrevPage();
                    outNextPage();
    
    ...
    
                }
            }
            else if (gallery2Is==1) {
                designbinIs=1;
                gallery2Is=0;
    
    ...
    
            }
            else if (designbinIs==0) {
                designbinIs=1;
    
    ...
    
            }
            else {return;}
        }
    }
    Code:
    function inPrevPage() {
        var jPrevPage=document.getElementById("prevpage");
        var jPrevPage_left=jPrevPage.style.left==""?-117:parseFloat(jPrevPage.style.left);
        if (jPrevPage_left<26) {
            jPrevPage_left=jPrevPage_left+speedPxPrevPage;
            jPrevPage.style.left=jPrevPage_left+"px";
            setTimeout(inPrevPage,16);
        }
        else if ((jPrevPage_left>=26)&&(jPrevPage_left<96)) {
            speedPxPrevPage=speedPxPrevPage/1.25;
            jPrevPage_left=jPrevPage_left+speedPxPrevPage;
            jPrevPage.style.left=jPrevPage_left+"px";
            setTimeout(inPrevPage,16);
        }
    }
    function inNextPage() {
        var jNextPage=document.getElementById("nextpage");
        var jNextPage_left=jNextPage.style.left==""?1044:parseFloat(jNextPage.style.left);
        if (jNextPage_left>955) {
            jNextPage_left=jNextPage_left-speedPxNextPage;
            jNextPage.style.left=jNextPage_left+"px";
            setTimeout(inNextPage,16);
        }
        else if ((jNextPage_left<=955)&&(jNextPage_left>885)) {
            speedPxNextPage=speedPxNextPage/1.25;
            jNextPage_left=jNextPage_left-speedPxNextPage;
            jNextPage.style.left=jNextPage_left+"px";
            setTimeout(inNextPage,16);
        }
    }
    function outPrevPage() {
        var jPrevPage=document.getElementById("prevpage");
        var jPrevPage_left=jPrevPage.style.left==""?96:parseFloat(jPrevPage.style.left);
        if (jPrevPage_left>-117) {
            jPrevPage_left=jPrevPage_left-5;
            jPrevPage.style.left=jPrevPage_left+"px";
            setTimeout(outPrevPage,1);
        }
    }
    function outNextPage() {
        var jNextPage=document.getElementById("nextpage");
        var jNextPage_left=jNextPage.style.left==""?900:parseFloat(jNextPage.style.left);
        if (jNextPage_left<1044) {
            jNextPage_left=jNextPage_left+5;
            jNextPage.style.left=jNextPage_left+"px";
            setTimeout(outNextPage,1);
        }
    }
    Any ideas as to what the problem is? Help much appreciated.
    Last edited by transmoderata; 06-18-2012 at 11:25 AM.

  • #2
    New Coder
    Join Date
    May 2012
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, in an attempt to debug this, I added an alert statement that is executed (several times due to the nature of the function, sorry for this annoyance) when inPrevPage() is called. Now you'll see that when "(2010 - 2011) GALLERY 1" is clicked, the alert appears as it should, but then if you click "(2011 -) GALLERY2", the alert appears again, and it shouldn't. Clicking on the Gallery 2 image executes clickGallery2(), and as you can see, NO WHERE in clickGallery2() is there a call for inPrevPage(). So how could it possibly be executing?


  •  

    Posting Permissions

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