From: ScottDowne Date: Mon, 16 May 2011 23:28:31 +0000 (-0400) Subject: [#t383] gml linting fixes X-Git-Tag: v0.6~2^2~5^2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=b69aae537a8479858a7ffec4e2beebbba5b9ff07;p=popcorn-js.git [#t383] gml linting fixes --- diff --git a/plugins/gml/popcorn.gml.js b/plugins/gml/popcorn.gml.js index d9ea26b..5491afa 100644 --- a/plugins/gml/popcorn.gml.js +++ b/plugins/gml/popcorn.gml.js @@ -45,19 +45,21 @@ }, seek = function( point ) { - if ( point < onPt ) reset(); + ( point < onPt ) && reset(); while ( onPt <= point ) { - if ( !strokes ) return; + if ( !strokes ) { + return; + } _stroke = strokes[ onStroke ] || strokes; var pt = _stroke.pt[ onPt ]; var p = onPt; - if (x !== null ) drawLine( x, y, pt.x, pt.y ); + x && drawLine( x, y, pt.x, pt.y ); x = pt.x; y = pt.y; - if ( onPt === p ) onPt++; + ( onPt === p ) && onPt++; } }; @@ -76,7 +78,9 @@ var si = setInterval(function() { - if ( !data ) return; + if ( !data ) { + return; + } clearInterval( si ); strokes = data.gml.tag.drawing.stroke; @@ -150,10 +154,7 @@ options.container.style.display = "none"; options.container.setAttribute( "id", "canvas" + options.gmltag ); - if ( document.getElementById( options.target ) ) { - document.getElementById( options.target ).appendChild( options.container ); - } - + document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( options.container ); // makes sure both processing.js and the gml data are loaded var readyCheck = setInterval(function() { @@ -166,8 +167,7 @@ clearInterval( readyCheck ); Popcorn.getJSONP( "http://000000book.com/data/" + options.gmltag + ".json?callback=", function( data ) { - new Processing( options.container, gmlPlayer ); - options.pjsInstance = Processing.getInstanceById( "canvas" + data.id ); + options.pjsInstance = new Processing( options.container, gmlPlayer ); options.pjsInstance.construct( self.media, data, options ); options._running && options.pjsInstance.loop(); }, false ); @@ -198,10 +198,7 @@ _teardown: function( options ) { options.pjsInstance && options.pjsInstance.exit(); - - if ( document.getElementById( options.target ) ) { - document.getElementById( options.target ).removeChild( options.container ); - } + document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options.container ); } }); })( Popcorn );