<script>
document.addEventListener('DOMContentLoaded', function () {
var p = Popcorn('#video')
+ .volume(0)
.play()
.webpage({
id: "webpages-a",
- start: 5, // seconds
- end: 15, // seconds
- src: 'http://www.webmademovies.org',
+ start: 0, // seconds
+ end: 5, // seconds
+ src: 'http://webmademovies.org/',
target: 'webpagediv'
} )
.webpage({
id: "webpages-b",
- start: 20, // seconds
- end: 45, // seconds
+ start: 0, // seconds
+ end: 10, // seconds
src: 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js',
target: 'webpagediv2'
} );
</head>
<body>
<h1 id="qunit-header">Popcorn WebPage Plug-in Demo</h1>
- <p> A Webpage displaying webmademovies.org will appear at 5 seconds and disappear at 15 seconds.</p>
- <p> A Webpage displaying zenit Processing.js wiki will appear at 20 seconds and disappear at 45 seconds.</p>
+ <p> A Webpage displaying webmademovies.org will appear at 0 seconds and disappear at 5 seconds.</p>
+ <p> A Webpage displaying zenit Processing.js wiki will appear at 0 seconds and disappear at 15 seconds.</p>
<div>
<video id='video'
controls preload='none'
*
*/
Popcorn.plugin( "webpage" , (function(){
-
- var exists, iframe, temp;
- iframe = document.createElement( 'iframe' ),
- iframe.setAttribute('width', "100%");
- iframe.setAttribute('height', "100%");
-
-
+
return {
+ manifest: {
+ about:{
+ name: "Popcorn Webpage Plugin",
+ version: "0.1",
+ author: "@annasob",
+ website: "annasob.wordpress.com"
+ },
+ options:{
+ id : {elem:'input', type:'text', label:'Id'},
+ start : {elem:'input', type:'text', label:'In'},
+ end : {elem:'input', type:'text', label:'Out'},
+ src : {elem:'input', type:'text', label:'Src'},
+ target : 'iframe-container'
+ }
+ },
+ _setup : function( options ) {
+ options.target = document.getElementById( options.target );
+ // make an iframe
+ options._iframe = document.createElement( 'iframe' ),
+ options._iframe.setAttribute('width', "100%");
+ options._iframe.setAttribute('height', "100%");
+ options._iframe.id = options.id;
+ options._iframe.src = options.src;
+ options._iframe.style.display = 'none';
+ // add the hidden iframe to the DON
+ options.target.appendChild(options._iframe);
+
+ },
/**
* @member webpage
* The start function will be executed when the currentTime
* options variable
*/
start: function(event, options){
- temp = document.getElementById( options.target );
- iframe.id = options.id;
- iframe.src = options.src;
- temp.appendChild(iframe);
+ // make the iframe visible
+ options._iframe.style.display = 'inline';
},
/**
* @member webpage
* options variable
*/
end: function(event, options){
- temp.removeChild(iframe);
+ // make the iframe invisible
+ options._iframe.style.display = 'none';
}
};
test("Popcorn Webpage Plugin", function () {
var popped = Popcorn("#video"),
- expects = 11,
+ expects = 10,
count = 0,
iframeInterval,
iframeInterval2,
popped.webpage({
id: "webpages-a",
- start: 5, // seconds
- end: 25, // seconds
+ start: 0, // seconds
+ end: 5, // seconds
src: 'http://webmademovies.org',
target: 'webpagediv'
})
.webpage({
id: "webpages-b",
- start: 35, // seconds
- end: 50, // seconds
+ start: 7, // seconds
+ end: 10, // seconds
src: 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js',
target: 'webpagediv'
})
+ .volume(0)
.play();
iframeInterval = setInterval( function() {
- if( popped.currentTime() > 7 && popped.currentTime() <= 25 ) {
+ if( popped.currentTime() > 1 && popped.currentTime() <= 5 ) {
ok (!!theiFrame[0], "iframe was created" );
plus();
- equals (theiFrame.length, 1, "there is only one iframe on the page" );
+ equals (theiFrame.length, 2, "there is only two iframes on the page" );
plus();
- equals (theiFrame[0].id, "webpages-a", "iframe has the id 'webpages-a'" );
+ equals (theiFrame[0].id, "webpages-a", "the first iframe has the id 'webpages-a'" );
plus();
equals (theiFrame[0].src, "http://webmademovies.org/", "iframe has the src 'http://webmademovies.org/'" );
plus();
}, 5000);
iframeInterval2 = setInterval( function() {
- if( popped.currentTime() > 27 && popped.currentTime() < 35 ) {
- equals (theiFrame.length, 0, "the iframe has been removed" );
+ if( popped.currentTime() > 10 ) {
+ ok (theiFrame[0].style.display === 'none' && theiFrame[1].style.display === 'none', "both iframes are hidden" );
plus();
clearInterval( iframeInterval2 );
}
- }, 5000);
+ }, 15000);
iframeInterval3 = setInterval( function() {
- if( popped.currentTime() > 37 && popped.currentTime() <= 50 ) {
- ok (!!theiFrame[0], "iframe was created" );
- plus();
- equals (theiFrame.length, 1, "there is only one iframe on the page" );
+ if( popped.currentTime() > 8 && popped.currentTime() <= 10 ) {
+ ok (!!theiFrame[1], "iframe was created" );
plus();
- equals (theiFrame[0].id, "webpages-b", "iframe has the id 'webpages-b'" );
+ equals (theiFrame[1].id, "webpages-b", "iframe second has the id 'webpages-b'" );
plus();
- equals (theiFrame[0].src,"http://zenit.senecac.on.ca/wiki/index.php/Processing.js", "iframe has the src 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js'" );
+ equals (theiFrame[1].src,"http://zenit.senecac.on.ca/wiki/index.php/Processing.js", "iframe has the src 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js'" );
plus();
clearInterval( iframeInterval3 );
}