1
0
Fork 0

Phi: implement missing property set in fgfs.js

Implement the second part of the mirror in
FGFS.Property.prototype.setValue instead of the current TODO.

Thanks to Laurent for the patch.
This commit is contained in:
Torsten Dreyer 2015-10-29 19:38:42 +01:00
parent dae544f0ec
commit ec37636b02

View file

@ -15,9 +15,29 @@ FGFS.Property.prototype.getPath = function() {
return this.path;
}
FGFS.Property.prototype.setValue = function(val) {
// TODO: send this out
this.value = val;
FGFS.Property.prototype.setValue = function(value) {
if( value == null )
return;
//this.value = val; value should be updated via PropertyListener
var url = "/json/" + this.path;
switch( typeof(value) ) {
case 'number':
case 'string':
case 'boolean':
$.post(url, JSON.stringify({'value' : value}))
.fail(function(err){
console.log("Error while setting property value: " + err);
});
return;
case 'object':
$.post(url, JSON.stringify(value))
.fail(function(err){
console.log("Error while setting property value: " + err);
});
return;
default:
return;
}
}
FGFS.Property.prototype.hasValue = function() {