Skip to content

Commit

Permalink
Update: Enhanced loading times (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangsonww committed May 20, 2024
1 parent d6a9939 commit 97b4d1c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions MovieVerse-Frontend/js/movie-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -997,25 +997,10 @@ async function populateMovieDetails(movie, imdbRating, rtRating, metascore, awar
document.getElementById('movie-rating').innerHTML = ``;
document.title = movie.title + " - Movie Details";

const movieImage = document.getElementById('movie-image');
const movieDescription = document.getElementById('movie-description');
const metascoreElement = metascore ? `<p><strong>Metascore:</strong> <a id="metacritics" href="${metaCriticsLink}" title="Click to search/view on Metacritics" target="_blank">${metascore}</a></p>` : '';
const awardsElement = awards ? `<p><strong>Awards:</strong> ${awards}</p>` : '';

if (movie.poster_path) {
movieImage.src = IMGPATH + movie.poster_path;
movieImage.alt = movie.title;
movieImage.loading = 'lazy';
}
else {
movieImage.style.display = 'none';
const noImageText = document.createElement('h2');
noImageText.textContent = 'Movie Image Not Available';
noImageText.style.textAlign = 'center';
noImageText.style.height = '800px';
document.querySelector('.movie-left').appendChild(noImageText);
}

const overview = movie.overview ? movie.overview : 'No overview available';
const genres = movie.genres.map(genre => genre.name).join(', ');
const releaseDate = movie.release_date ? movie.release_date : 'Release date not available';
Expand Down Expand Up @@ -1293,6 +1278,21 @@ async function populateMovieDetails(movie, imdbRating, rtRating, metascore, awar
mediaContainer.innerHTML = '<p>No media available</p>';
}

const movieImage = document.getElementById('movie-image');
if (movie.poster_path) {
movieImage.src = IMGPATH + movie.poster_path;
movieImage.alt = movie.title;
movieImage.loading = 'lazy';
}
else {
movieImage.style.display = 'none';
const noImageText = document.createElement('h2');
noImageText.textContent = 'Movie Image Not Available';
noImageText.style.textAlign = 'center';
noImageText.style.height = '800px';
document.querySelector('.movie-left').appendChild(noImageText);
}

hideSpinner();
}

Expand Down

0 comments on commit 97b4d1c

Please sign in to comment.