# Graph Gear Javascript API Vague Specification.

You can interact with a graphgear object over javascript in a nuber of interesting ways. These functions are listed in (and can be included from) source/graphgear.js

Setting Properties over javascript:

You can set most of the basic graph properties over javascript, a function like:
`

    	function setPropertyToValue(value) {
    		 flashMovie = document.getElementById("graphgear");
    		 flashMovie.changeProperty("propertyname", value);
    	}

`
Will set the value of propertyname to the passed value for the graphgear object with id="graphgear", the list of these properties is below:

idealSegmentLength, DeltaLimit, BOUNCE, SPRINGK, REPELK, RESISTANCE, MASS, GRAVITY, STOPVEL, STOPACC, STOPRENDER

You can also receive updates of node interaction (click interaction) in javascript with the function nodeNotify, for example:
`

    	function nodeNotify(nodeIdString) {
    		if(nodeIdString == "n1") {
    			document.getElementById("infospace").innerHTML = "somehtml";
    		}
    	}

`

As you can see, nodeNotify is a callback function that receives the node ID as its value. Here we check to see if this nodeIdString is equal to a certain id (n1), and if it is than we set the innerHTML value of some element "infospace" to "somehtml". The exact function you create can be fairly flexible, but it needs to be named nodeNotify and take a string as a parameter.

We also have two javascript functions that deal with changing the xml value, either by passing a reference to a new value or reading some dynamic field (like a textarea) for it's contents:

`

    	function jsSwitchXML(urlString) {
    		flashMovie = document.getElementById("graphgear");
    		flashMovie.switchXML(urlString);
    	}

`
`

    	function jsLiveXML(newXMLString) {
    		flashMovie = document.getElementById("graphgear");
    		flashMovie.liveXML(newXMLString);
    	}

`

The important bit is that jsLiveXML takes a string representation of some xml, and jsSwitchXML takes a urlString representing the location of an xml file.

You can also add nodes over javascript (but not remove them - yet).

`

    	function addNode(jId,jNodeType,jNodeCluster,jNodeText,jLinkValue,jImageValue,
    			 jScaleValue,jTextColor,jBackgroundColor,jEdgeId,jTarget,jLabel,jLabelColor) {
    		flashMovie = document.getElementById("graphgear");
    		flashMovie.jsAddNode(jId,jNodeType,jNodeCluster,jNodeText,jLinkValue,jImageValue,
    				     jScaleValue,jTextColor,jBackgroundColor,jEdgeId,jTarget,jLabel,jLabelColor);
    	}

`

Where there properties are the id, the type of node, the cluster, the node text, the link url, the image url, the scale value, the text color, the background color, the edge id, the target node (to connect this new node to), the edge label and the edge label color (see the graphxmlfile for more information)

That's it for now.