* @param {Object} options
*
* Example:
- var p = Popcorn('#video')
+ var p = Popcorn("#video")
.wikipedia({
start: 5, // seconds
end: 15, // seconds
- src: 'http://en.wikipedia.org/wiki/Cape_Town',
- target: 'wikidiv'
+ src: "http://en.wikipedia.org/wiki/Cape_Town",
+ target: "wikidiv"
} )
*
*/
},
options:{
start: {
- elem: 'input',
- type: 'text',
- label: 'In'
+ elem: "input",
+ type: "text",
+ label: "In"
},
end: {
- elem: 'input',
- type: 'text',
- label: 'Out'
+ elem: "input",
+ type: "text",
+ label: "Out"
},
lang: {
- elem: 'input',
- type: 'text',
- label: 'Language'
+ elem: "input",
+ type: "text",
+ label: "Language"
},
src: {
- elem: 'input',
- type: 'text',
- label: 'Src'
+ elem: "input",
+ type: "text",
+ label: "Src"
},
title: {
- elem: 'input',
- type: 'text',
- label: 'Title'
+ elem: "input",
+ type: "text",
+ label: "Title"
},
numberofwords: {
- elem: 'input',
- type: 'text',
- label: 'Num Of Words'
+ elem: "input",
+ type: "text",
+ label: "Num Of Words"
},
- target: 'wikipedia-container'
+ target: "wikipedia-container"
}
},
/**
var _text, _guid = Popcorn.guid();
// if the user didn't specify a language default to english
- if ( typeof options.lang === 'undefined' ) {
+ if ( !options.lang ) {
options.lang = "en";
}
// and stores it by appending values to the options object
window[ "wikiCallback" + _guid ] = function ( data ) {
- options._link = document.createElement( 'a' );
- options._link.setAttribute( 'href', options.src );
- options._link.setAttribute( 'target', '_blank' );
+ options._link = document.createElement( "a" );
+ options._link.setAttribute( "href", options.src );
+ options._link.setAttribute( "target", "_blank" );
// add the title of the article to the link
options._link.innerHTML = options.title || data.parse.displaytitle;
// get the content of the wiki article
- options._desc = document.createElement( 'p' );
+ options._desc = document.createElement( "p" );
// get the article text and remove any special characters
- _text = data.parse.text[ "*" ].substr( data.parse.text[ "*" ].indexOf( '<p>' ) );
+ _text = data.parse.text[ "*" ].substr( data.parse.text[ "*" ].indexOf( "<p>" ) );
_text = _text.replace( /((<(.|\n)+?>)|(\((.*?)\) )|(\[(.*?)\]))/g, "" );
options._desc.innerHTML = _text.substr( 0, options.numberofwords ) + " ...";
_teardown: function( options ){
- if ( options._added ) {
- options._link.parentNode && document.getElementById( options.target ).removeChild( options._link );
- options._desc.parentNode && document.getElementById( options.target ).removeChild( options._desc );
- delete options.target;
- }
+ if ( options._added ) {
+ options._link.parentNode && document.getElementById( options.target ).removeChild( options._link );
+ options._desc.parentNode && document.getElementById( options.target ).removeChild( options._desc );
+ delete options.target;
+ }
}
});
var popped = Popcorn( "#video" ),
expects = 11,
count = 0,
- theArticle = document.getElementById( 'wikidiv' );
+ theArticle = document.getElementById( "wikidiv" );
expect( expects );
stop();
- ok ( 'wikipedia' in popped, "wikipedia is a mehtod of the popped instance" );
+ ok ( "wikipedia" in popped, "wikipedia is a mehtod of the popped instance" );
plus();
equals ( theArticle.innerHTML, "", "initially, there is nothing in the wikidiv" );
popped.wikipedia({
start: 1, // seconds
end: 3, // seconds
- src: 'http://en.wikipedia.org/wiki/Cape_Town',
+ src: "http://en.wikipedia.org/wiki/Cape_Town",
title: "this is an article",
- target: 'wikidiv'
+ target: "wikidiv"
} )
.wikipedia({
start: 4, // seconds
end: 5, // seconds
- src: 'http://en.wikipedia.org/wiki/S%C3%A3o_Paulo',
- target: 'wikidiv'
+ src: "http://en.wikipedia.org/wiki/S%C3%A3o_Paulo",
+ target: "wikidiv"
} )
.volume(0)
.play();