<script src="../../popcorn.js"></script>
<script src="popcorn.flickr.js"></script>
<script>
- document.addEventListener('DOMContentLoaded', function () {
- var p = Popcorn('#video')
+ document.addEventListener( "DOMContentLoaded", function () {
+
+ var p = Popcorn( "#video" )
.flickr({
- start: 0, // seconds
- end: 5, // seconds
- username: 'AniaSob',
- apikey: 'd1d249260dd1673ec8810c8ce5150ae1',
- target: 'flickrdiv'
- } )
+ // seconds
+ start: 0,
+ // seconds
+ end: 5,
+ username: "AniaSob",
+ apikey: "d1d249260dd1673ec8810c8ce5150ae1",
+ target: "flickrdiv"
+ })
.flickr({
- start: 5, // seconds
- end: 15, // seconds
- userid: '35034346917@N01',
- target: 'flickrdiv'
- } )
+ // seconds
+ start: 5,
+ // seconds
+ end: 15,
+ userid: "35034346917@N01",
+ target: "flickrdiv"
+ })
.flickr({
- start: 20, // seconds
- end: 30, // seconds
- tags: 'georgia',
+ // seconds
+ start: 20,
+ // seconds
+ end: 30,
+ tags: "georgia",
numberofimages: 8,
- target: 'flickrdiv'
- } )
+ target: "flickrdiv"
+ })
.flickr({
- start: 35, // seconds
- end: 45, // seconds
- userid: '35034346917@N01',
- tags: 'georgia',
+ // seconds
+ start: 35,
+ // seconds
+ end: 45,
+ userid: "35034346917@N01",
+ tags: "georgia",
numberofimages: 8,
- target: 'flickrdiv'
- } )
+ target: "flickrdiv"
+ })
.play();
- }, false);
+ }, false );
</script>
</head>
<br />Flickr images tagged 'georgia' will appear at 20 seconds and disappear at 30 seconds.
<br />Flickr images by '35034346917@N01' and tagged 'georgia' will appear at 35 seconds and disappear at 45 seconds.</p>
<div>
- <video id='video'
+ <video id="video"
controls
- width= '250px'
+ width= "250px"
poster="../../test/poster.png">
- <source id='mp4'
+ <source id="mp4"
src="../../test/trailer.mp4"
type='video/mp4; codecs="avc1, mp4a"'>
- <source id='ogv'
+ <source id="ogv"
src="../../test/trailer.ogv"
type='video/ogg; codecs="theora, vorbis"'>
// get the userid from Flickr API by using the username and apikey
var isUserIDReady = function() {
if ( !_userid ) {
+
_uri = "http://api.flickr.com/services/rest/?method=flickr.people.findByUsername&";
_uri += "username=" + options.username + "&api_key=" + options.apikey + "&format=json&jsoncallback=flickr";
Popcorn.xhr.getJSONP( _uri, function(data) {
_userid = data.user.nsid;
getFlickrData();
});
+
} else {
+
setTimeout(function () {
isUserIDReady();
}, 5);
Popcorn.forEach( data.items, function ( item, i ) {
if ( i < _count ) {
+
_link = document.createElement( 'a' );
_link.setAttribute( 'href', item.link );
_link.setAttribute( "target", "_blank" );
_image.setAttribute( 'style', 'border:' + _border + ';padding:' + _padding );
_link.appendChild( _image );
containerDiv.appendChild( _link );
+
} else {
+
return false;
}
});
},
{
about:{
- name: "Popcorn Flickr Plugin",
+ name: "Popcorn Flickr Plugin",
version: "0.2",
- author: "Scott Downe, Steven Weerdenburg, Annasob",
+ author: "Scott Downe, Steven Weerdenburg, Annasob",
website: "http://scottdowne.wordpress.com/"
},
options:{
- start : {elem:'input', type:'number', label:'In'},
- end : {elem:'input', type:'number', label:'Out'},
- userid : {elem:'input', type:'text', label:'UserID'},
- tags : {elem:'input', type:'text', label:'Tags'},
- username : {elem:'input', type:'text', label:'Username'},
- apikey : {elem:'input', type:'text', label:'Api_key'},
- target : 'flickr-container',
- height : {elem:'input', type:'text', label:'Height'},
- width : {elem:'input', type:'text', label:'Width'},
- padding : {elem:'input', type:'text', label:'Padding'},
- border : {elem:'input', type:'text', label:'Border'},
- numberofimages : {elem:'input', type:'text', label:'Number of Images'}
+ start: {
+ elem: "input",
+ type: "number",
+ label: "In"
+ },
+ end: {
+ elem: "input",
+ type: "number",
+ label: "Out"
+ },
+ userid: {
+ elem: "input",
+ type: "text",
+ label: "UserID"
+ },
+ tags: {
+ elem: "input",
+ type: "text",
+ label: "Tags"
+ },
+ username: {
+ elem: "input",
+ type: "text",
+ label: "Username"
+ },
+ apikey: {
+ elem: "input",
+ type: "text",
+ label: "Api_key"
+ },
+ target: "flickr-container",
+ height: {
+ elem: "input",
+ type: "text",
+ label: "Height"
+ },
+ width: {
+ elem: "input",
+ type: "text",
+ label: "Width"
+ },
+ padding: {
+ elem: "input",
+ type: "text",
+ label: "Padding"
+ },
+ border: {
+ elem: "input",
+ type: "text",
+ label: "Border"
+ },
+ numberofimages: {
+ elem: "input",
+ type: "text",
+ label: "Number of Images"
+ }
}
});
})( Popcorn );
test("Popcorn Flickr Plugin", function () {
- var popped = Popcorn("#video"),
+ var popped = Popcorn( "#video" ),
expects = 10,
count = 0,
setupId,
- flickrdiv = document.getElementById('flickrdiv');
+ flickrdiv = document.getElementById( "flickrdiv" );
expect( expects );
function plus() {
- if ( ++count === expects) {
+ if ( ++count === expects ) {
start();
}
}
stop();
- ok('flickr' in popped, "flickr is a method of the popped instance");
+ ok( "flickr" in popped, "flickr is a method of the popped instance" );
plus();
equals ( flickrdiv.innerHTML, "", "initially, there is nothing inside the flickrdiv" );
plus();
popped.flickr({
- start: 0, // seconds
- end: 3, // seconds
- userid: '35034346917@N01',
+ // seconds
+ start: 0,
+ // seconds
+ end: 3,
+ userid: "35034346917@N01",
numberofimages: 1,
- target: 'flickrdiv'
- } )
+ target: "flickrdiv"
+ })
.flickr({
start: 4,
end: 7,
target: "flickrdiv"
})
.flickr({
- start: 8, // seconds
- end: 10, // seconds
- username: 'AniaSob',
- apikey: 'd1d249260dd1673ec8810c8ce5150ae1',
+ // seconds
+ start: 8,
+ // seconds
+ end: 10,
+ username: "AniaSob",
+ apikey: "d1d249260dd1673ec8810c8ce5150ae1",
numberofimages: 1,
- target: 'flickrdiv'
+ target: "flickrdiv"
});
setupId = popped.getLastTrackEventId();
popped.exec( 2, function() {
+
ok( /display: inline;/.test( flickrdiv.innerHTML ), "Div contents are displayed" );
plus();
ok( /img/.test( flickrdiv.innerHTML ), "An image exists" );
});
popped.exec( 5, function() {
+
var numberOfImages = document.getElementById( "flickrdiv" ).childNodes[1].getElementsByTagName( "a" ).length;
ok( /display: inline;/.test( flickrdiv.innerHTML ), "Div contents are displayed" );
});
popped.exec( 11, function() {
+
ok( /display: none;/.test( flickrdiv.innerHTML ), "Div contents are hidden again" );
plus();
popped.pause().removeTrackEvent( setupId );
- ok( !flickrdiv.children[2], "removed flickr was properly destroyed" );
+ ok( !flickrdiv.children[2], "Removed flickr was properly destroyed" );
plus();
});