Update templates/index.html
Browse files- templates/index.html +241 -2
templates/index.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
|
@@ -164,6 +164,245 @@
|
|
| 164 |
fetchAnswer(); // Trigger the fetch function
|
| 165 |
}
|
| 166 |
});
|
| 167 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
</body>
|
| 169 |
</html>
|
|
|
|
| 1 |
+
<!-- <!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
|
|
|
| 164 |
fetchAnswer(); // Trigger the fetch function
|
| 165 |
}
|
| 166 |
});
|
| 167 |
+
</script>
|
| 168 |
+
</body>
|
| 169 |
+
</html> -->
|
| 170 |
+
|
| 171 |
+
<!DOCTYPE html>
|
| 172 |
+
<html lang="en">
|
| 173 |
+
<head>
|
| 174 |
+
<meta charset="UTF-8" />
|
| 175 |
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 176 |
+
<title>PDF Q&A Chatbot</title>
|
| 177 |
+
<link
|
| 178 |
+
rel="stylesheet"
|
| 179 |
+
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
|
| 180 |
+
/>
|
| 181 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
| 182 |
+
<style>
|
| 183 |
+
/* Full-Screen Styling */
|
| 184 |
+
html,
|
| 185 |
+
body {
|
| 186 |
+
height: 100%;
|
| 187 |
+
margin: 0;
|
| 188 |
+
padding: 0;
|
| 189 |
+
font-family: "Arial", sans-serif;
|
| 190 |
+
background-image: url("https://source.unsplash.com/1920x1080/?technology,abstract"); /* Change Background */
|
| 191 |
+
background-size: cover;
|
| 192 |
+
background-position: center;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
.chat-container {
|
| 196 |
+
display: flex;
|
| 197 |
+
flex-direction: column;
|
| 198 |
+
height: 100vh;
|
| 199 |
+
justify-content: center;
|
| 200 |
+
align-items: center;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
.chat-box {
|
| 204 |
+
width: 80%;
|
| 205 |
+
max-width: 800px;
|
| 206 |
+
height: 70vh;
|
| 207 |
+
overflow-y: auto;
|
| 208 |
+
background: rgba(255, 255, 255, 0.9);
|
| 209 |
+
border-radius: 10px;
|
| 210 |
+
padding: 20px;
|
| 211 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
.chat-header {
|
| 215 |
+
text-align: center;
|
| 216 |
+
font-size: 22px;
|
| 217 |
+
font-weight: bold;
|
| 218 |
+
color: #007bff;
|
| 219 |
+
padding-bottom: 10px;
|
| 220 |
+
border-bottom: 2px solid #007bff;
|
| 221 |
+
margin-bottom: 10px;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
.message-container {
|
| 225 |
+
display: flex;
|
| 226 |
+
flex-direction: column;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
.user-message,
|
| 230 |
+
.bot-message {
|
| 231 |
+
margin: 10px 0;
|
| 232 |
+
padding: 12px;
|
| 233 |
+
border-radius: 10px;
|
| 234 |
+
max-width: 80%;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
.user-message {
|
| 238 |
+
background-color: #007bff;
|
| 239 |
+
color: white;
|
| 240 |
+
align-self: flex-end;
|
| 241 |
+
text-align: right;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.bot-message {
|
| 245 |
+
background-color: #f1f1f1;
|
| 246 |
+
align-self: flex-start;
|
| 247 |
+
text-align: left;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
/* Container for images */
|
| 251 |
+
.image-container {
|
| 252 |
+
display: flex;
|
| 253 |
+
gap: 10px;
|
| 254 |
+
flex-wrap: wrap;
|
| 255 |
+
margin-top: 10px;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
/* Thumbnails (Fixed Size) */
|
| 259 |
+
.img-thumbnail {
|
| 260 |
+
width: 100px; /* Adjust thumbnail size */
|
| 261 |
+
height: 100px; /* Ensure uniform size */
|
| 262 |
+
object-fit: cover;
|
| 263 |
+
cursor: pointer;
|
| 264 |
+
border-radius: 5px;
|
| 265 |
+
transition: transform 0.2s;
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
/* Add hover effect */
|
| 269 |
+
.img-thumbnail:hover {
|
| 270 |
+
transform: scale(1.1);
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
.inline-image {
|
| 274 |
+
max-width: 100%;
|
| 275 |
+
height: auto;
|
| 276 |
+
display: block;
|
| 277 |
+
margin: 10px 0;
|
| 278 |
+
cursor: pointer;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
/* Fullscreen Image Popup */
|
| 282 |
+
.popup-overlay {
|
| 283 |
+
position: fixed;
|
| 284 |
+
top: 0;
|
| 285 |
+
left: 0;
|
| 286 |
+
width: 100%;
|
| 287 |
+
height: 100%;
|
| 288 |
+
background: rgba(0, 0, 0, 0.8);
|
| 289 |
+
display: flex;
|
| 290 |
+
align-items: center;
|
| 291 |
+
justify-content: center;
|
| 292 |
+
z-index: 9999;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
.popup-content {
|
| 296 |
+
position: relative;
|
| 297 |
+
max-width: 80%;
|
| 298 |
+
max-height: 80%;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.popup-image {
|
| 302 |
+
width: 100%;
|
| 303 |
+
height: auto;
|
| 304 |
+
border-radius: 5px;
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
.close-btn {
|
| 308 |
+
position: absolute;
|
| 309 |
+
top: 10px;
|
| 310 |
+
right: 10px;
|
| 311 |
+
font-size: 20px;
|
| 312 |
+
color: rgb(0, 0, 0);
|
| 313 |
+
cursor: pointer;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
.input-group {
|
| 317 |
+
position: fixed;
|
| 318 |
+
bottom: 20px;
|
| 319 |
+
width: 80%;
|
| 320 |
+
max-width: 800px;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
.form-control {
|
| 324 |
+
height: 50px;
|
| 325 |
+
font-size: 16px;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
.btn {
|
| 329 |
+
height: 50px;
|
| 330 |
+
font-size: 16px;
|
| 331 |
+
}
|
| 332 |
+
</style>
|
| 333 |
+
</head>
|
| 334 |
+
<body>
|
| 335 |
+
<div class="chat-container">
|
| 336 |
+
<div class="chat-box" id="chat-box">
|
| 337 |
+
<div class="chat-header">📜 PDF Q&A Chatbot</div>
|
| 338 |
+
<div class="message-container"></div>
|
| 339 |
+
</div>
|
| 340 |
+
|
| 341 |
+
<!-- Image Popup Modal -->
|
| 342 |
+
<div id="image-popup">
|
| 343 |
+
<img id="popup-img" />
|
| 344 |
+
</div>
|
| 345 |
+
|
| 346 |
+
<div class="input-group">
|
| 347 |
+
<input
|
| 348 |
+
type="text"
|
| 349 |
+
id="query"
|
| 350 |
+
class="form-control"
|
| 351 |
+
placeholder="Ask a question..."
|
| 352 |
+
/>
|
| 353 |
+
<button class="btn btn-primary" onclick="fetchAnswer()">Ask</button>
|
| 354 |
+
</div>
|
| 355 |
+
</div>
|
| 356 |
+
|
| 357 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 358 |
+
<script>
|
| 359 |
+
function fetchAnswer() {
|
| 360 |
+
let query = $("#query").val();
|
| 361 |
+
if (!query) return;
|
| 362 |
+
|
| 363 |
+
let userMessage = `<div class="user-message">👤 ${query}</div>`;
|
| 364 |
+
$("#chat-box .message-container").append(userMessage);
|
| 365 |
+
$("#query").val("");
|
| 366 |
+
|
| 367 |
+
$.ajax({
|
| 368 |
+
url: "/query",
|
| 369 |
+
type: "POST",
|
| 370 |
+
contentType: "application/json",
|
| 371 |
+
data: JSON.stringify({ query: query }),
|
| 372 |
+
success: function (response) {
|
| 373 |
+
let messageContainer = $("#chat-box .message-container");
|
| 374 |
+
|
| 375 |
+
// Convert Markdown to HTML using marked.js
|
| 376 |
+
let botMessage = `<div class="bot-message">🤖 ${marked.parse(
|
| 377 |
+
response.text
|
| 378 |
+
)}</div>`;
|
| 379 |
+
messageContainer.append(botMessage).html();
|
| 380 |
+
|
| 381 |
+
// Scroll to bottom
|
| 382 |
+
$("#chat-box").scrollTop($("#chat-box")[0].scrollHeight);
|
| 383 |
+
},
|
| 384 |
+
});
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
// Allow user to submit query using "Enter" key
|
| 388 |
+
$("#query").keypress(function (event) {
|
| 389 |
+
if (event.which === 13) {
|
| 390 |
+
// Enter key code
|
| 391 |
+
event.preventDefault();
|
| 392 |
+
fetchAnswer();
|
| 393 |
+
}
|
| 394 |
+
});
|
| 395 |
+
|
| 396 |
+
// Function to expand image in a popup
|
| 397 |
+
function expandImage(img) {
|
| 398 |
+
let popup = document.createElement("div");
|
| 399 |
+
popup.classList.add("popup-overlay");
|
| 400 |
+
popup.innerHTML = `<div class="popup-content">
|
| 401 |
+
<img src="${img.src}" class="popup-image">
|
| 402 |
+
<span class="close-btn" onclick="this.parentElement.parentElement.remove()">✖</span>
|
| 403 |
+
</div>`;
|
| 404 |
+
document.body.appendChild(popup);
|
| 405 |
+
}
|
| 406 |
+
</script>
|
| 407 |
</body>
|
| 408 |
</html>
|