Blame view

src/misc/static/js/weather.js 2.31 KB
511d1511   Patrick Maeght   plot
1
2
3
4
5

var sync_plots = {
    humidity_plot : new PlotterClas("humidity", "humidity_plot", [10,30]),
}

5fc9423e   Patrick Maeght   weather js
6
var sync_weather = {
511d1511   Patrick Maeght   plot
7
    //
5fc9423e   Patrick Maeght   weather js
8
9
10
    set_data: function(data_) {
        //See data_: http://127.0.0.1:5030/eicdata/ajax/?&action=data_state&id=2016-12-01
        //if (data_.ACK) {
3780544a   Patrick Maeght   weather css
11
            var res = sync_weather.tuned_state(data_, ' ');
3780544a   Patrick Maeght   weather css
12
            document.getElementById('plc').innerHTML = res;
511d1511   Patrick Maeght   plot
13
14
15
            //var res = sync_weather.object_to_tree(data_, ' ');
            //document.getElementById('refresh').innerHTML = res;
            sync_plots.humidity_plot.refresh_list([data_[0].fields.updated , data_[0].fields.humidity]);
5fc9423e   Patrick Maeght   weather js
16
17
18
        //}
    },
    tuned_state: function(data) {
3780544a   Patrick Maeght   weather css
19
20
21
22
23
        data = data[0];
        res ='<h4>PLC</h4>'
        res +='<table>';
        if (data.is_safe == true) {
            res += sync_weather.get_success("is_safe", data.is_safe);
5fc9423e   Patrick Maeght   weather js
24
        } else {
3780544a   Patrick Maeght   weather css
25
            res += sync_weather.get_warning("is_safe", data.is_safe);
5fc9423e   Patrick Maeght   weather js
26
        }
3780544a   Patrick Maeght   weather css
27
28
        res += sync_weather.get_success("plc_mode", data.plc_mode);
        res += sync_weather.get_success("plc_timeout", data.plc_timeout);
5fc9423e   Patrick Maeght   weather js
29
30
31
        res += "</table>";
        return res
    },
ad5be706   Patrick Maeght   weather css
32
33
    // alert alert-success
    get_success: function(name, value) {return '<tr class="alert alert-info"><th scope="row">'+name+':&nbsp;</th><td>'+value+'</td></tr>';},
5fc9423e   Patrick Maeght   weather js
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    get_warning: function(name, value) {return '<tr class="alert alert-warning"><th scope="row">'+name+':&nbsp;</th><td>'+value+'</td></tr>';},
    setTimeout:function(){
        //alert("change");
        Async.status.timeout = document.getElementById('timer_select').value * 1000;
    },
    object_to_tree: function(argObject, level) {
      var msg = '';
      for (var propertyName in argObject) {
        if (typeof argObject[propertyName] == 'object'){
              msg += '<p>' + level + propertyName  + ': (' + typeof argObject[propertyName] + ')</p>';
              msg += this.object_to_tree(argObject[propertyName], level + '--&nbsp;');
        } else if (typeof argObject[propertyName] == 'function'){
              msg += '<p>' + level + propertyName  + ': (' + typeof argObject[propertyName] + ')</p>';
        } else {
              msg += '<p>' + level + propertyName  + ': (' + typeof argObject[propertyName] + ') <span class=\"fld\">' + argObject[propertyName] + '</span></p>';
        }
      }
      return msg
    }
}