Docfile commited on
Commit
c62db4e
·
verified ·
1 Parent(s): 099fcfc

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +104 -88
templates/index.html CHANGED
@@ -13,20 +13,12 @@
13
  colors: {
14
  primary: '#4CAF50',
15
  'primary-dark': '#3e8e41',
16
- },
17
- typography: {
18
- DEFAULT: {
19
- css: {
20
- maxWidth: 'none',
21
- },
22
- },
23
- },
24
  }
25
  }
26
  }
27
  </script>
28
  <style>
29
- /* Styles spécifiques pour le Markdown */
30
  .markdown-content {
31
  width: 100%;
32
  overflow-wrap: break-word;
@@ -52,73 +44,78 @@
52
  font-family: ui-monospace, monospace;
53
  }
54
 
55
- .markdown-content p {
56
- margin: 1rem 0;
57
- line-height: 1.7;
58
  }
59
 
60
- .markdown-content h1,
61
- .markdown-content h2,
62
- .markdown-content h3,
63
- .markdown-content h4 {
64
- font-weight: bold;
65
- margin: 1.5rem 0 1rem 0;
66
- line-height: 1.3;
67
- }
68
-
69
- .markdown-content h1 { font-size: 1.875rem; }
70
- .markdown-content h2 { font-size: 1.5rem; }
71
- .markdown-content h3 { font-size: 1.25rem; }
72
- .markdown-content h4 { font-size: 1.125rem; }
73
-
74
- .markdown-content ul,
75
- .markdown-content ol {
76
- margin: 1rem 0;
77
- padding-left: 1.5rem;
78
- }
79
-
80
- .markdown-content ul { list-style-type: disc; }
81
- .markdown-content ol { list-style-type: decimal; }
82
-
83
- .markdown-content li {
84
- margin: 0.5rem 0;
85
- }
86
-
87
- .markdown-content blockquote {
88
- border-left: 4px solid #e5e7eb;
89
- padding-left: 1rem;
90
- margin: 1rem 0;
91
- color: #4b5563;
92
- }
93
-
94
- /* Ajustements pour mobile */
95
- @media (max-width: 640px) {
96
- .markdown-content {
97
- font-size: 0.9375rem;
98
- }
99
-
100
- .markdown-content pre {
101
- padding: 0.75rem;
102
- font-size: 0.875rem;
103
- }
104
-
105
- .markdown-content h1 { font-size: 1.5rem; }
106
- .markdown-content h2 { font-size: 1.25rem; }
107
- .markdown-content h3 { font-size: 1.125rem; }
108
- .markdown-content h4 { font-size: 1rem; }
109
  }
110
  </style>
111
  </head>
112
  <body class="bg-gray-50 min-h-screen">
113
- <!-- [Previous body content remains the same until the results section] -->
 
 
 
 
 
 
 
 
 
114
 
