From: rwldrn Date: Tue, 8 Feb 2011 20:58:30 +0000 (-0500) Subject: [#310] Changes per review X-Git-Tag: v0.3~9^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=5963706770cb08ded76ae4948afda05c8696a502;p=popcorn-js.git [#310] Changes per review --- diff --git a/popcorn.js b/popcorn.js index e8ebee7..0c5b01f 100644 --- a/popcorn.js +++ b/popcorn.js @@ -951,7 +951,7 @@ // Exposes Popcorn to global context global.Popcorn = Popcorn; - + document.addEventListener( "DOMContentLoaded", function () { var videos = document.getElementsByTagName( "video" ); @@ -959,17 +959,18 @@ Popcorn.forEach( videos, function ( iter, key ) { var video = videos[ key ], - hasDataSources = false, + hasDataSources = false, dataSources, dataTemp, dataType, parserFn, popcornVideo; - - // Ensure that the DOM has an id, satisfies #310 + + // Ensure that the DOM has an id if ( !video.id ) { + video.id = Popcorn.guid( "__popcorn" ); + } - // Ensure we're looking at a dom node and that it has an id - // otherwise Popcorn won't be able to find the video element - if ( video.nodeType && video.nodeType === 1 && video.id ) { + // Ensure we're looking at a dom node + if ( video.nodeType && video.nodeType === 1 ) { popcornVideo = Popcorn( "#" + video.id ); @@ -982,17 +983,17 @@ dataTemp = source.split( ":" ); dataType = dataTemp[0]; - + if ( dataTemp.length === 1 ) { - + dataTemp = source.split( "." ); - + dataType = dataTemp[ dataTemp.length - 1 ]; - + } - + dataType = dataType.toUpperCase(); - + parserFn = "parse" + dataType; // If the video has data sources and the correct parser is registered, continue to load