javascript

位置:IT落伍者 >> javascript >> 浏览文章

一个以Javascript+xml的树型列表


发布日期:2023年12月11日
 
一个以Javascript+xml的树型列表
这是在网站下载的一个以Javascript+xml的树型列表这个列表界面非常的漂亮但是由于里面内容比较复杂而现在项目需要用到这个列表我到现在还没有摸清怎么在里面让点击一个树型的项目转到别的网页里面去希望有兴趣的朋友一起研究一下

部分代码如下

<script>

functiondtmlXMLLoaderObject(funcObjectdhtmlObject){

thisxmlDoc=;

thisonloadAction=funcObject||null;

thismainObject=dhtmlObject||null;

returnthis;

};

dtmlXMLLoaderObjectprototypewaitLoadFunction=function(dhtmlObject){

thischeck=function(){

if(!dhtmlObjectxmlDocreadyState)dhtmlObjectonloadAction(dhtmlObjectmainObject);

else{

if(dhtmlObjectxmlDocreadyState!=)returnfalse;

elsedhtmlObjectonloadAction(dhtmlObjectmainObject);}

};

returnthischeck;

};

dtmlXMLLoaderObjectprototypegetXMLTopNode=function(tagName){

if(thisxmlDocresponseXML){vartemp=thisxmlDocresponseXMLgetElementsByTagName(tagName);

varz=temp[];}

elsevarz=thisxmlDocdocumentElement;

if(z)returnz;

alert(IncorrectXML);

returndocumentcreateElement(DIV);

};

dtmlXMLLoaderObjectprototypeloadXMLString=function(xmlString){

try

{

varparser=newDOMParser();

thisxmlDoc=parserparseFromString(xmlStringtext/xml);

}

catch(e){

thisxmlDoc=newActiveXObject(MicrosoftXMLDOM);

thisxmlDocloadXML(xmlString);

}

thisonloadAction(thismainObject);

}

dtmlXMLLoaderObjectprototypeloadXML=function(filePath){

try

{

thisxmlDoc=newXMLHttpRequest();

thisxmlDocopen(GETfilePathtrue);

thisxmlDoconreadystatechange=newthiswaitLoadFunction(this);

thisxmlDocsend(null);

}

catch(e){

if(documentimplementation&&documentimplementationcreateDocument)

{

thisxmlDoc=documentimplementationcreateDocument(null);

thisxmlDoconload=newthiswaitLoadFunction(this);

}

else

{

thisxmlDoc=newActiveXObject(MicrosoftXMLDOM);

thisxmlDocasync=true;

thisxmlDoconreadystatechange=newthiswaitLoadFunction(this);

}

thisxmlDocload(filePath);

}

};

functioncallerFunction(funcObjectdhtmlObject){

thishandler=function(e){

if(!e)e=event;

funcObject(edhtmlObject);

returntrue;

};

returnthishandler;

};

functiongetAbsoluteLeft(htmlObject){

varxPos=htmlObjectoffsetLeft;

vartemp=htmlObjectoffsetParent;

while(temp!=null){

xPos+=tempoffsetLeft;

temp=tempoffsetParent;

}

returnxPos;

}

functiongetAbsoluteTop(htmlObject){

varyPos=htmlObjectoffsetTop;

vartemp=htmlObjectoffsetParent;

while(temp!=null){

yPos+=tempoffsetTop;

temp=tempoffsetParent;

}

returnyPos;

}

functionconvertStringToBoolean(inputString){if(typeof(inputString)==string)inputString=

inputStringtoLowerCase();

switch(inputString){

case:

casetrue:

caseyes:

casey:

case:

casetrue:

returntrue;

break;

default:returnfalse;

}

}

functiongetUrlSymbol(str){

if(strindexOf(?)!=)

return&

else

return?

}

functiondhtmlDragAndDropObject(){

thislastLanding=;

thisdragNode=;

thisdragStartNode=;

thisdragStartObject=;

thistempDOMU=null;

thistempDOMM=null;

thiswaitDrag=;

if(windowdhtmlDragAndDrop)returnwindowdhtmlDragAndDrop;

windowdhtmlDragAndDrop=this;

returnthis;

};

