|
everest79
金牌会员
一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『楼 主』:
仿TREE无限级树状html菜单生成
学习了mkd先前发布的代码,又在网上搜到一个html脚本,写出了这个
@echo off
if "%~1" == "" (call "%~f0" "%cd%"&goto :eof) else (pushd "%~1"||goto :eof)
set "str=^-^\^|^/"&&set/a sx=0,sy=0,sz=0&&set ot=%~nx1.htm
for /f "delims=:" %%i in ('findstr /b /n ":top" "%~f0"') do more +%%i "%~f0">%ot%
set/p=...................................<nul&call :subdir "%~1"
for /f "delims=:" %%x in ('findstr /b "::" "%~f0"') do echo %%x >>%ot%
echo .Done...&pause>nul&start "" "%ot%"&popd&goto :eof
:subdir
set/asx+=1,sy=sx%%4*2,sz=1/sx&&set tpath=%~1
set tpath=%tpath:\=\\%&&call set/p=%%str:~%sy%,2%%<nul
echo ss.m^("%~nx1","'%tpath%' title='Date:%~t1 %~a1'",1,%sz%^);>>%ot%
echo ss.cStart^(%sz%^);>>%ot%
for %%a in ("%~1\*") do call echo ss.m^("%%~nxa","'%tpath%' title='Date:%%~ta Size:%%~zaByte'",0^);>>%ot%
for /d %%a in ("%~1\*") do call :subdir "%%~fa"&echo ss.cEnd^(^);>>%ot%
goto :eof
:bottom
::ss.cEnd();
::ss.end();
::</script>
::</body></html>
:top
<html>
<head>
<title>Tree Menu::www.cn-dos.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type=text/css>
a {font: normal 12px 宋体; color: black; text-decoration: none; }
a:link {font: normal 12px 宋体; color: black; text-decoration: none; }
a:visited {font: normal 12px 宋体; color: black; text-decoration: none; }
a:hover {font: normal 12px 宋体; color: black; text-decoration: none; }
.icoface { border: 1px solid black; width: 9px; height: 9px; overflow: hidden; font: normal 7px 宋体; line-height: 8px; text-align: center; cursor: default; }
.line-hight { font: normal 8px 宋体; }
.newcss { font: normal 12px 宋体; color: black; text-decoration: none; }
</style>
<script language=javascript>
function s()
{
this.start=function()
{
document.writeln("<table cellpadding=1 cellspacing=0>");
}
this.end=function()
{
document.writeln("</table>");
}
this.m=function(cText,cLink,bc,bShow)
{
document.writeln("<tr><td><nobr><span class=icoface"+(bc?" onclick=menuChange(this)":"")+">"
+(bc?(bShow?"-":"+"):"<font color=#0080ff>f</font>")+"</span><span class=line-hight> </span><span class=newcss"+(bc?" onclick=menuChange(this)":"")+">"+cText+"</span></td><td> <a href="+cLink+" target=_blank><font class=line-hight>more</font></a></nobr></td></tr>");
}
this.cStart=function(bShow)
{
document.writeln("<tr style='display:"+(bShow?"block":"none")+"'><td>");
document.writeln("<table cellpadding=1 cellspacing=0 style='margin-left:12px;'>");
}
this.cEnd=function()
{
document.writeln("</table>");
document.writeln("</td></tr>");
}
}
function menuChange(obj)
{
obj=obj.parentNode.parentNode.parentNode;
obj.nextSibling.style.display=(obj.nextSibling.style.display=='none'?'block':'none');
obj.cells[0].childNodes[0].childNodes[0].innerText=(obj.nextSibling.style.display=='none'?'+':'-')
}
</script>
</head>
<body>
<script language=javascript>
var ss=new s();
ss.start(); js脚本按zh159的修改,另文件夹点击展开菜单
[ Last edited by everest79 on 2007-12-27 at 08:50 PM ]
此帖被 +12 点积分 点击查看详情 评分人:【 zh159 】 | 分数: +10 | 时间:2007-12-27 09:48 | 评分人:【 cooray 】 | 分数: +2 | 时间:2008-1-30 01:37 |
|
|
|
2007-12-27 00:17 |
|
|
zh159
金牌会员
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第
2 楼』:
改一下:
more +36 trees.cmd>trf.htm 改为 more +36 "%~nx0">trf.htm
这样可以用自定义名称的 bat 或 cmd,否则如果批处理名称不是 trees.cmd 就会出错
|
|
|
2007-12-27 09:47 |
|
|
everest79
金牌会员
一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第
3 楼』:
昨晚只是在当前目录下试了正常,今天在批处理中调用就不行了,刚改了,谢谢指正
|
|
2007-12-27 09:50 |
|
|
HAT
版主
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第
4 楼』:
收藏备用
|
|
|
2007-12-27 09:55 |
|
|
everest79
金牌会员
一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第
5 楼』:
还有个问题没有解决,当目录名为
C:\path path\new path.path
这样时路径扩展会不正常
会将最后一个不规范的路径当作文件来处理
|
|
2007-12-27 10:08 |
|
|
everest79
金牌会员
一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
|
2007-12-27 17:34 |
|
|
zh159
金牌会员
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第
7 楼』:
修改三个地方,效果会好些
Quote: | .icoface { border: 1px solid black; width: 9px; height: 9px; overflow: hidden; font: normal 9px 宋体; line-height: 8px; text-align: center; cursor: default; }
+(bc?(bShow?"-":"+"):"<font color=#0080ff>f</font>")+"</span><span class=line-hight> </span><a href="+cLink+" target=_blank>"+cText+"</a></nobr></td></tr>");
obj.cells[0].childNodes[0].childNodes[0].innerText=(obj.nextSibling.style.display=='none'?'+':'-') |
|
改为生成HTA的
@echo off
if "%~1" == "" (call "%~0" "%cd%"&goto :eof) else (pushd "%~1"||goto :eof)
set "str=^-^\^|^/"&&set/a sx=0,sy=0,sz=0&&set ot=%~nx1.hta
for /f "delims=:" %%i in ('findstr /b /n ":top" "%~f0"') do more +%%i "%~f0">%ot%
set/p=...................................<nul&call :subdir "%~1"
for /f "delims=:" %%x in ('findstr /b "::" "%~f0"') do echo %%x >>%ot%
echo .Done...&pause>nul&start %ot%&popd&goto :eof
:subdir
set/asx+=1,sy=sx%%4*2,sz=1/sx&&set tpath=%~1
set tpath=%tpath:\=\\%&&call set/p=%%str:~%sy%,2%%<nul
echo ss.m^("%~nx1","'%tpath%' title='Date:%~t1 %~a1'",1,%sz%^);>>%ot%
echo ss.cStart^(%sz%^);>>%ot%
for %%a in ("%~1\*") do call echo ss.m^("%%~nxa","'%tpath%' title='Date:%%~ta Size:%%~zaByte'",0^);>>%ot%
for /d %%a in ("%~1\*") do call :subdir "%%~fa"&echo ss.cEnd^(^);>>%ot%
goto :eof
:bottom
::ss.cEnd();
::ss.end();
::</script>
::</body></html>
:top
<html>
<head>
<title>Tree Menu::www.cn-dos.net</title>
<HTA:APPLICATION
APPLICATIONNAME="Tree Menu::www.cn-dos.net"
INNERBORDER="no"
/>
</hrad>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type=text/css>
a {font: normal 12px 宋体; color: black; text-decoration: none; }
a:link {font: normal 12px 宋体; color: black; text-decoration: none; }
a:visited {font: normal 12px 宋体; color: black; text-decoration: none; }
a:hover {font: normal 12px 宋体; color: black; text-decoration: none; }
.icoface { border: 1px solid black; width: 9px; height: 9px; overflow: hidden; font: normal 9px 宋体; line-height: 8px; text-align: center; cursor: default; }
.line-hight { font: normal 8px 宋体; }
</style>
<script language=javascript>
width = window.screen.width;
height = window.screen.height-30;
window.resizeTo(width,height);
ileft=(window.screen.width-width)/2;
itop=(window.screen.height-height)/2-15;
window.moveTo(ileft,itop);
function s()
{
this.start=function()
{
document.writeln("<table cellpadding=1 cellspacing=0>");
}
this.end=function()
{
document.writeln("</table>");
}
this.m=function(cText,cLink,bc,bShow)
{
document.writeln("<tr><td><nobr><span class=icoface"+(bc?" onclick=menuChange(this)":"")+">"
+(bc?(bShow?"-":"+"):"<font color=#0080ff>f</font>")+"</span><span class=line-hight> </span><a href="+cLink+" target=_blank>"+cText+"</a></nobr></td></tr>");
}
this.cStart=function(bShow)
{
document.writeln("<tr style='display:"+(bShow?"block":"none")+"'><td>");
document.writeln("<table cellpadding=1 cellspacing=0 style='margin-left:12px;'>");
}
this.cEnd=function()
{
document.writeln("</table>");
document.writeln("</td></tr>");
}
}
function menuChange(obj)
{
obj=obj.parentNode.parentNode.parentNode;
obj.nextSibling.style.display=(obj.nextSibling.style.display=='none'?'block':'none');
obj.cells[0].childNodes[0].childNodes[0].innerText=(obj.nextSibling.style.display=='none'?'+':'-')
}
</script>
</head>
<body bgcolor="#f0f0f0">
<script language=javascript>
var ss=new s();
ss.start(); [ Last edited by zh159 on 2007-12-27 at 07:08 PM ]
|
|
|
2007-12-27 19:07 |
|
|
everest79
金牌会员
一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第
8 楼』:
这个界面看起来好行多
能不能将路径逐级累进,这样就可以节省不少空间
还有在菜单文本上能不能实现点+号的效果,而不是超链接,将链接移到后一个固定符号上呢?
还有我在网上看到HTA标签里可以设置图标,我也么不起作用?非要用ico文件吗?
|
|
2007-12-27 19:40 |
|
|
everest79
金牌会员
一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第
9 楼』:
<HTA:APPLICATION
APPLICATIONNAME="Tree Menu::www.cn-dos.net"
INNERBORDER="no"
ICON="C:\\windows\\system32\\cmd.exe"
/> 加了一个图标,原来是任务栏的小图标,嘿嘿
this.m=function(cText,cLink,bc,bShow)
{
document.writeln("<tr><td><nobr><span class=icoface"+(bc?" onclick=menuChange(this)":"")+">"
+(bc?(bShow?"-":"+"):"<font color=#0080ff>f</font>")+"</span><span class=line-hight> </span><span class=newcss"+(bc?" onclick=menuChange(this)":"")+">"+cText+"</span></td><td> <a href="+cLink+" target=_blank><font class=line-hight>more</font></a></nobr></td></tr>");
} 将超链接移到后边,点文件夹将展开菜单
|
|
2007-12-27 20:52 |
|
|
zh159
金牌会员
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
|
2007-12-27 21:20 |
|
|
everest79
金牌会员
一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第
11 楼』:
嘿嘿,刚开始是批处理代码,被你一引诱,又到这上边了
|
|
2007-12-28 12:13 |
|
|
cooray
初级用户
积分 71
发帖 34
注册 2007-9-7
状态 离线
|
『第
12 楼』:
好东西,终于有了结点可以点的tree了~^_^
|
|
2008-1-30 01:40 |
|