Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


HTML status page with counter

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,41032
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> HTML status page with counter
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 HTML status page with counter - 12/15/2006 2:43:24 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I have a rather large script that ends up either moving or copying a large number of file.  As of right now I have my script opening up a small IE window displaying the word "Working..." that bounces back and forth marquee style.  Once the script is finished, the work "Finished!" comes up.

I was looking for ideas on how I could make a counter of some sort to increment with each file that is copied.  I tried to find a way to take a regular web hit counter and modify it to count, but couldn't figure that out.

Thoughts?
 
 
Post #: 1
 
 RE: HTML status page with counter - 12/15/2006 2:47:21 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Wouldn't it work to just have a div on the page and update its contents with a count?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to esnmb)
 
 
Post #: 2
 
 RE: HTML status page with counter - 12/15/2006 2:53:45 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Most likely.  Now at least I have a direction.  I'm not really that great at html.

thanks for the idea.

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: HTML status page with counter - 12/15/2006 3:59:12 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
So lost.  The page ends up just counting and adding to the page instead of replacing the digit that was already there.

(in reply to esnmb)
 
 
Post #: 4
 
 RE: HTML status page with counter - 12/15/2006 4:00:22 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Let's see the code.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to esnmb)
 
 
Post #: 5
 
 RE: HTML status page with counter - 12/15/2006 4:03:10 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
''''''''''''''''''Creates an Internet Explorer instance to display script status '''''''''''''''''''
Set objExplorer = Wscript.CreateObject("InternetExplorer.Application", "IE_")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Top = 180
objExplorer.Left = 200
objExplorer.Width = 630
objExplorer.Height = 320
objExplorer.Visible = 1
objExplorer.Resizable = 0
Do While (objExplorer.Busy)
Wscript.Sleep 250
Loop
'Defines HTML code for status window
Set objDocument = objExplorer.Document
objDocument.Open
objDocument.Writeln "<html><head><title>^^ Status Window^^</title></head>"
objDocument.Writeln "<style type=""text/css"">body {background-color: #FFFFFF;}"_
& ".style2 {font-family: Arial, Helvetica, sans-serif;font-size: 10.5pt;color: "_
& "#CC6600;font-weight: bold;}.style3 {font-family: Arial, Helvetica, sans-serif}"_
& "body,td,th {font-family: Arial, Helvetica, sans-serif;}</style></head><body>"
objDocument.body.style.cursor = "Wait"
objDocument.Writeln "<p class=""style2""><B>Collecting Folder Sizes...  If IE seems hung, give it a moment...<br>"
objDocument.Writeln "</B><i>If this window is closed the script will terminate.</i><br>"
objDocument.Writeln "<br>Please be patient...</p>"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
x = 0
' ---------- Your code here
For i = 0 To 100
Wscript.Sleep 200
objDocument.Write "<H3 id=myH1 onChange=""this.innerHTML='" & x & "'"">" & x & "</H3>"
x = x + 1
Next
'Completes HTML code for status window and closes it.
objDocument.Writeln "<p class=""style2"">Finished!</p>"
objDocument.body.style.cursor = "Default"
objDocument.Writeln "</body></html>"
objDocument.Writeln()
objDocument.Close
'Sub to quit the script if IE is closed.
Sub IE_onQuit()
Wscript.Quit
End Sub


(in reply to ebgreen)
 
 
Post #: 6
 
 RE: HTML status page with counter - 12/15/2006 4:11:23 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Use the DOM and get a reference to the div. Then update its .InnerText.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to esnmb)
 
 
Post #: 7
 
 RE: HTML status page with counter - 12/15/2006 5:14:49 AM   
  TNO


Posts: 1056
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Heres a slick progress bar I've been working on for loading images on my website:


      

Maybe this will give you an idea

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to esnmb)
 
 
Post #: 8
 
 RE: HTML status page with counter - 12/15/2006 5:18:58 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
So I would call function Sample() in the for each?

(in reply to TNO)
 
 
Post #: 9
 
 RE: HTML status page with counter - 12/15/2006 5:28:06 AM   
  TNO


Posts: 1056
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
make part=0, whole=total files and change part=part+10 to +1 instead and call Sample()

Its just a  proof of concept, the code could be ALOT prettier. I just wanted to show the basics of a sleek looking loading bar

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to esnmb)
 
 
Post #: 10
 
 RE: HTML status page with counter - 12/15/2006 5:40:12 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I put your code into a VBS for testing.  The buttons don't seem to work.

