diff --git a/assets/css/index.css b/assets/css/index.css index 4ae00ac..e008f48 100644 --- a/assets/css/index.css +++ b/assets/css/index.css @@ -16,3 +16,10 @@ justify-content: center; /* Horizontally center the content */ align-items: center; /* Vertically center the content */ } + +/* Hide the default link styling */ +a { + text-decoration: none; /* Remove underline */ + color: inherit; /* Inherit color from parent */ + cursor: pointer; /* Change cursor to pointer */ +} diff --git a/assets/js/api.js b/assets/js/api.js index 720c034..27310fc 100644 --- a/assets/js/api.js +++ b/assets/js/api.js @@ -8,6 +8,26 @@ const options = { }, }; +// Function to perform movie search +// Function to fetch movie data from the API +const searchOptions = { + method: "GET", + headers: { + accept: "application/json", + Authorization: + "Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI4YzNhNGM2NWM0YmIxNjQyYmQxZGIwNDdiMGFiYmMwYyIsInN1YiI6IjY1Njk3ZjVjZWVlMTg2MDBhZTYzNmI0MCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.IwECgYGXPKl2a4YxM9NGuyM-TIDJOXXpJSlaeQz6NL4", + }, +}; + +const singleOptions = { + method: "GET", + headers: { + accept: "application/json", + Authorization: + "Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI4YzNhNGM2NWM0YmIxNjQyYmQxZGIwNDdiMGFiYmMwYyIsInN1YiI6IjY1Njk3ZjVjZWVlMTg2MDBhZTYzNmI0MCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.IwECgYGXPKl2a4YxM9NGuyM-TIDJOXXpJSlaeQz6NL4", + }, +}; + const geTrendingFilms = async () => { try { const response = await fetch( @@ -42,15 +62,6 @@ const getMovies = async (query = null, options = {}) => { } }; -const singleOptions = { - method: "GET", - headers: { - accept: "application/json", - Authorization: - "Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI4YzNhNGM2NWM0YmIxNjQyYmQxZGIwNDdiMGFiYmMwYyIsInN1YiI6IjY1Njk3ZjVjZWVlMTg2MDBhZTYzNmI0MCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.IwECgYGXPKl2a4YxM9NGuyM-TIDJOXXpJSlaeQz6NL4", - }, -}; - // Function to fetch details of a single movie const getMovie = async (movieId) => { try { @@ -103,6 +114,7 @@ const renderMovieDetails = async (movieId) => { `; + // updated content // Append the movie details to the document body document.body.appendChild(rootNode); } catch (error) { @@ -110,11 +122,11 @@ const renderMovieDetails = async (movieId) => { } }; - document.addEventListener("DOMContentLoaded", async () => { // Retrieve the movie ID from the URL parameters const urlParams = new URLSearchParams(window.location.search); const movieId = urlParams.get("id"); + console.log(movieId); if (movieId) { try { @@ -122,13 +134,34 @@ document.addEventListener("DOMContentLoaded", async () => { const singleMovie = await getMovie(movieId); console.log(singleMovie); - // Populate the HTML elements with movie details - document.getElementById("movie-title").textContent = singleMovie.title; - document.getElementById("movie-description").textContent = - singleMovie.overview; - document.getElementById( - "movie-poster" - ).src = `https://media.themoviedb.org/t/p/w600_and_h900_bestv2/${singleMovie.poster_path}`; + // Create a new div to hold the movie details + const movieDetailsDiv = document.createElement("div"); + movieDetailsDiv.classList.add("container", "mx-auto"); + movieDetailsDiv.innerHTML = ` +
${singleMovie.overview}
+${singleMovie.runtime}
+-
-