| 1 |
<html> |
| 2 |
<head> |
| 3 |
<title>Downloading -FILENAME- (-FILESIZE- bytes)</title> |
| 4 |
<script language='javascript'> |
| 5 |
<!-- |
| 6 |
var scanned = 1; |
| 7 |
var fs = -FILESIZE-; |
| 8 |
function timestring(seconds) { |
| 9 |
var hours = Math.floor(seconds/3600); |
| 10 |
var minutes = Math.floor((seconds/60) - (hours*3600)); |
| 11 |
var seconds = seconds - (minutes*60) - (hours*3600); |
| 12 |
var string = ""; |
| 13 |
if (hours > 0) { |
| 14 |
if (hours < 10) |
| 15 |
string = "0"+hours; |
| 16 |
else |
| 17 |
string = hours; |
| 18 |
string += ":"; |
| 19 |
} |
| 20 |
if (minutes > 0) { |
| 21 |
if (minutes < 10) |
| 22 |
string += "0"+minutes; |
| 23 |
else |
| 24 |
string += minutes; |
| 25 |
} else { |
| 26 |
string += "00"; |
| 27 |
} |
| 28 |
string += ":"; |
| 29 |
if (seconds > 0) { |
| 30 |
if (seconds < 10) |
| 31 |
string += "0"+seconds; |
| 32 |
else |
| 33 |
string += seconds; |
| 34 |
} else { |
| 35 |
string += "00"; |
| 36 |
} |
| 37 |
return string; |
| 38 |
} |
| 39 |
function filesizestring(bytes) { |
| 40 |
var gb = Math.floor(bytes/1073741824); |
| 41 |
if (gb > 0) |
| 42 |
return gb.toString()+" Gb"; |
| 43 |
var mb = Math.floor(bytes/1048576); |
| 44 |
if (mb > 0) |
| 45 |
return mb.toString()+" Mb"; |
| 46 |
var kb = Math.floor(bytes/1024); |
| 47 |
if (kb > 0) |
| 48 |
return kb.toString()+" Kb"; |
| 49 |
return bytes.toString()+" bytes"; |
| 50 |
} |
| 51 |
function progressupdate(got, speed) { |
| 52 |
var msg; |
| 53 |
if (fs > 0) { |
| 54 |
var sofar = (got/fs)*16; |
| 55 |
for (var i = 1; i <=sofar; i++) |
| 56 |
document.getElementById('progress'+i).style.backgroundColor = 'blue'; |
| 57 |
msg = Math.round((got/-FILESIZE-)*100)+"%, time remaining: "+timestring(Math.round((fs-got)/speed))+"; "+filesizestring(speed)+"/s; total downloaded: "+filesizestring(got); |
| 58 |
} else { |
| 59 |
msg = "Time remaining: unknown; "+filesizestring(speed)+"/s; total downloaded: "+filesizestring(got); |
| 60 |
} |
| 61 |
document.getElementById('message1').innerHTML = msg; |
| 62 |
} |
| 63 |
function nowscanning() { |
| 64 |
for (var i = 1; i <=16; i++) |
| 65 |
document.getElementById('progress'+i).style.backgroundColor = 'blue'; |
| 66 |
if (scanned == 1) { |
| 67 |
var msg = "Download complete! Now scanning..."; |
| 68 |
document.getElementById('message1').innerHTML = msg; |
| 69 |
} |
| 70 |
} |
| 71 |
function downloadlink(rawlink, prettylink, type) { |
| 72 |
if (type == 0) |
| 73 |
var msg = "File scanned"; |
| 74 |
else if (type == 1) |
| 75 |
var msg = "File downloaded, but not scanned due to size"; |
| 76 |
else if (type == 2) |
| 77 |
var msg = "File too large to cache, please download directly"; |
| 78 |
document.getElementById('message1').innerHTML = msg; |
| 79 |
if (type != 2) |
| 80 |
document.getElementById('message2').innerHTML = "<a href='"+rawlink+"'>"+prettylink+"</a>"; |
| 81 |
else |
| 82 |
document.getElementById('message2').innerHTML = "<a href='"+prettylink+"'>"+prettylink+"</a>"; |
| 83 |
document.write("</body></html>"); |
| 84 |
} |
| 85 |
function downloadwarning(sizelimit) { |
| 86 |
scanned = 0; |
| 87 |
document.getElementById('message2').innerHTML = "Warning: File too large for content scanning. If you suspect that this file is larger than "+filesizestring(sizelimit)+", refresh this page to download directly."; |
| 88 |
} |
| 89 |
//--> |
| 90 |
</script> |
| 91 |
</head> |
| 92 |
<body> |
| 93 |
<script language='javascript'> |
| 94 |
<!-- |
| 95 |
document.write(unescape("\ |
| 96 |
<table align='center'><tr><td>\ |
| 97 |
<div style='font-size:8pt;padding:2px;border:solid black 1px'>\ |
| 98 |
<span id='progress1'>%26nbsp; %26nbsp;</span> \ |
| 99 |
<span id='progress2'>%26nbsp; %26nbsp;</span> \ |
| 100 |
<span id='progress3'>%26nbsp; %26nbsp;</span> \ |
| 101 |
<span id='progress4'>%26nbsp; %26nbsp;</span> \ |
| 102 |
<span id='progress5'>%26nbsp; %26nbsp;</span> \ |
| 103 |
<span id='progress6'>%26nbsp; %26nbsp;</span> \ |
| 104 |
<span id='progress7'>%26nbsp; %26nbsp;</span> \ |
| 105 |
<span id='progress8'>%26nbsp; %26nbsp;</span> \ |
| 106 |
<span id='progress9'>%26nbsp; %26nbsp;</span> \ |
| 107 |
<span id='progress10'>%26nbsp; %26nbsp;</span> \ |
| 108 |
<span id='progress11'>%26nbsp; %26nbsp;</span> \ |
| 109 |
<span id='progress12'>%26nbsp; %26nbsp;</span> \ |
| 110 |
<span id='progress13'>%26nbsp; %26nbsp;</span> \ |
| 111 |
<span id='progress14'>%26nbsp; %26nbsp;</span> \ |
| 112 |
<span id='progress15'>%26nbsp; %26nbsp;</span> \ |
| 113 |
<span id='progress16'>%26nbsp; %26nbsp;</span> \ |
| 114 |
</div>\ |
| 115 |
</td></tr></table>\ |
| 116 |
<center><p><tt id='message1'></tt></p><p id='message2' style='color: #600;'></p></center>")); |
| 117 |
//--> |
| 118 |
</script> |
| 119 |
|
| 120 |
<!-- |
| 121 |
The available variables are as follows: |
| 122 |
- FILENAME- gives the name of the file being downloaded |
| 123 |
- FILESIZE- gives the size of the file in bytes |
| 124 |
|
| 125 |
- FILESIZE- of zero indicates that file size is not known |
| 126 |
|
| 127 |
You need to remove the space between the - and the variable to use them |
| 128 |
in your HTML. They are there above so extra processing is not required. |
| 129 |
|
| 130 |
The following JavaScript functions must be defined: |
| 131 |
|
| 132 |
progressupdate(got, speed) |
| 133 |
This is called when the page is initially displayed (i.e. after |
| 134 |
initialtrickledelay has passed), and periodically afterwards to |
| 135 |
update progress (once every trickledelay seconds). |
| 136 |
Parameters: |
| 137 |
got - how much of the file we have downloaded, in bytes. |
| 138 |
speed - current estimate of download speed, in bytes per second. |
| 139 |
|
| 140 |
nowscanning() |
| 141 |
This is called once downloading is complete, and scanning has |
| 142 |
begun. (Note: scanning has not actually begun if downloadwarning() |
| 143 |
has been called at some point.) |
| 144 |
|
| 145 |
downloadlink(rawlink, prettylink, type) |
| 146 |
This is called after scanning has completed, and the file is |
| 147 |
ready to be sent to the user. |
| 148 |
Parameters: |
| 149 |
rawlink - the URL from which the scanned file can be grabbed |
| 150 |
prettylink - the original URL which triggered the fancy download manager |
| 151 |
type - the status of the download/scan: |
| 152 |
0 - downloaded & scanned |
| 153 |
1 - downloaded, but too big to have been scanned |
| 154 |
2 - too big to be completely downloaded |
| 155 |
codes 1 and 2 can only be encountered on files for which the content |
| 156 |
length is not known in advance. "rawlink" should be ignored for code 2. |
| 157 |
|
| 158 |
downloadwarning(sizelimit) |
| 159 |
This is called when a file with unknown content-length has exceeded |
| 160 |
the configured maxcontentfilecachescansize. Used to warn the user |
| 161 |
that the fancy DM may not be able to retrieve the entire file, |
| 162 |
and that they should download directly (refresh the page; the URL will |
| 163 |
have been added to DG's clean cache) if they know it to be larger |
| 164 |
than sizelimit. |
| 165 |
sizelimit - the value of the fancy DM's maxdownloadsize. If a file |
| 166 |
exceeds this limit also, the fancy DM cannot continue |
| 167 |
(will trigger downloadlink status type 2). |
| 168 |
|
| 169 |
Please note that the fancy download manager also outputs content contained in |
| 170 |
<noscript> tags, for browsers which disable or do not support javascript. If you |
| 171 |
customise this template, you may wish to test its behaviour and appearance in |
| 172 |
such circumstances. |
| 173 |
--> |