Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: components/physical_web/webui/resources/physical_web.js

Issue 2717363003: Add Physical Web WebUI Default Url Icon (Closed)
Patch Set: create differnt versions of img Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Takes the |nearbyUrlsData| input argument which holds metadata for web pages 6 * Takes the |nearbyUrlsData| input argument which holds metadata for web pages
7 * broadcast by nearby devices. 7 * broadcast by nearby devices.
8 * @param {Object} nearbyUrlsData Information about web pages broadcast by 8 * @param {Object} nearbyUrlsData Information about web pages broadcast by
9 * nearby devices 9 * nearby devices
10 */ 10 */
11 function renderTemplate(nearbyUrlsData) { 11 function renderTemplate(nearbyUrlsData) {
12 // This is the javascript code that processes the template: 12 // This is the javascript code that processes the template:
13 jstProcess(new JsEvalContext(nearbyUrlsData), $('physicalWebTemplate')); 13 jstProcess(new JsEvalContext(nearbyUrlsData), $('physicalWebTemplate'));
14 } 14 }
15 15
16 function requestNearbyURLs() { 16 function requestNearbyURLs() {
17 chrome.send('requestNearbyURLs'); 17 chrome.send('requestNearbyURLs');
18 } 18 }
19 19
20 function physicalWebItemClicked(index) { 20 function physicalWebItemClicked(index) {
21 chrome.send('physicalWebItemClicked', [index]); 21 chrome.send('physicalWebItemClicked', [index]);
22 } 22 }
23 23
24 function returnNearbyURLs(nearbyUrlsData) { 24 function returnNearbyURLs(nearbyUrlsData) {
25 var bodyContainer = $('body-container'); 25 var bodyContainer = $('body-container');
26 renderTemplate(nearbyUrlsData); 26 renderTemplate(nearbyUrlsData);
27 bodyContainer.style.visibility = 'visible';
mmocny 2017/03/02 17:13:35 Nit: could you create a CSS class for hidden items
Ran 2017/03/23 16:56:26 Done.
28 addErrorHandler();
29 }
27 30
28 bodyContainer.style.visibility = 'visible'; 31 function addErrorHandler() {
mmocny 2017/03/02 17:13:35 Please rename: `assignImageLoadErrorHandlers`
Ran 2017/03/23 16:56:26 Done.
32 var images = document.getElementsByTagName('img');
Matt Reynolds 2017/03/02 01:02:39 Would getElementsByName work here to get only the
mmocny 2017/03/02 17:13:35 Nit: chrome support `let` keyword now, which is mo
mmocny 2017/03/02 17:13:35 Personally I like using document.querySelector() (
Ran 2017/03/23 16:56:26 Done.
Ran 2017/03/23 16:56:26 Done.
Ran 2017/03/23 16:56:26 Done.
33 for (var i = 0; i < images.length; i++) {
34 var img = images[i];
35 img.addEventListener('error', function() {
36 this.src = "chrome://physical-web/link.png";
Matt Reynolds 2017/03/02 01:02:39 Use a relative path here (relative to the webui UR
Ran 2017/03/23 16:56:25 Done.
37 });
38 }
29 } 39 }
30 40
31 document.addEventListener('DOMContentLoaded', requestNearbyURLs); 41 document.addEventListener('DOMContentLoaded', requestNearbyURLs);
OLDNEW
« no previous file with comments | « components/physical_web/webui/physical_web_ui_constants.cc ('k') | components/resources/components_scaled_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698