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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
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 418dc1d6e90c1b5e8daffb35b8fbd841900eae08..e9f596e8730aeefc132aab122e57366996918a98 100644
--- a/components/physical_web/webui/resources/physical_web.js
+++ b/components/physical_web/webui/resources/physical_web.js
@@ -24,8 +24,18 @@ function physicalWebItemClicked(index) {
function returnNearbyURLs(nearbyUrlsData) {
var bodyContainer = $('body-container');
renderTemplate(nearbyUrlsData);
-
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.
+ addErrorHandler();
+}
+
+function addErrorHandler() {
mmocny 2017/03/02 17:13:35 Please rename: `assignImageLoadErrorHandlers`
Ran 2017/03/23 16:56:26 Done.
+ 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.
+ for (var i = 0; i < images.length; i++) {
+ var img = images[i];
+ img.addEventListener('error', function() {
+ 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.
+ });
+ }
}
document.addEventListener('DOMContentLoaded', requestNearbyURLs);
« 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