Home > Web Front-end > JS Tutorial > Hard disk browsing program, save it in web page format and use it_javascript skills

Hard disk browsing program, save it in web page format and use it_javascript skills

WBOY
Release: 2016-05-16 19:23:31
Original
870 people have browsed it

The hard disk browsing program can be used after saving it in web format. Put it on any disk, not on the desktop.

Copy the code The code is as follows:




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      outstr ="[本地磁盘:" drive[i] "]";
   outstr ="显示隐藏内容"
   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\n请不要随便改变数据文件*.ini文件中的内容.");}
}
function driveactive(driveval)
{
try{  
   if(lastdrive==("drive"+driveval)&¤tdrive.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(2,30))*100)/100;
   freespace=Math.round((drv.FreeSpace/Math.pow(2,30))*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+="本地磁盘:"+driveval+"\n文件系统:"+drv.FileSystem+"\n磁盘大小:"+totalsize+"\n已用空间:"+usespace+"\n可用空间:"+freespace+"\n";
   outstr="";
   currentdrive=pathstr=driveval+":\\";
   ffolder=fso.GetFolder(pathstr+"\\").SubFolders;
   getdata=new Enumerator(ffolder);
   outstr="
文件夹:[隐藏]
";
   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+="";
        ppathcounter++;
      }
    }
   subfolfil="找到"+fcount+"个文件夹,";
   fcount=0;
   ffile=fso.GetFolder(pathstr).Files;
   getdata=new Enumerator(ffile);
   outstr+="
文  件:[隐藏]
";
   for(;!getdata.atEnd();getdata.moveNext())
    {
     attribu=getdata.item().Attributes;
     if(hidestate||attribu==0||attribu==1||attribu==32||attribu==33)
      {
        fcount++;
        outstr+="";
      }
    } 
   outstr+="
";
   subfolfil+=fcount+"个文件.";
   document.getElementById("showcontent").innerHTML=outstr;
   document.getElementById("currentdrive").innerText=currentdrive;
   document.getElementById("showdriveatt").innerText=att;
   att="文件夹名称:\n\n文件夹大小:\n创建时间:\n\n修改时间:\n\n访问时间:\n\n";
   document.getElementById("showfolderatt").innerText=att;
   document.getElementById("subfolfil").innerText=subfolfil;
   att="[打开]";
   att+="[收藏]";
   document.getElementById("openfol").innerHTML=att;
   document.getElementById("showorhide").focus();
   getdata="";
   }catch(errorinf){alert(errorinf.description+"\n\n请不要随便改变数据文件*.ini文件中的内容.");}
}
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(2,10),sizesign="KB"):{}
     totalsize=Math.round((totalsize)*100)/100+sizesign;
     att+="文件夹名称:\n"+fol.Name+"\n文件夹大小:"+totalsize+"\n创建时间:\n";
     att+=fol.DateCreated+"\n修改时间:\n"+fol.DateLastModified+"\n访问时间:\n"+fol.DateLastAccessed;
     document.getElementById("showfolderatt").innerText=att+"\n";
    }
}catch(errorinf){alert(errorinf.description+"\n\n请不要随便改变数据文件*.ini文件中的内容.");}
}
function openfolder(currfolder)
{
try
{
   var sign=0,outstr="",attribu=0,subfolfil="",fcount=0;
   if(currfolder==""){alert("没有选择文件夹.");return false;}
   currentdrive=currfolder;
   ffolder=fso.GetFolder(currfolder).SubFolders;
   getdata=new Enumerator(ffolder);
   outstr="
文件夹:[隐藏]
";
   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+="";
        ppathcounter++;
      }
    }
   subfolfil="找到"+fcount+"个文件夹,";
   fcount=0;
   ffile=fso.GetFolder(currfolder).Files;
   getdata=new Enumerator(ffile);
   outstr+="
