From 30f89f902438adc1d166eae89478fe8b5a590cd7 Mon Sep 17 00:00:00 2001
From: Ellert <>
Date: Tue, 10 Oct 2017 11:50:17 +0000
Subject: [PATCH] fhemweb_iconLabel.js, fhemweb_iconSwitch.js: improved color
handling
git-svn-id: https://svn.fhem.de/fhem/trunk@15224 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/www/pgm2/fhemweb_iconLabel.js | 4 ++++
fhem/www/pgm2/fhemweb_iconRadio.js | 2 ++
fhem/www/pgm2/fhemweb_iconSwitch.js | 4 ++++
3 files changed, 10 insertions(+)
diff --git a/fhem/www/pgm2/fhemweb_iconLabel.js b/fhem/www/pgm2/fhemweb_iconLabel.js
index 57047d1c1..d828f50ea 100644
--- a/fhem/www/pgm2/fhemweb_iconLabel.js
+++ b/fhem/www/pgm2/fhemweb_iconLabel.js
@@ -58,6 +58,8 @@ FW_IconLabelCreate(elName, devName, vArr, currVal, set, params, cmd)
if(ilast > 0) { //text only with color
if (vArr[i+1] && vArr[i+1].indexOf("@") == 0) {
col = vArr[i+1].replace(/@/,'');
+ if( col.match(/^[A-F0-9]{6}$/))
+ col = "#"+col;
$(newEl).find("span").html(arg+"")
.attr("style","color: "+col+" !important; padding:0.0em 0.3em ")
.attr("title",arg);
@@ -72,6 +74,8 @@ FW_IconLabelCreate(elName, devName, vArr, currVal, set, params, cmd)
});
} else if (vArr[i+1] && vArr[i+1].indexOf("@") > 0) { //text or image with color
ico = vArr[i+1].split("@");
+ if( ico[1] && ico[1].match(/^[A-F0-9]{6}$/))
+ ico[1] = "#"+ico[1];
FW_cmd(FW_root+"?cmd={FW_makeImage('"+vArr[i+1]+"','"+arg+"')}&XHR=1",function(data){
data = data.replace(/\n$/,'');
$(newEl).find("span").html((vArr[i+1] == data ? ico[0] : data )+"")
diff --git a/fhem/www/pgm2/fhemweb_iconRadio.js b/fhem/www/pgm2/fhemweb_iconRadio.js
index 321c7abb7..b2e577557 100644
--- a/fhem/www/pgm2/fhemweb_iconRadio.js
+++ b/fhem/www/pgm2/fhemweb_iconRadio.js
@@ -153,6 +153,7 @@ FW_iconRadioCreate(elName, devName, vArr, currVal, set, params, cmd)
If <icon> is no icon name, the text will be displayed, otherwise
the icon. If nothing is specified, the reference value will be displayed.
+
=end html
=begin html_DE
@@ -198,6 +199,7 @@ FW_iconRadioCreate(elName, devName, vArr, currVal, set, params, cmd)
angezeigt, sonst das Icon. Wird <icon> nicht angegeben,
wird der Vergleichwert angezeigt.
+
=end html_DE
=cut
*/
diff --git a/fhem/www/pgm2/fhemweb_iconSwitch.js b/fhem/www/pgm2/fhemweb_iconSwitch.js
index 013f30f07..f3b617846 100644
--- a/fhem/www/pgm2/fhemweb_iconSwitch.js
+++ b/fhem/www/pgm2/fhemweb_iconSwitch.js
@@ -92,6 +92,8 @@ FW_iconSwitchCreate(elName, devName, vArr, currVal, set, params, cmd)
}
if (vArr[i+1] && vArr[i+1].indexOf("@") == 0) { //text only with color
col = vArr[i+1].replace(/@/,'');
+ if( col.match(/^[A-F0-9]{6}$/))
+ col = "#"+col;
$(newEl).find("span").html(vArr[i]+"")
.attr("style","color: "+col+" !important; padding:0.0em 0.3em ")
.attr("title",arg);
@@ -107,6 +109,8 @@ FW_iconSwitchCreate(elName, devName, vArr, currVal, set, params, cmd)
});
} else if (vArr[i+1] && vArr[i+1].indexOf("@") > 0) { //text or image with color
ico = vArr[i+1].split("@");
+ if( ico[1] && ico[1].match(/^[A-F0-9]{6}$/))
+ ico[1] = "#"+ico[1];
FW_cmd(FW_root+"?cmd={FW_makeImage('"+vArr[i+1]+"','"+arg+"')}&XHR=1",function(data){
data = data.replace(/\n$/,'');
$(newEl).find("span").html((vArr[i+1] == data ? ico[0] : data )+"")