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

📄 folder.js

📁 数据库的程序驱动文件
💻 JS
字号:
// Folder
// Constructor
function Folder(activeToc,description,info,icon,showCheckBox)
{   
	// Data member
	this.id = -1
	this.toc = activeToc
	this.desc = description
	this.info = info
	this.showCheckBox = showCheckBox;
	this.layer = 0
	this.iconSrc = this.toc.iconFolderExpanded
	this.iconPersoSrc = icon
	if (icon)
		this.iconSrc = this.iconPersoSrc
	this.iconImg = 0
	this.nodeImg = 0
	this.isLastNode = 0
	this.isExpanded = true
	this.isFolder = true
	this.children = new Array
	this.childrensCounter = 0

	// Methods
	this.initialize		= FolderInitialize
	this.setState		= FolderSetState
	this.addChild		= FolderAddChild
	this.createIndex	= treeCreateIndex
	this.hide			= FolderHide
	this.display		= folderDisplay
	this.draw			= FolderDraw
	this.totalHeight	= FolderTotalHeight
	this.expand			= FolderExpand 
	this.expandRec		= FolderExpandRec
}

// FolderInitialize
//
function FolderInitialize(level, lastNode, leftSide)
{   
	var i=0 
	var nc = this.childrensCounter

	this.createIndex()
	   var auxEv ="<a  style='CURSOR: hand' onclick='javascript:" + this.toc.name +".nodeClicked("+this.id+")'>"  
	   if (level>0){
		 if (lastNode){ //the last 'brother' in the children array	 
		   this.draw(leftSide + auxEv + "<img name='" + this.toc.name + "nodeIcon" + this.id + "' src='" + this.toc.iconMinus1 + "' width=" + this.toc.iconWidth + " height=" + this.toc.iconHeight + " border=0></a>",level)
		   leftSide = leftSide + "<img src='" + this.toc.iconEmpty + "' width=" + this.toc.iconWidth + " height=" + this.toc.iconHeight + ">"
		   this.isLastNode = 1
		 } else {
		   this.draw(leftSide + auxEv + "<img name='" + this.toc.name + "nodeIcon" + this.id + "' src='" + this.toc.iconMinus2 + "' width=" + this.toc.iconWidth + " height=" + this.toc.iconHeight + " border=0></a>",level)
		   leftSide = leftSide + "<img src='" + this.toc.iconLine3 + "' width=" + this.toc.iconWidth + " height=" + this.toc.iconHeight + ">"
		   this.isLastNode = 0
	    }
	  } else{
		 this.draw('',level)
	  }// end of if else  (level>0) 

	if (nc > 0)	{//if folder has a lot children 
	 level = level + 1
	 for (i=0 ; i < this.childrensCounter; i++)
	 {
	   if (i == this.childrensCounter-1) // if is last node
		 this.children[i].initialize(level, 1, leftSide)
	   else
		 this.children[i].initialize(level, 0, leftSide)
	  }
	} 	
}

// FolderDraw
//
function FolderDraw(leftSide,level)
{
	
    var sHTML = "";	
	sHTML +="<table " 	 
	sHTML +=" id='" + this.toc.name + "folder" + this.id + "' style='position:block;' " 
	sHTML +=" border=0 cellspacing=0 cellpadding=0>\n" 

	sHTML +='<tr><td>' 
	sHTML +=leftSide 
	if (this.toc.showIcons){
		sHTML +="<img name='" + this.toc.name + "folderIcon" + this.id + "' " 
		sHTML +="src='" + this.iconSrc + "' border=0>" 
	}
	sHTML +='</td><td valign=middle nowrap>' 
	 
	if(this.showCheckBox == 1){
	   sHTML +="<input name='checkboxName' type='checkbox' value='"+this.id+"' onClick='javascript:checkboxClick(\""+this.id+"\",\""+this.info+"\",\""+this.desc+"\")'>"
	}
	 
	if (level>0) //the first node click no valic
    sHTML +="<a  style='CURSOR: hand' onclick='javascript:" + this.toc.name +".infoClicked(\""+this.info+"\",\"descriptionStyle"+this.id+"\")'  onDblClick='javascript:" + this.toc.name +".infoDoubleClicked(\""+this.info+"\",\"descriptionStyle"+this.id+"\")'>"	
	sHTML +="<font id='descriptionStyle" + this.id+ "'size='2' COLOR='#000000'>" + this.desc + "</font>" 
	if (level>0)
	  sHTML +='</a>'
	sHTML +='</td></tr>' 
	sHTML +="</table>\n" 
	//alert(sHTML)
	document.write(sHTML)

	 

	 
		this.layer  = eval(this.toc.name + "folder" + this.id)
		if (this.toc.showIcons)
			this.iconImg = eval(this.toc.name + "folderIcon"+ this.id)
		if (this.id>0)
			  this.nodeImg = eval(this.toc.name + "nodeIcon" + this.id)
	 
	 
}

