X-Git-Url: https://www.hackdaworld.org/gitweb/?a=blobdiff_plain;f=js%2Fintres.js;h=84bc7059084e2222827a65fbfc92262eadb79adf;hb=53f9a32e5440e6f7916169b332a98dfb1fed0e3d;hp=abfce1594e1003d83ef950bbbedad62fc9e7c7c7;hpb=a70ae963d2557a79e7402cd36b3be29f5aa01867;p=outofuni%2Fintres.git diff --git a/js/intres.js b/js/intres.js index abfce15..84bc705 100644 --- a/js/intres.js +++ b/js/intres.js @@ -13,6 +13,9 @@ var config = { var thermo = { init: function() { thermo.draw(); + $('#thermo').click(function() { + thermo.draw_thermos(); + }); }, draw: function() { thermo.get_thermos(); @@ -38,21 +41,50 @@ var thermo = { 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="
"; + switch(type) { + case 'd': + html+="
"+alias+"
"; + html+="
"+name+"
"; + html+="
"+state+"
"; + html+="
"+eco+"
"; + html+="
"+comfort+"
"; + break; + case 'h': + html+="
"+alias+"
"; + html+="
"+name+"
"; + html+="
"+state+"
"; + html+="
"+eco+"
"; + html+="
"+comfort+ + "
"; + break; + } + html+="
"; + 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+"
"; + html+=thermo.draw_thermo(th.alias,i,th.state, + th.eco,th.comfort,'d'); } - tdiv=$('div#thermobody'); - tdiv.html(html); + $('div#thermobody').html(html); } };