Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Yet another progress bar ... progress report.

by Macphisto (Hermit)
on May 29, 2002 at 15:42 UTC ( [id://170118]=note: print w/replies, xml ) Need Help??


in reply to Yet another progress bar.

Okay, so I had to use a wee bit of javascript. I'm not happy about it. I'm seeking counseling for it. Do you know of a good doctor?

Anywho, I got a minimal case working. I'm storing session information with a PostgreSQL database using a random 10 alphanumerics for session_id, so I decided to use the session_id as temporary filename and to rename the file after upload was completed. When a user hits "Upload" there is an OnClick setting that will open a new window( the javascript, it leaves a funny smell on my clothing! ) which due to its title( inventively: /upload/progress ) and some params tacked onto it, gives the progress handler all the information it needs. Every three seconds the window reloads, -s'ing the session_id which is a filename. Currently, I haven't played around enough to see if I can get the total size of the file before hand so I can produce a percentage or a keen little graph. This leads me to the conclusion that a progress bar is highly possible. Maybe my hack isn't the most inventive or pretty thing in the world. However, I'm far from being one of the better perl hackers on this board and I'm sure someone could come up with a more elegant way of doing this. Again, impossible is not a word that perl takes lightly.

Everyone has their demons...you just happen to be.

Replies are listed 'Best First'.
Not your average progress bar
by Aristotle (Chancellor) on May 29, 2002 at 19:44 UTC

    Just suggesting a bit of useless glitz here, which could make it look smoother:

    I was initially going to suggest you try putting an initially empty IFRAME into your upload page, wherein the Javascript then loads the progress meter CGI OnSubmit(). But IFRAMEs are the devil. Even so the idea itself has merit..

    But let's take it to a whole new dimension. Place an initially empty graphic on your page (the transparent singlepixel GIF will do). Your Javascript shall then reload that image from the progress meter CGI's address, which now produces image/png rather then text/html, complete with a Refresh: header. This method should work for any but the very dumbest of browsers and will provide the feedback completely smoothly integrated into your upload page. Now you have the mirrors.

    It's time to add the smoke: have the Javascript replace another, static image of for example a clock with an animated version. Your users will never even know what hit them.

    David Copperfield made the Statue of Liberty disappear, why couldn't you make a progress meter? :-)

    Update: Darn. As Macphisto pointed out, the page with the upload form will be frozen while the upload happens, with no chance to update any images in it. In that case, I guess the only way to resolve this is to use frames in some fashion.

    Actually, it should be possible - the FORM tag has a TARGET attribute just like the A anchor tag does, if memory serves. In that case one could launch the upload into a different frame and set up abovementioned smoke and mirrors. It will require funny Javascript posing though..

    Guess a progress popup really is the only actually workable solution. :-(

    ____________
    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://170118]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-28 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found