...

View Full Version : functions execute first time, fail to execute after that



transmoderata
06-18-2012, 06:10 AM
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:


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;}
}
}


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.

transmoderata
06-18-2012, 10:25 AM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum