View Full Version : What does this part of the code do...
Hi all, what does this part of the code do:
avail="190+((toppage.x2-210)/6)"
oCMenu.menuplacement=new Array(190,avail,avail+"*2",avail+"*3",avail+"*4",avail+"*5")
Thanks
-Mike Barone
WWW.CGISCRIPT.NET, LLC
FREE CGI/PERL SCRIPTS
Positions the main menus I suspect.
function Mike(name, mail) {
*****this.name = "Xanth";
*****this.mail = [url:zxrcsuvsmv]belgedin@earthlink.net[/url:zxrcsuvsmv];
*****return this;
}
That's just the code that I use to get the menus on this page positioned correctly.
-Thomas Brattli-
http://www.bratta.com/
http://www.dhtmlcentral.com/
Okay, I am getting closer. I understand what the 190 does, can you guys walk me through the elements below? What does the "avail" mean, why do some have "+" after them and other not? Finally, what are the "*[number]"?
new Array(190,avail,avail+"*2",avail+"*3",avail+"*4",avail+"*5")
I appreciate you guys taking the time. I am starting to get it.
-Mike Barone
WWW.CGISCRIPT.NET, LLC
FREE CGI/PERL SCRIPTS
In this:
avail="50+((toppage.x2-210)/6)" = "50" is position and "/6" divides by button total.
Can you explain what this does and where the numbers come from please:
(toppage.x2-210)
Thanks again!
-Mike Barone
WWW.CGISCRIPT.NET, LLC
FREE CGI/PERL SCRIPTS
toppage is a object that contains the entire width and height of the document.
Made with the object constructor:
function makePageCoords(win,fr){
if(!win) win=window
this.x=0;this.x2=(bw.ns4 || bw.ns6)?win.innerWidth-1:win.document.body.offsetWidth;
if(!fr&&bw.ie) this.x2-=20; else if(!fr&&bw.ns4) this.x2-=4; else if(bw.ns6) this.x2+=1
if(bw.ns4&&!win.rows) this.x2+=5
this.y=0;this.y2=(bw.ns4 || bw.ns6)?win.innerHeight:win.document.body.offsetHe ight;
if(!fr&&bw.ie) this.y2-=4; else if(bw.ns4&&fr) this.y2+=4
this.y2orig=this.y2; this.x50=this.x2/2; this.y50=this.y2/2;
this.x10=(this.x2*10)/100-5;this.y10=(this.y2*10)/100-5
this.x15=(this.x2*15)/100-5;this.y15=(this.y2*15)/100-5;
return this;
}
You can find some explainations on this at bratta.com/dhtml/scripts.asp (click tutorials, then documentsize)
toppage.x2 is the total width of the document.
The reason it looks a little strange in the code:
avail="190+((toppage.x2-210)/6)"
oCMenu.menuplacement=new Array(190,avail,avail+"*2",avail+"*3",avail+"*4",avail+"*5")
Is that I made it into a string so that each time the page reloads and the toppage changes the string will be evaluated so the menu items get the correct position.
Did that help?
-Thomas Brattli-
http://www.bratta.com/
http://www.dhtmlcentral.com/
Yes, that helped a lot! It will give me enough to get to the next question ;)
Thanks!
-Mike Barone
WWW.CGISCRIPT.NET, LLC
FREE CGI/PERL SCRIPTS
vBulletin® v3.6.7, Copyright ©2000-2008, Jelsoft Enterprises Ltd.