summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5401c1b)
we can now get some events traced right into plugins.js instead of having to instrument all callbacks
14 files changed:
+// set to either
+// * false or undefined or none : no debug
+// * true : trace all event calls
+// * [ 'in_progress', 'query_done' ] : would only trace to these events
+var plugin_debug=false;
+plugin_debug = [ 'in_progress', 'query_done' ];
+
var Plugin = Class.extend({
init: function(options, element) {
var Plugin = Class.extend({
init: function(options, element) {
return (typeof this.on_filter_added === 'function');
},
return (typeof this.on_filter_added === 'function');
},
+ // do we need to log API calls ?
+ _is_in : function (obj, arr) {
+ for(var i=0; i<arr.length; i++) {
+ if (arr[i] == obj) return true;
+ }
+ },
+ _deserves_logging: function (event) {
+ if ( ! plugin_debug ) return false;
+ else if ( plugin_debug === true) return true;
+ else if (this._is_in (event, plugin_debug)) return true;
+ return false;
+ },
+
_query_handler: function(prefix, event_type, data) {
// We suppose this.query_handler_prefix has been defined if this
// callback is triggered
_query_handler: function(prefix, event_type, data) {
// We suppose this.query_handler_prefix has been defined if this
// callback is triggered
switch(event_type) {
case FILTER_ADDED:
switch(event_type) {
case FILTER_ADDED:
+ event = 'filter_added';
break;
case FILTER_REMOVED:
break;
case FILTER_REMOVED:
+ event = 'filter_removed';
break;
case CLEAR_FILTERS:
break;
case CLEAR_FILTERS:
+ event = 'filter_clear';
break;
case FIELD_REMOVED:
break;
case FIELD_REMOVED:
+ event = 'field_removed';
break;
case CLEAR_FIELDS:
break;
case CLEAR_FIELDS:
break;
default:
return;
} // switch
break;
default:
return;
} // switch
- fn = 'on_' + prefix + fn;
+ fn = 'on_' + prefix + event;
if (typeof this[fn] === 'function') {
if (typeof this[fn] === 'function') {
+ if (this._deserves_logging (event)) {
+ var classname=this.classname;
+ messages.debug("Plugin._query_handler: calling "+fn+" on "+classname);
+ }
// call with data as parameter
// XXX implement anti loop
this[fn](data);
// call with data as parameter
// XXX implement anti loop
this[fn](data);
_record_handler: function(prefix, event_type, record) {
// We suppose this.query_handler_prefix has been defined if this
// callback is triggered
_record_handler: function(prefix, event_type, record) {
// We suppose this.query_handler_prefix has been defined if this
// callback is triggered
switch(event_type) {
case NEW_RECORD:
switch(event_type) {
case NEW_RECORD:
break;
case CLEAR_RECORDS:
break;
case CLEAR_RECORDS:
+ event = 'clear_records';
- fn = 'query_in_progress';
+ event = 'query_in_progress';
break;
case FIELD_STATE_CHANGED:
break;
case FIELD_STATE_CHANGED:
- fn = 'field_state_changed';
+ event = 'field_state_changed';
break;
default:
return;
} // switch
break;
default:
return;
} // switch
- fn = 'on_' + prefix + fn;
+ fn = 'on_' + prefix + event;
if (typeof this[fn] === 'function') {
if (typeof this[fn] === 'function') {
+ if (this._deserves_logging (event)) {
+ var classname=this.classname;
+ messages.debug("Plugin._record_handler: calling "+fn+" on "+classname);
+ }
// call with data as parameter
// XXX implement anti loop
this[fn](record);
// call with data as parameter
// XXX implement anti loop
this[fn](record);
var ActiveFilters = Plugin.extend({
init: function(options, element) {
var ActiveFilters = Plugin.extend({
init: function(options, element) {
+ this.classname="active_filters";
this._super(options, element);
this.elts('closeButton').click(function() {
this._super(options, element);
this.elts('closeButton').click(function() {
var debug=false;
debug=true;
var debug=false;
debug=true;
+ // this now should be obsolete, rather use plugin_debug in plugin.js
// more on a on-per-record basis
var debug_deep=false;
// debug_deep=true;
// more on a on-per-record basis
var debug_deep=false;
// debug_deep=true;
var GoogleMap = Plugin.extend({
init: function(options, element) {
var GoogleMap = Plugin.extend({
init: function(options, element) {
+ this.classname="googlemap";
this._super(options, element);
/* Member variables */
this._super(options, element);
/* Member variables */
var SimpleList = Plugin.extend ({
init: function (options, element) {
var SimpleList = Plugin.extend ({
init: function (options, element) {
+ this.classname=options.classname;
this._super (options, element);
this.buffered_records=[];
this.listen_query(options.query_uuid);
this._super (options, element);
this.buffered_records=[];
this.listen_query(options.query_uuid);
var self=this;
var $plugindiv = this.elmt();
var options = this.options;
var self=this;
var $plugindiv = this.elmt();
var options = this.options;
- var classname=options.classname;
// locate the <table> element; with datatables in the way,
// this might not be a direct son of the div-plugin
// locate the <table> element; with datatables in the way,
// this might not be a direct son of the div-plugin
- var $table = $plugindiv.find("table."+classname).first();
+ var $table = $plugindiv.find("table."+this.classname).first();
// also we may or may not have a header
// also we may or may not have a header
- var $tbody = $table.find("tbody."+classname).first();
+ var $tbody = $table.find("tbody."+this.classname).first();
var use_datatables = $table.hasClass("with-datatables");
var rows=self.buffered_records;
self.buffered_records=[];
var use_datatables = $table.hasClass("with-datatables");
var rows=self.buffered_records;
self.buffered_records=[];
if (use_datatables)
this._datatables_update_table($table, $tbody, rows, options.key);
else
if (use_datatables)
this._datatables_update_table($table, $tbody, rows, options.key);
else
- this._regular_update_table($table, $tbody, rows, options.key, classname);
+ this._regular_update_table($table, $tbody, rows, options.key, this.classname);
},
_regular_set_message: function ($table, $tbody, message) {
},
_regular_set_message: function ($table, $tbody, message) {
_regular_update_table: function ($table, $tbody, rows, key, classname) {
if (debug)
_regular_update_table: function ($table, $tbody, rows, key, classname) {
if (debug)
- messages.debug('regular_update_table ' + rows.length + " rows" + " key=" + key + " classname=" + classname);
+ messages.debug('regular_update_table ' + rows.length + " rows" +
+ " key=" + key + " classname=" + this.classname);
var self=this;
var html=$.map(rows, function (row) {
var value = row;
var self=this;
var html=$.map(rows, function (row) {
var value = row;
});
if ($.isArray(value)) {
return $.map(value, function(val, i) {
});
if ($.isArray(value)) {
return $.map(value, function(val, i) {
- return self._html_row ( self._cell (key, val), classname);
+ return self._html_row ( self._cell (key, val), this.classname);
- return self._html_row ( self._cell (key, value), classname);
+ return self._html_row ( self._cell (key, value), this.classname);
}
}).join();
$tbody.html(html);
}
}).join();
$tbody.html(html);
*/
init: function(options, element) {
// Call the parent constructor, see FAQ when forgotten
*/
init: function(options, element) {
// Call the parent constructor, see FAQ when forgotten
+ this.classname="maddash";
this._super(options, element);
this._super(options, element);
var Messages = Plugin.extend ({
init: function (options, element) {
var Messages = Plugin.extend ({
init: function (options, element) {
this._super (options, element);
// subscribe to the various messages channels
var self=this;
this._super (options, element);
// subscribe to the various messages channels
var self=this;
* applied, which allows to maintain chainability of calls
*/
init: function(options, element) {
* applied, which allows to maintain chainability of calls
*/
init: function(options, element) {
+ // for debugging tools
+ this.classname="myplugin";
// Call the parent constructor, see FAQ when forgotten
this._super(options, element);
// Call the parent constructor, see FAQ when forgotten
this._super(options, element);
var QueryGrid = Plugin.extend({
init: function(options, element) {
var QueryGrid = Plugin.extend({
init: function(options, element) {
+ this.classname="querygrid";
this._super(options, element);
/* Member variables */
this._super(options, element);
/* Member variables */
var QueryTable = Plugin.extend({
var QueryTable = Plugin.extend({
- init: function(options, element)
- {
+ init: function(options, element) {
+ this.classname="querytable";
this._super(options, element);
/* Member variables */
this._super(options, element);
/* Member variables */
+ var debug=false;
+ debug=true;
+
// XXX record selected (multiple selection ?)
// XXX record disabled ?
// XXX out of sync plugin ?
// XXX record selected (multiple selection ?)
// XXX record disabled ?
// XXX out of sync plugin ?
var QueryUpdater = Plugin.extend({
var QueryUpdater = Plugin.extend({
- init: function(options, element)
- {
+ init: function(options, element) {
+ this.classname="queryupdater";
this._super(options, element);
var self = this;
this._super(options, element);
var self = this;
/***************************** GUI EVENTS *****************************/
/***************************** GUI EVENTS *****************************/
- do_update: function(e)
- {
+ do_update: function(e) {
var self = e.data;
// XXX check that the query is not disabled
manifold.raise_event(self.options.query_uuid, RUN_UPDATE);
var self = e.data;
// XXX check that the query is not disabled
manifold.raise_event(self.options.query_uuid, RUN_UPDATE);
on_query_in_progress: function()
{
on_query_in_progress: function()
{
+ messages.debug("queryupdater.on_query_in_progress");
init: function(options, element)
{
init: function(options, element)
{
+ this.classname="scheduler";
this._super(options, element);
/* Member variables */
this._super(options, element);
/* Member variables */
(function($){
var SensLabMap = Plugin.extend({
init: function(options, element) {
(function($){
var SensLabMap = Plugin.extend({
init: function(options, element) {
+ this.classname="senslabmap";
this._super(options, element);
this.elmt().on('show', this, this.on_show);
this._super(options, element);
this.elmt().on('show', this, this.on_show);
* applied, which allows to maintain chainability of calls
*/
init: function(options, element) {
* applied, which allows to maintain chainability of calls
*/
init: function(options, element) {
+ this.classname="slicestat";
// Call the parent constructor, see FAQ when forgotten
this._super(options, element);
// Call the parent constructor, see FAQ when forgotten
this._super(options, element);
var TopmenuValidation = Plugin.extend({
init: function(options, element) {
var TopmenuValidation = Plugin.extend({
init: function(options, element) {
+ this.classname="topmenuvalidation";
this._super(options, element);
this.listen_query(options.query_uuid);
this.triggered=false;
this._super(options, element);
this.listen_query(options.query_uuid);
this.triggered=false;