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..ef67ec014ccbdccab06c536c5cf32f702d368de5 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 = $('componentTemplate').cloneNode(true); |
|
James Hawkins
2014/03/27 18:46:43
Why do you need to clone?
Shrikant Kelkar
2014/03/27 19:28:07
I am rewriting contents of the template in jstProc
|
| + $('componentPlaceholder').innerHTML = ''; |
| + $('componentPlaceholder').appendChild(output); |
| jstProcess(input, output); |
| + output.style.visibility = 'visible'; |
| } |
| /** |
| @@ -72,6 +75,21 @@ function returnComponentsData(componentsData) { |
| body.className = 'show-tmi-mode-initial'; |
| } |
| +function returnComponentStatus(component_id, status) { |
|
James Hawkins
2014/03/27 18:46:43
Who calls this?
Shrikant Kelkar
2014/03/27 19:28:07
component_ui.cc in response to requestComponentSta
|
| + $('status-' + component_id).innerText = status; |
|
James Hawkins
2014/03/27 18:46:43
Use textContent, not innerText.
Shrikant Kelkar
2014/03/27 19:28:07
Done.
|
| + var node = $(component_id); |
| + if (status == 'in-progress') { |
| + node.disabled = true; |
| + window.setTimeout(function() { updateComponentStatus(node); }, 1000); |
|
James Hawkins
2014/03/27 18:46:43
nit: Move 1000 to a well-named constant.
Shrikant Kelkar
2014/03/27 19:28:07
Done.
|
| + } 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 |
| @@ -79,12 +97,13 @@ function returnComponentsData(componentsData) { |
| */ |
| function handleCheckUpdate(node) { |
| node.disabled = true; |
| + |
| + $('status-' + String(node.id)).innerText = 'Checking for update...'; |
|
James Hawkins
2014/03/27 18:46:43
textContent
Shrikant Kelkar
2014/03/27 19:28:07
Done.
|
| + |
| // Tell the C++ ComponentssDOMHandler to check for update. |
| chrome.send('checkUpdate', [String(node.id)]); |
| + window.setTimeout(function() { updateComponentStatus(node); }, 1000); |
| } |
| // Get data and have it displayed upon loading. |
| document.addEventListener('DOMContentLoaded', requestComponentsData); |
| - |
| -// Add handlers to static HTML elements. |
| -$('button-check-update').onclick = handleCheckUpdate; |