3
<title>Downloading -FILENAME- (-FILESIZE- bytes)</title>
4
<script language='javascript'>
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);
22
string += "0"+minutes;
31
string += "0"+seconds;
39
function filesizestring(bytes) {
40
var gb = Math.floor(bytes/1073741824);
42
return gb.toString()+" Gb";
43
var mb = Math.floor(bytes/1048576);
45
return mb.toString()+" Mb";
46
var kb = Math.floor(bytes/1024);
48
return kb.toString()+" Kb";
49
return bytes.toString()+" bytes";
51
function progressupdate(got, speed) {
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);
59
msg = "Time remaining: unknown; "+filesizestring(speed)+"/s; total downloaded: "+filesizestring(got);
61
document.getElementById('message1').innerHTML = msg;
63
function nowscanning() {
64
for (var i = 1; i <=16; i++)
65
document.getElementById('progress'+i).style.backgroundColor = 'blue';
67
var msg = "Download complete! Now scanning...";
68
document.getElementById('message1').innerHTML = msg;
71
function downloadlink(rawlink, prettylink, type) {
73
var msg = "File scanned";
75
var msg = "File downloaded, but not scanned due to size";
77
var msg = "File too large to cache, please download directly";
78
document.getElementById('message1').innerHTML = msg;
80
document.getElementById('message2').innerHTML = "<a href='"+rawlink+"'>"+prettylink+"</a>";
82
document.getElementById('message2').innerHTML = "<a href='"+prettylink+"'>"+prettylink+"</a>";
83
document.write("</body></html>");
85
function downloadwarning(sizelimit) {
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.";
93
<script language='javascript'>
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> \
116
<center><p><tt id='message1'></tt></p><p id='message2' style='color: #600;'></p></center>"));
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
125
- FILESIZE- of zero indicates that file size is not known
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.
130
The following JavaScript functions must be defined:
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).
137
got - how much of the file we have downloaded, in bytes.
138
speed - current estimate of download speed, in bytes per second.
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.)
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.
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.
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
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).
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