// FolderSetState
// Change the state of a folder
function FolderSetState(isExpanded)
{  
	if (isExpanded == this.isExpanded)
		return
	this.isExpanded = isExpanded 
	treeApplyChanges(this)
}

// treeApplyChanges
//
function treeApplyChanges(folder)
{
	var i=0
	if (folder.isExpanded){
	    folder.toc.setCookie(folder.id,1)
		if (folder.nodeImg)
			if (folder.isLastNode)
				folder.nodeImg.src = folder.toc.iconMinus1
			else
				folder.nodeImg.src = folder.toc.iconMinus2

		if (folder.iconPersoSrc)
			folder.iconImg.src =folder.iconPersoSrc
		else
			folder.iconImg.src = folder.toc.iconFolderExpanded

		for (i=0; i<folder.childrensCounter; i++)
			folder.children[i].display()
	}else { 
		if(folder.toc.isInitPage>0){ 
		    folder.toc.deleteCookie(folder.id)
		 }
		if (folder.nodeImg)
			if (folder.isLastNode)
				folder.nodeImg.src = folder.toc.iconPlus1
			else
				folder.nodeImg.src = folder.toc.iconPlus2

		if (folder.iconPersoSrc)
			folder.iconImg.src =folder.iconPersoSrc
		else
			folder.iconImg.src = folder.toc.iconFolderCollapsed

		for (i=0; i<folder.childrensCounter; i++)
			folder.children[i].hide()
	}
} 

// hide folder
//
function FolderHide()
{  
		if (this.layer.style.display == 'none')
		  return
		this.layer.style.display = 'none'
	 
	    this.setState(0)
}


// FolderAddChild
//
function FolderAddChild(childNode)
{
	this.children[this.childrensCounter] = childNode
	this.childrensCounter++
	return childNode
}

 

// FolderExpand
//
function FolderExpand(maxLevel)
{
	if (this.isExpanded)
		this.toc.nodeClicked(this.id)
	var currentLevel = 1
	if (maxLevel)
		this.expandRec(maxLevel,currentLevel)
	else
		this.expandRec(1,currentLevel)
	 	 
}

// FolderExpand
//
function FolderExpandRec(maxlevel,currentlevel)
{
	var i = 0
	this.toc.nodeClicked(this.id)
	if 	(currentlevel<maxlevel){
		currentlevel++;
		for (i=0; i < this.childrensCounter; i++){
			if (this.children[i].isFolder)
						this.children[i].expandRec(maxlevel,currentlevel)
		}
	}
}

// treeCreateIndex
//
function treeCreateIndex()
{
	this.id = this.toc.nodesCounter
	this.toc.nodesIndex[this.toc.nodesCounter] = this
	this.toc.nodesCounter++
}

// FolderTotalHeight
//
function FolderTotalHeight()
{
	var h = this.layer.clip.height
	var i = 0
	if (this.isExpanded)
		for (i=0 ; i < this.childrensCounter; i++)
			h = h + this.children[i].totalHeight()
	return h
} 

// folderDisplay
//
function folderDisplay()
{
	if (this.layer){
			this.layer.style.display = 'block'
	}
}

 

⌨️ 快捷键说明

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