找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 14968|回复: 2

笨狼代码大管家.hta

[复制链接]
发表于 2011-9-7 12:46:31 | 显示全部楼层 |阅读模式
另存为“笨狼代码大管家.hta”
用于查看、整理、修改、阅读各类脚本代码工具
  1. <HTML>
  2. <HEAD>
  3. <TITLE>笨狼代码大管家</TITLE>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  5. <style>
  6. body
  7. {
  8.         font-size:12;
  9.         BACKGROUND: #DADADA;
  10.         margin-left:5;
  11.         overflow:visible;
  12. }

  13. .folder
  14. {
  15.        
  16.         font-size:18;
  17.         cursor:hand;
  18. }
  19. .folderIcon
  20. {
  21.         color:navy;
  22.         font-family:wingdings;
  23.         font-size:18;
  24.         cursor:hand;
  25. }
  26. .file
  27. {
  28.         color:navy;       
  29.         font-size:18;
  30.         cursor:hand;
  31.         height:21;
  32. }
  33. .fileIcon
  34. {
  35.         color:navy;
  36.         font-family:wingdings;
  37.         font-size:18;
  38.         cursor:hand;
  39.         height:21;
  40.         display:inline;
  41. }
  42. input
  43. {
  44.         width:20;
  45.         overflow:visible;
  46.         border:1px solid lightblue;
  47.         background-color:#cccccc;
  48.         cursor:text;       
  49. }
  50. button
  51. {
  52.         border:1px solid  gray;       
  53.         width:60;       
  54.         margin-left:2;
  55.         cursor:hand;
  56.         font-size:12;
  57.         filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#eaeaff', endColorStr='#618fff', gradientType='0');
  58. }
  59. textarea
  60. {
  61.         font-family:Verdana;
  62.         font-size:12px;
  63.         overflow-x:visible;
  64.         overflow-y:scroll;
  65.                 margin-left:40;            
  66. }

  67. #frmTree
  68. {
  69.         WIDTH:200px;
  70.         height:630;
  71.         MARGIN: 0px;
  72.         PADDING: 0px;       
  73.         overflow:scroll;
  74.         overflow-x:scroll;
  75.         MARGIN-right:10;
  76. }
  77.        
  78. #frmSeach
  79. {
  80.         WIDTH:200px;
  81.         height:630;
  82.         MARGIN: 0px;
  83.         PADDING: 0px;       
  84.         overflow:scroll;
  85.         MARGIN-right:10;       
  86. }

  87. #hide_control
  88. {
  89.         POSITION: absolute;
  90.         LEFT:213px;
  91.         TOP:43px;
  92.         WIDTH:10px;
  93.         height:630;       
  94.         BACKGROUND: #DADADA;
  95.         padding-top:300;
  96.         cursor:e-resize;
  97.         border:1 solid gray;
  98.         z-index:100;
  99. }
  100. #frmTop
  101. {
  102.         width:100%;
  103.         height:20;
  104. }               
  105. #txtFrm
  106. {
  107.         POSITION: absolute;
  108.         LEFT:230px;
  109.         TOP:50px;
  110.         WIDTH:100%;
  111.         MARGIN-left: -20px;
  112.         PADDING: 0px;
  113.         BACKGROUND: #DADADA;
  114. }
  115. #txtRead
  116. {
  117.         display:none;
  118.         position:absolute;
  119.         color:red;
  120.         font-size:18 px;
  121.         top:0;
  122.         left:0;
  123.         background-color:black;
  124.         z-index:1000;
  125. }

  126. #tab1
  127. {
  128.         border:1 solid  ;
  129.         cursor:hand;
  130. }
  131.   #tab2
  132. {
  133.         border:1 solid  ;
  134.         cursor:hand;
  135.         BACKGROUND: gray;
  136.         margin-right:200;
  137. }

  138. </style>


  139. </HEAD>
  140. <BODY onselectstart="vbs:selectControl" onkeydown="vbs:shortCut">

  141. <div id="frmTop">
  142.         <span id="tab1" onclick="vbs:showMe me"> &nbsp;目 录 </span>
  143.         <span id="tab2" onclick="vbs:showMe me" > &nbsp;搜 索 </span>
  144.                 标题:<input id="articleTitle" style="width:100" readonly/>
  145.         <button id="browse" onclick="vbs:browseMe" >预览</button>                       
  146.         <button id="saveButton" onclick="vbs:saveFile" >保存</button>
  147.         <button id="browse" onclick="vbs:createFile" >新建</button>       
  148.         <button id="format" onclick="vbs:formatXML">格式化XML</button>       
  149.         <button id="test" onclick="vbs:read">阅读模式</button>       
  150.         <button id="test" onclick="vbs:showHelp">说明</button>       
  151.         行&nbsp;<span id="Ln">1</span><hr/>
  152. </div>
  153. <div  id="frmTree" onclick="vbs:f_Click" onkeydown="vbs:deletFile" >

  154.         <div id="tree" style='margin-left:0;color:navy;font-size:12;cursor:hand;' ></div>
  155. </div>

  156. <div  id="frmSeach" onclick="vbs:f_Click" >

  157.         <hr/>
  158.         <div id="list" style='margin-left:0' onkeydown="deletFile">
  159.         <input id="searchKey" style="width:100" onkeypress="vbs:searchPress"/>       
  160.         <button onclick="vbs:seachFile" id="searchButton">查找</button><br/>
  161.                 <div id="seachList" style='margin-left:0' >搜索结果</div>
  162.         </div>
  163. </div>

  164. <input type="button"  id="hide_control" onmousedown="vbs:beginDrag" onmouseup="vbs:upHandler"  bgcolor="#eeeeee"/>
  165. <div valign="top" id="txtFrm">

  166.         <textarea id="txt"   onkeydown='vbs:TabTxt' onclick="vbs:showLn"  ></textarea>       
  167. </div>
  168. <div valign="top" id="txtRead" >

  169.        
  170.         <button  onclick='vbs:closeRead' >关闭</button>
  171.         <br/>
  172.          <iframe id='ifrm' frameborder=0 width="101%"  height="1000" SCROLLING="no" ></iframe>
  173. </div>



  174. <SCRIPT LANGUAGE="vbscript">


  175. '**************************
  176. '*****超级大笨狼***********
  177. '**************************
  178.         on error resume next
  179.         window.resizeTo window.screen.availWidth,window.screen.availHeight
  180.         window.moveTo 0,0
  181.         frmTree.style.height = cint(window.screen.availHeight )-70
  182.         hide_control.style.height = cint(window.screen.availHeight * 0.98)+5
  183.         txt.style.height = cint(window.screen.availHeight )-70
  184.         txt.style.width = cint(window.screen.availWidth - 250)
  185.         'txt.style.width = window.screen.availWidth - px2Int(txtFrm.style.left) -20
  186.        
  187.         Set fso = CreateObject("Scripting.FileSystemObject")
  188.         dim thisFileDir'定义本文件绝对路径
  189.         dim thisFileName'定义本文件名
  190.         dim thisFileFolder'定义本文件夹路径               

  191.        
  192.         thisFileDir = replace(window.location.href,"file:///","")
  193.         thisFileDir = unescape(replace(thisFileDir,"/",""))         
  194.         thisFileName = LastOne(thisFileDir,"")       
  195.         thisFileFolder=getFolderDir(thisFileDir)
  196.         tree.title = thisFileFolder
  197.        
  198.         dim currentDir'当前路径
  199.         dim currentFile'当前文件
  200.         dim currentDiv'当前DIV对象       
  201.         dim currentSpan'当前Span对象       
  202.         dim delatX
  203.         dim dragAble:dragAble = false       
  204.         dim Dtitle
  205.        
  206.         Dtitle=document.title

  207.         currentDir = thisFileFolder               
  208.         set currentDiv = tree
  209.         tree.innerText =  getTxtName(thisFileName)       
  210.        
  211.         showMe tab1
  212.         showFolder tree
  213.        
  214. sub read
  215.         txtRead.style.display="block"
  216.         txtRead.style.border="1px solid red"         
  217.          
  218.           
  219.          HTML="<marquee id= SCROLLAMOUNT='4' SCROLLDELAY='1'  direction='up' height=' " & window.screen.availHeight-80  & "'>"
  220.          HTML=  HTML & "<xmp style='word-wrap:break-word;line-height:60px ;' >" &  txt.value & "</xmp></marquee>"  
  221.         ifrm.document.body.innerHTML= HTML
  222.         ifrm.document.body.style.backgroundColor = "#000000"
  223.         ifrm.document.body.style.fontSize="40"         
  224.         ifrm.document.body.style.color="red"
  225.         ifrm.document.body.style.textDecoration="underline"
  226.         set marquee=ifrm.document.body.getElementsByTagName("marquee")(0)
  227.         marquee.onmousemove=getRef("setMarquee")
  228. end sub




  229. sub setMarquee
  230.         set m=ifrm.document.body.getElementsByTagName("marquee")(0)
  231.         pos=  ifrm.window.event.clientY
  232.         total=  ifrm.window.screen.availHeight                  
  233.         if not isnumeric(pos) then exit sub
  234.         if pos >total*2/5  and pos< total*3/5 then
  235.                 m.stop  
  236.                  
  237.         else
  238.                 m.start                 
  239.         end if
  240.         if  pos< total*2/5 then        
  241.                 m.direction="down"   
  242.         else
  243.                 m.direction="up"          
  244.         end if

  245.         if  pos >total/5  and pos< total*4/5 then
  246.                 m.scrollAmount=1
  247.         else
  248.                 m.scrollAmount=int(abs((pos-total/2)/20-8))
  249.         end if
  250.          
  251. end sub

  252. sub closeRead
  253.          txtRead.style.display="none"
  254.          
  255. end sub

  256. sub showLn
  257.         Ln.innerText = cint((window.event.offsetY-2)/15)+1       
  258.        
  259. end sub

  260. sub txt_onscroll
  261.         frmTop.scrollIntoView
  262. end sub       

  263. sub formatXML()         
  264.         set doc = createobject("MSXML2.DOMDocument")
  265.         if doc.loadXML(txt.value) then
  266.                 Dim rdr, wrt
  267.                 set wrt = createobject("MSXML2.MXXMLWriter")
  268.                 set rdr = createobject("MSXML2.SAXXMLReader")                
  269.                 wrt.indent = True
  270.                 Set rdr.contentHandler = wrt               
  271.                 rdr.parse(txt.value)
  272.                 txt.value = wrt.output
  273.         else
  274.                 alert("XML格式不正确,请确保Well-Formed!")
  275.         end if         
  276. end sub



  277. sub shortCut
  278.    
  279.         if window.event.keyCode=83 and window.event.ctrlKey  then
  280.                 if currentFile<>"" then saveFile
  281.                 window.event.cancelBubble = true
  282.                 window.event.returnValue = false               
  283.         end if
  284.         if window.event.keyCode=66 and window.event.ctrlKey  then
  285.                 browseMe
  286.                 window.event.cancelBubble = true
  287.                 window.event.returnValue = false
  288.         end if
  289.          
  290.         if window.event.keyCode=78 and window.event.ctrlKey  then
  291.                 createFile
  292.                 window.event.cancelBubble = true
  293.                 window.event.returnValue = false
  294.         end if
  295.        
  296. end sub         
  297. sub browseMe       
  298.         dim win
  299.         set win=window.open(currentFile)
  300.         'win.document.write txt.value
  301. end sub

  302. sub createFile
  303.         '点创建按钮,真的创建了.
  304.         if vartype(currentSpan)<>0 then currentSpan.style.color = "navy"               
  305.         if currentDir ="" then
  306.                 '如果点到了文件
  307.                 currentDir=getFolderDir(currentFile)
  308.         else
  309.                 '点到了文件夹
  310.                 dim n                               
  311.                 set n=currentDiv.nextSibling       
  312.                 do                        
  313.                         if vartype(n) =9 then  exit do       
  314.                         if left(n.title,len(currentDir)) <> currentDir then exit do
  315.                         set  currentDiv        =n                        
  316.                         set n=n.nextSibling                                               
  317.                 loop
  318.         end if
  319.         dim re,newFile,s,f
  320.        
  321.         set re = new RegExp       
  322.         re.Pattern = "[^\d]"
  323.         re.Global=true
  324.         newFile = currentDir & "新收藏" & re.Replace(mid(cstr(now()),3),"") & ".txt"       
  325.         currentFile=newFile'新建文件是当前文件       
  326.         '构造innerHTML
  327.         s =  "<div class='file' title='" & newFile                  
  328.         s = s & "'        style='margin-left:"
  329.         if currentDiv.className = "file" then
  330.                 s = s  &  currentDiv.style.marginLeft & ";' >&nbsp;"
  331.         else
  332.                 s = s  &  px2Int(currentDiv.style.marginLeft) + 8 & ";' >&nbsp;"
  333.         end if
  334.         s = s  &  "<span class='fileIcon'>2" & "</span>"
  335.         s = s  &  "<input value='"       
  336.         s = s &  getTxtName(lastOne(newFile,"")) & "' title='" & getTxtName(lastOne(newFile,"")) & "' onchange='vbs:reName me' />"                                 
  337.         s = s & "</div>"
  338.         '插入innerHTML
  339.         currentDiv.insertAdjacentHTML "AfterEnd",s
  340.        
  341.         articleTitle.value = getTxtName(lastOne(newFile,""))
  342.         txt.value = ""
  343.         currentDir = ""
  344.         set currentDiv = currentDiv.nextSibling
  345.         set currentSpan = currentDiv.getElementsByTagName("SPAN")(0)
  346.         currentSpan.style.color = "red"       
  347.         '创建文件
  348.         set f=fso.CreateTextFile(newFile)
  349.         f.close
  350. end sub
  351.        
  352. function getFolderDir(fullDir)
  353. '输入得到全路径,得到文件夹路径
  354.         s=LastOne(fullDir,"")
  355.         getFolderDir = left(fullDir,len(fullDir)-len(s))
  356. end function

  357. sub saveFile
  358. '保存对文件的修改         
  359.    Dim  f, st
  360.    set f= fso.GetFile(currentFile)  
  361.    If f.attributes and 1 Then
  362.                 if        window.confirm("该文件属性为只读,是否改变其属性并保存修改?") then f.attributes = f.attributes - 1
  363.         end if
  364.    Set st = fso.OpenTextFile(currentFile, 2, True)   
  365.    
  366.    st.Write txt.value
  367.    st.close
  368. end sub




  369. sub deletFile
  370. '删除文件
  371. dim  n         
  372.         if window.event.keyCode =46 and window.event.srcElement.tagName<>"INPUT"  then       
  373.        
  374.                 if currentFile<>""  then
  375.                         if currentFile = thisFileDir   then
  376.                                 alert "不允许删除本文件!"
  377.                                 exit sub
  378.                         end if
  379.                         if fso.FileExists(currentFile)  then
  380.                                 fso.deletefile currentFile,true
  381.                                 currentDiv.parentElement.removeChild currentDiv       
  382.                                 txt.value = ""
  383.                                 currentFile = ""
  384.                                 articleTitle.value = ""
  385.                         end if               
  386.                 end if
  387.                
  388.                 if currentDir<>""   then
  389.                         if currentDir = thisFileFolder   then
  390.                                 alert "不允许删除根目录!"
  391.                                 exit sub
  392.                         end if                                       
  393.                         set n = currentDiv.nextSibling
  394.                                         if window.confirm( currentDir & vbcrlf & "这个文件夹有子文件,你要删除全部子文件吗?") then
  395.                                                 do
  396.                                                         if vartype(n) =9 then  exit do  
  397.                                                         if px2Int(n.style.marginLeft) <= px2Int(currentDiv.style.marginLeft)   then exit do                                                        
  398.                                                                 n.parentElement.removeChild n                                                               
  399.                                                         set n=currentDiv.nextSibling                               
  400.                                                 loop                                       
  401.                                                                                        
  402.                                                 if  fso.FolderExists(currentDir)  then fso.DeleteFolder left(currentDir,len(currentDir)-1)
  403.                                                 currentDiv.parentElement.removeChild currentDiv                                                                                                               
  404.                                         end if
  405.                 end if
  406.                
  407.         end if       
  408. end sub



  409. sub showMe(obj)
  410.         if obj.id ="tab1" then
  411.                 tab2.style.backgroundColor="gray"
  412.                 tab1.style.backgroundColor="#DADADA"
  413.                 frmSeach.style.display="none"  
  414.                 frmTree.style.display=""
  415.         else
  416.                 tab1.style.backgroundColor="gray"
  417.                 tab2.style.backgroundColor="#DADADA"
  418.                 frmSeach.style.display=""
  419.                 frmTree.style.display="none"  
  420.         end if

  421. end sub

  422. sub beginDrag
  423. '开始拖拽       
  424.         delatX=window.event.clientX - px2Int(hide_control.currentStyle.left)       
  425.         document.attachEvent "onmousemove",getRef("moveHandler")       
  426.         dragAble = true       
  427.         window.event.cancelBubble = true       
  428. end sub

  429. sub moveHandler
  430. '移动绑定事件
  431.         if not dragAble then exit sub       
  432.         dim x
  433.         x = window.event.clientX - delatX
  434.         hide_control.style.left= x & "px"
  435.         txtFrm.style.left=( x + 20) & "px"       
  436.         txt.style.width = window.screen.availWidth - px2Int(txtFrm.style.left) -20
  437.         window.event.cancelBubble=true
  438. end sub

  439. sub upHandler
  440. '放开绑定事件       
  441.         document.detachEvent "onmousemove",getRef("moveHandler")
  442.         dim x
  443.         x = window.event.clientX - delatX
  444.        
  445.         if px2Int(hide_control.style.left)>205 then
  446.          frmTree.style.width = abs( px2Int(hide_control.style.left)-10) & "px"       
  447.          frmSeach.style.width = abs( px2Int(hide_control.style.left)-10) & "px"
  448.          else
  449.          frmTree.style.width = "200px"       
  450.          frmSeach.style.width = "200px"
  451.         end if

  452.        

  453.         dragAble = false               
  454.         window.event.cancelBubble=true       
  455. end sub

  456. function getTxtName(fullName)
  457. '去掉文件名后缀
  458.         dim s:s=lastOne(fullName,".")         
  459.         getTxtName = left(fullName ,len(fullName)-len(s)-1)
  460. end function


  461. sub reName(obj)
  462.         '改名
  463.         dim Arr,a
  464.         Arr=array("/","",":","*","?",chr(34),"|","<",">")
  465.         for each a in Arr
  466.                 if instr(obj.value,a) >0 then
  467.                         alert "命名不能含有/\:*?" & chr(34) &  "|<>其中的一个"
  468.                         obj.focus
  469.                         exit sub
  470.                  end if
  471.         next       
  472.         dim oldName,newName,oldPath,oldType
  473.         oldName = obj.parentElement.title
  474.         oldPath = getFolderDir(oldName)
  475.         oldType = lastOne(oldName,".")
  476.         newName = oldPath & obj.value & "." & oldType       
  477.         Set f = fso.GetFile(oldName)
  478.         f.copy newName
  479.                 currentFile = newName
  480.         f.delete True
  481.         obj.parentElement.title = newName
  482.         articleTitle.value = getTxtName(lastOne(newName,""))
  483. end sub

  484. Function LastOne(Str,splitStr)
  485. '输入字符和分隔符,得到最后一部分
  486.         LastOne = right(Str,len(Str)-InStrRev(Str,splitStr))
  487. End Function

  488. sub  selectControl
  489. '控制页面选择的状态
  490.         if window.event.srcElement.tagName<>"INPUT" and window.event.srcElement.tagName<>"TEXTAREA"  then
  491.                 document.selection.clear
  492.         end if
  493. end sub

  494. function isTXT(fileNameStr)
  495. '判断是否是文本类型的文件       
  496.         dim s,Arr,a,returnValue
  497.         returnValue = false
  498.         s=lcase(LastOne(fileNameStr,"."))
  499.         Arr=array("txt","sql","htm","html","asp","csv","aspx","xml","js","vbs","ini","bat","css","htc","hta","xsl","xslt","lrc","vb","cs","cx","asa","aspx","asax","config","shtml","stm","cpp","c","cxx","h","hpp","rc","pl","pm","cgi","php3","php","java","jsp","tpl","wsh","sgf","xsd","udl","asmx","inc","cmd")
  500.         for each a in Arr
  501.                 if a=s then
  502.                         returnValue =true
  503.                         exit for
  504.                 end if
  505.         next
  506.         isTXT = returnValue
  507. end function

  508. sub showFolder(obj)
  509.             dim  folderspec :folderspec = obj.title
  510.             obj.setAttribute "parsed",true          
  511.                 if not fso.FolderExists(folderspec) then
  512.                         alert folderspec & "该文件夹不存在,也许是被移动了,所以刷新一下本程序"
  513.                         window.location.reload
  514.                 exit sub
  515.                 end if
  516.                 dim f, f1, sf,sf1,i,s,fName
  517.                 set f=fso.GetFolder(folderspec)        
  518.                 set sf=f.Subfolders
  519.                 re = re &   f.name & ""   
  520.                 s=""           
  521.                 for each sf1 in sf
  522.                         s =  s & "<div class='folder' title='" & sf1.path & "\' style='margin-left:" & cint(replace(obj.style.marginLeft,"px","")) + 8 & ";'>"
  523.                         s =  s & "<span class='folderIcon'>0" & "</span><input value='" & sf1.name & "' readonly style='cursor:hand;'/></div>"                                         
  524.                 next
  525.                
  526.                 For Each f1 in f.Files
  527.                         if isTXT(f1.name)  then                                  
  528.                                 s =  s & "<div class='file' title='" &  f1.path                          
  529.                                 s = s & "'        style='margin-left:"
  530.                                 s = s  &  px2Int(obj.style.marginLeft) + 8 & ";' >&nbsp;"
  531.                                 s = s  &  "<span class='fileIcon'>2" & "</span>"
  532.                                 s = s  &  "<input value='"
  533.                                 fName = getTxtName(f1.name)
  534.                                 s = s & fName & "' title='" & fName & "' onchange='vbs:reName me' />"                                 
  535.                                 s = s & "</div>"
  536.                         end if
  537.                 Next       
  538.                  obj.insertAdjacentHTML "AfterEnd",s                  
  539. end sub



  540. function px2Int(px)
  541.         px2Int = cint(replace(px,"px",""))
  542. end function



  543. sub f_Click()
  544.         dim obj,d,f,state
  545.         set obj = window.event.srcElement
  546.         if obj.id="searchKey" then exit sub
  547.         if  obj.tagName<>"SPAN" and obj.tagName<>"INPUT"  then exit sub
  548.         set currentDiv = obj.parentElement       
  549.         set obj = currentDiv.getElementsByTagName("SPAN")(0)
  550.          window.event.cancelBubble = true
  551.         select case obj.className
  552.                 case  "folderIcon"  
  553.                         '点到了文件夹       
  554.                         if vartype(currentSpan)=8 then
  555.                                  currentSpan.style.color = "navy"
  556.                         end if
  557.                         set currentSpan = obj               
  558.                         state = abs(cint(obj.innerHTML)  -1)
  559.                         obj.innerHTML = state
  560.                         obj.style.color="red"
  561.                         set d = obj.parentElement                       
  562.                         currentDir = d.title
  563.                         currentFile = ""
  564.                         if d.getAttribute("parsed")=true then
  565.                                 '合拢
  566.                                          
  567.                                 fold d,state                         
  568.                         else
  569.                                 '解析       
  570.                                 showFolder d          
  571.                         end if
  572.                        
  573.                        
  574.                 case  "fileIcon"  
  575.                         '点到了文件,在textArea里面载入文本文件
  576.                        
  577.                         if vartype(currentSpan)=8 then
  578.                                  currentSpan.style.color = "navy"
  579.                         end if
  580.                         set currentSpan = obj
  581.                         obj.style.color="red"
  582.                         readText obj.parentElement.title
  583.                         currentDir = ""
  584.                         currentFile = obj.parentElement.title
  585.                        
  586.         end select       
  587. end sub       

  588. sub fold(o,stateOpen)        '合拢       
  589.         dim n
  590.         set n=o.nextSibling       
  591.         do
  592.                 if vartype(n) =9 then  exit do                
  593.                 if px2Int(n.style.marginLeft) <= px2Int(o.style.marginLeft)   then exit do          
  594.                 if stateOpen=1 then n.style.display="" else  n.style.display="none"       
  595.                 set n=n.nextSibling                       
  596.         loop       
  597. end sub


  598. sub readText(filePath)  
  599.         Dim f,fName
  600.        
  601.         if not fso.FileExists(filePath) then
  602.                 alert filePath & vbcrlf & "该文件不存在,也许是被移动了,所以刷新一下本程序"
  603.                 window.location.reload
  604.                 exit sub
  605.         end if
  606.                
  607.         'TXT已经加载的当前文件不再加载.
  608.        
  609.         if filePath = currentFile then exit sub
  610.         txt.value = ""
  611.         Set f = fso.OpenTextFile(filePath, 1, true)
  612.                 if not f.AtEndOfStream  then
  613.                         txt.value = f.readAll
  614.                  else
  615.                         txt.value = ""
  616.                  end if               
  617.                 fName = lastOne(filePath,"")               
  618.                 articleTitle.value =  getTxtName(fName)                       
  619.         f.Close
  620.         Ln.innerText = 1
  621. End sub

  622. sub TabTxt()
  623.         '支持tab键的文本框
  624.         if  window.event.keyCode=38  then
  625.                 if cint(Ln.innerText) >1 then Ln.innerText =  cint(Ln.innerText)-1
  626.         end if
  627.         if window.event.keyCode=40 then
  628.                 Ln.innerText =  cint(Ln.innerText)+1         
  629.                        
  630.         end if
  631.        
  632.         if window.event.keyCode<> 9 then exit sub       
  633.         dim sel,mytext       
  634.         set sel = document.selection.createRange()
  635.          'txt.createTextRange
  636.         mytext = sel.text
  637.         if len(mytext)=0   then
  638.                 sel.text =string(4," ")
  639.                 window.event.cancelBubble = true
  640.                 window.event.returnValue = false               
  641.                 exit sub
  642.         end if
  643.        
  644.         dim  t,Arr
  645.         t=0
  646.         Arr = split(mytext,vbcrlf)       
  647.         if window.event.shiftKey then
  648.         '按sift                       
  649.                 for i=0 to ubound(Arr)
  650.                         if left(Arr(i),1)=vbtab then
  651.                                 Arr(i) = mid(Arr(i),2)
  652.                                 t= t + 1
  653.                         else
  654.                                 for j=1 to 4
  655.                                         if left(Arr(i),1)=" " then
  656.                                                 Arr(i) = mid(Arr(i),2)
  657.                                                 t= t + 1
  658.                                         else
  659.                                                 exit for
  660.                                         end if                       
  661.                                 next
  662.                         end if
  663.                 next
  664.                 t= t
  665.         else
  666.         '不按sift       
  667.                 for i=0 to ubound(Arr)
  668.                         Arr(i) = vbtab & Arr(i)
  669.                         t= t +1
  670.                 next                               
  671.         end if
  672.                 mytext = join(Arr,vbcrlf)
  673.                 sel.text = mytext
  674.                 sel.collapse true
  675.                 sel.moveEnd "character",0        
  676.                 sel.moveStart "character",(len(mytext) * -1) + t               
  677.                 sel.select()
  678.         window.event.cancelBubble = true
  679.         window.event.returnValue = false
  680. end sub

  681. '下面是关于搜索
  682. dim  seachResult'查找结果
  683. dim num '结果数量
  684. dim word'搜索关键字

  685. tagStop = false
  686. seachResult =""       

  687. '按回车后响应
  688. sub searchPress
  689.         if window.event.keyCode=13  then
  690.                 seachFile
  691.         end if
  692. end sub

  693. '显示搜索结果
  694. sub seachFile()       
  695.                 num =0       
  696.                 seachList.innerText = "搜索结果"                 
  697.                 word = searchKey.value               
  698.                  seachResult =""                 
  699.                  if trim(word)="" then
  700.                         alert "关键字为空!"
  701.                         searchKey.focus
  702.                         exit sub
  703.                 else
  704.                         dim l
  705.                         for each l in list.getElementsByTagName("DIV")
  706.                                 if l.id<>"seachList" then list.removeChild l                 
  707.                         next
  708.                         seachList.innerText = "搜索结果"                       
  709.                         seachWord thisFileFolder
  710.                         seachList.insertAdjacentHTML "AfterEnd",seachResult
  711.                         seachList.innerText = "搜索结果:" & num & "个"
  712.                         alert "搜索完毕!"       
  713.                  end if
  714. end sub

  715. sub seachWord(theFolder)       
  716.         dim f,f1,st,re,fd,fd1
  717.         set f = fso.GetFolder(theFolder)
  718.         for each f1 in f.Files
  719.                 if isTxt(f1.path)  then
  720.                         if instr(f1.path,word)>0 then
  721.                                 seachResult = seachResult & "<div class='file' title='" &  f1.path
  722.                                 seachResult = seachResult & "'><span class='fileIcon'>2" & "</span>"
  723.                                 seachResult = seachResult &  "<input value='"
  724.                                 fName = getTxtName(f1.name)
  725.                                 seachResult = seachResult & fName & "' title='" & fName & "'>"                                 
  726.                                 seachResult = seachResult & "</div>"
  727.                                 num = num + 1
  728.                         else
  729.                                 set st = f1.OpenAsTextStream
  730.                                 '逐行读               
  731.                                 Do While st.AtEndOfStream <> True
  732.                                         if instr(st.ReadLine,word)>0 then
  733.                                                 num = num +1                                               
  734.                                                 seachResult = seachResult & "<div class='file' title='" &  f1.path
  735.                                                 seachResult = seachResult & "'><span class='fileIcon'>2" & "</span>"
  736.                                                 seachResult = seachResult &  "<input value='"
  737.                                                 fName = getTxtName(f1.name)
  738.                                                 seachResult = seachResult & fName & "' title='" & fName & "'>"                                 
  739.                                                 seachResult = seachResult & "</div>"
  740.                                                 exit do                               
  741.                                         end if
  742.                                  Loop
  743.                                 st.Close
  744.                         end if       
  745.                 end if
  746.         next
  747.         set fd = fso.GetFolder(theFolder)
  748.                 for each  fd1 in fd.SubFolders
  749.                         seachWord fd1
  750.                 next
  751. end sub


  752. sub showHelp
  753.         dim msg,f,re,version
  754.         set f=fso.GetFile(thisFileDir)
  755.         version = f.DateLastModified
  756.         set re = new RegExp       
  757.         re.Pattern = "[^\d]"
  758.         re.Global=true
  759.         version =  re.Replace(mid(cstr(version),3),"/")
  760.                 version =   left(version ,len(version)-3)
  761.         set re = nothing       
  762.         msg =                "  文本代码管理工具【IE5.5以上版本】" & vbcrlf
  763.         msg = msg & "------------------------------------------------" & vbcrlf
  764.         msg = msg & "  使用方法:放到文本类型的文件夹里面,双击运行。" & vbcrlf
  765.         msg = msg & "功能:" & vbcrlf
  766.         msg = msg & "1,快速浏览,预览CTRL+B,搜索文本类型的文件和代码;" & vbcrlf
  767.         msg = msg & "2,按DEL可以删除点中的文件和文件夹;" & vbcrlf
  768.         msg = msg & "3,可以修改文件名和文字内容,CTRL+S保存;" & vbcrlf
  769.         msg = msg & "4,可以创建文件CTRL+N并且编辑保存;" & vbcrlf
  770.         msg = msg & "5,文本编辑支持TAB和shift+TAB键;" & vbcrlf
  771.         msg = msg & "6,格式化Well-Formed的XML文件;"        & vbcrlf
  772.         msg = msg &    vbcrlf
  773.         msg = msg & "作者:CSDN超级大笨狼[" & version & "版本]请随时到网站检查最新版本" & vbcrlf       
  774.         msg = msg & "欢迎传播使用,交流代码panyuguang962@hotmail.com" & vbcrlf
  775.         msg = msg & "http://superdullwolf.cnzone.net/index.asp" & vbcrlf
  776.         alert msg
  777. end sub
  778. </SCRIPT>

  779. </BODY>
  780. </HTML>
复制代码

评分

参与人数 1技术 +1 收起 理由
wc726842270 + 1 学习了

查看全部评分

发表于 2011-9-7 13:03:38 | 显示全部楼层
干嘛用的?
发表于 2011-9-7 13:21:04 | 显示全部楼层
真不知要过多少年少有这水平,唉、
原来是在这儿啊

  1. HTML="<marquee id= SCROLLAMOUNT='4' SCROLLDELAY='1'  direction='up' height=' " & window.screen.availHeight-80  & "'>"

  2.          HTML=  HTML & "<xmp style='word-wrap:break-word;line-height:60px ;' >" &  txt.value & "</xmp></marquee>"  
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 00:13 , Processed in 0.011523 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表