Chromium Code Reviews| Index: components/dom_distiller/webui/resources/about_dom_distiller.js |
| diff --git a/components/dom_distiller/webui/resources/about_dom_distiller.js b/components/dom_distiller/webui/resources/about_dom_distiller.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a1b2e5f5f3b37c037fa962050be26476d58b9d1f |
| --- /dev/null |
| +++ b/components/dom_distiller/webui/resources/about_dom_distiller.js |
| @@ -0,0 +1,35 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * Callback from the backend with the list of entries to display. |
| + * This call will build the entries section of the DOM distiller page, or hide |
| + * that section if there are none to display. |
| + * @param {!Array.<string>} entries The entries. |
| + */ |
| +function onGotEntries(entries) { |
| + $('entries-section').hidden = !entries.length; |
| + if (entries.length > 0) { |
| + var list = document.createElement('ul'); |
| + for (var i=0; i < entries.length; i++) { |
| + var listItem = document.createElement('li'); |
| + var link = document.createElement('a'); |
| + var linkHref = document.createAttribute('href'); |
|
Evan Stade
2013/09/11 01:44:01
setAttribute()
nyquist
2013/09/12 17:42:12
Done.
|
| + var text = document.createTextNode(entries[i].title); |
|
Evan Stade
2013/09/11 01:44:01
innerText =
nyquist
2013/09/12 17:42:12
Done.
|
| + link.appendChild(text); |
| + linkHref.nodeValue = entries[i].url; |
| + link.setAttributeNode(linkHref); |
| + listItem.appendChild(link); |
| + list.appendChild(listItem); |
| + } |
| + $('entries-list').appendChild(list); |
| + } |
| +} |
| + |
| +/* All the work we do onload. */ |
| +function onLoadWork() { |
| + chrome.send('requestEntries'); |
| +} |
| + |
| +document.addEventListener('DOMContentLoaded', onLoadWork); |