]> git.mxchange.org Git - flightgear.git/commitdiff
PropertyBrowser: Add a JSON link and the path
authorTorsten Dreyer <torsten@ŧ3r.de>
Fri, 13 Feb 2015 10:42:45 +0000 (11:42 +0100)
committerTorsten Dreyer <torsten@ŧ3r.de>
Fri, 13 Feb 2015 10:42:45 +0000 (11:42 +0100)
src/Network/http/PropertyUriHandler.cxx

index 77e6df8e668954e9bd1a8e5fa2ad1e26fa269bb4..3fe9c33b9286436697f3751cb827e5d3b39d9925 100644 (file)
@@ -85,8 +85,8 @@ public:
   virtual ~DOMNode();
 
   virtual std::string render() const;
-  virtual void addChild( DOMElement * child );
-  virtual void setAttribute( const string & name, const string & value );
+  virtual DOMNode * addChild( DOMElement * child );
+  virtual DOMNode * setAttribute( const string & name, const string & value );
 protected:
   string _name;
   typedef vector<const DOMElement*> Children_t;
@@ -129,14 +129,16 @@ string DOMNode::render() const
   return reply;
 }
 
-void DOMNode::addChild( DOMElement * child )
+DOMNode * DOMNode::addChild( DOMElement * child )
 {
   _children.push_back( child );
+  return dynamic_cast<DOMNode*>(child);
 }
 
-void DOMNode::setAttribute( const string & name, const string & value )
+DOMNode * DOMNode::setAttribute( const string & name, const string & value )
 {
   _attributes[name] = value;
+  return this;
 }
 
 class SortedChilds : public simgear::PropertyList {
@@ -188,6 +190,16 @@ DOMElement * createHeader( const string & prefix, const string & propertyPath )
   root->addChild( headline );
   headline->addChild( new DOMTextElement("FlightGear Property Browser") );
 
+  {
+    DOMNode * div = new DOMNode("div");
+    root->addChild(div);
+    div->addChild( new DOMNode("span"))->addChild( new DOMTextElement("Path:"));
+    div->addChild( new DOMNode("span"))->addChild( new DOMTextElement( propertyPath ) );
+    div->addChild( new DOMNode("a"))->
+         setAttribute("href",string("/json/")+propertyPath+"?i=y")->
+         addChild( new DOMTextElement( "As JSON" ) );
+  }
+
   DOMNode * breadcrumb = new DOMNode("ul");
   root->addChild( breadcrumb );