mirror of
https://gitlab.silvrtree.co.uk/martind2000/censis-archive.git
synced 2025-02-25 14:13:35 +00:00
”2016-09-14”
This commit is contained in:
parent
70b9b267a8
commit
f578eab065
@ -482,7 +482,7 @@
|
|||||||
filter.push(co2);
|
filter.push(co2);
|
||||||
|
|
||||||
|
|
||||||
//if (step % 100 === 0) {
|
//If (step % 100 === 0) {
|
||||||
if (filter.length >= max) {
|
if (filter.length >= max) {
|
||||||
let sub100 = filter.reduce((prev, cur) => prev + cur);
|
let sub100 = filter.reduce((prev, cur) => prev + cur);
|
||||||
chunk.sub100 = sub100 / max;
|
chunk.sub100 = sub100 / max;
|
||||||
@ -508,27 +508,31 @@
|
|||||||
|
|
||||||
|
|
||||||
var Widget = Backbone.View.extend({
|
var Widget = Backbone.View.extend({
|
||||||
tagName : 'div',
|
//el: '#widgets',
|
||||||
template: _.template($('#widget-template').html()),
|
template: _.template($('#widget-template').html()),
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
_.bindAll(this, 'render');
|
_.bindAll(this, 'render');
|
||||||
|
this.modes = ['', 'lux', 'temp', 'co2', 'humid', 'noise'];
|
||||||
this.listenTo(this.model,'change',function(d){
|
this.titles = [
|
||||||
let data = d.get('data');
|
'', 'Light Levels', 'Temperature', 'Co2 Levels', 'Humidity', 'Sound'
|
||||||
|
];
|
||||||
|
this.listenTo(this.model,'change',function() {
|
||||||
this.render();
|
this.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.widgetMode = this.id.split('-')[1];
|
this.widgetMode = this.id.split('-')[1];
|
||||||
|
this.title = this.titles[this.modes.indexOf(this.widgetMode)];
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
let data = this.model.get('data');
|
let data = this.model.get('data');
|
||||||
let value = (typeof data !== 'undefined') ? data[this.widgetMode] : 0;
|
let value = (typeof data !== 'undefined') ? data[this.widgetMode] : 0;
|
||||||
var html = this.template({name:this.widgetMode,value:value});
|
var html = this.template({name: this.title,value: value});
|
||||||
console.log(html);
|
console.log(html);
|
||||||
console.log(this.$el);
|
console.log(this.$el);
|
||||||
this.$el.empty();
|
console.log('rendering');
|
||||||
this.$el.html('<p>hello</p>');
|
this.$el.append(html);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
@ -55,9 +55,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="widget-temp" style="color:yellow;background-color:grey;border:1px yellow solid;">
|
<div id="widgets">
|
||||||
|
<div class='mui-row' id="widget-temp">
|
||||||
</div>
|
</div>
|
||||||
<div id="widget-co2" style="color:yellow;background-color:grey;border 1px solid yellow;"></div>
|
<div class='mui-row' id="widget-co2"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script type="text/template" id="loaded-template">
|
<script type="text/template" id="loaded-template">
|
||||||
<div
|
<div
|
||||||
style="background-color: darkred;color: white;font-weight: 900;text-align: center">Loaded
|
style="background-color: darkred;color: white;font-weight: 900;text-align: center">Loaded
|
||||||
@ -215,7 +220,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/template" id="widget-template">
|
<script type="text/template" id="widget-template">
|
||||||
<div>
|
<div class="mui-col-md-3 panel">
|
||||||
<div class="mui-col-md-2"><%= name %></div>
|
<div class="mui-col-md-2"><%= name %></div>
|
||||||
<div class="mui-col-md-2"><%= value %></div>
|
<div class="mui-col-md-2"><%= value %></div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user