Docfile commited on
Commit
b734db3
·
verified ·
1 Parent(s): 2451ccd

Update templates/generale.html

Browse files
Files changed (1) hide show
  1. templates/generale.html +81 -133
templates/generale.html CHANGED
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html>
2
  <html lang="fr">
3
 
4
  <head>
@@ -6,22 +6,16 @@
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
  <title>Question Générale</title>
8
  <script src="https://cdn.tailwindcss.com"></script>
9
- <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js"></script>
10
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
11
- <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
12
- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
13
- <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script>
14
  <script>
15
  MathJax = {
16
  tex: {
17
- inlineMath: [
18
- ['$', '$'],
19
- ['\\(', '\\)']
20
- ],
21
- displayMath: [
22
- ['$$', '$$'],
23
- ['\\[', '\\]']
24
- ],
25
  processEscapes: true
26
  },
27
  options: {
@@ -36,13 +30,13 @@
36
  }
37
  };
38
  </script>
39
- <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
40
  <style>
41
  .animated-button {
42
  background-image: linear-gradient(to right, #4facfe, #00f2fe);
 
43
  box-shadow: 0 4px 15px 0 rgba(65, 132, 234, 0.75);
44
  transition: background-position 0.3s ease-in-out, transform 0.2s ease-in-out, box-shadow 0.3s ease-in-out;
45
- background-size: 200% auto;
46
  }
47
 
48
  .animated-button:hover {
@@ -60,63 +54,57 @@
60
  }
61
 
62
  .input-underline:focus {
63
- outline: none;
64
  background-size: 100% 2px;
65
  }
 
 
 
 
 
66
  </style>
67
  </head>
68
 
69
- <body class="bg-gradient-to-r from-gray-100 to-gray-200 min-h-screen flex items-center justify-center font-sans overflow-x-hidden">
70
- <div class="container mx-auto p-8 bg-white rounded-3xl shadow-2xl max-w-3xl transform transition-all duration-500 ease-in-out hover:scale-102">
71
  <div class="flex justify-between items-center mb-6">
72
  <h1 class="text-3xl font-bold text-gray-800">Poser une question générale</h1>
73
- <button onclick="showInfo()"
74
- class="animated-button text-white px-4 py-2 rounded-lg transition duration-300 flex items-center">
75
  <i class="fas fa-info-circle mr-2"></i>Info
76
  </button>
77
  </div>
78
 
79
  <div class="mb-6">
80
  <label for="questionInput" class="block mb-2 text-lg font-medium text-gray-700">Votre question :</label>
81
- <textarea id="questionInput"
82
- class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-400 input-underline transition duration-200"
83
- rows="4" placeholder="Entrez votre question ici..."></textarea>
84
  </div>
85
 
86
  <div class="mb-6">
87
  <label for="urlInput" class="block mb-2 text-lg font-medium text-gray-700">URLs (optionnel) :</label>
88
  <div class="flex">
89
- <input type="text" id="urlInput"
90
- class="flex-grow p-3 border border-gray-300 rounded-l-lg focus:ring-2 focus:ring-blue-400 input-underline transition duration-200"
91
- placeholder="Entrez une URL">
92
- <button onclick="addUrl()"
93
- class="animated-button text-white px-4 py-2 rounded-r-lg transition duration-300">Ajouter</button>
94
  </div>
95
- <div id="urlList" class="mt-2"></div>
96
  </div>
97
 
98
  <div class="mb-6">
99
  <label for="fileUpload" class="block mb-2 text-lg font-medium text-gray-700">Fichiers (optionnel) :</label>
100
- <input type="file" id="fileUpload"
101
- class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-400 input-underline transition duration-200"
102
- multiple>
103
  </div>
104
 
105
- <button onclick="submitQuestion()"
106
- class="animated-button w-full text-white px-4 py-3 rounded-lg transition duration-300 text-lg font-medium">Soumettre</button>
107
 
108
- <div id="loader" class="hidden mt-4 text-center">
109
  <div class="flex justify-center items-center">
110
  <div class="animate-spin rounded-full h-12 w-12 border-t-4 border-b-4 border-blue-500"></div>
111
  <p class="ml-2 text-gray-600">Chargement en cours...</p>
112
  </div>
113
  </div>
114
 
115
- <div id="response" class="mt-6 p-4 bg-gray-100 rounded-lg shadow-lg opacity-0 transform translate-y-4"></div>
116
 
117
  <div id="copyResponseContainer" class="hidden mt-4">
118
- <button onclick="copyResponse()"
119
- class="animated-button w-full text-white px-4 py-2 rounded-lg transition duration-300 flex items-center justify-center">
120
  <i class="fas fa-copy mr-2"></i>Copier la réponse
121
  </button>
122
  </div>
@@ -144,127 +132,87 @@
144
 
145
  if (url) {
146
  const urlItem = document.createElement('div');
147
- urlItem.className = 'url-item flex items-center mt-2 bg-gray-200 p-2 rounded-lg shadow-sm transform transition-all duration-300 ease-in-out hover:scale-105';
148
  urlItem.innerHTML = `
149
  <span class="flex-grow truncate">${url}</span>
150
- <button onclick="removeUrl(this)" class="ml-2 text-red-500 hover:text-red-700 transition duration-300">
151
  <i class="fas fa-times"></i>
152
  </button>
153
  `;
154
  urlList.appendChild(urlItem);
155
  urlInput.value = '';
156
- anime({
157
- targets: urlItem,
158
- opacity: [0, 1],
159
- translateY: [-10, 0],
160
- duration: 300,
161
- easing: 'easeOutExpo'
162
- });
163
  }
164
  }
