PierreH commited on
Commit
83ee0e3
·
verified ·
1 Parent(s): 6eb3f7c

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +457 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Star
3
- emoji: 😻
4
  colorFrom: green
5
- colorTo: gray
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: star
3
+ emoji: 🐳
4
  colorFrom: green
5
+ colorTo: green
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,457 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </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: pointer;
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 labelWidth = word.text.length * 8 + 16;
182
+ const labelHeight = 24;
183
+
184
+ // Calculate position if not set
185
+ if (word.x === null || word.y === null) {
186
+ const angleStep = (2 * Math.PI) / keywords.length;
187
+ const angle = index * angleStep - Math.PI / 2;
188
+ word.x = centerX + radius * Math.cos(angle) - labelWidth / 2;
189
+ word.y = centerY + radius * Math.sin(angle) - labelHeight / 2;
190
+ }
191
+
192
+ const label = document.createElement('div');
193
+ label.className = 'label draggable';
194
+ label.style.left = `${word.x}px`;
195
+ label.style.top = `${word.y}px`;
196
+ label.textContent = word.text;
197
+ label.dataset.index = index;
198
+
199
+ label.addEventListener('mousedown', (e) => {
200
+ startDrag(e, label, index);
201
+ });
202
+
203
+ if (index === selectedKeywordIndex) {
204
+ label.classList.add('selected');
205
+ }
206
+
207
+ container.appendChild(label);
208
+ });
209
+
210
+ resizeCanvas();
211
+ }
212
+
213
+ function startDrag(e, label, index) {
214
+ isDragging = true;
215
+ draggedLabel = label;
216
+ draggedIndex = index;
217
+ dragStartX = e.clientX - parseFloat(label.style.left);
218
+ dragStartY = e.clientY - parseFloat(label.style.top);
219
+
220
+ // Select the label being dragged
221
+ selectKeyword(index);
222
+
223
+ document.addEventListener('mousemove', drag);
224
+ document.addEventListener('mouseup', stopDrag);
225
+
226
+ e.preventDefault();
227
+ }
228
+
229
+ function drag(e) {
230
+ if (!isDragging) return;
231
+
232
+ const container = document.getElementById('target-container');
233
+ const containerRect = container.getBoundingClientRect();
234
+
235
+ // Calculate new position
236
+ let newX = e.clientX - dragStartX;
237
+ let newY = e.clientY - dragStartY;
238
+
239
+ // Constrain to container bounds
240
+ newX = Math.max(0, Math.min(newX, container.offsetWidth - draggedLabel.offsetWidth));
241
+ newY = Math.max(0, Math.min(newY, container.offsetHeight - draggedLabel.offsetHeight));
242
+
243
+ draggedLabel.style.left = `${newX}px`;
244
+ draggedLabel.style.top = `${newY}px`;
245
+
246
+ // Update keyword position
247
+ keywords[draggedIndex].x = newX;
248
+ keywords[draggedIndex].y = newY;
249
+
250
+ resizeCanvas();
251
+ }
252
+
253
+ function stopDrag() {
254
+ isDragging = false;
255
+ draggedLabel = null;
256
+ draggedIndex = null;
257
+
258
+ document.removeEventListener('mousemove', drag);
259
+ document.removeEventListener('mouseup', stopDrag);
260
+ }
261
+
262
+ function selectKeyword(index) {
263
+ selectedKeywordIndex = index;
264
+ document.getElementById('editKeyword').value = keywords[index].text;
265
+
266
+ // Update UI
267
+ document.querySelectorAll('.label').forEach(label => {
268
+ label.classList.remove('selected');
269
+ });
270
+
271
+ const selectedLabel = document.querySelector(`.label[data-index='${index}']`);
272
+ if (selectedLabel) {
273
+ selectedLabel.classList.add('selected');
274
+ }
275
+ }
276
+
277
+ function resizeCanvas() {
278
+ const container = document.getElementById('target-container');
279
+ canvas.width = container.offsetWidth;
280
+ canvas.height = container.offsetHeight;
281
+ drawLines();
282
+ }
283
+
284
+ function drawLines() {
285
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
286
+
287
+ if (keywords.length < 2) return;
288
+
289
+ ctx.beginPath();
290
+ ctx.strokeStyle = '#3b82f6';
291
+ ctx.lineWidth = 1;
292
+ ctx.setLineDash([5, 3]);
293
+
294
+ const positions = keywords.map(k => {
295
+ return {
296
+ x: k.x + (document.querySelector(`.label[data-index='${keywords.indexOf(k)}']`)?.offsetWidth / 2 || 0),
297
+ y: k.y + (document.querySelector(`.label[data-index='${keywords.indexOf(k)}']`)?.offsetHeight / 2 || 0)
298
+ };
299
+ });
300
+
301
+ // Draw connecting lines
302
+ for (let i = 0; i < positions.length; i++) {
303
+ const next = positions[(i + 1) % positions.length];
304
+ ctx.moveTo(positions[i].x, positions[i].y);
305
+ ctx.lineTo(next.x, next.y);
306
+ }
307
+
308
+ ctx.stroke();
309
+ }
310
+
311
+ function addKeyword() {
312
+ const input = document.getElementById('newKeyword');
313
+ const text = input.value.trim();
314
+
315
+ if (text) {
316
+ keywords.push({ text: text, x: null, y: null });
317
+ input.value = '';
318
+ renderKeywords();
319
+ }
320
+ }
321
+
322
+ function updateKeyword() {
323
+ const input = document.getElementById('editKeyword');
324
+ const text = input.value.trim();
325
+
326
+ if (text && selectedKeywordIndex !== null) {
327
+ keywords[selectedKeywordIndex].text = text;
328
+ renderKeywords();
329
+ selectKeyword(selectedKeywordIndex);
330
+ }
331
+ }
332
+
333
+ function deleteKeyword() {
334
+ if (selectedKeywordIndex !== null) {
335
+ keywords.splice(selectedKeywordIndex, 1);
336
+ selectedKeywordIndex = null;
337
+ document.getElementById('editKeyword').value = '';
338
+ renderKeywords();
339
+ }
340
+ }
341
+
342
+ function resetKeywords() {
343
+ keywords.forEach(word => {
344
+ word.x = null;
345
+ word.y = null;
346
+ });
347
+ renderKeywords();
348
+ }
349
+
350
+ async function saveAsImage() {
351
+ const buttons = document.querySelectorAll('button, input');
352
+ buttons.forEach(btn => btn.style.visibility = 'hidden');
353
+
354
+ const note = document.getElementById('userNotes');
355
+ const originalStyles = {
356
+ textAlign: note.style.textAlign,
357
+ fontSize: note.style.fontSize,
358
+ fontWeight: note.style.fontWeight,
359
+ backgroundColor: note.style.backgroundColor,
360
+ border: note.style.border,
361
+ boxShadow: note.style.boxShadow
362
+ };
363
+
364
+ note.style.textAlign = 'center';
365
+ note.style.fontSize = '18px';
366
+ note.style.fontWeight = 'bold';
367
+ note.style.backgroundColor = 'transparent';
368
+ note.style.border = 'none';
369
+ note.style.boxShadow = 'none';
370
+
371
+ try {
372
+ const canvas = await html2canvas(document.querySelector('.w-full.max-w-md'), {
373
+ scale: 2,
374
+ backgroundColor: '#f9fafb',
375
+ useCORS: true,
376
+ logging: false
377
+ });
378
+
379
+ const link = document.createElement('a');
380
+ link.download = `etoile_mots_${new Date().toISOString().split('T')[0]}.png`;
381
+ link.href = canvas.toDataURL('image/png');
382
+ document.body.appendChild(link);
383
+ link.click();
384
+ document.body.removeChild(link);
385
+ } catch (err) {
386
+ console.error("Erreur lors de l'export:", err);
387
+ } finally {
388
+ buttons.forEach(btn => btn.style.visibility = 'visible');
389
+
390
+ Object.keys(originalStyles).forEach(style => {
391
+ note.style[style] = originalStyles[style];
392
+ });
393
+ }
394
+ }
395
+
396
+ async function saveAsPDF() {
397
+ const buttons = document.querySelectorAll('button, input');
398
+ buttons.forEach(btn => btn.style.visibility = 'hidden');
399
+
400
+ const note = document.getElementById('userNotes');
401
+ const originalStyles = {
402
+ textAlign: note.style.textAlign,
403
+ fontSize: note.style.fontSize,
404
+ fontWeight: note.style.fontWeight,
405
+ backgroundColor: note.style.backgroundColor,
406
+ border: note.style.border,
407
+ boxShadow: note.style.boxShadow
408
+ };
409
+
410
+ note.style.textAlign = 'center';
411
+ note.style.fontSize = '18px';
412
+ note.style.fontWeight = 'bold';
413
+ note.style.backgroundColor = 'transparent';
414
+ note.style.border = 'none';
415
+ note.style.boxShadow = 'none';
416
+
417
+ try {
418
+ const canvas = await html2canvas(document.querySelector('.w-full.max-w-md'), {
419
+ scale: 2,
420
+ backgroundColor: '#f9fafb',
421
+ useCORS: true,
422
+ logging: false
423
+ });
424
+
425
+ const imgData = canvas.toDataURL('image/png');
426
+ const pdf = new jsPDF({
427
+ orientation: 'portrait',
428
+ unit: 'mm'
429
+ });
430
+
431
+ const imgWidth = 190;
432
+ const imgHeight = (canvas.height * imgWidth) / canvas.width;
433
+
434
+ pdf.addImage(imgData, 'PNG', 10, 10, imgWidth, imgHeight);
435
+ pdf.save(`etoile_mots_${new Date().toISOString().split('T')[0]}.pdf`);
436
+ } catch (err) {
437
+ console.error("Erreur lors de l'export PDF:", err);
438
+ } finally {
439
+ buttons.forEach(btn => btn.style.visibility = 'visible');
440
+
441
+ Object.keys(originalStyles).forEach(style => {
442
+ note.style[style] = originalStyles[style];
443
+ });
444
+ }
445
+ }
446
+
447
+ // Initialize
448
+ document.addEventListener('DOMContentLoaded', () => {
449
+ renderKeywords();
450
+ });
451
+
452
+ window.addEventListener('resize', () => {
453
+ renderKeywords();
454
+ });
455
+ </script>
456
+ <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>
457
+ </html>