PDA

View Full Version : I want to run go() gunction 1st ...some plz help



asamaiya
12-21-2009, 09:59 PM
that all code is generating menu ...but menu is loading at last .. i uses alert to resolve ... but alert which is inside of go function coming at last ....


<script type='text/javascript'>
var LowBgColor='transparent';
var LowSubBgColor='#666666';

var HighBgColor='#CC6617';

var HighSubBgColor='#CC6617';
var FontLowColor='#ffffff';
var FontSubLowColor='#ffffff';
var FontHighColor='#ffffff';
var FontSubHighColor='#ffffff';
var BorderColor='transparent';
var BorderWidth=1;
var BorderBtwnElmnts=1;
var FontFamily="Verdana, Arial, sans-serif"
var FontSize=7;
var FontBold=1;
var FontItalic=0;
var MenuTextCentered='center';
var MenuCentered='left';
var MenuVerticalCentered='top';
var ChildOverlap=.0;
var ChildVerticalOverlap=.0;
var StartTop=1;
var StartLeft=0;
var VerCorrect=0;
var HorCorrect=0;
var LeftPaddng=2;
var TopPaddng=5;
var DissapearDelay=500;

var FirstLineHorizontal=1;
var MenuFramesVertical=1;
var TakeOverBgColor=1;
var FirstLineFrame='';
var SecLineFrame='';
var DocTargetFrame='';
var TargetLoc='globalNav';
var HideTop=0;
var MenuWrap=1;
var RightToLeft=0;
var UnfoldsOnClick=0;
var WebMasterCheck=0;
var ShowArrow=1;
var Arrws=['images/tri.gif',5,10,'images/tridown.gif',10,5,'images/trileft.gif',5,10];
function Go(){return}
function BeforeStart(){return}
function AfterBuild(){return}
function BeforeFirstOpen(){return}
function AfterCloseAll(){return}

alert("build_menus");

var NoOffFirstLineMenus= 5;Menu1_1_1= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu1_1_2= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu1_1_3= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu1_1_4= new Array("","","",0,25,145,"","","","","","","","","","left",""); Menu1_1_5= new Array(" ","","",0,25,145,"","","","","","","","","","left",""); Menu1_1= new Array("","","",5,25,145,"","","","","","","","","","left",""); Menu1_2_1= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu1_2_2= new Array(" ","","",0,25,145,"","","","","","","","","","left",""); Menu1_2_3= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu1_2_4= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu1_2= new Array(""," ","",4,25,145,"","","","","","","","","","left",""); Menu1_3= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu1_4_1= new Array(" ","","",0,25,145,"","","","","","","","","","left",""); Menu1_4_2= new Array(""," w","",0,25,145,"","","","","","","","","","left",""); Menu1_4= new Array(""," ","",2,25,145,"","","","","","","","","","left",""); Menu1_5_1= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu1_5_2= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu1_5= new Array("","","",2,25,145,"","","","","","","","","","left",""); Menu1= new Array(""," ","",5,30,124,"","","","","","","","","","",""); Menu2_1= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu2_2= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu2_3= new Array("& "," ","",0,25,145,"","","","","","","","","","left",""); Menu2_4= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu2_5= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu2= new Array(""," ","",5,30,124,"","","","","","","","","","",""); Menu3_1_1= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu3_1_2= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3_1= new Array("","","",2,25,145,"","","","","","","","","","left",""); Menu3_2_1= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3_2_2= new Array(" ","","",0,25,145,"","","","","","","","","","left",""); Menu3_2= new Array(""," ","",2,25,145,"","","","","","","","","","left",""); Menu3_3_1= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3_3_2= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3_3= new Array(""," ","",2,25,145,"","","","","","","","","","left",""); Menu3_4= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3_5= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3_6= new Array("C","","",0,25,145,"","","","","","","","","","left",""); Menu3_7= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3_8= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3_9= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3_10= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu3= new Array(""," ","",10,30,124,"","","","","","","","","","",""); Menu4_1= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu4_2= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu4_3= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu4_4= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu4_5= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu4_6= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu4= new Array(""," ","",6,30,124,"","","","","","","","","","",""); Menu5_1= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu5_2= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu5_3= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu5= new Array(""," ","",3,30,124,"","","","","","","","","","",""); Menu6_1= new Array(""," ","",0,25,145,"","","","","","","","","","left",""); Menu6_2= new Array(" "," ","",0,25,145,"","","","","","","","","","left",""); Menu6_3= new Array(""," ","",0,25,145,"","","","","","","","","","left","");