165
 
166
  function removeUrl(button) {
167
- const urlItem = button.parentElement;
168
- anime({
169
- targets: urlItem,
170
- opacity: [1, 0],
171
- translateY: -10,
172
- duration: 300,
173
- easing: 'easeInExpo',
174
- complete: function (anim) {
175
- urlItem.remove();
176
- }
177
- });
178
  }
179
 
180
- function submitQuestion() {
181
- const question = document.getElementById('questionInput').value;
182
- if (question.trim()) {
183
- const loader = document.getElementById('loader');
184
- const responseDiv = document.getElementById('response');
185
- const copyResponseContainer = document.getElementById('copyResponseContainer');
186
 
187
- loader.classList.remove('hidden');
188
- responseDiv.style.opacity = 0;
189
- responseDiv.style.transform = 'translateY(40px)';
190
- copyResponseContainer.classList.add('hidden');
191
 
192
- const formData = new FormData();
193
- formData.append('question', question);
 
 
194
 
195
- document.querySelectorAll('.url-item').forEach(item => {
196
- formData.append('urls', item.querySelector('span').textContent);
197
- });
198
 
199
- Array.from(document.getElementById('fileUpload').files).forEach(file => {
200
- formData.append('files', file);
201
- });
202
 
203
- fetch('/submit', {
 
 
 
 
 
204
  method: 'POST',
205
  body: formData
206
- })
207
- .then(response => response.json())
208
- .then(data => {
209
- loader.classList.add('hidden');
210
- if (data.error) {
211
- responseDiv.innerHTML = `<p class="text-red-600">Erreur : ${data.error}</p>`;
212
- } else {
213
- const htmlContent = marked.parse(data.response);
214
- responseDiv.innerHTML = htmlContent;
215
- copyResponseContainer.classList.remove('hidden');
216
 
217
- MathJax.typesetPromise([responseDiv]).then(() => {
218
- console.log('LaTeX rendu avec succès');
219
- anime({
220
- targets: responseDiv,
221
- opacity: [0, 1],
222
- translateY: [40, 0],
223
- duration: 500,
224
- easing: 'easeOutExpo'
225
- });
226
- }).catch((err) => {
227
- console.error('Erreur lors du rendu LaTeX:', err);
228
- responseDiv.innerHTML = `<p class="text-red-600">Erreur lors du rendu LaTeX. Vérifiez votre syntaxe.</p>`;
229
- anime({
230
- targets: responseDiv,
231
- opacity: [0, 1],
232
- translateY: [40, 0],
233
- duration: 500,
234
- easing: 'easeOutExpo'
235
- });
236
- });
237
- }
238
- })
239
- .catch(error => {
240
- loader.classList.add('hidden');
241
- responseDiv.innerHTML = `<p class="text-red-600">Erreur : ${error.message}</p>`;
242
- anime({
243
- targets: responseDiv,
244
- opacity: [0, 1],
245
- translateY: [40, 0],
246
- duration: 500,
247
- easing: 'easeOutExpo'
248
- });
249
- });
250
  }
251
  }
252
 
253
  function copyResponse() {
254
  const responseDiv = document.getElementById('response');
255
- const range = document.createRange();
256
- range.selectNode(responseDiv);
257
- window.getSelection().removeAllRanges();
258
- window.getSelection().addRange(range);
259
- document.execCommand('copy');
260
- window.getSelection().removeAllRanges();
261
-
262
- Swal.fire({
263
- icon: 'success',
264
- title: 'Copié !',
265
- text: 'La réponse a été copiée dans le presse-papiers.',
266
- showConfirmButton: false,
267
- timer: 1500
268
  });
269
  }
270
  </script>
 
1
+ <!DOCTYPE html>
2
  <html lang="fr">
3
 
4
  <head>
 
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
  <title>Question Générale</title>
8
  <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js" defer></script>
10
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
11
+ <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11" defer></script>
12
+ <script src="https://polyfill.io/v3/polyfill.min.js?features=es6" defer></script>
13
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" defer></script>
14
  <script>
15
  MathJax = {
16
  tex: {
17
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
18
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
 
 
 
 
 
 
19
  processEscapes: true
20
  },
21
  options: {
 
30
  }
31
  };
32
  </script>
33
+ <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" defer></script>
34
  <style>
35
  .animated-button {
36
  background-image: linear-gradient(to right, #4facfe, #00f2fe);
37
+ background-size: 200% auto;
38
  box-shadow: 0 4px 15px 0 rgba(65, 132, 234, 0.75);
39
  transition: background-position 0.3s ease-in-out, transform 0.2s ease-in-out, box-shadow 0.3s ease-in-out;
 
40
  }
41
 
42
  .animated-button:hover {
 
54
  }
55
 
56
  .input-underline:focus {
 
57
  background-size: 100% 2px;
58
  }
59
+
60
+ #response {
61
+ overflow-x: auto;
62
+ white-space: pre-wrap;
63
+ }
64
  </style>
65
  </head>
66
 
67
+ <body class="bg-gradient-to-r from-gray-100 to-gray-200 min-h-screen flex items-center justify-center font-sans">
68
+ <div class="container mx-auto p-8 bg-white rounded-3xl shadow-2xl max-w-3xl">
69
  <div class="flex justify-between items-center mb-6">
70
  <h1 class="text-3xl font-bold text-gray-800">Poser une question générale</h1>
71
+ <button onclick="showInfo()" class="animated-button text-white px-4 py-2 rounded-lg flex items-center">
 
72
  <i class="fas fa-info-circle mr-2"></i>Info
73
  </button>
74
  </div>
75
 
76
  <div class="mb-6">
77
  <label for="questionInput" class="block mb-2 text-lg font-medium text-gray-700">Votre question :</label>
78
+ <textarea id="questionInput" class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-400 input-underline" rows="4" placeholder="Entrez votre question ici..."></textarea>
 
 
79
  </div>
80
 
81
  <div class="mb-6">
82
  <label for="urlInput" class="block mb-2 text-lg font-medium text-gray-700">URLs (optionnel) :</label>
83
  <div class="flex">
84
+ <input type="text" id="urlInput" class="flex-grow p-3 border border-gray-300 rounded-l-lg focus:ring-2 focus:ring-blue-400 input-underline" placeholder="Entrez une URL">
85
+ <button onclick="addUrl()" class="animated-button text-white px-4 py-2 rounded-r-lg">Ajouter</button>
 
 
 
86
  </div>
87
+ <div id="urlList" class="mt-2 space-y-2"></div>
88
  </div>
89
 
90
  <div class="mb-6">
91
  <label for="fileUpload" class="block mb-2 text-lg font-medium text-gray-700">Fichiers (optionnel) :</label>
92
+ <input type="file" id="fileUpload" class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-400 input-underline" multiple>
 
 
93
  </div>
94
 
95
+ <button onclick="submitQuestion()" class="animated-button w-full text-white px-4 py-3 rounded-lg text-lg font-medium">Soumettre</button>
 
