MMOON commited on
Commit
45ea18f
·
verified ·
1 Parent(s): 9582a81

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +19 -27
index.html CHANGED
@@ -25,11 +25,11 @@
25
  .sidebar {
26
  width: 280px; background: var(--sidebar-bg); color: var(--sidebar-text-color);
27
  display: flex; flex-direction: column;
28
- position: fixed; top: 0; left: 0; bottom: 0; /* Positionnement fixe */
29
  transition: transform 0.3s ease-in-out;
30
  z-index: 1000;
31
  transform: translateX(0);
32
- border-right: 1px solid var(--sidebar-border-color); /* Bordure propre */
33
  }
34
  .sidebar.collapsed { transform: translateX(-100%); }
35
 
@@ -40,13 +40,11 @@
40
  .logo-title-group { display: flex; align-items: center; gap: 12px; }
41
  .logo { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
42
  .sidebar-title { font-size: 1.5em; font-weight: 700; color: var(--white); }
43
-
44
  .sidebar-toggle {
45
  background: none; border: none; color: var(--sidebar-text-color); font-size: 1.5em;
46
  cursor: pointer; padding: 5px; transition: color 0.2s ease;
47
  }
48
  .sidebar-toggle:hover { color: var(--white); }
49
-
50
  .sidebar-nav, .sidebar-actions { padding: 15px; }
51
  .sidebar-nav { display: flex; flex-direction: column; gap: 10px; }
52
 
@@ -62,7 +60,6 @@
62
  .nav-button#updateDataBtn:hover:not(:disabled) { background-color: #218838; }
63
  .nav-button#applyFiltersBtn { background-color: var(--primary-color); }
64
  .nav-button#applyFiltersBtn:hover:not(:disabled) { background-color: var(--primary-dark); }
65
-
66
  .sidebar-actions { border-top: 1px solid var(--sidebar-border-color); display: flex; gap: 10px; }
67
  .action-button {
68
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
@@ -70,7 +67,6 @@
70
  padding: 10px; border-radius: 8px; cursor: pointer; transition: background-color 0.2s ease, color 0.2s ease;
71
  }
72
  .action-button:hover { background-color: var(--sidebar-hover-bg); color: var(--white); }
73
-
74
  .sidebar-filters { flex: 1; overflow-y: auto; padding: 0 15px; margin-top: 15px; }
75
  .filter-group label { display: block; margin-bottom: 8px; font-size: 1em; font-weight: 500; }
76
  .filter-input {
@@ -80,18 +76,16 @@
80
  .filter-input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 5px var(--primary-color); }
81
 
82
  /* --- ZONE DE CONTENU PRINCIPALE --- */
83
- /* CORRECTION MAJEURE: Le contenu principal a un margin-left pour ne pas être sous la sidebar */
84
  .content-wrapper {
85
  flex: 1;
86
- margin-left: 280px; /* Doit correspondre à la largeur de la sidebar */
87
  transition: margin-left 0.3s ease-in-out;
88
  display: flex;
89
  flex-direction: column;
90
  }
91
  .sidebar.collapsed ~ .content-wrapper {
92
- margin-left: 0; /* Pas de marge quand la sidebar est fermée */
93
  }
94
-
95
  .top-bar {
96
  display: flex; align-items: center; padding: 0 20px;
97
  height: 60px; background: var(--white);
@@ -101,10 +95,10 @@
101
  .open-sidebar-btn {
102
  background: none; border: none; font-size: 1.5em; cursor: pointer; color: var(--text-color);
103
  margin-right: 20px;
104
- display: none; /* Caché par défaut */
105
  }
106
  .sidebar.collapsed ~ .content-wrapper .open-sidebar-btn {
107
- display: block; /* Visible seulement quand la sidebar est fermée */
108
  }
109
 
110
  .top-bar-title { color: var(--secondary-color); font-size: 1.5em; font-weight: 500; }
@@ -197,9 +191,8 @@
197
  keywords: document.getElementById('keywordsFilter'),
198
  }
199
  };
200
-
201
  const REAL_DATA_URL = 'https://www.plateforme-sca.fr/media/11/download';
202
- const PROXY_URL = `https://api.allorigins.win/raw?url=${encodeURIComponent(REAL_DATA_URL)}`;
203
  let allData = [];
204
  let filteredData = [];
205
 
@@ -212,37 +205,35 @@
212
  ui.resultsContainer.innerHTML = '<div class="loading-overlay">Chargement des données...</div>';
