using the host from the document.location

This commit is contained in:
Martin Donnelly 2016-11-23 20:49:07 +00:00
parent 80179091b6
commit 59675e69ca
2 changed files with 15 additions and 3 deletions

View File

@ -19,7 +19,8 @@
</div>
<div class="section">Indoors</div>
<div>
<div class="temp" id="indoorTemp"></div>
<span class="temp" id="indoorTemp"></span> <span id='fan' class="fan">Fan On</span>
</div>
<div class="section">Weather</div>

View File

@ -6,18 +6,29 @@ let TempModel = Backbone.Model.extend({});
let Temp = Backbone.View.extend({
tagName: 'div',
initialize: function () {
initialize: function() {
_.bindAll(this, 'render');
this.model.bind('change', this.render);
this.$indoorTemp = $('#indoorTemp');
this.$fan = $('#fan');
this.$fan.hide();
},
render: function () {
render: function() {
console.log('Temp:Render');
const data = this.model.get('data');
this.$indoorTemp.empty().html(parseFloat(data.temp) + '&deg;c&nbsp;');
if (data.mode === 'FanOff' && this.$fan.is(':visible')) {
this.$fan.hide();
}
if (data.mode === 'FanOn' && this.$fan.is(':hidden')) {
this.$fan.show();
}
}
});