"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Table = Object.create( {}, {
|
"_eventName" : {
|
value : "tableEvent.Table"
|
},
|
"_th" : {
|
value : null,
|
writable : true
|
},
|
"_trs" : {
|
value : [],
|
writable : true
|
},
|
"_tableID" : {
|
value : "vue0",
|
writable : true
|
},
|
"init" : {
|
value : function(){
|
|
$( "#" + this._tableID ).remove();
|
|
this._th = null;
|
this._trs = [];
|
|
var self = this;
|
|
$( this ).off( self._eventName );
|
|
|
$( this ).on( self._eventName, self.tableEventHandler );
|
},
|
enumerable : true
|
},
|
"tableEventHandler" : {
|
value : function( event ){
|
if ( event.dvjh && event.dvjh.length == 1 ){
|
if ( this._th == null ){
|
this._th = event.dvjh.p1Name;
|
}
|
|
this._trs.push( event.dvjh.p1Data );
|
}
|
|
return false;
|
},
|
enumerable : true
|
},
|
"print" : {
|
value : function( id ){
|
if ( this._th != null && this._trs[ 0 ] != null ){
|
var t0 = this._trs[ 0 ][ 3 ];
|
|
this._tableID = "vue" + t0;
|
|
var self = this,
|
deltaT = [],
|
tdlength = this._th.length,
|
trlength = this._trs.length,
|
array = [ "<table id='" + this._tableID + "' class='dvjhTable'>" ],
|
arrayHead = [ "<thead><tr>" ],
|
arrayFoot = [ "<tfoot><tr>" ];
|
|
deltaT.push( 0 );
|
|
for( var i = 1; i < trlength; i++ ){
|
deltaT.push( this._trs[ i ][ 3 ] - t0 );
|
}
|
|
for ( var i = 0; i < tdlength; i++ ){
|
arrayHead.push( "<th>" + self._th[ i ] + "</th>" );
|
}
|
|
arrayHead.push( "<th>Delta T ms</th></tr></thead>" );
|
|
for ( var i = 0; i < tdlength; i++ ){
|
arrayFoot.push( "<th>" + self._th[ i ] + "</th>" );
|
}
|
|
arrayFoot.push( "<th>Delta T ms</th></tr></tfoot>" );
|
|
array.push( arrayHead.join(''), arrayFoot.join(''), "<tbody>" );
|
|
for ( var j = 0; j < trlength; j++ ){
|
array.push( "<tr>" );
|
|
for ( var i = 0; i < tdlength; i++ ){
|
array.push( "<td>" + self._trs[ j ][ i ] + "</td>" );
|
}
|
|
array.push( "<td>" + deltaT[ j ] + "</td></tr>" );
|
}
|
|
array.push( "</tbody></table>" );
|
|
$( "#" + id ).append( array.join('') );
|
|
$( "#" + this._tableID ).tablesorter({
|
sortList: [ [ 3, 0 ] ],
|
widgets: [ 'zebra' ],
|
headers: {
|
4 : { sorter : false }
|
}
|
});
|
} else {
|
$( "#" + id ).html( "<p>Il n'y a aucune information à afficher !</p>" );
|
}
|
},
|
enumerable : true
|
}
|
});
|
|
|
|
|
|
|
|
var Pair = Object.create( {}, {
|
"_number" : {
|
value : 0,
|
writable : true
|
},
|
"init" : {
|
value : function( n ){
|
this._number = 0;
|
|
if ( typeof n === "number" ){
|
this._number = n;
|
}
|
},
|
enumerable : true
|
},
|
"add" : {
|
value : function( obj ){
|
this._number++;
|
|
if ( ( this._number % 2 == 0 ) && ( obj._eventName ) ){
|
var objEvent = new $.Event( obj._eventName );
|
|
|
|
|
|
|
|
|
|
objEvent.dvjh = {
|
"length" : 1,
|
"p1Name" : "Pair",
|
"p1Data" : this._number
|
};
|
|
$( obj ).trigger( objEvent );
|
}
|
},
|
enumerable : true
|
}
|
});
|
|
|
|
|
|
|
|
var Impair = Object.create( {}, {
|
"_number" : {
|
value : 0,
|
writable : true
|
},
|
"init" : {
|
value : function( n ){
|
this._number = 0;
|
|
if ( typeof n === "number" ){
|
this._number = n;
|
}
|
},
|
enumerable : true
|
},
|
"add" : {
|
value : function( obj ){
|
this._number++;
|
|
if ( ( this._number % 2 != 0 ) && ( obj._eventName ) ){
|
var objEvent = new $.Event( obj._eventName );
|
|
objEvent.dvjh = {
|
"length" : 1,
|
"p1Name" : "Impair",
|
"p1Data" : this._number
|
};
|
|
$( obj ).trigger( objEvent );
|
}
|
},
|
enumerable : true
|
}
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var Total = Object.create( {}, {
|
"_eventName" : {
|
value : "totalEvent.Total"
|
},
|
"_number" : {
|
value : 0,
|
writable : true
|
},
|
"_source" : {
|
value : "",
|
writable : true
|
},
|
"_total" : {
|
value : 0,
|
writable : true
|
},
|
"_timeStamp" : {
|
value : 0,
|
writable : true
|
},
|
"_milliseconds" : {
|
value : 1000,
|
writable : true
|
},
|
"init" : {
|
value : function( milliseconds, divID ){
|
|
this._number = 0;
|
this._source = "";
|
this._total = 0;
|
this._timeStamp = 0;
|
this._milliseconds = parseInt( milliseconds, 10 ) || 1000;
|
|
Table.init();
|
Pair.init();
|
Impair.init();
|
|
var self = this;
|
|
$( this ).off( self._eventName );
|
|
|
$( this ).on( self._eventName, self.totalEventHandler );
|
|
var pairInterval = window.setInterval( function(){
|
Pair.add( self );
|
}, 30 ),
|
impairInterval = window.setInterval( function(){
|
Impair.add( self );
|
}, 40 );
|
|
window.setTimeout( function(){
|
window.clearInterval( pairInterval );
|
window.clearInterval( impairInterval );
|
Table.print( divID );
|
}, this._milliseconds);
|
},
|
enumerable : true
|
},
|
"totalEventHandler" : {
|
value : function( event ){
|
if ( event.dvjh && event.dvjh.length == 1 ){
|
this._number = event.dvjh.p1Data;
|
this._source = event.dvjh.p1Name;
|
this._total += this._number;
|
this._timeStamp = event.timeStamp;
|
|
var self = this,
|
outputEvent = new $.Event( Table._eventName );
|
|
outputEvent.dvjh = {
|
"length" : 1,
|
"p1Name" : [ "Total", "Nombre", "Source", "TimeStamp ms" ],
|
"p1Data" : [ this._total, this._number, this._source, this._timeStamp ]
|
};
|
|
$( Table ).trigger( outputEvent );
|
}
|
|
return false;
|
},
|
enumerable : true
|
}
|
});
|