This commit is contained in:
2025-08-28 14:34:18 +02:00
commit 5ff4c53a10
29 changed files with 1705 additions and 0 deletions

42
TP3/EX1/app.js Normal file
View File

@@ -0,0 +1,42 @@
import { getMovies } from './model.js';
const searchInput = document.getElementById('searchInput');
const searchBtn = document.getElementById('searchBtn');
const movieList = document.getElementById('movie-list');
async function search(searchMovie) {
if (searchMovie.trim() === '') {
return;
}
const movies = await getMovies(searchMovie);
renderMovies(movies);
}
function renderMovies(movies) {
movieList.innerHTML = '';
if (movies.length === 0) {
movieList.innerHTML = '<p>Aucun film trouvé.</p>';
return;
}
movies.forEach(movie => {
const movieCard = document.createElement('div');
movieCard.classList.add('movie-card');
movieCard.innerHTML = `
<h3>${movie.Title} (${movie.Year})</h3>
<img src="${movie.Poster !== 'N/A' ? movie.Poster : 'https://via.placeholder.com/200x300.png?text=Pas+d%27image'}" alt="${movie.Title}">
`;
movieList.appendChild(movieCard);
});
}
searchBtn.addEventListener('click', () => {
search(searchInput.value);
});
searchInput.addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
search(searchInput.value);
}
});