diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..d3c96b5 Binary files /dev/null and b/.DS_Store differ diff --git a/books-images/1984.jpg b/books-images/1984.jpg deleted file mode 100644 index d3b39aa..0000000 Binary files a/books-images/1984.jpg and /dev/null differ diff --git a/books-images/harry-potter-and-the-sorcerer.jpg b/books-images/harry-potter-and-the-sorcerer.jpg deleted file mode 100644 index 05d8a24..0000000 Binary files a/books-images/harry-potter-and-the-sorcerer.jpg and /dev/null differ diff --git a/books-images/moby-dick.jpg b/books-images/moby-dick.jpg deleted file mode 100644 index 20a5ac9..0000000 Binary files a/books-images/moby-dick.jpg and /dev/null differ diff --git a/books-images/pride-and-prejudice.jpg b/books-images/pride-and-prejudice.jpg deleted file mode 100644 index 6460748..0000000 Binary files a/books-images/pride-and-prejudice.jpg and /dev/null differ diff --git a/books-images/the-chronicles-of-narnia.jpg b/books-images/the-chronicles-of-narnia.jpg deleted file mode 100644 index e1848c2..0000000 Binary files a/books-images/the-chronicles-of-narnia.jpg and /dev/null differ diff --git a/books-images/the-great-gatsby.jpg b/books-images/the-great-gatsby.jpg deleted file mode 100644 index 04d0aee..0000000 Binary files a/books-images/the-great-gatsby.jpg and /dev/null differ diff --git a/books-images/the-hobbit.jpg b/books-images/the-hobbit.jpg deleted file mode 100644 index bbf7dde..0000000 Binary files a/books-images/the-hobbit.jpg and /dev/null differ diff --git a/books-images/the-lord-of-the-rings.jpg b/books-images/the-lord-of-the-rings.jpg deleted file mode 100644 index 3823218..0000000 Binary files a/books-images/the-lord-of-the-rings.jpg and /dev/null differ diff --git a/books-images/to-kill-a-mockingbird.jpg b/books-images/to-kill-a-mockingbird.jpg deleted file mode 100644 index 20fadb4..0000000 Binary files a/books-images/to-kill-a-mockingbird.jpg and /dev/null differ diff --git a/books-images/unknown.jpg b/books-images/unknown.jpg deleted file mode 100644 index 3de71e8..0000000 Binary files a/books-images/unknown.jpg and /dev/null differ diff --git a/index.html b/index.html index cf5c31a..a708b00 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,47 @@ + - - Project Library + + Rent a movie + -

Project Library

- + +
+
+

FilmNest

+
+ +
+ +
+

Filter by genre + + + + +

+
+ +
+

Sort by year + + + +

