| |
| document.addEventListener('DOMContentLoaded', function() { |
| initUpload(); |
| initAnalysis(); |
| initResults(); |
| initCreateChallengeModal(); |
| |
| |
| const urlParams = new URLSearchParams(window.location.search); |
| if (urlParams.get('sample') === 'true') { |
| loadSampleCase(); |
| } |
| }); |
|
|
| |
| function initUpload() { |
| const uploadZone = document.getElementById('uploadZone'); |
| const fileInput = document.getElementById('fileInput'); |
| const browseButton = document.getElementById('browseButton'); |
| const filePreview = document.getElementById('filePreview'); |
| const analyzeBtn = document.getElementById('analyzeBtn'); |
| const addMoreFilesBtn = document.getElementById('addMoreFiles'); |
| const clearAllFilesBtn = document.getElementById('clearAllFiles'); |
| const previewList = document.getElementById('previewList'); |
| const fileCount = document.getElementById('fileCount'); |
|
|
| |
| let selectedFiles = []; |
|
|
| |
| uploadZone.addEventListener('click', () => { |
| fileInput.click(); |
| }); |
|
|
| |
| if (browseButton) { |
| browseButton.addEventListener('click', (e) => { |
| e.stopPropagation(); |
| fileInput.click(); |
| }); |
| } |
|
|
| |
| addMoreFilesBtn.addEventListener('click', () => { |
| fileInput.click(); |
| }); |
|
|
| |
| clearAllFilesBtn.addEventListener('click', () => { |
| clearAllFiles(); |
| }); |
|
|
| |
| fileInput.addEventListener('change', (e) => { |
| handleFileSelect(e); |
| if (getSelectedFiles().length > 0) { |
| startAnalysis(); |
| } |
| }); |
|
|
| |
| uploadZone.addEventListener('dragover', (e) => { |
| e.preventDefault(); |
| uploadZone.classList.add('drag-over'); |
| }); |
|
|
| uploadZone.addEventListener('dragleave', (e) => { |
| e.preventDefault(); |
| uploadZone.classList.remove('drag-over'); |
| }); |
|
|
| uploadZone.addEventListener('drop', (e) => { |
| e.preventDefault(); |
| uploadZone.classList.remove('drag-over'); |
| |
| const files = e.dataTransfer.files; |
| if (files.length > 0) { |
| handleFileSelect({ target: { files } }); |
| } |
| }); |
|
|
| |
| analyzeBtn.addEventListener('click', startAnalysis); |
|
|
| function handleFileSelect(e) { |
| const files = Array.from(e.target.files); |
| if (files.length === 0) return; |
|
|
| |
| const validFiles = []; |
| const validTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/tiff']; |
| |
| files.forEach(file => { |
| |
| if (!validTypes.includes(file.type)) { |
| window.oncoConnect.showToast(`Invalid file type: ${file.name}. Please upload JPG, PNG, or TIFF files.`, 'error'); |
| return; |
| } |
|
|
| |
| if (file.size > 50 * 1024 * 1024) { |
| window.oncoConnect.showToast(`File too large: ${file.name}. Maximum size is 50MB.`, 'error'); |
| return; |
| } |
|
|
| validFiles.push(file); |
| }); |
|
|
| if (validFiles.length === 0) return; |
|
|
| |
| selectedFiles = [...selectedFiles, ...validFiles]; |
| |
| |
| updateFilePreview(); |
| updateAnalyzeButton(); |
| |
| |
| fileInput.value = ''; |
| } |
|
|
| function updateFilePreview() { |
| if (selectedFiles.length === 0) { |
| filePreview.style.display = 'none'; |
| return; |
| } |
|
|
| filePreview.style.display = 'block'; |
| |
| |
| fileCount.textContent = `${selectedFiles.length} file${selectedFiles.length > 1 ? 's' : ''}`; |
| |
| |
| previewList.innerHTML = ''; |
| |
| selectedFiles.forEach((file, index) => { |
| const previewItem = createFilePreviewItem(file, index); |
| previewList.appendChild(previewItem); |
| }); |
| } |
|
|
| function createFilePreviewItem(file, index) { |
| const item = document.createElement('div'); |
| item.className = 'preview-item'; |
| item.innerHTML = ` |
| <div class="preview-icon"> |
| <svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| <rect x="3" y="3" width="18" height="18" rx="2" ry="2" stroke="currentColor" stroke-width="2"/> |
| <circle cx="8.5" cy="8.5" r="1.5" stroke="currentColor" stroke-width="2"/> |
| <path d="M21 15L16 10L5 21" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
| </svg> |
| </div> |
| <div class="preview-details"> |
| <div class="file-name">${file.name}</div> |
| <div class="file-meta"> |
| <span class="file-size">${window.oncoConnect.formatFileSize(file.size)}</span> |
| <span class="file-status">Ready to analyze</span> |
| </div> |
| </div> |
| <button class="remove-file" onclick="removeFile(${index})" aria-label="Remove ${file.name}"> |
| <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| <line x1="18" y1="6" x2="6" y2="18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
| <line x1="6" y1="6" x2="18" y2="18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
| </svg> |
| </button> |
| `; |
| return item; |
| } |
|
|
| function removeFile(index) { |
| selectedFiles.splice(index, 1); |
| updateFilePreview(); |
| updateAnalyzeButton(); |
| } |
|
|
| function clearAllFiles() { |
| selectedFiles = []; |
| updateFilePreview(); |
| updateAnalyzeButton(); |
| } |
|
|
| function updateAnalyzeButton() { |
| const analyzeBtn = document.getElementById('analyzeBtn'); |
| analyzeBtn.disabled = selectedFiles.length === 0; |
| |
| |
| const btnText = analyzeBtn.querySelector('.btn-text'); |
| if (selectedFiles.length === 0) { |
| btnText.textContent = 'Analyze Images'; |
| } else if (selectedFiles.length === 1) { |
| btnText.textContent = 'Analyze Image'; |
| } else { |
| btnText.textContent = `Analyze ${selectedFiles.length} Images`; |
| } |
| } |
|
|
| |
| window.removeFile = removeFile; |
| window.clearAllFiles = clearAllFiles; |
| window.getSelectedFiles = () => selectedFiles; |
| } |
|
|
| |
| function initAnalysis() { |
| |
| } |
|
|
| function startAnalysis() { |
| const selectedFiles = window.getSelectedFiles(); |
| if (!selectedFiles || selectedFiles.length === 0) { |
| window.oncoConnect.showToast('Please select at least one image to analyze', 'error'); |
| return; |
| } |
|
|
| const uploadSection = document.getElementById('uploadSection'); |
| const loadingSection = document.getElementById('loadingSection'); |
| const resultsSection = document.getElementById('resultsSection'); |
|
|
| |
| uploadSection.style.display = 'none'; |
| loadingSection.style.display = 'block'; |
| resultsSection.style.display = 'none'; |
|
|
| |
| const fileCount = selectedFiles.length; |
| const message = fileCount === 1 ? 'Analysis started...' : `Analysis started for ${fileCount} images...`; |
| window.oncoConnect.showToast(message, 'info'); |
|
|
| |
| const steps = ['step1', 'step2', 'step3', 'step4']; |
| const stepTexts = [ |
| 'Starting analysis...', |
| `Processing ${fileCount} image${fileCount > 1 ? 's' : ''}...`, |
| 'Running AI classification...', |
| 'Finding clinical trials...' |
| ]; |
| let currentStep = 0; |
| const progressFill = document.getElementById('progressFill'); |
| const progressText = document.getElementById('progressText'); |
|
|
| const progressInterval = setInterval(() => { |
| if (currentStep > 0) { |
| |
| const prevStep = document.getElementById(steps[currentStep - 1]); |
| prevStep.classList.remove('active'); |
| prevStep.classList.add('completed'); |
| } |
| |
| if (currentStep < steps.length) { |
| |
| const currentStepEl = document.getElementById(steps[currentStep]); |
| currentStepEl.classList.add('active'); |
| |
| |
| const progress = ((currentStep + 1) / steps.length) * 100; |
| progressFill.style.width = progress + '%'; |
| progressText.textContent = stepTexts[currentStep]; |
| |
| currentStep++; |
| } else { |
| clearInterval(progressInterval); |
| |
| progressFill.style.width = '100%'; |
| progressText.textContent = 'Analysis complete!'; |
| |
| |
| setTimeout(() => { |
| showResults(); |
| }, 1000); |
| } |
| }, 1200); |
| } |
|
|
| function showResults() { |
| const loadingSection = document.getElementById('loadingSection'); |
| const resultsSection = document.getElementById('resultsSection'); |
| const selectedFiles = window.getSelectedFiles(); |
|
|
| loadingSection.style.display = 'none'; |
| resultsSection.style.display = 'block'; |
|
|
| |
| loadResultsData(); |
| |
| |
| setupImageSelector(selectedFiles); |
| |
| |
| resultsSection.scrollIntoView({ behavior: 'smooth' }); |
| } |
|
|
| function setupImageSelector(files) { |
| const imageSelector = document.getElementById('imageSelector'); |
| const imageSelect = document.getElementById('imageSelect'); |
| |
| if (files.length > 1) { |
| |
| imageSelector.style.display = 'block'; |
| imageSelect.innerHTML = ''; |
| |
| files.forEach((file, index) => { |
| const option = document.createElement('option'); |
| option.value = index; |
| option.textContent = file.name; |
| imageSelect.appendChild(option); |
| }); |
| |
| |
| imageSelect.addEventListener('change', (e) => { |
| const selectedIndex = parseInt(e.target.value); |
| switchToImage(selectedIndex, files[selectedIndex]); |
| }); |
| |
| |
| switchToImage(0, files[0]); |
| } else { |
| |
| imageSelector.style.display = 'none'; |
| if (files.length === 1) { |
| switchToImage(0, files[0]); |
| } |
| } |
| } |
|
|
| function switchToImage(index, file) { |
| |
| document.getElementById('imageFileName').textContent = file.name; |
| document.getElementById('imageResolution').textContent = '2048×2048'; |
| document.getElementById('analyzedTime').textContent = '2 minutes ago'; |
| |
| |
| const img = document.getElementById('analyzedImage'); |
| img.src = URL.createObjectURL(file); |
| img.alt = `Analyzed pathology image: ${file.name}`; |
| |
| |
| initImageViewer(); |
| } |
|
|
| function loadSampleCase() { |
| |
| const mockFiles = [ |
| { |
| name: 'sample_breast_wsi_1.jpg', |
| size: 2.4 * 1024 * 1024, |
| type: 'image/jpeg' |
| }, |
| { |
| name: 'sample_breast_wsi_2.jpg', |
| size: 1.8 * 1024 * 1024, |
| type: 'image/jpeg' |
| } |
| ]; |
| |
| |
| window.getSelectedFiles = () => mockFiles; |
| |
| |
| updateFilePreview(); |
| updateAnalyzeButton(); |
| |
| |
| setTimeout(() => { |
| startAnalysis(); |
| }, 1000); |
| |
| function updateFilePreview() { |
| const filePreview = document.getElementById('filePreview'); |
| const previewList = document.getElementById('previewList'); |
| const fileCount = document.getElementById('fileCount'); |
| |
| filePreview.style.display = 'block'; |
| fileCount.textContent = `${mockFiles.length} files`; |
| |
| previewList.innerHTML = ''; |
| mockFiles.forEach((file, index) => { |
| const previewItem = createFilePreviewItem(file, index); |
| previewList.appendChild(previewItem); |
| }); |
| } |
| |
| function updateAnalyzeButton() { |
| const analyzeBtn = document.getElementById('analyzeBtn'); |
| analyzeBtn.disabled = false; |
| |
| const btnText = analyzeBtn.querySelector('.btn-text'); |
| btnText.textContent = `Analyze ${mockFiles.length} Images`; |
| } |
| |
| function createFilePreviewItem(file, index) { |
| const item = document.createElement('div'); |
| item.className = 'preview-item'; |
| item.innerHTML = ` |
| <div class="preview-icon"> |
| <svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| <rect x="3" y="3" width="18" height="18" rx="2" ry="2" stroke="currentColor" stroke-width="2"/> |
| <circle cx="8.5" cy="8.5" r="1.5" stroke="currentColor" stroke-width="2"/> |
| <path d="M21 15L16 10L5 21" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
| </svg> |
| </div> |
| <div class="preview-details"> |
| <div class="file-name">${file.name}</div> |
| <div class="file-meta"> |
| <span class="file-size">${window.oncoConnect.formatFileSize(file.size)}</span> |
| <span class="file-status">Ready to analyze</span> |
| </div> |
| </div> |
| <button class="remove-file" onclick="removeFile(${index})" aria-label="Remove ${file.name}"> |
| <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| <line x1="18" y1="6" x2="6" y2="18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
| <line x1="6" y1="6" x2="18" y2="18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
| </svg> |
| </button> |
| `; |
| return item; |
| } |
| } |
|
|
| |
| function initResults() { |
| |
| document.getElementById('saveCase').addEventListener('click', () => { |
| requireAuth(saveCase); |
| }); |
| |
| |
| document.getElementById('createChallenge').addEventListener('click', () => { |
| requireAuth(() => { |
| window.oncoConnect.openModal('createChallengeModal'); |
| }); |
| }); |
| |
| |
| document.getElementById('analyzeAnother').addEventListener('click', resetAnalyzer); |
| |
| |
| initHeatmapControls(); |
| |
| |
| initTrialFilters(); |
|
|
| |
| const exportBtn = document.getElementById('exportTrials'); |
| if (exportBtn) exportBtn.addEventListener('click', exportTrials); |
| } |
|
|
| function loadResultsData() { |
| |
| const analyzedImage = document.getElementById('analyzedImage'); |
| const uploadZone = document.getElementById('uploadZone'); |
| |
| if (uploadZone.selectedFile) { |
| |
| const reader = new FileReader(); |
| reader.onload = function(e) { |
| analyzedImage.src = e.target.result; |
| }; |
| reader.readAsDataURL(uploadZone.selectedFile); |
| |
| |
| document.getElementById('imageFileName').textContent = uploadZone.selectedFile.name; |
| document.getElementById('imageResolution').textContent = '2048×2048'; |
| } else { |
| |
| analyzedImage.src = createPlaceholderImage(400, 400, '#f8fafc', '🔬 Pathology Image'); |
| document.getElementById('imageFileName').textContent = 'sample_breast_wsi.jpg'; |
| document.getElementById('imageResolution').textContent = '2048×2048'; |
| } |
| |
| |
| document.getElementById('analyzedTime').textContent = 'Just now'; |
| |
| |
| createHeatmapOverlay(); |
| |
| |
| document.getElementById('cancerStatus').textContent = 'Yes'; |
| document.getElementById('confidenceValue').textContent = '94.2%'; |
| document.getElementById('diagnosisExplanation').textContent = |
| 'Analysis indicates invasive ductal carcinoma with well-defined tumor boundaries. High cellular density and irregular nuclear morphology support malignant classification.'; |
| |
| |
| document.getElementById('chemoResponse').textContent = 'Likely Responsive'; |
| document.getElementById('chemoExplanation').textContent = |
| 'Tumor characteristics suggest good response to standard chemotherapy protocols. High proliferation markers and hormone receptor status indicate favorable treatment outcomes.'; |
|
|
| |
| updateRiskAssessment(87); |
| |
| |
| loadClinicalTrials(); |
| |
| |
| initImageViewer(); |
| } |
|
|
| function updateRiskAssessment(score) { |
| const riskScoreEl = document.getElementById('riskScore'); |
| const riskBadgeEl = document.getElementById('riskBadge'); |
| const riskCategoryEl = document.getElementById('riskCategory'); |
| if (!riskScoreEl || !riskBadgeEl || !riskCategoryEl) return; |
|
|
| riskScoreEl.textContent = String(score); |
| let riskLevel, riskClass; |
| if (score >= 70) { riskLevel = 'HIGH RISK'; riskClass = 'high-risk'; } |
| else if (score >= 40) { riskLevel = 'MEDIUM RISK'; riskClass = 'medium-risk'; } |
| else { riskLevel = 'LOW RISK'; riskClass = 'low-risk'; } |
|
|
| riskBadgeEl.textContent = riskLevel; |
| riskBadgeEl.className = 'card-badge ' + riskClass; |
| riskCategoryEl.textContent = riskLevel; |
| } |
|
|
| function createPlaceholderImage(width, height, color, text) { |
| const canvas = document.createElement('canvas'); |
| canvas.width = width; |
| canvas.height = height; |
| |
| const ctx = canvas.getContext('2d'); |
| ctx.fillStyle = color; |
| ctx.fillRect(0, 0, width, height); |
| |
| |
| ctx.strokeStyle = '#e2e8f0'; |
| ctx.lineWidth = 1; |
| |
| |
| for (let i = 0; i < width; i += 20) { |
| for (let j = 0; j < height; j += 20) { |
| if (Math.random() > 0.7) { |
| ctx.fillStyle = '#e2e8f0'; |
| ctx.fillRect(i, j, 15, 15); |
| } |
| } |
| } |
| |
| |
| ctx.fillStyle = '#9ca3af'; |
| ctx.font = '20px sans-serif'; |
| ctx.textAlign = 'center'; |
| ctx.fillText(text, width/2, height/2); |
| |
| return canvas.toDataURL(); |
| } |
|
|
| function createHeatmapOverlay() { |
| const canvas = document.getElementById('heatmapOverlay'); |
| const ctx = canvas.getContext('2d'); |
| |
| canvas.width = 400; |
| canvas.height = 400; |
| |
| |
| const gradient = ctx.createRadialGradient(200, 200, 0, 200, 200, 150); |
| gradient.addColorStop(0, 'rgba(255, 0, 0, 0.8)'); |
| gradient.addColorStop(0.5, 'rgba(255, 255, 0, 0.6)'); |
| gradient.addColorStop(1, 'rgba(255, 0, 0, 0)'); |
| |
| ctx.fillStyle = gradient; |
| ctx.fillRect(0, 0, 400, 400); |
| |
| |
| for (let i = 0; i < 5; i++) { |
| const x = Math.random() * 400; |
| const y = Math.random() * 400; |
| const radius = Math.random() * 30 + 20; |
| |
| const spotGradient = ctx.createRadialGradient(x, y, 0, x, y, radius); |
| spotGradient.addColorStop(0, 'rgba(255, 0, 0, 0.9)'); |
| spotGradient.addColorStop(1, 'rgba(255, 0, 0, 0)'); |
| |
| ctx.fillStyle = spotGradient; |
| ctx.beginPath(); |
| ctx.arc(x, y, radius, 0, 2 * Math.PI); |
| ctx.fill(); |
| } |
| } |
|
|
| function initImageViewer() { |
| const zoomInBtn = document.getElementById('zoomIn'); |
| const zoomOutBtn = document.getElementById('zoomOut'); |
| const fitScreenBtn = document.getElementById('fitScreen'); |
| const downloadOverlayBtn = document.getElementById('downloadOverlay'); |
| const analyzedImage = document.getElementById('analyzedImage'); |
| |
| let currentZoom = 1; |
| const minZoom = 0.5; |
| const maxZoom = 3; |
| const zoomStep = 0.2; |
| |
| zoomInBtn.addEventListener('click', () => { |
| currentZoom = Math.min(currentZoom + zoomStep, maxZoom); |
| updateImageZoom(); |
| }); |
| |
| zoomOutBtn.addEventListener('click', () => { |
| currentZoom = Math.max(currentZoom - zoomStep, minZoom); |
| updateImageZoom(); |
| }); |
| |
| fitScreenBtn.addEventListener('click', () => { |
| currentZoom = 1; |
| updateImageZoom(); |
| }); |
| |
| downloadOverlayBtn.addEventListener('click', () => { |
| downloadHeatmap(); |
| }); |
| |
| function updateImageZoom() { |
| analyzedImage.style.transform = `scale(${currentZoom})`; |
| analyzedImage.style.transformOrigin = 'center'; |
| } |
| |
| function downloadHeatmap() { |
| const canvas = document.getElementById('heatmapOverlay'); |
| const link = document.createElement('a'); |
| link.download = 'heatmap-overlay.png'; |
| link.href = canvas.toDataURL(); |
| link.click(); |
| window.oncoConnect.showToast('Heatmap downloaded successfully!', 'success'); |
| } |
| } |
|
|
| function initHeatmapControls() { |
| const heatmapToggle = document.getElementById('heatmapToggle'); |
| const opacitySlider = document.getElementById('opacitySlider'); |
| const opacityValue = document.getElementById('opacityValue'); |
| const heatmapOverlay = document.getElementById('heatmapOverlay'); |
| |
| |
| updateHeatmapVisibility(); |
| |
| heatmapToggle.addEventListener('change', () => { |
| updateHeatmapVisibility(); |
| }); |
| |
| opacitySlider.addEventListener('input', () => { |
| const opacity = opacitySlider.value / 100; |
| heatmapOverlay.style.opacity = opacity; |
| opacityValue.textContent = opacitySlider.value + '%'; |
| }); |
| } |
|
|
| function updateHeatmapVisibility() { |
| const heatmapToggle = document.getElementById('heatmapToggle'); |
| const heatmapOverlay = document.getElementById('heatmapOverlay'); |
| const analyzedImage = document.getElementById('analyzedImage'); |
| |
| if (heatmapToggle.checked) { |
| |
| analyzedImage.style.display = 'block'; |
| heatmapOverlay.style.display = 'block'; |
| } else { |
| |
| analyzedImage.style.display = 'block'; |
| heatmapOverlay.style.display = 'none'; |
| } |
| } |
|
|
| function initTrialFilters() { |
| const filterChips = document.querySelectorAll('.filter-chip'); |
| filterChips.forEach(chip => { |
| chip.addEventListener('click', () => { |
| const group = chip.parentElement; |
| |
| |
| group.querySelectorAll('.filter-chip').forEach(sibling => { |
| sibling.classList.remove('active'); |
| }); |
| |
| |
| chip.classList.add('active'); |
| |
| |
| filterTrials(); |
| }); |
| }); |
| } |
|
|
| function filterTrials() { |
| const activePhase = document.querySelector('.filter-chip[data-phase].active')?.dataset.phase || 'all'; |
| const activeStatus = document.querySelector('.filter-chip[data-status].active')?.dataset.status || 'all'; |
| const activeDistance = document.querySelector('.filter-chip[data-distance].active')?.dataset.distance || 'all'; |
| const activeBiomarker = document.querySelector('.filter-chip[data-biomarker].active')?.dataset.biomarker || 'all'; |
| |
| const trialCards = document.querySelectorAll('.trial-card'); |
| |
| trialCards.forEach(card => { |
| const phase = card.dataset.phase; |
| const status = card.dataset.status; |
| const distance = card.dataset.distance || 'remote'; |
| const biomarkers = (card.dataset.biomarkers || '').split(','); |
|
|
| const phaseMatch = activePhase === 'all' || phase === activePhase; |
| const statusMatch = activeStatus === 'all' || status === activeStatus; |
| const distanceMatch = activeDistance === 'all' || distance === activeDistance; |
| const biomarkerMatch = activeBiomarker === 'all' || biomarkers.includes(activeBiomarker); |
| |
| card.style.display = (phaseMatch && statusMatch && distanceMatch && biomarkerMatch) ? 'block' : 'none'; |
| }); |
| } |
|
|
| function loadClinicalTrials() { |
| const trialsList = document.getElementById('trialsList'); |
| const trials = window.oncoConnect.getClinicalTrials(); |
| |
| trialsList.innerHTML = trials.map(trial => ` |
| <div class="trial-card" |
| data-phase="${trial.phase.split(' ')[1]}" |
| data-status="${trial.status.toLowerCase()}" |
| data-distance="${trial.distance || 'remote'}" |
| data-biomarkers="${(trial.biomarkers || []).join(',')}"> |
| <div class="trial-header"> |
| <h3 class="trial-title">${trial.title}</h3> |
| <div class="trial-badges"> |
| <span class="trial-badge phase">${trial.phase}</span> |
| <span class="trial-badge status ${trial.status.toLowerCase()}">${trial.status}</span> |
| </div> |
| </div> |
| <div class="trial-description">${trial.description}</div> |
| <div class="trial-details"> |
| <div class="trial-detail"> |
| <span class="detail-label">Inclusion:</span> |
| <span class="detail-value">${trial.inclusion}</span> |
| </div> |
| <div class="trial-detail"> |
| <span class="detail-label">Site:</span> |
| <span class="detail-value">${trial.location}</span> |
| </div> |
| <div class="trial-detail"> |
| <span class="detail-label">Contact:</span> |
| <span class="detail-value">${trial.contact}</span> |
| </div> |
| </div> |
| </div> |
| `).join(''); |
| } |
|
|
| function saveCase() { |
| const caseData = { |
| id: window.oncoConnect.generateId(), |
| fileName: document.getElementById('fileName').textContent, |
| diagnosis: document.getElementById('cancerStatus').textContent, |
| confidence: document.getElementById('confidenceValue').textContent, |
| timestamp: new Date().toISOString(), |
| chemoResponse: document.getElementById('chemoResponse').textContent |
| }; |
| |
| |
| const savedCases = window.oncoConnect.getSavedData('savedCases') || []; |
| savedCases.push(caseData); |
| window.oncoConnect.saveData('savedCases', savedCases); |
| |
| window.oncoConnect.showToast('Case saved successfully!'); |
| } |
|
|
| function resetAnalyzer() { |
| document.getElementById('uploadSection').style.display = 'block'; |
| document.getElementById('loadingSection').style.display = 'none'; |
| document.getElementById('resultsSection').style.display = 'none'; |
| |
| |
| document.getElementById('fileInput').value = ''; |
| document.getElementById('filePreview').style.display = 'none'; |
| document.getElementById('analyzeBtn').disabled = true; |
| |
| |
| window.scrollTo({ top: 0, behavior: 'smooth' }); |
| } |
|
|
| |
| function initCreateChallengeModal() { |
| const modal = document.getElementById('createChallengeModal'); |
| const form = document.getElementById('challengeForm'); |
| const closeBtn = document.getElementById('closeChallengeModal'); |
| const cancelBtn = document.getElementById('cancelChallenge'); |
| |
| closeBtn.addEventListener('click', () => { |
| window.oncoConnect.closeModal(modal); |
| }); |
| |
| cancelBtn.addEventListener('click', () => { |
| window.oncoConnect.closeModal(modal); |
| }); |
| |
| form.addEventListener('submit', (e) => { |
| e.preventDefault(); |
| createChallenge(); |
| }); |
| } |
|
|
| function createChallenge() { |
| const title = document.getElementById('challengeTitle').value; |
| const description = document.getElementById('challengeDescription').value; |
| const difficulty = document.getElementById('challengeDifficulty').value; |
| |
| const challengeData = { |
| id: window.oncoConnect.generateId(), |
| title, |
| description, |
| difficulty, |
| solved: 0, |
| enrolled: true, |
| createdBy: 'user', |
| timestamp: new Date().toISOString() |
| }; |
| |
| |
| const challenges = window.oncoConnect.getSavedData('challenges') || []; |
| challenges.push(challengeData); |
| window.oncoConnect.saveData('challenges', challenges); |
| |
| |
| window.oncoConnect.closeModal('createChallengeModal'); |
| window.oncoConnect.showToast('Challenge created successfully!'); |
| |
| |
| document.getElementById('challengeForm').reset(); |
| } |