Some javascript library fixes
- don't ignore "func" property for Property InputValues - expose "timeofday" command via fgcommand.js
This commit is contained in:
parent
94426d1f46
commit
5e2a37be56
2 changed files with 18 additions and 7 deletions
|
@ -64,5 +64,8 @@ var fgCommand = {
|
||||||
reposition: function() {
|
reposition: function() {
|
||||||
$.post("/run.cgi?value=reposition");
|
$.post("/run.cgi?value=reposition");
|
||||||
},
|
},
|
||||||
|
timeofday: function(type,offset) {
|
||||||
|
this.sendCommand("timeofday", this.twoArgs("timeofday", type, "offset", null != offset ? offset : 0 ));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -203,26 +203,34 @@ FGFS.InputValue = function(arg) {
|
||||||
this.min = null;
|
this.min = null;
|
||||||
this.max = null;
|
this.max = null;
|
||||||
this.precision = 4;
|
this.precision = 4;
|
||||||
|
this.format = null;
|
||||||
this.func = null;
|
this.func = null;
|
||||||
|
|
||||||
if( arg.precision != null ) this.precision = arg.precision;
|
if( arg.precision != null ) this.precision = arg.precision;
|
||||||
|
if( arg.format != null ) this.format = arg.format;
|
||||||
|
|
||||||
|
this.getFormatted = function( value ) {
|
||||||
|
if( null != this.format )
|
||||||
|
return this.format(value);
|
||||||
|
return value.toPrecision(this.precision);
|
||||||
|
}
|
||||||
|
|
||||||
this.getValue = function() {
|
this.getValue = function() {
|
||||||
var value = this.value;
|
var value = this.value;
|
||||||
if (this.property != null)
|
if (this.property != null)
|
||||||
value = this.property.getNumValue();
|
value = this.property.getNumValue();
|
||||||
else if( this.func != null )
|
if( this.func != null )
|
||||||
value = this.func();
|
value = this.func(value);
|
||||||
|
|
||||||
if (this.interpolationTable != null && this.interpolationTable.length > 0)
|
if (this.interpolationTable != null && this.interpolationTable.length > 0)
|
||||||
return FGFS.interpolate(value, this.interpolationTable).toPrecision(this.precision);
|
return this.getFormatted(FGFS.interpolate(value, this.interpolationTable));
|
||||||
|
|
||||||
value = value * this.scale + this.offset;
|
value = value * this.scale + this.offset;
|
||||||
if( this.min != null && value < this.min )
|
if( this.min != null && value < this.min )
|
||||||
return this.min.toPrecision(this.precision);
|
return this.getFormatted(this.min);
|
||||||
if( this.max != null && value > this.max )
|
if( this.max != null && value > this.max )
|
||||||
return this.max.toPrecision(this.precision);
|
return this.getFormatted(this.max);
|
||||||
return value.toPrecision(this.precision);
|
return this.getFormatted(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof (arg) == 'number') {
|
if (typeof (arg) == 'number') {
|
||||||
|
|
Loading…
Reference in a new issue