-澳门凯发
// node object
function node(id, pid, name, url, title, target, 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;
};
// tree object
function dtree(objname) {
this.config = {
target : null,
folderlinks : true,
useselection : true,
usecookies : true,
uselines : true,
useicons : true,
usestatustext : false,
closesamelevel : false,
inorder : false
}
this.icon = {
root : 'inc/dtree/img/base.gif',
folder : 'inc/dtree/img/folder.gif',
folderopen : 'inc/dtree/img/folderopen.gif',
node : 'inc/dtree/img/page.gif',
empty : 'inc/dtree/img/empty.gif',
line : 'inc/dtree/img/line.gif',
join : 'inc/dtree/img/join.gif',
joinbottom : 'inc/dtree/img/joinbottom.gif',
plus : 'inc/dtree/img/plus.gif',
plusbottom : 'inc/dtree/img/plusbottom.gif',
minus : 'inc/dtree/img/minus.gif',
minusbottom : 'inc/dtree/img/minusbottom.gif',
nlplus : 'inc/dtree/img/nolines_plus.gif',
nlminus : 'inc/dtree/img/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) {
if (this.config.usecookies) this.selectednode = this.getselected();
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; n';
}
if (node.url) {
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