Chromium Code Reviews| Index: chrome/browser/resources/components.js |
| diff --git a/chrome/browser/resources/components.js b/chrome/browser/resources/components.js |
| index 8753e3192ab210b51c8f2d1ea813a50ca67c33bd..8b3f9543373497c9d53460a6c2b2b8e56f37319a 100644 |
| --- a/chrome/browser/resources/components.js |
| +++ b/chrome/browser/resources/components.js |
| @@ -14,8 +14,11 @@ |
| function renderTemplate(componentsData) { |
| // This is the javascript code that processes the template: |
| var input = new JsEvalContext(componentsData); |
| - var output = $('componentTemplate'); |
| + var output = $('component-template').cloneNode(true); |
| + $('component-placeholder').innerHTML = ''; |
| + $('component-placeholder').appendChild(output); |
| jstProcess(input, output); |
| + output.removeAttribute('hidden'); |
| } |
| /** |
| @@ -73,18 +76,41 @@ function returnComponentsData(componentsData) { |
| } |
| /** |
| + * Component update status refresh interval. |
| + */ |
| +var STATUS_REFRESH_INTERVAL = 1000; |
| + |
| +function returnComponentStatus(component_id, status) { |
| + $('status-' + component_id).textContent = status; |
| + var node = $(component_id); |
| + if (status == 'in-progress') { |
| + node.disabled = true; |
| + window.setTimeout(function() { updateComponentStatus(node); }, |
| + STATUS_REFRESH_INTERVAL); |
|
James Hawkins
2014/03/27 20:12:03
Why are we using polling instead of having the bro
Shrikant Kelkar
2014/03/27 22:00:13
The c++ code doesn't have a callback so far.
James Hawkins
2014/03/27 22:02:44
So let's fix it. We shouldn't be polling from the
|
| + } else { |
| + node.disabled = false; |
| + } |
| +} |
| + |
| +function updateComponentStatus(node) { |
| + chrome.send('requestComponentStatus', [String(node.id)]); |
| +} |
| + |
| +/** |
| * Handles an 'enable' or 'disable' button getting clicked. |
| * @param {HTMLElement} node The HTML element representing the component |
| * being checked for update. |
| */ |
| function handleCheckUpdate(node) { |
| node.disabled = true; |
| + |
| + $('status-' + String(node.id)).textContent = 'Checking for update...'; |
| + |
| // Tell the C++ ComponentssDOMHandler to check for update. |
| chrome.send('checkUpdate', [String(node.id)]); |
| + window.setTimeout(function() { updateComponentStatus(node); }, |
| + STATUS_REFRESH_INTERVAL); |
| } |
| // Get data and have it displayed upon loading. |
| document.addEventListener('DOMContentLoaded', requestComponentsData); |
| - |
| -// Add handlers to static HTML elements. |
| -$('button-check-update').onclick = handleCheckUpdate; |