/*--------------------------------------------------| | dTree 2.05 | www.destroydrop.com/javascript/tree/ | |---------------------------------------------------| | Copyright (c) 2002-2003 Geir Landr:o | | | | This script can be used freely as long as all | | copyright messages are intact. | | | | Updated: 17.04.2003 | |--------------------------------------------------*/ /* This is a specially modified for DAlbum version of dTree*/ var _treeAlwaysOpen=true; if (document.getElementById && document.createElement) { var agt=navigator.userAgent.toLowerCase(); var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1); if (!is_opera6) _treeAlwaysOpen=false; } // Node object function Node(id, pid, name, url, title, target, icon, iconOpen, open, dynload) { this.dynload = dynload; 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 || _treeAlwaysOpen; 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.icondir= 'images/'; this.icon = { root : 'imgfolder.gif', folder : 'folder.gif', folderOpen : 'folderopen.gif', node : 'page.gif', empty : 'empty.gif', line : 'line.gif', join : 'join.gif', joinBottom : 'joinbottom.gif', plus : 'plus.gif', plusBottom : 'plusbottom.gif', minus : 'minus.gif', minusBottom : 'minusbottom.gif', nlPlus : 'nolines_plus.gif', nlMinus : '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, dynload) { this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open, dynload); }; // 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() { // this.icon.root = this.icondir + this.icon.root; this.icon.folder = this.icondir + this.icon.folder; this.icon.folderOpen = this.icondir + this.icon.folderOpen; this.icon.node = this.icondir + this.icon.node ; this.icon.empty = this.icondir + this.icon.empty ; this.icon.line = this.icondir + this.icon.line ; this.icon.join = this.icondir + this.icon.join ; this.icon.joinBottom = this.icondir + this.icon.joinBottom; this.icon.plus = this.icondir + this.icon.plus ; this.icon.plusBottom = this.icondir + this.icon.plusBottom; this.icon.minus = this.icondir + this.icon.minus ; this.icon.minusBottom = this.icondir + this.icon.minusBottom; this.icon.nlPlus = this.icondir + this.icon.nlPlus; this.icon.nlMinus = this.icondir + this.icon.nlMinus; 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'; } 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) { if (!_treeAlwaysOpen) { str += ''; } } else str += ''; } str+=''; return str; }; // Checks if a node has any children and if it is the last sibling dTree.prototype.setCS = function(node) { var lastId; if (node.dynload) node._hc = true; for (var n=0; n