fhemweb_iconLabel.js, fhemweb_iconSwitch.js: improved color handling

git-svn-id: https://svn.fhem.de/fhem/trunk@15224 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Ellert
2017-10-10 11:50:17 +00:00
parent 79d4c1bcef
commit 385b8ed738
3 changed files with 10 additions and 0 deletions

View File

@@ -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 )+"")

View File

@@ -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.<br>
</li>
<br>
=end html
=begin html_DE
@@ -198,6 +199,7 @@ FW_iconRadioCreate(elName, devName, vArr, currVal, set, params, cmd)
angezeigt, sonst das Icon. Wird &lt;icon&gt; nicht angegeben,
wird der Vergleichwert angezeigt.<br>
</li>
<br>
=end html_DE
=cut
*/

View File

@@ -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 )+"")