Set objExplorer = Wscript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Top = 180
objExplorer.Left = 200
objExplorer.Width = 630
objExplorer.Height = 320
objExplorer.Visible = 1
objExplorer.Resizable = 0
Do While (objExplorer.Busy)
Wscript.Sleep 250
Loop
'Defines HTML code for status window
Set objDocument = objExplorer.Document
objDocument.Open
objDocument.Writeln "<html>" _
& "<head><script type=""text/vbscript"">"
objDocument.Writeln "Dim part"
objDocument.Writeln "part=0"
objDocument.Writeln "Dim whole"
objDocument.Writeln "whole=100"
objDocument.Writeln "Function progress(part,whole)"
objDocument.Writeln "If(part>=whole) Then"
objDocument.Writeln "MsgBox(""Complete"")"
objDocument.Writeln "Else"
objDocument.Writeln "document.getElementById(""LB1"").style.width=Round(part/whole*100)"
objDocument.Writeln "document.getElementById(""status"").innerText=Round(part/whole*100) & ""%"""
objDocument.Writeln "End If"
objDocument.Writeln "End Function"
objDocument.Writeln "Function Sample()"
objDocument.Writeln "part=part+10"
objDocument.Writeln "progress part,whole"
objDocument.Writeln "End Function"
objDocument.Writeln "Function Reset()"
objDocument.Writeln "part=0"
objDocument.Writeln "document.getElementById(""LB1"").style.width=0"
objDocument.Writeln "document.getElementById(""status"").innerText="""
objDocument.Writeln "End Function"
objDocument.Writeln "</script>"
objDocument.Writeln "</head>"
objDocument.Writeln "<body style=""background-color:black;color:white"">"
objDocument.Writeln "<span id=""LB0"" style=""position:absolute;left:50%;top:50%;"">"
objDocument.Writeln "<span style=""position:absolute;font-family:arial;font-size:10px;color:#FFFFFF;left:-50;top:-18"">"
objDocument.Writeln "Loading...<span id=""status""></span>"
objDocument.Writeln "</span>"
objDocument.Writeln "<span style=""position:absolute;left:-50;top:-5;font-size:1px;width:100;height:10px;background:#333"">"
objDocument.Writeln "<span id=""LB1"" style=""position:absolute;left:0;top:0;font-size:1px;width:0;height:10px;background:#FFFFFF""></span>"
objDocument.Writeln "</span>"
objDocument.Writeln "</span>"
objDocument.Writeln "<center><button onclick=""Sample"">Progress!!!</button><button onclick=""Reset"">Reset</button></center>"
objDocument.Writeln "</body>"
objDocument.Writeln "</html>"
objDocument.Writeln()
objDocument.Close

(in reply to TNO)
 
 
Post #: 11
 
 RE: HTML status page with counter - 12/15/2006 5:47:59 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I have it working now.  Now to try to count files.

(in reply to esnmb)
 
 
Post #: 12
 
 RE: HTML status page with counter - 12/15/2006 5:49:28 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Also, I don't know totalFiles.

(in reply to TNO)
 
 
Post #: 13
 
 RE: HTML status page with counter - 12/15/2006 6:17:19 AM   
  TNO


Posts: 1056
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
hmm, you're going to need the total files to determing the correct %.

Somehwere in your code you could increment the total count before hand right? If you're manipulating the files in some way, then you have a means of getting how many there are. For Each File In Folder totalcount=totalcount+1 or something.

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to esnmb)
 
 
Post #: 14
 
 RE: HTML status page with counter - 12/15/2006 6:22:04 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
"whole" would be the totalcount correct?

(in reply to TNO)
 
 
Post #: 15
 
 RE: HTML status page with counter - 12/15/2006 6:42:12 AM   
  TNO


Posts: 1056
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
correct

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to esnmb)
 
 
Post #: 16
 
 RE: HTML status page with counter - 12/15/2006 6:46:10 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
The thing is my script calls many different subs and copy files from multiple locations.
I have it working where I update the progress bar in my subs, but I don't know how to get the folder count and pass it back up to the whole variable.  Not sure if it's possible.

(in reply to TNO)
 
 
Post #: 17
 
 RE: HTML status page with counter - 12/15/2006 8:08:30 AM   
  TNO


Posts: 1056
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
You could create an array and append the fullpath of each file to it instead of copy, then at the very end iterate the array to get the total count, and copy

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to esnmb)
 
 
Post #: 18
 
 RE: HTML status page with counter - 12/15/2006 8:11:43 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
yeah.  This is becoming to complicated for this already complicated script.

I will just use a standard web page to show it is running and when it is finished.

But I will most certainly use your progress bar in future script.  Thanks a lot!

(in reply to TNO)
 
 
Post #: 19
 
 RE: HTML status page with counter - 12/15/2006 8:13:16 AM   
  TNO


Posts: 1056
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
I assume your code is designed somthing like this:

Sub  blah
   do some stuff
  copy files

End Sub

Sub  blah
   do some stuff
   copy files

End Sub

Sub  blah
   do some stuff
   copy files

End Sub

Sub  blah
   do some stuff
   copy files

End Sub

If so, then what I meant by my last post is, do something like this instead:

MyArray=blah()


Sub  blah
   do some stuff
   Add file paths to Array

End Sub

Sub  blah
   do some stuff
  
Add file paths to Array
End Sub

Sub  blah
   do some stuff
  
Add file paths to Array
End Sub

Sub  blah
   do some stuff
  
Add file paths to Array
End Sub

Get size of array for total count
part = current count in array
for each item in array, update progress bar, copy file

hope this helps

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to TNO)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> HTML status page with counter Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts