1
0
Fork 0

fgfs.js: simpler implementation of property-set

Thanks to Laurent for the patch
This commit is contained in:
Torsten Dreyer 2015-11-05 18:30:59 +01:00
parent 94a5384b40
commit cadc93c8bb

View file

@ -18,26 +18,7 @@ FGFS.Property.prototype.getPath = function() {
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;
}
this.listener.setProperty(this.path, value);
}
FGFS.Property.prototype.hasValue = function() {
@ -125,6 +106,7 @@ FGFS.PropertyListener = function(arg) {
command : 'get',
node : path
}));
prop.listener = this;
}
return this._nextId;
};