PierreH commited on
Commit
cb3e03a
·
verified ·
1 Parent(s): 57a23fc

Add 1 files

Browse files
Files changed (1) hide show
  1. index.html +477 -216
index.html CHANGED
@@ -1,224 +1,485 @@
1
- <!DOCTYPE html><html lang="fr">
 
2
  <head>
3
- <meta charset="UTF-8">
4
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
- <title>Toile Dynamique Minimaliste</title>
6
- <script src="https://cdn.tailwindcss.com"></script>
7
- <style>
8
- .target-container {
9
- position: relative;
10
- width: 100%;
11
- aspect-ratio: 1/1;
12
- border-radius: 50%;
13
- overflow: visible;
14
- }
15
- .circle { position: absolute; border-radius: 50%; z-index: 1; }
16
- .circle1 { background-color: #fecaca; width: 8%; height: 8%; top: 46%; left: 46%; }
17
- .circle2 { background-color: #fed7aa; width: 20%; height: 20%; top: 40%; left: 40%; }
18
- .circle3 { background-color: #fef08a; width: 35%; height: 35%; top: 32.5%; left: 32.5%; }
19
- .circle4 { background-color: #bbf7d0; width: 55%; height: 55%; top: 22.5%; left: 22.5%; }
20
- .circle5 { background-color: #bfdbfe; width: 75%; height: 75%; top: 12.5%; left: 12.5%; }.label {
21
- position: absolute;
22
- font-weight: bold;
23
- font-size: 0.75rem;
24
- color: #333;
25
- cursor: pointer;
26
- user-select: none;
27
- white-space: nowrap;
28
- z-index: 7;
29
- padding: 0.25rem 0.5rem;
30
- background-color: rgba(255, 255, 255, 0.85);
31
- border-radius: 0.25rem;
32
- transition: all 0.2s ease;
33
- box-shadow: 0 1px 2px rgba(0,0,0,0.1);
34
- }
35
- .label:hover { transform: scale(1.05); background-color: rgba(255,255,255,0.95); }
36
- .label.selected { background-color: #3b82f6; color: white; transform: scale(1.1); }
37
-
38
- #canvas {
39
- position: absolute;
40
- top: 0; left: 0;
41
- width: 100%; height: 100%;
42
- z-index: 6;
43
- pointer-events: none;
44
- }
45
-
46
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  </head>
48
  <body class="bg-gray-50 min-h-screen flex flex-col items-center justify-center p-4">
49
- <div class="w-full max-w-md bg-white rounded-xl shadow-md p-6 space-y-6">
50
- <h1 class="text-xl font-bold text-center text-gray-700">☆ Mon Étoile de Mots ☆</h1>
51
- <textarea id="editKeyword" class="w-full p-2 rounded-lg border" placeholder="Modifier le mot sélectionné..."></textarea>
52
- <div class="target-container bg-white shadow-inner" id="target-container">
53
- <canvas id="canvas"></canvas>
54
- <div class="circle circle5"></div>
55
- <div class="circle circle4"></div>
56
- <div class="circle circle3"></div>
57
- <div class="circle circle2"></div>
58
- <div class="circle circle1"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  </div>
60
- </div> <script>
61
- let keywords = [
62
- { text: "Identification", x: null, y: null },
63
- { text: "Gestion", x: null, y: null },
64
- { text: "Adaptation", x: null, y: null },
65
- { text: "Autonomie", x: null, y: null }
66
- ];
67
-
68
- let selectedKeywordIndex = null;
69
- let isDragging = false;
70
- let dragStartX, dragStartY;
71
- let draggedLabel = null;
72
- let draggedIndex = null;
73
-
74
- const canvas = document.getElementById('canvas');
75
- const ctx = canvas.getContext('2d');
76
 
77
- function renderKeywords() {
78
- const container = document.getElementById('target-container');
79
- const centerX = container.offsetWidth / 2;
80
- const centerY = container.offsetHeight / 2;
81
- const radius = Math.min(centerX, centerY) * 0.35;
82
-
83
- container.querySelectorAll('.label').forEach(e => e.remove());
84
-
85
- keywords.forEach((word, index) => {
86
- const labelWidth = word.text.length * 8 + 16;
87
- const labelHeight = 24;
88
-
89
- if (word.x === null || word.y === null) {
90
- const angleStep = (2 * Math.PI) / keywords.length;
91
- const angle = index * angleStep - Math.PI / 2;
92
- word.x = centerX + radius * Math.cos(angle) - labelWidth / 2;
93
- word.y = centerY + radius * Math.sin(angle) - labelHeight / 2;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
-
96
- const label = document.createElement('div');
97
- label.className = 'label';
98
- label.style.left = `${word.x}px`;
99
- label.style.top = `${word.y}px`;
100
- label.textContent = word.text;
101
- label.dataset.index = index;
102
-
103
- label.addEventListener('mousedown', (e) => startDrag(e, label, index));
104
- label.addEventListener('touchstart', (e) => {
105
- const touch = e.touches[0];
106
- startDrag(touch, label, index);
107
- });
108
-
109
- if (index === selectedKeywordIndex) label.classList.add('selected');
110
- container.appendChild(label);
111
- });
112
-
113
- resizeCanvas();
114
- }
115
-
116
- function startDrag(e, label, index) {
117
- isDragging = true;
118
- draggedLabel = label;
119
- draggedIndex = index;
120
- dragStartX = e.clientX - parseFloat(label.style.left);
121
- dragStartY = e.clientY - parseFloat(label.style.top);
122
- selectKeyword(index);
123
-
124
- document.addEventListener('mousemove', drag);
125
- document.addEventListener('mouseup', stopDrag);
126
- e.preventDefault();
127
- }
128
-
129
- function drag(e) {
130
- if (!isDragging) return;
131
-
132
- const container = document.getElementById('target-container');
133
- let newX = e.clientX - dragStartX;
134
- let newY = e.clientY - dragStartY;
135
-
136
- newX = Math.max(0, Math.min(newX, container.offsetWidth - draggedLabel.offsetWidth));
137
- newY = Math.max(0, Math.min(newY, container.offsetHeight - draggedLabel.offsetHeight));
138
-
139
- draggedLabel.style.left = `${newX}px`;
140
- draggedLabel.style.top = `${newY}px`;
141
-
142
- keywords[draggedIndex].x = newX;
143
- keywords[draggedIndex].y = newY;
144
-
145
- resizeCanvas();
146
- }
147
-
148
- function stopDrag() {
149
- isDragging = false;
150
- draggedLabel = null;
151
- draggedIndex = null;
152
-
153
- document.removeEventListener('mousemove', drag);
154
- document.removeEventListener('mouseup', stopDrag);
155
- }
156
-
157
- function selectKeyword(index) {
158
- selectedKeywordIndex = index;
159
- document.getElementById('editKeyword').value = keywords[index].text;
160
- document.querySelectorAll('.label').forEach(label => label.classList.remove('selected'));
161
- const selectedLabel = document.querySelector(`.label[data-index='${index}']`);
162
- if (selectedLabel) selectedLabel.classList.add('selected');
163
- }
164
-
165
- function deselectKeyword() {
166
- selectedKeywordIndex = null;
167
- document.getElementById('editKeyword').value = '';
168
- document.querySelectorAll('.label').forEach(label => label.classList.remove('selected'));
169
- }
170
-
171
- function resizeCanvas() {
172
- const container = document.getElementById('target-container');
173
- canvas.width = container.offsetWidth;
174
- canvas.height = container.offsetHeight;
175
- drawLines();
176
- }
177
-
178
- function drawLines() {
179
- ctx.clearRect(0, 0, canvas.width, canvas.height);
180
- if (keywords.length < 2) return;
181
-
182
- ctx.beginPath();
183
- ctx.strokeStyle = '#3b82f6';
184
- ctx.lineWidth = 1;
185
- ctx.setLineDash([5, 3]);
186
-
187
- const positions = keywords.map((k, i) => {
188
- const label = document.querySelector(`.label[data-index='${i}']`);
189
- return {
190
- x: k.x + (label?.offsetWidth || 0) / 2,
191
- y: k.y + (label?.offsetHeight || 0) / 2
192
- };
193
- });
194
-
195
- for (let i = 0; i < positions.length; i++) {
196
- const next = positions[(i + 1) % positions.length];
197
- ctx.moveTo(positions[i].x, positions[i].y);
198
- ctx.lineTo(next.x, next.y);
199
- }
200
-
201
- ctx.stroke();
202
- }
203
-
204
- document.addEventListener('DOMContentLoaded', () => {
205
- renderKeywords();
206
-
207
- document.addEventListener('click', (e) => {
208
- if (!e.target.classList.contains('label') && !e.target.closest('.label')) {
209
- deselectKeyword();
210
  }
211
- });
212
- });
213
-
214
- document.addEventListener('touchmove', function(e) {
215
- if (isDragging) {
216
- const touch = e.touches[0];
217
- drag(touch);
218
- e.preventDefault();
219
- }
220
- }, { passive: false });
221
-
222
- document.addEventListener('touchend', stopDrag);
223
- </script></body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
  <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Toile Dynamique Minimaliste</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
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
10
+ <style>
11
+ .target-container {
12
+ position: relative;
13
+ width: 100%;
14
+ aspect-ratio: 1/1;
15
+ border-radius: 50%;
16
+ overflow: visible;
17
+ }
18
+
19
+ .circle {
20
+ position: absolute;
21
+ border-radius: 50%;
22
+ z-index: 1;
23
+ }
24
+
25
+ .circle1 { background-color: #fecaca; width: 8%; height: 8%; top: 46%; left: 46%; }
26
+ .circle2 { background-color: #fed7aa; width: 20%; height: 20%; top: 40%; left: 40%; }
27
+ .circle3 { background-color: #fef08a; width: 35%; height: 35%; top: 32.5%; left: 32.5%; }
28
+ .circle4 { background-color: #bbf7d0; width: 55%; height: 55%; top: 22.5%; left: 22.5%; }
29
+ .circle5 { background-color: #bfdbfe; width: 75%; height: 75%; top: 12.5%; left: 12.5%; }
30
+
31
+ .label {
32
+ position: absolute;
33
+ font-weight: bold;
34
+ font-size: 0.75rem;
35
+ color: #333;
36
+ cursor: move;
37
+ user-select: none;
38
+ white-space: nowrap;
39
+ z-index: 7;
40
+ padding: 0.25rem 0.5rem;
41
+ background-color: rgba(255, 255, 255, 0.85);
42
+ border-radius: 0.25rem;
43
+ transition: all 0.2s ease;
44
+ box-shadow: 0 1px 2px rgba(0,0,0,0.1);
45
+ }
46
+
47
+ .label:hover {
48
+ transform: scale(1.05);
49
+ background-color: rgba(255, 255, 255, 0.95);
50
+ }
51
+
52
+ .label.selected {
53
+ background-color: #3b82f6;
54
+ color: white;
55
+ transform: scale(1.1);
56
+ }
57
+
58
+ #canvas {
59
+ position: absolute;
60
+ top: 0;
61
+ left: 0;
62
+ width: 100%;
63
+ height: 100%;
64
+ z-index: 6;
65
+ pointer-events: none;
66
+ }
67
+
68
+ .note-input {
69
+ resize: none;
70
+ font-size: 0.875rem;
71
+ text-align: center;
72
+ background-color: transparent;
73
+ border: none;
74
+ outline: none;
75
+ }
76
+
77
+ .note-input::placeholder {
78
+ color: #9ca3af;
79
+ }
80
+
81
+ .action-btn {
82
+ transition: all 0.2s ease;
83
+ }
84
+
85
+ .action-btn:hover {
86
+ transform: translateY(-1px);
87
+ }
88
+
89
+ .action-btn:active {
90
+ transform: translateY(1px);
91
+ }
92
+ </style>
93
  </head>
94
  <body class="bg-gray-50 min-h-screen flex flex-col items-center justify-center p-4">
95
+ <div class="w-full max-w-md bg-white rounded-xl shadow-md p-6 space-y-6">
96
+ <h1 class="text-xl font-bold text-center text-gray-700">☆ Mon Étoile de Mots ☆</h1>
97
+
98
+ <textarea id="userNotes" class="note-input w-full p-2 rounded-lg bg-gray-50"
99
+ placeholder="Écrivez vos notes ici... nom, date, objectifs etc." rows="2"></textarea>
100
+
101
+ <div class="target-container bg-white shadow-inner" id="target-container">
102
+ <canvas id="canvas"></canvas>
103
+ <div class="circle circle5"></div>
104
+ <div class="circle circle4"></div>
105
+ <div class="circle circle3"></div>
106
+ <div class="circle circle2"></div>
107
+ <div class="circle circle1"></div>
108
+ </div>
109
+
110
+ <div class="grid grid-cols-2 gap-3">
111
+ <input type="text" id="newKeyword" placeholder="Nouveau mot"
112
+ class="col-span-2 p-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
113
+
114
+ <div class="flex space-x-2">
115
+ <input type="text" id="editKeyword" placeholder="Modifier"
116
+ class="flex-1 p-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
117
+ <button onclick="updateKeyword()" class="action-btn bg-blue-500 text-white px-3 py-2 rounded-lg hover:bg-blue-600">
118
+ Modifier
119
+ </button>
120
+ </div>
121
+
122
+ <button onclick="deleteKeyword()" class="action-btn bg-red-500 text-white py-2 rounded-lg hover:bg-red-600">
123
+ Supprimer
124
+ </button>
125
+
126
+ <button onclick="addKeyword()" class="action-btn bg-green-500 text-white py-2 rounded-lg hover:bg-green-600">
127
+ Ajouter
128
+ </button>
129
+
130
+ <button onclick="saveAsImage()" class="action-btn bg-purple-500 text-white py-2 rounded-lg hover:bg-purple-600">
131
+ Enregistrer (Image)
132
+ </button>
133
+
134
+ <button onclick="saveAsPDF()" class="action-btn bg-indigo-500 text-white py-2 rounded-lg hover:bg-indigo-600">
135
+ Enregistrer (PDF)
136
+ </button>
137
+
138
+ <button onclick="resetKeywords()" class="action-btn bg-gray-500 text-white py-2 rounded-lg hover:bg-gray-600 col-span-2">
139
+ Réinitialiser
140
+ </button>
141
+ </div>
142
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
+ <script>
145
+ // Initialize jsPDF
146
+ const { jsPDF } = window.jspdf;
147
+
148
+ let keywords = [
149
+ { text: "Identification", x: null, y: null },
150
+ { text: "Gestion", x: null, y: null },
151
+ { text: "Adaptation", x: null, y: null },
152
+ { text: "Autonomie", x: null, y: null },
153
+ { text: "Connaissance", x: null, y: null },
154
+ { text: "Prévention", x: null, y: null },
155
+ { text: "Équilibre", x: null, y: null },
156
+ { text: "Stratégies", x: null, y: null },
157
+ { text: "Motivation", x: null, y: null },
158
+ { text: "Recours", x: null, y: null }
159
+ ];
160
+
161
+ let selectedKeywordIndex = null;
162
+ let isDragging = false;
163
+ let dragStartX, dragStartY;
164
+ let draggedLabel = null;
165
+ let draggedIndex = null;
166
+
167
+ const canvas = document.getElementById('canvas');
168
+ const ctx = canvas.getContext('2d');
169
+
170
+ function renderKeywords() {
171
+ const container = document.getElementById('target-container');
172
+ const centerX = container.offsetWidth / 2;
173
+ const centerY = container.offsetHeight / 2;
174
+ const radius = Math.min(centerX, centerY) * 0.35;
175
+
176
+ // Remove existing labels
177
+ container.querySelectorAll('.label').forEach(e => e.remove());
178
+
179
+ // Create new labels
180
+ keywords.forEach((word, index) => {
181
+ const label = document.createElement('div');
182
+ label.className = 'label draggable';
183
+ label.textContent = word.text;
184
+ label.dataset.index = index;
185
+
186
+ // Calculate position if not set
187
+ if (word.x === null || word.y === null) {
188
+ const angleStep = (2 * Math.PI) / keywords.length;
189
+ const angle = index * angleStep - Math.PI / 2;
190
+ word.x = centerX + radius * Math.cos(angle) - label.offsetWidth / 2;
191
+ word.y = centerY + radius * Math.sin(angle) - label.offsetHeight / 2;
192
+ }
193
+
194
+ label.style.left = `${word.x}px`;
195
+ label.style.top = `${word.y}px`;
196
+
197
+ label.addEventListener('mousedown', (e) => {
198
+ startDrag(e, label, index);
199
+ });
200
+
201
+ if (index === selectedKeywordIndex) {
202
+ label.classList.add('selected');
203
+ }
204
+
205
+ container.appendChild(label);
206
+ });
207
+
208
+ // Force reflow to ensure labels are rendered before calculating positions
209
+ setTimeout(() => {
210
+ updateLabelPositions();
211
+ resizeCanvas();
212
+ }, 0);
213
  }
214
+
215
+ function updateLabelPositions() {
216
+ const container = document.getElementById('target-container');
217
+ const labels = container.querySelectorAll('.label');
218
+
219
+ labels.forEach((label, index) => {
220
+ if (keywords[index].x === null || keywords[index].y === null) {
221
+ const rect = label.getBoundingClientRect();
222
+ const containerRect = container.getBoundingClientRect();
223
+
224
+ keywords[index].x = rect.left - containerRect.left;
225
+ keywords[index].y = rect.top - containerRect.top;
226
+ }
227
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  }
229
+
230
+ function startDrag(e, label, index) {
231
+ isDragging = true;
232
+ draggedLabel = label;
233
+ draggedIndex = index;
234
+
235
+ const rect = label.getBoundingClientRect();
236
+ dragStartX = e.clientX - rect.left;
237
+ dragStartY = e.clientY - rect.top;
238
+
239
+ // Select the label being dragged
240
+ selectKeyword(index);
241
+
242
+ document.addEventListener('mousemove', drag);
243
+ document.addEventListener('mouseup', stopDrag);
244
+
245
+ e.preventDefault();
246
+ }
247
+
248
+ function drag(e) {
249
+ if (!isDragging || !draggedLabel) return;
250
+
251
+ const container = document.getElementById('target-container');
252
+ const containerRect = container.getBoundingClientRect();
253
+
254
+ // Calculate new position relative to container
255
+ let newX = e.clientX - containerRect.left - dragStartX;
256
+ let newY = e.clientY - containerRect.top - dragStartY;
257
+
258
+ // Constrain to container bounds
259
+ newX = Math.max(0, Math.min(newX, container.offsetWidth - draggedLabel.offsetWidth));
260
+ newY = Math.max(0, Math.min(newY, container.offsetHeight - draggedLabel.offsetHeight));
261
+
262
+ draggedLabel.style.left = `${newX}px`;
263
+ draggedLabel.style.top = `${newY}px`;
264
+
265
+ // Update keyword position
266
+ keywords[draggedIndex].x = newX;
267
+ keywords[draggedIndex].y = newY;
268
+
269
+ drawLines();
270
+ }
271
+
272
+ function stopDrag() {
273
+ isDragging = false;
274
+ draggedLabel = null;
275
+ draggedIndex = null;
276
+
277
+ document.removeEventListener('mousemove', drag);
278
+ document.removeEventListener('mouseup', stopDrag);
279
+ }
280
+
281
+ function selectKeyword(index) {
282
+ selectedKeywordIndex = index;
283
+ document.getElementById('editKeyword').value = keywords[index].text;
284
+
285
+ // Update UI
286
+ document.querySelectorAll('.label').forEach(label => {
287
+ label.classList.remove('selected');
288
+ });
289
+
290
+ const selectedLabel = document.querySelector(`.label[data-index='${index}']`);
291
+ if (selectedLabel) {
292
+ selectedLabel.classList.add('selected');
293
+ }
294
+ }
295
+
296
+ function resizeCanvas() {
297
+ const container = document.getElementById('target-container');
298
+ canvas.width = container.offsetWidth;
299
+ canvas.height = container.offsetHeight;
300
+ drawLines();
301
+ }
302
+
303
+ function drawLines() {
304
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
305
+
306
+ if (keywords.length < 2) return;
307
+
308
+ ctx.beginPath();
309
+ ctx.strokeStyle = '#3b82f6';
310
+ ctx.lineWidth = 1;
311
+ ctx.setLineDash([5, 3]);
312
+
313
+ const labels = document.querySelectorAll('.label');
314
+ const positions = [];
315
+
316
+ labels.forEach(label => {
317
+ const index = parseInt(label.dataset.index);
318
+ if (!isNaN(index) && index >= 0 && index < keywords.length) {
319
+ const rect = label.getBoundingClientRect();
320
+ const containerRect = canvas.getBoundingClientRect();
321
+
322
+ positions.push({
323
+ x: rect.left - containerRect.left + rect.width / 2,
324
+ y: rect.top - containerRect.top + rect.height / 2
325
+ });
326
+ }
327
+ });
328
+
329
+ // Draw connecting lines
330
+ for (let i = 0; i < positions.length; i++) {
331
+ const next = positions[(i + 1) % positions.length];
332
+ ctx.moveTo(positions[i].x, positions[i].y);
333
+ ctx.lineTo(next.x, next.y);
334
+ }
335
+
336
+ ctx.stroke();
337
+ }
338
+
339
+ function addKeyword() {
340
+ const input = document.getElementById('newKeyword');
341
+ const text = input.value.trim();
342
+
343
+ if (text) {
344
+ keywords.push({ text: text, x: null, y: null });
345
+ input.value = '';
346
+ renderKeywords();
347
+ }
348
+ }
349
+
350
+ function updateKeyword() {
351
+ const input = document.getElementById('editKeyword');
352
+ const text = input.value.trim();
353
+
354
+ if (text && selectedKeywordIndex !== null) {
355
+ keywords[selectedKeywordIndex].text = text;
356
+ renderKeywords();
357
+ selectKeyword(selectedKeywordIndex);
358
+ }
359
+ }
360
+
361
+ function deleteKeyword() {
362
+ if (selectedKeywordIndex !== null) {
363
+ keywords.splice(selectedKeywordIndex, 1);
364
+ selectedKeywordIndex = null;
365
+ document.getElementById('editKeyword').value = '';
366
+ renderKeywords();
367
+ }
368
+ }
369
+
370
+ function resetKeywords() {
371
+ keywords.forEach(word => {
372
+ word.x = null;
373
+ word.y = null;
374
+ });
375
+ renderKeywords();
376
+ }
377
+
378
+ async function saveAsImage() {
379
+ const buttons = document.querySelectorAll('button, input');
380
+ buttons.forEach(btn => btn.style.visibility = 'hidden');
381
+
382
+ const note = document.getElementById('userNotes');
383
+ const originalStyles = {
384
+ textAlign: note.style.textAlign,
385
+ fontSize: note.style.fontSize,
386
+ fontWeight: note.style.fontWeight,
387
+ backgroundColor: note.style.backgroundColor,
388
+ border: note.style.border,
389
+ boxShadow: note.style.boxShadow
390
+ };
391
+
392
+ note.style.textAlign = 'center';
393
+ note.style.fontSize = '18px';
394
+ note.style.fontWeight = 'bold';
395
+ note.style.backgroundColor = 'transparent';
396
+ note.style.border = 'none';
397
+ note.style.boxShadow = 'none';
398
+
399
+ try {
400
+ const canvas = await html2canvas(document.querySelector('.w-full.max-w-md'), {
401
+ scale: 2,
402
+ backgroundColor: '#f9fafb',
403
+ useCORS: true,
404
+ logging: false
405
+ });
406
+
407
+ const link = document.createElement('a');
408
+ link.download = `etoile_mots_${new Date().toISOString().split('T')[0]}.png`;
409
+ link.href = canvas.toDataURL('image/png');
410
+ document.body.appendChild(link);
411
+ link.click();
412
+ document.body.removeChild(link);
413
+ } catch (err) {
414
+ console.error("Erreur lors de l'export:", err);
415
+ } finally {
416
+ buttons.forEach(btn => btn.style.visibility = 'visible');
417
+
418
+ Object.keys(originalStyles).forEach(style => {
419
+ note.style[style] = originalStyles[style];
420
+ });
421
+ }
422
+ }
423
+
424
+ async function saveAsPDF() {
425
+ const buttons = document.querySelectorAll('button, input');
426
+ buttons.forEach(btn => btn.style.visibility = 'hidden');
427
+
428
+ const note = document.getElementById('userNotes');
429
+ const originalStyles = {
430
+ textAlign: note.style.textAlign,
431
+ fontSize: note.style.fontSize,
432
+ fontWeight: note.style.fontWeight,
433
+ backgroundColor: note.style.backgroundColor,
434
+ border: note.style.border,
435
+ boxShadow: note.style.boxShadow
436
+ };
437
+
438
+ note.style.textAlign = 'center';
439
+ note.style.fontSize = '18px';
440
+ note.style.fontWeight = 'bold';
441
+ note.style.backgroundColor = 'transparent';
442
+ note.style.border = 'none';
443
+ note.style.boxShadow = 'none';
444
+
445
+ try {
446
+ const canvas = await html2canvas(document.querySelector('.w-full.max-w-md'), {
447
+ scale: 2,
448
+ backgroundColor: '#f9fafb',
449
+ useCORS: true,
450
+ logging: false
451
+ });
452
+
453
+ const imgData = canvas.toDataURL('image/png');
454
+ const pdf = new jsPDF({
455
+ orientation: 'portrait',
456
+ unit: 'mm'
457
+ });
458
+
459
+ const imgWidth = 190;
460
+ const imgHeight = (canvas.height * imgWidth) / canvas.width;
461
+
462
+ pdf.addImage(imgData, 'PNG', 10, 10, imgWidth, imgHeight);
463
+ pdf.save(`etoile_mots_${new Date().toISOString().split('T')[0]}.pdf`);
464
+ } catch (err) {
465
+ console.error("Erreur lors de l'export PDF:", err);
466
+ } finally {
467
+ buttons.forEach(btn => btn.style.visibility = 'visible');
468
+
469
+ Object.keys(originalStyles).forEach(style => {
470
+ note.style[style] = originalStyles[style];
471
+ });
472
+ }
473
+ }
474
+
475
+ // Initialize
476
+ document.addEventListener('DOMContentLoaded', () => {
477
+ renderKeywords();
478
+ });
479
+
480
+ window.addEventListener('resize', () => {
481
+ renderKeywords();
482
+ });
483
+ </script>
484
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=PierreH/star" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
485
  </html>