Movie-Me-Now/templates/index.html

78 lines
2.6 KiB
HTML
Raw Normal View History

2025-04-02 18:49:04 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Movie Slideshow</title>
<style>
/* Basic styling for slideshow */
#movie-container {
text-align: center;
margin-top: 30px;
}
#movie-poster {
width: 200px;
margin: 20px;
}
.rating-buttons button {
margin: 10px;
padding: 10px 20px;
font-size: 16px;
}
</style>
</head>
<body>
<h1 style="text-align: center;">Rate Movies</h1>
<form id="ratingForm" method="POST" action="/recommend">
<!-- Hidden inputs for movie ratings; one per movie -->
{% for movie in movies %}
<input type="hidden" name="{{ movie.title }}" id="rating-{{ loop.index0 }}" value="not seen">
{% endfor %}
<div id="movie-container">
<img id="movie-poster" src="" alt="Movie Poster">
<h2 id="movie-title"></h2>
<p id="movie-description"></p>
</div>
<div class="rating-buttons" style="text-align: center;">
<button type="button" onclick="recordRating('like')">Like</button>
<button type="button" onclick="recordRating('dislike')">Dislike</button>
<button type="button" onclick="recordRating('not seen')">Not Seen</button>
</div>
</form>
<script>
const movies = {{ movies | tojson }};
let currentIndex = 0;
const posterEl = document.getElementById("movie-poster");
const titleEl = document.getElementById("movie-title");
const descriptionEl = document.getElementById("movie-description");
// Function to display the movie at the given index
function showMovie(index) {
if (index >= movies.length) {
// All movies rated; submit the form
document.getElementById("ratingForm").submit();
return;
}
const movie = movies[index];
posterEl.src = movie.poster;
posterEl.alt = movie.title;
titleEl.textContent = movie.title + " (" + movie.year + ")";
descriptionEl.textContent = movie.description;
}
// Record the rating for the current movie and show the next one
function recordRating(rating) {
// Update the hidden input for the current movie with the chosen rating
document.getElementById("rating-" + currentIndex).value = rating;
currentIndex++;
showMovie(currentIndex);
}
// Initialize the slideshow with the first movie
showMovie(currentIndex);
</script>
</body>
</html>