?? tree.js~2~
字號:
var appPath;
var imgPath = '../common/images/';
var imgBlank = imgPath + 'empty.gif';
var imgFolderClose = imgPath + 'folder_close.gif';
var imgFolderOpen = imgPath + 'folder_open.gif';
var imgText = imgPath + 'text_node.gif';
function Node(aId, aText){
this.nodeId = aId;
this.isOpen = false;
this.nodeText = aText;
this.link = '#';
//this.title = ''; 其它屬性
//this.parentNode = null;
this.childNodes = new Array();
this.childCount = 0;
}
Node.prototype.addChild = function(aChildNode){
//aChildNode.parentNode = this;
this.childNodes[this.childCount++] = aChildNode;
}
function dispNode(aNode){
if (aNode.childCount > 0){
imgNode = aNode.isOpen ? imgFolderClose : imgFolderOpen;
document.write('<img name="' + aNode.nodeId + '" style="cursor:hand" onclick="expand(this)" src="' + imgNode + '">' + aNode.nodeText);
} else
document.write('<img src="' + imgText + '"><a href="' + aNode.link + '">' + aNode.nodeText + '</a>');
}
function expand(obj){
var divId = 'div' + obj.name;
var divObj = document.getElementById(divId);
if (divObj) with (divObj){
if (style.display == 'none'){
obj.src = imgFolderOpen;
style.display = 'block';
} else {
obj.src = imgFolderClose;
style.display = 'none';
}
}
}
function makeTree(aNode, aLevel){
if (aLevel == 0) dispNode(aNode);
document.write('<div id="div' + aNode.nodeId + '" style="display:block">');
var tmpNode;
var imgNode;
for (var i=0; i < aNode.childCount; i++){
tmpNode = aNode.childNodes[i];
for (var j=0; j <= aLevel; j++)
document.write('<img src="' + imgBlank + '">');
dispNode(tmpNode);
document.write('<br>');
if (tmpNode.childCount > 0) makeTree(tmpNode, aLevel+1);
}
document.write('</div>');
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -