2002/08/07 18:21:48
[org.ibex.core.git] / src / org / xwt / builtin / splash.xwt
1 <xwt>
2
3     <template thisbox="window" orient="vertical">
4
5         minwidth = maxwidth = $inner.width;
6         minheight = maxheight = $inner.height;
7         x = (xwt.screenWidth - width) / 2;
8         y = (xwt.screenHeight - height) / 2;
9
10         _KeyPressed = function(k) {
11             if (k == "escape") thisbox = null;
12         }
13
14         xwt.thread = function() {
15             try {
16                 var origin = xwt.origin;
17                 if (origin.substring(0, 21) == "http://launch.xwt.org") {
18                     origin = origin.substring(22);
19                     origin = "http://" + origin.substring(origin.indexOf('/') + 1);
20                 }
21                 xwt.println("origin is " + origin);
22     
23                 xwt.loadArchive(origin, function(num, den) {
24                         $left.flex = 50 * (num / den);
25                         $right.flex = 50 + 50 * (1.0 - num /den);
26                         var pct = xwt.math.ceil(num * 100 / den);
27                         if (1024 > num) {
28                             num = "" + num + " bytes";
29                         } else if (1024 * 1024 > num) {
30                             num = "" + xwt.math.ceil(num / 1024) + "kb";
31                         } else {
32                             num = "" + xwt.math.ceil(num / (1024 * 1024)) + "Mb";
33                         }
34                         $status.text = "Downloading: " + pct + "% [" + num + "]";
35                     });
36     
37                     xwt.newBox("main", function(num, den) {
38                         $left.flex = 50 + 50 * (num / den);
39                         $right.flex = 50 * (1.0 - num / den);
40                         if ($right.flex == 0) $right.width = 0;
41                         $status.text = "Initializing: " + xwt.math.ceil(num * 100 / den) + "%";
42                     });
43                     thisbox = null;
44
45             } catch (e) {
46                 $status.text = "Error: " + e;
47                 if ($status.text.substring(0, 13) == "Error: Error:") $status.text = $status.text.substring(7);
48             }
49
50         }
51
52         <box absolute="true" sizetoimage="true" id="inner" image="org.xwt.builtin.lithium"/>
53
54         <box/>
55         <box text="Downloading user interface..." vshrink="true" hpad="4" vpad="3" id="status" textcolor="white"/>
56         <box hpad="4" height="10">
57             <box flex="0.0" image="org.xwt.builtin.progress" tile="true" id="left"/>
58             <box flex="100.0" id="right"/>
59         </box>
60         <box height="5"/>
61
62     </template>
63