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 * Converts a number in bytes to a string in megabytes split by comma into | 6 * Converts a number in bytes to a string in megabytes split by comma into |
7 * three digit block. | 7 * three digit block. |
8 * @param {number} bytes The number in bytes. | 8 * @param {number} bytes The number in bytes. |
9 * @return {string} Formatted string in megabytes. | 9 * @return {string} Formatted string in megabytes. |
10 */ | 10 */ |
11 function ToMegaByteString(bytes) { | 11 function ToMegaByteString(bytes) { |
12 var mb = Math.floor(bytes / (1 << 20)); | 12 var mb = Math.floor(bytes / (1 << 20)); |
13 return mb.toString().replace( | 13 return mb.toString().replace( |
14 /\d+?(?=(\d{3})+$)/g, // Digit sequence (\d+) followed (?=) by 3n digits. | 14 /\d+?(?=(\d{3})+$)/g, // Digit sequence (\d+) followed (?=) by 3n digits. |
15 function(three_digit_block) { return three_digit_block + ','; } | 15 function(three_digit_block) { return three_digit_block + ','; } |
16 ); | 16 ); |
17 } | 17 } |
18 | 18 |
19 /** | 19 /** |
20 * Updates the Drive related Flags section. | |
21 * @param {Array} flags List of dictionaries describing flags. | |
22 */ | |
23 function updateDriveRelatedFlags(flags) { | |
24 var ul = $('drive-related-flags'); | |
25 updateKeyValueList(ul, flags); | |
26 } | |
27 | |
28 /** | |
29 * Updates the Drive related Preferences section. | 20 * Updates the Drive related Preferences section. |
30 * @param {Array} preferences List of dictionaries describing preferences. | 21 * @param {Array} preferences List of dictionaries describing preferences. |
31 */ | 22 */ |
32 function updateDriveRelatedPreferences(preferences) { | 23 function updateDriveRelatedPreferences(preferences) { |
33 var ul = $('drive-related-preferences'); | 24 var ul = $('drive-related-preferences'); |
34 updateKeyValueList(ul, preferences); | 25 updateKeyValueList(ul, preferences); |
35 } | 26 } |
36 | 27 |
37 /** | 28 /** |
38 * Updates the Connection Status section. | 29 * Updates the Connection Status section. |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 $('button-show-file-entries').addEventListener('click', function() { | 291 $('button-show-file-entries').addEventListener('click', function() { |
301 var button = $('button-show-file-entries'); | 292 var button = $('button-show-file-entries'); |
302 button.parentNode.removeChild(button); | 293 button.parentNode.removeChild(button); |
303 chrome.send('listFileEntries'); | 294 chrome.send('listFileEntries'); |
304 }); | 295 }); |
305 | 296 |
306 window.setInterval(function() { | 297 window.setInterval(function() { |
307 chrome.send('periodicUpdate'); | 298 chrome.send('periodicUpdate'); |
308 }, 1000); | 299 }, 1000); |
309 }); | 300 }); |
OLD | NEW |