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

📄 organizetree.js

📁 数据库的程序驱动文件
💻 JS
字号:
function OrganizeTree(tocName,imgPath)
{   
	// Data member
	//////////////////////////////
	this.name= tocName 
	this.rootNode = 0
	this.nodesIndex = new Array
	this.nodesCounter = 0 
	this.showIcons =true
	this.isInitPage = 0;
	
	// Styles
	this.oldDescriptionStyle = null; // add liujian when you click a  node ,the color of text will changes.
	this.styleItemFolderLink=0
	this.styleItemFolderNoLink=0
	this.styleItemLink=0
	this.styleItemNoLink=0

	// Icons
	this.iconPath					= imgPath
	this.iconWidth					= "24"
	this.iconHeight					= "22"
	this.iconPlus					= this.iconPath + "/plus.gif"
	this.iconMinus					= this.iconPath + "/minus.gif"
	this.iconPlus1					= this.iconPath + "/plus1.gif"
	this.iconPlus2					= this.iconPath + "/plus2.gif"
	this.iconMinus1					= this.iconPath + "/minus1.gif"
	this.iconMinus2					= this.iconPath + "/minus2.gif"
	this.iconItem					= this.iconPath + "/item.gif"
	this.iconFolderCollapsed		= this.iconPath + "/folder.gif"
	this.iconFolderExpanded			= this.iconPath + "/folderopen.gif"
	this.iconEmpty					= this.iconPath + "/empty.gif"
	this.iconLine1					= this.iconPath + "/line1.gif"
	this.iconLine2					= this.iconPath + "/line2.gif"
	this.iconLine3					= this.iconPath + "/line3.gif"

	// Methods
	this.display		= TreeDisplay
	this.makeFolder		= TreeMakeFolder
	this.makeItem		= TreeMakeItem
	this.insertNode		= TreeInsertNode
	this.nodeClicked	= TreeNodeClicked
	this.infoClicked    = TreeInfoClicked
	this.infoDoubleClicked    = TreeInfoDoubleClicked
	this.expand 		= TreeExpand
	this.cookieView     = TreeCookieView
	this.setCookie      = TreeSetCookie
	this.getCookie      = TreeGetCookie
	this.deleteCookie   = TreeDeleteCookie
}

// TreeDisplay
// Display the Toc
function TreeDisplay(startNode,expandLevel){ 
	this.rootNode = startNode

	if (!this.showIcons){
		this.iconPlus1			= this.iconPlus
		this.iconPlus2			= this.iconPlus
		this.iconMinus			= this.iconMinus
		this.iconMinus1			= this.iconMinus
		this.iconMinus2			= this.iconMinus
		this.iconLine3			= this.iconEmpty
	} 
	this.rootNode.initialize(0, 1, '')
	this.rootNode.display() 
    this.rootNode.expand(expandLevel) 
	this.cookieView() // add liujian  
	this.isInitPage = 1; // init is finished in order to set cookie 
}

// TreeMakeFolder
// Create a folder
function TreeMakeFolder(description,info,icon,showCheckBox)
{
	newFolder = new Folder(this,description,info,icon,showCheckBox)
	return newFolder ;
}

// TreeMakeItem
// Create a item
function TreeMakeItem(description, info,icon,showCheckBox)
{   
	newItem = new Node(this,description, info,icon,showCheckBox)
	return newItem
}

// insertNode
// Insert a item
function TreeInsertNode(parentFolder, nodeToInsert)
{
	return parentFolder.addChild(nodeToInsert)
} 
// TreeExpand
function TreeExpand(maxlevel)
{
	this.rootNode.expand(maxlevel);
}

// nodeClicked
// Event
function TreeNodeClicked(nodeId)
{
	var clickedNode = this.nodesIndex[nodeId]
	clickedNode.setState(!clickedNode.isExpanded)
}

function TreeInfoClicked(info,descriptionStyle){
// alert(descriptionStyle)
   if(this.oldDescriptionStyle!=null)document.getElementById(this.oldDescriptionStyle).color = "#000000";
   document.getElementById(descriptionStyle).color = 'blue';
   this.oldDescriptionStyle = descriptionStyle;
   
 // alert(info)
   // need realize in *.jsp
  getALlInfo(info)  
}

function TreeInfoDoubleClicked(info,descriptionStyle){
// alert(descriptionStyle)
  
   
 // alert(info)
   // need realize in *.jsp
  infoDoubleClick(info)  
}
// Tree END


// cookie begin
 
 
 
function TreeGetCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf(prefix);
	if (begin <0) {  
		 return null;
	}  
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
   var result = unescape(dc.substring(begin + prefix.length, end));
   return result
}

function TreeCookieView(){
  var i ; 
  for( i = 0 ;i<this.nodesCounter-1;i++){
    var node = this.nodesIndex[i] 
    var cookieID = "cookieID"+node.id;
	var temp = TreeGetCookie(cookieID); // look for cookie value  
	if(temp!=null && temp ==1){ // if exist then open node
	  if(node.isFolder)
	     node.setState(1);
	}  
  } 
}

function TreeDeleteCookie(name) {
    var cookieID = "cookieID"+name;
	if (TreeGetCookie(cookieID)) {
		document.cookie = "cookieID"+name + "=" 
	}
}
function TreeSetCookie(name, value) {
  //  alert("setCookie="+value);
	var curCookie = "cookieID"+name + "=" + escape(value) 
	document.cookie = curCookie;
}
 
// cookie end

 

⌨️ 快捷键说明

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