var thermo = {
init: function() {
thermo.draw();
+ $('#thermo').click(function() {
+ thermo.draw_thermos();
+ });
},
draw: function() {
thermo.get_thermos();
alias=alias.replace(/alias\s+/,"");
var state=ret.match(/STATE.*/)+'';
state=state.replace(/STATE\s+/,"");
+ var eco=ret.match(/ecoTemperature.*/)+'';
+ eco=eco.replace(/.*ecoTemperature\s+/,"");
+ var comfort=ret.match(/comfortTem.*/)+'';
+ comfort=comfort.replace(/.*comfortTem.*\s+/,"");
thermo.thermos[id]={};
thermo.thermos[id].alias=alias;
- thermo.thermos[id].temp=state;
+ thermo.thermos[id].state=state;
+ thermo.thermos[id].eco=eco;
+ thermo.thermos[id].comfort=comfort;
thermo.draw_thermos();
});
}
},
+ draw_thermo: function(alias,name,state,eco,comfort,type) {
+ var html="<div class=thermo>";
+ switch(type) {
+ case 'd':
+ html+="<div class=thermoalias>"+alias+"</div>";
+ html+="<div class=thermoname>"+name+"</div>";
+ html+="<div class=thermostate>"+state+"</div>";
+ html+="<div class=thermoeco>"+eco+"</div>";
+ html+="<div class=thermocomfort>"+comfort+"</div>";
+ break;
+ case 'h':
+ html+="<div class=thermoalias><b>"+alias+"</b></div>";
+ html+="<div class=thermoname><b>"+name+"</b></div>";
+ html+="<div class=thermostate><b>"+state+"</b></div>";
+ html+="<div class=thermoeco><b>"+eco+"</b></div>";
+ html+="<div class=thermocomfort><b>"+comfort+
+ "</b></div>";
+ break;
+ }
+ html+="</div>";
+ return html;
+ },
draw_thermos: function() {
- var html="";
+ var html=thermo.draw_thermo('Alias','Name','State',
+ 'Eco','Comfort','h');
for(var i in thermo.thermos) {
var th=thermo.thermos[i];
- html+=th.alias+" "+th.temp+"<br>";
+ html+=thermo.draw_thermo(th.alias,i,th.state,
+ th.eco,th.comfort,'d');
}
- tdiv=$('div#thermobody');
- tdiv.html(html);
+ $('div#thermobody').html(html);
}
};