almost working
[myslice.git] / plugins / senslabmap / static / js / senslabmap.js
1 (function($){
2   var SensLabMap = Plugin.extend({
3     init: function(options, element) {
4       this._super(options, element);
5       
6       this.elmt().on('show', this, this.on_show);
7       
8       this.method = query.object;
9       
10       /* Setup query and record handlers */
11       this.listen_query(options.query_uuid);
12       this.listen_query(options.query_all_uuid, 'all');
13
14       /* GUI setup and event binding */
15       this.initialize_map();
16     },
17     
18     initialize_map: function() {
19       this.nodes = [];
20       this.id = 0;
21     },
22
23     refresh: function() {
24       console.log("refresh");
25       myrender();
26     },
27     
28     on_show: function(e) {
29       e.data.refresh();
30     },
31     
32     on_all_new_record: function(n) {
33       // format is : [name, x, y, z, uid, state]
34       // state = "Busy", "Alive" or "Down"
35       this.id++;
36       node = [this.id, n.x, n.y, n.z, this.id, "Alive"];
37       this.nodes.push(node);
38       console.log("node id " + this.id);
39     },
40     
41     on_all_query_done: function() {
42       nodes = this.nodes;
43       init();
44       parseNodebox();
45     }
46   });
47   $.plugin('SensLabMap', SensLabMap);
48 })(jQuery);