File size: 3,963 Bytes
af53f00 |
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
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 = "⏳ Analysis in progress...";
let width = 0;
const totalTime = 180000; // 3 minutes
const intervalTime = totalTime / 100;
const interval = setInterval(() => {
if (width >= 100) {
clearInterval(interval);
progressBar.textContent = "100%";
setTimeout(() => {
progressContainer.style.display = "none";
progressBar.style.width = "0%";
progressBar.textContent = "0%";
analyzeBtn.disabled = false;
analyzeBtn.textContent = "Analyze";
}, 1000);
} else {
width += 1;
progressBar.style.width = width + "%";
progressBar.textContent = width + "%";
}
}, intervalTime);
// fallback di sicurezza
setTimeout(() => {
analyzeBtn.disabled = false;
analyzeBtn.textContent = "Analyze";
progressContainer.style.display = "none";
progressBar.style.width = "0%";
progressBar.textContent = "0%";
}, totalTime + 3000);
}
}
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 = `Main PDF selected: ${fileInput.files[0].name}`;
}
});
}
const comparisonInput = document.getElementById("comparison_files");
if (comparisonInput) {
comparisonInput.addEventListener("change", function () {
const label = document.querySelector('label[for="comparison_files"]');
if (comparisonInput.files.length > 0 && label) {
label.textContent = `${comparisonInput.files.length} comparison files selected`;
}
});
}
const flashMessages = document.querySelectorAll(".error");
if (flashMessages.length > 0) {
setTimeout(() => {
flashMessages.forEach(message => message.remove());
}, 5000);
}
});
|