[#1222] Updated XML parser so it doesn't copy ids from its manifests

This commit is contained in:
David Seifried 2012-07-23 11:12:50 -04:00
Родитель 3c2fcfbbd9
Коммит 8f44ce1993
2 изменённых файлов: 19 добавлений и 34 удалений

Просмотреть файл

@ -41,7 +41,8 @@
for ( var i = 0, nal = nodeAttributes.length; i < nal; i++ ) { for ( var i = 0, nal = nodeAttributes.length; i < nal; i++ ) {
var key = nodeAttributes.item(i).nodeName, var key = nodeAttributes.item(i).nodeName,
data = nodeAttributes.item(i).nodeValue; data = nodeAttributes.item(i).nodeValue,
manifestItem = manifestData[ data ];
// converts in into start // converts in into start
if (key === "in") { if (key === "in") {
@ -51,7 +52,13 @@
returnObject.end = toSeconds( data ); returnObject.end = toSeconds( data );
// this is where ids in the manifest are linked // this is where ids in the manifest are linked
} else if ( key === "resourceid" ) { } else if ( key === "resourceid" ) {
Popcorn.extend( returnObject, manifestData[data] ); for ( var item in manifestItem ) {
if ( manifestItem.hasOwnProperty( item ) ) {
if ( !returnObject[ item ] && item !== "id" ) {
returnObject[ item ] = manifestItem[ item ];
}
}
}
// everything else // everything else
} else { } else {
returnObject[key] = data; returnObject[key] = data;

Просмотреть файл

@ -1,54 +1,32 @@
asyncTest( "Popcorn 0.1 XML Parser Plugin", function () { asyncTest( "Popcorn 0.1 XML Parser Plugin", 7, function () {
var expects = 7, var poppercorn = Popcorn( "#video" );
count = 0,
interval,
poppercorn = Popcorn( "#video" );
function plus() {
if ( ++count === expects ) {
start();
}
}
expect(expects);
Popcorn.plugin( "parserTest1", { Popcorn.plugin( "parserTest1", {
start: function ( event, options ) { start: function ( event, options ) {
ok( options.item2 === "item2", "parserTest1 has data directly from manifest" ); ok( options.item2 === "item2", "parserTest1 has data directly from manifest" );
plus();
ok( options.item3 === "item3", "parserTest1 has cascading data from manifest" ); ok( options.item3 === "item3", "parserTest1 has cascading data from manifest" );
plus(); }
},
end: function ( event, options ) {}
}); });
Popcorn.plugin( "parserTest2", { Popcorn.plugin( "parserTest2", {
start: function ( event, options ) { start: function ( event, options ) {
ok( options.text === "item4", "parserTest2 has text data" ); ok( options.text === "item4", "parserTest2 has text data" );
plus();
ok( options.item1 === "item1", "parserTest2 has cascading data from parent" ); ok( options.item1 === "item1", "parserTest2 has cascading data from parent" );
plus(); }
},
end: function ( event, options ) {}
}); });
Popcorn.plugin( "parserTest3", { Popcorn.plugin( "parserTest3", {
start: function ( event, options ) { start: function ( event, options ) {
ok( options.item1 === "item1", "parserTest3 has cascading data from parent" ); ok( options.item1 === "item1", "parserTest3 has cascading data from parent" );
plus();
ok( options.item2 === "item2", "parserTest3 has data directly from manifest" ); ok( options.item2 === "item2", "parserTest3 has data directly from manifest" );
plus();
ok( options.item3 === "item3", "parserTest3 has cascading data from manifest" ); ok( options.item3 === "item3", "parserTest3 has cascading data from manifest" );
plus(); start();
}, }
end: function ( event, options ) {}
}); });
poppercorn.parseXML( "data/unit.XML", function() { poppercorn.parseXML( "data/unit.XML", function() {
poppercorn.currentTime(5).play(); poppercorn.play( 5 );
}); poppercorn.mute();
});
}); });