213
  ui.updateDataBtn.disabled = true;
214
  ui.updateDataBtn.querySelector('i').classList.add('fa-spin');
215
-
216
  try {
217
  const response = await fetch(PROXY_URL);
218
  if (!response.ok) {
219
  throw new Error(`Erreur réseau: ${response.status} ${response.statusText}`);
220
  }
221
  const arrayBuffer = await response.arrayBuffer();
222
-
223
  const workbook = XLSX.read(arrayBuffer, { type: 'array' });
224
  const worksheet = workbook.Sheets[workbook.SheetNames[0]];
225
  const rawJsonData = XLSX.utils.sheet_to_json(worksheet);
226
 
227
- // Vérification de la validité des données reçues
228
  if (!rawJsonData || !Array.isArray(rawJsonData)) {
229
  throw new Error("Les données reçues sont invalides ou vides.");
230
  }
231
 
 
 
232
  allData = rawJsonData.map(item => ({
233
  'BuSCA': parseInt(item['BuSCA'], 10) || 0,
234
  'Titre': String(item['Titre'] || '').trim(),
235
  'Texte': String(item['Texte'] || '').trim(),
236
- 'Matrice (catégories)': String(item['Matrice (catégories)'] || 'Non spécifié').trim(),
237
- 'Danger': String(item['Danger'] || 'Non spécifié').trim(),
238
  'Section': String(item['Section'] || 'Non spécifié').trim(),
239
  'Lien': String(item['Lien'] || '').trim(),
240
  'Lien2': String(item['Lien2'] || '').trim()
241
  })).filter(item => item.BuSCA > 0 && item.Titre);
242
-
243
  showNotification('Données mises à jour avec succès !', 'success');
244
  processData();
245
-
246
  } catch (error) {
247
  console.error('Erreur lors de la mise à jour:', error);
248
  ui.resultsContainer.innerHTML = `<div class="empty-state" style="color: red;">Échec du chargement des données.<br>${error.message}</div>`;
@@ -261,12 +252,12 @@
261
  const criteria = {
262
  keywords: ui.filters.keywords.value.toLowerCase().split(',').map(k => k.trim()).filter(Boolean)
263
  };
264
-
265
  if (criteria.keywords.length === 0) {
266
  filteredData = allData;
267
  } else {
268
  filteredData = allData.filter(item => {
269
- const itemText = (item.Titre + ' ' + item.Texte + ' ' + item.Danger + ' ' + item['Matrice (catégories)']).toLowerCase();
 
270
  return criteria.keywords.every(k => itemText.includes(k));
271
  });
272
  }
@@ -287,6 +278,7 @@
287
  return;
288
  }
289
  const sortedData = [...filteredData].sort((a, b) => b.BuSCA - a.BuSCA);
 
290
  ui.resultsContainer.innerHTML = sortedData.map(item => `
291
  <article class="bulletin-card">
292
  <div class="bulletin-header" data-toggle="content">
@@ -296,7 +288,7 @@
296
  <div class="bulletin-content">
297
  <p class="bulletin-summary"><strong>Texte:</strong><br>${item.Texte.replace(/\n/g, '<br>') || 'Contenu non disponible.'}</p>
298
  <div class="bulletin-meta">
299
- <strong>Matrice:</strong> ${item['Matrice (catégories)']} | <strong>Danger:</strong> ${item.Danger}
300
  </div>
301
  <div class="bulletin-links">
302
  ${item.Lien ? `<a href="${item.Lien}" target="_blank" rel="noopener noreferrer">🔗 Lien 1</a>` : ''}
@@ -309,7 +301,7 @@
309
  function updateStats() {
310
  const totalBulletins = allData.length;
311
  const foundBulletins = filteredData.length;
312
- const uniqueMatrices = new Set(filteredData.map(i => i['Matrice (catégories)'])).size;
313
  const uniqueDangers = new Set(filteredData.map(i => i.Danger)).size;
314
  ui.statsContainer.innerHTML = `
315
  <div class="stat-card"><div class="stat-number">${foundBulletins} / ${totalBulletins}</div><div class="stat-label">Bulletins Trouvés</div></div>
@@ -367,7 +359,7 @@
367
  const csvContent = [
368
  headers.join(','),
369
  ...filteredData.map(item => [
370
- item.BuSCA, escapeCsv(item.Titre), escapeCsv(item['Matrice (catégories)']),
371
  escapeCsv(item.Danger), escapeCsv(item.Texte),
372
  escapeCsv(item.Lien), escapeCsv(item.Lien2)
373
  ].join(','))
@@ -381,7 +373,7 @@
381
  document.body.removeChild(link);
382
  showNotification('Export CSV généré !', 'success');
383
  }
384
-
385
  initializeApp();
386
  });
