/*--------------------------------------------------| | dTree 2.05 | www.destroydrop.com/javascript/tree/ | |---------------------------------------------------| | Copyright (c) 2002-2003 Geir Landrö | | | | This script can be used freely as long as all | | copyright messages are intact. | | | | Updated: 17.04.2003 | |--------------------------------------------------*/ function dTreeQuote(str) { return (str .replace(/\\/g, "\\\\") .replace(/\"/g, """) .replace(/\'/g, "'")); } // Node object function Node(id, pid, name, isParent, url, dataname, datatype, title, target, icon, iconOpen, open, hasUnseen) { this.isParent = isParent; 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.dataname = dataname; this.datatype = datatype; this.hasUnseen = hasUnseen; this._io = open || false; this._is = false; this._ls = false; this._hc = false; this._ai = 0; this._p; }; // Tree object function dTree(objName) { this.obj = objName; this.config = { target: null, hideRoot: false, folderLinks: true, useSelection: true, useCookies: false, useLines: true, useIcons: true, useStatusText: false, closeSameLevel: false, inOrder: false }; this.icon = { root: 'img/base.gif', folder: 'img/folder.gif', folderOpen: 'img/folderopen.gif', node: 'img/page.gif', empty: 'img/empty.gif', line: 'img/line.gif', join: 'img/join.gif', joinBottom: 'img/joinbottom.gif', plus: 'img/plus.gif', plusBottom: 'img/plusbottom.gif', minus: 'img/minus.gif', minusBottom: 'img/minusbottom.gif', nlPlus: 'img/nolines_plus.gif', nlMinus: 'img/nolines_minus.gif' }; this.aNodes = []; this.aIndent = []; this.root = new Node(-1); this.selectedNode = null; this.selectedFound = false; this.completed = false; return this; }; dTree.prototype = { obj: null, config: null, icon: null, aNodes: null, aIndent: null, root: null, selectedNode: null, selectedFound: false, completed: false, // Adds a new node to the node array add: function(id, pid, name, isParent, url, datatype, title, target, icon, iconOpen, open, hasUnseen) { this.aNodes[this.aNodes.length] = new Node(id, pid, name, isParent, url, datatype, title, target, icon, iconOpen, open, false, hasUnseen); }, // Open/close all nodes openAll: function() { this.oAll(true); }, closeAll: function() { this.oAll(false); }, // Outputs the tree to the page toString: function() { var str = '