文  件:[隐藏]
";
   for(;!getdata.atEnd();getdata.moveNext())
    {
     attribu=getdata.item().Attributes;
     if(hidestate||attribu==0||attribu==1||attribu==32||attribu==33)
      {
        fcount++;
        if(openfromfav==0)
          outstr+="";
        else
          outstr+="";
      }
    }   
   outstr+="
";
subfolfil =fcount "documents.";
document.getElementById("showcontent").innerHTML=outstr;
document.getElementById("currentdrive").innerText=currentdrive;
att="Folder name: nn Folder size: n Creation time: nn Modification time: nn Access time:";
document.getElementById("showfolderatt").innerText=att;
document.getElementById(" subfolfil").innerText=subfolfil;
att="[Open]";
att="[< a href='' onclick="addfav();return false;">Collection]";
document.getElementById("openfol").innerHTML=att;
getdata="" ;
openfromfav=0;
}catch(errorinf){alert(errorinf.description "nnPlease do not change the contents of the data file *.ini file casually.");}
}
function upfile()
{
var rootpath="";
rootpath=currentdrive;
if(!rootpath.match(/^[a-z]:\$/i))
{
         rootpath=rootpath.replace(/\[^\]*$/,"");
folderactive(rootpath);
}
else
alert("Drive root directory.");
}
function flashdrive()
{
folderactive(currentdrive );
}
function openfav()
{
lastfav="";
var outstr="",i=0;
for(i;i {
outstr =" outstr =" favactive(this.id);return false;" target='_blank'>" favorite[i].replace(/^. \/,"") "
";
}
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 saved.");
return false;
}
var i=0;
for(i=0;i< ;favcounter;i )
{
if(favorite[i]==currentdrive)
{
alert("The folder already exists in the frequently used folder.");
return false ;
                                                     🎜> {
ffile=fso.CreateTextFile(favpath,true);
} }
ffile.Write("|" currentdrive);
ffile.Close();
favorite[favcounter]=currentdrive ;
favcounter ;
openfav();
alert("Added successfully.");
}catch(errorinf){alert(errorinf.description "nnPlease do not delete data files *.ini casually 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("没有选择常用文件夹.");
        return false;
     }
   if(confirm("确定删除常用文件夹(并非从硬盘删除):\n"+delpath+"\n?"))
     {
        favcounter--;
        for(j;j favorite[j]=favorite[j+1];
for(j=0;j newfav+=favorite[j]+"|";
ffile=fso.OpenTextFile(favpath,2);
newfav=newfav.replace(/^\||\|$/,"");
ffile.WriteLine(newfav);
ffile.Close();
openfav();
document.getElementById("delfav").value="";
alert("删除成功.");
}

}catch(errorinf){document.getElementById("delfav").value="";alert(errorinf.description+"\n\n请不要随便删除数据文件*.ini文件.");}
}
function unfurlorfold(objid,obj)
{
if(obj.innerText=="隐藏")
{
obj.innerText="显示";
document.getElementById(objid).style.display="none";
}
else
{
obj.innerText="隐藏";
document.getElementById(objid).style.display="";
}
document.getElementById("showorhide").focus();
return false;
}


FileLookThroughAdmin V1.0




  

FileLookThroughAdmin


  


  


  

    
      
        
        
        
      
      
        
        
      
      
        
        
      
      
        
        
      
      
        
        
        
      
      
        
          
删除常用文件夹:


          
            P:


            [执行删除]
          
        
      

    
收藏夹 文件夹及文件 相关信息

          HardDrives>>
        

          

        

          Tag>>
        

          DisplayContent
        

          CurrentPath>>
        

          

        

          
常用文件夹:

          

        

          
onmouseover="this.style.backgroundColor='#FFFFDD';"
onmouseout="this.style.backgroundColor='#CCCCCC';">
          上一级目录

          

        

          当前驱动器信息:
          

          当前文件夹信息:
          
          

          

        

  



  
    디자인:sgw.LKing(∮LKing♂)[FS:Ecjtu2006|QQ:28857496|E-Mail:sgw.lking@gmail.com][@06.11]
  




source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template