387
  </script>
 
25
  .sidebar {
26
  width: 280px; background: var(--sidebar-bg); color: var(--sidebar-text-color);
27
  display: flex; flex-direction: column;
28
+ position: fixed; top: 0; left: 0; bottom: 0;
29
  transition: transform 0.3s ease-in-out;
30
  z-index: 1000;
31
  transform: translateX(0);
32
+ border-right: 1px solid var(--sidebar-border-color);
33
  }
34
  .sidebar.collapsed { transform: translateX(-100%); }
35
 
 
40
  .logo-title-group { display: flex; align-items: center; gap: 12px; }
41
  .logo { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
42
  .sidebar-title { font-size: 1.5em; font-weight: 700; color: var(--white); }
 
43
  .sidebar-toggle {
44
  background: none; border: none; color: var(--sidebar-text-color); font-size: 1.5em;
45
  cursor: pointer; padding: 5px; transition: color 0.2s ease;
46
  }
47
  .sidebar-toggle:hover { color: var(--white); }
 
48
  .sidebar-nav, .sidebar-actions { padding: 15px; }
49
  .sidebar-nav { display: flex; flex-direction: column; gap: 10px; }
50
 
 
60
  .nav-button#updateDataBtn:hover:not(:disabled) { background-color: #218838; }
61
  .nav-button#applyFiltersBtn { background-color: var(--primary-color); }
62
  .nav-button#applyFiltersBtn:hover:not(:disabled) { background-color: var(--primary-dark); }
 
63
  .sidebar-actions { border-top: 1px solid var(--sidebar-border-color); display: flex; gap: 10px; }
64
  .action-button {
65
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
 
67
  padding: 10px; border-radius: 8px; cursor: pointer; transition: background-color 0.2s ease, color 0.2s ease;
68
  }
69
  .action-button:hover { background-color: var(--sidebar-hover-bg); color: var(--white); }
 
70
  .sidebar-filters { flex: 1; overflow-y: auto; padding: 0 15px; margin-top: 15px; }
71
  .filter-group label { display: block; margin-bottom: 8px; font-size: 1em; font-weight: 500; }
72
  .filter-input {
 
76
  .filter-input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 5px var(--primary-color); }
77
 
78
  /* --- ZONE DE CONTENU PRINCIPALE --- */
 
79
  .content-wrapper {
80
  flex: 1;
81
+ margin-left: 280px;
82
  transition: margin-left 0.3s ease-in-out;
83
  display: flex;
84
  flex-direction: column;
85
  }
86
  .sidebar.collapsed ~ .content-wrapper {
87
+ margin-left: 0;
88
  }
 
89
  .top-bar {
90
  display: flex; align-items: center; padding: 0 20px;
91
  height: 60px; background: var(--white);
 
95
  .open-sidebar-btn {
96
  background: none; border: none; font-size: 1.5em; cursor: pointer; color: var(--text-color);
97
  margin-right: 20px;
98
+ display: none;
99
  }
100
  .sidebar.collapsed ~ .content-wrapper .open-sidebar-btn {
101
+ display: block;
102
  }
103
 
104
  .top-bar-title { color: var(--secondary-color); font-size: 1.5em; font-weight: 500; }
 
191
  keywords: document.getElementById('keywordsFilter'),
192
  }
193
  };
 
194
  const REAL_DATA_URL = 'https://www.plateforme-sca.fr/media/11/download';
195
+ const PROXY_URL = `https://corsproxy.io/?${encodeURIComponent(REAL_DATA_URL)}`;
196
  let allData = [];
197
  let filteredData = [];
198
 
 
205
  ui.resultsContainer.innerHTML = '<div class="loading-overlay">Chargement des données...</div>';
206
  ui.updateDataBtn.disabled = true;
207
  ui.updateDataBtn.querySelector('i').classList.add('fa-spin');
 
