From: Christopher De Cairos Date: Mon, 6 Jun 2011 15:55:44 +0000 (-0400) Subject: fixed id creation issue, modified html file. X-Git-Tag: v0.7^2~31^2~13 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0f24aaef137ecdbfde2a7da67723fcbf16bd1478;p=popcorn-js.git fixed id creation issue, modified html file. --- diff --git a/plugins/processing/popcorn.processing.html b/plugins/processing/popcorn.processing.html index b8a4d22..8348c6c 100644 --- a/plugins/processing/popcorn.processing.html +++ b/plugins/processing/popcorn.processing.html @@ -15,20 +15,20 @@ end: 5, // seconds control: 'pause', target: 'processing-div', - sketch: 'test.pjs' + sketch: 'test2.pjs' } ) .processing({ // Div with sketch defined here start: 5, // seconds end: 10, // seconds control: 'pause', target: 'processing-div2', - sketch: 'test2.pjs' + sketch: 'test.pjs' } ) .processing({ // Canvas with sketch hard-coded defined start: 10, // seconds end: 15, // seconds control: 'pause', - sketch: 'test.pjs', + sketch: 'test2.pjs', target: 'processing-canvas2', // we don't need a sketch because we are pausing a canvas that is hard coded } ) .processing({ // Div with sketch defined here @@ -38,13 +38,6 @@ sketch: 'test2.pjs', target: 'processing-div2', // Thest mulitple instructions for one sketch - Especially relevant here since the first time we are building a canvas } ) - .processing({ // Div With a sketch defined as a file calling a function within the sketch - start: 20, // seconds - control: 'function', - func: 'switch_status', - sketch: 'test.pjs', - target: 'processing-div3', - } ) }, false); diff --git a/plugins/processing/popcorn.processing.js b/plugins/processing/popcorn.processing.js index c64baf1..94128d2 100644 --- a/plugins/processing/popcorn.processing.js +++ b/plugins/processing/popcorn.processing.js @@ -67,43 +67,34 @@ init = function() { if ( window.Processing ) { - if ( !types[ options.control ] ) { - throw ( "popcorn.processing plug-in ERROR: un-recognized control type '" + options.control + "' must be 'pause' or 'function'" ); - } - if ( options.start >= options.end ) { - throw ( "popcorn.processing plug-in ERROR: invalid start and end pause timings '" + options.start + "' must be less than '" + options.end + "'" ); - } parentTarget = document.getElementById( options.target ); - if ( !parentTarget ) { - throw ( "popcorn.processing plug-in ERROR: Target '" + options.target + "' does not exist." ); - } else { - if ( parentTarget.tagName === "CANVAS" ) { - canvas = parentTarget; - } else if ( parentTarget.tagName === "DIV" ) { - canvas = document.createElement( "canvas" ); - canvas.id = options.target + "Sketch"; - canvas.setAttribute( "data-processing-sources", options.sketch ); - canvas.style.display = "none"; - parentTarget.appendChild( canvas ); - } - Popcorn.xhr({ - url: options.sketch, - dataType: "text", - success: function( responseCode ) { - codeReady = true; - processingCode = responseCode; - } - }); - - createCanvas = function() { - if ( codeReady ) { - processingInstance = new Processing( canvas, processingCode ); - } else { - setTimeout ( createCanvas, 10 ); - } - }; - createCanvas(); + if ( parentTarget.tagName === "CANVAS" ) { + canvas = parentTarget; + } else if ( parentTarget.tagName === "DIV" ) { + canvas = document.createElement( "canvas" ); + // +new Date() is used here to create unique id's for canvas' within the same div. + canvas.id = options.target + "Sketch" + +new Date(); + canvas.setAttribute( "data-processing-sources", options.sketch ); + canvas.style.display = "none"; + parentTarget.appendChild( canvas ); } + Popcorn.xhr({ + url: options.sketch, + dataType: "text", + success: function( responseCode ) { + codeReady = true; + processingCode = responseCode; + } + }); + + createCanvas = function() { + if ( codeReady ) { + processingInstance = new Processing( canvas, processingCode ); + } else { + setTimeout ( createCanvas, 10 ); + } + }; + createCanvas(); } else { !processingLoaded && loadProcessing(); setTimeout( init, 10 );