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

Unified Diff: components/physical_web/webui/resources/physical_web.js

Issue 2717363003: Add Physical Web WebUI Default Url Icon (Closed)
Patch Set: rebase 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 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 b050945951938506355bfc04751d0abe32defa84..86002dd5027c47f343ec945f5c6dc06e7bb474c9 100644
--- a/components/physical_web/webui/resources/physical_web.js
+++ b/components/physical_web/webui/resources/physical_web.js
@@ -25,6 +25,8 @@ function renderTemplate(nearbyUrlsData) {
// This is the javascript code that processes the template:
jstProcess(new JsEvalContext(nearbyUrlsData), templateDiv);
+ assignImageLoadErrorHandlers();
+
let bodyContainer = $('body-container');
bodyContainer.hidden = false;
}
@@ -41,4 +43,15 @@ function pushNearbyURLs(nearbyUrlsData) {
renderTemplate(nearbyUrlsData);
}
+function assignImageLoadErrorHandlers() {
+ var pwIcons = document.querySelectorAll('.physicalWebIcon');
+ pwIcons.forEach(function(e) {
+ let img = e.getElementsByTagName('img')[0];
+ img.addEventListener('error', function() {
+ img.src =
+ 'chrome://physical-web/ic_link_grey600_36dp.png';
+ });
+ });
+}
+
document.addEventListener('DOMContentLoaded', physicalWebPageLoaded);
« no previous file with comments | « components/physical_web/webui/physical_web_ui_constants.cc ('k') | components/resources/physical_web_ui_resources.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698