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']; |
11 $('has-access-token').textContent = authStatus['has-access-token']; | 11 $('has-access-token').textContent = authStatus['has-access-token']; |
12 } | 12 } |
13 | 13 |
14 /** | 14 /** |
15 * Updates the GCache Contents section. | 15 * Updates the GCache Contents section. |
16 * @param {Array} gcacheContents List of dictionaries describing metadata | 16 * @param {Array} gcacheContents List of dictionaries describing metadata |
17 * of files and directories under the GCache directory. | 17 * of files and directories under the GCache directory. |
18 */ | 18 */ |
19 function updateGCacheContents(gcacheContents) { | 19 function updateGCacheContents(gcacheContents) { |
20 var tbody = $('gcache-contents'); | 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++) { | 21 for (var i = 0; i < gcacheContents.length; i++) { |
29 var entry = gcacheContents[i]; | 22 var entry = gcacheContents[i]; |
30 var tr = document.createElement('tr'); | 23 var tr = document.createElement('tr'); |
31 | 24 |
32 // Add some suffix based on the type. | 25 // Add some suffix based on the type. |
33 var path = entry.path; | 26 var path = entry.path; |
34 if (entry.is_directory) | 27 if (entry.is_directory) |
35 path += '/'; | 28 path += '/'; |
36 else if (entry.is_symbolic_link) | 29 else if (entry.is_symbolic_link) |
37 path += '@'; | 30 path += '@'; |
(...skipping 10 matching lines...) Expand all Loading... |
48 * C++ side repeatedly with contents of a directory. | 41 * C++ side repeatedly with contents of a directory. |
49 * @param {string} directoryContentsAsText Pre-formatted string representation | 42 * @param {string} directoryContentsAsText Pre-formatted string representation |
50 * of contents a directory in the file system. | 43 * of contents a directory in the file system. |
51 */ | 44 */ |
52 function updateFileSystemContents(directoryContentsAsText) { | 45 function updateFileSystemContents(directoryContentsAsText) { |
53 var div = $('file-system-contents'); | 46 var div = $('file-system-contents'); |
54 div.appendChild(createElementFromText('pre', directoryContentsAsText)); | 47 div.appendChild(createElementFromText('pre', directoryContentsAsText)); |
55 } | 48 } |
56 | 49 |
57 /** | 50 /** |
| 51 * Updates the Cache Contents section. |
| 52 * @param {Object} cacheEntry Dictionary describing a cache entry. |
| 53 * The function is called from the C++ side repeatedly. |
| 54 */ |
| 55 function updateCacheContents(cacheEntry) { |
| 56 var tr = document.createElement('tr'); |
| 57 tr.appendChild(createElementFromText('td', cacheEntry.resource_id)); |
| 58 tr.appendChild(createElementFromText('td', cacheEntry.md5)); |
| 59 tr.appendChild(createElementFromText('td', cacheEntry.is_present)); |
| 60 tr.appendChild(createElementFromText('td', cacheEntry.is_pinned)); |
| 61 tr.appendChild(createElementFromText('td', cacheEntry.is_dirty)); |
| 62 tr.appendChild(createElementFromText('td', cacheEntry.is_mounted)); |
| 63 tr.appendChild(createElementFromText('td', cacheEntry.is_persistent)); |
| 64 |
| 65 $('cache-contents').appendChild(tr); |
| 66 } |
| 67 |
| 68 /** |
58 * Creates an element named |elementName| containing the content |text|. | 69 * Creates an element named |elementName| containing the content |text|. |
59 * @param {string} elementName Name of the new element to be created. | 70 * @param {string} elementName Name of the new element to be created. |
60 * @param {string} text Text to be contained in the new element. | 71 * @param {string} text Text to be contained in the new element. |
61 * @return {HTMLElement} The newly created HTML element. | 72 * @return {HTMLElement} The newly created HTML element. |
62 */ | 73 */ |
63 function createElementFromText(elementName, text) { | 74 function createElementFromText(elementName, text) { |
64 var element = document.createElement(elementName); | 75 var element = document.createElement(elementName); |
65 element.appendChild(document.createTextNode(text)); | 76 element.appendChild(document.createTextNode(text)); |
66 return element; | 77 return element; |
67 } | 78 } |
68 | 79 |
69 document.addEventListener('DOMContentLoaded', function() { | 80 document.addEventListener('DOMContentLoaded', function() { |
70 chrome.send('pageLoaded'); | 81 chrome.send('pageLoaded'); |
71 }); | 82 }); |
OLD | NEW |