<body>
<h1 id="qunit-header">Popcorn tagthisperson Plug-in Demo</h1>
<p> A tag displaying Scott will appear at 0 seconds and disappear at 15 seconds.</p>
- <p> A separate tag displaying Anna Sob will appear at 0 seconds and disappear at 10 seconds. At 5 seconds Scott will be appended to this tag.</p>
+ <p> A separate tag displaying Anna Sob with an image will appear at 0 seconds and disappear at 10 seconds. At 5 seconds Scott will be appended to this tag.</p>
<div>
<video id='video'
controls preload='none'
/**
* tagthisperson popcorn plug-in
* Adds people's names to an element on the page.
- * Options parameter will need a start, end, target and person.
+ * Options parameter will need a start, end, target, image and person.
* Start is the time that you want this plug-in to execute
* End is the time that you want this plug-in to stop executing
* Person is the name of the person who you want to tag
+ * Image is the url to the image of the person - optional
* Target is the id of the document element that the text needs to be
* attached to, this target element must exist on the DOM
*
} )
*
*/
- Popcorn.plugin( "tagthisperson" , (function(){
+ Popcorn.plugin( "tagthisperson" , ( function() {
var peopleArray = [];
// one People object per options.target
- var People = function(){
+ var People = function() {
this.name = "";
- this.contains = {};
+ this.contains = { };
this.toString = function() {
var r = [];
for ( var j in this.contains ) {
- if ( this.contains.hasOwnProperty(j) ) {
- r.push( " " + this.contains[j] );
+ if ( this.contains.hasOwnProperty( j ) ) {
+ r.push( " " + this.contains[ j ] );
}
}
return r.toString();
// loop through the existing objects to ensure no duplicates
// the idea here is to have one object per unique options.target
for ( var i = 0; i< peopleArray.length; i++ ) {
- if ( peopleArray[i].name === options.target ) {
+ if ( peopleArray[ i ].name === options.target ) {
options._p = peopleArray[ i ];
exists = true;
break;
options._p.contains[ options.person ] = options.person;
}
//options._p.contains[options.person] = options.person;
- if (document.getElementById( options.target )) {
+ if ( document.getElementById( options.target ) ) {
document.getElementById( options.target ).innerHTML = options._p.toString();
}
},
test("Popcorn tagthisperson Plugin", function () {
- var popped = Popcorn("#video"),
+ var popped = Popcorn( "#video" ),
expects = 7,
count = 0,
interval,
interval2,
interval3,
- tagdiv = document.getElementById('tagdiv');
+ tagdiv = document.getElementById( 'tagdiv' );
expect(expects);
function plus() {
- if ( ++count===expects) {
+ if ( ++count===expects ) {
start();
}
}
stop();
- ok ('tagthisperson' in popped, "tagthisperson is a method of the popped instance");
+ ok ( 'tagthisperson' in popped, "tagthisperson is a method of the popped instance" );
plus();
equals ( tagdiv.innerHTML, "", "initially, there is nothing inside the tagdiv" );
interval = setInterval( function() {
if( popped.currentTime() > 0 && popped.currentTime() <= 5 ) {
- equals (tagdiv.childElementCount, 1, "tagdiv now contains one child elements" );
+ equals ( tagdiv.childElementCount, 1, "tagdiv now contains one child elements" );
plus();
equals ( tagdiv.textContent.trim() , "Anna Sob" ,"tagdiv shows the first tag" );
plus();
}, 2000);
interval3 = setInterval( function() {
- if( popped.currentTime() > 5) {
+ if( popped.currentTime() > 5 ) {
equals ( tagdiv.innerHTML.trim() , "Scott" ,"tagdiv shows the second tag only" );
plus();
clearInterval( interval3 );
}
}, 5000);
interval4 = setInterval( function() {
- if( popped.currentTime() > 10) {
+ if( popped.currentTime() > 10 ) {
equals ( tagdiv.innerHTML , "" ,"tagdiv is now cleared" );
plus();
clearInterval( interval4 );