Skip to content

Commit

Permalink
[BasicUI] Consider the correct iconset when reloading the icon
Browse files Browse the repository at this point in the history
Fix #1790

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo committed Mar 14, 2023
1 parent 3dd8e6f commit abc3d45
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<img data-icon="%icon_name%" src="../icon/%icon_name_in_url%?state=%state_in_url%&iconset=%icon_set_in_url%&format=%icon_type%&anyFormat=true" />
<img data-icon="%icon_set%:%icon_name%" src="../icon/%icon_name_in_url%?state=%state_in_url%&iconset=%icon_set_in_url%&format=%icon_type%&anyFormat=true" />
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<img data-icon="%icon_name%" src="../icon/%icon_name_in_url%?iconset=%icon_set_in_url%&format=%icon_type%&anyFormat=true" />
<img data-icon="%icon_set%:%icon_name%" src="../icon/%icon_name_in_url%?iconset=%icon_set_in_url%&format=%icon_type%&anyFormat=true" />
13 changes: 10 additions & 3 deletions bundles/org.openhab.ui.basic/web-src/smarthome.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@
var
_t = this,
suppress = false,
noneImageSrc = "/icon/none.png";
noneImageSrc = "/icon/none.png",
splittedIconAttr;

_t.parentNode = parentNode;
_t.formRow = parentNode.parentNode;
Expand All @@ -344,7 +345,9 @@
}

if (_t.icon !== null) {
_t.iconName = _t.icon.getAttribute(o.iconAttribute);
splittedIconAttr = _t.icon.getAttribute(o.iconAttribute).split(":");
_t.iconSet = splittedIconAttr[0];
_t.iconName = splittedIconAttr[1];
if (_t.icon.src !== noneImageSrc) {
_t.icon.addEventListener("error", replaceImageWithNone);
}
Expand All @@ -360,6 +363,8 @@
encodeURIComponent(_t.iconName) +
"?state=" +
encodeURIComponent(state) +
"&iconset=" +
encodeURIComponent(_t.iconSet) +
"&format=" +
smarthome.UI.iconType +
"&anyFormat=true"
Expand All @@ -368,7 +373,9 @@
_t.icon.setAttribute("src",
"/icon/" +
encodeURIComponent(_t.iconName) +
"?format=" +
"?iconset=" +
encodeURIComponent(_t.iconSet) +
"&format=" +
smarthome.UI.iconType +
"&anyFormat=true"
);
Expand Down

0 comments on commit abc3d45

Please sign in to comment.