+
+ + + +
+ +
+ + + + \ No newline at end of file diff --git a/movie-images/.DS_Store b/movie-images/.DS_Store new file mode 100644 index 0000000..d53fbaf Binary files /dev/null and b/movie-images/.DS_Store differ diff --git a/movie-images/a-quiet-place.jpg b/movie-images/a-quiet-place.jpg new file mode 100644 index 0000000..bca4b45 Binary files /dev/null and b/movie-images/a-quiet-place.jpg differ diff --git a/movie-images/back-to-future.jpg b/movie-images/back-to-future.jpg new file mode 100644 index 0000000..7bf8137 Binary files /dev/null and b/movie-images/back-to-future.jpg differ diff --git a/movie-images/get-out-movie.jpeg b/movie-images/get-out-movie.jpeg new file mode 100644 index 0000000..0463284 Binary files /dev/null and b/movie-images/get-out-movie.jpeg differ diff --git a/movie-images/guardian-of-galaxy.jpg b/movie-images/guardian-of-galaxy.jpg new file mode 100644 index 0000000..56518c5 Binary files /dev/null and b/movie-images/guardian-of-galaxy.jpg differ diff --git a/movie-images/her.jpeg b/movie-images/her.jpeg new file mode 100644 index 0000000..ba9aa2a Binary files /dev/null and b/movie-images/her.jpeg differ diff --git a/movie-images/inception-movie.jpg b/movie-images/inception-movie.jpg new file mode 100644 index 0000000..8b079fd Binary files /dev/null and b/movie-images/inception-movie.jpg differ diff --git a/movie-images/matrix.jpg b/movie-images/matrix.jpg new file mode 100644 index 0000000..673442f Binary files /dev/null and b/movie-images/matrix.jpg differ diff --git a/movie-images/movie image.webp b/movie-images/movie image.webp new file mode 100644 index 0000000..33bd0ee Binary files /dev/null and b/movie-images/movie image.webp differ diff --git a/movie-images/shaun-of-the-dead.jpg b/movie-images/shaun-of-the-dead.jpg new file mode 100644 index 0000000..388b169 Binary files /dev/null and b/movie-images/shaun-of-the-dead.jpg differ diff --git a/movie-images/the-exorcist.jpg b/movie-images/the-exorcist.jpg new file mode 100644 index 0000000..5a624d6 Binary files /dev/null and b/movie-images/the-exorcist.jpg differ diff --git a/movie-images/the-hangover.jpeg b/movie-images/the-hangover.jpeg new file mode 100644 index 0000000..c52529d Binary files /dev/null and b/movie-images/the-hangover.jpeg differ diff --git a/pull_request_template.md b/pull_request_template.md index d92c89b..e8c6749 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -4,4 +4,4 @@ PS. Don't forget to add it in your readme as well. ## Collaborators Add your collaborators here. Write their GitHub usernames in square brackets. If there's more than one, separate them with a comma, like this: -[github-username-1, github-username-2] +[github-username-1](https://github.com/smily342), [https://github.com/Heleneabrahamsson] diff --git a/recipe-images/baked-chicken.jpg b/recipe-images/baked-chicken.jpg deleted file mode 100644 index b580fdc..0000000 Binary files a/recipe-images/baked-chicken.jpg and /dev/null differ diff --git "a/recipe-images/cheat\342\200\231s-cheesy-focaccia.jpg" "b/recipe-images/cheat\342\200\231s-cheesy-focaccia.jpg" deleted file mode 100644 index 4a6128e..0000000 Binary files "a/recipe-images/cheat\342\200\231s-cheesy-focaccia.jpg" and /dev/null differ diff --git a/recipe-images/chicken-paprikash.jpg b/recipe-images/chicken-paprikash.jpg deleted file mode 100644 index 361e5fe..0000000 Binary files a/recipe-images/chicken-paprikash.jpg and /dev/null differ diff --git a/recipe-images/deep-fried-fish-bones.jpg b/recipe-images/deep-fried-fish-bones.jpg deleted file mode 100644 index d9ed554..0000000 Binary files a/recipe-images/deep-fried-fish-bones.jpg and /dev/null differ diff --git a/recipe-images/fish-dish.jpg b/recipe-images/fish-dish.jpg deleted file mode 100644 index 4166fb7..0000000 Binary files a/recipe-images/fish-dish.jpg and /dev/null differ diff --git a/recipe-images/grilled.jpg b/recipe-images/grilled.jpg deleted file mode 100644 index fe7a433..0000000 Binary files a/recipe-images/grilled.jpg and /dev/null differ diff --git a/recipe-images/individual-vegetarian-lasagnes.jpg b/recipe-images/individual-vegetarian-lasagnes.jpg deleted file mode 100644 index 58fab20..0000000 Binary files a/recipe-images/individual-vegetarian-lasagnes.jpg and /dev/null differ diff --git a/recipe-images/meat.jpg b/recipe-images/meat.jpg deleted file mode 100644 index b1896d9..0000000 Binary files a/recipe-images/meat.jpg and /dev/null differ diff --git a/recipe-images/vegetarian-shepherd's-pie.jpg b/recipe-images/vegetarian-shepherd's-pie.jpg deleted file mode 100644 index a6d811a..0000000 Binary files a/recipe-images/vegetarian-shepherd's-pie.jpg and /dev/null differ diff --git a/recipe-images/vegetarian-stir-fried-garlic-s.jpg b/recipe-images/vegetarian-stir-fried-garlic-s.jpg deleted file mode 100644 index 86babc8..0000000 Binary files a/recipe-images/vegetarian-stir-fried-garlic-s.jpg and /dev/null differ diff --git a/script.js b/script.js index 6a61c06..957fe5a 100644 --- a/script.js +++ b/script.js @@ -1,406 +1,169 @@ -/*Here we have created two different arrays that you can work with if you want. -If you choose to create your own arrays with elements, just make sure that some -of the properties make sense to filter on, and some to sort on.*/ - -const books = [ - { - title: 'The Great Gatsby', - author: 'F. Scott Fitzgerald', - year: 1925, - genre: 'Fiction', - rating: 4.2, - description: - 'A classic novel set in the Roaring Twenties, it explores themes of wealth, love, and the American Dream through the enigmatic Jay Gatsby.', - image: './books-images/the-great-gatsby.jpg' - }, - { - title: 'To Kill a Mockingbird', - author: 'Harper Lee', - year: 1960, - genre: 'Fiction', - rating: 4.5, - description: - 'Set in the American South, this novel tackles issues of racism and injustice through the eyes of young Scout Finch.', - image: './books-images/to-kill-a-mockingbird.jpg' - }, - { - title: '1984', - author: 'George Orwell', - year: 1949, - genre: 'Science Fiction', - rating: 4.4, - description: - 'A dystopian classic that explores totalitarianism and the consequences of a surveillance state in a bleak future.', - image: './books-images/1984.jpg' - }, - { - title: 'Pride and Prejudice', - author: 'Jane Austen', - year: 1813, - genre: 'Fiction', - rating: 4.25, - description: - 'A timeless romance novel that examines societal expectations and the misunderstandings that can arise from pride and prejudice.', - image: './books-images/pride-and-prejudice.jpg' - }, - { - title: 'The Catcher in the Rye', - author: 'J.D. Salinger', - year: 1951, - genre: 'Fiction', - rating: 4, - description: - 'Narrated by the teenage Holden Caulfield, the novel explores themes of alienation and the search for authenticity.', - image: './books-images/unknown.jpg' - }, - { - title: 'The Hobbit', - author: 'J.R.R. Tolkien', - year: 1937, - genre: 'Fantasy', - rating: 4.6, - description: - 'A fantasy adventure novel that follows Bilbo Baggins on a quest to help a group of dwarves reclaim their homeland from a dragon.', - image: './books-images/the-hobbit.jpg' - }, +const movies = [ { - title: "Harry Potter and the Sorcerer's Stone", - author: 'J.K. Rowling', - year: 1997, - genre: 'Fantasy', - rating: 4.7, + title: 'Inception', + director: 'Christopher Nolan', + year: 2010, + genre: 'sci-fi', description: - 'The first book in the beloved Harry Potter series, it introduces readers to the magical world of Hogwarts and the young wizard Harry Potter.', - image: "./books-images/harry-potter-and-the-sorcerer'.jpg" + 'A mind-bending exploration of dreams within dreams, directed by Christopher Nolan.', + image: './movie-images/inception-movie.jpg' }, { - title: 'Moby-Dick', - author: 'Herman Melville', - year: 1851, - genre: 'Adventure', - rating: 4.1, + title: 'Get Out', + director: 'Jordan Peele', + year: 2017, + genre: 'horror', description: - 'An epic tale of obsession, revenge, and the relentless pursuit of the great white whale, Moby Dick.', - image: './books-images/moby-dick.jpg' + 'A social horror film that blends suspense with sharp commentary on race and society.', + image: './movie-images/get-out-movie.jpeg' }, { - title: 'The Lord of the Rings: The Fellowship of the Ring', - author: 'J.R.R. Tolkien', - year: 1954, - genre: 'Fantasy', - rating: 4.55, + title: 'Back to the Future', + director: 'Robert Zemeckis', + year: 1985, + genre: 'sci-fi', description: - 'The first volume of the epic fantasy trilogy follows Frodo Baggins and the Fellowship on their quest to destroy the One Ring.', - image: './books-images/the-lord-of-the-rings.jpg' + 'A classic time-travel adventure with humor, starring Michael J. Fox.', + image: './movie-images/back-to-future.jpg' }, { - title: 'The Shining', - author: 'Stephen King', - year: 1977, - genre: 'Horror', - rating: 4.3, + title: 'The Exorcist', + director: 'William Friedkin', + year: 1973, + genre: 'horror', description: - "A psychological horror novel that tells the story of the Torrance family's terrifying experiences at the haunted Overlook Hotel.", - image: './books-images/unknown.jpg' + 'One of the scariest films of all time, revolving around demonic possession.', + image: './movie-images/the-exorcist.jpg' }, { - title: 'The Chronicles of Narnia: The Lion, the Witch and the Wardrobe', - author: 'C.S. Lewis', - year: 1950, - genre: 'Fantasy', - rating: 4.15, + title: 'The Hangover', + director: 'Todd Phillips', + year: 2009, + genre: 'comedy', description: - 'The first book in the Chronicles of Narnia series, it follows the adventures of children who discover the magical land of Narnia.', - image: './books-images/the-chronicles-of-narnia.jpg' + 'A hilarious tale of a wild night gone wrong, featuring unforgettable misadventures.', + image: './movie-images/the-hangover.jpeg' }, { - title: 'The Da Vinci Code', - author: 'Dan Brown', - year: 2003, - genre: 'Mystery', - rating: 3.8, + title: 'The Matrix', + director: 'Lana Wachowski, Lilly Wachowski', + year: 1999, + genre: 'sci-fi', description: - 'A gripping mystery thriller that follows Harvard symbologist Robert Langdon as he unravels the secrets of the Da Vinci Code.', - image: './books-images/unknown.jpg' + 'A groundbreaking sci-fi action film about reality, artificial intelligence, and rebellion.', + image: './movie-images/matrix.jpg' }, { - title: 'The Alchemist', - author: 'Paulo Coelho', - year: 1988, - genre: 'Fiction', - rating: 4.25, + title: "Shaun of the Dead", + director: 'Edgar Wright', + year: 2004, + genre: 'horror', description: - 'A philosophical novel that tells the story of Santiago, a shepherd boy, on his quest to discover his personal legend.', - image: './books-images/unknown.jpg' + 'A man\'s uneventful life takes a turn when he has to lead his friends and family through a zombie apocalypse.', + image: './movie-images/shaun-of-the-dead.jpg' }, { - title: 'The Hunger Games', - author: 'Suzanne Collins', - year: 2008, - genre: 'Science Fiction', - rating: 4.3, + title: 'A Quiet Place', + director: 'John Krasinski', + year: 2018, + genre: 'horror, sci-fi', description: - "In a dystopian future, Katniss Everdeen becomes a symbol of rebellion when she volunteers to take her sister's place in the brutal Hunger Games.", - image: './books-images/unknown.jpg' + 'A tense, almost silent thriller about surviving in a world where making noise can be deadly.', + image: './movie-images/a-quiet-place.jpg' }, { - title: 'The Girl with the Dragon Tattoo', - author: 'Stieg Larsson', - year: 2005, - genre: 'Mystery', - rating: 4.1, + title: 'Guardians of the Galaxy', + director: 'James Gunn', + year: 2014, + genre: 'sci-fi, comedy', description: - 'A gripping mystery novel featuring investigative journalist Mikael Blomkvist and the enigmatic hacker Lisbeth Salander.', - image: './books-images/unknown.jpg' + 'A fun-filled space adventure with a quirky band of misfits saving the universe.', + image: './movie-images/guardian-of-galaxy.jpg' }, { - title: 'The Road', - author: 'Cormac McCarthy', - year: 2006, - genre: 'Dystopian', - rating: 4, + title: 'Her', + director: 'Spike Jonze', + year: 2013, + genre: 'sci-fi, romance', description: - "Set in a post-apocalyptic world, it follows a father and son's harrowing journey to survive and find safety.", - image: './books-images/unknown.jpg' - }, - { - title: "The Hitchhiker's Guide to the Galaxy", - author: 'Douglas Adams', - year: 1979, - genre: 'Science Fiction', - rating: 4.35, - description: - "A comedic science fiction series that follows the misadventures of Arthur Dent after Earth's destruction.", - image: './books-images/unknown.jpg' - }, - { - title: 'The Giver', - author: 'Lois Lowry', - year: 1993, - genre: 'Dystopian', - rating: 4.12, - description: - 'A dystopian novel set in a seemingly perfect society where young Jonas discovers the dark truth beneath the surface.', - image: './books-images/unknown.jpg' + 'A futuristic love story between a man and an artificial intelligence operating system.', + image: './movie-images/her.jpeg' } -] +]; -const recipes = [ - { - name: 'Individual vegetarian lasagnes', - cuisineType: ['italian'], - ingredients: [ - '1.2 kg cherry tomatoes', - '5 sprigs of fresh thyme', - 'extra virgin olive oil', - '2 shallots', - '2 cloves of garlic', - '500 g baby spinach', - '8-12 fresh or dried lasagne sheets', - '350 g ricotta cheese', - 'WHITE SAUCE', - '600 ml milk', - '25 g unsalted butter', - '2 heaped tablespoons flour', - '150 g vegetarian sharp, mature cheese', - '100 g mozzarella' - ], - source: 'Jamie Oliver', - totalTime: 130, - url: 'http://www.jamieoliver.com/recipes/vegetables-recipes/individual-vegetarian-lasagnes/', - image: './recipe-images/individual-vegetarian-lasagnes.jpg' - }, - { - name: 'Vegetarian Stir-Fried Garlic Scape', - cuisineType: ['Balanced'], - ingredients: [ - '8 oz. garlic scapes', - '3 oz. baby corn', - '3 oz. carrots', - '1 oz. dried shiitake mushrooms', - '1 clove of garlic sliced thinly', - '3 slices of fresh ginger root', - '2 tablespoons vegetable oil', - '1/4 cup shaoxing cooking wine', - '1/4 vegetarian stock or water', - '1 tablespoon light soy sauce', - '1 teaspoon sugar', - '1 teaspoon cornstarch', - '1/4 teaspoon ground white pepper' - ], - source: 'Red Cook', - totalTime: null, - url: 'http://redcook.net/2010/06/16/garlic-scape-an-off-menu-treat/', - image: './recipe-images/vegetarian-stir-fried-garlic-s.jpg' - }, - { - name: 'Cheat’s cheesy focaccia', - cuisineType: ['Italian'], - ingredients: [ - '500g pack bread mix', - '2 tbsp olive oil , plus a little extra for drizzling', - '25g parmesan (or vegetarian alternative), grated', - '75g dolcelatte cheese (or vegetarian alternative)' - ], - source: 'BBC Good Food', - totalTime: 40, - url: 'https://www.bbcgoodfood.com/recipes/cheats-cheesy-focaccia', - image: './recipe-images/cheat’s-cheesy-focaccia.jpg' - }, - { - name: "Vegetarian Shepherd's Pie", - cuisineType: ['Balanced', 'High-Fiber'], - ingredients: [ - '2 tablespoons extra-virgin olive oil', - '1 large onion, finely diced', - '2 carrots, peeled and thinly sliced', - '2 celery stalks, thinly sliced', - '10 ounces cremini mushrooms, trimmed and sliced', - '1 tablespoon tomato paste', - "1 tablespoon vegetarian Worcestershire sauce, such as Annie's Naturals", - '1 dried bay leaf', - '1 cup French green lentils, picked over', - 'Kosher salt and freshly ground pepper', - '1 cup frozen peas', - '2 pounds Yukon Gold potatoes, scrubbed and cut into 1 1/2-inch pieces', - '4 cloves garlic', - '4 tablespoons unsalted butter', - '1/2 cup whole milk, warmed' - ], - source: 'Martha Stewart', - totalTime: 120, - url: 'https://www.marthastewart.com/1535235/vegetarian-shepherds-pie', - image: "./recipe-images/vegetarian-shepherd's-pie.jpg" - }, - { - name: 'Chicken Paprikash', - cuisineType: ['Low-Carb'], - ingredients: [ - '640 grams chicken - drumsticks and thighs ( 3 whole chicken legs cut apart)', - '1/2 teaspoon salt', - '1/4 teaspoon black pepper', - '1 tablespoon butter – cultured unsalted (or olive oil)', - '240 grams onion sliced thin (1 large onion)', - '70 grams Anaheim pepper chopped (1 large pepper)', - '25 grams paprika (about 1/4 cup)', - '1 cup chicken stock', - '1/2 teaspoon salt', - '1/2 cup sour cream', - '1 tablespoon flour – all-purpose' - ], - source: 'No Recipes', - totalTime: 80, - url: 'http://norecipes.com/recipe/chicken-paprikash/', - image: './recipe-images/chicken-paprikash.jpg' - }, - { - name: 'Baked Chicken', - cuisineType: ['american'], - ingredients: [ - '6 bone-in chicken breast halves, or 6 chicken thighs and wings, skin-on', - '1/2 teaspoon coarse salt', - '1/2 teaspoon Mrs. Dash seasoning', - '1/4 teaspoon freshly ground black pepper' - ], - source: 'Martha Stewart', - totalTime: 90, - url: 'http://www.marthastewart.com/318981/baked-chicken', - image: './recipe-images/baked-chicken.jpg' - }, - { - name: 'Deep Fried Fish Bones', - cuisineType: ['south east asian'], - ingredients: ['8 small whiting fish or smelt', '4 cups vegetable oil'], - source: 'Serious Eats', - totalTime: 31, - url: 'http://www.seriouseats.com/recipes/2011/03/deep-fried-fish-bones-recipe.html', - image: './recipe-images/deep-fried-fish-bones.jpg' - }, - { - name: 'Burnt-Scallion Fish', - cuisineType: ['chinese'], - ingredients: [ - '2 bunches scallions', - '8 tbsp. butter', - '2 8-oz. fish filets' - ], - source: 'Saveur', - totalTime: 70, - url: 'http://www.saveur.com/article/Recipes/Burnt-Scallion-Fish', - image: './recipe-images/fish-dish.jpg' - }, - { - name: 'Curry-Crusted Fish', - cuisineType: ['south east asian'], - ingredients: [ - '3 slices bread , about 85g/3oz in total', - '1 lime', - '1.0 tbsp Korma curry paste', - '4 thick white fish fillets' - ], - source: 'BBC Good Food', - totalTime: 80, - url: 'http://www.bbcgoodfood.com/recipes/4717/', - image: './recipe-images/fish-dish.jpg' - }, - { - name: 'Meat Stock', - cuisineType: 'american', - ingredients: [ - '2.5 pounds beef marrow bones', - '1 large onion, quartered', - '2 carrots, sliced', - '1 leek, cleaned and sliced', - '2 celery stalks, sliced', - '2.5 pounds organic beef stew meat, cubed', - '2 tablespoons tomato paste', - '5 cloves garlic', - '2 bay leaves', - '3 sprigs thyme', - '3 sprigs Italian parsley', - '1/2 teaspoon black peppercorns' - ], - source: 'Food52', - totalTime: 60, - url: 'https://food52.com/recipes/3712-meat-stock', - image: './recipe-images/meat.jpg' - }, - { - name: 'Homemade Meat Broth', - cuisineType: 'american', - ingredients: [ - '1 teaspoon salt', - '1 carrot, peeled', - '1 medium onion, peeled', - '2 or 3 celery stalks', - '¼ red or yellow bell pepper, stripped of all its seeds', - '1 small boiling potato, peeled', - '1 ripe, fresh tomato, or 1 canned Italian plum tomato, drained of juice', - '5 pounds assorted pieces of meat and bones (see meat suggestions above), of which no less than 1½ pounds is all meat' - ], - source: 'Cookstr', - totalTime: 60, - url: 'http://www.cookstr.com/recipes/il-brodo-homemade-meat-broth', - image: './recipe-images/meat.jpg' - }, - { - name: 'Spice-Rubbed Grilled Flap Meat (Sirloin Tip) Recipe', - cuisineType: 'south-american', - ingredients: [ - '1 tablespoon whole black peppercorns, toasted', - '1 teaspoon coriander seed, toasted', - '1 teaspoon fennel seed, toasted', - '1 teaspoon cumin pods, toasted', - '1 teaspoon red pepper flakes', - '1/2 teaspoon dried oregano', - '2 medium cloves garlic, minced (about 2 teaspoons)', - '2 tablespoons vegetable or canola oil', - '1 whole flap meat steak, 2 to 2 1/2 pounds', - 'Kosher salt' - ], - source: 'Serious Eats', - totalTime: 240, - url: 'http://www.seriouseats.com/recipes/2012/05/spice-rubbed-grilled-flap-meat-sirloin-tip-recipe.html', - image: './recipe-images/grilled.jpg' +// Function to display movies (generic to handle sorting and filtering) +function displayMovies(movieList) { + const moviesSection = document.getElementById('movies-section'); + moviesSection.innerHTML = ''; // Clear previous movies + + movieList.forEach(movie => { + const movieElement = ` +
+ ${movie.title} +
+

${movie.title}

+

Director: ${movie.director} | Year: ${movie.year}

+

Genre: ${movie.genre}

+

${movie.description}

+
+
`; + moviesSection.innerHTML += movieElement; + }); +} + +// Function to display all movies +function displayAllMovies() { + displayMovies(movies); +} + +// Function to filter and display movies based on genre +function recommendMovieByGenre(genre) { + const filteredMovies = movies.filter(movie => { + const genres = movie.genre.split(',').map(g => g.trim().toLowerCase()); + return genres.includes(genre.toLowerCase()); + }); + + if (filteredMovies.length === 0) { + document.getElementById('movies-section').innerHTML = '

No movies found for the selected genre.

'; + } else { + displayMovies(filteredMovies); } -] +} + +// Sorting functions +function sortMoviesNewToOld() { + const sortedMovies = [...movies].sort((a, b) => b.year - a.year); + displayMovies(sortedMovies); +} + +function sortMoviesOldToNew() { + const sortedMovies = [...movies].sort((a, b) => a.year - b.year); + displayMovies(sortedMovies); +} + +// Variable to track the currently selected genre +let currentGenre = ''; + +// Function to handle genre button click +function handleGenreClick(genre) { + if (currentGenre === genre) { + currentGenre = ''; + displayAllMovies(); + } else { + currentGenre = genre; + recommendMovieByGenre(currentGenre); + } +} + +// Add event listeners for the genre buttons +document.getElementById('sci-fi').addEventListener('click', () => handleGenreClick('sci-fi')); +document.getElementById('horror').addEventListener('click', () => handleGenreClick('horror')); +document.getElementById('comedy').addEventListener('click', () => handleGenreClick('comedy')); +document.getElementById('romance').addEventListener('click', () => handleGenreClick('romance')); + +// Add event listeners for the sorting buttons +document.getElementById('sort-new-to-old').addEventListener('click', sortMoviesNewToOld); +document.getElementById('sort-old-to-new').addEventListener('click', sortMoviesOldToNew); + +// Initially display all movies +displayAllMovies(); diff --git a/style.css b/style.css index e69de29..a40e301 100644 --- a/style.css +++ b/style.css @@ -0,0 +1,86 @@ +body { + text-align: center; + background-color: #EEEEEE; +} + +article { + border: solid 3px #929AAB; + margin-top: 50px; + padding: 20px; + display: flex; +} + +img { + width: 184px; + height: 273px; +} + +.card-content { + display: flex; + flex-direction: column; + justify-content: center; + flex: 1; + margin-left: 50px; + font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; +} + +h1 { + font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; + font-weight: bold; + text-transform: uppercase; + color: #white; + margin-bottom: 150%; +} + +h2 { + font-family: Arial, Helvetica, sans-serif; +} + +button { + cursor: pointer; + margin: 5px; + background-color: #393E46; + color: white; + border: solid 2px #929AAB; + border-radius: 30px +} + +button:hover { + background-color: #929AAB; +} + +.filter { + margin-bottom: 20px; + font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; +} + +.sort { + font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; +} + +.hero { + background-image: url(https://media.istockphoto.com/id/1522056968/photo/happy-girls-watching-a-surprising-movie-in-theatre.webp?a=1&b=1&s=612x612&w=0&k=20&c=vuqdVzunFwJDj13oWRmynZ45j-zDgZyM8BaemwUzxDE=); + background-size: cover; + background-position: center; + height: 350px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + color: white; +} + +@media (min-width:900px) { + h1 { + position: absolute; + top: 10px; + /* Adjusts the distance from the top of the page */ + left: 10px; + /* Adjusts the distance from the left side of the page */ + margin: 25px; + /* Removes default margin for more precise positioning */ + + + } + +} \ No newline at end of file