Debian Codegraph @

debian/upload.html

raw symbols SCIP
1 <!DOCTYPE html
2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6 <title>mod_upload_progress test page</title>
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
8 <script type="text/javascript">// <![CDATA[
9 interval = null;
10
11 function fetch(uuid) {
12 req = new XMLHttpRequest();
13 req.open("GET", "/progress", 1);
14 req.setRequestHeader("X-Progress-ID", uuid);
15 req.onreadystatechange = function () {
16 if (req.readyState == 4) {
17 if (req.status == 200) {
18 /* poor-man JSON parser */
19 document.getElementById('dump').innerHTML = req.responseText;
20 var upload = eval('new Object(' + req.responseText + ')');
21
22 document.getElementById('tp').innerHTML = upload.state;
23
24 /* change the width if the inner progress-bar */
25 if (upload.state == 'done' || upload.state == 'uploading') {
26 bar = document.getElementById('progressbar');
27 w = 400 * upload.received / upload.size;
28 bar.style.width = w + 'px';
29 }
30 /* we are done, stop the interval */
31 if (upload.state == 'done') {
32 bar = document.getElementById('progressbar');
33 bar.style.width = '398px';
34 window.clearTimeout(interval);
35 }
36 }
37 }
38 }
39 req.send(null);
40 }
41
42 function openProgressBar(event) {
43 /* generate random progress-id */
44 uuid = "";
45 for (i = 0; i < 32; i++) {
46 uuid += Math.floor(Math.random() * 16).toString(16);
47 }
48 /* create an iframe as a form target */
49 document.getElementById("frameholder").innerHTML =
50 '<iframe id="uploadframe" name="uploadframe" width="0" height="0" ' +
51 'frameborder="0" border="0" src="about:blank"></iframe>';
52 /* patch the form-action tag to include the progress-id */
53 var form = document.getElementById("upload");
54 form.action="/upload.html?X-Progress-ID=" + uuid;
55 form.target="uploadframe";
56 /* call the progress-updater every 1000ms */
57 interval = window.setInterval(
58 function () {
59 fetch(uuid);
60 },
61 1000
62 );
63 form.submit();
64 return false;
65 }
66 // ]]>
67 </script>
68 </head>
69 <body>
70 <h1>mod_upload_progress test page</h1>
71 <div>
72 <form id="upload" enctype="multipart/form-data"
73 action="/upload.html" method="post"
74 onsubmit="return openProgressBar();">
75 <div>
76 <input type="hidden" name="MAX_FILE_SIZE" value="30000000" />
77 <input name="userfile" type="file" />
78 <input type="submit" value="Send File" />
79 </div>
80 </form>
81 </div>
82 <div>
83 <div id="progress" style="width: 400px; border: 1px solid black">
84 <div id="progressbar"
85 style="width: 1px; background-color: black; border: 1px solid white">
86 &nbsp;
87 </div>
88 </div>
89 <div id="tp">(throughput)</div>
90 <pre id="dump"></pre>
91 <div id="frameholder"></div>
92 </div>
93 </body>
94 </html>