xh Class
These methods apply to the top level of the Xholon application. All of the methods in this class MUST be preceeded by "$wnd.xh." (ex: "$wnd.xh.app();") if they are run from within the Xholon application. The "$wnd." is a GWT requirement. They MUST be preceeded by "xh." (ex: "xh.app();") if they are run using a developer's tool such as Firebug or Developer Tools.
Constructor
xh
()
Item Index
Methods
app
()
IApplication
Get the single app-specific IApplication instance.
Returns:
An instance of a subclass of org.primordion.xholon.app.Application.
Example:
var app = $wnd.xh.app();
attrs
-
node
Log all attribute name/value pairs (JavaScript properties) of a node to the browser console. This is mostly intended for debugging.
Parameters:
-
node
IXholonAn IXholon node.
Example:
var node = $wnd.xh.root();
$wnd.xh.attrs(node);
html.toggle
-
elementId
Toggle the visibility of an existing HTML element, typically a div that starts with "xh".
Parameters:
-
elementId
StringAn HTML element id.
Example:
$wnd.xh.html.toggle("xhgui");
html.xhElements
()
String
Get an array of top-level "xh" element id's.
Returns:
a comma-delimited list (ex: "xhtop,xhgui,xhappspecific,xhconsole,xhtabs,xhchart,xhcanvas,xhgraph,xhsvg,xhimg").
Example:
$wnd.xh.html.xhElements();
param
-
pName
-
[pValue]
Get or set the value of an application parameter.
Parameters:
-
pName
StringThe name of the parameter.
-
[pValue]
String optionalThe value of the parameter.
Returns:
The value of the parameter, or null, or undefined.
Example:
// set the interval between time steps as 200 milliseconds
// show the before and after values in the browser console
console.log($wnd.xh.param("TimeStepInterval"));
$wnd.xh.param("TimeStepInterval", "200");
console.log($wnd.xh.param("TimeStepInterval"));
require
-
scriptName
-
[scriptPath]
Require a single named JavaScript library. If the script is located in the Xholon application library, then only the scriptName needs to be provided.
Parameters:
-
scriptName
StringThe name of a script.
-
[scriptPath]
String optionalThe URL for the script.
Example:
$wnd.xh.require("d3.v2.min.js");
$wnd.xh.require("three.min.js", "http://threejs.org/build/");
root
()
IXholon
Get the app-specific root of the composite structure hierarchy.
Returns:
An instance of a subclass of org.primordion.xholon.base.Xholon.
Example:
var root = $wnd.xh.root();
service
-
serviceName
Get a Xholon Service.
Parameters:
-
serviceName
StringThe name of a service (ex: "TimelineService").
Returns:
An IXholon node, or null.
Example:
var service = $wnd.xh.service("TimelineService");
console.log(service);
services
()
Display a list of names of services and their activation status, in the out tab.
Example:
$wnd.xh.services();
state
-
controllerState
Set controller state. The example below sets the controller state to CS_STEPPING, which causes the app to move forward one timestep, and then go into CS_PAUSE state.
Parameters:
-
controllerState
Number5 is currently the only useful value.
Example:
$wnd.xh.state(5);
test
()
Run the Xholon JavaScript API unit tests, using QUnit. The tests are intended to run inside the Furcifer app: http://www.primordion.com/Xholon/gwt/XholonQUnit.html?app=Furcifer&gui=clsc See also the Information page for the Furcifer app (Help > Information).
Example:
$wnd.xh.test();
xpath
-
expression
-
node
Evaluate an XPath 1.0 expression.
Parameters:
-
expression
StringAn XPath 1.0 String expression (ex: "ancestor::HelloWorldSystem/World");
-
node
IXholonAn IXholon node.
Returns:
An IXholon node, or null.
Example:
var node = $wnd.xh.root().first(); // get the Hello node
$wnd.xh.xpath("ancestor::HelloWorldSystem/World", node);
xport
-
formatName
-
node
-
[efParams]
Export a node and its subtree to an external format. Because "export" is a JS keyword, we use "xport" instead.
Parameters:
-
formatName
StringThe name of an external format (ex: "MindMap").
-
node
IXholonAn IXholon node.
-
[efParams]
String optionalA JSON-formatted string containing one or more key/value pairs. To determine the possible parameters for a given external format, look at the efParams object in each ef source file.
Example:
var root = $wnd.xh.root();
$wnd.xh.xport("MindMap", root);
$wnd.xh.xport("Yaml", root);
$wnd.xh.xport("_other,Newick", root);
$wnd.xh.xport("_xholon,Xhn", root);
$wnd.xh.xport("_d3,CirclePack", root);
$wnd.xh.xport("Graphviz", root, '{"layout":"neato"}');
xports
()
Array
Get an array of external format names.
Returns:
An array of strings. Example: Csv GraphML Graphviz MindMap Yaml _other,ChapNetwork,ChapTree,Newick _xholon,Cd,Csh,Ih,Xhn _d3,CirclePack
Example:
var root = $wnd.xh.root();
var formatNamesArr = $wnd.xh.xports();
for (var i = 0; i < formatNamesArr.length; i++) {
root.println(formatNamesArr[i]);
}