images/Tree.js

(完整代码) 710B

function Tree(rootNode) {
	var $ = this;
	this.root = rootNode;
	
	this.show = function(container) {
		$.update($.root);
		this.root.expand();
		
		if(container.tagName)
			container.appendChild($.root.container);
		else if(typeof container == "string")
			document.getElementById(container).appendChild($.root.container);
	}
	
	this.update = function(parent) {
		parent.indent();
		for (var i = 0; i < parent.children.length; i++) {
			parent.children[i].level = parent.level + 1;
			for (var j = 0; j < parent.ancestor.length; j++) {
				parent.children[i].ancestor.push(parent.ancestor[j]);
			}
			parent.children[i].ancestor.push(parent);
			$.update(parent.children[i]);
		}
	}
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。