Spaces:
Running
Running
Update static/script.js
Browse files- static/script.js +114 -26
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,40 @@ 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) {
|
@@ -218,7 +243,7 @@ function loadResumerPage() {
|
|
218 |
//Quand on clique sur le boutton traduction ---------------
|
219 |
|
220 |
|
221 |
-
|
222 |
document.body.style.setProperty('--background-image', "url('traduction.webp')");
|
223 |
let appContainer = document.createElement("div");
|
224 |
appContainer.classList.add("app-container");
|
@@ -228,12 +253,6 @@ function loadResumerPage() {
|
|
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,7 +502,7 @@ function loadResumerPage() {
|
|
483 |
const data = await response.json();
|
484 |
|
485 |
if (data.translated_text) {
|
486 |
-
resultElement.innerText = "📝
|
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,12 +702,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 +1104,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 +1272,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">${data.summary}</p>
|
138 |
+
`;
|
139 |
+
|
140 |
+
document.getElementById("documentResult").dataset.summaryText = data.summary;
|
141 |
+
document.getElementById("downloadSection").style.display = "block";
|
142 |
+
|
143 |
+
const playVoiceBtn = document.getElementById("playVoiceBtn");
|
144 |
+
playVoiceBtn.addEventListener("click", function () {
|
145 |
+
const textToRead = document.getElementById("summaryText").textContent;
|
146 |
+
const utterance = new SpeechSynthesisUtterance(textToRead);
|
147 |
+
utterance.lang = "en-US"; // ou "fr-FR" si ton résumé est en français
|
148 |
+
window.speechSynthesis.speak(utterance);
|
149 |
+
});
|
150 |
+
}
|
151 |
+
else {
|
152 |
resultElement.innerText = "❌ Summary not available.";
|
153 |
}
|
154 |
} catch (error) {
|
|
|
243 |
//Quand on clique sur le boutton traduction ---------------
|
244 |
|
245 |
|
246 |
+
function loadTraductionPage() {
|
247 |
document.body.style.setProperty('--background-image', "url('traduction.webp')");
|
248 |
let appContainer = document.createElement("div");
|
249 |
appContainer.classList.add("app-container");
|
|
|
253 |
<div class="logo-top">SMARTDOCS</div>
|
254 |
<div class="logo-bottom">AI</div>
|
255 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
<div class="menu-section">
|
257 |
<button class="menu-btn" id="resumerButton">SUMMARIZE</button>
|
258 |
<button class="menu-btn" id="qesdocButton">DOC-QUESTIONS</button>
|
|
|
502 |
const data = await response.json();
|
503 |
|
504 |
if (data.translated_text) {
|
505 |
+
resultElement.innerText = "📝 Traduction :\n " + data.translated_text;
|
506 |
// Stocker le texte traduit pour le téléchargement
|
507 |
resultElement.dataset.translatedText = data.translated_text;
|
508 |
// Afficher les options de téléchargement
|
|
|
702 |
|
703 |
const data = await response.json();
|
704 |
if (data.answer) {
|
|
|
705 |
answerDiv.innerHTML = `
|
706 |
+
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
707 |
+
<button id="playAnswerVoiceBtn" style="
|
708 |
+
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
709 |
+
color: white;
|
710 |
+
border: none;
|
711 |
+
padding: 10px 16px;
|
712 |
+
border-radius: 12px;
|
713 |
+
cursor: pointer;
|
714 |
+
font-size: 14px;
|
715 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
716 |
+
transition: transform 0.2s;
|
717 |
+
">
|
718 |
+
🔊 Listen to Answer
|
719 |
+
</button>
|
720 |
+
</div>
|
721 |
<h3 class="centered-title">✅ The result :</h3>
|
722 |
<br>
|
723 |
+
<p id="answerText" style="font-size: 16px;">${data.answer}</p>
|
724 |
`;
|
725 |
+
|
726 |
+
// 🎤 Ajouter l'effet vocal
|
727 |
+
const playVoiceBtn = document.getElementById("playAnswerVoiceBtn");
|
728 |
+
playVoiceBtn.addEventListener("click", function () {
|
729 |
+
const textToRead = document.getElementById("answerText").textContent;
|
730 |
+
const utterance = new SpeechSynthesisUtterance(textToRead);
|
731 |
+
utterance.lang = "en-US"; // ou adapte ici si tu as des réponses en français
|
732 |
+
window.speechSynthesis.speak(utterance);
|
733 |
+
});
|
734 |
+
|
735 |
} else {
|
736 |
answerDiv.innerHTML = `❌ ${data.error || "Erreur inconnue"}`;
|
737 |
}
|
|
|
1104 |
const data = await response.json();
|
1105 |
|
1106 |
if (data.caption) {
|
1107 |
+
resultContainer.innerHTML = `
|
1108 |
+
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
1109 |
+
<button id="playVoiceBtn" style="
|
1110 |
+
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
1111 |
+
color: white;
|
1112 |
+
border: none;
|
1113 |
+
padding: 10px 16px;
|
1114 |
+
border-radius: 12px;
|
1115 |
+
cursor: pointer;
|
1116 |
+
font-size: 14px;
|
1117 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
1118 |
+
transition: transform 0.2s;
|
1119 |
+
">
|
1120 |
+
🔊 Listen to Interpretation
|
1121 |
+
</button>
|
1122 |
+
</div>
|
1123 |
<h3 style="text-align: center; font-size: 1.5rem; font-weight: bold; color: black;">📸 Generated caption :</h3>
|
1124 |
<br>
|
1125 |
+
<p id="interpretationText" style="text-align: center; font-size: 1.2rem; font-weight: bold; color: black;">${data.caption}</p>
|
1126 |
+
`; // 🎤 Ajouter l'effet vocal
|
1127 |
+
const playVoiceBtn = document.getElementById("playVoiceBtn");
|
1128 |
+
playVoiceBtn.addEventListener("click", function () {
|
1129 |
+
const textToRead = document.getElementById("interpretationText").textContent;
|
1130 |
+
const utterance = new SpeechSynthesisUtterance(textToRead);
|
1131 |
+
utterance.lang = "en-US"; // adapte ici selon la langue de l'interprétation
|
1132 |
+
window.speechSynthesis.speak(utterance);
|
1133 |
+
});
|
1134 |
+
} else if (data.error) {
|
1135 |
resultContainer.innerHTML = `<p class="error-text">❌ Erreur : ${data.error}</p>`;
|
1136 |
}
|
1137 |
} catch (error) {
|
|
|
1272 |
const data = await response.json();
|
1273 |
if (data.answer) {
|
1274 |
|
1275 |
+
resultContainer.innerHTML = `
|
1276 |
+
<div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
|
1277 |
+
<button id="playVoiceBtn" style="
|
1278 |
+
background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
|
1279 |
+
color: white;
|
1280 |
+
border: none;
|
1281 |
+
padding: 10px 16px;
|
1282 |
+
border-radius: 12px;
|
1283 |
+
cursor: pointer;
|
1284 |
+
font-size: 14px;
|
1285 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
1286 |
+
transition: transform 0.2s;
|
1287 |
+
">
|
1288 |
+
🔊 Listen to Answer
|
1289 |
+
</button>
|
1290 |
+
</div>
|
1291 |
|
1292 |
<h3 style="text-align: center; font-size: 1.5rem; font-weight: bold; color: black">🧠 Generated answer :</h3>
|
1293 |
<br>
|
1294 |
<p style="text-align: center; font-size: 1.2rem; font-weight: bold; color: black;">${data.answer}</p>
|
1295 |
|
1296 |
`;
|
1297 |
+
// 🎤 Ajouter l'effet vocal
|
1298 |
+
const playVoiceBtn = document.getElementById("playVoiceBtn");
|
1299 |
+
playVoiceBtn.addEventListener("click", function () {
|
1300 |
+
const textToRead = data.answer;
|
1301 |
+
const utterance = new SpeechSynthesisUtterance(textToRead);
|
1302 |
+
utterance.lang = "en-US"; // adapte ici selon la langue de la réponse
|
1303 |
+
window.speechSynthesis.speak(utterance);
|
1304 |
+
});
|
1305 |
+
|
1306 |
} else {
|
1307 |
resultContainer.innerHTML = `<p class="placeholder-text">Erreur : ${data.error}</p>`;
|
1308 |
}
|