Movie Carousel
var movies = ['Interstellar', 'Empire Strikes Back', "Kill Bill", "Wreck it Ralph"];
function MovieElement(movieObject) {
this.domElement = $('<article></article>');
this.header = $('<h1>' + movieObject.Title + '</h1>');
this.director = $('<h3>' + movieObject.Director + '</h3>');
this.image = $('<img src=' + movieObject.Poster + '>');
this.plot = $('<p>' + movieObject.Plot + '</p>');
this.domElement.prepend(this.plot);
this.domElement.prepend(this.image);
this.domElement.prepend(this.director);
this.domElement.prepend(this.header);
console.log(this);
return this.domElement;
};
function addMovieToPage(url) {
$.getJSON(url, function(movie) {
var movieObj = new MovieElement(movie);
$('#movies').append(movieObj);
});
}
window.onload = function(evt) {
console.log('Heyllllloooo');
addMovieToPage('http://www.omdbapi.com/?t=interstellar&y=&plot=short&r=json');
addMovieToPage('http://www.omdbapi.com/?t=empire+strikes+back&y=&plot=short&r=json');
addMovieToPage('http://www.omdbapi.com/?t=mean+girls&y=&plot=short&r=json');
addMovieToPage('http://www.omdbapi.com/?t=almost+famous&y=&plot=short&r=json');
}