FSO的强大功能(7)
set obj = currentDiv.getElementsByTagName("SPAN")(0)
window.event.cancelBubble = true
select case obj.className
case "folderIcon"
'点到了文件夹
if vartype(currentSpan)=8 then
currentSpan.style.color = "navy"
end if
set currentSpan = obj
state = abs(cint(obj.innerHTML) -1)
obj.innerHTML = state
obj.style.color="red"
set d = obj.parentElement
currentDir = d.title
currentFile = ""
if d.getAttribute("parsed")=true then
'合拢
fold d,state
else
'解析
showFolder d
end if
case "fileIcon"
'点到了文件,在textArea里面载入文本文件
if vartype(currentSpan)=8 then
currentSpan.style.color = "navy"
end if
set currentSpan = obj
obj.style.color="red"
readText obj.parentElement.title
currentDir = ""
currentFile = obj.parentElement.title
end select
end sub
sub fold(o,stateOpen) '合拢
dim n
set n=o.nextSibling
do
if vartype(n) =9 then exit do
if px2Int(n.style.marginLeft) <= px2Int(o.style.marginLeft) then exit do
if stateOpen=1 then n.style.display="" else n.style.display="none"
set n=n.nextSibling
loop
end sub
sub readText(filePath)
Dim f,fName
if not fso.FileExists(filePath) then
alert filePath & vbcrlf & "该文件不存在,也许是被移动了,所以刷新一下本程序"
window.location.reload
exit sub
end if
'TXT已经加载的当前文件不再加载.
if filePath = currentFile then exit sub
txt.value = ""
Set f = fso.OpenTextFile(filePath, 1, true)
if not f.AtEndOfStream then
txt.value = f.readAll
else
txt.value = ""
end if
fName = lastOne(filePath,"\")
articleTitle.value = getTxtName(fName)
f.Close
Ln.innerText = 1
End sub
sub TabTxt()
'支持tab键的文本框
if window.event.keyCode=38 then
if cint(Ln.innerText) >1 then Ln.innerText = cint(Ln.innerText)-1
end if
if window.event.keyCode=40 then
内容版权声明:除非注明,否则皆为本站原创文章。