Hard drive browsing program, saved as webpage format for use

Source: Internet
Author: User

The hard disk browsing program can be used after it is saved as a webpage format. It can be placed on a random disk instead of a desktop. Copy codeThe Code is as follows: <Head>
<Script language = "javascript" type = "text/javascript">
Var errorinf = new Error ();
Var fso, fdrive, ffolder, ffile;
Var getdata = "", selfpath = "", drvpath = "", favpath = "";
Var drive = new Array (), favorite = new Array ();
Var currentdrive = "";
Var hidestate = false;
Var lastdrive = "", lastfav = "";
Var ppath = new Error (), ppathcounter = 0, favcounter = 0;
Var openfromfav = 0;
Function initdoc ()
{
Try
{
Var outstr = "", counter = 0, I = 0, writestr = "";
Fso = new ActiveXObject ("Scripting. FileSystemObject ");
Selfpath = fso. GetParentFolderName (location. pathname. replace (/\//,""));
Drvpath = selfpath + "\ drvinf. ini ";
/* Get the hard drives on the computer .*/
If (! Fso. FileExists (drvpath ))
{
Fdrive = fso. Drives;
Getdata = new Enumerator (fdrive );
For (;! Getdata. atEnd (); getdata. moveNext ())
If (getdata. item (). DriveType = 2)
{
Drive [counter] = getdata. item (). DriveLetter;
Writestr + = drive [counter] + "$ ";
Counter ++;
}
Ffile = fso. CreateTextFile (drvpath, true );
Writestr = writestr. replace (/\ $ /,"");
Ffile. WriteLine (writestr + "\ r ");
Ffile. Close ();
}
Else
{
Ffile = fso. OpenTextFile (drvpath, 1 );
Getdata = ffile. ReadAll (). replace (/\ '| \ "| \/| \: | \ s +/g ,"");
Getdata = getdata. replace (/^ \ $ + | \ $ + $ /,"");
Getdata = getdata. replace (/\\ \$ +/, "$ ");
Drive = getdata. split ("$ ");
Ffile. Close ();
}
For (I = 0; I <drive. length; I ++)
Outstr + = "[<a href ='' id = 'Drive "+ drive [I] +" 'onclick = \ "driveactive (drive [" + I + "]); return false; \ "> Local disk:" + drive [I] + "</a>]";
Outstr + = "show hidden content <input style = 'height: 15px; border: none; 'Type = 'checkbox' id = 'showorhide 'onclick = 'hidestate = this. checked; flashdrive (); '>"
Document. getElementById ("drives"). innerHTML = outstr;
Getdata = ""; outstr = "";
/* Get the exist item .*/
Favpath = selfpath + "\ favinf. ini ";
If (fso. FileExists (favpath ))
{
Ffile = fso. OpenTextFile (favpath, 1 );
If (! Ffile. AtEndOfStream)
{
Getdata = ffile. ReadAll (). replace (/\ "| \ s +/g ,"");
Getdata = getdata. replace (/^ \ | + |\| + $ /,"");
Getdata = getdata. replace (// |\| +/, "| ");
Favorite = getdata. split ("| ");
}
Ffile. Close ();
If (favorite [0] = "")
Favcounter = 0;
Else
Favcounter = favorite. length;
}
Else
{
Ffile = fso. CreateTextFile (favpath, true );
Ffile. Close ();
Favcounter = 0;
}
Openfav ();
Driveactive ("C ");
Getdata = "";
} Catch (errorinf) {alert (errorinf. description + "\ n please do not change the content of the data file *. ini file .");}
}
Function driveactive (driveval)
{
Try {
If (lastdrive = ("drive" + driveval) & currentdrive. match (/^ [a-z] \:\$/I ))
{
Document. getElementById ("showorhide"). focus ();
Return false;
}
If (lastdrive = "") lastdrive = "driveC ";
Document. getElementById (lastdrive). style. backgroundColor = "# CCCCCC ";
Lastdrive = "drive" + driveval;
Document. getElementById (lastdrive). style. backgroundColor = "# FFFFDD ";
Var att = "", drv, totalsize, freespace, usespace, outstr = "", pathstr = "", attribu = 0, subfolfil = "", fcount = 0;
Drv = fso. GetDrive (driveval );
Totalsize = Math. round (drv. TotalSize/Math. pow (100) * 100;
Freespace = Math. round (drv. FreeSpace/Math. pow (100) * 100;
Usespace = Math. round (totalsize-freespace) * 100)/100;
Totalsize> 1? Totalsize + = "GB": totalsize = totalsize * Math. pow (2, 10) + "MB ";
Freespace> 1? Freespace + = "GB": freespace = freespace * Math. pow (2, 10) + "MB ";
Usespace> 1? Usespace + = "GB": usespace = usespace * Math. pow (2, 10) + "MB ";
Att + = "Local disk:" + driveval + "\ n File System:" + drv. fileSystem + "\ n disk size:" + totalsize + "\ n used space:" + usespace + "\ n available space:" + freespace + "\ n ";
Outstr = "";
Currentdrive = pathstr = driveval + ":\\";
Ffolder = fso. GetFolder (pathstr + "\"). SubFolders;
Getdata = new Enumerator (ffolder );
Outstr = "<div class = 'showcon '> Folder: [<a href = ''onclick = \" return unfurlorfold ('folshow', this ); \ "> hide </a>] <div id = 'folshow '> ";
Ppathcounter = 0;
For (;! Getdata. atEnd (); getdata. moveNext ())
{
Attribu = getdata. item (). Attributes;
If (hidestate | attribu = 16 | attribu = 17 | attribu = 48 | attribu = 49)
{
Fcount ++;
Ppath [ppathcounter] = driveval + ": \" + getdata. item (). name;
Outstr + = "<div> <a href = ''onclick = \" folderactive (ppath ["+ ppathcounter +"]);"
Outstr + = "return false; \"> "+ getdata. item (). Name +" </a> </div> ";
Ppathcounter ++;
}
}
Subfolfil = "find" + fcount + "folders ,";
Fcount = 0;
Ffile = fso. GetFolder (pathstr). Files;
Getdata = new Enumerator (ffile );
Outstr + = "</div> <div class = 'showcon '> document & nbsp: [<a href = ''onclick = \ "return unfurlorfold ('filshow ', this); \"> hide </a>] <div id = 'filshow'> ";
For (;! Getdata. atEnd (); getdata. moveNext ())
{
Attribu = getdata. item (). Attributes;
If (hidestate | attribu = 0 | attribu = 1 | attribu = 32 | attribu = 33)
{
Fcount ++;
Outstr + = "<div> <a href = \" "+ currentdrive +" \ "target = '_ blank'>" + getdata. item (). name + "</a> </div> ";
}
}
Outstr + = "</div> ";
Subfolfil + = fcount + "files .";
Document. getElementById ("showcontent"). innerHTML = outstr;
Document. getElementById ("currentdrive"). innerText = currentdrive;
Document. getElementById ("showdriveatt"). innerText = att;
Att = "folder name: \ n folder size: \ n Creation Time: \ n modification time: \ n Access time: \ n ";
Document. getElementById ("showfolderatt"). innerText = att;
Document. getElementById ("subfolfil"). innerText = subfolfil;
Att = "[<a href = \" "+ currentdrive +" \ "target = '_ blank'> open </a>]";
Att + = "[<a href = ''onclick = \" addfav (); return false; \ "> favorites </a>]";
Document. getElementById ("openfol"). innerHTML = att;
Document. getElementById ("showorhide"). focus ();
Getdata = "";
} Catch (errorinf) {alert (errorinf. description + "\ n please do not change the content of the data file *. ini file .");}
}
Function folderactive (folderval)
{
Try
{
Var att = "", fol = "", totalsize = 0, sizesign = "";
Openfolder (folderval );
If (! Folderval. match (/^ [a-z] \: \ $/I ))
{
Fol = fso. GetFolder (folderval );
Totalsize = fol. Size/Math. pow (2, 30 );
Totalsize> 1? Sizesign = "GB" :( totalsize = totalsize * Math. pow (2, 10), sizesign = "MB ");
(Totalsize <1 & sizesign = "MB ")? (Totalsize = totalsize * Math. pow (), sizesign = "KB "):{}
Totalsize = Math. round (totalsize) * 100)/100 + sizesign;
Att + = "folder Name: \ n" + fol. Name + "\ n folder size:" + totalsize + "\ n Creation Time: \ n ";
Att + = fol. DateCreated + "\ n modification time: \ n" + fol. DateLastModified + "\ n Access time: \ n" + fol. DateLastAccessed;
Document. getElementById ("showfolderatt"). innerText = att + "\ n ";
}
} Catch (errorinf) {alert (errorinf. description + "\ n please do not change the content of the data file *. ini file .");}
}
Function openfolder (currfolder)
{
Try
{
Var sign = 0, outstr = "", attribu = 0, subfolfil = "", fcount = 0;
If (currfolder = "") {alert ("No folder selected."); return false ;}
Currentdrive = currfolder;
Ffolder = fso. GetFolder (currfolder). SubFolders;
Getdata = new Enumerator (ffolder );
Outstr = "<div class = 'showcon '> Folder: [<a href = ''onclick = \" return unfurlorfold ('folshow', this ); \ "> hide </a>] <div id = 'folshow '> ";
Ppathcounter = 0;
For (;! Getdata. atEnd (); getdata. moveNext ())
{
Attribu = getdata. item (). Attributes;
If (hidestate | attribu = 16 | attribu = 17 | attribu = 48 | attribu = 49)
{
Fcount ++;
Ppath [ppathcounter] = currfolder. replace (/\ + $/I, "") + "\" + getdata. item (). name;
Outstr + = "<div> <a href = ''onclick = \" folderactive (ppath ["+ ppathcounter +"]);"
Outstr + = "return false; \"> "+ getdata. item (). Name +" </a> </div> ";
Ppathcounter ++;
}
}
Subfolfil = "find" + fcount + "folders ,";
Fcount = 0;
Ffile = fso. GetFolder (currfolder). Files;
Getdata = new Enumerator (ffile );
Outstr + = "</div> <div class = 'showcon '> text & nbsp: [<a href = ''onclick = \ "return unfurlorfold ('filshow ', this); \"> hide </a>] <div id = 'filshow'> ";
For (;! Getdata. atEnd (); getdata. moveNext ())
{
Attribu = getdata. item (). Attributes;
If (hidestate | attribu = 0 | attribu = 1 | attribu = 32 | attribu = 33)
{
Fcount ++;
If (openfromfav = 0)
Outstr + = "<div> <a href = \" "+ currentdrive +" \ "target = '_ blank'>" + getdata. item (). name + "</a> </div> ";
Else
Outstr + = "<div> <a href = \" "+ currentdrive +" \ "+ getdata. item (). name + "\" target = '_ blank'> "+ getdata. item (). name + "</a> </div> ";
}
}
Outstr + = "</div> ";
Subfolfil + = fcount + "files .";
Document. getElementById ("showcontent"). innerHTML = outstr;
Document. getElementById ("currentdrive"). innerText = currentdrive;
Att = "folder name: \ n folder size: \ n Creation Time: \ n modification time: \ n Access time :";
Document. getElementById ("showfolderatt"). innerText = att;
Document. getElementById ("subfolfil"). innerText = subfolfil;
Att = "[<a href = \" "+ currentdrive +" \ "target = '_ blank'> open </a>]";
Att + = "[<a href = ''onclick = \" addfav (); return false; \ "> favorites </a>]";
Document. getElementById ("openfol"). innerHTML = att;
Getdata = "";
Openfromfav = 0;
} Catch (errorinf) {alert (errorinf. description + "\ n please do not change the content of the data file *. ini file .");}
}
Function upfile ()
{
Var rootpath = "";
Rootpath = currentdrive;
If (! Rootpath. match (/^ [a-z] \: \ $/I ))
{
Rootpath = rootpath. replace (// \ [^ \] * $ /,"");
If (rootpath. match (/^ [a-z] \: $/I) {rootpath + = "\\";}
Folderactive (rootpath );
}
Else
Alert ("drive root directory .");
}
Function flashdrive ()
{
Folderactive (currentdrive );
}
Function openfav ()
{
Lastfav = "";
Var outstr = "", I = 0;
For (I; I <favcounter; I ++)
{
Outstr + = "<a id = 'fav" + I + "'href ='' onclick = \ "openfromfav = 1; folderactive (favorite [" + I + "]);"
Outstr + = "favactive (this. id); return false; \ "target = '_ blank'>" + favorite [I]. replace (/^. + \\/, "") + "</a> <br> ";
}
Document. getElementById ("showfavorite"). innerHTML = outstr;
Document. getElementById ("delfav"). value = "";
}
Function favactive (favid)
{
Var I = parseInt (favid. match (/\ d /));
If (lastfav! = "")
Document. getElementById (lastfav). style. backgroundColor = "# CCCCCC ";
Lastfav = favid;
Document. getElementById ("delfav"). value = favorite [I];
Document. getElementById (lastfav). style. backgroundColor = "# FFFFDD ";
Document. getElementById ("showorhide"). focus ();
}
Function addfav ()
{
Try
{
If (currentdrive. match (/^ [a-z] \: \ $/I ))
{
Alert ("Only folders can be added to favorites .");
Return false;
}
Var I = 0;
For (I = 0; I <favcounter; I ++)
{
If (favorite [I] = currentdrive)
{
Alert ("this folder already exists in a common folder .");
Return false;
}
}
If (fso. FileExists (favpath ))
{
Ffile = fso. OpenTextFile (favpath, 8 );
}
Else
{
Ffile = fso. CreateTextFile (favpath, true );
}
Ffile. Write ("|" + currentdrive );
Ffile. Close ();
Favorite [favcounter] = currentdrive;
Favcounter ++;
Openfav ();
Alert ("added successfully .");
} Catch (errorinf) {alert (errorinf. description + "\ n please do not delete the data file *. ini file .");}
}
Function delfav ()
{
Try
{
Var delpath = document. getElementById ("delfav"). value;
Var I = lastfav. match (/\ d/), j = parseInt (I );
Var newfav = "";
Document. getElementById ("showorhide"). focus ();
If (delpath = "")
{
Alert ("common folders not selected .");
Return false;
}
If (confirm ("are you sure you want to delete common folders (not from hard disk): \ n" + delpath + "\ n? "))
{
Favcounter --;
For (j; j <favcounter; j ++)
Favorite [j] = favorite [j + 1];
For (j = 0; j <favcounter; j ++)
Newfav + = favorite [j] + "| ";
Ffile = fso. OpenTextFile (favpath, 2 );
Newfav = newfav. replace (/^ \ | |\| $ /,"");
Ffile. WriteLine (newfav );
Ffile. Close ();
Openfav ();
Document. getElementById ("delfav"). value = "";
Alert ("deleted successfully .");
}

} Catch (errorinf) {document. getElementById ("delfav "). value = ""; alert (errorinf. description + "\ n please do not delete any data file *. INI file. ");}
}
Function unfurlorfold (objid, obj)
{
If (obj. innerText = "hide ")
{
Obj. innerText = "show ";
Document. getElementById (objid). style. display = "none ";
}
Else
{
Obj. innerText = "hide ";
Document. getElementById (objid). style. display = "";
}
Document. getElementById ("showorhide"). focus ();
Return false;
}
</Script>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> FileLookThroughAdmin V1.0 </title>
<Style type = "text/css">
<! --
Body {
Background-color: # EEEEEE ;}

Div. main {
Background-color: # CCCCCC;
Width: 100%;
Padding: 6px 10px 10px ;}

H1 {font-size: 36px;
Font-family: "文 ";
Color: # 0000FF ;}

Hr {
Width: 95%;
Text-align: left ;}

Table. tableclass {
Table-layout: fixed;
Word-wrap: break-word;
Width: 100%;
Font-size: 12px;
Background-color: # EEEEEE ;}
Table. tableclass td {
Background-color: # CCCCCC ;}

# Drive {}
Td. drvinf {
Vertical-align: top;
Padding: 5px ;}
Td. folderfile {
Height: pixel PX;
Vertical-align: top ;}
Td. folderfile div. showcon {
Width: 100% ;}
Td. folderfile div. showcon div {
Padding: 1px 0px;
Width: 49%;
Float: left ;}

A: link {text-decoration: none;
Color: # 0000FF ;}
A: active {text-decoration: none;
Color: # 0000FF ;}
A: visited {text-decoration: none;
Color: # 0000FF ;}
A: hover {
Text-decoration: underline;
Color: # FF0000;
Background-color: # FFFFDD ;}

. Button {
Border: none;
Height: 20px;
Width: 50px;
Background-color: # CCCCCC ;}

Td. fav {
Vertical-align: top;
Padding: 5px ;}
-->
</Style>
</Head>
<Body onLoad = "javascript: initdoc (); status = 'filelookthroughadmin v1.0';">
<Div class = "main">
<H1> FileLookThroughAdmin <Div style = "margin-top:-36px;"> <Div style = "margin-top:-14px; position: relative; left: 5%;"> <Div>
<Table class = "tableclass">
<Tr align = "center">
<Td width = "18%"> favorites </td>
<Td width = "60%"> folders and files </td>
<Td> related information </td>
</Tr>
<Tr>
<Td align = "center">
HardDrives>
</Td>
<Td colspan = "2">
<Div id = "drives"> </div>
</Td>
</Tr>
<Tr>
<Td align = "center">
Tag>
</Td>
<Td align = "center" colspan = "2">
DisplayContent
</Td>
</Tr>
<Tr>
<Td align = "center">
CurrentPath>
</Td>
<Td colspan = "2">
<Div id = "currentdrive"> </div>
</Td>
</Tr>
<Tr>
<Td class = "fav">
<Div> common folders: </div>
<Div id = "showfavorite"> </div>
</Td>
<Td rowspan = "2" class = "folderfile">
<Div onclick = "upfile ();" style = "height: 15px; cursor: pointer; padding-top: 5px;" align = "center"
Onmouseover = "this. style. backgroundColor = '# ffffdd ';"
Onmouseout = "this. style. backgroundColor = '# cccccccc';">
Upper-level directory </div>
<Div id = "showcontent" style = "padding-left: 5px;"> </div>
</Td>
<Td rowspan = "2" class = "drvinf">
<Font color = "# FF0000"> current drive information: </font>
<Div id = "showdriveatt"> </div>
<Font color = "# FF0000"> current Folder Information: </font>
<Span id = "openfol"> </span>
<Div id = "showfolderatt"> </div>
<Div id = "subfolfil" style = "color: # FF0000;"> </div>
</Td>
</Tr>
<Tr>
<Td class = "fav">
<Div> Delete common folders: </div> <br>
<Div align = "center">
P: <input id = "delfav" type = "text" style = "border: none;" readonly> <br>
[<A href = "" onClick = "delfav (); return false;"> Delete </a>]
</Div>
</Td>
</Tr>
</Table>
</Div>
</Div>
<Div>
<Font style = "font-size: 12px; cursor: default;" color = "#666666" onmouseover = "this. color = '# ff0000' "onmouseout =" this. color = '#666666' ">
Design: sgw. LKing (l∮ king♂) [FS: Ecjtu2006 | QQ: 28857496 | E-Mail: sgw.lking@gmail.com] [@ 06.11]
</Font>
</Div>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.