|
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; |
|
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); |
|
|
|
|
|
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); |
|
} |
|
}); |
|
|