sample-js-processing-init.js / js
/* * This code searches for all the <script type="application/processing" target="canvasid"> * in your page and loads each script in the target canvas with the proper id. * It is useful to smooth the process of adding Processing code in your page and starting * the Processing.js engine. */ if ( window.addEventListener ) { window.addEventListener("load", function() { var scripts = document.getElementsByTagName("script"); for ( var i = 0; i < scripts.length; i++ ) { if ( scripts[i].type == "application/processing" ) { var src = scripts[i].src, canvas = scripts[i].nextSibling; if ( src && src.indexOf("#") ) { canvas = document.getElementById( src.substr( src.indexOf("#") + 1 ) ); } else { while ( canvas && canvas.nodeName.toUpperCase() != "CANVAS" ) canvas = canvas.nextSibling; } if ( canvas ) { Processing(canvas, scripts[i].text); } } } }, false); }
(C) Æliens 04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.