</script><script type='text/javascript'>


var AgntUsr=navigator.userAgent.toLowerCase();
var DomYes=document.getElementById?1:0;
var NavYes=AgntUsr.indexOf('mozilla')!=-1&&AgntUsr.indexOf('compatible')==-1?1:0;
var ExpYes=AgntUsr.indexOf('msie')!=-1?1:0;
var Opr=AgntUsr.indexOf('opera')!=-1?1:0;
var Opr6orless=window.opera && navigator.userAgent.search(/opera.[1-6]/i)!=-1 //DynamicDrive.com added code
var DomNav=DomYes&&NavYes?1:0;
var DomExp=DomYes&&ExpYes?1:0;
var Nav4=NavYes&&!DomYes&&document.layers?1:0;
var Exp4=ExpYes&&!DomYes&&document.all?1:0;
var PosStrt=(NavYes||ExpYes)&&!Opr6orless?1:0;

var FrstLoc,ScLoc,DcLoc;
var ScWinWdth,ScWinHght,FrstWinWdth,FrstWinHght;
var ScLdAgainWin;
var FirstColPos,SecColPos,DocColPos;
var RcrsLvl=0;
var FrstCreat=1,Loadd=0,Creatd=0,IniFlg,AcrssFrms=1;
var FrstCntnr=null,CurrntOvr=null,CloseTmr=null;
var CntrTxt,TxtClose,ImgStr;
var Ztop=100;
var ShwFlg=0;
var M_StrtTp=StartTop,M_StrtLft=StartLeft;
var StaticPos=0;
var LftXtra=DomNav?LeftPaddng:0;
var TpXtra=DomNav?TopPaddng:0;
var M_Hide=Nav4?'hide':'hidden';
var M_Show=Nav4?'show':'visible';
var Par=parent.frames[0]&&FirstLineFrame!=SecLineFrame?parent:window;
var Doc=Par.document;
var Bod=Doc.body;
var Trigger=NavYes?Par:Bod;

MenuTextCentered=MenuTextCentered==1||MenuTextCentered=='center'?'center':MenuTextCentered==0||MenuT extCentered!='right'?'left':'right';



WbMstrAlrts=["Item not defined: ","Item needs height: ","Item needs width: "];
alert('1st');
if(Trigger.onload)Dummy=Trigger.onload;
if(DomNav&&!Opr)Trigger.addEventListener('load',Go,false);
else Trigger.onload=Go;

function Dummy(){ return}

function CnclSlct(){return false}

function RePos(){
FrstWinWdth=ExpYes?FrstLoc.document.body.clientWidth:FrstLoc.innerWidth;
FrstWinHght=ExpYes?FrstLoc.document.body.clientHeight:FrstLoc.innerHeight;
ScWinWdth=ExpYes?ScLoc.document.body.clientWidth:ScLoc.innerWidth;
ScWinHght=ExpYes?ScLoc.document.body.clientHeight:ScLoc.innerHeight;
if(MenuCentered=='justify'&&FirstLineHorizontal){
FrstCntnr.style.width=FrstWinWdth;
ClcJus();
var P=FrstCntnr.FrstMbr,W=Menu1[5],i;
for(i=0;i<NoOffFirstLineMenus;i++){P.style.width=W;P=P.PrvMbr}}
StaticPos=-1;
if(TargetLoc)ClcTrgt();
if(MenuCentered)ClcLft();
if(MenuVerticalCentered)ClcTp();
PosMenu(FrstCntnr,StartTop,StartLeft)}

function UnLoaded(){
if(CloseTmr)clearTimeout(CloseTmr);
Loadd=0; Creatd=0;
if(HideTop){
var FCStyle=Nav4?FrstCntnr:FrstCntnr.style;
FCStyle.visibility=M_Hide}}

function ReDoWhole(){
if(ScWinWdth!=ScLoc.innerWidth||ScWinHght!=ScLoc.innerHeight||FrstWinWdth!=FrstLoc.innerWidth||FrstW inHght!=FrstLoc.innerHeight)Doc.location.reload()}

