home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_03.cab / jsbrwhd.asp < prev    next >
Text File  |  1997-11-13  |  7KB  |  328 lines

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