Сделана кнопка выбора режима работы (Normal/ECO)
Как сделать чтобы она работала и прописано это было в HTML коде, а не в условии отображения
Т.е. если у реле стоит "0" то это нормальный режим, а если "0" то экономичный
HTMLПоказать
Код: Выделить всё
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="tablerad">
<tbody>
<tr>
<td colspan="3" id="cell1">Батарея на входе</td>
</tr>
<tr>
<td rowspan="3" id="cell2"> <div class="switch">
<input type="radio" class="switch-input" name="view" value="week" id="week" checked>
<label for="week" class="switch-label switch-label-off">Normal</label>
<input type="radio" class="switch-input" name="view" value="month" id="month">
<label for="month" class="switch-label switch-label-on"> ECO</label>
<span class="switch-selection"></span>
</div></td>
<td rowspan="3" id="cell3">%espSensor_temp02.value% °C</td>
<td id="cell5">Деньги</td>
</tr>
<tr>
<td id="cell6">Киловаты</td>
</tr>
<tr>
<td id="cell7">Рост температуры</td>
</tr>
<tr>
<td colspan="3" id="cell4">
<div class="progress" style= "margin-bottom: 0px; margin-bottom: 4px;"">
<span class="green" style="width: %espSensor_temp02.periodten%%;"><span>%espSensor_temp02.periodten%%</span></span>
</div>
</td>
</tr>
</tbody>
</table>
<script>
$('button').on('click', function(){
$('button').removeClass('button2');
$(this).addClass('button3');
});
</script>
CSSПоказать
Код: Выделить всё
.tablerad {
color: black;
text-align: center;
font-size: 12px;
table-layout: fixed;
/*width: 383px;*/
border-collapse: collapse;
}
.tablerad td{
border: 0px solid black;
}
/*Имя комнаты*/
#cell1 {
height: 18px;
font-size: 14px;
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
color: white;
border-bottom: 1px solid white;
border-top: 1px solid white;
letter-spacing: 1px;
word-spacing: 3px;
}
/*Режим работы*/
#cell2{
width: 80px;
height: 50px;
padding-right: 10px;
padding-left: 5px;
}
/*Температура и график*/
#cell3{
width: 140px;
font-size: 25px;
font-weight: bold;
letter-spacing: 1px;
word-spacing: 3px;
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
color: white;
border-left: 1px solid white;
border-right: 1px solid white;
}
/*Прогресс бар*/
#cell4{
height: 18px;
width: 383px;
border-bottom: 1px solid white;
}
/*Деньги*/
#cell5{
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
color: white;
font-size: 9px;
letter-spacing: 1px;
word-spacing: 3px;
}
/*Киловаты*/
#cell6 {
border-top: 1px solid white;
border-bottom: 1px solid white;
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
color: white;
font-size: 9px;
letter-spacing: 1px;
word-spacing: 3px;
}
/*Рост температуры*/
#cell7{
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
color: white;
font-size: 9px;
letter-spacing: 1px;
word-spacing: 3px;
}
/*Кнопка режима работы*/
body {
font: 13px/20px "Lucida Grande", Tahoma, Verdana, sans-serif;
color: #404040;
background: #363a41;
}
.container {
margin: 50px auto;
width: 120px;
}
.switch {
position: relative;
margin: 5px auto;
height: 26px;
width: 120px;
background: rgba(0, 0, 0, 0.25);
border-radius: 3px;
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
}
.switch-label {
position: relative;
z-index: 2;
float: left;
width: 58px;
line-height: 26px;
font-size: 11px;
color: rgba(255, 255, 255, 0.35);
text-align: center;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
cursor: pointer;
}
.switch-label:active {
font-weight: bold;
}
.switch-label-off {
padding-left: 2px;
}
.switch-label-on {
padding-right: 2px;
}
/*
Note: using adjacent or general sibling selectors
combined with pseudo classes doesn't work in Safari
5.0 and Chrome 12.
See this article for more info and a potential fix:
https://css-tricks.com/webkit-sibling-bug/
*/
.switch-input {
display: none;
}
.switch-input:checked + .switch-label {
font-weight: bold;
color: rgba(0, 0, 0, 0.65);
text-shadow: 0 1px rgba(255, 255, 255, 0.25);
-webkit-transition: 0.15s ease-out;
-moz-transition: 0.15s ease-out;
-o-transition: 0.15s ease-out;
transition: 0.15s ease-out;
}
.switch-input:checked + .switch-label-on ~ .switch-selection {
/* Note: left: 50% doesn't transition in WebKit */
left: 60px;
}
.switch-selection {
display: block;
position: absolute;
z-index: 1;
top: 2px;
left: 2px;
width: 58px;
height: 22px;
background: #65bd63;
border-radius: 3px;
background-image: -webkit-linear-gradient(top, #9dd993, #65bd63);
background-image: -moz-linear-gradient(top, #9dd993, #65bd63);
background-image: -o-linear-gradient(top, #9dd993, #65bd63);
background-image: linear-gradient(to bottom, #9dd993, #65bd63);
-webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 0 2px rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 0 2px rgba(0, 0, 0, 0.2);
-webkit-transition: left 0.15s ease-out;
-moz-transition: left 0.15s ease-out;
-o-transition: left 0.15s ease-out;
transition: left 0.15s ease-out;
}
.switch-blue .switch-selection {
background: #3aa2d0;
background-image: -webkit-linear-gradient(top, #4fc9ee, #3aa2d0);
background-image: -moz-linear-gradient(top, #4fc9ee, #3aa2d0);
background-image: -o-linear-gradient(top, #4fc9ee, #3aa2d0);
background-image: linear-gradient(to bottom, #4fc9ee, #3aa2d0);
}
.switch-yellow .switch-selection {
background: #c4bb61;
background-image: -webkit-linear-gradient(top, #e0dd94, #c4bb61);
background-image: -moz-linear-gradient(top, #e0dd94, #c4bb61);
background-image: -o-linear-gradient(top, #e0dd94, #c4bb61);
background-image: linear-gradient(to bottom, #e0dd94, #c4bb61);
}
/**Прогресс бар**//
.progress {
height: 18px;
width: 378px;
background: #ebebeb;
border-left: 0px solid transparent;
border-right: 0px solid transparent;
border-radius: 10px;
}
.progress > span {
position: relative;
float: left;
margin: 0 -1px;
min-width: 30px;
height: 20px;
line-height: 16px;
text-align: left;
background: #cccccc;
border: 1px solid;
border-color: #bfbfbf #b3b3b3 #9e9e9e;
border-radius: 4px;
background-image: -webkit-linear-gradient(top, #f0f0f0, #dbdbdb 70%, #cccccc);
background-image: -moz-linear-gradient(top, #f0f0f0, #dbdbdb 70%, #cccccc);
background-image: -o-linear-gradient(top, #f0f0f0, #dbdbdb 70%, #cccccc);
background-image: linear-gradient(to bottom, #f0f0f0, #dbdbdb 70%, #cccccc);
-webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}
.progress > span > span {
padding: 0 8px;
font-size: 11px;
font-weight: bold;
color: #404040;
color: rgba(0, 0, 0, 0.7);
text-shadow: 0 1px rgba(255, 255, 255, 0.4);
}
.progress .green {
background: #85c440;
border-color: #78b337 #6ba031 #568128;
background-image: -webkit-linear-gradient(top, #b7dc8e, #99ce5f 70%, #85c440);
background-image: -moz-linear-gradient(top, #b7dc8e, #99ce5f 70%, #85c440);
background-image: -o-linear-gradient(top, #b7dc8e, #99ce5f 70%, #85c440);
background-image: linear-gradient(to bottom, #b7dc8e, #99ce5f 70%, #85c440);
}