OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Out of the box experience flow (OOBE). | 6 * @fileoverview Out of the box experience flow (OOBE). |
7 * This is the main code for the OOBE WebUI implementation. | 7 * This is the main code for the OOBE WebUI implementation. |
8 */ | 8 */ |
9 | 9 |
10 var localStrings = new LocalStrings(); | 10 var localStrings = new LocalStrings(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 | 144 |
145 /** | 145 /** |
146 * Sets update's progress bar value. | 146 * Sets update's progress bar value. |
147 * @param {number} progress Percentage of the progress bar. | 147 * @param {number} progress Percentage of the progress bar. |
148 */ | 148 */ |
149 Oobe.setUpdateProgress = function(progress) { | 149 Oobe.setUpdateProgress = function(progress) { |
150 $('update-progress-bar').value = progress; | 150 $('update-progress-bar').value = progress; |
151 }; | 151 }; |
152 | 152 |
153 /** | 153 /** |
154 * Sets estimated time left until download will complete. | |
155 * @param {number} days Number of estimated days. | |
156 * @param {number} hours Number of estimated hours. | |
157 * @param {number} minutes Number of estimated minutes. | |
158 * @param {number} seconds Number of estimated seconds. | |
159 */ | |
160 Oobe.setUpdateEstimatedTimeLeft = function(days, hours, minutes, seconds) { | |
161 var units = ['days', 'hours', 'minutes', 'seconds']; | |
Nikita (slow)
2012/05/10 16:04:31
These should be loaded from localizedStrings.
| |
162 var values = [days, hours, minutes, seconds]; | |
163 var unit = 0; | |
164 while (units[unit + 1] && values[unit] == 0) | |
165 ++unit; | |
166 | |
167 var text; | |
168 if (!units[unit + 1] || values[unit] == 0) { | |
Nikita (slow)
2012/05/10 16:04:31
Bad localization pattern.
String format itself sho
| |
169 text = values[unit] + ' ' + units[unit]; | |
170 } else { | |
171 text = values[unit] + ' ' + units[unit] + ', ' + | |
172 values[unit + 1] + ' ' + units[unit + 1]; | |
173 } | |
174 $('update-estimated-time-left').innerText = text; | |
175 }; | |
176 | |
177 /** | |
178 * Sets update's dowloading rate. | |
179 * @param {number} dowloading rate in bytes/sec. | |
180 */ | |
181 Oobe.setUpdateDownloadingRate = function(rate) { | |
182 var units = ['B/s', 'kB/s', 'MB/s', 'GB/s', 'TB/s', 'PB/s']; | |
Nikita (slow)
2012/05/10 16:04:31
If we end up showing this to user than these shoul
| |
183 var unit = 0; | |
184 while (units[unit + 1] && rate >= 999) { | |
185 rate /= 1024; | |
186 ++unit; | |
187 } | |
188 var text = Math.round(rate) + ' ' + units[unit]; | |
189 $('update-downloading-rate').innerText = text; | |
190 }; | |
191 | |
192 /** | |
154 * Sets update message, which is shown above the progress bar. | 193 * Sets update message, which is shown above the progress bar. |
155 * @param {text} message Message which is shown by the label. | 194 * @param {text} message Message which is shown by the label. |
156 */ | 195 */ |
157 Oobe.setUpdateMessage = function(message) { | 196 Oobe.setUpdateMessage = function(message) { |
158 $('update-upper-label').textContent = message; | 197 $('update-upper-label').textContent = message; |
159 }; | 198 }; |
160 | 199 |
161 /** | 200 /** |
162 * Shows or hides update curtain. | 201 * Shows or hides update curtain. |
163 * @param {boolean} enable Are curtains shown? | 202 * @param {boolean} enable Are curtains shown? |
164 */ | 203 */ |
165 Oobe.showUpdateCurtain = function(enable) { | 204 Oobe.showUpdateCurtain = function(enable) { |
166 $('update-screen-curtain').hidden = !enable; | 205 $('update-screen-curtain').hidden = !enable; |
167 $('update-screen-main').hidden = enable; | 206 $('update-screen-main').hidden = enable; |
168 }; | 207 }; |
169 | 208 |
170 /** | 209 /** |
210 * Shows or hides update downloading stats. | |
211 * @param {boolean} enable Are stats shown? | |
212 */ | |
213 Oobe.showUpdateDownloadingStats = function(enable) { | |
214 $('update-downloading-stats').hidden = !enable; | |
215 }; | |
216 | |
217 /** | |
171 * Sets TPM password. | 218 * Sets TPM password. |
172 * @param {text} password TPM password to be shown. | 219 * @param {text} password TPM password to be shown. |
173 */ | 220 */ |
174 Oobe.setTpmPassword = function(password) { | 221 Oobe.setTpmPassword = function(password) { |
175 $('tpm-busy').hidden = true; | 222 $('tpm-busy').hidden = true; |
176 $('tpm-password').textContent = password; | 223 $('tpm-password').textContent = password; |
177 $('tpm-password').hidden = false; | 224 $('tpm-password').hidden = false; |
178 }; | 225 }; |
179 | 226 |
180 /** | 227 /** |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 return { | 340 return { |
294 Oobe: Oobe | 341 Oobe: Oobe |
295 }; | 342 }; |
296 }); | 343 }); |
297 | 344 |
298 var Oobe = cr.ui.Oobe; | 345 var Oobe = cr.ui.Oobe; |
299 | 346 |
300 disableTextSelectAndDrag(); | 347 disableTextSelectAndDrag(); |
301 | 348 |
302 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); | 349 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); |
OLD | NEW |