Spaces:
Sleeping
Sleeping
File size: 10,602 Bytes
d77360c | 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | <!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Second Life — Clinical Trial Matching</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body{background:linear-gradient(135deg,#0d1117 0%,#161b22 100%);min-height:100vh;}
.hero-title{font-size:3rem;font-weight:800;background:linear-gradient(90deg,#58a6ff,#79c0ff);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;}
.portal-card{background:#161b22;border:1px solid #30363d;border-radius:12px;padding:2rem;}
.form-control,.form-select{background:#0d1117;border-color:#30363d;color:#e6edf3;}
.form-control:focus,.form-select:focus{background:#0d1117;border-color:#58a6ff;color:#e6edf3;box-shadow:0 0 0 .2rem rgba(88,166,255,.25);}
.nav-tabs .nav-link{color:#8b949e;border-color:transparent;}
.nav-tabs .nav-link.active{color:#e6edf3;background:#161b22;border-color:#30363d #30363d #161b22;}
.err{color:#f85149;font-size:.85rem;min-height:1.2rem;}
</style>
</head>
<body>
<div class="container py-5">
<div class="text-center mb-5">
<div class="text-primary mb-2" style="font-size:2rem">⬡</div>
<h1 class="hero-title">Second Life</h1>
<p class="text-secondary fs-5 mb-1">AI-Powered Clinical Trial Matching</p>
<p class="text-muted small">Connecting patients with life-changing research opportunities</p>
</div>
<div class="row g-4 justify-content-center">
<!-- Patient Portal -->
<div class="col-lg-5">
<div class="portal-card">
<div class="text-center mb-3" style="font-size:2.5rem">🧑⚕️</div>
<h4 class="text-center mb-1">Patient Portal</h4>
<p class="text-muted text-center small mb-3">Find clinical trials matched to your conditions</p>
<ul class="nav nav-tabs mb-3" id="patientTabs">
<li class="nav-item"><a class="nav-link active" href="#" data-pt="p-login">Login</a></li>
<li class="nav-item"><a class="nav-link" href="#" data-pt="p-register">Register</a></li>
</ul>
<!-- Login -->
<div id="p-login">
<input type="text" class="form-control mb-2" id="pl-user" placeholder="Username">
<input type="password" class="form-control mb-3" id="pl-pass" placeholder="Password">
<div class="err mb-2" id="pl-err"></div>
<button class="btn btn-primary w-100" onclick="patientLogin()">Login as Patient</button>
<p class="text-muted text-center mt-2 small">Demo: john_doe / pass123</p>
</div>
<!-- Register -->
<div id="p-register" style="display:none">
<div class="row g-2 mb-2">
<div class="col"><input type="text" class="form-control form-control-sm" id="pr-fn" placeholder="First Name"></div>
<div class="col"><input type="text" class="form-control form-control-sm" id="pr-ln" placeholder="Last Name"></div>
</div>
<div class="row g-2 mb-2">
<div class="col"><input type="date" class="form-control form-control-sm" id="pr-dob"></div>
<div class="col">
<select class="form-select form-select-sm" id="pr-gender">
<option value="">Gender</option>
<option value="M">Male</option>
<option value="F">Female</option>
<option value="O">Other</option>
</select>
</div>
</div>
<input type="text" class="form-control form-control-sm mb-2" id="pr-addr" placeholder="Address (123 Main St Boston MA 02101)">
<input type="text" class="form-control form-control-sm mb-2" id="pr-user" placeholder="Username">
<input type="password" class="form-control form-control-sm mb-3" id="pr-pass" placeholder="Password">
<div class="err mb-2" id="pr-err"></div>
<button class="btn btn-primary w-100" onclick="patientRegister()">Create Patient Account</button>
</div>
</div>
</div>
<!-- Hospital Portal -->
<div class="col-lg-5">
<div class="portal-card">
<div class="text-center mb-3" style="font-size:2.5rem">🏥</div>
<h4 class="text-center mb-1">Hospital / Research Portal</h4>
<p class="text-muted text-center small mb-3">Find eligible patients for your clinical trials</p>
<ul class="nav nav-tabs mb-3" id="hospitalTabs">
<li class="nav-item"><a class="nav-link active" href="#" data-ht="h-login">Login</a></li>
<li class="nav-item"><a class="nav-link" href="#" data-ht="h-register">Register</a></li>
</ul>
<!-- Login -->
<div id="h-login">
<input type="text" class="form-control mb-2" id="hl-user" placeholder="Username">
<input type="password" class="form-control mb-3" id="hl-pass" placeholder="Password">
<div class="err mb-2" id="hl-err"></div>
<button class="btn btn-success w-100" onclick="hospitalLogin()">Login as Hospital</button>
<p class="text-muted text-center mt-2 small">Demo: mgh / mgh123</p>
</div>
<!-- Register -->
<div id="h-register" style="display:none">
<input type="text" class="form-control form-control-sm mb-2" id="hr-name" placeholder="Hospital / Institution Name">
<input type="text" class="form-control form-control-sm mb-2" id="hr-loc" placeholder="Location (City, ST) e.g. Boston, MA">
<input type="text" class="form-control form-control-sm mb-2" id="hr-conds"
placeholder="Research conditions (comma-separated, e.g. diabetes, hypertension)">
<input type="text" class="form-control form-control-sm mb-2" id="hr-user" placeholder="Username">
<input type="password" class="form-control form-control-sm mb-3" id="hr-pass" placeholder="Password">
<div class="err mb-2" id="hr-err"></div>
<button class="btn btn-success w-100" onclick="hospitalRegister()">Create Hospital Account</button>
</div>
</div>
</div>
</div>
<p class="text-center text-muted small mt-4">DSCI 5260 | Group 7 — Second Life Clinical Trial Matching</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Enter key submit helpers
function _onEnter(inputId, fn) {
document.getElementById(inputId).addEventListener('keydown', e => { if(e.key==='Enter') fn(); });
}
document.addEventListener('DOMContentLoaded', () => {
_onEnter('pl-pass', patientLogin);
_onEnter('pl-user', patientLogin);
_onEnter('pr-pass', patientRegister);
_onEnter('hl-pass', hospitalLogin);
_onEnter('hl-user', hospitalLogin);
_onEnter('hr-pass', hospitalRegister);
});
// Tab switching
document.querySelectorAll('#patientTabs .nav-link').forEach(a => {
a.addEventListener('click', e => {
e.preventDefault();
document.querySelectorAll('#patientTabs .nav-link').forEach(x => x.classList.remove('active'));
a.classList.add('active');
document.getElementById('p-login').style.display = a.dataset.pt === 'p-login' ? '' : 'none';
document.getElementById('p-register').style.display = a.dataset.pt === 'p-register' ? '' : 'none';
});
});
document.querySelectorAll('#hospitalTabs .nav-link').forEach(a => {
a.addEventListener('click', e => {
e.preventDefault();
document.querySelectorAll('#hospitalTabs .nav-link').forEach(x => x.classList.remove('active'));
a.classList.add('active');
document.getElementById('h-login').style.display = a.dataset.ht === 'h-login' ? '' : 'none';
document.getElementById('h-register').style.display = a.dataset.ht === 'h-register' ? '' : 'none';
});
});
async function patientLogin() {
const u = document.getElementById('pl-user').value.trim();
const p = document.getElementById('pl-pass').value;
const e = document.getElementById('pl-err');
e.textContent = '';
if (!u || !p) { e.textContent = 'Enter username and password'; return; }
const r = await post('/auth/patient/login', {username:u, password:p});
if (r.ok) location.href = '/patient'; else e.textContent = (await r.json()).error || 'Login failed';
}
async function patientRegister() {
const body = {
username: document.getElementById('pr-user').value.trim(),
password: document.getElementById('pr-pass').value,
first_name: document.getElementById('pr-fn').value.trim(),
last_name: document.getElementById('pr-ln').value.trim(),
dob: document.getElementById('pr-dob').value,
gender: document.getElementById('pr-gender').value,
address: document.getElementById('pr-addr').value.trim(),
};
const e = document.getElementById('pr-err');
e.textContent = '';
if (!body.username || !body.password) { e.textContent = 'Username and password required'; return; }
const r = await post('/auth/patient/register', body);
if (r.ok) location.href = '/patient'; else e.textContent = (await r.json()).error || 'Registration failed';
}
async function hospitalLogin() {
const u = document.getElementById('hl-user').value.trim();
const p = document.getElementById('hl-pass').value;
const e = document.getElementById('hl-err');
e.textContent = '';
if (!u || !p) { e.textContent = 'Enter username and password'; return; }
const r = await post('/auth/hospital/login', {username:u, password:p});
if (r.ok) location.href = '/hospital'; else e.textContent = (await r.json()).error || 'Login failed';
}
async function hospitalRegister() {
const condsRaw = document.getElementById('hr-conds').value.trim();
const body = {
username: document.getElementById('hr-user').value.trim(),
password: document.getElementById('hr-pass').value,
hospital_name: document.getElementById('hr-name').value.trim(),
location: document.getElementById('hr-loc').value.trim(),
research_conditions: condsRaw ? condsRaw.split(',').map(s => s.trim().toLowerCase()).filter(Boolean) : [],
};
const e = document.getElementById('hr-err');
e.textContent = '';
if (!body.username || !body.password || !body.hospital_name) { e.textContent = 'All fields required'; return; }
const r = await post('/auth/hospital/register', body);
if (r.ok) location.href = '/hospital'; else e.textContent = (await r.json()).error || 'Registration failed';
}
function post(url, body) {
return fetch(url, {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body)});
}
</script>
</body>
</html>
|