-
Notifications
You must be signed in to change notification settings - Fork 30
/
u.html
77 lines (59 loc) · 1.73 KB
/
u.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
<html>
<head>
<script language="javascript">
<!--
var xmlhttp = new XMLHttpRequest( );
var progress = 0;
var speed = 0;
var blob;
var log;
var running = false;
function a( ) {
log = document.getElementById( "log" );
log.textContent += "uploader initialized\n";
parent.onMessage( "UI " + new Date( ).getTime( ) );
}
function b( b ) {
blob = b;
log.textContent += "got " + blob.length + "\n";
}
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 = blob.length / xmlhttp.getResponseHeader( "Content-Length" );
speed = progress / ( new Date( ).getTime( ) - start );
}
else if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
stop = new Date( ).getTime( );
running = false;
progress = 1;
speed = 0;
parent.onMessage( "UF " + blob.length + " " + ( stop - start ) );
}
}
xmlhttp.open( "POST", "blank.dat?" + new Date( ).getTime( ), true );
start = new Date( );
parent.onMessage( "UR" );
xmlhttp.send( blob );
}
else if ( e.substr( 0, 1 ) == "P" ) { // Progress
parent.onMessage( "UP " + progress + " " + speed );
}
else {
parent.onMessage( "ERROR" );
}
}
function r( ) {
return( running );
}
// -->
</script>
</head>
<body>
<pre id="log"></pre>
</body>
</html>