function Node(id, pid, name, url, title, target, checked, icon, iconOpen, open ) { this.id = id; this.pid = pid; this.name = name; this.url = url; this.title = title; this.target = target; this.icon = icon; this.iconOpen = iconOpen; this._io = open || false; this._is = false; this._ls = false; this._hc = false; this._ai = 0; this._p; this._checked = checked || false; }; // Tree object function dTree(objName,filepath,showBoxLevel,showBoxOnlyLeaf) { this.config = { target : null, folderLinks : true, useSelection : true, useLines : true, useIcons : true, useStatusText : false, closeSameLevel : false, inOrder : false, check : true } this.filePath=filepath; this.showBoxLevel = showBoxLevel; this.showBoxOnlyLeaf = showBoxOnlyLeaf; this.icon = { root : this.filePath+'base.gif', folder : this.filePath+'collection.gif', folderOpen : this.filePath+'collection.gif', node : this.filePath+'collection.gif', empty : this.filePath+'empty.gif', line : this.filePath+'L4.gif', join : this.filePath+'L1.gif', joinBottom : this.filePath+'L2.gif', plus : this.filePath+'P1.gif', plusBottom : this.filePath+'P2.gif', minus : this.filePath+'M1.gif', minusBottom : this.filePath+'M2.gif', nlPlus : this.filePath+'nolines_plus.gif', nlMinus : this.filePath+'nolines_minus.gif' }; this.obj = objName; this.aNodes = []; this.aIndent = []; this.root = new Node(-1); this.selectedNode = null; this.selectedFound = false; this.completed = false; }; // Adds a new node to the node array dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) { this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open); }; // Open/close all nodes dTree.prototype.openAll = function() { this.oAll(true); }; dTree.prototype.closeAll = function() { this.oAll(false); }; // Outputs the tree to the page dTree.prototype.toString = function() { var str = '
\n'; if (document.getElementById) { str += this.addNode(this.root); } else str += 'Browser not supported.'; str += '
'; if (!this.selectedFound) this.selectedNode = null; this.completed = true; return str; }; // Creates the tree structure dTree.prototype.addNode = function(pNode) { var str = ''; var n=0; if (this.config.inOrder) n = pNode._ai; for (n; nthis.showBoxLevel||!node._hc)){//��ϲ㼶Ҫ�����ʾcheckbox if(node._checked) { str+= ''; }else { str+= ''; } } if((this.showBoxOnlyLeaf!='no')&&(this.showBoxOnlyLeaf=='leaf'&&!node._hc)){//leafֻ��Ҷ�ӽڵ���ʾcheckbox,all����ʾ if(node._checked) { str+= ''; }else { str+= ''; } //alert(str); } if((this.showBoxOnlyLeaf!='no')&&(this.showBoxOnlyLeaf=='all')){//leafֻ��Ҷ�ӽڵ���ʾcheckbox,all����ʾ if(node._checked) { str+= ''; }else { str+= ''; } } } if (this.config.useIcons) { if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node); if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node; if (this.root.id == node.pid) { node.icon = this.icon.root; node.iconOpen = this.icon.root; } str += ''; } if (node.url) { str += ''; str += node.name; if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += ''; str += ''; if (node._hc) { str += '
'; str += this.addNode(node); str += '
'; } this.aIndent.pop(); return str; }; // Adds the empty and line icons dTree.prototype.indent = function(node, nodeId) { var str = ''; if (this.root.id != node.pid) { for (var n=0; n'; (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); if (node._hc) { str += ''; } else str += ''; } return str; }; // Checks if a node has any children and if it is the last sibling dTree.prototype.setCS = function(node) { var lastId; for (var n=0; n