Update app.py
Browse files
app.py
CHANGED
|
@@ -278,7 +278,7 @@ landing_template = '''
|
|
| 278 |
</html>
|
| 279 |
'''
|
| 280 |
|
| 281 |
-
# --- Upload & Result Page Template (Original Design with Home Button and Progress Bar
|
| 282 |
upload_template = '''
|
| 283 |
<!DOCTYPE html>
|
| 284 |
<html lang="en">
|
|
@@ -344,38 +344,36 @@ upload_template = '''
|
|
| 344 |
background-color: #000;
|
| 345 |
color: #fff;
|
| 346 |
}
|
| 347 |
-
/* Progress
|
| 348 |
-
#
|
| 349 |
position: fixed;
|
| 350 |
top: 0;
|
| 351 |
left: 0;
|
| 352 |
width: 100%;
|
| 353 |
height: 100%;
|
| 354 |
-
background: rgba(255,255,255,0.
|
| 355 |
display: none;
|
| 356 |
-
flex-direction: column;
|
| 357 |
align-items: center;
|
| 358 |
justify-content: center;
|
|
|
|
| 359 |
z-index: 9999;
|
| 360 |
}
|
| 361 |
#progressContainer {
|
| 362 |
width: 80%;
|
| 363 |
-
max-width:
|
| 364 |
-
background: #ddd;
|
| 365 |
-
border: 2px solid #000;
|
| 366 |
-
border-radius: 5px;
|
| 367 |
-
overflow: hidden;
|
| 368 |
-
margin-bottom: 20px;
|
| 369 |
}
|
| 370 |
#progressBar {
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
background: #000;
|
| 374 |
-
|
|
|
|
|
|
|
| 375 |
}
|
| 376 |
#progressText {
|
|
|
|
| 377 |
font-size: 1.2rem;
|
| 378 |
-
font-
|
| 379 |
}
|
| 380 |
.content-wrapper {
|
| 381 |
display: flex;
|
|
@@ -427,16 +425,16 @@ upload_template = '''
|
|
| 427 |
<body>
|
| 428 |
<!-- Home button -->
|
| 429 |
<a href="{{ url_for('landing') }}" class="home-btn">Home</a>
|
| 430 |
-
<!-- Progress bar
|
| 431 |
-
<div id="
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
</div>
|
| 437 |
<div class="typing-effect" id="typing"></div>
|
| 438 |
-
<!--
|
| 439 |
-
<form method="post" enctype="multipart/form-data" onsubmit="
|
| 440 |
<input type="file" name="file" accept="image/*" required>
|
| 441 |
<!-- Hidden field to pass the selected object type -->
|
| 442 |
<input type="hidden" name="object_type" value="{{ object_type }}">
|
|
@@ -471,39 +469,49 @@ upload_template = '''
|
|
| 471 |
{% endif %}
|
| 472 |
<div class="footer">© 2024 MathLens AI Detection App. All rights reserved.</div>
|
| 473 |
<script>
|
| 474 |
-
//
|
| 475 |
-
function
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
];
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
// Increase progress by a random value (to add some variability)
|
| 491 |
-
progress += Math.floor(Math.random() * 3) + 1;
|
| 492 |
if (progress > 100) progress = 100;
|
| 493 |
progressBar.style.width = progress + "%";
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
if (progress <= phrases[i].limit) {
|
| 497 |
progressText.textContent = phrases[i].text;
|
| 498 |
break;
|
| 499 |
}
|
| 500 |
}
|
| 501 |
-
|
| 502 |
-
if (progress >= 100) {
|
| 503 |
clearInterval(interval);
|
|
|
|
| 504 |
}
|
| 505 |
-
},
|
| 506 |
}
|
|
|
|
| 507 |
// Existing typing effect code
|
| 508 |
const textArray = ["MathLens", "Smart Counting with Maths"];
|
| 509 |
let textIndex = 0;
|
|
|
|
| 278 |
</html>
|
| 279 |
'''
|
| 280 |
|
| 281 |
+
# --- Upload & Result Page Template (Original Design with Home Button and Progress Bar Overlay) ---
|
| 282 |
upload_template = '''
|
| 283 |
<!DOCTYPE html>
|
| 284 |
<html lang="en">
|
|
|
|
| 344 |
background-color: #000;
|
| 345 |
color: #fff;
|
| 346 |
}
|
| 347 |
+
/* Progress overlay styles */
|
| 348 |
+
#progressOverlay {
|
| 349 |
position: fixed;
|
| 350 |
top: 0;
|
| 351 |
left: 0;
|
| 352 |
width: 100%;
|
| 353 |
height: 100%;
|
| 354 |
+
background: rgba(255,255,255,0.9);
|
| 355 |
display: none;
|
|
|
|
| 356 |
align-items: center;
|
| 357 |
justify-content: center;
|
| 358 |
+
flex-direction: column;
|
| 359 |
z-index: 9999;
|
| 360 |
}
|
| 361 |
#progressContainer {
|
| 362 |
width: 80%;
|
| 363 |
+
max-width: 400px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
}
|
| 365 |
#progressBar {
|
| 366 |
+
height: 20px;
|
| 367 |
+
width: 0;
|
| 368 |
+
background-color: #000;
|
| 369 |
+
border-radius: 10px;
|
| 370 |
+
-webkit-transition: width 0.05s linear;
|
| 371 |
+
transition: width 0.05s linear;
|
| 372 |
}
|
| 373 |
#progressText {
|
| 374 |
+
margin-top: 10px;
|
| 375 |
font-size: 1.2rem;
|
| 376 |
+
font-family: "Share Tech Mono", monospace;
|
| 377 |
}
|
| 378 |
.content-wrapper {
|
| 379 |
display: flex;
|
|
|
|
| 425 |
<body>
|
| 426 |
<!-- Home button -->
|
| 427 |
<a href="{{ url_for('landing') }}" class="home-btn">Home</a>
|
| 428 |
+
<!-- Progress overlay with progress bar and dynamic text -->
|
| 429 |
+
<div id="progressOverlay">
|
| 430 |
+
<div id="progressContainer">
|
| 431 |
+
<div id="progressBar"></div>
|
| 432 |
+
<div id="progressText">Starting up... ๐ ๏ธ</div>
|
| 433 |
+
</div>
|
| 434 |
</div>
|
| 435 |
<div class="typing-effect" id="typing"></div>
|
| 436 |
+
<!-- The form now has an id and an onsubmit handler -->
|
| 437 |
+
<form id="uploadForm" method="post" enctype="multipart/form-data" onsubmit="handleFormSubmit(event)">
|
| 438 |
<input type="file" name="file" accept="image/*" required>
|
| 439 |
<!-- Hidden field to pass the selected object type -->
|
| 440 |
<input type="hidden" name="object_type" value="{{ object_type }}">
|
|
|
|
| 469 |
{% endif %}
|
| 470 |
<div class="footer">© 2024 MathLens AI Detection App. All rights reserved.</div>
|
| 471 |
<script>
|
| 472 |
+
// Intercept form submission and simulate a progress bar animation
|
| 473 |
+
function handleFormSubmit(e) {
|
| 474 |
+
e.preventDefault();
|
| 475 |
+
// Determine if the visitor is on mobile (adjust delay accordingly)
|
| 476 |
+
var isMobile = /Mobi|Android/i.test(navigator.userAgent);
|
| 477 |
+
var totalDelay = isMobile ? 5000 : 2000; // 5 seconds on mobile, 2 seconds on desktop
|
| 478 |
+
startProgressAndSubmit(totalDelay);
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
// Animate the progress overlay and then submit the form after the simulated delay
|
| 482 |
+
function startProgressAndSubmit(totalTime) {
|
| 483 |
+
var progressOverlay = document.getElementById("progressOverlay");
|
| 484 |
+
progressOverlay.style.display = "flex";
|
| 485 |
+
var progressBar = document.getElementById("progressBar");
|
| 486 |
+
var progressText = document.getElementById("progressText");
|
| 487 |
+
var progress = 0;
|
| 488 |
+
var updateInterval = totalTime / 100; // time (ms) per 1% increment
|
| 489 |
+
var phrases = [
|
| 490 |
+
{ threshold: 0, text: "Starting up... ๐ ๏ธ" },
|
| 491 |
+
{ threshold: 10, text: "Writing scripts... ๐ค" },
|
| 492 |
+
{ threshold: 30, text: "Calculating formulas... ๐งฎ" },
|
| 493 |
+
{ threshold: 50, text: "Crunching numbers... ๐ข" },
|
| 494 |
+
{ threshold: 70, text: "Almost there... ๐" },
|
| 495 |
+
{ threshold: 90, text: "Finalizing... ๐" },
|
| 496 |
+
{ threshold: 100, text: "Done! โ
" }
|
| 497 |
];
|
| 498 |
+
var interval = setInterval(function() {
|
| 499 |
+
progress++;
|
|
|
|
|
|
|
| 500 |
if (progress > 100) progress = 100;
|
| 501 |
progressBar.style.width = progress + "%";
|
| 502 |
+
for (var i = phrases.length - 1; i >= 0; i--) {
|
| 503 |
+
if (progress >= phrases[i].threshold) {
|
|
|
|
| 504 |
progressText.textContent = phrases[i].text;
|
| 505 |
break;
|
| 506 |
}
|
| 507 |
}
|
| 508 |
+
if (progress === 100) {
|
|
|
|
| 509 |
clearInterval(interval);
|
| 510 |
+
document.getElementById("uploadForm").submit();
|
| 511 |
}
|
| 512 |
+
}, updateInterval);
|
| 513 |
}
|
| 514 |
+
|
| 515 |
// Existing typing effect code
|
| 516 |
const textArray = ["MathLens", "Smart Counting with Maths"];
|
| 517 |
let textIndex = 0;
|