@@ -17,62 +17,90 @@ var isDownload = false;
17
17
//Percentage of the progress bar
18
18
var percentage = 0 ;
19
19
//Get the progress bar values and the element itself.
20
- var progressbar = $ ( '#loadBar' ) ,
21
- max = percentage ,
22
- value = progressbar . val ( ) ;
20
+ var progressbar = $ ( '#loadBar-width ' ) ,
21
+ max = percentage ,
22
+ value = 0 ;
23
23
//Value for the interval clearing function.
24
- var animationFunction = null ;
24
+ var animationFunction ;
25
+ var isAnimate = false ;
26
+
27
+
28
+ /* IMAGE SVG */
29
+ var dlFile = "<svg class='dlImg' xmlns='http://www.w3.org/2000/svg' width='90px' height='90px' viewBox='0 0 128 128'><path id='dlSVG' fill='black' stroke='black' stroke-width='1' d='M 110.00,116.00 C 110.00,116.00 110.00,124.00 110.00,124.00 110.00,124.00 20.00,124.00 20.00,124.00 20.00,124.00 20.00,116.00 20.00,116.00 20.00,116.00 110.00,116.00 110.00,116.00 Z M 83.00,3.00 C 83.00,3.00 83.00,65.00 83.00,65.00 83.00,65.00 110.00,65.00 110.00,65.00 110.00,65.00 97.63,78.88 97.63,78.88 97.63,78.88 76.63,99.88 76.63,99.88 76.63,99.88 64.88,111.13 64.88,111.13 64.88,111.13 53.13,99.63 53.13,99.63 53.13,99.63 32.38,79.00 32.38,79.00 32.38,79.00 20.00,65.00 20.00,65.00 20.00,65.00 47.00,65.00 47.00,65.00 47.00,65.00 47.00,3.00 47.00,3.00 47.00,3.00 83.00,3.00 83.00,3.00 Z' /></svg>"
25
30
26
31
/* DEBUG VALUES */
27
32
/* --- */
28
33
34
+ //Update of all elements in the page
35
+ function RefreshFileBox ( ) {
36
+ if ( percentage < 100 || ( filesDL == filesNeeded ) ) {
37
+ percentage = Math . floor ( ( 100 / filesNeeded ) * filesDL ) ;
38
+ }
39
+
40
+ if ( isAnimate ) {
41
+ animationFunction = setInterval ( animationBar , 15 ) ;
42
+ } else {
43
+ clearInterval ( animationFunction ) ;
44
+ }
45
+
46
+ if ( filesNeeded > 0 ) {
47
+ if ( percentage == 100 || ( filesDL == filesNeeded ) ) {
48
+ $ ( "#progressInfoWS" ) . html ( "Done !" ) ;
49
+ $ ( "#progressInfo" ) . html ( "Files donwloaded : " + filesDL + "<br>Files remaining : " + filesNeeded ) ;
50
+ } else {
51
+ $ ( "#progressInfo" ) . html ( "Files donwloaded : " + filesDL + "<br>Files remaining : " + filesNeeded ) ;
52
+ }
53
+ }
54
+ }
29
55
//Animation when page is loaded.
30
56
$ ( "body" ) . ready ( function ( ) {
31
57
$ ( "body" ) . animate ( { opacity : 1 , marginTop : "0px" } , 500 ) ;
32
58
} ) ;
33
-
34
59
// Called when the number of files to download changes.
35
60
function SetFilesNeeded ( needed ) {
36
61
filesNeeded = needed ;
37
62
RefreshFileBox ( ) ;
38
63
}
39
-
40
64
// Called at the start, tells us how many files need to be downloaded in total.
41
65
function SetFilesTotal ( total ) {
42
66
filesTotal = total ;
43
67
RefreshFileBox ( ) ;
44
68
}
45
-
46
69
// Called when a file starts downloading. The filename includes the entire path of the file;
47
70
// for example "materials/models/bobsModels/car.mdl".
48
71
function DownloadingFile ( fileName ) {
72
+ if ( isDownload ) {
73
+ filesDL ++ ;
74
+ isDownload = false ;
75
+ isAnimate = true ;
76
+ }
77
+ $ ( "#loadBar-width" ) . css ( { "visibility" : "visible" } ) ;
49
78
isDownload = true ;
50
79
$ ( "#stateLoad" ) . html ( "Downloading " + fileName ) ;
51
- $ ( "#noBorder " ) . attr ( "src" , "./img/dl.png" ) ;
80
+ $ ( "#imgLoad " ) . html ( dlFile ) ;
52
81
$ ( "#noBorder" ) . attr ( "class" , "NOPE" ) ;
53
- var test = fileName . split ( " " ) ;
54
- for ( var i = 0 ; i < test . length ; i ++ ) {
55
- if ( test [ i ] == "Workshop" ) {
82
+ var splitSTR = fileName . split ( " " ) ;
83
+ for ( var i = 0 ; i < splitSTR . length ; i ++ ) {
84
+ if ( splitSTR [ i ] == "Workshop" ) {
56
85
$ ( "#progressInfoWS" ) . html ( "Download addon from Workshop..." ) ;
57
86
} else {
58
87
$ ( "#progressInfoWS" ) . html ( " - - - " ) ;
59
88
}
60
89
}
61
90
RefreshFileBox ( ) ;
62
91
}
63
-
64
92
// Called when something happens. This might be "Initialising Game Data", "Sending Client Info", etc.
65
93
function SetStatusChanged ( status ) {
66
94
if ( isDownload ) {
67
95
filesDL ++ ;
68
96
isDownload = false ;
97
+ isAnimate = true ;
69
98
}
70
99
var statusSTR = status . split ( " " ) ;
71
100
for ( var i = 0 ; i < statusSTR . length ; i ++ ) {
72
101
if ( statusSTR [ i ] == "Sending" ) {
73
102
percentage = 100 ;
74
- animateFinal ( ) ;
75
- $ ( "#serverInfo" ) . html ( status + "<br><div id='spinner'></div>" ) ;
103
+ setTimeout ( function ( ) { animateFinal ( ) ; $ ( "#serverInfo" ) . html ( status + "<br><div id='spinner'></div>" ) ; } , 1000 ) ;
76
104
}
77
105
}
78
106
$ ( "#stateLoad" ) . html ( status ) ;
@@ -87,39 +115,16 @@ function GameDetails(servername, serverurl, mapname, maxplayers, steamid, gamemo
87
115
$ ( "#map" ) . html ( mapname ) ;
88
116
$ ( "#serverBanner img" ) . attr ( "alt" , servername + " - IMAGE MISSING" ) ;
89
117
}
90
-
91
- //Mise à jour des différents éléments présent dans la page
92
- function RefreshFileBox ( ) {
93
- if ( percentage < 100 ) {
94
- percentage = Math . floor ( ( 100 / filesNeeded ) * filesDL ) ;
95
- }
96
-
97
- if ( percentage <= 100 && percentage > 0 && percentage != value ) {
98
- animationFunction = setInterval ( function ( ) { animationBar ( ) ; } , 10 ) ;
99
- } else {
100
- clearInterval ( animationFunction ) ;
101
- }
102
-
103
- if ( filesNeeded > 0 ) {
104
- if ( percentage == 100 ) {
105
- $ ( "#progressInfoWS" ) . html ( "Done !" ) ;
106
- } else {
107
- $ ( "#progressInfo" ) . html ( "Files donwloaded : " + filesDL + "<br>Files remaining : " + filesNeeded ) ;
108
- }
109
- }
110
- }
111
-
118
+ // Animate the progress of the Progress bar.
112
119
function animationBar ( ) {
113
120
if ( percentage > value ) {
114
121
value += 1 ;
115
- addValue = progressbar . val ( value ) ;
116
- } else if ( percentage >= 100 ) {
117
- $ ( "#loadBar" ) . animate ( { backgroundColor :"green" , padding :"10px" , borderWidth :"0px" } , 500 , "easeOutExpo" ) ;
118
- percentage = percentage + 1 ;
119
- clearInterval ( animationFunction ) ;
122
+ progressbar . width ( value + "%" ) ;
123
+ $ ( "#rules" ) . html ( value + "%" ) ;
124
+ } else if ( percentage == 100 ) {
125
+ $ ( "#loadBar-width" ) . animate ( { backgroundColor :"green" } , 500 , "easeOutExpo" ) ;
120
126
}
121
127
}
122
-
123
128
//Animate the panels when the message "Sending Clien Info" is sended.
124
129
function animateFinal ( ) {
125
130
$ ( "header" ) . animate ( { left :"-55%" } , 500 , "easeOutExpo" ) ;
@@ -131,5 +136,5 @@ function animateFinal() {
131
136
$ ( "#serverBanner" ) . animate ( { top :"15%" } , 500 , "easeOutExpo" ) ;
132
137
$ ( "#serverInfo" ) . animate ( { opacity :1 , top :"45%" } , 500 , "easeOutExpo" ) ;
133
138
} ) ;
134
-
139
+ clearInterval ( animationFunction ) ;
135
140
}
0 commit comments