208
  try {
209
  const response = await fetch(PROXY_URL);
210
  if (!response.ok) {
211
  throw new Error(`Erreur réseau: ${response.status} ${response.statusText}`);
212
  }
213
  const arrayBuffer = await response.arrayBuffer();
 
214
  const workbook = XLSX.read(arrayBuffer, { type: 'array' });
215
  const worksheet = workbook.Sheets[workbook.SheetNames[0]];
216
  const rawJsonData = XLSX.utils.sheet_to_json(worksheet);
217
 
 
218
  if (!rawJsonData || !Array.isArray(rawJsonData)) {
219
  throw new Error("Les données reçues sont invalides ou vides.");
220
  }
221
 
222
+ // --- CORRECTION MAJEURE ICI ---
223
+ // On utilise les nouveaux noms de colonnes 'Matrices' et 'Dangers' du fichier Excel
224
  allData = rawJsonData.map(item => ({
225
  'BuSCA': parseInt(item['BuSCA'], 10) || 0,
226
  'Titre': String(item['Titre'] || '').trim(),
227
  'Texte': String(item['Texte'] || '').trim(),
228
+ 'Matrice': String(item['Matrices'] || 'Non spécifié').trim(), // Lecture de 'Matrices'
229
+ 'Danger': String(item['Dangers'] || 'Non spécifié').trim(), // Lecture de 'Dangers'
230
  'Section': String(item['Section'] || 'Non spécifié').trim(),
231
  'Lien': String(item['Lien'] || '').trim(),
232
  'Lien2': String(item['Lien2'] || '').trim()
233
  })).filter(item => item.BuSCA > 0 && item.Titre);
234
+
235
  showNotification('Données mises à jour avec succès !', 'success');
236
  processData();
 
237
  } catch (error) {
238
  console.error('Erreur lors de la mise à jour:', error);
239
  ui.resultsContainer.innerHTML = `<div class="empty-state" style="color: red;">Échec du chargement des données.<br>${error.message}</div>`;
 
252
  const criteria = {
253
  keywords: ui.filters.keywords.value.toLowerCase().split(',').map(k => k.trim()).filter(Boolean)
254
  };
 
255
  if (criteria.keywords.length === 0) {
256
  filteredData = allData;
257
  } else {
258
  filteredData = allData.filter(item => {
259
+ // On cherche dans les clés internes 'Danger' et 'Matrice'
260
+ const itemText = (item.Titre + ' ' + item.Texte + ' ' + item.Danger + ' ' + item.Matrice).toLowerCase();
261
  return criteria.keywords.every(k => itemText.includes(k));
262
  });
263
  }
 
278
  return;
279
  }
280
  const sortedData = [...filteredData].sort((a, b) => b.BuSCA - a.BuSCA);
281
+ // On utilise les clés internes 'Matrice' et 'Danger' pour l'affichage
282
  ui.resultsContainer.innerHTML = sortedData.map(item => `
283
  <article class="bulletin-card">
284
  <div class="bulletin-header" data-toggle="content">
 
288
  <div class="bulletin-content">
289
  <p class="bulletin-summary"><strong>Texte:</strong><br>${item.Texte.replace(/\n/g, '<br>') || 'Contenu non disponible.'}</p>
290
  <div class="bulletin-meta">
291
+ <strong>Matrice:</strong> ${item.Matrice} | <strong>Danger:</strong> ${item.Danger}
292
  </div>
293
  <div class="bulletin-links">
294
  ${item.Lien ? `<a href="${item.Lien}" target="_blank" rel="noopener noreferrer">🔗 Lien 1</a>` : ''}
 
301
  function updateStats() {
302
  const totalBulletins = allData.length;
303
  const foundBulletins = filteredData.length;
304
+ const uniqueMatrices = new Set(filteredData.map(i => i.Matrice)).size;
305
  const uniqueDangers = new Set(filteredData.map(i => i.Danger)).size;
306
  ui.statsContainer.innerHTML = `
307
  <div class="stat-card"><div class="stat-number">${foundBulletins} / ${totalBulletins}</div><div class="stat-label">Bulletins Trouvés</div></div>
 
359
  const csvContent = [
360
  headers.join(','),
361
  ...filteredData.map(item => [
362
+ item.BuSCA, escapeCsv(item.Titre), escapeCsv(item.Matrice),
363
  escapeCsv(item.Danger), escapeCsv(item.Texte),
364
  escapeCsv(item.Lien), escapeCsv(item.Lien2)
365
  ].join(','))
 
373
  document.body.removeChild(link);
374
  showNotification('Export CSV généré !', 'success');
375
  }
376
+
377
  initializeApp();
378
  });
379
  </script>