diff --git a/js/admin.js b/js/admin.js index cef25a1..faf0fd2 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1,22 +1,12 @@ const API_URL = '../api.php'; -let allItems = []; -let currentAdminTab = 'critique'; -let currentPage = 1; -const itemsPerPage = 12; -let selectedIds = new Set(); -let pendingDeleteAction = null; +let allItems = [], currentAdminTab = 'critique', currentPage = 1, selectedIds = new Set(); -function getStarsHTML(rating) { - let r = parseFloat(String(rating).replace(',', '.')) || 0; - r = Math.min(Math.max(r, 0), 5); - const full = Math.floor(r); - const hasHalf = (r - full) >= 0.5; - const empty = Math.max(0, 5 - Math.ceil(r)); - let html = '★'.repeat(full); - if (hasHalf) html += ''; - html += `${'☆'.repeat(empty)}`; - return html; -} +// --- Utilitaires --- +const getStarsHTML = (rating) => { + let r = Math.min(Math.max(parseFloat(rating) || 0, 0), 5); + const full = Math.floor(r), hasHalf = (r - full) >= 0.5, empty = Math.max(0, 5 - Math.ceil(r)); + return '★'.repeat(full) + (hasHalf ? '' : '') + `${'☆'.repeat(empty)}`; +}; function parseCSV(text) { if (text.charCodeAt(0) === 0xFEFF) text = text.slice(1);