js mode example cleanups

This commit is contained in:
fjenett
2011-06-18 19:37:00 +00:00
parent adeb692223
commit 87deeaa360
16 changed files with 129 additions and 144 deletions

View File

@@ -7,7 +7,7 @@ window.onload = function () {
function tryFindSketch () {
var sketch = Processing.instances[0];
if ( sketch == undefined )
return setTimeout(tryFindSketch, 200);
sketch.setTree( document.body.parentNode );
setTimeout(tryFindSketch, 200); // retry after 0.2 secs
else
sketch.setTree( document.body.parentNode );
}

View File

@@ -1,5 +1,5 @@
/**
* Renders a simple graph from this documents node tree.
* Renders a simple graph from this documents DOM node tree.
*/
Node tree;
@@ -72,13 +72,15 @@
text( label, x+10, y+3 );
}
// called by JavaScript, sends the root DOM Node
void setTree ( Node root )
{
tree = root;
}
/* explain Node to Processing */
// explain Node to Processing, the attributes described here are part of the DOM Node:
// http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247
interface Node
{
Node[] childNodes;