almost working
[unfold.git] / plugins / senslabmap / static / js / senslabmap.js
index eb3acd2..10abf41 100644 (file)
@@ -3,48 +3,46 @@
     init: function(options, element) {
       this._super(options, element);
       
-      /* Member variables */
-      // query status
-      this.received_all = false;
-      this.received_set = false;
-      this.in_set_buffer = Array();
+      this.elmt().on('show', this, this.on_show);
       
-      var query = manifold.query_store.find_analyzed_query(options.query_uuid);
       this.method = query.object;
       
-      var keys = manifold.metadata.get_key(this.method);
-      this.key = (keys && keys.length == 1) ? keys[0] : null;
-      
       /* Setup query and record handlers */
       this.listen_query(options.query_uuid);
-      this.listen_query(options.query_uuid, 'all');
-      
+      this.listen_query(options.query_all_uuid, 'all');
+
       /* GUI setup and event binding */
       this.initialize_map();
     },
     
     initialize_map: function() {
-      // TODO: this is static, retrieve directly nodes
-      nodes = nodes_gre;
-      init();
-      parseNodebox();
+      this.nodes = [];
+      this.id = 0;
     },
-    
-    on_show: function(e) {
-      // TODO
+
+    refresh: function() {
+      console.log("refresh");
+      myrender();
     },
     
-    on_filter_added: function(filter) {
-      console.log(filter);
+    on_show: function(e) {
+      e.data.refresh();
     },
     
-    on_new_record: function(record) {
-      console.log(record);
+    on_all_new_record: function(n) {
+      // format is : [name, x, y, z, uid, state]
+      // state = "Busy", "Alive" or "Down"
+      this.id++;
+      node = [this.id, n.x, n.y, n.z, this.id, "Alive"];
+      this.nodes.push(node);
+      console.log("node id " + this.id);
     },
     
-    on_record_received: function(record) {
-      console.log(record);
-    },
+    on_all_query_done: function() {
+      nodes = this.nodes;
+      init();
+      parseNodebox();
+    }
   });
   $.plugin('SensLabMap', SensLabMap);
 })(jQuery);