⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eqtree.js

📁 eq最新版。。。。辕马..................
💻 JS
字号:


function TreeView(obj){
	this.obj=obj;
	this.root=new node(0);
	this.nodes=[]
	this.currentNode=null;
	this.html=""
	this.config={

		blank		:'┣━',
		line		:'┣━'
	}
	for(i in this.config){var tem=this.config[i];this.config[i]=new Image();this.config[i].txt=tem}
}

function node(id,pid,txt){
	this.id=id
	this.pid=pid
	this.txt=txt
	this.indent=""
	this.open=false;
	this.lastNode=false;
	this.hasNode=false
}


TreeView.prototype.add=function(id,pid,txt){
	var itemTxt=txt?txt:"New Item"
	this.nodes[this.nodes.length]=new node(id,pid,itemTxt)
}

TreeView.prototype.DrawTree=function(pNode){
	var str=""
	for(var i=0;i<this.nodes.length;i++){
		if(this.nodes[i].pid==pNode.id){
			str+=this.DrawNode(this.nodes[i].id,i)
		}
	}
	return str
}

TreeView.prototype.ChkPro=function(pNode){
	var last;
	for(var n=0;n<this.nodes.length;n++){
		if(this.nodes[n].pid==pNode.id)pNode.hasNode=true;
		if (this.nodes[n].pid == pNode.pid) last= this.nodes[n].id;
	}
	if (last==pNode.id) pNode.lastNode = true;
}

TreeView.prototype.DrawNode=function(id,nid){
	var str=""
	var select_ed = ""
	var nNode=this.nodes[nid]
	this.DrawLine(nNode,nNode)
	if(nNode.hasNode)
	nNode.indent+=(nNode.hasNode?"":"")
	if (select_value==id){select_ed = "selected"}else{select_ed = "";}
	str+="<option value="+id+" "+select_ed+">"+nNode.indent+this.DrawLink(nid)+"</option>"
	if(nNode.hasNode){
	str+=this.DrawTree(nNode)
	}
	return str;
}


TreeView.prototype.DrawLine=function(nNode,tem){
	for(var i=1;i<this.nodes.length;i++){
		if(this.nodes[i].id==tem.pid){
		nNode.indent=(this.nodes[i].lastNode?this.config.blank.txt:this.config.line.txt)+nNode.indent
		this.DrawLine(nNode,this.nodes[i])
		}
	}
}
TreeView.prototype.DrawLink=function(nid){
	var nNode=this.nodes[nid]
	return nNode.txt
}

TreeView.prototype.toString=function(){
	//var str=""
	var	str="<option value="+0+">频道首页</option>"
	for(var i=0;i<this.nodes.length;i++)this.ChkPro(this.nodes[i])
	str+=this.DrawTree(this.root)
	return str
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -