首页 > web前端 > js教程 > 正文

硬盘浏览程序,保存成网页格式便可使用_javascript技巧

WBOY
发布: 2016-05-16 19:23:31
原创
849 人浏览过

硬盘浏览程序,保存成网页格式便可使用,放到随意一个盘,不要放桌面就可以了

复制代码 代码如下:



<script> <BR>var errorinf=new Error(); <BR>var fso,fdrive,ffolder,ffile; <BR>var getdata="",selfpath="",drvpath="",favpath=""; <BR>var drive=new Array(),favorite=new Array(); <BR>var currentdrive=""; <BR>var hidestate=false; <BR>var lastdrive="",lastfav=""; <BR>var ppath=new Error(),ppathcounter=0,favcounter=0; <BR>var openfromfav=0; <BR>function initdoc() <BR>{ <BR>try <BR>{ <BR> var outstr="",counter=0,i=0,writestr=""; <BR> fso=new ActiveXObject("Scripting.FileSystemObject"); <BR> selfpath=fso.GetParentFolderName(location.pathname.replace(/\//,"")); <BR> drvpath=selfpath+"\\drvinf.ini"; <BR> /*Get the hard drives on the computer.*/ <BR> if(!fso.FileExists(drvpath)) <BR> { <BR> fdrive=fso.Drives; <BR> getdata=new Enumerator(fdrive); <BR> for(;!getdata.atEnd();getdata.moveNext()) <BR> if(getdata.item().DriveType==2) <BR> { <BR> drive[counter]=getdata.item().DriveLetter; <BR> writestr+=drive[counter]+"$"; <BR> counter++; <BR> } <BR> ffile=fso.CreateTextFile(drvpath,true); <BR> writestr=writestr.replace(/\$$/,""); <BR> ffile.WriteLine(writestr+"\r"); <BR> ffile.Close(); <BR> } <BR> else <BR> { <BR> ffile=fso.OpenTextFile(drvpath,1); <BR> getdata=ffile.ReadAll().replace(/\'|\"|\\|\/|\:|\s+/g,""); <BR> getdata=getdata.replace(/^\$+|\$+$/,""); <BR> getdata=getdata.replace(/\$\$+/,"$"); <BR> drive=getdata.split("$"); <BR> ffile.Close(); <BR> } <BR> for(i=0;i<drive.length;i++) <BR> outstr+="[<a href='' id='drive"+drive[i]+"' onClick=\"driveactive(drive["+i+"]);return false;\">本地磁盘:"+drive[i]+"]"; <BR> outstr+="显示隐藏内容<input style='height:15px;border:none;' type='checkbox' id='showorhide' onClick='hidestate=this.checked;flashdrive();'>" <BR> document.getElementById("drives").innerHTML=outstr; <BR> getdata="";outstr=""; <BR> /*Get the exist item.*/ <BR> favpath=selfpath+"\\favinf.ini"; <BR> if(fso.FileExists(favpath)) <BR> { <BR> ffile=fso.OpenTextFile(favpath,1); <BR> if(!ffile.AtEndOfStream) <BR> { <BR> getdata=ffile.ReadAll().replace(/\"|\s+/g,""); <BR> getdata=getdata.replace(/^\|+|\|+$/,""); <BR> getdata=getdata.replace(/\|\|+/,"|"); <BR> favorite=getdata.split("|"); <BR> } <BR> ffile.Close(); <BR> if(favorite[0]=="") <BR> favcounter=0; <BR> else <BR> favcounter=favorite.length; <BR> } <BR> else <BR> { <BR> ffile=fso.CreateTextFile(favpath,true); <BR> ffile.Close(); <BR> favcounter=0; <BR> } <BR> openfav(); <BR> driveactive("C"); <BR> getdata=""; <BR>}catch(errorinf){alert(errorinf.description+"\n\n请不要随便改变数据文件*.ini文件中的内容.");} <BR>} <BR>function driveactive(driveval) <BR>{ <BR>try{ <BR> if(lastdrive==("drive"+driveval)&&currentdrive.match(/^[a-z]\:\\$/i)) <BR> { <BR> document.getElementById("showorhide").focus(); <BR> return false; <BR> } <BR> if(lastdrive=="")lastdrive="driveC"; <BR> document.getElementById(lastdrive).style.backgroundColor="#CCCCCC"; <BR> lastdrive="drive"+driveval; <BR> document.getElementById(lastdrive).style.backgroundColor="#FFFFDD"; <BR> var att="",drv,totalsize,freespace,usespace,outstr="",pathstr="",attribu=0,subfolfil="",fcount=0; <BR> drv=fso.GetDrive(driveval); <BR> totalsize=Math.round((drv.TotalSize/Math.pow(2,30))*100)/100; <BR> freespace=Math.round((drv.FreeSpace/Math.pow(2,30))*100)/100; <BR> usespace=Math.round((totalsize-freespace)*100)/100; <BR> totalsize>1 ? totalsize+="GB":totalsize=totalsize*Math.pow(2,10)+"MB"; <BR> freespace>1 ? freespace+="GB":freespace=freespace*Math.pow(2,10)+"MB"; <BR> usespace>1 ? usespace+="GB":usespace=usespace*Math.pow(2,10)+"MB"; <BR> att+="本地磁盘:"+driveval+"\n文件系统:"+drv.FileSystem+"\n磁盘大小:"+totalsize+"\n已用空间:"+usespace+"\n可用空间:"+freespace+"\n"; <BR> outstr=""; <BR> currentdrive=pathstr=driveval+":\\"; <BR> ffolder=fso.GetFolder(pathstr+"\\").SubFolders; <BR> getdata=new Enumerator(ffolder); <BR> outstr="<div class='showcon'>文件夹:[<a href='' onclick=\"return unfurlorfold('folshow',this);\">隐藏]<div id='folshow'>"; <BR> ppathcounter=0; <BR> for(;!getdata.atEnd();getdata.moveNext()) <BR> { <BR> attribu=getdata.item().Attributes; <BR> if(hidestate||attribu==16||attribu==17||attribu==48||attribu==49) <BR> { <BR> fcount++; <BR> ppath[ppathcounter]=driveval+":\\"+getdata.item().name; <BR> outstr+="<div><a href='' onClick=\"folderactive(ppath["+ppathcounter+"]);" <BR> outstr+="return false;\">"+getdata.item().Name+"</script>
";
        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     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+"个文件.";
   document.getElementById("showcontent").innerHTML=outstr;
   document.getElementById("currentdrive").innerText=currentdrive;
   att="文件夹名称:\n\n文件夹大小:\n创建时间:\n\n修改时间:\n\n访问时间:";
   document.getElementById("showfolderatt").innerText=att;
   document.getElementById("subfolfil").innerText=subfolfil;
   att="[打开]";
   att+="[收藏]";
   document.getElementById("openfol").innerHTML=att;
   getdata="";
   openfromfav=0;
  }catch(errorinf){alert(errorinf.description+"\n\n请不要随便改变数据文件*.ini文件中的内容.");}
}
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("驱动器根目录.");
}
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("只能收藏文件夹.");
       return false;
     }
   var i=0;
   for(i=0;i     {
       if(favorite[i]==currentdrive)
         {
            alert("常用文件夹中已经存在该文件夹.");
            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("添加成功.");
}catch(errorinf){alert(errorinf.description+"\n\n请不要随便删除数据文件*.ini文件.");}
}
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


  


  


  

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

          HardDrives>>
        

          

        

          Tag>>
        

          DisplayContent
        

          CurrentPath>>
        

          

        

          
常用文件夹:

          

        

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

          

        

          当前驱动器信息:
          

          当前文件夹信息:
          
          

          

        

          
删除常用文件夹:


          

            P:


            [执行删除]
          

        

  



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





来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板