-
Notifications
You must be signed in to change notification settings - Fork 30
/
d.html
85 lines (66 loc) · 2.1 KB
/
d.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<html>
<head>
<script language="javascript">
<!--
var xmlhttp = new XMLHttpRequest( );
var progress = 0;
var bytesDownloaded = 0;
var timeSpent = 0;
var blob = "";
var file = "";
var log;
var running = false;
function a( f ) {
log = document.getElementById( "log" );
log.textContent += "downloader initialized with " + f + "\n";
file = f;
parent.onMessage( "DI " + file + " " + new Date( ).getTime( ) );
}
function b( ) {
log.textContent += "sent " + blob.length + "\n";
return( blob );
}
function c( e ) { // similar to the way WebWorkers functions but usually e is an object. (e.data) We'll just work with e as a string.
var start = new Date( ).getTime( );
var stop = start;
if ( e.substr( 0, 1 ) == "R" ) { // Run the test
running = true;
xmlhttp.onreadystatechange = function( ) {
if ( xmlhttp.readyState == 3 ) {
progress = xmlhttp.responseText.length / xmlhttp.getResponseHeader( "Content-Length" );
bytesDownloaded = xmlhttp.responseText.length;
timeSpent = new Date( ).getTime( ) - start;
}
else if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
stop = new Date( ).getTime( );
running = false;
progress = 1;
blob = xmlhttp.responseText;
parent.onMessage( "DF " + xmlhttp.responseText.length + " " + ( stop - start ) );
}
}
xmlhttp.open( "GET", file + "?" + new Date( ).getTime( ), true );
start = new Date( ).getTime( );
xmlhttp.send( );
parent.onMessage( "DR" );
}
else if ( e.substr( 0, 1 ) == "P" ) { // Progress
parent.onMessage( "DP " + progress + " " + bytesDownloaded + " " + timeSpent );
}
else if ( e.substr( 0, 1 ) == "G" ) { // Get blob (to be used by upload worker)
parent.onMessage( "G" + xmlhttp.responseText );
}
else {
parent.onMessage( "ERROR" );
}
}
function r( ) {
return( running );
}
// -->
</script>
</head>
<body>
<pre id="log"></pre>
</body>
</html>