dhtmlDragAndDropObjectprototyperemoveDraggableItem=function(htmlNode){

htmlNodeonmousedown=null;

htmlNodedragStarter=null;

htmlNodedragLanding=null;

}

dhtmlDragAndDropObjectprototypeaddDraggableItem=function(htmlNodedhtmlObject){

htmlNodeonmousedown=thispreCreateDragCopy;

htmlNodedragStarter=dhtmlObject;

thisaddDragLanding(htmlNodedhtmlObject);

}

dhtmlDragAndDropObjectprototypeaddDragLanding=function(htmlNodedhtmlObject){

htmlNodedragLanding=dhtmlObject;

}

dhtmlDragAndDropObjectprototypepreCreateDragCopy=function(e)

{

if(windowdhtmlDragAndDropwaitDrag){

windowdhtmlDragAndDropwaitDrag=;

documentbodyonmouseup=windowdhtmlDragAndDroptempDOMU;

documentbodyonmousemove=windowdhtmlDragAndDroptempDOMM;

return;

}

windowdhtmlDragAndDropwaitDrag=;

windowdhtmlDragAndDroptempDOMU=documentbodyonmouseup;

windowdhtmlDragAndDroptempDOMM=documentbodyonmousemove;

windowdhtmlDragAndDropdragStartNode=this;

windowdhtmlDragAndDropdragStartObject=thisdragStarter;

documentbodyonmouseup=windowdhtmlDragAndDroppreCreateDragCopy;

documentbodyonmousemove=windowdhtmlDragAndDropcallDrag;

};

dhtmlDragAndDropObjectprototypecallDrag=function(e){

if(!e)e=windowevent;

dragger=windowdhtmlDragAndDrop;

if(!draggerdragNode){

draggerdragNode=draggerdragStartObject_createDragNode(draggerdragStartNode);

documentbodyappendChild(draggerdragNode);

documentbodyonmouseup=draggerstopDrag;

draggerwaitDrag=;

}

draggerdragNodestyleleft=eclientX++documentbodyscrollLeft;draggerdragNodestyletop=

eclientY++documentbodyscrollTop;

if(!esrcElement)varz=etarget;elsez=esrcElement;

draggercheckLanding(z);

}

dhtmlDragAndDropObjectprototypecheckLanding=function(htmlObject){

if(htmlObjectdragLanding){if(thislastLanding)thislastLandingdragLanding_dragOut(thislastLanding);

thislastLanding=htmlObject;thislastLanding=thislastLandingdragLanding_dragIn(thislastLandingthisdragStartNode);}

else{

if(htmlObjecttagName!=BODY)thischeckLanding(htmlObjectparentNode);

else{if(thislastLanding)thislastLandingdragLanding_dragOut(thislastLanding);thislastLanding=;}

}

}

dhtmlDragAndDropObjectprototypestopDrag=function(e){

dragger=windowdhtmlDragAndDrop;

if(draggerlastLanding)draggerlastLandingdragLanding_drag(draggerdragStartNodedraggerdragStartObjectdraggerlastLanding);

draggerlastLanding=;

draggerdragNodeparentNoderemoveChild(draggerdragNode);

draggerdragNode=;

draggerdragStartNode=;

draggerdragStartObject=;

documentbodyonmouseup=draggertempDOMU;

documentbodyonmousemove=draggertempDOMM;

draggertempDOMU=null;

draggertempDOMM=null;

draggerwaitDrag=;

}

</script>

<!dhtmlXTreejs>

<script>

