Agile / project 5 /script.js
thatsdevvvv's picture
Upload 2050 files
390cffd verified
// Shared utilities and state management
class OncoConnect {
constructor() {
this.init();
}
init() {
// Initialize toast system
this.initToast();
// Initialize navigation
this.initNavigation();
// Initialize modals
this.initModals();
// Load saved data
this.loadData();
}
// Toast System
initToast() {
if (!document.getElementById('toast')) {
const toast = document.createElement('div');
toast.id = 'toast';
toast.className = 'toast';
toast.setAttribute('role', 'alert');
toast.setAttribute('aria-live', 'polite');
document.body.appendChild(toast);
}
}
showToast(message, type = 'success') {
const toast = document.getElementById('toast');
if (toast) {
toast.textContent = message;
toast.className = `toast ${type}`;
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}
}
// Navigation
initNavigation() {
// Handle mobile navigation if needed
// Currently using simple navigation
}
// Modal System
initModals() {
// Handle modal close on backdrop click
document.addEventListener('click', (e) => {
if (e.target.classList.contains('modal')) {
this.closeModal(e.target);
}
});
// Handle escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
const openModal = document.querySelector('.modal.show');
if (openModal) {
this.closeModal(openModal);
}
const openDrawer = document.querySelector('.drawer.show');
if (openDrawer) {
this.closeDrawer(openDrawer);
}
}
});
}
openModal(modalId) {
const modal = document.getElementById(modalId);
if (modal) {
modal.classList.add('show');
modal.setAttribute('aria-hidden', 'false');
// Focus first focusable element
const focusable = modal.querySelector('input, button, select, textarea');
if (focusable) {
setTimeout(() => focusable.focus(), 100);
}
}
}
closeModal(modal) {
if (typeof modal === 'string') {
modal = document.getElementById(modal);
}
if (modal) {
modal.classList.remove('show');
modal.setAttribute('aria-hidden', 'true');
}
}
openDrawer(drawerId) {
const drawer = document.getElementById(drawerId);
if (drawer) {
drawer.classList.add('show');
drawer.setAttribute('aria-hidden', 'false');
}
}
closeDrawer(drawer) {
if (typeof drawer === 'string') {
drawer = document.getElementById(drawer);
}
if (drawer) {
drawer.classList.remove('show');
drawer.setAttribute('aria-hidden', 'true');
}
}
// Data Management
loadData() {
this.data = {
savedCases: this.getSavedData('savedCases') || [],
enrollments: this.getSavedData('enrollments') || [],
connections: this.getSavedData('connections') || [],
challenges: this.getSavedData('challenges') || this.getDefaultChallenges()
};
}
getSavedData(key) {
try {
return JSON.parse(localStorage.getItem(key));
} catch {
return null;
}
}
saveData(key, data) {
try {
localStorage.setItem(key, JSON.stringify(data));
} catch {
console.warn('Failed to save data to localStorage');
}
}
// Default Data
getDefaultChallenges() {
return [
{
id: 'rare-disease-drug',
title: 'Rare Disease Drug Response Predictive Modeling',
description: 'Drug development for rare diseases is slowed by small patient populations and limited trial data. Students are tasked with building an ML model that predicts patient response to candidate compounds using pre-clinical and limited clinical datasets.',
difficulty: 'Expert',
solved: 12,
enrolled: false
},
{
id: 'prostate-gleason',
title: 'Prostate Gleason Grading',
description: 'Create automated systems for accurate Gleason scoring of prostate cancer specimens using deep learning.',
difficulty: 'Expert',
solved: 18,
enrolled: false
},
{
id: 'lung-nodule',
title: 'Lung Nodule Detection',
description: 'Build robust models for detecting and classifying lung nodules in histopathology images.',
difficulty: 'Intermediate',
solved: 31,
enrolled: false
},
{
id: 'colon-polyp',
title: 'Colon Polyp Segmentation',
description: 'Develop precise segmentation algorithms for colon polyp identification and boundary delineation.',
difficulty: 'Advanced',
solved: 15,
enrolled: false
},
{
id: 'skin-lesion',
title: 'Skin Lesion Triage',
description: 'Create triage systems for skin lesion classification to assist in early melanoma detection.',
difficulty: 'Beginner',
solved: 42,
enrolled: false
},
{
id: 'wsi-artifact',
title: 'WSI Artifact Removal',
description: 'Develop methods to detect and remove common artifacts in whole slide images for better analysis.',
difficulty: 'Intermediate',
solved: 27,
enrolled: false
}
];
}
getDefaultProfiles() {
return [
{
id: 'sarah-chen',
name: 'Dr. Sarah Chen',
role: 'Senior Pathologist',
expertise: ['Breast', 'Deep Learning', 'WSI Analysis'],
solved: 50,
bio: 'Leading pathologist specializing in breast cancer diagnosis with extensive experience in AI-assisted pathology. Published researcher in computational pathology with focus on whole slide image analysis.'
},
{
id: 'michael-torres',
name: 'Dr. Michael Torres',
role: 'ML Research Scientist',
expertise: ['Prostate', 'Computer Vision', 'Segmentation'],
solved: 45,
bio: 'Machine learning researcher focused on medical imaging applications. Expert in developing robust computer vision algorithms for pathology image analysis.'
},
{
id: 'emily-rodriguez',
name: 'Dr. Emily Rodriguez',
role: 'Digital Pathologist',
expertise: ['Segmentation', 'Lung', 'Feature Extraction'],
solved: 41,
bio: 'Digital pathology expert with strong background in image segmentation and feature extraction for pulmonary pathology applications.'
},
{
id: 'david-kim',
name: 'Dr. David Kim',
role: 'Pathology Resident',
expertise: ['Colon', 'Classification', 'Python'],
solved: 38,
bio: 'Pathology resident with programming expertise, focused on developing automated classification systems for gastrointestinal pathology.'
},
{
id: 'maria-gonzalez',
name: 'Dr. Maria Gonzalez',
role: 'Research Director',
expertise: ['Multi-organ', 'AI Ethics', 'Clinical Translation'],
solved: 35,
bio: 'Research director overseeing AI implementation in clinical pathology with expertise in ethical AI development and clinical translation.'
},
{
id: 'james-wilson',
name: 'Dr. James Wilson',
role: 'Dermatopathologist',
expertise: ['Skin', 'Melanoma', 'Diagnostic AI'],
solved: 32,
bio: 'Dermatopathologist specializing in melanoma diagnosis with focus on developing AI tools for skin cancer detection and classification.'
},
{
id: 'lisa-patel',
name: 'Dr. Lisa Patel',
role: 'Computational Pathologist',
expertise: ['Image Processing', 'Quality Control', 'Artifact Detection'],
solved: 28,
bio: 'Computational pathologist focused on image quality assessment and artifact detection in digital pathology workflows.'
},
{
id: 'robert-zhang',
name: 'Dr. Robert Zhang',
role: 'Biomedical Engineer',
expertise: ['Algorithm Development', 'Performance Metrics', 'Validation'],
solved: 25,
bio: 'Biomedical engineer specializing in algorithm development and validation for medical imaging applications in pathology.'
},
{
id: 'anna-kowalski',
name: 'Dr. Anna Kowalski',
role: 'Pathology Fellow',
expertise: ['Hematopathology', 'Pattern Recognition', 'Research'],
solved: 22,
bio: 'Pathology fellow with research focus on hematologic malignancies and pattern recognition in blood and bone marrow specimens.'
},
{
id: 'thomas-mueller',
name: 'Dr. Thomas Mueller',
role: 'Medical Informatics Specialist',
expertise: ['Data Integration', 'Clinical Workflows', 'DICOM'],
solved: 20,
bio: 'Medical informatics specialist working on integration of AI tools into clinical pathology workflows and DICOM standard compliance.'
}
];
}
getClinicalTrials() {
return [
{
id: 'trial-1',
title: 'Immunotherapy Combination for Advanced Breast Cancer',
phase: 'Phase II',
status: 'Recruiting',
description: 'Evaluating combination immunotherapy in patients with advanced triple-negative breast cancer.',
inclusion: 'Confirmed TNBC, ECOG 0-1, adequate organ function',
location: 'Multiple US sites',
contact: 'clinical-trials@oncoconnect.org'
},
{
id: 'trial-2',
title: 'Targeted Therapy for High-Grade Prostate Cancer',
phase: 'Phase III',
status: 'Active',
description: 'Comparing targeted therapy versus standard care in high-grade prostate adenocarcinoma.',
inclusion: 'Gleason 8-10, metastatic disease, prior therapy allowed',
location: 'US and EU centers',
contact: 'prostate-study@oncoconnect.org'
},
{
id: 'trial-3',
title: 'Early Detection Biomarker Study',
phase: 'Phase I',
status: 'Recruiting',
description: 'Investigating novel biomarkers for early cancer detection across multiple tumor types.',
inclusion: 'High-risk patients, no prior cancer diagnosis',
location: 'Academic medical centers',
contact: 'biomarker-study@oncoconnect.org'
}
];
}
// Utility Functions
formatFileSize(bytes) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
generateId() {
return Date.now().toString(36) + Math.random().toString(36).substr(2);
}
debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
}
// Initialize OncoConnect
window.oncoConnect = new OncoConnect();
// Export for use in other scripts
if (typeof module !== 'undefined' && module.exports) {
module.exports = OncoConnect;
}