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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>qooxdoo » Demo</title>
<link type="text/css" rel="stylesheet" href="../../resource/css/layout.css"/>
<!--[if IE]>
<link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
<![endif]-->
<script type="text/javascript" src="../../script/qx.js"></script>
</head>
<body>
<script type="text/javascript" src="../../script/layout.js"></script>
<div id="demoDescription">
<p>Testing multiple parallel requests of files with different sizes.</p>
</div>
<script type="text/javascript">
qx.core.Init.getInstance().defineMain(function()
{
var lab1 = new qx.ui.basic.Label("40KB");
var lab2 = new qx.ui.basic.Label("400KB");
var lab3 = new qx.ui.basic.Label("4000KB");
var spin1 = new qx.ui.form.Spinner(0, 3, 50);
var spin2 = new qx.ui.form.Spinner(0, 3, 20);
var spin3 = new qx.ui.form.Spinner(0, 3, 10);
var grid = new qx.ui.layout.GridLayout;
grid.setLocation(20, 48);
grid.setDimension(qx.constant.Core.AUTO, qx.constant.Core.AUTO);
grid.setHorizontalSpacing(10);
grid.setVerticalSpacing(4);
grid.setBorder(qx.renderer.border.BorderPresets.getInstance().thinOutset);
grid.setBackgroundColor("white");
grid.setPadding(10);
grid.setColumnCount(3);
grid.setRowCount(2);
grid.setColumnWidth(0, 50);
grid.setColumnWidth(1, 50);
grid.setColumnWidth(2, 50);
grid.setRowHeight(0, 18);
grid.setRowHeight(1, 22);
qx.ui.core.ClientDocument.getInstance().add(grid);
grid.add(lab1, 0, 0);
grid.add(lab2, 1, 0);
grid.add(lab3, 2, 0);
grid.add(spin1, 0, 1);
grid.add(spin2, 1, 1);
grid.add(spin3, 2, 1);
var btn = new qx.ui.form.Button("Send", "icon/16/button-ok.png");
btn.setLocation(20, 120);
qx.ui.core.ClientDocument.getInstance().add(btn);
var area = new qx.ui.form.TextArea("");
area.setLocation(20, 154);
area.setDimension(192, 400);
qx.ui.core.ClientDocument.getInstance().add(area);
btn.addEventListener("execute", function(e)
{
var s1 = parseInt(spin1.getValue());
var s2 = parseInt(spin2.getValue());
var s3 = parseInt(spin3.getValue());
while ((s1+s2+s3) > 0)
{
if (s1 > 0)
{
makeRequest(40);
s1--;
};
if (s2 > 0)
{
makeRequest(400);
s2--;
};
if (s3 > 0)
{
makeRequest(4000);
s3--;
};
};
});
function makeRequest(size)
{
var req = new qx.io.remote.RemoteRequest("data/filesize/" + size + "kb.xml", "GET", "application/xml");
req.addEventListener("completed", function(e) {
area.setValue(area.getValue() + "Request " + size + "kb: completed\n");
});
req.addEventListener("failed", function(e) {
area.setValue(area.getValue() + "Request " + size + "kb: failed\n");
});
req.addEventListener("timeout", function(e) {
area.setValue(area.getValue() + "Request " + size + "kb: timeout\n");
});
req.send();
};
});
</script>
</body>
</html>
|