115
- <!-- Results Section with improved Markdown support -->
116
- <div id="results" class="mt-12 bg-white rounded-lg shadow-lg p-6 hidden">
117
- <h2 class="text-2xl font-semibold text-primary mb-4">📝 Résultat de l'analyse</h2>
118
- <div id="analysis-result" class="markdown-content"></div>
119
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
- <!-- [Rest of the body content remains the same until the script section] -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  <script>
124
  document.addEventListener('DOMContentLoaded', () => {
@@ -130,39 +127,62 @@
130
 
131
  let uploadedFiles = [];
132
 
133
- // Configure marked options for better Markdown rendering
134
- marked.setOptions({
135
- breaks: true, // Enable line breaks
136
- gfm: true, // Enable GitHub Flavored Markdown
137
- headerIds: false, // Disable header IDs to prevent conflicts
138
- mangle: false, // Disable mangling to prevent emoji issues
139
- smartLists: true, // Enable smart lists
140
- smartypants: true, // Enable smart punctuation
141
- xhtml: true // Enable XHTML output
142
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
- // [Previous event listeners and functions remain the same]
 
 
 
145
 
146
  async function handleSubmit() {
147
- const formData = new FormData();
148
- const analysisType = document.querySelector('input[name="analysis_type"]:checked')?.value;
 
 
149
 
150
- if (!analysisType || uploadedFiles.length === 0) {
151
- alert('Veuillez sélectionner un type d\'analyse et au moins une image.');
 
152
  return;
153
  }
154
 
 
155
  formData.append('analysis_type', analysisType);
156
  uploadedFiles.forEach(file => formData.append('images', file));
157
 
158
  submitBtn.disabled = true;
159
- submitBtn.innerHTML = 'Analyse en cours...';
160
 
161
  try {
162
  const response = await fetch('/analyze', {
163
  method: 'POST',
164
  body: formData
165
  });
 
166
  const data = await response.json();
167
 
168
  if (data.error) {
@@ -170,10 +190,7 @@
170
  }
171
 
172
  resultsSection.classList.remove('hidden');
173
- // Convert Markdown to HTML with proper spacing
174
  analysisResult.innerHTML = marked.parse(data.result);
175
-
176
- // Scroll to results
177
  resultsSection.scrollIntoView({ behavior: 'smooth' });
178
  } catch (error) {
179
  alert('Erreur lors de l\'analyse: ' + error.message);
@@ -183,7 +200,6 @@
183
  }
184
  }
185
 
186
- // Make removeImage function global
187
  window.removeImage = removeImage;
188
  });
189
  </script>
 
13
  colors: {
14
  primary: '#4CAF50',
15
  'primary-dark': '#3e8e41',
16
+ }
 
 
 
 
 
 
 
17
  }
18
  }
19
  }
20
  </script>
21
  <style>
 
22
  .markdown-content {
23
  width: 100%;
24
  overflow-wrap: break-word;
 
44
  font-family: ui-monospace, monospace;
45
  }
46
 
47
+ @keyframes fadeIn {
48
+ from { opacity: 0; }
49
+ to { opacity: 1; }
50
  }
51
 
