PierreH commited on
Commit
8a81557
·
verified ·
1 Parent(s): eb39ed7

Add 1 files

Browse files
Files changed (1) hide show
  1. index.html +78 -88
index.html CHANGED
@@ -5,7 +5,6 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Étoile de Mots Interactive</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
9
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
10
  <style>
11
  .target-container {
@@ -162,6 +161,28 @@
162
  flex-wrap: wrap;
163
  }
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  @media (max-width: 640px) {
166
  .label {
167
  font-size: 0.75rem;
@@ -194,10 +215,6 @@
194
  <i class="fas fa-star text-yellow-400 mr-2"></i>Étoile de Mots
195
  </h1>
196
  <div class="flex gap-2">
197
- <button onclick="saveAsPDF()" class="action-btn bg-indigo-500 text-white px-4 py-2 rounded-lg hover:bg-indigo-600">
198
- <i class="fas fa-file-pdf"></i>
199
- <span class="mobile-hidden">PDF</span>
200
- </button>
201
  <button onclick="resetKeywords()" class="action-btn bg-gray-500 text-white px-4 py-2 rounded-lg hover:bg-gray-600">
202
  <i class="fas fa-redo"></i>
203
  <span class="mobile-hidden">Réinit.</span>
@@ -227,6 +244,32 @@
227
  </button>
228
  </div>
229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  <div class="style-editor" id="styleEditor" style="display: none;">
231
  <h3 class="font-medium text-gray-700 mb-3">Style du mot sélectionné</h3>
232
 
@@ -287,27 +330,9 @@
287
  Appliquer
288
  </button>
289
  </div>
290
-
291
- <div class="context-menu" id="contextMenu">
292
- <div class="context-menu-item" onclick="editSelectedKeyword()">
293
- <i class="fas fa-edit text-blue-500"></i> Modifier
294
- </div>
295
- <div class="context-menu-item" onclick="deleteSelectedKeyword()">
296
- <i class="fas fa-trash text-red-500"></i> Supprimer
297
- </div>
298
- <div class="context-menu-item" onclick="deselectKeyword()">
299
- <i class="fas fa-times-circle text-gray-500"></i> Désélectionner
300
- </div>
301
- <div class="context-menu-item" onclick="showStyleEditor()">
302
- <i class="fas fa-paint-brush text-purple-500"></i> Style
303
- </div>
304
- </div>
305
  </div>
306
 
307
  <script>
308
- // Initialize jsPDF
309
- const { jsPDF } = window.jspdf;
310
-
311
  let keywords = [
312
  { text: "Identification", x: null, y: null, color: "#1e293b", bgColor: "#ffffff", fontSize: "0.85rem", fontWeight: "500" },
313
  { text: "Gestion", x: null, y: null, color: "#1e293b", bgColor: "#ffffff", fontSize: "0.85rem", fontWeight: "500" },
@@ -333,6 +358,7 @@
333
  const canvas = document.getElementById('canvas');
334
  const ctx = canvas.getContext('2d');
335
  const contextMenu = document.getElementById('contextMenu');
 
336
 
337
  function renderKeywords() {
338
  const container = document.getElementById('target-container');
@@ -589,19 +615,6 @@
589
  }
590
  }
591
 
592
- function editSelectedKeyword() {
593
- if (selectedKeywordIndex === null) return;
594
-
595
- const newText = prompt("Modifier le mot:", keywords[selectedKeywordIndex].text);
596
- if (newText !== null && newText.trim() !== "") {
597
- keywords[selectedKeywordIndex].text = newText.trim();
598
- renderKeywords();
599
- selectKeyword(selectedKeywordIndex);
600
- }
601
-
602
- contextMenu.style.display = 'none';
603
- }
604
-
605
  function deleteSelectedKeyword() {
606
  if (selectedKeywordIndex === null) return;
607
 
@@ -644,6 +657,31 @@
644
  document.removeEventListener('click', closeContextMenu);
645
  }
646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  function showStyleEditor() {
648
  if (selectedKeywordIndex === null) return;
649
 
@@ -688,58 +726,6 @@
688
  document.getElementById('styleEditor').style.display = 'none';
689
  }
690
 
691
- async function saveAsPDF() {
692
- const buttons = document.querySelectorAll('button, input');
693
- buttons.forEach(btn => btn.style.visibility = 'hidden');
694
-
695
- const note = document.getElementById('userNotes');
696
- const originalStyles = {
697
- textAlign: note.style.textAlign,
698
- fontSize: note.style.fontSize,
699
- fontWeight: note.style.fontWeight,
700
- backgroundColor: note.style.backgroundColor,
701
- border: note.style.border,
702
- boxShadow: note.style.boxShadow
703
- };
704
-
705
- note.style.textAlign = 'center';
706
- note.style.fontSize = '18px';
707
- note.style.fontWeight = 'bold';
708
- note.style.backgroundColor = 'transparent';
709
- note.style.border = 'none';
710
- note.style.boxShadow = 'none';
711
-
712
- try {
713
- const canvas = await html2canvas(document.querySelector('.w-full.max-w-2xl'), {
714
- scale: 2,
715
- backgroundColor: '#f9fafb',
716
- useCORS: true,
717
- logging: false
718
- });
719
-
720
- const imgData = canvas.toDataURL('image/png');
721
- const pdf = new jsPDF({
722
- orientation: 'portrait',
723
- unit: 'mm'
724
- });
725
-
726
- const imgWidth = 190;
727
- const imgHeight = (canvas.height * imgWidth) / canvas.width;
728
-
729
- pdf.addImage(imgData, 'PNG', 10, 10, imgWidth, imgHeight);
730
- pdf.save(`etoile_mots_${new Date().toISOString().split('T')[0]}.pdf`);
731
- } catch (err) {
732
- console.error("Erreur lors de l'export PDF:", err);
733
- alert("Une erreur est survenue lors de l'export PDF");
734
- } finally {
735
- buttons.forEach(btn => btn.style.visibility = 'visible');
736
-
737
- Object.keys(originalStyles).forEach(style => {
738
- note.style[style] = originalStyles[style];
739
- });
740
- }
741
- }
742
-
743
  // Initialize
744
  document.addEventListener('DOMContentLoaded', () => {
745
  renderKeywords();
@@ -763,6 +749,10 @@
763
  document.getElementById('styleEditor').style.display === 'block') {
764
  document.getElementById('styleEditor').style.display = 'none';
765
  }
 
 
 
 
766
  });
767
  });
