home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_03.cab / jsbrwhd.asp < prev    next >
Encoding:
Text File  |  1997-09-05  |  6.3 KB  |  297 lines

  1. <%@ LANGUAGE=VBScript %>
  2.  
  3. <% 
  4. Option Explicit
  5.  
  6. Const L_LOOKIN_TEXT = "Look in:"
  7. Const L_NAME_TEXT = "Name"
  8. Const L_SIZE_TEXT = "Size"
  9. Const L_TYPE_TEXT = "Type"
  10. Const L_LASTMODIFIED_TEXT = "Modified"
  11. Const L_SLASH_TEXT = "\"    
  12. Const FIXEDDISK = 2
  13.  
  14. Dim path, FileSystem, drives, drive, primarydrive
  15.  
  16. path = Request.Cookies("HTMLA")("LASTPATH")
  17.  
  18. If path = "" Then
  19.     Set FileSystem=CreateObject("Scripting.FileSystemObject")
  20.     Set drives = FileSystem.Drives
  21.  
  22.     For Each drive in drives
  23.         primarydrive = drive    
  24.         
  25.         'exit after the first FIXEDDISK if there is one...
  26.         if drive.DriveType = FIXEDDISK then
  27.             Exit For            
  28.         end if
  29.         
  30.     Next
  31.     
  32.     primarydrive = primarydrive & L_SLASH_TEXT
  33.  
  34.     Response.Cookies("HTMLA")("LASTPATH")=primarydrive
  35.     path = primarydrive
  36. End If
  37. %>
  38.  
  39. <HTML>
  40. <HEAD>
  41.     <TITLE></TITLE>
  42.     
  43.     <SCRIPT LANGUAGE="JavaScript">
  44.     
  45.     function writeTblOpen(){
  46.             document.write("<TABLE BORDER = 1 CELLPADDING = 1 CELLSPACING = 0  BORDERCOLOR='#CCCCCC'  BORDERCOLORDARK='#CCCCCC' BORDERCOLORLIGHT='#CCCCCC'><TR>");            
  47.     }
  48.     
  49.     function writeTblClose(){
  50.         document.write("</TABLE>");
  51.     }
  52.     
  53.     function writeTblHead(cellwidth,sorttype,stringwidth,thestring)
  54.         {
  55.         var i;    
  56.         var quote = '"'
  57.                 
  58.         var writestr = "<TD WIDTH=" + cellwidth + " BORDER = 1  BORDERCOLOR='#CCCCCC' BORDERCOLORDARK='#FFFFFF' BORDERCOLORLIGHT='#000000'><FONT SIZE=1 FACE='HELV'>";
  59.         writestr += "<A HREF = 'javascript:sortList("+quote+sorttype+quote+");'>";
  60.     
  61.         stringwidth = stringwidth - thestring.length;
  62.         for (i=stringwidth;i>0;i--)
  63.             {
  64.             thestring += " "
  65.             }
  66.         writestr += thestring;        
  67.         writestr += "</A></TD>";
  68.         document.write(writestr);        
  69.         return;
  70.         }
  71.     </SCRIPT>
  72. </HEAD>
  73.  
  74. <BODY BGCOLOR="#CCCCCC" LINK="#000000" VLINK="#000000" ALINK="#000000" TOPMARGIN = 5 LEFTMARGIN = 5 onLoad="loadList();">
  75. <FORM NAME="userform" onSubmit="changeDir(document.userform.currentPath.value);">
  76.  
  77. <TABLE>
  78. <TR><TD WIDTH = 40><FONT FACE="Helv" SIZE = 1>
  79.     <%= L_LOOKIN_TEXT %>
  80.     </TD>
  81.     <TD>
  82.     <INPUT TYPE="text" NAME="currentPath" VALUE="<%= path %>" SIZE = 50 OnBlur="changeDir(this.value);">
  83.     </TD>
  84.     <TD>
  85.         <A HREF="javascript:upDir();"><IMG SRC="updir.GIF" WIDTH=23 HEIGHT=22 BORDER=0></A>
  86.     </TD>
  87.     </TR>
  88. </TABLE>
  89.  
  90. <SCRIPT LANGUAGE="JavaScript">
  91.     writeTblOpen();
  92.     writeTblHead(176, "fname", 50,"<%= L_NAME_TEXT %>");    
  93.     writeTblHead(75, "fsize",15,"<%= L_SIZE_TEXT %>");
  94.     writeTblHead(75, "ftype",15,"<%= L_TYPE_TEXT %>");
  95.     writeTblHead(160, "lastmodified",45,"<%= L_LASTMODIFIED_TEXT %>");    
  96.     writeTblClose();
  97. </SCRIPT>
  98.  
  99. </FORM>
  100.  
  101. <SCRIPT LANGUAGE="JavaScript">
  102.     function loadList()
  103.         {
  104.         parent.hlist.location.href = "JSBrwSet.asp?btype=" + top.opener.JSBrowser.browsertype;        
  105.         }
  106.     function redrawList()
  107.         {
  108.         parent.list.location.href = "JSBrwLs.asp";        
  109.         }
  110.         
  111.  
  112.     function listFuncs()
  113.         {
  114.         this.loadList = loadList;
  115.         this.sortList = sortList;
  116.         this.SetFilter = SetFilter;
  117.         this.changeDir = changeDir;
  118.         this.setPath = setPath;
  119.         this.selIndex = 0;
  120.         this.sortby = "fname";
  121.         this.sortAsc = true;
  122.         this.filterType = "";
  123.         }
  124.  
  125.  
  126.     function upDir()
  127.         {
  128.         lastpath = document.userform.currentPath.value;
  129.         uppath = lastpath;
  130.         while (lastpath.indexOf("/") > -1)
  131.             {
  132.             lastpath = lastpath.substring(0,lastpath.indexOf("/")) + "\\" + lastpath.substring(lastpath.indexOf("/")+1,lastpath.length);
  133.             }         
  134.         if (lastpath.lastIndexOf("\\") == lastpath.length-1)
  135.             {
  136.             lastpath = lastpath.substring(0,lastpath.length-1);
  137.             }
  138.         lastwhack = lastpath.lastIndexOf("\\");
  139.         if (lastwhack > 0)
  140.             {
  141.             uppath = lastpath.substring(0,lastwhack+1);
  142.             }    
  143.         document.userform.currentPath.value = uppath;
  144.         if (lastpath.lastIndexOf(":") == lastpath.length-1)
  145.             {
  146.             lastpath += "\\";
  147.             }
  148.         changeDir(uppath);
  149.         }
  150.     
  151.     function changeDir(newpath)
  152.         {
  153.         var thispath = "JSBrwSet.asp?btype=" + top.opener.JSBrowser.browsertype + "&path=" + escape(newpath);
  154.         parent.hlist.location.href = thispath;
  155.         return false;
  156.         }
  157.     
  158.     function setPath()
  159.         {        
  160.         top.opener.JSBrowser.currentFile = parent.filter.document.userform.currentFile.value;
  161.         top.opener.JSBrowser.currentPath = document.userform.currentPath.value;        
  162.         top.opener.JSBrowser.BrowserObjSetPath();
  163.         top.location.href = "JSBrwCl.asp";        
  164.         }
  165.     
  166.     function SetFilter(selFilter)
  167.         {
  168.         listFunc.filterType = selFilter.options[selFilter.selectedIndex].value;
  169.         loadList();
  170.         }
  171.  
  172.  
  173.     function numOrder(a,b)
  174.         {
  175.         return a[listFunc.sortby]-b[listFunc.sortby];
  176.         }
  177.  
  178.     function sortList(sortby)
  179.         {
  180.         if (sortby != listFunc.sortby)
  181.             {
  182.             listFunc.sortby = sortby;
  183.             listFunc.sortAsc = true;
  184.             }
  185.         else
  186.             {
  187.             listFunc.sortAsc = !listFunc.sortAsc;
  188.             }
  189.  
  190.         listItem = cachedList[0];
  191.         var num = parseFloat(listItem[sortby]);
  192.  
  193.         if (isNaN(num))
  194.             {
  195.             cachedList.sort(sortOrder);
  196.             }
  197.         else
  198.             { 
  199.             cachedList.sort(numOrder);
  200.             }
  201.             
  202.         if (!listFunc.sortAsc)
  203.             {
  204.             cachedList.reverse();
  205.             }
  206.         redrawList();
  207.         }
  208.  
  209.     function sortOrder(a,b)
  210.         {
  211.         
  212.         astr = a["ftype"] + a[listFunc.sortby]
  213.         bstr = b["ftype"] + b[listFunc.sortby]
  214.         
  215.         
  216.         if (astr.toLowerCase() < bstr.toLowerCase())
  217.             {
  218.             return -1;
  219.             }
  220.         else
  221.             {
  222.             if (astr.toLowerCase() > bstr.toLowerCase())
  223.                 {
  224.                 return 1;
  225.                 }
  226.             else
  227.                 {
  228.                 return 0;
  229.                 }
  230.             }
  231.         }
  232.  
  233.         
  234.     function crop(thestring,size)
  235.         {
  236.         if (top.opener.JSBrowser.sysfontsize == 1)
  237.             {
  238.                 size = size-10;
  239.             }
  240.         if (thestring.length > size)
  241.             {
  242.             thestring = thestring.substring(0,size) + "...";
  243.             }
  244.         return thestring;
  245.         }
  246.  
  247.  
  248.     function fullname(fname,fext)
  249.         {
  250.         if (fext == "")
  251.             {
  252.             return fname;        
  253.             }
  254.         else
  255.             {            
  256.             return (fname + "." + fext);
  257.             }
  258.         }
  259.         
  260.     function formatsize(iStr)
  261.         {
  262.             iStr = iStr.round;
  263.             return iStr;
  264.         }
  265.     
  266.     function listObj(fpath, fname,fext, fsize, ftype, lastupdated)
  267.         {
  268.         this.path = fpath;
  269.         if (ftype == "File Folder")
  270.             {
  271.             this.icon = "dir.gif"
  272.             }
  273.         else
  274.             {
  275.             this.icon = "file.gif"
  276.             }
  277.         this.fname = fname;    
  278.         this.fext = fext;
  279.         this.displayname = crop(fullname(fname,fext),30);    
  280.         this.fsize = fsize;
  281.         this.displaysize = formatsize(fsize);
  282.         this.ftype = ftype;
  283.         this.lastupdated = lastupdated;
  284.         this.displaydate = crop(lastupdated,20);
  285.         this.deleted = false;
  286.         this.updated = false;
  287.         this.newitem = false;
  288.         }
  289.     
  290.     cachedList = new Array();    
  291.     listFunc = new listFuncs();
  292.     
  293. </SCRIPT>
  294.  
  295. </BODY>
  296. </HTML>
  297.