Index: chrome/browser/resources/chromeos/drive_internals.js |
diff --git a/chrome/browser/resources/chromeos/drive_internals.js b/chrome/browser/resources/chromeos/drive_internals.js |
index e372a1ce9fd1cffa60e8ac3e4e4e2fdd1c838329..1e40dcb2771a178964df42c91fc2c4b7f6a7757c 100644 |
--- a/chrome/browser/resources/chromeos/drive_internals.js |
+++ b/chrome/browser/resources/chromeos/drive_internals.js |
@@ -11,6 +11,50 @@ function UpdateAuthStatus(auth_status) { |
$('has-access-token').textContent = auth_status['has-access-token']; |
} |
+/** |
+ * Updates the GCache Contents section. |
+ * @param {Array} gcache_contents List of dictionaries describing metadata |
James Hawkins
2012/07/26 17:50:02
nit: gcacheContents
|
+ * of files and directories under the GCache directory. |
+ */ |
+function UpdateGCacheContents(gcache_contents) { |
+ var tbody = $('gcache-contents'); |
+ // Add a header row. |
+ var tr = document.createElement('tr'); |
+ tr.appendChild(createElementFromText('th', 'Path')); |
+ tr.appendChild(createElementFromText('th', 'Size')); |
+ tr.appendChild(createElementFromText('th', 'Last Modified')); |
+ tbody.appendChild(tr); |
+ |
+ for (var i = 0; i < gcache_contents.length; ++i) { |
James Hawkins
2012/07/26 17:50:02
nit: i++
satorux1
2012/07/26 19:18:14
Done.
|
+ var entry = gcache_contents[i]; |
+ var tr = document.createElement('tr'); |
+ |
+ // Add some suffix based on the type. |
+ var path = entry.path; |
+ if (entry.is_directory) |
+ path += '/'; |
+ else if (entry.is_symbolic_link) |
+ path += '@'; |
+ |
+ tr.appendChild(createElementFromText('td', path)); |
+ tr.appendChild(createElementFromText('td', entry.size)); |
+ tr.appendChild(createElementFromText('td', entry.last_modified)); |
+ tbody.appendChild(tr); |
+ } |
+} |
+ |
+/** |
+ * Creates an element of |elementName| from |text|. |
James Hawkins
2012/07/26 17:50:02
nit: s/of/named/
James Hawkins
2012/07/26 17:50:02
nit: s/from/containing the content/
satorux1
2012/07/26 19:18:14
Done.
|
+ * @param {string} elementName Name of the new element to be created. |
+ * @param {string} text Text to be contained in the new element. |
+ * @return {HTMLElement} The newly created HTML element. |
+ */ |
+function createElementFromText(elementName, text) { |
+ var element = document.createElement(elementName); |
+ element.appendChild(document.createTextNode(text)); |
+ return element; |
+} |
+ |
document.addEventListener('DOMContentLoaded', function() { |
chrome.send('pageLoaded'); |
}); |