home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 September / CHIPCD_9_99.iso / software / uaktualnienia / OptionPackPL / iis4_02.cab / JSBrwHd.asp < prev    next >
Encoding:
Text File  |  1998-04-27  |  7.1 KB  |  332 lines

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