},
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++;
}
};
var si = setInterval(function() {
- if ( !data ) return;
+ if ( !data ) {
+ return;
+ }
clearInterval( si );
strokes = data.gml.tag.drawing.stroke;
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() {
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 );
_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 );