| Index: components/physical_web/webui/resources/physical_web.js
|
| diff --git a/components/physical_web/webui/resources/physical_web.js b/components/physical_web/webui/resources/physical_web.js
|
| index 70d856fe7db71a2222280e9cda9630a922507d4b..b050945951938506355bfc04751d0abe32defa84 100644
|
| --- a/components/physical_web/webui/resources/physical_web.js
|
| +++ b/components/physical_web/webui/resources/physical_web.js
|
| @@ -9,27 +9,36 @@
|
| * nearby devices
|
| */
|
| function renderTemplate(nearbyUrlsData) {
|
| + if (nearbyUrlsData['metadata'].length != 0) {
|
| + $('empty-list-container').hidden = true;
|
| + }
|
| + // This is a workaround with jstemplate. Jstemplate render only works on empty
|
| + // node. When we need to rerender things, we have to remove previous nodes.
|
| + let renderContainer = document.getElementById('render-container');
|
| + // Remove existing childNode.
|
| + while (renderContainer.hasChildNodes()) {
|
| + renderContainer.removeChild(renderContainer.lastChild);
|
| + }
|
| + let templateDiv = document.getElementById('render-template').cloneNode(true);
|
| + renderContainer.appendChild(templateDiv);
|
| +
|
| // This is the javascript code that processes the template:
|
| - jstProcess(new JsEvalContext(nearbyUrlsData), $('physicalWebTemplate'));
|
| + jstProcess(new JsEvalContext(nearbyUrlsData), templateDiv);
|
| +
|
| + let bodyContainer = $('body-container');
|
| + bodyContainer.hidden = false;
|
| }
|
|
|
| -function requestNearbyURLs() {
|
| - chrome.send('requestNearbyURLs');
|
| +function physicalWebPageLoaded() {
|
| + chrome.send('physicalWebPageLoaded');
|
| }
|
|
|
| function physicalWebItemClicked(index) {
|
| chrome.send('physicalWebItemClicked', [index]);
|
| }
|
|
|
| -function returnNearbyURLs(nearbyUrlsData) {
|
| - var bodyContainer = $('body-container');
|
| +function pushNearbyURLs(nearbyUrlsData) {
|
| renderTemplate(nearbyUrlsData);
|
| - bodyContainer.hidden = false;
|
| -
|
| - if (nearbyUrlsData['metadata'].length == 0) {
|
| - var emptyMessage = $('empty-list-container');
|
| - emptyMessage.hidden = false;
|
| - }
|
| }
|
|
|
| -document.addEventListener('DOMContentLoaded', requestNearbyURLs);
|
| +document.addEventListener('DOMContentLoaded', physicalWebPageLoaded);
|
|
|