52
+ .animate-fade-in {
53
+ animation: fadeIn 1s ease-out;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
  </style>
56
  </head>
57
  <body class="bg-gray-50 min-h-screen">
58
+ <div class="container mx-auto px-4 py-8 max-w-6xl">
59
+ <!-- Header -->
60
+ <header class="text-center mb-12 animate-fade-in">
61
+ <h1 class="text-5xl font-bold text-primary mb-4">
62
+ ✨ Mariam Anglais ✨
63
+ </h1>
64
+ <p class="text-gray-600 text-lg">
65
+ Bienvenue ! Téléchargez vos images, choisissez votre type d'analyse, et laissez la magie opérer.
66
+ </p>
67
+ </header>
68
 
69
+ <!-- Main Content -->
70
+ <div class="grid md:grid-cols-2 gap-8">
71
+ <!-- Upload Section -->
72
+ <div class="bg-white rounded-xl shadow-lg p-6">
73
+ <h2 class="text-2xl font-semibold text-primary mb-4">📷 Téléchargement d'images</h2>
74
+ <div
75
+ class="upload-zone border-2 border-dashed border-primary rounded-lg p-8 text-center cursor-pointer hover:bg-gray-50 transition-colors"
76
+ onclick="document.getElementById('image-upload').click()">
77
+ <input type="file" id="image-upload" multiple accept="image/*" class="hidden">
78
+ <div class="flex flex-col items-center">
79
+ <svg class="h-12 w-12 text-primary mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
80
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
81
+ </svg>
82
+ <span class="text-gray-600">Cliquez ou glissez vos images ici</span>
83
+ </div>
84
+ </div>
85
+ <div id="preview-container" class="mt-4 grid grid-cols-2 gap-4"></div>
86
+ </div>
87
 
88
+ <!-- Analysis Type Section -->
89
+ <div class="bg-white rounded-xl shadow-lg p-6">
90
+ <h2 class="text-2xl font-semibold text-primary mb-4">🎛️ Choix du type d'analyse</h2>
91
+ <div class="space-y-4">
92
+ <label class="flex items-center p-4 rounded-lg border border-gray-200 cursor-pointer hover:bg-gray-50 transition-colors">
93
+ <input type="radio" name="analysis_type" value="text" class="h-4 w-4 text-primary">
94
+ <span class="ml-3">🔍 Type 1: Analyse de Texte</span>
95
+ </label>
96
+ <label class="flex items-center p-4 rounded-lg border border-gray-200 cursor-pointer hover:bg-gray-50 transition-colors">
97
+ <input type="radio" name="analysis_type" value="icon" class="h-4 w-4 text-primary">
98
+ <span class="ml-3">🧠 Type 2: Document iconographique</span>
99
+ </label>
100
+ </div>
101
+ <button id="submit-btn" class="w-full mt-6 bg-primary hover:bg-primary-dark text-white font-bold py-3 px-6 rounded-lg transition-all transform hover:-translate-y-1 hover:shadow-lg disabled:opacity-50 disabled:cursor-not-allowed">
102
+ 🚀 Soumettre
103
+ </button>
104
+ </div>
105
+ </div>
106
+
107
+ <!-- Results Section -->
108
+ <div id="results" class="mt-12 bg-white rounded-xl shadow-lg p-6 hidden">
109
+ <h2 class="text-2xl font-semibold text-primary mb-4">📝 Résultat de l'analyse</h2>
110
+ <div id="analysis-result" class="markdown-content prose max-w-none"></div>
111
+ </div>
112
+
113
+ <!-- Footer -->
114
+ <footer class="mt-12 text-center text-gray-600">
115
+ <hr class="my-4">
116
+ <p>© 2025 Mariam AI - Tous droits réservés.</p>
117
+ </footer>
118
+ </div>
119
 
120
  <script>
121
  document.addEventListener('DOMContentLoaded', () => {
 
127
 
128
  let uploadedFiles = [];
129
 
130
+ imageUpload.addEventListener('change', handleFileSelect);
131
+ submitBtn.addEventListener('click', handleSubmit);
132
+
133
+ function handleFileSelect(event) {
134
+ uploadedFiles = Array.from(event.target.files);
135
+ updatePreview();
136
+ }
137
+
138
+ function updatePreview() {
139
+ previewContainer.innerHTML = '';
140
+ uploadedFiles.forEach((file, index) => {
141
+ const preview = document.createElement('div');
142
+ preview.className = 'relative';
143
+ preview.innerHTML = `
144
+ <img src="${URL.createObjectURL(file)}" alt="Preview" class="w-full h-32 object-cover rounded-lg">
145
+ <button onclick="removeImage(${index})" class="absolute top-2 right-2 bg-red-500 text-white rounded-full p-1 hover:bg-red-600">
146
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
147
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
148
+ </svg>
149
+ </button>
150
+ `;
151
+ previewContainer.appendChild(preview);
152
+ });
153
+ submitBtn.disabled = uploadedFiles.length === 0;
154
+ }
155
 
156
+ function removeImage(index) {
157
+ uploadedFiles.splice(index, 1);
158
+ updatePreview();
159
+ }
160
 
161
  async function handleSubmit() {
162
+ if (uploadedFiles.length === 0) {
163
+ alert('Veuillez sélectionner au moins une image.');
164
+ return;
165
+ }
166
 
167
+ const analysisType = document.querySelector('input[name="analysis_type"]:checked')?.value;
168
+ if (!analysisType) {
169
+ alert('Veuillez sélectionner un type d\'analyse.');
170
  return;
171
  }
172
 
173
+ const formData = new FormData();
174
  formData.append('analysis_type', analysisType);
175
  uploadedFiles.forEach(file => formData.append('images', file));
176
 
177
  submitBtn.disabled = true;
178
+ submitBtn.innerHTML = '<span class="animate-pulse">Analyse en cours...</span>';
179
 
180
  try {
181
  const response = await fetch('/analyze', {
182
  method: 'POST',
183
  body: formData
184
  });
185
+
186
  const data = await response.json();
187
 
188
  if (data.error) {
 
190
  }
191
 
192
  resultsSection.classList.remove('hidden');
 
193
  analysisResult.innerHTML = marked.parse(data.result);
 
 
194
  resultsSection.scrollIntoView({ behavior: 'smooth' });
195
  } catch (error) {
196
  alert('Erreur lors de l\'analyse: ' + error.message);
 
200
  }
201
  }
202
 
 
203
  window.removeImage = removeImage;
204
  });
205
  </script>