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
@@ -1,17 +1,20 @@
// wait for document to load ...
window.onload = function () {
tryLinkSketch();
}
// try and find the sketch
function tryLinkSketch() {
var sketchId = "wordDroppings";
var sketch = Processing.getInstanceById(sketchId);
var sketch = Processing.instances[0];
if ( sketch == undefined )
return setTimeout(tryLinkSketch, 200); /*try again later*/
setTimeout(tryLinkSketch, 200); /*try again later*/
else {
initDragDrop(sketch);
}
}
// initialize DnD, add event listeners
function initDragDrop ( sketch ) {
var target = sketch.externals.canvas;
var targetPosition = getElementPosition(target);
@@ -5,8 +5,6 @@
* <div>Drag</div> <div>us</div> <div>to</div> <div>your</div> <div>sketch</div>
* </div>
* <style>.draggables div{display: inline-block;background:white;color: black;padding: 10px;}</style>
* <br />
* (Opera currently not supported …)
*/
color normalColor;
@@ -60,6 +58,9 @@ void draw ()
text( message, cx+7.5, cy+2.5 );
}
// the following events are not part of Processing API. they
// are being called from JavaScript, see ".js" tab
void dragEnter ()
{
currentColor = dragColor;