When I can't access these days, I reviewed the things on the hard drive and found this thing. Due to my limited level and no research on DHTML, I did it very roughly. I pasted it to attract jade. I hope that some experts can help modify or come up with better things.
The test environment is Windows XP Professional Edition SP2. I have temporarily found bugs in code coloring. Although there are solutions, due to the amount of code (it is really annoying to write code in Notepad), it has not been corrected for the time being. In addition, it is expected that automatic completion and other functions will be added in the future.
ps: Use VBS script + DHTML, the main function is completed by regular expression + wmic, the code needs to be saved as an HTA type file, and of course it can also be changed to a pure VBS script, but that is much less efficient and the code is more complicated.
The code is as follows:
<HTML>
<HEAD>
<title>Code Editor</title>
<HTA:APPLICATION selection="no" SCROLL="no" contextMenu="no" />
<SCRIPT LANGUAGE="VBSCRIPT">
'*********************************************************************
'The script begins
'*********************************************************************
Set shell=CreateObject("WScript.Shell")
Set fso=CreateObject("Scripting.FileSystemObject")
'*********************************************************************
'Travel over all local types of files
'*********************************************************************
Sub OptionAdd(fExt)
str = "<select size=""1"" name=""objOption"" onChange=""TestSub"">"
Set objDataFiles = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!//./root/cimv2")
Set colFiles = objDataFiles. _
ExecQuery("Select * from CIM_DataFile where extension = '" & fExt & "'")
For Each objFile in colFiles
str = str & "<option value=""" & objFile.name & """>" & _
objFile.name & "</option>"
next
str = "<label>local script file:</label>" & str & "</select>"
forOption.innerHTML = str
end Sub
'*********************************************************************
'Color conversion
'*********************************************************************
Sub ChangeColor
if cxs.value = "vbs" then
WinMain.innerHTML = ChangeVBS(WinMain.innerText)
else 'CMD script
WinMain.innerHTML = ChangeCMD(WinMain.innerText)
end if
end Sub
'*********************************************************************
'VBS conversion module
'*********************************************************************
Function ChangeVBS(sText)
Set re=new RegExp
re.IgnoreCase =true
re.Global=true
'Comment conversion
re.Pattern = "(/'.*)/r/n"
sText = re.Replace(sText,"<font color=#339999>$1</font><p>")
'Convert symbol to [blue]
re.Pattern = "(/(|/)|/&|/+|/-|/*|/%|/:|/;|/.|/"" & ")"
sText = re.Replace(sText,"<font color=#993333>$1</font>")
sText = "<table ><tr><td width='1024' " & _