Skip to content

Commit

Permalink
Update app.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Bello-Barry authored Sep 9, 2024
1 parent 34a48a9 commit 3e1c332
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Importer les fonctions Firebase nécessaires
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.13.1/firebase-app.js";
import { getFirestore, collection, addDoc, getDocs } from "https://www.gstatic.com/firebasejs/10.13.1/firebase-firestore.js";

// Configuration Firebase
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyAWZg09J3DF8-vYjUEMOo_kDANNDwqzWGw",
authDomain: "film2bsk.firebaseapp.com",
Expand All @@ -13,7 +13,7 @@ const firebaseConfig = {
measurementId: "G-SMW65VQX9G"
};

// Initialisation Firebase
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);

Expand Down Expand Up @@ -60,17 +60,14 @@ async function fetchMovies() {
function displayMovies(category = null) {
const movieList = document.getElementById(category ? 'category-movies' : 'movie-list');
movieList.innerHTML = '';

movies.forEach(movie => {
if (!category || movie.category === category) {
const movieElement = document.createElement('div');
movieElement.className = 'movie';
movieElement.innerHTML = `
<h3>${movie.title}</h3>
<p class="category">Catégorie: ${movie.category}</p>
<iframe sandbox="allow-scripts allow-same-origin" width="100%" height="200"
src="https://www.youtube.com/embed/${getYouTubeId(movie.link)}"
frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<iframe sandbox="allow-scripts allow-same-origin" width="100%" height="200" src="https://www.youtube.com/embed/${getYouTubeId(movie.link)}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<p>${movie.description}</p>
`;
movieList.appendChild(movieElement);
Expand All @@ -83,7 +80,6 @@ function updateCategories() {
const categoryList = document.getElementById('category-list');
const categories = [...new Set(movies.map(movie => movie.category))];
categoryList.innerHTML = '';

categories.forEach(category => {
const button = document.createElement('button');
button.className = 'category-button';
Expand Down Expand Up @@ -134,7 +130,7 @@ document.getElementById('add-movie-form').addEventListener('submit', function(e)
this.reset();
});

// Navigation entre les pages
// Navigation
document.querySelectorAll('header a').forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
Expand Down

0 comments on commit 3e1c332

Please sign in to comment.