能给小弟一个吗?
---------------------------------------------------------------
/************************************************************************************
*Title : treeMaker 脚本文件 (Ver 2.2)
*program : 区钊贤
*website : http://www.ouzx.com
*e-mail : [email protected]
*Date : 2003-02-22 (all right reserved)
************************************************************************************/
//----------------const value
var Tree_CHILD=-1;
var Tree_LAST=-2;
var Tree_ROOT=-3;
var Tree_FIRST=-4;
var Tree_SIBLING=-5;
//---------------------
var Tree_const_begin_folder=-1;
var Tree_const_folder=0;
var Tree_const_end_folder=1;
var Tree_const_file=2;
var Tree_LINK=3;
var Tree_SCRIPT=4;
var Tree_const_end=5;
var Tree_isNC6 = (document.getElementById && !document.all)?true:false;
var Tree_isIE = (document.all)?true:false;
if(Tree_isNC6==false&&Tree_isIE==false)
alert("本脚本不支持你的浏览器");
//---------------------------
var Tree_treeView_index=0;
var Tree_node_index=0;
//-------------------------
var Tree_treeView_array=new Array();
var Tree_node_array=new Array();
//----------------------------
function Tree_action(type,script,link,target,treeViewIndex)
{
this.type=type;
this.link=link;
this.target=target;
this.script=script;
this.treeViewIndex = treeViewIndex;
}
//---------------------------
function Tree_treeView()
{
//treeView设置
this.Indent=13;
this.useImage=this.useHint=this.useStatus=this.useTitleAsStatus
=this.showSelect=this.useTitleAsHint=true;
this.fileImg=this.folderImg1=this.folderImg2="";
this.folderClass1=this.folderClass2=this.folderClass3=
this.fileClass1=this.fileClass2=this.fileClass3="";
this.target="blank";
//--------
this.selectID=null;//选择结点的id
this.id=Tree_treeView_index;//read noly
var action=new Tree_action(0,0,0,0,Tree_treeView_index++);
this.container=new Tree_node("","","","","",action);
this.container.expand=true;
this.getRoot=function getRoot()
{
return this.container.childCount>0?
this.container.child[0]:null;
}
//----------
this.flag=false;
//-------------事件扩展函数
//expanding--->click--->expanded;
//collapsing--->click--->collapsed
this.callback_expanding=function callback_expanding(nodeID){return true;}//展开前调用的函数
this.callback_expanded=function callback_expanded(nodeID){}//展开后调用函数
this.callback_collapsing=function callback_collapsing(nodeID){return true;};//折叠前调用的函数
this.callback_collapsed=function callback_collapsed(nodeID){};//折叠后调用的函数
//----
this.callback_click=function callback_click(nodeID){//点击结点时调用的函数
return true;
}
this.callback_rightClick=function callback_rightClick(nodeID){//右键结点时调用的函数
return false;
}
//---------
Tree_treeView_array[this.id]=this;
//----
this.click=function click(nodeID)
{
var node=this.getNode(nodeID);
if(node!=null) Tree_clickNode(nodeID);
}
//------------
this.helper=function helper(node)
{
if(node.childCount==0) return;
this.expand(node.id,true);
var i=0;
while(i<=node.childCount-1)
this.helper(node.child[i++]);
}
//
this.expandAll=function expandAll()
{
this.flag=true;
var i=0;
while(i<=this.container.childCount-1)
this.helper(this.container.child[i++]);
this.flag=false;
}
//----------
this.select=function select(nodeID)
{
var node=this.getNode(nodeID);
if(node!=null)
{
Tree_selectNode(nodeID);
}
}
//----------------
this.setText=function setText(nodeID,text)
{
var node=this.getNode(nodeID);
if(node!=null)
node.setText(text);
}
//-----------------
this.getImage=function getImage(nodeID)
{
var node=this.getNode(nodeID);
if(node!=null)
return node.getImage();
return null;
}
//-------------
this.getSelect=function getSelect(){//返回选择结点
if(this.selectID!=null)
return this.getNode(this.selectID);
return null;
}
//----------
this.expand=function expand(nodeID,isExpand)
{
var node=this.getNode(nodeID);
this.flag=true;
var div=document.getElementById("Tree_expand"+nodeID);
if(node!=null)
{
if(node.expanded==isExpand)return;
if(div)div.previousSibling.onclick();
else node.expanded=isExpand;
}
this.flag=false;
}
//----------
this.clear=function clear()
{
this.container.child.length=this.container.childCount=0;
this.refresh();
}
//-----------
this.add=function add(relate_ID,nOption,nIndex,text,hint,status,img1,img2)
{
if(nOption==Tree_ROOT)
{
return this.container.addChild(nIndex,text,hint,status,img1,img2);
}
if(nOption==Tree_CHILD)
{
var parent=this.getNode(relate_ID);
if(parent==null) return null;
return parent.addChild(nIndex,text,hint,status,img1,img2);
}
if(nOption==Tree_SIBLING)
{
if(relate_ID==this.container.id) return null;
var node=this.getNode(relate_ID);
if(node==null) return null;
return node.parent.addChild(nIndex,text,hint,status,img1,img2);
}
return null;
}
//----------------
this.del=function del(id)
{
if(id==this.container.id)//do not del container
return;
var obj=this.getNode(id);
if(obj!=null)obj.parent.delChild(obj.index);
}
//--------------------------
this.getNode=function getNode(nID)
{
if(nID==this.container.id)return null;
var obj=null;
try
{
obj=Tree_node_array[nID];
if(obj!=null&&obj.id==nID)
return obj.container()==this.container?obj:null;
return null;
}
catch(e)
{
return null;
}
}
//----------------
this.refresh=function refresh(){
this.container.refresh();
}
//-------
this.isReady=function isReady(){
return document.getElementById("Tree_treeView_"+this.id)!=null;
}
}
//-----------------------------
---------------------------------------------------------------
function Tree_node(text,hint,status,img1,img2,action)
{
this.img1=typeof(img1)=="string"?img1:"";
this.img2=typeof(img2)=="string"?img2:"";
this.text=typeof(text)=="string"?text:"";
this.hint=typeof(hint)=="string"?hint:"";
this.status=typeof(status)=="string"?status:"";
//------------------
this.child = new Array();
this.id=Tree_node_index;
this.parent=null;
this.action=action;
this.expanded=false;
this.selected=false;
this.index=0;//在父结点的序号
this.childCount=0;
Tree_node_array[Tree_node_index++]=this;
//------------------
this.addChild=function addChild(index,text,hint,status,img1,img2)
{
var action=new Tree_action(0,0,0,0,this.action.treeViewIndex);
var node=new Tree_node(text,hint,status,img1,img2,action);
this.add(node,index);
return node;
}
//--------
this.getImage=function getImage(){
return document.getElementById("Tree_img_"+this.id);
}
//------------------
this.refresh=function refresh()
{
if(this.parent!=null)return;
var html="
1<div id='Tree_treeView_"+this.id+"'>";
2var div=document.getElementById("Tree_treeView_"+this.id);
3if(div==null)
4document.write(html+this.getHtml()+"</div>
");
else div.innerHTML=this.getHtml();
}
//-----------------------
this.setLink=function setLink(link,target)
{
if(this.parent==null) return;//container
this.action.type=Tree_LINK;
this.action.target=target;
this.action.link=link;
}
//-----------------------
this.setScript=function setScript(script)
{
this.action.type=Tree_SCRIPT;
this.action.script=script;
}
//---------------------
this.next=function getNext(){
if(this.parent==null ¦ ¦ this.index>=this.parent.childCount-1)
return null;
return (this.parent.child[this.index+1]);
}
//------------------------
this.prev=function getPrev(){
if(this.parent==null ¦ ¦ this.index<=0)
return null;
return (this.parent.child[this.index-1]);
}
//------------------
this.container=function container()//get container node
{
va