X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fsenslabmap%2Fstatic%2Fjs%2Fsenslabmap.js;h=68e2189cc27f5dc23754899d691a232d1b00e4fe;hb=8ed7a9041ea134a9f4eea1c37d1ca0740ae83641;hp=8075be9cf81bd1965201e4fd808d6e6e22d11200;hpb=38c4da7256807f22c2e495d57af8598a5ee84d95;p=unfold.git diff --git a/plugins/senslabmap/static/js/senslabmap.js b/plugins/senslabmap/static/js/senslabmap.js index 8075be9c..68e2189c 100644 --- a/plugins/senslabmap/static/js/senslabmap.js +++ b/plugins/senslabmap/static/js/senslabmap.js @@ -1,80 +1,52 @@ -/** - * Description: SensLab display of 3D-geolocated data - * Copyright (c) 2012 UPMC Sorbonne Universite - INRIA - * License: GPLv3 - */ - -// xxx TODO -- this plugin has never been tested -// update_map looks suspiciously empty... -// in addition it could use a bit of cleaning like what was done for the first plugins -// especially wrt using 'instance' and 'data' in such a confusing way - -(function( $ ){ - - $.fn.SensLabMap = function( method ) { - /* Method calling logic */ - if ( methods[method] ) { - return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); - } else if ( typeof method === 'object' || ! method ) { - return methods.init.apply( this, arguments ); - } else { - $.error( 'Method ' + method + ' does not exist on $.SensLabMap' ); - } - }; - - var methods = { - init : function( options ) { - return this.each(function(){ - var $this = $(this), - data = $this.data('SensLabMap'), SensLabMap = $('
', { text : $this.attr('title') }); - // If the plugin hasn't been initialized yet - if ( ! data ) { - /* Plugin initialization */ - //google.load('maps', '3', { other_params: 'sensor=false' }); - //google.setOnLoadCallback(initialize); - init(); - /* End of plugin initialization */ - $(this).data('SensLabMap', { - plugin_uuid: options.plugin_uuid, - query_uuid: options.query_uuid, - target : $this, - SensLabMap : SensLabMap - }); - /* Subscribe to query updates */ - $.subscribe('/results/' + options.query_uuid + '/changed', {instance: $this}, update_map); - } - }); - }, - destroy : function( ) { - return this.each(function(){ - var $this = $(this), data = $this.data('SensLabMap'); - $(window).unbind('SensLabMap'); - data.SensLabMap.remove(); - $this.removeData('SensLabMap'); - }); - }, -/* - reposition : function( ) { // ... }, - show : function( ) { // ... }, - hide : function( ) { // ... }, -*/ - update : function( content ) { - // should be made a private function - set3dsize() - }, - }; - - /* Private methods */ - function update_map(e, rows) { - var $plugindiv = e.data.instance; - $plugindiv.closest('.need-spin').spin(false); - - if(rows) { - /* TODO rendering */ - } else { - alert('error'); - } - - } - -})( jQuery ); +(function($){ + var SensLabMap = Plugin.extend({ + 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.el().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'); + + /* GUI setup and event binding */ + this.initialize_map(); + }, + + initialize_map: function() { + // TODO: this is static, retrieve directly nodes + nodes = nodes_gre; + init(); + parseNodebox(); + }, + + on_show: function(e) { + // TODO + }, + + on_filter_added: function(filter) { + console.log(filter); + }, + + on_new_record: function(record) { + console.log(record); + }, + + on_record_received: function(record) { + console.log(record); + }, + }); + $.plugin('SensLabMap', SensLabMap); +})(jQuery);