1+ function UnityProgress ( dom ) {
2+ this . progress = 0.0 ;
3+ this . message = "" ;
4+ this . dom = dom ;
5+
6+ var parent = dom . parentNode ;
7+
8+ var background = document . createElement ( "div" ) ;
9+ background . style . background = "#4D4D4D" ;
10+ background . style . position = "absolute" ;
11+ parent . appendChild ( background ) ;
12+ this . background = background ;
13+
14+ var logoImage = document . createElement ( "img" ) ;
15+ logoImage . src = "TemplateData/progresslogo.png" ;
16+ logoImage . style . position = "absolute" ;
17+ parent . appendChild ( logoImage ) ;
18+ this . logoImage = logoImage ;
19+
20+ var progressFrame = document . createElement ( "img" ) ;
21+ progressFrame . src = "TemplateData/loadingbar.png" ;
22+ progressFrame . style . position = "absolute" ;
23+ parent . appendChild ( progressFrame ) ;
24+ this . progressFrame = progressFrame ;
25+
26+ var progressBar = document . createElement ( "img" ) ;
27+ progressBar . src = "TemplateData/fullbar.png" ;
28+ progressBar . style . position = "absolute" ;
29+ parent . appendChild ( progressBar ) ;
30+ this . progressBar = progressBar ;
31+
32+ var messageArea = document . createElement ( "p" ) ;
33+ messageArea . style . position = "absolute" ;
34+ parent . appendChild ( messageArea ) ;
35+ this . messageArea = messageArea ;
36+
37+
38+ this . SetProgress = function ( progress ) {
39+ if ( this . progress < progress )
40+ this . progress = progress ;
41+ this . messageArea . style . display = "none" ;
42+ this . progressFrame . style . display = "inline" ;
43+ this . progressBar . style . display = "inline" ;
44+ this . Update ( ) ;
45+ }
46+
47+ this . SetMessage = function ( message ) {
48+ this . message = message ;
49+ this . background . style . display = "inline" ;
50+ this . logoImage . style . display = "inline" ;
51+ this . progressFrame . style . display = "none" ;
52+ this . progressBar . style . display = "none" ;
53+ this . Update ( ) ;
54+ }
55+
56+ this . Clear = function ( ) {
57+ this . background . style . display = "none" ;
58+ this . logoImage . style . display = "none" ;
59+ this . progressFrame . style . display = "none" ;
60+ this . progressBar . style . display = "none" ;
61+ }
62+
63+ this . Update = function ( ) {
64+ this . background . style . top = this . dom . offsetTop + 'px' ;
65+ this . background . style . left = this . dom . offsetLeft + 'px' ;
66+ this . background . style . width = this . dom . offsetWidth + 'px' ;
67+ this . background . style . height = this . dom . offsetHeight + 'px' ;
68+
69+ var logoImg = new Image ( ) ;
70+ logoImg . src = this . logoImage . src ;
71+ var progressFrameImg = new Image ( ) ;
72+ progressFrameImg . src = this . progressFrame . src ;
73+
74+ this . logoImage . style . top = this . dom . offsetTop + ( this . dom . offsetHeight * 0.5 - logoImg . height * 0.5 ) + 'px' ;
75+ this . logoImage . style . left = this . dom . offsetLeft + ( this . dom . offsetWidth * 0.5 - logoImg . width * 0.5 ) + 'px' ;
76+ this . logoImage . style . width = logoImg . width + 'px' ;
77+ this . logoImage . style . height = logoImg . height + 'px' ;
78+
79+ this . progressFrame . style . top = this . dom . offsetTop + ( this . dom . offsetHeight * 0.5 + logoImg . height * 0.5 + 10 ) + 'px' ;
80+ this . progressFrame . style . left = this . dom . offsetLeft + ( this . dom . offsetWidth * 0.5 - progressFrameImg . width * 0.5 ) + 'px' ;
81+ this . progressFrame . width = progressFrameImg . width ;
82+ this . progressFrame . height = progressFrameImg . height ;
83+
84+ this . progressBar . style . top = this . progressFrame . style . top ;
85+ this . progressBar . style . left = this . progressFrame . style . left ;
86+ this . progressBar . width = progressFrameImg . width * Math . min ( this . progress , 1 ) ;
87+ this . progressBar . height = progressFrameImg . height ;
88+
89+ this . messageArea . style . top = this . progressFrame . style . top ;
90+ this . messageArea . style . left = 0 ;
91+ this . messageArea . style . width = '100%' ;
92+ this . messageArea . style . textAlign = 'center' ;
93+ this . messageArea . innerHTML = this . message ;
94+ }
95+
96+ this . Update ( ) ;
97+ }
0 commit comments