Spaces:
Running
Running
Update static/script.js
Browse files- static/script.js +25 -114
static/script.js
CHANGED
|
@@ -14,7 +14,7 @@ function loadResumerPage() {
|
|
| 14 |
appContainer.innerHTML = `
|
| 15 |
<div class="sidebar">
|
| 16 |
<div class="logo-container">
|
| 17 |
-
<div class="logo-top">
|
| 18 |
<div class="logo-bottom">AI</div>
|
| 19 |
</div>
|
| 20 |
<a href="principal.html" class="home-link">
|
|
@@ -115,41 +115,15 @@ function loadResumerPage() {
|
|
| 115 |
return;
|
| 116 |
}
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
cursor: pointer;
|
| 128 |
-
font-size: 14px;
|
| 129 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 130 |
-
transition: transform 0.2s;
|
| 131 |
-
">
|
| 132 |
-
🔊 Listen to Summary
|
| 133 |
-
</button>
|
| 134 |
-
</div>
|
| 135 |
-
<h3 class="centered-title">📝 Summary generated :</h3>
|
| 136 |
-
<br>
|
| 137 |
-
<p id="summaryText">${data.summary}</p>
|
| 138 |
-
`;
|
| 139 |
-
|
| 140 |
-
document.getElementById("documentResult").dataset.summaryText = data.summary;
|
| 141 |
-
document.getElementById("downloadSection").style.display = "block";
|
| 142 |
-
|
| 143 |
-
// 🎤 Ajouter l'effet vocal
|
| 144 |
-
const playVoiceBtn = document.getElementById("playVoiceBtn");
|
| 145 |
-
playVoiceBtn.addEventListener("click", function () {
|
| 146 |
-
const textToRead = document.getElementById("summaryText").textContent;
|
| 147 |
-
const utterance = new SpeechSynthesisUtterance(textToRead);
|
| 148 |
-
utterance.lang = "en-US"; // ou "fr-FR" si ton résumé est en français
|
| 149 |
-
window.speechSynthesis.speak(utterance);
|
| 150 |
-
});
|
| 151 |
-
}
|
| 152 |
-
else {
|
| 153 |
resultElement.innerText = "❌ Summary not available.";
|
| 154 |
}
|
| 155 |
} catch (error) {
|
|
@@ -254,6 +228,12 @@ function loadResumerPage() {
|
|
| 254 |
<div class="logo-top">SMARTDOCS</div>
|
| 255 |
<div class="logo-bottom">AI</div>
|
| 256 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
<div class="menu-section">
|
| 258 |
<button class="menu-btn" id="resumerButton">SUMMARIZE</button>
|
| 259 |
<button class="menu-btn" id="qesdocButton">DOC-QUESTIONS</button>
|
|
@@ -503,7 +483,7 @@ function loadResumerPage() {
|
|
| 503 |
const data = await response.json();
|
| 504 |
|
| 505 |
if (data.translated_text) {
|
| 506 |
-
resultElement.innerText = "📝
|
| 507 |
// Stocker le texte traduit pour le téléchargement
|
| 508 |
resultElement.dataset.translatedText = data.translated_text;
|
| 509 |
// Afficher les options de téléchargement
|
|
@@ -703,36 +683,12 @@ askBtn.addEventListener('click', async () => {
|
|
| 703 |
|
| 704 |
const data = await response.json();
|
| 705 |
if (data.answer) {
|
|
|
|
| 706 |
answerDiv.innerHTML = `
|
| 707 |
-
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
| 708 |
-
<button id="playAnswerVoiceBtn" style="
|
| 709 |
-
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
| 710 |
-
color: white;
|
| 711 |
-
border: none;
|
| 712 |
-
padding: 10px 16px;
|
| 713 |
-
border-radius: 12px;
|
| 714 |
-
cursor: pointer;
|
| 715 |
-
font-size: 14px;
|
| 716 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 717 |
-
transition: transform 0.2s;
|
| 718 |
-
">
|
| 719 |
-
🔊 Listen to Answer
|
| 720 |
-
</button>
|
| 721 |
-
</div>
|
| 722 |
<h3 class="centered-title">✅ The result :</h3>
|
| 723 |
<br>
|
| 724 |
-
<p
|
| 725 |
`;
|
| 726 |
-
|
| 727 |
-
// 🎤 Ajouter l'effet vocal
|
| 728 |
-
const playVoiceBtn = document.getElementById("playAnswerVoiceBtn");
|
| 729 |
-
playVoiceBtn.addEventListener("click", function () {
|
| 730 |
-
const textToRead = document.getElementById("answerText").textContent;
|
| 731 |
-
const utterance = new SpeechSynthesisUtterance(textToRead);
|
| 732 |
-
utterance.lang = "en-US"; // ou adapte ici si tu as des réponses en français
|
| 733 |
-
window.speechSynthesis.speak(utterance);
|
| 734 |
-
});
|
| 735 |
-
|
| 736 |
} else {
|
| 737 |
answerDiv.innerHTML = `❌ ${data.error || "Erreur inconnue"}`;
|
| 738 |
}
|
|
@@ -1105,34 +1061,13 @@ interpretButton.addEventListener('click', async function () {
|
|
| 1105 |
const data = await response.json();
|
| 1106 |
|
| 1107 |
if (data.caption) {
|
| 1108 |
-
|
| 1109 |
-
|
| 1110 |
-
<button id="playVoiceBtn" style="
|
| 1111 |
-
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
| 1112 |
-
color: white;
|
| 1113 |
-
border: none;
|
| 1114 |
-
padding: 10px 16px;
|
| 1115 |
-
border-radius: 12px;
|
| 1116 |
-
cursor: pointer;
|
| 1117 |
-
font-size: 14px;
|
| 1118 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 1119 |
-
transition: transform 0.2s;
|
| 1120 |
-
">
|
| 1121 |
-
🔊 Listen to Interpretation
|
| 1122 |
-
</button>
|
| 1123 |
-
</div>
|
| 1124 |
<h3 style="text-align: center; font-size: 1.5rem; font-weight: bold; color: black;">📸 Generated caption :</h3>
|
| 1125 |
<br>
|
| 1126 |
-
<p
|
| 1127 |
-
`;
|
| 1128 |
-
|
| 1129 |
-
playVoiceBtn.addEventListener("click", function () {
|
| 1130 |
-
const textToRead = document.getElementById("interpretationText").textContent;
|
| 1131 |
-
const utterance = new SpeechSynthesisUtterance(textToRead);
|
| 1132 |
-
utterance.lang = "en-US"; // adapte ici selon la langue de l'interprétation
|
| 1133 |
-
window.speechSynthesis.speak(utterance);
|
| 1134 |
-
});
|
| 1135 |
-
} else if (data.error) {
|
| 1136 |
resultContainer.innerHTML = `<p class="error-text">❌ Erreur : ${data.error}</p>`;
|
| 1137 |
}
|
| 1138 |
} catch (error) {
|
|
@@ -1273,37 +1208,13 @@ sendBtn.addEventListener("click", async function () {
|
|
| 1273 |
const data = await response.json();
|
| 1274 |
if (data.answer) {
|
| 1275 |
|
| 1276 |
-
|
| 1277 |
-
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
| 1278 |
-
<button id="playVoiceBtn" style="
|
| 1279 |
-
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
| 1280 |
-
color: white;
|
| 1281 |
-
border: none;
|
| 1282 |
-
padding: 10px 16px;
|
| 1283 |
-
border-radius: 12px;
|
| 1284 |
-
cursor: pointer;
|
| 1285 |
-
font-size: 14px;
|
| 1286 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 1287 |
-
transition: transform 0.2s;
|
| 1288 |
-
">
|
| 1289 |
-
🔊 Listen to Answer
|
| 1290 |
-
</button>
|
| 1291 |
-
</div>
|
| 1292 |
|
| 1293 |
<h3 style="text-align: center; font-size: 1.5rem; font-weight: bold; color: black">🧠 Generated answer :</h3>
|
| 1294 |
<br>
|
| 1295 |
<p style="text-align: center; font-size: 1.2rem; font-weight: bold; color: black;">${data.answer}</p>
|
| 1296 |
|
| 1297 |
`;
|
| 1298 |
-
// 🎤 Ajouter l'effet vocal
|
| 1299 |
-
const playVoiceBtn = document.getElementById("playVoiceBtn");
|
| 1300 |
-
playVoiceBtn.addEventListener("click", function () {
|
| 1301 |
-
const textToRead = data.answer;
|
| 1302 |
-
const utterance = new SpeechSynthesisUtterance(textToRead);
|
| 1303 |
-
utterance.lang = "en-US"; // adapte ici selon la langue de la réponse
|
| 1304 |
-
window.speechSynthesis.speak(utterance);
|
| 1305 |
-
});
|
| 1306 |
-
|
| 1307 |
} else {
|
| 1308 |
resultContainer.innerHTML = `<p class="placeholder-text">Erreur : ${data.error}</p>`;
|
| 1309 |
}
|
|
|
|
| 14 |
appContainer.innerHTML = `
|
| 15 |
<div class="sidebar">
|
| 16 |
<div class="logo-container">
|
| 17 |
+
<div class="logo-top">SMARTDOCS</div>
|
| 18 |
<div class="logo-bottom">AI</div>
|
| 19 |
</div>
|
| 20 |
<a href="principal.html" class="home-link">
|
|
|
|
| 115 |
return;
|
| 116 |
}
|
| 117 |
|
| 118 |
+
if (data.summary) {
|
| 119 |
+
resultElement.innerHTML = `
|
| 120 |
+
<h3 class="centered-title">📝 Summary generated :</h3>
|
| 121 |
+
<br>
|
| 122 |
+
<p>${data.summary}</p>
|
| 123 |
+
`;
|
| 124 |
+
document.getElementById("documentResult").dataset.summaryText = data.summary;
|
| 125 |
+
document.getElementById("downloadSection").style.display = "block";
|
| 126 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
resultElement.innerText = "❌ Summary not available.";
|
| 128 |
}
|
| 129 |
} catch (error) {
|
|
|
|
| 228 |
<div class="logo-top">SMARTDOCS</div>
|
| 229 |
<div class="logo-bottom">AI</div>
|
| 230 |
</div>
|
| 231 |
+
<a href="principal.html" class="home-link">
|
| 232 |
+
<img src="https://cdn-icons-png.flaticon.com/512/1946/1946436.png"
|
| 233 |
+
alt="Accueil"
|
| 234 |
+
class="home-icon"
|
| 235 |
+
style="filter: brightness(0) saturate(100%) invert(71%) sepia(16%) saturate(4251%) hue-rotate(180deg) brightness(104%) contrast(91%);">
|
| 236 |
+
</a>
|
| 237 |
<div class="menu-section">
|
| 238 |
<button class="menu-btn" id="resumerButton">SUMMARIZE</button>
|
| 239 |
<button class="menu-btn" id="qesdocButton">DOC-QUESTIONS</button>
|
|
|
|
| 483 |
const data = await response.json();
|
| 484 |
|
| 485 |
if (data.translated_text) {
|
| 486 |
+
resultElement.innerText = "📝 Translation :\n " + data.translated_text;
|
| 487 |
// Stocker le texte traduit pour le téléchargement
|
| 488 |
resultElement.dataset.translatedText = data.translated_text;
|
| 489 |
// Afficher les options de téléchargement
|
|
|
|
| 683 |
|
| 684 |
const data = await response.json();
|
| 685 |
if (data.answer) {
|
| 686 |
+
|
| 687 |
answerDiv.innerHTML = `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 688 |
<h3 class="centered-title">✅ The result :</h3>
|
| 689 |
<br>
|
| 690 |
+
<p>${data.answer}</p>
|
| 691 |
`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 692 |
} else {
|
| 693 |
answerDiv.innerHTML = `❌ ${data.error || "Erreur inconnue"}`;
|
| 694 |
}
|
|
|
|
| 1061 |
const data = await response.json();
|
| 1062 |
|
| 1063 |
if (data.caption) {
|
| 1064 |
+
|
| 1065 |
+
resultContainer.innerHTML = `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1066 |
<h3 style="text-align: center; font-size: 1.5rem; font-weight: bold; color: black;">📸 Generated caption :</h3>
|
| 1067 |
<br>
|
| 1068 |
+
<p style="text-align: center; font-size: 1.2rem; font-weight: bold; color: black;">${data.caption}</p>
|
| 1069 |
+
`;
|
| 1070 |
+
} else if (data.error) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1071 |
resultContainer.innerHTML = `<p class="error-text">❌ Erreur : ${data.error}</p>`;
|
| 1072 |
}
|
| 1073 |
} catch (error) {
|
|
|
|
| 1208 |
const data = await response.json();
|
| 1209 |
if (data.answer) {
|
| 1210 |
|
| 1211 |
+
resultContainer.innerHTML = `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1212 |
|
| 1213 |
<h3 style="text-align: center; font-size: 1.5rem; font-weight: bold; color: black">🧠 Generated answer :</h3>
|
| 1214 |
<br>
|
| 1215 |
<p style="text-align: center; font-size: 1.2rem; font-weight: bold; color: black;">${data.answer}</p>
|
| 1216 |
|
| 1217 |
`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1218 |
} else {
|
| 1219 |
resultContainer.innerHTML = `<p class="placeholder-text">Erreur : ${data.error}</p>`;
|
| 1220 |
}
|