functiondhtmlXTreeObject(htmlObjectwidthheightrootId){

if(typeof(htmlObject)!=object)

thisparentObject=documentgetElementById(htmlObject);

else

thisparentObject=htmlObject;

thismytype=tree;

thiswidth=width;

thisheight=height;

thisrootId=rootId;

thisstyle_pointer=pointer;

if(navigatorappName==MicrosoftInternetExplorer)thisstyle_pointer=hand;

thishfMode=;

thisnodeCut=;

thisXMLsource=;

thisXMLloadingWarning=;

this_globalIdStorage=newArray();

thisglobalNodeStorage=newArray();

this_globalIdStorageSize=;

thistreeLinesOn=true;

thischeckFuncHandler=;

thisopenFuncHandler=;

thisdblclickFuncHandler=;

thistscheck=false;

thistimgen=true;

thisimPath=treeGfx/;

thischeckArray=newArray(iconUnCheckAllgificonCheckAllgificonCheckGraygif);

thislineArray=newArray(linegiflinegiflinegifblankgifblankgif);

thisminusArray=newArray(minusgifminusgifminusgifminusgifminusgif);

thisplusArray=newArray(plusgifplusgifplusgifplusgifplusgif);

thisimageArray=newArray(leafgiffolderOpengiffolderClosedgif);

thiscutImg=newArray();

thiscutImage=but_cutgif;

thisdragger=newdhtmlDragAndDropObject();

lNode=newdhtmlXTreeItemObject(thisrootIdthis);

lNodechildNodes[]childNodes[]styledisplay=none;

lNodechildNodes[]childNodes[]childNodes[]className=hiddenRow;

thisallTree=this_createSelf();

thisallTreeappendChild(lNode);

thisallTreeonselectstart=newFunction(returnfalse;);

thisXMLLoader=newdtmlXMLLoaderObject(this_parseXMLTreethis);

thisdraggeraddDragLanding(thisallTreethis);

returnthis;

};

functiondhtmlXTreeItemObject(itemIditemTextparentObjecttreeObjectactionHandlermode){

lNode=;

thisacolor=;

thisscolor=;

thistr=;

thischildsCount=;

thistempDOMM=;

thistempDOMU=;

thisdragSpan=;

thisdragMove=;

thisspan=;

thiscloseble=;

thischildNodes=newArray();

thischeckstate=;

thistreeNod=treeObject;

thislabel=itemText;

thisparentObject=parentObject;

thisactionHandler=actionHandler;

thisimages=newArray(treeObjectimageArray[]treeObjectimageArray[]treeObjectimageArray[]);

thisid=treeObject_globalIdStorageAdd(itemIdthis);

if(thistreeNodcheckBoxOff)lNode=thistreeNod_createItem(thismode);

elselNode=thistreeNod_createItem(thismode);

lNodeobjBelong=this;

returnthis;

};

dhtmlXTreeObjectprototype_globalIdStorageAdd=function(itemIditemObject){

if(this_globalIdStorageFind(itemId)){d=newDate();itemId=dvalueOf()+_+itemId;returnthis_globalI

dStorageAdd(itemIditemObject);}

this_globalIdStorage[this_globalIdStorageSize]=itemId;

thisglobalNodeStorage[this_globalIdStorageSize]=itemObject;

this_globalIdStorageSize++;

returnitemId;

};

dhtmlXTreeObjectprototype_globalIdStorageSub=function(itemId){

for(vari=;i<this_globalIdStorageSize;i++)

if(this_globalIdStorage[i]==itemId)

{

this_globalIdStorage[i]=this_globalIdStorage[this_globalIdStorageSize];

thisglobalNodeStorage[i]=thisglobalNodeStorage[this_globalIdStorageSize];

this_globalIdStorageSize;

this_globalIdStorage[this_globalIdStorageSize]=;

thisglobalNodeStorage[this_globalIdStorageSize]=;

}

};

dhtmlXTreeObjectprototype_globalIdStorageFind=function(itemId){

for(vari=;i<this_globalIdStorageSize;i++)

if(this_globalIdStorage[i]==itemId)

returnthisglobalNodeStorage[i];

return;

};

dhtmlXTreeObjectprototype_drawNewTr=function(htmlObject)

{

vartr=documentcreateElement(tr);

vartd=documentcreateElement(td);

vartd=documentcreateElement(td);

tdappendChild(documentcreateTextNode());

lSpan=;tdappendChild(htmlObject);trappendChild(td);trappendChild(td);

returntr;

};

dhtmlXTreeObjectprototypeloadXMLString=function(xmlString){thisXMLLoaderloadXMLString(xmlString);};

dhtmlXTreeObjectprototypeloadXML=function(file){thisXMLLoaderloadXML(file);};