function Check(WMnu,NoOf){
var i,array,ArrayLoc;
ArrayLoc=parent.frames[0]?parent.frames[FirstLineFrame]:self;
for(i=0;i<NoOf;i++){
array=WMnu+eval(i+1);
if(!ArrayLoc[array]){WbMstrAlrt(0,array); return false}
if(i==0){ if(!ArrayLoc[array][4]){WbMstrAlrt(1,array); return false}
if(!ArrayLoc[array][5]){WbMstrAlrt(2,array); return false}}
if(ArrayLoc[array][3])if(!Check(array+'_',ArrayLoc[array][3])) return false}
return true}

function WbMstrAlrt(No,Xtra){
return confirm(WbMstrAlrts[No]+Xtra+' ')}

function Go(){ alert('go');
Dummy();
if(Loadd||!PosStrt)return;
BeforeStart();
Creatd=0; Loadd=1;
status='Building menu';
if(FrstCreat){
if(FirstLineFrame =="" || !parent.frames[FirstLineFrame]){
FirstLineFrame=SecLineFrame;
if(FirstLineFrame =="" || !parent.frames[FirstLineFrame]){
FirstLineFrame=SecLineFrame=DocTargetFrame;
if(FirstLineFrame =="" || !parent.frames[FirstLineFrame])FirstLineFrame=SecLineFrame=DocTargetFrame=''}}
if(SecLineFrame =="" || !parent.frames[SecLineFrame]){
SecLineFrame=DocTargetFrame;
if(SecLineFrame =="" || !parent.frames[SecLineFrame])SecLineFrame=DocTargetFrame=FirstLineFrame}
if(DocTargetFrame =="" || !parent.frames[DocTargetFrame])DocTargetFrame=SecLineFrame;
if(WebMasterCheck){ if(!Check('Menu',NoOffFirstLineMenus)){status='build aborted';return}}
FrstLoc=FirstLineFrame!=""?parent.frames[FirstLineFrame]:window;
ScLoc=SecLineFrame!=""?parent.frames[SecLineFrame]:window;
DcLoc=DocTargetFrame!=""?parent.frames[DocTargetFrame]:window;
if (FrstLoc==ScLoc) AcrssFrms=0;
if (AcrssFrms)FirstLineHorizontal=MenuFramesVertical?0:1;
FrstWinWdth=ExpYes?FrstLoc.document.body.clientWidth:FrstLoc.innerWidth;
FrstWinHght=ExpYes?FrstLoc.document.body.clientHeight:FrstLoc.innerHeight;
ScWinWdth=ExpYes?ScLoc.document.body.clientWidth:ScLoc.innerWidth;
ScWinHght=ExpYes?ScLoc.document.body.clientHeight:ScLoc.innerHeight;
if(Nav4){ CntrTxt=MenuTextCentered!='left'?"<div align='"+MenuTextCentered+"'>":"";
TxtClose="</font>"+MenuTextCentered!='left'?"</div>":""}}
FirstColPos=Nav4?FrstLoc.document:FrstLoc.document.body;
SecColPos=Nav4?ScLoc.document:ScLoc.document.body;
DocColPos=Nav4?DcLoc.document:ScLoc.document.body;
if (TakeOverBgColor)FirstColPos.bgColor=AcrssFrms?SecColPos.bgColor:DocColPos.bgColor;
if(MenuCentered=='justify'&&FirstLineHorizontal)ClcJus();
if(FrstCreat){
FrstCntnr=CreateMenuStructure('Menu',NoOffFirstLineMenus);
FrstCreat=AcrssFrms?0:1}
else CreateMenuStructureAgain('Menu',NoOffFirstLineMenus);
if(TargetLoc)ClcTrgt();
if(MenuCentered)ClcLft();
if(MenuVerticalCentered)ClcTp();
PosMenu(FrstCntnr,StartTop,StartLeft);
IniFlg=1;
Initiate();
Creatd=1;
ScLdAgainWin=ExpYes?ScLoc.document.body:ScLoc;
ScLdAgainWin.onunload=UnLoaded;
Trigger.onresize=Nav4?ReDoWhole:RePos;
AfterBuild();
if(MenuVerticalCentered=='static'&&!AcrssFrms)setInterval('KeepPos()',250);
status='Welcome to Select Furniture Outlet'}