96
 
97
+ <div id="loader" class="hidden mt-4">
98
  <div class="flex justify-center items-center">
99
  <div class="animate-spin rounded-full h-12 w-12 border-t-4 border-b-4 border-blue-500"></div>
100
  <p class="ml-2 text-gray-600">Chargement en cours...</p>
101
  </div>
102
  </div>
103
 
104
+ <div id="response" class="mt-6 p-4 bg-gray-100 rounded-lg shadow-lg"></div>
105
 
106
  <div id="copyResponseContainer" class="hidden mt-4">
107
+ <button onclick="copyResponse()" class="animated-button w-full text-white px-4 py-2 rounded-lg flex items-center justify-center">
 
108
  <i class="fas fa-copy mr-2"></i>Copier la réponse
109
  </button>
110
  </div>
 
132
 
133
  if (url) {
134
  const urlItem = document.createElement('div');
135
+ urlItem.className = 'flex items-center bg-gray-200 p-2 rounded-lg shadow-sm';
136
  urlItem.innerHTML = `
137
  <span class="flex-grow truncate">${url}</span>
138
+ <button onclick="removeUrl(this)" class="ml-2 text-red-500 hover:text-red-700">
139
  <i class="fas fa-times"></i>
140
  </button>
141
  `;
142
  urlList.appendChild(urlItem);
143
  urlInput.value = '';
 
 
 
 
 
 
 
144
  }
145
  }
146
 
147
  function removeUrl(button) {
148
+ const urlItem = button.closest('.url-item');
149
+ urlItem.remove();
 
 
 
 
 
 
 
 
 
150
  }
151
 
152
+ async function submitQuestion() {
153
+ const question = document.getElementById('questionInput').value.trim();
154
+ if (!question) return;
 
 
 
155
 
156
+ const loader = document.getElementById('loader');
157
+ const responseDiv = document.getElementById('response');
158
+ const copyResponseContainer = document.getElementById('copyResponseContainer');
 
159
 
160
+ loader.classList.remove('hidden');
161
+ responseDiv.innerHTML = '';
162
+ responseDiv.classList.add('opacity-0');
163
+ copyResponseContainer.classList.add('hidden');
164
 
165
+ const formData = new FormData();
166
+ formData.append('question', question);
 
167
 
168
+ document.querySelectorAll('#urlList .url-item').forEach(item => {
169
+ formData.append('urls', item.querySelector('span').textContent);
170
+ });
171
 
172
+ Array.from(document.getElementById('fileUpload').files).forEach(file => {
173
+ formData.append('files', file);
174
+ });
175
+
176
+ try {
177
+ const response = await fetch('/submit', {
178
  method: 'POST',
179
  body: formData
180
+ });
181
+ const data = await response.json();
 
 
 
 
 
 
 
 
182
 
183
+ loader.classList.add('hidden');
184
+ responseDiv.classList.remove('opacity-0');
185
+
186
+ if (data.error) {
187
+ responseDiv.innerHTML = `<p class="text-red-600">Erreur : ${data.error}</p>`;
188
+ } else {
189
+ const htmlContent = marked.parse(data.response);
190
+ responseDiv.innerHTML = htmlContent;
191
+ copyResponseContainer.classList.remove('hidden');
192
+
193
+ await MathJax.typesetPromise([responseDiv]);
194
+ console.log('LaTeX rendu avec succès');
195
+ }
196
+ } catch (error) {
197
+ loader.classList.add('hidden');
198
+ responseDiv.innerHTML = `<p class="text-red-600">Erreur : ${error.message}</p>`;
199
+ responseDiv.classList.remove('opacity-0');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
201
  }
202
 
203
  function copyResponse() {
204
  const responseDiv = document.getElementById('response');
205
+ const text = responseDiv.innerText;
206
+ navigator.clipboard.writeText(text).then(() => {
207
+ Swal.fire({
208
+ icon: 'success',
209
+ title: 'Copié !',
210
+ text: 'La réponse a été copiée dans le presse-papiers.',
211
+ showConfirmButton: false,
212
+ timer: 1500
213
+ });
214
+ }).catch(err => {
215
+ console.error('Erreur lors de la copie:', err);
 
 
216
  });
217
  }
218
  </script>