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} auth_status Dictionary containing auth status. | 7 * @param {Object} authStatus Dictionary containing auth status. |
8 */ | 8 */ |
9 function UpdateAuthStatus(auth_status) { | 9 function updateAuthStatus(authStatus) { |
10 $('has-refresh-token').textContent = auth_status['has-refresh-token']; | 10 $('has-refresh-token').textContent = authStatus['has-refresh-token']; |
11 $('has-access-token').textContent = auth_status['has-access-token']; | 11 $('has-access-token').textContent = authStatus['has-access-token']; |
| 12 } |
| 13 |
| 14 /** |
| 15 * Updates the GCache Contents section. |
| 16 * @param {Array} gcacheContents List of dictionaries describing metadata |
| 17 * of files and directories under the GCache directory. |
| 18 */ |
| 19 function updateGCacheContents(gcacheContents) { |
| 20 var tbody = $('gcache-contents'); |
| 21 // Add a header row. |
| 22 var tr = document.createElement('tr'); |
| 23 tr.appendChild(createElementFromText('th', 'Path')); |
| 24 tr.appendChild(createElementFromText('th', 'Size')); |
| 25 tr.appendChild(createElementFromText('th', 'Last Modified')); |
| 26 tbody.appendChild(tr); |
| 27 |
| 28 for (var i = 0; i < gcacheContents.length; i++) { |
| 29 var entry = gcacheContents[i]; |
| 30 var tr = document.createElement('tr'); |
| 31 |
| 32 // Add some suffix based on the type. |
| 33 var path = entry.path; |
| 34 if (entry.is_directory) |
| 35 path += '/'; |
| 36 else if (entry.is_symbolic_link) |
| 37 path += '@'; |
| 38 |
| 39 tr.appendChild(createElementFromText('td', path)); |
| 40 tr.appendChild(createElementFromText('td', entry.size)); |
| 41 tr.appendChild(createElementFromText('td', entry.last_modified)); |
| 42 tbody.appendChild(tr); |
| 43 } |
| 44 } |
| 45 |
| 46 /** |
| 47 * Creates an element named |elementName| containing the content |text|. |
| 48 * @param {string} elementName Name of the new element to be created. |
| 49 * @param {string} text Text to be contained in the new element. |
| 50 * @return {HTMLElement} The newly created HTML element. |
| 51 */ |
| 52 function createElementFromText(elementName, text) { |
| 53 var element = document.createElement(elementName); |
| 54 element.appendChild(document.createTextNode(text)); |
| 55 return element; |
12 } | 56 } |
13 | 57 |
14 document.addEventListener('DOMContentLoaded', function() { | 58 document.addEventListener('DOMContentLoaded', function() { |
15 chrome.send('pageLoaded'); | 59 chrome.send('pageLoaded'); |
16 }); | 60 }); |
OLD | NEW |