Hallo,
ich versuche den smallrtr um ein Popup zur Betriebsart zu erweitern.
Wie kann ich den Wert des Items auswerten um je nach Wert ein Symbol anzuzeigen?
Die Zeile scheint so nicht zu gehen:
Gesamt Widget
Danke für eure Hilfe.
ich versuche den smallrtr um ein Popup zur Betriebsart zu erweitern.
Wie kann ich den Wert des Items auswerten um je nach Wert ein Symbol anzuzeigen?
Die Zeile scheint so nicht zu gehen:
Code:
{% if [item_comfort] == '1' %}
Code:
<a href="#{{ uid }}-popup" data-rel="popup"> {% if [item_comfort] == '1' %} <img class="icon icon1" src="icons/ws/user_available.svg" alt="{{ uid }}-popup" /> {% elseif [item_comfort] == 2 %} <img class="icon icon1" src="icons/ws/user_away.svg" alt="{{ uid }}-popup" /> {% else %} <img class="icon icon1" src="icons/ws/user_away.svg" alt="{{ uid }}-popup" /> {% endif %} </a>
Gesamt Widget
Code:
/** * Extended Small RTR (Room Temperatur Regulator) * * @param {id=} unique id for this widget * @param {text=} name of the rtr * @param {item(num)} a gad/item for the actual temperature * @param {item(num)} a gad/item for the set temperature * @param {item(bool)} a gad/item for the current state of the actor * @param {value=0.5} step for plus/minus buttons (optional, default 0.5°) */ {% macro ext(id, txt, gad_actual, gad_set, gad_state, step, item_comfort, item_night, item_frost, supplements) %} {% import "@widgets/basic.html" as basic %} {% set uid = uid(page, id) %} /** Design */ <div id="{{ uid }}" class="rtr"> <table style="width:100%; text-align: left;"> <tr> <th width="20%">{% if txt %} {{ txt }} {% endif %}</th> <td width="10%"><div class="temp">{{ basic.print(id~'actual', gad_actual, '°C' ) }}</div></td> <td width="10%"> {% if gad_set %} {{ basic.offset(id~'minus', 'gad_set', -(step|default(0.5)), 'minus', '', 'micro') }} {% endif %} </td> <td width="10%"><div class="temp">{{ basic.print(id~'set', gad_set, '°C' ) }}</div></td> <td width="10%"> {% if gad_set %} {{ basic.offset(id~'plus', 'gad_set', (step|default(0.5)), 'plus', '', 'micro') }} {% endif %} </td> <td width="10%"> {% if gad_state %} {{ basic.print(id~'state', gad_state, '%' ) }} {% endif %} </td> <td width="15%"> {% for supplement in supplements %} {{ supplement|raw }} {% endfor %} </td> <td width="15%"> {% if item_comfort is not empty %} <a href="#{{ uid }}-popup" data-rel="popup"> {% if [item_comfort] == '1' %} <img class="icon icon1" src="icons/ws/user_available.svg" alt="{{ uid }}-popup" /> {% elseif [item_comfort] == 2 %} <img class="icon icon1" src="icons/ws/user_away.svg" alt="{{ uid }}-popup" /> {% else %} <img class="icon icon1" src="icons/ws/user_away.svg" alt="{{ uid }}-popup" /> {% endif %} </a> <div id="{{ uid }}-popup" data-role="popup"> <div> {% if item_comfort is not empty and (item_comfort == item_night or item_night is empty) and (item_comfort == item_frost or item_frost is empty) %} {{ basic.stateswitch(id~'sw_comfort', item_comfort, 'icon', [1, 2], ['user_available.svg', 'user_away.svg'], '', ['icon1', 'icon0']) }} {{ basic.stateswitch(id~'sw_night', item_comfort, 'icon', [3, 2], ['scene_night.svg', 'scene_night.svg'], '', ['icon1', 'icon0']) }} {{ basic.stateswitch(id~'sw_frost', item_comfort, 'icon', [4, 2], ['weather_frost.svg', 'weather_frost.svg'], '', ['icon1', 'icon0']) }} {% else %} {% if item_comfort is not empty %} {{ basic.stateswitch(id~'sw_comfort', item_comfort, 'icon', '', ['user_away.svg', 'user_available.svg']) }} {% endif %} {% if item_night is not empty %} {{ basic.stateswitch(id~'sw_night', item_night, 'icon', '', ['scene_night.svg', 'scene_night.svg']) }} {% endif %} {% if item_frost is not empty %} {{ basic.stateswitch(id~'sw_frost', item_frost, 'icon', '', ['weather_frost.svg', 'weather_frost.svg']) }} {% endif %} {% endif %} {% endif %} </div> </div> </td> </tr> </table> {% if gad_set %} /** Events */ <script type="text/javascript"> // plus / minus $("#{{ uid~'minus' }}").unbind('click').bind('click', function(){ var temp = (Math.round((parseFloat($("#{{ uid~'set' }}").html().replace(',','.')) - {{ step|default(0.5) }}) * 10) / 10).toFixed(1); $("#{{ uid~'set' }}").html(temp + ' °C'); io.write("{{ gad_set }}", temp); }); $("#{{ uid~'plus' }}").unbind('click').bind('click', function(){ var temp = (Math.round((parseFloat($("#{{ uid~'set' }}").html().replace(',','.')) + {{ step|default(0.5) }}) * 10) / 10).toFixed(1); $("#{{ uid~'set' }}").html(temp + ' °C'); io.write("{{ gad_set }}", temp); }); </script> {% endif %} </div> {% endmacro %}
Kommentar