Chromium Code Reviews| 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 * Updates the Authentication Status section. | 6 * Updates the Authentication Status section. |
| 7 * @param {Object} authStatus Dictionary containing auth status. | 7 * @param {Object} authStatus Dictionary containing auth status. |
| 8 */ | 8 */ |
| 9 function updateAuthStatus(authStatus) { | 9 function updateAuthStatus(authStatus) { |
| 10 $('has-refresh-token').textContent = authStatus['has-refresh-token']; | 10 $('has-refresh-token').textContent = authStatus['has-refresh-token']; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 * Updates the Local Storage summary. | 72 * Updates the Local Storage summary. |
| 73 * @param {Object} localStorageSummary Dictionaty describing the status of local | 73 * @param {Object} localStorageSummary Dictionaty describing the status of local |
| 74 * stogage. | 74 * stogage. |
| 75 */ | 75 */ |
| 76 function updateLocalStorageUsage(localStorageSummary) { | 76 function updateLocalStorageUsage(localStorageSummary) { |
| 77 var freeSpaceInMB = localStorageSummary.free_space / (1 << 20); | 77 var freeSpaceInMB = localStorageSummary.free_space / (1 << 20); |
| 78 $('local-storage-freespace').innerText = freeSpaceInMB; | 78 $('local-storage-freespace').innerText = freeSpaceInMB; |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Updates the summary about in-flight operations. | |
| 83 * @param {Object} operationsSummary Dictionaty describing the status of | |
|
satorux1
2012/08/22 20:20:02
seems to me that operationsSummary is a list of di
Haruki Sato
2012/08/24 19:06:11
Yes. Done.
Thanks!
| |
| 84 * in-flight operations. | |
| 85 */ | |
| 86 function updateInFlightOperations(operationsSummary) { | |
| 87 for (var i = 0; i < operationsSummary.length; i++) { | |
| 88 var operation = operationsSummary[i]; | |
| 89 var tr = document.createElement('tr'); | |
| 90 tr.appendChild(createElementFromText('td', operation.operation_id)); | |
| 91 tr.appendChild(createElementFromText('td', operation.operation_type)); | |
| 92 tr.appendChild(createElementFromText('td', operation.file_path)); | |
| 93 tr.appendChild(createElementFromText('td', operation.transfer_state)); | |
| 94 tr.appendChild(createElementFromText('td', operation.start_time)); | |
| 95 var progress = operation.progress_current + '/' + operation.progress_total; | |
| 96 if (operation.progress_total > 0) { | |
| 97 progress += ' (' + | |
| 98 (operation.progress_current / operation.progress_total * 100) + '%)'; | |
| 99 } | |
| 100 tr.appendChild(createElementFromText('td', progress)); | |
| 101 | |
| 102 $('in-flight-operations-contents').appendChild(tr); | |
| 103 } | |
|
satorux1
2012/08/22 20:20:02
I think we want to be able to monitor the in-fligh
Haruki Sato
2012/08/24 19:06:11
Done.
Added periodic update using setInterval.
| |
| 104 } | |
| 105 | |
| 106 /** | |
| 82 * Creates an element named |elementName| containing the content |text|. | 107 * Creates an element named |elementName| containing the content |text|. |
| 83 * @param {string} elementName Name of the new element to be created. | 108 * @param {string} elementName Name of the new element to be created. |
| 84 * @param {string} text Text to be contained in the new element. | 109 * @param {string} text Text to be contained in the new element. |
| 85 * @return {HTMLElement} The newly created HTML element. | 110 * @return {HTMLElement} The newly created HTML element. |
| 86 */ | 111 */ |
| 87 function createElementFromText(elementName, text) { | 112 function createElementFromText(elementName, text) { |
| 88 var element = document.createElement(elementName); | 113 var element = document.createElement(elementName); |
| 89 element.appendChild(document.createTextNode(text)); | 114 element.appendChild(document.createTextNode(text)); |
| 90 return element; | 115 return element; |
| 91 } | 116 } |
| 92 | 117 |
| 93 document.addEventListener('DOMContentLoaded', function() { | 118 document.addEventListener('DOMContentLoaded', function() { |
| 94 chrome.send('pageLoaded'); | 119 chrome.send('pageLoaded'); |
| 95 }); | 120 }); |
| OLD | NEW |