function KeepPos(){
var TS=ExpYes?FrstLoc.document.body.scrollTop:FrstLoc.pageYOffset;
if(TS!=StaticPos){
var FCStyle=Nav4?FrstCntnr:FrstCntnr.style;
FCStyle.top=FrstCntnr.OrgTop=StartTop+TS;StaticPos=TS}}

function ClcJus(){
var a=BorderBtwnElmnts?1:2,b=BorderBtwnElmnts?BorderWidth:0;
var Size=Math.round(((FrstWinWdth-a*BorderWidth)/NoOffFirstLineMenus)-b),i,j;
for(i=1;i<NoOffFirstLineMenus+1;i++){j=eval('Menu'+i);j[5]=Size}
StartLeft=0}

function ClcTrgt(){
var TLoc=Nav4?FrstLoc.document.layers[TargetLoc]:DomYes?FrstLoc.document.getElementById(TargetLoc):FrstLoc.document.all[TargetLoc];
StartTop=M_StrtTp;
StartLeft=M_StrtLft;
if(DomYes){
while(TLoc){StartTop+=TLoc.offsetTop;StartLeft+=TLoc.offsetLeft;TLoc=TLoc.offsetParent}}
else{ StartTop+=Nav4?TLoc.pageY:TLoc.offsetTop;StartLeft+=Nav4?TLoc.pageX:TLoc.offsetLeft}}

function ClcLft(){
if(MenuCentered!='left'&&MenuCentered!='justify'){
var Size=FrstWinWdth-(!Nav4?parseInt(FrstCntnr.style.width):FrstCntnr.clip.width);
StartLeft=M_StrtLft;
StartLeft+=MenuCentered=='right'?Size:Size/2}}

function ClcTp(){
if(MenuVerticalCentered!='top'&&MenuVerticalCentered!='static'){
var Size=FrstWinHght-(!Nav4?parseInt(FrstCntnr.style.height):FrstCntnr.clip.height);
StartTop=M_StrtTp;
StartTop+=MenuVerticalCentered=='bottom'?Size:Size/2}}

function Initiate(){
if(IniFlg){ Init(FrstCntnr);IniFlg=0;
if(ShwFlg)AfterCloseAll();ShwFlg=0}}

function Init(CntnrPntr){
var Mmbr=CntnrPntr.FrstMbr;
var MCStyle=Nav4?CntnrPntr:CntnrPntr.style;
RcrsLvl++;
MCStyle.visibility=RcrsLvl==1?M_Show:M_Hide;
while(Mmbr!=null){
if(Mmbr.Hilite){Mmbr.Hilite=0;if(KeepHilite)LowItem(Mmbr)}
if(Mmbr.ChildCntnr) Init(Mmbr.ChildCntnr);
Mmbr=Mmbr.PrvMbr}
RcrsLvl--}

function ClearAllChilds(Pntr){
var CPCCStyle;
while (Pntr){
if(Pntr.Hilite){
Pntr.Hilite=0;
if(KeepHilite)LowItem(Pntr);
if(Pntr.ChildCntnr){
CPCCStyle=Nav4?Pntr.ChildCntnr:Pntr.ChildCntnr.style;
CPCCStyle.visibility=M_Hide;
ClearAllChilds(Pntr.ChildCntnr.FrstMbr)}
break}
Pntr=Pntr.PrvMbr}}





