Spaces:
Running
Running
Update static/script.js
Browse files- static/script.js +147 -24
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,15 +115,41 @@ function loadResumerPage() {
|
|
115 |
return;
|
116 |
}
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
resultElement.innerText = "❌ Summary not available.";
|
128 |
}
|
129 |
} catch (error) {
|
@@ -482,13 +508,41 @@ function loadResumerPage() {
|
|
482 |
|
483 |
const data = await response.json();
|
484 |
|
485 |
-
if (data.
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
resultElement.innerText = "❌ Translation not available.";
|
493 |
}
|
494 |
} catch (error) {
|
@@ -683,12 +737,36 @@ askBtn.addEventListener('click', async () => {
|
|
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,13 +1139,34 @@ interpretButton.addEventListener('click', async function () {
|
|
1061 |
const data = await response.json();
|
1062 |
|
1063 |
if (data.caption) {
|
1064 |
-
|
1065 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1071 |
resultContainer.innerHTML = `<p class="error-text">❌ Erreur : ${data.error}</p>`;
|
1072 |
}
|
1073 |
} catch (error) {
|
@@ -1208,13 +1307,37 @@ sendBtn.addEventListener("click", async function () {
|
|
1208 |
const data = await response.json();
|
1209 |
if (data.answer) {
|
1210 |
|
1211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
}
|
|
|
14 |
appContainer.innerHTML = `
|
15 |
<div class="sidebar">
|
16 |
<div class="logo-container">
|
17 |
+
<div class="logo-top">SMARTDOC</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 |
+
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
121 |
+
<button id="playVoiceBtn" style="
|
122 |
+
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
123 |
+
color: white;
|
124 |
+
border: none;
|
125 |
+
padding: 10px 16px;
|
126 |
+
border-radius: 12px;
|
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" style="font-size: 16px;">${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) {
|
|
|
508 |
|
509 |
const data = await response.json();
|
510 |
|
511 |
+
if (data.translation) {
|
512 |
+
resultElement.innerHTML = `
|
513 |
+
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
514 |
+
<button id="playVoiceBtn" style="
|
515 |
+
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
516 |
+
color: white;
|
517 |
+
border: none;
|
518 |
+
padding: 10px 16px;
|
519 |
+
border-radius: 12px;
|
520 |
+
cursor: pointer;
|
521 |
+
font-size: 14px;
|
522 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
523 |
+
transition: transform 0.2s;
|
524 |
+
">
|
525 |
+
🔊 Listen to Translation
|
526 |
+
</button>
|
527 |
+
</div>
|
528 |
+
<h3 class="centered-title">🌍 Translation :</h3>
|
529 |
+
<br>
|
530 |
+
<p id="translationText" style="font-size: 16px;">${data.translation}</p>
|
531 |
+
`;
|
532 |
+
|
533 |
+
document.getElementById("documentResult").dataset.translationText = data.translation;
|
534 |
+
document.getElementById("downloadSection").style.display = "block";
|
535 |
+
|
536 |
+
// 🎤 Ajouter l'effet vocal
|
537 |
+
const playVoiceBtn = document.getElementById("playVoiceBtn");
|
538 |
+
playVoiceBtn.addEventListener("click", function () {
|
539 |
+
const textToRead = document.getElementById("translationText").textContent;
|
540 |
+
const utterance = new SpeechSynthesisUtterance(textToRead);
|
541 |
+
utterance.lang = "en-US"; // adapte ici selon la langue de ta traduction ("fr-FR" pour du français par exemple)
|
542 |
+
window.speechSynthesis.speak(utterance);
|
543 |
+
});
|
544 |
+
}
|
545 |
+
else {
|
546 |
resultElement.innerText = "❌ Translation not available.";
|
547 |
}
|
548 |
} catch (error) {
|
|
|
737 |
|
738 |
const data = await response.json();
|
739 |
if (data.answer) {
|
|
|
740 |
answerDiv.innerHTML = `
|
741 |
+
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
742 |
+
<button id="playAnswerVoiceBtn" style="
|
743 |
+
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
744 |
+
color: white;
|
745 |
+
border: none;
|
746 |
+
padding: 10px 16px;
|
747 |
+
border-radius: 12px;
|
748 |
+
cursor: pointer;
|
749 |
+
font-size: 14px;
|
750 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
751 |
+
transition: transform 0.2s;
|
752 |
+
">
|
753 |
+
🔊 Listen to Answer
|
754 |
+
</button>
|
755 |
+
</div>
|
756 |
<h3 class="centered-title">✅ The result :</h3>
|
757 |
<br>
|
758 |
+
<p id="answerText" style="font-size: 16px;">${data.answer}</p>
|
759 |
`;
|
760 |
+
|
761 |
+
// 🎤 Ajouter l'effet vocal
|
762 |
+
const playVoiceBtn = document.getElementById("playAnswerVoiceBtn");
|
763 |
+
playVoiceBtn.addEventListener("click", function () {
|
764 |
+
const textToRead = document.getElementById("answerText").textContent;
|
765 |
+
const utterance = new SpeechSynthesisUtterance(textToRead);
|
766 |
+
utterance.lang = "en-US"; // ou adapte ici si tu as des réponses en français
|
767 |
+
window.speechSynthesis.speak(utterance);
|
768 |
+
});
|
769 |
+
|
770 |
} else {
|
771 |
answerDiv.innerHTML = `❌ ${data.error || "Erreur inconnue"}`;
|
772 |
}
|
|
|
1139 |
const data = await response.json();
|
1140 |
|
1141 |
if (data.caption) {
|
1142 |
+
resultContainer.innerHTML = `
|
1143 |
+
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
1144 |
+
<button id="playVoiceBtn" style="
|
1145 |
+
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
1146 |
+
color: white;
|
1147 |
+
border: none;
|
1148 |
+
padding: 10px 16px;
|
1149 |
+
border-radius: 12px;
|
1150 |
+
cursor: pointer;
|
1151 |
+
font-size: 14px;
|
1152 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
1153 |
+
transition: transform 0.2s;
|
1154 |
+
">
|
1155 |
+
🔊 Listen to Interpretation
|
1156 |
+
</button>
|
1157 |
+
</div>
|
1158 |
<h3 style="text-align: center; font-size: 1.5rem; font-weight: bold; color: black;">📸 Generated caption :</h3>
|
1159 |
<br>
|
1160 |
<p style="text-align: center; font-size: 1.2rem; font-weight: bold; color: black;">${data.caption}</p>
|
1161 |
+
`; // 🎤 Ajouter l'effet vocal
|
1162 |
+
const playVoiceBtn = document.getElementById("playVoiceBtn");
|
1163 |
+
playVoiceBtn.addEventListener("click", function () {
|
1164 |
+
const textToRead = document.getElementById("interpretationText").textContent;
|
1165 |
+
const utterance = new SpeechSynthesisUtterance(textToRead);
|
1166 |
+
utterance.lang = "en-US"; // adapte ici selon la langue de l'interprétation
|
1167 |
+
window.speechSynthesis.speak(utterance);
|
1168 |
+
});
|
1169 |
+
} else if (data.error) {
|
1170 |
resultContainer.innerHTML = `<p class="error-text">❌ Erreur : ${data.error}</p>`;
|
1171 |
}
|
1172 |
} catch (error) {
|
|
|
1307 |
const data = await response.json();
|
1308 |
if (data.answer) {
|
1309 |
|
1310 |
+
resultContainer.innerHTML = `
|
1311 |
+
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
1312 |
+
<button id="playVoiceBtn" style="
|
1313 |
+
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
1314 |
+
color: white;
|
1315 |
+
border: none;
|
1316 |
+
padding: 10px 16px;
|
1317 |
+
border-radius: 12px;
|
1318 |
+
cursor: pointer;
|
1319 |
+
font-size: 14px;
|
1320 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
1321 |
+
transition: transform 0.2s;
|
1322 |
+
">
|
1323 |
+
🔊 Listen to Answer
|
1324 |
+
</button>
|
1325 |
+
</div>
|
1326 |
|
1327 |
<h3 style="text-align: center; font-size: 1.5rem; font-weight: bold; color: black">🧠 Generated answer :</h3>
|
1328 |
<br>
|
1329 |
<p style="text-align: center; font-size: 1.2rem; font-weight: bold; color: black;">${data.answer}</p>
|
1330 |
|
1331 |
`;
|
1332 |
+
// 🎤 Ajouter l'effet vocal
|
1333 |
+
const playVoiceBtn = document.getElementById("playVoiceBtn");
|
1334 |
+
playVoiceBtn.addEventListener("click", function () {
|
1335 |
+
const textToRead = data.answer;
|
1336 |
+
const utterance = new SpeechSynthesisUtterance(textToRead);
|
1337 |
+
utterance.lang = "en-US"; // adapte ici selon la langue de la réponse
|
1338 |
+
window.speechSynthesis.speak(utterance);
|
1339 |
+
});
|
1340 |
+
|
1341 |
} else {
|
1342 |
resultContainer.innerHTML = `<p class="placeholder-text">Erreur : ${data.error}</p>`;
|
1343 |
}
|