FGPanel2.0: implement setProperty
This commit is contained in:
parent
c32d6029ff
commit
7505f3b816
1 changed files with 20 additions and 2 deletions
|
@ -106,6 +106,14 @@ FGFS.PropertyListener = function(arg) {
|
|||
throw new Error('removeProperty not yet implemented');
|
||||
};
|
||||
|
||||
this.setProperty = function( path, val ) {
|
||||
this._ws.send(JSON.stringify({
|
||||
command : 'set',
|
||||
node : path,
|
||||
value: val
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// expects:
|
||||
|
@ -141,6 +149,11 @@ FGFS.PropertyMirror = function(mirroredProperties) {
|
|||
return this.mirror[id];
|
||||
};
|
||||
|
||||
this.setProperty = function( key, value ) {
|
||||
var node = this.mirror[key];
|
||||
this.listener.setProperty( node.path, value );
|
||||
}
|
||||
|
||||
// TODO: ugly static variable, change this!
|
||||
FGFS.NodeProvider.mirror = this;
|
||||
}
|
||||
|
@ -415,7 +428,7 @@ FGFS.FGPanel = function( propUrl )
|
|||
});
|
||||
}
|
||||
|
||||
var mirror = new FGFS.PropertyMirror(this.props.propertyMirror);
|
||||
this.mirror = new FGFS.PropertyMirror(this.props.propertyMirror);
|
||||
|
||||
this.instruments = $(this.props.instrumentSelector).fgLoadInstruments(this.props.instrumentDataKey);
|
||||
|
||||
|
@ -426,14 +439,19 @@ FGFS.FGPanel = function( propUrl )
|
|||
window.setTimeout( $.proxy(this.update,this), this.props.updateInterval );
|
||||
}
|
||||
|
||||
this.setProperty = function( key, value ) {
|
||||
this.mirror.setProperty( key, value );
|
||||
}
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
var hasFGPanel = $("body").data("fgpanel");
|
||||
if( hasFGPanel ) {
|
||||
var panelProps = $("body").data("fgpanel-props");
|
||||
new FGFS.FGPanel( panelProps == null ? "fgpanel.json" : panelProps );
|
||||
window.fgPanel = new FGFS.FGPanel( panelProps == null ? "fgpanel.json" : panelProps );
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue