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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fr">
|
| 3 |
+
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 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: {
|
| 28 |
+
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
|
| 29 |
+
},
|
| 30 |
+
startup: {
|
| 31 |
+
pageReady: () => {
|
| 32 |
+
return MathJax.startup.defaultPageReady().then(() => {
|
| 33 |
+
console.log('MathJax initial typesetting complete');
|
| 34 |
+
});
|
| 35 |
+
}
|
| 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 {
|
| 49 |
+
background-position: right center;
|
| 50 |
+
transform: translateY(-2px);
|
| 51 |
+
box-shadow: 0 6px 20px 0 rgba(65, 132, 234, 0.9);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.input-underline {
|
| 55 |
+
background-image: linear-gradient(to right, #4facfe, #00f2fe);
|
| 56 |
+
background-size: 0% 2px;
|
| 57 |
+
background-repeat: no-repeat;
|
| 58 |
+
background-position: left bottom;
|
| 59 |
+
transition: background-size 0.3s ease;
|
| 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>
|
| 123 |
+
</div>
|
| 124 |
+
|
| 125 |
+
<script>
|
| 126 |
+
function showInfo() {
|
| 127 |
+
Swal.fire({
|
| 128 |
+
title: 'Information',
|
| 129 |
+
html: `
|
| 130 |
+
<p class="mb-2">Ce formulaire vous permet de poser des questions générales.</p>
|
| 131 |
+
<p class="mb-2">Vous pouvez également ajouter des URLs et des fichiers pour fournir plus de contexte à votre question.</p>
|
| 132 |
+
<p>La réponse sera formatée en Markdown et peut inclure des équations LaTeX.</p>
|
| 133 |
+
<p class="mb-2">Et si vous avez le courage de résoudre vos exos de math ici, veuillez signaler à Mariam de répondre en utilisant du LaTeX.</p>
|
| 134 |
+
`,
|
| 135 |
+
icon: 'info',
|
| 136 |
+
confirmButtonText: 'Compris'
|
| 137 |
+
});
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
function addUrl() {
|
| 141 |
+
const urlInput = document.getElementById('urlInput');
|
| 142 |
+
const urlList = document.getElementById('urlList');
|
| 143 |
+
const url = urlInput.value.trim();
|
| 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>
|
| 271 |
+
</body>
|
| 272 |
+
|
| 273 |
+
</html>
|