svghmi/widget_jsontable.ysl2
branchsvghmi
changeset 3069 a9b03c2634c5
parent 3066 d7b9c2ceb3fb
child 3080 e5fa1f49f0b9
equal deleted inserted replaced
3068:81758c94f3df 3069:a9b03c2634c5
     1 // widget_jsontable.ysl2
     1 // widget_jsontable.ysl2
     2 
     2 
     3 template "widget[@type='JsonTable']", mode="widget_class"
     3 template "widget[@type='JsonTable']", mode="widget_class"
     4     ||
     4     ||
     5     class JsonTableWidget extends Widget{
     5     class JsonTableWidget extends Widget{
     6         cache = [100,50];
     6         // arbitrary defaults to avoid missing entries in query
       
     7         cache = [0,100,50];
     7         do_http_request(...opt) {
     8         do_http_request(...opt) {
     8             const query = {
     9             const query = {
     9                 args: this.args,
    10                 args: this.args,
    10                 range: this.cache[1],
    11                 range: this.cache[1],
    11                 position: this.cache[2],
    12                 position: this.cache[2],
    12                 visible: this.visible,
    13                 visible: this.visible,
       
    14                 extra: this.cache.slice(4),
    13                 options: opt
    15                 options: opt
    14             };
    16             };
    15 
    17 
    16             const options = {
    18             const options = {
    17                  method: 'POST',
    19                  method: 'POST',
   218     |     spread_json_data: function(janswer) {
   220     |     spread_json_data: function(janswer) {
   219     |         let [range,position,jdata] = janswer;
   221     |         let [range,position,jdata] = janswer;
   220     |         this.apply_hmi_value(1, range);
   222     |         this.apply_hmi_value(1, range);
   221     |         this.apply_hmi_value(2, position);
   223     |         this.apply_hmi_value(2, position);
   222     |         this.apply_hmi_value(3, this.visible);
   224     |         this.apply_hmi_value(3, this.visible);
   223     |         console.log(range,position,jdata);
       
   224     apply "$data_elt", mode="json_table_render_except_comments" {
   225     apply "$data_elt", mode="json_table_render_except_comments" {
   225         with "expressions","$initexpr_ns";
   226         with "expressions","$initexpr_ns";
   226         with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*";
   227         with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*";
   227     }
   228     }
   228     |     }
   229     |     }