Actualiser js/public.js
This commit is contained in:
@@ -6,6 +6,7 @@ let activeStreamingFilter = '';
|
||||
let searchQuery = '';
|
||||
let currentPage = 1;
|
||||
const itemsPerPage = 12;
|
||||
let physicalOnlyFilter = false;
|
||||
|
||||
function getStarsHTML(rating) {
|
||||
const r = parseFloat(rating) || 0;
|
||||
@@ -52,6 +53,17 @@ async function loadPublicData() {
|
||||
const response = await fetch(`${API_URL}?action=get_films`);
|
||||
films = await response.json();
|
||||
generateStreamingSelect();
|
||||
|
||||
// Écouteur pour le filtre physique
|
||||
const physicalCheckbox = document.getElementById('physical-only-checkbox');
|
||||
if (physicalCheckbox) {
|
||||
physicalCheckbox.addEventListener('change', (e) => {
|
||||
physicalOnlyFilter = e.target.checked;
|
||||
currentPage = 1;
|
||||
renderPublicGrid();
|
||||
});
|
||||
}
|
||||
|
||||
renderPublicGrid();
|
||||
} catch (error) {
|
||||
console.error("Erreur de récupération :", error);
|
||||
@@ -101,6 +113,15 @@ function renderPublicGrid() {
|
||||
|
||||
let filtered = films.filter(f => f.type === currentPubTab);
|
||||
|
||||
// FILTRE PHYSIQUE UNIQUENENT
|
||||
if (physicalOnlyFilter) {
|
||||
filtered = filtered.filter(f =>
|
||||
!f.streaming ||
|
||||
f.streaming === 'Disponible en support physique ou Cinéma' ||
|
||||
f.streaming.trim() === ''
|
||||
);
|
||||
}
|
||||
|
||||
if (currentPubTab === 'critique' && activeRatingFilter > 0) {
|
||||
filtered = filtered.filter(f => {
|
||||
const rating = parseFloat(f.rating) || 0;
|
||||
|
||||
Reference in New Issue
Block a user