<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JK:支持民族工业,尽量少买X货</title>
<style remark="JK_10000@yahoo.com.cn">
body{font-size:12px;}
</style>
</head>
<body >
<script language=javascript src="JKTree.js"></script>
<div style="font-size:10pt;">
<H3>JKTree性能测试</H3>
<form name=frm >
<table border=1>
<tr>
<td>
枝节点类型:
</td>
<td>
<select name=folderType >
<option value=Folder >Folder</option>
<option value=FolderCheckbox >FolderCheckbox</option>
</select>
</td>
<td>
叶节点类型:
</td>
<td><select name=fileType >
<option value=File >File</option>
<option value=FileCheckbox >FileCheckbox</option>
</select>
</td>
</tr>
<tr>
<td>
Folder01的枝节点数:
</td>
<td>
<select name=folderNum >
<option value=5 >5</option>
<option value=10 >10</option>
<option value=20 >20</option>
<option value=30 >30</option>
<option value=50 >50</option>
<option value=70 >70</option>
<option value=100 >100</option>
<option value=100 >150</option>
<option value=200 >200</option>
<option value=500 >500</option>
</select>
</td>
<td>
每枝的叶节点数
</td>
<td>
<select name=fileNum >
<option value=5 >5</option>
<option value=10 >10</option>
<option value=20 >20</option>
<option value=30 >30</option>
<option value=50 >50</option>
<option value=70 >70</option>
<option value=100 >100</option>
<option value=100 >150</option>
<option value=200 >200</option>
<option value=500 >500</option>
</select>
</td>
</tr>
<tr>
<td colspan=4 >
<input type=button value="重新生成数据"
onclick="regenerateData();">
<input type=button value="打开所有结点"
onclick="expandAll();">
</td>
</tr>
</table>
注:另有:<a href="JKTree.htm">JKTree主要功能演示</a> <br/>
注:本页面仅在IE6/FireFox1.5下测试过。其它浏览器或其它版本未经测试。<br/>
注-----:作者JK:<a href="mailTo:jk_10000@yahoo.com.cn?subject=About%20JKTree">JK_10000@yahoo.com.cn</a><br/>
<hr/>
</div>
<DIV id=treeContainerDiv onmouseover="jkTree_mouseOverInTree(event);" onmouseout="jkTree_mouseOutInTree(event);" onclick="jkTree_clickInTree(event);">
</DIV>
<script >
var folderArray=new Array();
function regenerateData(){
var folderType=document.frm.folderType.value;
var fileType=document.frm.fileType.value;
var folderNum=document.frm.folderNum.value*1;
var fileNum=document.frm.fileNum.value*1;
folderArray=new Array();
var tempAr=null;
tempAr=folderArray[""]=new Array();
tempAr.push([folderType,"Folder01","Folder01"]);
tempAr.push([folderType,"Folder02","Folder02"]);
tempAr.push([folderType,"Folder03","Folder03"]);
tempAr.push([folderType,"Folder04","Folder04"]);
tempAr.push([fileType,"File01","File01"]);
tempAr.push([fileType,"File02","File02"]);
folderArray["Folder01"]=new Array();
for(var i=0;i<folderNum;i++){
folderArray["Folder01"].push([folderType,"Folder01_"+i,"鸣鹤在阴其子和之Folder01_"+i]);
var tempAr=folderArray["Folder01_"+i]=new Array();
for(var j=0;j<fileNum;j++){
tempAr.push([fileType,"Folder01_"+i+"_"+j,"我有好爵吾与尔糜之Folder01_"+i+"_"+j]);
}
}
tempAr=folderArray["Folder02"]=new Array();
tempAr.push([fileType,"File0201","File0201"]);
tempAr=folderArray["Folder03"]=new Array();
tempAr.push([fileType,"File0301","File0301"]);
tempAr=folderArray["Folder04"]=new Array();
tempAr.push([fileType,"File0401","File0401"]);
document.getElementById("treeContainerDiv").innerHTML=jkTree_rootHtml;
jkTree_allTreeItems=new Array();
}
function expandAll(){
var d0=new Date();
var totalCount=0;
var folderCount=-1;
for(var i in folderArray) {
jkTree_showTreeItem(i);
totalCount+=folderArray[i].length;
folderCount++;
}
alert('节点数:'+totalCount+'\n枝节点数:'+folderCount+'\n耗时:'+(new Date()-d0));
}
function jkTree_getSubItems(parentItemObj) //此函数仅作示例,修改(或重载)此函数来自定义tree的节点数据类型。
{
var parentItemId=parentItemObj.id.replace(/treeItem_/ig,"");
if(parentItemId=="") return folderArray[""];
else return folderArray[parentItemId];
}
function jkTree_getItemHtml(parentItemObj,item)//此函数仅作示例,修改(或重载)此函数来自定义tree的节点HTML。
{
switch(item[0].toLowerCase()){
case "folder":
return folderJKHtml+'<A href="#" target="aaaa" onclick="jkTree_highlightLink(this);">'+item[2]+'</A></DIV><span id="tree_tree_'+item[1]+'" style="display:none" ></span>';
case "file":
return fileJKHtml+'<A href="#" target="aaaa" onclick="jkTree_highlightLink(this);">'+item[2]+'</A></DIV>';
case "foldercheckbox":
return folderJKHtml+'<input type=checkbox valign="middle" style="margin:0px;" onclick="selectAllSubCheckboxesForDemo(this,\''+item[1]+'\');" value="'+item[1]+'">'+item[2]+'</DIV><span id="tree_tree_'+item[1]+'" style="display:none" ></span>';
case "filecheckbox":
return '<input type=checkbox style="margin:0px;" name=abcdefg value="'+item[1]+'">'+item[2]+'</DIV>';
}
return "";
}
function selectAllSubCheckboxesForDemo(checkboxObj,itemId)
{
var subTreeContainer=jkTree_getSubTreeContainer(itemId);
if(!subTreeContainer) return ;
var checked=checkboxObj.checked;
var allinputs=subTreeContainer.getElementsByTagName("input");
for(var i=0;i<allinputs.length;i++){
if(allinputs[i].type=="checkbox") allinputs[i].checked=checked;
}
}
</script>
<script >
//生成tree的代码.---------------------
document.getElementById("treeContainerDiv").innerHTML=jkTree_rootHtml;
regenerateData();
jkTree_showTreeItem("");//展开根目录
</script>
</body>
</html>
评论0