768
  </script>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Étoile de Mots Interactive</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
 
8
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
  <style>
10
  .target-container {
 
161
  flex-wrap: wrap;
162
  }
163
 
164
+ .edit-modal {
165
+ position: fixed;
166
+ top: 0;
167
+ left: 0;
168
+ width: 100%;
169
+ height: 100%;
170
+ background-color: rgba(0,0,0,0.5);
171
+ display: flex;
172
+ align-items: center;
173
+ justify-content: center;
174
+ z-index: 1000;
175
+ display: none;
176
+ }
177
+
178
+ .edit-modal-content {
179
+ background: white;
180
+ border-radius: 0.75rem;
181
+ padding: 1.5rem;
182
+ width: 90%;
183
+ max-width: 400px;
184
+ }
185
+
186
  @media (max-width: 640px) {
187
  .label {
188
  font-size: 0.75rem;
 
215
  <i class="fas fa-star text-yellow-400 mr-2"></i>Étoile de Mots
216
  </h1>
217
  <div class="flex gap-2">
 
 
 
 
218
  <button onclick="resetKeywords()" class="action-btn bg-gray-500 text-white px-4 py-2 rounded-lg hover:bg-gray-600">
219
  <i class="fas fa-redo"></i>
220
  <span class="mobile-hidden">Réinit.</span>
 
244
  </button>
245
  </div>
246
 
247
+ <div class="context-menu" id="contextMenu">
248
+ <div class="context-menu-item" onclick="showEditModal()">
249
+ <i class="fas fa-edit text-blue-500"></i> Modifier
250
+ </div>
251
+ <div class="context-menu-item" onclick="deleteSelectedKeyword()">
252
+ <i class="fas fa-trash text-red-500"></i> Supprimer
253
+ </div>
254
+ <div class="context-menu-item" onclick="showStyleEditor()">
255
+ <i class="fas fa-paint-brush text-purple-500"></i> Style
256
+ </div>
257
+ <div class="context-menu-item" onclick="deselectKeyword()">
258
+ <i class="fas fa-times-circle text-gray-500"></i> Désélectionner
259
+ </div>
260
+ </div>
261
+
262
+ <div class="edit-modal" id="editModal">
263
+ <div class="edit-modal-content">
264
+ <h3 class="font-bold text-lg mb-4">Modifier le mot</h3>
265
+ <input type="text" id="editKeywordInput" class="w-full p-2 border rounded mb-4">
266
+ <div class="flex justify-end gap-2">
267
+ <button onclick="closeEditModal()" class="px-4 py-2 rounded-lg border">Annuler</button>
268
+ <button onclick="updateKeyword()" class="px-4 py-2 rounded-lg bg-blue-500 text-white">Enregistrer</button>
269
+ </div>
270
+ </div>
271
+ </div>
272
+
273
  <div class="style-editor" id="styleEditor" style="display: none;">
274
  <h3 class="font-medium text-gray-700 mb-3">Style du mot sélectionné</h3>
275
 
 
330
  Appliquer
331
  </button>
332
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  </div>
334
 
335
  <script>
 
 
 
336
  let keywords = [
337
  { text: "Identification", x: null, y: null, color: "#1e293b", bgColor: "#ffffff", fontSize: "0.85rem", fontWeight: "500" },
338
  { text: "Gestion", x: null, y: null, color: "#1e293b", bgColor: "#ffffff", fontSize: "0.85rem", fontWeight: "500" },
 
358
  const canvas = document.getElementById('canvas');
359
  const ctx = canvas.getContext('2d');
360
  const contextMenu = document.getElementById('contextMenu');
361
+ const editModal = document.getElementById('editModal');
362
 
363
  function renderKeywords() {
364
  const container = document.getElementById('target-container');
 
615
  }
616
  }
617
 
 
 
 
 
 
 
 
 
 
 
 
 
 
618
  function deleteSelectedKeyword() {
619
  if (selectedKeywordIndex === null) return;
620
 
 
657
  document.removeEventListener('click', closeContextMenu);
658
  }
659
 
660
+ function showEditModal() {
661
+ if (selectedKeywordIndex === null) return;
662
+
663
+ const keyword = keywords[selectedKeywordIndex];
664
+ document.getElementById('editKeywordInput').value = keyword.text;
665
+ editModal.style.display = 'flex';
666
+ contextMenu.style.display = 'none';
667
+ }
668
+
669
+ function closeEditModal() {
670
+ editModal.style.display = 'none';
671
+ }
672
+
673
+ function updateKeyword() {
674
+ if (selectedKeywordIndex === null) return;
675
+
676
+ const newText = document.getElementById('editKeywordInput').value.trim();
677
+ if (newText) {
678
+ keywords[selectedKeywordIndex].text = newText;
679
+ renderKeywords();
680
+ selectKeyword(selectedKeywordIndex);
681
+ }
682
+ closeEditModal();
683
+ }
684
+
685
  function showStyleEditor() {
686
  if (selectedKeywordIndex === null) return;
687
 
 
726
  document.getElementById('styleEditor').style.display = 'none';
727
  }
728
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
729
  // Initialize
730
  document.addEventListener('DOMContentLoaded', () => {
731
  renderKeywords();
 
749
  document.getElementById('styleEditor').style.display === 'block') {
750
  document.getElementById('styleEditor').style.display = 'none';
751
  }
752
+
753
+ if (editModal.style.display === 'flex' && !editModal.querySelector('.edit-modal-content').contains(e.target)) {
754
+ closeEditModal();
755
+ }
756
  });
757
  });
758
  </script>