dhtmlXTreeObjectprototype_attachChildNode=function(parentObjectitemIditemTextitemActionHandlerimageimageimageoptionStrchildsurlbeforeNode){

if(beforeNode)parentObject=beforeNodeparentObject;

if(((parentObjectXMLload==)&&(thisXMLsource))&&(!thisXMLloadingWarning))

{

parentObjectXMLload=;thisloadXML(thisXMLsource+getUrlSymbol(thisXMLsource)+itemId=+escape(emId));

}

varCount=parentObjectchildsCount;

varNodes=parentObjectchildNodes;

if((!itemActionHandler)&&(thisaFunc))itemActionHandler=thisaFunc;

Nodes[Count]=newdhtmlXTreeItemObject(itemIditemTextparentObjectthisitemActionHandler);

if(image)Nodes[Count]images[]=image;

if(image)Nodes[Count]images[]=image;

if(image)Nodes[Count]images[]=image;

parentObjectchildsCount++;

vartr=this_drawNewTr(Nodes[lNode);

if(thisXMLloadingWarning)

Nodes[lNodeparentNodeparentNodestyledisplay=none;

if(optionStr){

vartempStr=optionStrsplit();

for(vari=;i<tempStrlength;i++)

{

switch(tempStr[i])

{

caseTOP:if(parentObjectchildsCount>)beforeNode=lNodechildNodes[]childNodes[]nodempreviousSibling;break;

}

};

};

if((beforeNode)&&(beforeNodetrnextSibling))

lNodechildNodes[]insertBefore(trbeforeNodetrnextSibling);

else

lNodechildNodes[]appendChild(tr);

if(thisXMLsource)if((childs)&&(childs!=))Nodes[Count]XMLload=;elseNodes[Count]XMLload=;

Nodes[Count]tr=tr;

trnodem=Nodes[Count];

if(emId==)

trchildNodes[]className=hitemIddenRow;

if(optionStr){

vartempStr=optionStrsplit();

for(vari=;i<tempStrlength;i++)

{

switch(tempStr[i])

{

caseSELECT:thisselectItem(itemIdfalse);break;

caseCALL:thisselectItem(itemIdtrue);break;

caseCHILD:Nodes[Count]XMLload=;break;

caseCHECKED:

if(thisXMLloadingWarning)

thissetCheckList+=itemId;

else

thissetCheck(itemId);

break;

caseOPEN:Nodes[Count]openMe=;break;

}

};

};

if(!thisXMLloadingWarning)

{

if(this_getOpenState(parentObject)<)

thisopenItem(parentObjectid);

if(beforeNode)

{

this_correctPlus(beforeNode);

this_correctLine(beforeNode);

}

this_correctPlus(parentObject);

this_correctLine(parentObject);

this_correctPlus(Nodes[Count]);

if(parentObjectchildsCount>=)

{

this_correctPlus(Nodes[parentObjectchildsCount]);

this_correctLine(Nodes[parentObjectchildsCount]);

}

if(parentObjectchildsCount!=)this_correctPlus(Nodes[]);

if(thistscheck)this_correctCheckStates(parentObject);

}

returnNodes[Count];

};

dhtmlXTreeObjectprototypeinsertNewItem=function(parentIditemIditemTextitemActionHandlerimageimageimageoptionStrchildsurl){

varparentObject=this_globalIdStorageFind(parentId);

if(!parentObject)return();

returnthis_attachChildNode(parentObjectitemIditemTextitemActionHandlerimageimageimageoptionStrchildsurl);

};

dhtmlXTreeObjectprototype_parseXMLTree=function(dhtmlObjectnodeparentIdlevel){

dhtmlObjectXMLloadingWarning=;

varnodeAskingCall=;

if(!node){

node=dhtmlObjectXMLLoadergetXMLTopNode(tree);

parentId=nodegetAttribute(id);

dhtmlObjectsetCheckList=;

}

for(vari=;i<nodechildNodeslength;i++)

{

if((nodechildNodes[i]nodeType==)&&(nodechildNodes[i]tagName==item))

{

varname=nodechildNodes[i]getAttribute(text);

varcId=nodechildNodes[i]getAttribute(id);

varim=nodechildNodes[i]getAttribute(im);

varim=nodechildNodes[i]getAttribute(im);

varim=nodechildNodes[i]getAttribute(im);

varaColor=nodechildNodes[i]getAttribute(aCol);

varsColor=nodechildNodes[i]getAttribute(sCol);

varchd=nodechildNodes[i]getAttribute(child);

varatop=nodechildNodes[i]getAttribute(top);

varaopen=nodechildNodes[i]getAttribute(open);

varaselect=nodechildNodes[i]getAttribute(select);

varacall=nodechildNodes[i]getAttribute(call);

varachecked=nodechildNodes[i]getAttribute(checked);

varcloseable=nodechildNodes[i]getAttribute(closeable);

varurl=nodechildNodes[i]getAttribute(url);

varzST=;

if(aselect)zST+=SELECT;

if(atop)zST+=TOP;

if(acall)nodeAskingCall=cId;

if(achecked)zST+=CHECKED;

if((aopen)&&(aopen!=))zST+=OPEN;

vartemp=dhtmlObject_globalIdStorageFind(parentId);

tempXMLload=;

dhtmlObjectinsertNewItem(parentIdcIdnameimimimzSTchdurl);

if(dhtmlObjectparserExtension)dhtmlObjectparserExtension_parseExtension(nodechildNodes[i]dhtmlObjectparserExtensioncIdparentId);

dhtmlObjectsetItemColor(cIdaColorsColor);

if((closeable==)||(closeable==))dhtmlObjectsetItemCloseable(cIdcloseable);

varzcall=dhtmlObject_parseXMLTree(dhtmlObjectnodechildNodes[i]cId);

if(zcall!=)nodeAskingCall=zcall;

}

else

if((nodechildNodes[i]nodeType==)&&(nodechildNodes[i]tagName==userdata))

{

varname=nodechildNodes[i]getAttribute(name);

if((name)&&(nodechildNodes[i]childNodes[])){

dhtmlObjectsetUserData(parentIdnamenodechildNodes[i]childNodes[]data);

};

};

};

if(!level){

dhtmlObjectlastLoadedXMLId=parentId;

dhtmlObject_redrawFrom(dhtmlObject);

dhtmlObjectXMLloadingWarning=;

varchArr=dhtmlObjectsetCheckListsplit();

for(varn=;n<chArrlength;n++)

if(chArr[n])dhtmlObjectsetCheck(chArr[n]);

if(nodeAskingCall!=)dhtmlObjectselectItem(nodeAskingCalltrue);

}

returnnodeAskingCall;

};

dhtmlXTreeObjectprototype_redrawFrom=function(dhtmlObjectitemObject){

if(!itemObject){

vartempx=dhtmlObject_globalIdStorageFind(dhtmlObjectlastLoadedXMLId);

dhtmlObjectlastLoadedXMLId=;

if(!tempx)return;

}

elsetempx=itemObject;

for(vari=;i<tempxchildsCount;i++)

{

if(!itemObject)tempxchildNodes[lNodeparentNodeparentNodestyledisplay=;

if(tempxchildNodes[i]openMe==)

for(varzy=;zy<tempxchildNodes[i]childNodeslength;zy++)

tempxchildNodes[lNodechildNodes[]childNodes[zy+]styledisplay=;

dhtmlObject_redrawFrom(dhtmlObjecttempxchildNodes[i]);

dhtmlObject_correctLine(tempxchildNodes[i]);

dhtmlObject_correctPlus(tempxchildNodes[i]);

};

dhtmlObject_correctLine(tempx);

dhtmlObject_correctPlus(tempx);

};

dhtmlXTreeObjectprototype_createSelf=function(){

vardiv=documentcreateElement(div);

divclassName=containerTableStyle;

divstylewidth=thiswidth;

divstyleheight=thisheight;

thisparentObjectappendChild(div);

returndiv;

};

dhtmlXTreeObjectprototype_xcloseAll=function(itemObject)

{

if(thisrootId!=itemObjectid)this_HideShow(itemObject);

for(vari=;i<itemObjectchildsCount;i++)

this_xcloseAll(itemObjectchildNodes[i]);

};

dhtmlXTreeObjectprototype_xopenAll=function(itemObject)

{

this_HideShow(itemObject);

for(vari=;i<itemObjectchildsCount;i++)

this_xopenAll(itemObjectchildNodes[i]);

};

dhtmlXTreeObjectprototype_correctPlus=function(itemObject){

varworkArray=thislineArray;

if((thisXMLsource)&&(!itemObjectXMLload))

{

varworkArray=thisplusArray;

lNodechildNodes[]childNodes[]childNodes[]childNodes[]src=thisimPath+itemO

bjectimages[];

}

else

try{

if(itemObjectchildsCount)

{

if(lNodechildNodes[]childNodes[]styledisplay!=none)

{

varworkArray=thisminusArray;

lNodechildNodes[]childNodes[]childNodes[]childNodes[]src=thisimPath+itemO

bjectimages[];

}

else

{

varworkArray=thisplusArray;

lNodechildNodes[]childNodes[]childNodes[]childNodes[]src=thisimPath+itemO

bjectimages[];

}

}

else

{

lNodechildNodes[]childNodes[]childNodes[]childNodes[]src=thisimPath+itemO

bjectimages[];

}

}

catch(e){};

vartempNum=;

if(!itemObjecttreeNodtreeLinesOn)lNodechildNodes[]childNodes[]childNodes[]

childNodes[]src=thisimPath+workArray[];

else{

if(itemObjectparentObject)tempNum=this_getCountStatus(itemObjectiditemObjectparentObject);

lNodechildNodes[]childNodes[]childNodes[]childNodes[]src=thisimPath+workArray[tempNum];

}

};

dhtmlXTreeObjectprototype_correctLine=function(itemObject){

varsNode=itemObjectparentObject;

try{

if(sNode)

if((this_getLineStatus(itemObjectidsNode)==)||(!thistreeLinesOn))

{

for(vari=;i<=itemObjectchildsCount;i++)

{

lNodechildNodes[]childNodes[i]childNodes[]stylebackgroundImage=;

lNodechildNodes[]childNodes[i]childNodes[]stylebackgroundRepeat=;

}

}

else

for(vari=;i<=itemObjectchildsCount;i++)

{

lNodechildNodes[]childNodes[i]childNodes[]stylebackgroundImage=url(+thisimPath+linegif);

lNodechildNodes[]childNodes[i]childNodes[]stylebackgroundRepeat=repeaty;

}

}

catch(e){};

};

dhtmlXTreeObjectprototype_getCountStatus=function(itemIditemObject){

try{

if(itemObjectchildsCount<=){if(itemObjectid==thisrootId)return;elsereturn;}

if(lNodechildNodes[]childNodes[]nodemid==itemId)if(!itemObjectid)return;elsereturn;

if(lNodechildNodes[]childNodes[itemObjectchildsCount]nodemid==itemId)return;

}

catch(e){};

return;

};

dhtmlXTreeObjectprototype_getLineStatus=function(itemIditemObject){

if(lNodechildNodes[]childNodes[itemObjectchildsCount]nodemid==itemId)return;

return;

}

dhtmlXTreeObjectprototype_HideShow=function(itemObjectmode){

if(((thisXMLsource)&&(!itemObjectXMLload))&&(!mode)){itemObjectXMLload=;thisloadXML(thisXMLsource+getUrlSymbol(thisXMLsource)+id=+escape(itemObjectid));return;};

varNodes=lNodechildNodes[]childNodes;varCount=Nodeslength;

if(Count>){

if(((Nodes[]styledisplay!=none)||(mode==))&&(mode!=))node;elsenode;

for(vari=;i<Count;i++)

Nodes[i]styledisplay=nodestyle;

}

this_correctPlus(itemObject);

}

dhtmlXTreeObjectprototype_getOpenState=function(itemObject){

varz=lNodechildNodes[]childNodes;

if(zlength<=)return;

if(z[]styledisplay!=none)return;

elsereturn;

}

dhtmlXTreeObjectprototypeonRowClick=function(){

if(thisparentObjecttreeNoddblclickFuncHandler)if(!thisparentObjecttreeNoddblclickFuncHandler(thisparentObjectid))return;

if((thisparentObjectcloseble)&&(thisparentObjectcloseble!=))

thisparentObjecttreeNod_HideShow(thisparentObject);

else

thisparentObjecttreeNod_HideShow(thisparentObject);

};

dhtmlXTreeObjectprototypeonRowClick=function(){

if(thisparentObjecttreeNodopenFuncHandler)if(!thisparentObjecttreeNodopenFuncHandler(thisparentObjectidthisparentObjecttreeNod_getOpenState(thisparentObject)))return;

if((thisparentObjectcloseble)&&(thisparentObjectcloseble!=))

thisparentObjecttreeNod_HideShow(thisparentObject);

else

thisparentObjecttreeNod_HideShow(thisparentObject);

};

dhtmlXTreeObjectprototypeonRowSelect=function(ehtmlObjectmode){

if(!htmlObject)htmlObject=this;

htmlObjectchildNodes[]className=selectedTreeRow;

if(htmlObjectparentObjectscolor)htmlObjectparentOlor=htmlObjectparentObjectscolor;

if((htmlObjectparentObjecttreeNodlastSelected)&&(htmlObjectparentObjecttreeNodlastSelected!=

htmlObject))

{

htmlObjectparentObjecttreeNodlastSelectedchildNodes[]className=standartTreeRow;

if(htmlObjectparentObjecttreeNodlastSelectedparentObjectacolor)htmlObjectparentObjecttreeNodlastSelectedparentOlor=htmlObjectparentObjecttreeNod

lastSelectedparentObjectacolor;

}

htmlObjectparentObjecttreeNodlastSelected=htmlObject;

if(!mode){if(htmlObjectparentObjectactionHandler)htmlObjectparentObjectactionHandler(htmlObjectparentObjectid);}

};

dhtmlXTreeObjectprototype_correctCheckStates=function(dhtmlObject){

if(!thistscheck)return;

if(dhtmlObjectid==thisrootId)return;

varact=lNodechildNodes[]childNodes;

varflag=;varflag=;

if(actlength<)return;

for(vari=;i<actlength;i++)

if(act[i]nodemcheckstate==)flag=;

elseif(act[i]nodemcheckstate==)flag=;

else{flag=;flag=;break;}

if((flag)&&(flag))this_setCheck(dhtmlObjectnotsure);

elseif(flag)this_setCheck(dhtmlObjectfalse);

elsethis_setCheck(dhtmlObjecttrue);

this_correctCheckStates(dhtmlObjectparentObject);

}

dhtmlXTreeObjectprototypeonCheckBoxClick=function(e){

if(thistreeNodtscheck)

if(thisparentObjectcheckstate==)thistreeNod_setSubChecked(falsethisparentObject);

elsethistreeNod_setSubChecked(truethisparentObject);

else

if(thisparentObjectcheckstate==)thistreeNod_setCheck(thisparentObjectfalse);

elsethistreeNod_setCheck(thisparentObjecttrue);

thistreeNod_correctCheckStates(thisparentObjectparentObject);

if(thistreeNodcheckFuncHandler)return(thistreeNodcheckFuncHandler(thisparentObjectidthisparentObjectcheckstate));

elsereturntrue;

};

dhtmlXTreeObjectprototype_createItem=function(acheckitemObjectmode){

vartable=documentcreateElement(table);

tablecellSpacing=;tablecellPadding=;

tableborder=;

if(thishfMode)tablestyletableLayout=fixed;

tablestylemargin=;tablestylepadding=;

vartbody=documentcreateElement(tbody);

vartr=documentcreateElement(tr);

vartd=documentcreateElement(td);

tdclassName=standartTreeImage;

varimg=documentcreateElement(img);

imgborder=;tdappendChild(img);imgstylepadding=;

vartd=documentcreateElement(td);

varinp=documentcreateElement(img);inpchecked=;inpsrc=thisimPath+thischeckArray[];inpstylewidth=px;inpstyleheight=px;

if(!acheck)inpstyledisplay=none;

tdappendChild(inp);

tdwidth=px;

inponclick=thisonCheckBoxClick;

inptreeNod=this;

inpparentObject=itemObject;

vartd=documentcreateElement(td);

tdclassName=standartTreeImage;

varimg=documentcreateElement(img);imgonmousedown=this_preventNsDrag;

imgborder=;

if(!mode)imgsrc=thisimPath+thisimageArray[];

tdappendChild(img);imgstylepadding=;imgstylemargin=;

if(thistimgen)

{imgstylewidth=px;imgstyleheight=px;}

else

{imgstylewidth=px;imgstyleheight=px;}

</script>

               

上一篇:区分JavaScript,Js,VBScript,ASP

下一篇:用Javascript实现父窗体的更新