| 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) { |
| 16 ); | 16 return three_digit_block + ','; |
| 17 }); |
| 17 } | 18 } |
| 18 | 19 |
| 19 /** | 20 /** |
| 20 * Updates the Drive related Preferences section. | 21 * Updates the Drive related Preferences section. |
| 21 * @param {Array} preferences List of dictionaries describing preferences. | 22 * @param {Array} preferences List of dictionaries describing preferences. |
| 22 */ | 23 */ |
| 23 function updateDriveRelatedPreferences(preferences) { | 24 function updateDriveRelatedPreferences(preferences) { |
| 24 var ul = $('drive-related-preferences'); | 25 var ul = $('drive-related-preferences'); |
| 25 updateKeyValueList(ul, preferences); | 26 updateKeyValueList(ul, preferences); |
| 26 } | 27 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 185 } |
| 185 } | 186 } |
| 186 | 187 |
| 187 /** | 188 /** |
| 188 * Updates the local cache information about account metadata. | 189 * Updates the local cache information about account metadata. |
| 189 * @param {Object} localMetadata Dictionary describing account metadata. | 190 * @param {Object} localMetadata Dictionary describing account metadata. |
| 190 */ | 191 */ |
| 191 function updateLocalMetadata(localMetadata) { | 192 function updateLocalMetadata(localMetadata) { |
| 192 var changestamp = localMetadata['account-largest-changestamp-local']; | 193 var changestamp = localMetadata['account-largest-changestamp-local']; |
| 193 | 194 |
| 194 $('account-largest-changestamp-local').textContent = | 195 $('account-largest-changestamp-local').textContent = changestamp.toString() + |
| 195 changestamp.toString() + | |
| 196 (changestamp > 0 ? ' (loaded)' : ' (not loaded)') + | 196 (changestamp > 0 ? ' (loaded)' : ' (not loaded)') + |
| 197 (localMetadata['account-metadata-refreshing'] ? ' (refreshing)' : ''); | 197 (localMetadata['account-metadata-refreshing'] ? ' (refreshing)' : ''); |
| 198 } | 198 } |
| 199 | 199 |
| 200 /** | 200 /** |
| 201 * Updates the summary about delta update status. | 201 * Updates the summary about delta update status. |
| 202 * @param {Object} deltaUpdateStatus Dictionary describing delta update status. | 202 * @param {Object} deltaUpdateStatus Dictionary describing delta update status. |
| 203 */ | 203 */ |
| 204 function updateDeltaUpdateStatus(deltaUpdateStatus) { | 204 function updateDeltaUpdateStatus(deltaUpdateStatus) { |
| 205 $('push-notification-enabled').textContent = | 205 $('push-notification-enabled').textContent = |
| 206 deltaUpdateStatus['push-notification-enabled']; | 206 deltaUpdateStatus['push-notification-enabled']; |
| 207 $('last-update-check-time').textContent = | 207 $('last-update-check-time').textContent = |
| 208 deltaUpdateStatus['last-update-check-time']; | 208 deltaUpdateStatus['last-update-check-time']; |
| 209 $('last-update-check-error').textContent = | 209 $('last-update-check-error').textContent = |
| 210 deltaUpdateStatus['last-update-check-error']; | 210 deltaUpdateStatus['last-update-check-error']; |
| 211 } | 211 } |
| 212 | 212 |
| 213 /** | 213 /** |
| 214 * Updates the event log section. | 214 * Updates the event log section. |
| 215 * @param {Array} log Array of events. | 215 * @param {Array} log Array of events. |
| 216 */ | 216 */ |
| 217 function updateEventLog(log) { | 217 function updateEventLog(log) { |
| 218 var ul = $('event-log'); | 218 var ul = $('event-log'); |
| 219 updateKeyValueList(ul, log); | 219 updateKeyValueList(ul, log); |
| 220 } | 220 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 $('button-show-file-entries').addEventListener('click', function() { | 291 $('button-show-file-entries').addEventListener('click', function() { |
| 292 var button = $('button-show-file-entries'); | 292 var button = $('button-show-file-entries'); |
| 293 button.parentNode.removeChild(button); | 293 button.parentNode.removeChild(button); |
| 294 chrome.send('listFileEntries'); | 294 chrome.send('listFileEntries'); |
| 295 }); | 295 }); |
| 296 | 296 |
| 297 window.setInterval(function() { | 297 window.setInterval(function() { |
| 298 chrome.send('periodicUpdate'); | 298 chrome.send('periodicUpdate'); |
| 299 }, 1000); | 299 }, 1000); |
| 300 }); | 300 }); |
| OLD | NEW |