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) { FGFS.Property.prototype.setValue = function(value) {
if( value == null ) if( value == null )
return; return;
//this.value = val; value should be updated via PropertyListener this.listener.setProperty(this.path, value);
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() { FGFS.Property.prototype.hasValue = function() {
@ -125,6 +106,7 @@ FGFS.PropertyListener = function(arg) {
command : 'get', command : 'get',
node : path node : path
})); }));
prop.listener = this;
} }
return this._nextId; return this._nextId;
}; };