rejetto forum

Uploads progress window in custom template

0 Members and 1 Guest are viewing this topic.

Offline exorcist

  • Occasional poster
  • *
    • Posts: 9
  • King of the Dust
    • View Profile
    • Dusted Wax Kingdom
At first, I'm very oldschool and still using the lastest stable version 2.2f :) I made a template that meets my creteria and everything works absolutely great!

I added:
Code: [Select]
onClick="window.open('/~progress');"in the "Upload File" button section code:
Code: [Select]
<input name="upbtn" ... >
Now when the user hits the upload button, it also opens a new window with upload progress.
My question is: Can I use some "trigger" to close this window when the upload is complete?

I've tried the following ways with javascript inserted in the beginning of [progress-upload-file] section:
1)
Code: [Select]
<script type="text/javascript">
if (%perc% > 98) {
 window.close();
}
</script>
2)
Code: [Select]
<script type="text/javascript">
var param = (%total-bytes%-%done-bytes%)/1024-2.5*%speed-kb%;
if (param<0) {
 window.close();
}

Both methods depend of the refresh rate setup in [progress] section and don't work stable.
Any hints will be heartily appreciated! :)

Template file dwk.tpl attached to the post...

« Last Edit: October 29, 2010, 01:00:31 PM by exorcist »
In dust we trust...


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
i have no experience about creating "new windows" with javascript,
but i guess you can keep track of them by using "names", and then close that named window in the "results" page.

have you every seen the current default template of 2.3 ? it has a box inside the page that's updated regularly. It's a joy for the eye. :D
i went for this after firefox not refreshing with the 2.2's method.
« Last Edit: November 01, 2010, 12:25:56 PM by rejetto »


Offline exorcist

  • Occasional poster
  • *
    • Posts: 9
  • King of the Dust
    • View Profile
    • Dusted Wax Kingdom
Closing with javascript works perfectly :) I just can't come up with a proper condition (trigger) when actually the upload is complete (when [progress] switches to [progress-nofiles]) to close the progress window :)
In dust we trust...


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
sorry for the late reply.
did you try putting the javascript code for closing in the [progress-nofiles] ?
that will work just as a trigger