| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * WebUI to monitor the Sync File System Service. |
| 7 */ |
| 8 var extensionStatuses = (function() { |
| 9 'use strict'; |
| 10 |
| 11 function ExtensionStatuses() { |
| 12 } |
| 13 |
| 14 /** |
| 15 * Get initial map of extension statuses (pending batch sync, enabled and |
| 16 * disabled). |
| 17 */ |
| 18 function getExtensionStatuses() { |
| 19 chrome.send('getExtensionStatuses'); |
| 20 } |
| 21 |
| 22 // TODO(calvinlo): Move to helper file so it doesn't need to be duplicated. |
| 23 /** |
| 24 * Creates an element named |elementName| containing the content |text|. |
| 25 * @param {string} elementName Name of the new element to be created. |
| 26 * @param {string} text Text to be contained in the new element. |
| 27 * @return {HTMLElement} The newly created HTML element. |
| 28 */ |
| 29 function createElementFromText(elementName, text) { |
| 30 var element = document.createElement(elementName); |
| 31 element.appendChild(document.createTextNode(text)); |
| 32 return element; |
| 33 } |
| 34 |
| 35 /** |
| 36 * Handles callback from onGetExtensionStatuses. |
| 37 * @param {Array} list of dictionaries containing 'extensionID' and 'status'. |
| 38 */ |
| 39 ExtensionStatuses.prototype.onGetExtensionStatuses = |
| 40 function(extensionStatuses) { |
| 41 var itemContainer = $('extension-entries'); |
| 42 for (var i = 0; i < extensionStatuses.length; i++) { |
| 43 var originEntry = extensionStatuses[i]; |
| 44 var tr = document.createElement('tr'); |
| 45 tr.appendChild(createElementFromText('td', originEntry.extensionID)); |
| 46 tr.appendChild(createElementFromText('td', originEntry.status)); |
| 47 itemContainer.appendChild(tr); |
| 48 } |
| 49 } |
| 50 |
| 51 document.addEventListener('DOMContentLoaded', getExtensionStatuses); |
| 52 return new ExtensionStatuses; |
| 53 })(); |
| OLD | NEW |