*/
end: function(event, options){
options._container.style.display = "none";
+ },
+ _teardown: function( options ) {
+ document.getElementById( options.target ).removeChild( options._container );
}
};
})());
test("Popcorn attribution Plugin", function () {
var popped = Popcorn("#video"),
- expects = 7,
+ expects = 8,
count = 0,
+ setupId,
attributiondiv = document.getElementById('attribdiv');
expect(expects);
popped.attribution({
start: 0, // seconds
- end: 5, // seconds
+ end: 0.5, // seconds
nameofwork: "A Shared Culture",
copyrightholder:"Jesse Dylan",
license: "CC-BY-N6",
target: 'attribdiv'
} )
.attribution({
- start: 3, // seconds
- end: 10, // seconds
+ start: 0.5, // seconds
+ end: 1, // seconds
nameofwork: "Internet",
nameofworkurl:"http://www.archive.org/details/CC1232_internet",
copyrightholder:"The Computer Chronicles",
} )
.volume(0);
- popped.exec( 1, function() {
+ setupId = popped.getLastTrackEventId();
+
+ popped.exec( 0, function() {
equals ( attributiondiv.childElementCount, 2, "attributiondiv now has two inner elements" );
plus();
equals (attributiondiv.children[0].style.display , "inline", "attribution is visible on the page" );
plus();
});
- popped.exec( 4, function() {
+ popped.exec( 0.5, function() {
equals (attributiondiv.children[1].style.display , "inline", "second attribution is visible on the page" );
plus();
});
- popped.exec( 11, function() {
- equals (attributiondiv.children[1].style.display , "none", "second attribution is no longer visible on the page" );
+ popped.exec( 1, function() {
+ equals(attributiondiv.children[1].style.display , "none", "second attribution is no longer visible on the page" );
plus();
- equals (attributiondiv.children[0].style.display , "none", "first attribution is no longer visible on the page" );
+ equals(attributiondiv.children[0].style.display , "none", "first attribution is no longer visible on the page" );
+ plus();
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !attributiondiv.children[1], "removed attribution was properly destroyed" );
plus();
});
*/
end: function( event, options ){
containerDiv.style.display = "none";
+ },
+ _teardown: function( options ) {
+ document.getElementById( options.target ).removeChild( containerDiv );
}
};
},
test("Popcorn Flickr Plugin", function () {
var popped = Popcorn("#video"),
- expects = 7,
+ expects = 8,
count = 0,
+ setupId,
flickrdiv = document.getElementById('flickrdiv');
expect( expects );
plus();
popped.flickr({
- start: 1, // seconds
- end: 3, // seconds
+ start: 0, // seconds
+ end: 1, // seconds
userid: '35034346917@N01',
numberofimages: '1',
target: 'flickrdiv'
} )
.flickr({
- start: 4, // seconds
- end: 7, // seconds
+ start: 1, // seconds
+ end: 2, // seconds
username: 'AniaSob',
apikey: 'd1d249260dd1673ec8810c8ce5150ae1',
numberofimages: '1',
target: 'flickrdiv'
- } );;
+ });
- popped.exec( 2, function() {
+ setupId = popped.getLastTrackEventId();
+
+ popped.exec( 0.5, function() {
ok( /display: inline;/.test( flickrdiv.innerHTML ), "Div contents are displayed" );
plus();
ok( /img/.test( flickrdiv.innerHTML ), "An image exists" );
plus();
});
- popped.exec( 5, function() {
+ popped.exec( 1.5, function() {
ok( /display: inline;/.test( flickrdiv.innerHTML ), "Div contents are displayed" );
plus();
ok( /img/.test( flickrdiv.innerHTML ), "An image exists" );
plus();
});
- popped.exec( 7, function() {
+ popped.exec( 2, function() {
ok( /display: none;/.test( flickrdiv.innerHTML ), "Div contents are hidden again" );
plus();
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !flickrdiv.children[1], "removed flickr was properly destroyed" );
+ plus();
});
- popped.volume(0);
- popped.play();
+ popped.volume(0).play();
});
*/
end: function(event, options){
options._container.style.display = "none";
+ },
+ _teardown: function( options ) {
+ document.getElementById( options.target ).removeChild( options._container );
}
-
});
-})( Popcorn );
\ No newline at end of file
+})( Popcorn );
test("Popcorn Footnote Plugin", function () {
var popped = Popcorn("#video"),
- expects = 7,
+ expects = 8,
count = 0,
+ setupId,
footnotediv = document.getElementById('footnotediv');
expect(expects);
popped.footnote({
start: 0, // seconds
- end: 2, // seconds
+ end: 1, // seconds
text: 'This video made exclusively for drumbeat.org',
target: 'footnotediv'
- } )
+ })
.footnote({
- start: 2, // seconds
- end: 4, // seconds
+ start: 1, // seconds
+ end: 2, // seconds
text: 'Visit webmademovies.org for more details',
target: 'footnotediv'
- } )
- .volume(0);
+ });
- popped.exec( 1, function() {
+ setupId = popped.getLastTrackEventId();
+
+ popped.exec( 0, function() {
equals ( footnotediv.childElementCount, 2, "footnotediv now has two inner elements" );
plus();
equals (footnotediv.children[0].innerHTML , "This video made exclusively for drumbeat.org", "footnote displaing correct information" );
plus();
});
- popped.exec( 3, function() {
+ popped.exec( 1, function() {
equals (footnotediv.children[1].style.display , "inline", "second footnote is visible on the page" );
plus();
});
- popped.exec( 5, function() {
+ popped.exec( 2, function() {
ok (footnotediv.children[1].style.display === 'none' && footnotediv.children[0].style.display === 'none', "footnote are no longer vidible on the page" );
plus();
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !footnotediv.children[1], "removed footnote was properly destroyed" );
+ plus();
});
- popped.play();
+ popped.play().volume(0);
});
*/
end: function(event, options){
newdiv.setAttribute( "style", "display:none" );
+ },
+ _teardown: function( options ) {
+ document.getElementById( options.target ).removeChild( newdiv );
}
};
},
test("Popcorn Google Feed Plugin", function () {
var popped = Popcorn("#video"),
- expects = 10,
+ expects = 11,
+ setupId,
count = 0;
expect(expects);
plus();
popped.googlefeed({
- start: 0, // seconds
- end: 5, // seconds
- target: "feed",
- url: "http://zenit.senecac.on.ca/~chris.tyler/planet/rss20.xml",
- title: "Planet Feed",
- orientation: "Vertical"
- } )
- .googlefeed({
- start: 0, // seconds
- end: 5, // seconds
- target: "feed1",
- url: "http://blog.pikimal.com/geek/feed/",
- title: "pikiGeek",
- orientation: "Horizontal"
- } )
- .volume(0);
+ start: 0, // seconds
+ end: 1, // seconds
+ target: "feed",
+ url: "http://zenit.senecac.on.ca/~chris.tyler/planet/rss20.xml",
+ title: "Planet Feed",
+ orientation: "Vertical"
+ })
+ .googlefeed({
+ start: 0, // seconds
+ end: 2, // seconds
+ target: "feed1",
+ url: "http://blog.pikimal.com/geek/feed/",
+ title: "pikiGeek",
+ orientation: "Horizontal"
+ })
+ .volume(0);
+
+ setupId = popped.getLastTrackEventId();
+ popped.exec( 0, function() {
+ ok(google.load, "Google Feed is available");
+ plus();
+ ok(GFdynamicFeedControl, "Dynamic Feed Control Available");
+ plus();
+ ok (document.getElementById('_feed1'), "First feed is on the page" );
+ plus();
+ equals (document.getElementById('_feed1').offsetParent.id, "feed", "First feed is inside the 'feed' div" );
+ plus();
+ });
popped.exec( 1, function() {
- ok(google.load, "Google Feed is available");
- plus();
- ok(GFdynamicFeedControl, "Dynamic Feed Control Available");
- plus();
- ok (document.getElementById('_feed1'), "First feed is on the page" );
- plus();
- equals (document.getElementById('_feed1').offsetParent.id, "feed", "First feed is inside the 'feed' div" );
- plus();
+ ok (document.getElementById('_feed2'), "Second feed is on the page" );
+ plus();
+ equals (document.getElementById('_feed2').offsetParent.id, "feed1", "Second feed is inside the 'feed2' div" );
+ plus();
});
popped.exec( 2, function() {
- ok (document.getElementById('_feed2'), "Second feed is on the page" );
- plus();
- equals (document.getElementById('_feed2').offsetParent.id, "feed1", "Second feed is inside the 'feed2' div" );
- plus();
- });
- popped.exec( 6, function() {
- ok (document.getElementById('_feed2').style.display === "none" &&
- document.getElementById('_feed1').style.display === "none", "Both feeds are no lnger visible" );
- plus();
+ ok (document.getElementById('_feed2').style.display === "none" &&
+ document.getElementById('_feed1').style.display === "none", "Both feeds are no lnger visible" );
+ plus();
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !document.getElementById('feed1').children[0], "removed footnote was properly destroyed" );
+ plus();
});
popped.play();
ok (document.getElementById('actualmap2').style.display === "none" &&
document.getElementById('actualmap1').style.display === "none", "Both maps are no longer visible" );
plus();
- popped.pause();
-
- popped.removeTrackEvent( setupId );
+ popped.pause().removeTrackEvent( setupId );
ok( !document.getElementById('actualmap3'), "removed map was properly destroyed" );
plus();
}
options.container = document.createElement( 'div' );
+ var container = document.createElement( 'div' );
if ( document.getElementById( options.target ) ) {
document.getElementById( options.target ).appendChild( options.container );
+ options.container.appendChild( container );
}
var readyCheck = setInterval(function() {
if ( !scriptLoaded ) {
return;
}
- clearInterval(readyCheck);
+ clearInterval( readyCheck );
- var newsShow = new google.elements.NewsShow( options.container, {
+ options.newsShow = new google.elements.NewsShow( container, {
format : "300x250",
queryList : [
{ q: options.topic || "Top Stories" }
*/
end: function( event, options ){
options.container.setAttribute( 'style', 'display:none' );
+ },
+ _teardown: function( options ) {
+ // google news does not like this, throws an error "a is null"
+ // doesn't hurt popcorn, and only happens once
+ document.getElementById( options.target ).removeChild( options.container );
+ options.newsShow = null;
}
-
});
})( Popcorn );
test( "Popcorn google news Plugin", function () {
var popped = Popcorn( "#video" ),
- expects = 7,
+ expects = 8,
count = 0,
+ setupId,
googlenewsdiv = document.getElementById( "googlenewsdiv" );
expect(expects);
popped.googlenews({
start: 0, // seconds
- end: 5, // seconds
+ end: 1, // seconds
topic: "Oil Spill",
target: "googlenewsdiv"
})
.googlenews({
- start: 3, // seconds
- end: 10, // seconds
+ start: 1, // seconds
+ end: 2, // seconds
topic: "Village Telco",
target: "googlenewsdiv"
})
.volume( 0 );
+
+ setupId = popped.getLastTrackEventId();
- popped.exec( 1, function() {
+ popped.exec( 0, function() {
equals( googlenewsdiv.childElementCount, 2, "googlenewsdiv now has two inner elements" );
plus();
equals( googlenewsdiv.children[0].style.display , "inline", "first googlenews is visible on the page" );
plus();
});
- popped.exec( 4, function() {
+ popped.exec( 1, function() {
equals( googlenewsdiv.children[1].style.display , "inline", "second googlenews is visible on the page" );
plus();
});
- popped.exec( 11, function() {
+ popped.exec( 2, function() {
equals( googlenewsdiv.children[1].style.display , "none", "second googlenews is no longer visible on the page" );
plus();
equals( googlenewsdiv.children[0].style.display , "none", "first googlenews is no longer visible on the page" );
plus();
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !googlenewsdiv.children[1], "removed google news was properly destroyed" );
+ plus();
});
popped.play();
-});
\ No newline at end of file
+});
*/
end: function( event, options ) {
options.link.style.display = "none";
+ },
+ _teardown: function( options ) {
+ document.getElementById( options.target ).removeChild( options.link );
}
-
});
})( Popcorn );
test("Popcorn Image Plugin", function () {
var popped = Popcorn("#video"),
- expects = 5,
+ expects = 6,
count = 0,
+ setupId,
imagediv = document.getElementById('imagediv');
expect( expects );
target: 'imagediv'
});
+ setupId = popped.getLastTrackEventId();
+
popped.exec( 2, function() {
- ok( /display: block;/.test( imagediv.innerHTML ), "Div contents are displayed" );
- plus();
- ok( /img/.test( imagediv.innerHTML ), "An image exists" );
- plus();
+ ok( /display: block;/.test( imagediv.innerHTML ), "Div contents are displayed" );
+ plus();
+ ok( /img/.test( imagediv.innerHTML ), "An image exists" );
+ plus();
});
popped.exec( 4, function() {
- ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" );
- plus();
+ ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" );
+ plus();
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !imagediv.children[0], "removed image was properly destroyed" );
+ plus();
});
popped.volume(0).play();
(function (Popcorn) {
- var _artists = [],
+ var _artists = {},
lastFMcallback = function(data){
if (data.artist) {
- var htmlString = '<h3>'+data.artist.name+'</h3>';
+ var htmlString = "";
+
+ htmlString = '<h3>'+data.artist.name+'</h3>';
htmlString += '<a href="'+data.artist.url+'" target="_blank" style="float:left;margin:0 10px 0 0;"><img src="'+ data.artist.image[2]['#text'] +'" alt=""></a>';
htmlString += '<p>'+ data.artist.bio.summary +'</p>';
htmlString += '<hr /><p><h4>Tags</h4><ul>';
htmlString += '</ul></p>';
- _artists[data.artist.name.toLowerCase()] = htmlString;
+ _artists[data.artist.name.toLowerCase()].htmlString = htmlString;
}
};
if(!_artists[options.artist]) {
- _artists[options.artist] = "Unknown Artist";
+ _artists[options.artist] = {
+ count: 0,
+ htmlString: "Unknown Artist"
+ };
Popcorn.getJSONP("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist="+ options.artist +"&api_key="+options.apikey+"&format=json&callback=lastFMcallback", lastFMcallback, false );
-
}
+ _artists[options.artist].count++;
},
/**
* options variable
*/
start: function( event, options ) {
- options._container.innerHTML = _artists[options.artist];
+ options._container.innerHTML = _artists[options.artist].htmlString;
options._container.style.display = "inline";
},
/**
end: function( event, options ) {
options._container.style.display = "none";
options._container.innerHTML = "";
+ },
+ _teardown: function( options ) {
+ // cleaning possible reference to _artist array;
+ --_artists[ options.artist ].count || delete _artists[ options.artist ];
+ document.getElementById( options.target ).removeChild( options._container );
}
};
})());
plugin. Please do not use it for other purposes.
*/
var popped = Popcorn("#video"),
- expects = 8,
+ expects = 9,
count = 0,
+ setupId,
lastfmdiv = document.getElementById('lastfmdiv');
expect( expects );
apikey: '30ac38340e8be75f9268727cb4526b3d'
});
+ setupId = popped.getLastTrackEventId();
+
popped.exec( 2, function() {
equals ( lastfmdiv.childElementCount, 3, "lastfmdiv now has three inner elements" );
plus();
popped.exec( 5, function() {
equals (lastfmdiv.children[2].innerHTML , "Unknown Artist", "Artist information could not be found" );
plus();
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !lastfmdiv.children[2], "removed artist was properly destroyed" );
+ plus();
});
popped.volume(0).play();
end: function( event, options ) {
document.getElementById( options.target ).innerHTML = '';
+ },
+ _teardown: function( options ) {
+ getData, data, getTemplate, template = null;
}
};
},
if ( map ) {
map.div.style.display = 'none';
}
- }
+ },
+ _teardown: function( options ) {
+ document.getElementById( options.target ).removeChild( newdiv );
+ newdiv = map = centerlonlat = projection = displayProjection = pointLayer = selectControl = popup = null;
+ }
};
},
{
test("Popcorn OpenMap Plugin", function () {
var popped = Popcorn("#video"),
- expects = 12,
- count = 0,
- mapInterval,
- mapInterval2,
- mapInterval3,
- mapInterval4;
+ expects = 13,
+ count = 0,
+ setupId,
+ mapInterval,
+ mapInterval2,
+ mapInterval3,
+ mapInterval4;
expect(expects);
.volume(0)
.play();
+ setupId = popped.getLastTrackEventId();
+
mapInterval = popped.exec( 4, function() {
if( popped.currentTime() > 3 && popped.currentTime() <= 5 ) {
ok(OpenLayers, "OpenLayers is available");
document.getElementById('actualmap1').style.display === "none", "All three maps are no longer visible" );
plus();
clearInterval( mapInterval4 );
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !document.getElementById('actualmap3'), "removed map was properly destroyed" );
+ plus();
}
} );
-} );
\ No newline at end of file
+} );
// PLUGIN: tagthisperson
(function (Popcorn) {
+
+ var peopleArray = [];
+ // one People object per options.target
+ var People = function() {
+ this.name = "";
+ this.contains = { };
+ this.toString = function() {
+ var r = [];
+ for ( var j in this.contains ) {
+ if ( this.contains.hasOwnProperty( j ) ) {
+ r.push( " " + this.contains[ j ] );
+ }
+ }
+ return r.toString();
+ };
+ };
/**
* tagthisperson popcorn plug-in
*/
Popcorn.plugin( "tagthisperson" , ( function() {
- var peopleArray = [];
- // one People object per options.target
- var People = function() {
- this.name = "";
- this.contains = { };
- this.toString = function() {
- var r = [];
- for ( var j in this.contains ) {
- if ( this.contains.hasOwnProperty( j ) ) {
- r.push( " " + this.contains[ j ] );
- }
- }
- return r.toString();
- };
- };
-
return {
manifest: {
about:{
*/
end: function( event, options ) {
options.container.style.display = "none";
+ },
+ _teardown: function( options ) {
+
+ document.getElementById( options.target ).removeChild( options.container );
}
});
test("Popcorn Twitter Plugin", function () {
var popped = Popcorn("#video"),
- expects = 6,
+ expects = 7,
count = 0,
+ setupId,
twitterdiv = document.getElementById('twitterdiv');
expect( expects );
title: 'Steve Song',
src: '@stevesong',
target: 'twitterdiv',
- } );
+ });
+
+ setupId = popped.getLastTrackEventId();
popped.exec( 1, function() {
ok( /display: inline;/.test( twitterdiv.innerHTML ), "Div contents are displayed" );
popped.exec( 2, function() {
ok( /display: none;/.test( twitterdiv.innerHTML ), "Div contents are hidden again" );
plus();
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !twitterdiv.children[0], "removed twitter was properly destroyed" );
+ plus();
});
popped.play();
end: function(event, options){
// make the iframe invisible
options._iframe.style.display = 'none';
+ },
+ _teardown: function( options ) {
+
+ document.getElementById( options.target ).removeChild( options._iframe );
}
-
});
})( Popcorn );
test("Popcorn Webpage Plugin", function () {
var popped = Popcorn("#video"),
- expects = 10,
+ expects = 11,
count = 0,
+ setupId,
theiFrame = document.getElementsByTagName('iframe');
expect(expects);
})
.volume(0);
+ setupId = popped.getLastTrackEventId();
+
popped.exec( 0, function() {
ok (!!theiFrame[0], "iframe was created" );
plus();
plus();
});
- popped.exec( 2, function() {
- ok (theiFrame[0].style.display === 'none' && theiFrame[1].style.display === 'none', "both iframes are hidden" );
- plus();
- });
-
popped.exec( 1, function() {
ok (!!theiFrame[1], "iframe was created" );
plus();
plus();
});
+ popped.exec( 2, function() {
+ ok (theiFrame[0].style.display === 'none' && theiFrame[1].style.display === 'none', "both iframes are hidden" );
+ plus();
+
+ popped.pause().removeTrackEvent( setupId );
+ ok( !theiFrame[1], "removed webpage was properly destroyed" );
+ plus();
+ });
+
popped.play();
});
document.getElementById( options.target ).removeChild( options._desc );
}
}
-
});
})( Popcorn );
plus();
equals (theArticle.childElementCount, 2, "wikidiv now contains two child elements" );
plus();
- equals (theArticle.childNodes[0].innerHTML, "this is an article", "wikidiv has the right title" );
+ equals (theArticle.children[0].innerHTML, "this is an article", "wikidiv has the right title" );
plus();
- ok (theArticle.childNodes[1].innerHTML !=="", "wikidiv has some content" );
+ ok (theArticle.children[1].innerHTML !=="", "wikidiv has some content" );
plus();
});
plus();
equals (theArticle.childElementCount, 2, "wikidiv now contains two child elements" );
plus();
- ok (theArticle.childNodes[1].innerHTML !== "", "wikidiv has the right content" );
+ ok (theArticle.children[1].innerHTML !== "", "wikidiv has the right content" );
plus();
});
});