Spaces:
Sleeping
Sleeping
File size: 3,644 Bytes
8c42b67 37341dc 8c42b67 37341dc 8c42b67 1422112 8c42b67 37341dc 1422112 8c42b67 37341dc 8c42b67 1422112 37341dc 1422112 8c42b67 37341dc b792603 8c42b67 37341dc 8c42b67 37341dc 8c42b67 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
document.addEventListener("DOMContentLoaded", function () {
const logoLink = document.getElementById("logo-link");
if (logoLink) {
logoLink.addEventListener("click", function () {
const logo = document.getElementById("logo");
logo.style.transform = "scale(1.5)";
setTimeout(() => {
logo.style.transform = "scale(1)";
}, 500);
});
}
function startProgress() {
const progressBar = document.getElementById("progress-bar");
const progressContainer = document.getElementById("progress-container");
const analyzeBtn = document.querySelector("button[type='submit']");
if (progressBar && progressContainer && analyzeBtn) {
progressContainer.style.display = "block";
analyzeBtn.disabled = true;
analyzeBtn.textContent = "⏳ Analisi in corso...";
let width = 0;
const totalTime = 180000; // 3 minutes in milliseconds
const intervalTime = totalTime / 100; // Divide the time for each step (to fill the bar in 180s)
const interval = setInterval(() => {
if (width >= 100) {
clearInterval(interval);
progressBar.textContent = "100%";
setTimeout(() => {
progressContainer.style.display = "none"; // Hide the progress bar after completion
}, 1000); // Delay to allow the user to see the completion
} else {
width += 1;
progressBar.style.width = width + "%";
progressBar.textContent = width + "%";
}
}, intervalTime); // Update the progress bar at the specified interval time
// fallback per riabilitare il pulsante (verrà ignorato se il server risponde prima)
setTimeout(() => {
analyzeBtn.disabled = false;
analyzeBtn.textContent = "Analyze";
progressContainer.style.display = "none";
progressBar.style.width = "0%";
progressBar.textContent = "0%";
}, totalTime + 2000); // Timeout after total time plus extra 2 seconds to hide progress
}
}
window.startProgress = startProgress;
const analysisForm = document.getElementById("analysisForm");
if (analysisForm) {
analysisForm.addEventListener("submit", function () {
startProgress();
});
}
const analysisType = document.getElementById("analysis_type");
if (analysisType) {
analysisType.addEventListener("change", function () {
document.getElementById("pubmed-options").style.display =
this.value === "pubmed" ? "block" : "none";
document.getElementById("local-options").style.display =
this.value === "local" ? "block" : "none";
});
analysisType.dispatchEvent(new Event("change"));
}
const fileInput = document.getElementById("pdf_file");
if (fileInput) {
fileInput.addEventListener("change", function () {
const fileLabel = document.querySelector('label[for="pdf_file"]');
if (fileInput.files.length > 0 && fileLabel) {
fileLabel.textContent = `File selected: ${fileInput.files[0].name}`;
}
});
}
const flashMessages = document.querySelectorAll(".error");
if (flashMessages.length > 0) {
setTimeout(() => {
flashMessages.forEach(message => message.remove());
}, 5000);
}
});
|