function CreateMenuStructure(MName,NumberOf){
RcrsLvl++;
var i,NoOffSubs,Mbr,Wdth=0,Hght=0;
var PrvMmbr=null;
var WMnu=MName+'1';
var MenuWidth=eval(WMnu+'[5]');
var MenuHeight=eval(WMnu+'[4]');
var Location=RcrsLvl==1?FrstLoc:ScLoc;
if (RcrsLvl==1&&FirstLineHorizontal){
for(i=1;i<NumberOf+1;i++){
WMnu=MName+eval(i);
Wdth=eval(WMnu+'[5]')?Wdth+eval(WMnu+'[5]'):Wdth+MenuWidth}
Wdth=BorderBtwnElmnts?Wdth+(NumberOf+1)*BorderWidth:Wdth+2*BorderWidth;Hght=MenuHeight+2*BorderWidth }
else{ for(i=1;i<NumberOf+1;i++){
WMnu=MName+eval(i);
Hght=eval(WMnu+'[4]')?Hght+eval(WMnu+'[4]'):Hght+MenuHeight}
Hght=BorderBtwnElmnts?Hght+(NumberOf+1)*BorderWidth:Hght+2*BorderWidth;Wdth=MenuWidth+2*BorderWidth}
if(DomYes){
var MmbrCntnr=Location.document.createElement("div");
MmbrCntnr.style.position='absolute';
MmbrCntnr.style.visibility='hidden';
Location.document.body.appendChild(MmbrCntnr)}
else{ if(Nav4) var MmbrCntnr=new Layer(Wdth,Location)
else{ WMnu+='c';
Location.document.body.insertAdjacentHTML("AfterBegin","<div id='"+WMnu+"' style='visibility:hidden; position:absolute;'><\/div>");
var MmbrCntnr=Location.document.all[WMnu]}}
MmbrCntnr.SetUp=CntnrSetUp;
MmbrCntnr.SetUp(Wdth,Hght,NumberOf);
if(Exp4){ MmbrCntnr.InnerString='';
for(i=1;i<NumberOf+1;i++){
WMnu=MName+eval(i);
MmbrCntnr.InnerString+="<div id='"+WMnu+"' style='position:absolute;'><\/div>"}
MmbrCntnr.innerHTML=MmbrCntnr.InnerString}
for(i=1;i<NumberOf+1;i++){
WMnu=MName+eval(i);
NoOffSubs=eval(WMnu+'[3]');
Wdth=RcrsLvl==1&&FirstLineHorizontal?eval(WMnu+'[5]')?eval(WMnu+'[5]'):MenuWidth:MenuWidth;
Hght=RcrsLvl==1&&FirstLineHorizontal?MenuHeight:eval(WMnu+'[4]')?eval(WMnu+'[4]'):MenuHeight;
if(DomYes){
Mbr=Location.document.createElement("div");
Mbr.style.position='absolute';
Mbr.style.visibility='inherit';
MmbrCntnr.appendChild(Mbr)}
else Mbr=Nav4?new Layer(Wdth,MmbrCntnr):Location.document.all[WMnu];
Mbr.SetUp=Nav4?NavMbrSetUp:MbrSetUp;
Mbr.SetUp(MmbrCntnr,PrvMmbr,WMnu,Wdth,Hght);
if(NoOffSubs) Mbr.ChildCntnr=CreateMenuStructure(WMnu+'_',NoOffSubs);
PrvMmbr=Mbr}
MmbrCntnr.FrstMbr=Mbr;
RcrsLvl--;
return(MmbrCntnr)}

function CreateMenuStructureAgain(MName,NumberOf){
var i,WMnu,NoOffSubs,PrvMmbr,Mbr=FrstCntnr.FrstMbr;
RcrsLvl++;
for(i=NumberOf;i>0;i--){
WMnu=MName+eval(i);
NoOffSubs=eval(WMnu+'[3]');
PrvMmbr=Mbr;
if(NoOffSubs)Mbr.ChildCntnr=CreateMenuStructure(WMnu+'_',NoOffSubs);
Mbr=Mbr.PrvMbr}
RcrsLvl--}
alert('end');
</script>
<div id="globalNav">
</div>




Help would be appreciated .....
thanks

jmrker
12-21-2009, 10:25 PM
Why is this function repeated in the code? :confused:

function Go(){return}

asamaiya
12-21-2009, 10:38 PM
I dont have any idea what this code is doing .............. :( .... can you please help it out .. some how Go; should run 1st .....

thanks
samaiya

jmrker
12-22-2009, 12:13 AM
I dont have any idea what this code is doing .............. :( .... can you please help it out .. some how Go; should run 1st .....

thanks
samaiya

Where did you get the code from?
Has it ever worked?
Have you requested information from the author?

You have only posted the JS part, and have nothing about how it is used in the HTML page.

asamaiya
12-22-2009, 12:39 AM
this is working on our website you can directly take [html +javascript ] from http://www.selectfurnitureoutlet.com , taken from an open source contribution buiild in OScommerce ,
problem is menu loading time ... which takes max. time when there are lots of products

thanks