From 6e3486349b4c5f1c53c53034c40803ad4abf0900 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Fri, 13 Feb 2015 11:42:45 +0100 Subject: [PATCH] PropertyBrowser: Add a JSON link and the path --- src/Network/http/PropertyUriHandler.cxx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Network/http/PropertyUriHandler.cxx b/src/Network/http/PropertyUriHandler.cxx index 77e6df8e6..3fe9c33b9 100644 --- a/src/Network/http/PropertyUriHandler.cxx +++ b/src/Network/http/PropertyUriHandler.cxx @@ -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 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(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 );