Re: Large amount of image files, causes freeze.

  •  10-29-2009, 9:44 AM

    Re: Large amount of image files, causes freeze.

    Got it down to 10 sec now!!!

    Edited your browse_Img.asp Showbrowse_Img-function to this and added this class.

     

    Function Showbrowse_Img(spec)

     Dim f, sf, fol, fc, fil, s, ext, counter
     Dim fso
     Set tmpstrm = New StrConCatArray
     Set fso = Server.CreateObject("Scripting.FileSystemObject")

     Set f = fso.GetFolder(spec)
     Set sf = f.SubFolders
     tmpstrm.Add "<table border=""0"" cellspacing=""1"" cellpadding=""1"" valign=""top"" id=""FoldersAndFiles"" style=""width:100%"" class=sortable>"
     tmpstrm.Add "<tr onMouseOver=""row_over(this)"" onMouseOut=""row_out(this)"" bgcolor=""#f0f0f0"">"
     tmpstrm.Add "<td width=16 nowrap><img src=""../images/refresh.gif"" alt=""refresh"" onclick=""parent.Refresh('"&folpath&"');"" onMouseOver=""parent.CuteEditor_ColorPicker_ButtonOver(this);"" style=""VERTICAL-ALIGN: middle""></td>"
     tmpstrm.Add "<td width=""60%"" Class=""filelistHeadCol""><b>Name</b></td>"
     tmpstrm.Add "<td nowrap Class=""filelistHeadCol""><b>Size</b></td>"
     If CBool(AllowDelete) Then
      tmpstrm.Add "<td nowrap></td>" 
     End If
     If CBool(AllowRename) Then
      tmpstrm.Add "<td nowrap></td>" 
     End If
     tmpstrm.Add "</tr>"
     tmpstrm.Add "<tr onMouseOver=""row_over(this)"" onMouseOut=""row_out(this)"" onclick=""Editor_upfolder();"">"
     tmpstrm.Add "<td><img src=""../images/parentfolder.gif"" alt=""Go up one level"" style=""VERTICAL-ALIGN: middle""></td>"
     tmpstrm.Add "<td>...</td>"
     tmpstrm.Add "<td></td>"
     If CBool(AllowDelete) Then
      tmpstrm.Add "<td nowrap></td>" 
     End If
     If CBool(AllowRename) Then
      tmpstrm.Add "<td nowrap></td>" 
     End If
     tmpstrm.Add "</tr>" 
     
     For Each fol In sf 'add the html for the folders
      dim str_openfolderEvent
      str_openfolderEvent = "onclick=""parent.SetUpload_FolderPath('"&current_Path&folpath&fol.name&"');location.href='browse_Img.asp?"&setting&"&loc=" & folpath & fol.name & "&GP="&current_Path&"';"""
      tmpstrm.Add "<tr onMouseOver=""row_over(this)"" onMouseOut=""row_out(this)"">"
      tmpstrm.Add "<td "&str_openfolderEvent&"><img vspace=""0"" hspace=""0"" src=""../images/closedfolder.gif"" style=""VERTICAL-ALIGN: middle""></td>" & vbcrlf
      tmpstrm.Add "<td valign=""top"" style=""cursor:pointer"" "&str_openfolderEvent&">" & vbcrlf
      tmpstrm.Add fol.name & "&nbsp;&nbsp;</td>" & vbcrlf
      tmpstrm.Add "<td NOWRAP style=""cursor:pointer;"" "&str_openfolderEvent&">" & FormatSize(fol.size) & "</td>"
      if CBool(AllowDelete) Then
       tmpstrm.Add "<td NOWRAP style=""cursor:pointer; border:1px"" ><img vspace=""0"" hspace=""0"" src=""../images/delete.gif"" onclick=""deletefolder('" & current_Path & folpath  & fol.name & "')"" alt=""Delete""></td>"
      End If
      if CBool(AllowRename) Then 
       tmpstrm.Add "<td NOWRAP style=""cursor:pointer; border:1px"" ><img vspace=""0"" hspace=""0"" src=""../images/edit.gif"" alt=""Rename"" onclick=""renamefolder('" & current_Path & folpath  & fol.name & "')""></td>"
      End If  
      tmpstrm.Add "</tr>" & vbcrlf
     Next
     Set fc = f.Files
     
     dim filename
     For Each fil In fc 'add the html for the files
      filename=fil.name
      MyPath=current_Path & folpath & filename
      If (InStr(fil.name, "'" ) = 0) Then
       If ValidImage(filename) Then
        tmpstrm.Add "<tr onMouseOver=""row_over(this)"" onMouseOut=""row_out(this)"" onclick=""parent.row_click('"
        tmpstrm.Add MyPath
        tmpstrm.Add "'); "">"
        tmpstrm.Add "<td style=""cursor:pointer"" ><img hspace=""3"" vspace=""1"" src=""../images/"
        tmpstrm.Add GetExtension(filename)
        tmpstrm.Add ".gif"" border=""0"" alt="""" style=""VERTICAL-ALIGN: middle""></td>"
        tmpstrm.Add "<td align=""left"" valign=""top"" style=""cursor:pointer"" >"
        tmpstrm.Add filename
        tmpstrm.Add "</td>"
        tmpstrm.Add "<td NOWRAP>"
        tmpstrm.Add FormatSize(fil.size)
        tmpstrm.Add "</td>"
        if CBool(AllowDelete) Then
         tmpstrm.Add "<td><img vspace=""0"" hspace=""0"" src=""../images/delete.gif"" alt=""Delete"" onclick=""deletefile('"
         tmpstrm.Add MyPath
         tmpstrm.Add "')""></td>"
        End If
        if CBool(AllowRename) Then 
         tmpstrm.Add "<td><img vspace=""0"" hspace=""0"" src=""../images/edit.gif"" alt=""Rename"" onclick=""renamefile('"
         tmpstrm.Add MyPath
         tmpstrm.Add "','"
         tmpstrm.Add filename
         tmpstrm.Add "')""></td>"
        End If
        tmpstrm.Add "</tr>"
       End If
      End If
     Next
     tmpstrm.Add "</table>"
     Showbrowse_Img = tmpstrm.value
      Set tmpstrm = Nothing
      set f=nothing
     set fso=nothing
      
    End Function


    Class StrConCatArray
     Private StringCounter
     Private StringArray()
     Private StringLength
     
     'called at creation of instance
     Private Sub Class_Initialize()
      StringCounter = 0
      InitStringLength = 128
      ReDim StringArray(InitStringLength - 1)
      StringLength = InitStringLength
     End Sub
     
     Private Sub Class_Terminate()
      Erase StringArray
     End Sub

     'add new string to array
     Public Sub Add(byref NewString)
      StringArray(StringCounter) = NewString
      StringCounter = StringCounter + 1
      
      'ReDim array if necessary
      If StringCounter MOD StringLength = 0 Then
       'redimension
       ReDim Preserve StringArray(StringCounter + StringLength - 1)
       
       'double the size of the array next time
       StringLength = StringLength * 2
      End If
     End Sub
     
     'return the concatenated string
     Public Property Get Value
      Value = Join(StringArray, "")
     End Property
     
     'resets array
     Public Function Clear()
      StringCounter = 0
      
      Redim StringArray(InitStringLength - 1)
      StringLength = InitStringLength
     End Function  
    End Class
     
    Now i will dive into the "gallery" (c:
View Complete Thread