|
|
|
@ -111,6 +111,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
visibleCards.forEach(card => container.appendChild(card));
|
|
|
|
|
paginateCards();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -147,4 +148,66 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
document.getElementById('search-input').addEventListener('input', applyFilters);
|
|
|
|
|
document.getElementById('rarete-filter').addEventListener('change', applyFilters);
|
|
|
|
|
document.getElementById('sort-select').addEventListener('change', applyFilters);
|
|
|
|
|
|
|
|
|
|
/***** Partie Pagination ******/
|
|
|
|
|
|
|
|
|
|
const ITEMS_PER_PAGE = 10;
|
|
|
|
|
let currentPage = 1;
|
|
|
|
|
|
|
|
|
|
function paginateCards() {
|
|
|
|
|
const allCards = Array.from(document.querySelectorAll('#collection-container .emoji-card'));
|
|
|
|
|
const container = document.getElementById('collection-container');
|
|
|
|
|
const totalPages = Math.ceil(allCards.length / ITEMS_PER_PAGE);
|
|
|
|
|
|
|
|
|
|
// Masquer toutes les cartes
|
|
|
|
|
allCards.forEach(card => card.style.display = 'none');
|
|
|
|
|
|
|
|
|
|
// Afficher uniquement les cartes de la page courante
|
|
|
|
|
const start = (currentPage - 1) * ITEMS_PER_PAGE;
|
|
|
|
|
const end = start + ITEMS_PER_PAGE;
|
|
|
|
|
|
|
|
|
|
allCards.slice(start, end).forEach(card => card.style.display = 'block');
|
|
|
|
|
|
|
|
|
|
renderPagination(totalPages);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderPagination(totalPages) {
|
|
|
|
|
const pagination = document.getElementById('pagination');
|
|
|
|
|
pagination.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
const addBtn = (text, page = null, isActive = false, disabled = false) => {
|
|
|
|
|
const btn = document.createElement('button');
|
|
|
|
|
btn.textContent = text;
|
|
|
|
|
if (isActive) btn.classList.add('active');
|
|
|
|
|
if (disabled) btn.disabled = true;
|
|
|
|
|
if (page !== null) {
|
|
|
|
|
btn.addEventListener('click', () => {
|
|
|
|
|
currentPage = page;
|
|
|
|
|
paginateCards();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
pagination.appendChild(btn);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
addBtn('Précédent', currentPage - 1, false, currentPage === 1);
|
|
|
|
|
|
|
|
|
|
for (let i = 1; i <= totalPages; i++) {
|
|
|
|
|
if (
|
|
|
|
|
i === 1 ||
|
|
|
|
|
i === totalPages ||
|
|
|
|
|
(i >= currentPage - 1 && i <= currentPage + 1)
|
|
|
|
|
) {
|
|
|
|
|
addBtn(i, i, i === currentPage);
|
|
|
|
|
} else if (
|
|
|
|
|
i === 2 && currentPage > 3 ||
|
|
|
|
|
i === totalPages - 1 && currentPage < totalPages - 2
|
|
|
|
|
) {
|
|
|
|
|
addBtn('...');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addBtn('Suivant', currentPage + 1, false, currentPage === totalPages);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paginateCards();
|
|
|
|
|
});
|