Hi guys, I was editing the zoom macro for my needs today and... well, it is those of one mysteries with javascript that I'll never understand, but maybe with your help I'll do, who knows...
Well, the thing is about that variables, or elements, or as you wish to call, that have a value, but, even if it doesn't match with the conditional expression, the script still continues working.
In the Zoom in and out images macro there is a value for "zoom". The first time, it's ok, it matches and so, the script can be executed, but... why the next times it's executed when that element already has a value that, in my head (and with alert checks), doesn't match at all with the expected condition?
Let's have a look to "getAttribute('zoom')". Ok, the first time it's null, so, the script can run. Then, that isn't being reset anywhere (I post the other macros used), so, why the hell it continues zooming out and in?????
Another doubt is why that value is divided by 10 inside "_Zoom_hndlImage".
The code is reformatted to avoid page distortion.
_Zoom_Image{
$_Zoom_doitImg="
if(getAttribute('zoom')==null){
setAttribute('initW',width);
setAttribute('initH',height);
setAttribute('zoom',1)
}
var iz=".$_Zoom_By.";
setAttribute('zoom',getAttribute('zoom')*iz);
iz=getAttribute('zoom');
width=bz*iz*getAttribute('initW');
height=bz*iz*getAttribute('initH')";
&_Zoom_hndlImage;
}
_Zoom_hndlImage{
$JS_doit="var b=getElementsByTagName('body')[0];
if(b){var bz=(b.getAttribute('zoom')==null)?1 : (b.getAttribute('zoom')/10);
for(var j=0,i=images;j<i.length;j++)
with(i[j])if(urlencode(src)=='".urlencode($ImageURL)."'){".$_Zoom_doitImg."}}";
&JS_hndlDoc;
}
JS_hndlDoc{
# Same as JS_hndlDocs, but only for the current frame.
injectJS("(function(){".$JS_func.$_JS_urlencode."with(document){".$JS_doit."}".$JS_last."})()","frame");
$JS_doit=""; $JS_func=""; $JS_last=""; $JS_fail="";
}
Edited 3 time(s). Last edit at 03/10/2009 01:39AM by JohnHell.