From ec37636b02310c3bf36fe93bb7ba58871d3c6245 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Thu, 29 Oct 2015 19:38:42 +0100 Subject: [PATCH] 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. --- Phi/lib/fgfs.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Phi/lib/fgfs.js b/Phi/lib/fgfs.js index 4236062aa..75e085388 100644 --- a/Phi/lib/fgfs.js +++ b/Phi/lib/fgfs.js @@ -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() {