2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

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 29e0487052
commit 30f89f9024
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(ilast > 0) { //text only with color
if (vArr[i+1] && vArr[i+1].indexOf("@") == 0) { if (vArr[i+1] && vArr[i+1].indexOf("@") == 0) {
col = vArr[i+1].replace(/@/,''); col = vArr[i+1].replace(/@/,'');
if( col.match(/^[A-F0-9]{6}$/))
col = "#"+col;
$(newEl).find("span").html(arg+"") $(newEl).find("span").html(arg+"")
.attr("style","color: "+col+" !important; padding:0.0em 0.3em ") .attr("style","color: "+col+" !important; padding:0.0em 0.3em ")
.attr("title",arg); .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 } else if (vArr[i+1] && vArr[i+1].indexOf("@") > 0) { //text or image with color
ico = vArr[i+1].split("@"); 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){ FW_cmd(FW_root+"?cmd={FW_makeImage('"+vArr[i+1]+"','"+arg+"')}&XHR=1",function(data){
data = data.replace(/\n$/,''); data = data.replace(/\n$/,'');
$(newEl).find("span").html((vArr[i+1] == data ? ico[0] : data )+"") $(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 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> the icon. If nothing is specified, the reference value will be displayed.<br>
</li> </li>
<br>
=end html =end html
=begin html_DE =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, angezeigt, sonst das Icon. Wird &lt;icon&gt; nicht angegeben,
wird der Vergleichwert angezeigt.<br> wird der Vergleichwert angezeigt.<br>
</li> </li>
<br>
=end html_DE =end html_DE
=cut =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 if (vArr[i+1] && vArr[i+1].indexOf("@") == 0) { //text only with color
col = vArr[i+1].replace(/@/,''); col = vArr[i+1].replace(/@/,'');
if( col.match(/^[A-F0-9]{6}$/))
col = "#"+col;
$(newEl).find("span").html(vArr[i]+"") $(newEl).find("span").html(vArr[i]+"")
.attr("style","color: "+col+" !important; padding:0.0em 0.3em ") .attr("style","color: "+col+" !important; padding:0.0em 0.3em ")
.attr("title",arg); .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 } else if (vArr[i+1] && vArr[i+1].indexOf("@") > 0) { //text or image with color
ico = vArr[i+1].split("@"); 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){ FW_cmd(FW_root+"?cmd={FW_makeImage('"+vArr[i+1]+"','"+arg+"')}&XHR=1",function(data){
data = data.replace(/\n$/,''); data = data.replace(/\n$/,'');
$(newEl).find("span").html((vArr[i+1] == data ? ico[0] : data )+"") $(newEl).find("span").html((vArr[i+1] == data ? ico[0] : data )+"")