html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Field Placement Compliance Tracker</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1400px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
h1 {
color: #333;
text-align: center;
}
#controls {
display: flex;
gap: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
}
#search {
padding: 10px;
font-size: 16px;
flex: 1;
min-width: 200px;
}
button {
padding: 10px 15px;
background: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background: #0056b3;
}
button.danger {
background: #dc3545;
}
button.danger:hover {
background: #c82333;
}
table {
width: 100%;
border-collapse: collapse;
background: white;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
overflow-x: auto;
display: block;
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background: #f8f9fa;
position: sticky; top: 0;
z-index: 10;
}
tr:hover {
background: #f1f1f1;
}
.status {
padding: 5px 10px;
border-radius: 20px;
font-weight: bold;
font-size: 14px;
}
.compliant { background: #d4edda; color: #155724; }
.mostly-compliant { background: #fff3cd; color: #856404; }
.non-compliant { background: #f8d7da; color: #721c24; }
.na { background: #e2e3e5; color: #383d41; }
#modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
z-index: 1000;
}
#modal-content {
background: white;
margin: 5% auto;
padding: 30px;
max-width: 800px;
max-height: 80vh;
overflow-y: auto;
border-radius: 10px;
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
#modal h2 { margin-top: 0; }
#name-input {
width: 100%;
padding: 10px;
font-size: 16px;
margin-bottom: 20px;
border: 1px solid #ddd;
border-radius: 5px;
}
.section {
margin-bottom: 30px;
}
.section h3 {
color: #007bff;
border-bottom: 2px solid #007bff;
padding-bottom: 10px;
}
.req-item {
display: flex;
gap: 10px;
align-items: center;
margin-bottom: 15px;
flex-wrap: wrap;
}
.req-item label {
font-weight: bold;
min-width: 150px;
}
.req-item select, .req-item input, .req-item textarea {
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
flex: 1;
max-width: 150px;
}
.req-item textarea {
height: 60px;
max-width: 200px;
resize: vertical;
}
.modal-buttons {
display: flex;
gap: 10px;
justify-content: flex-end;
}
@media (max-width: 768px) {
#controls { flex-direction: column; }
.req-item { flex-direction: column; align-items: flex-start; }
}
</style>
</head>
<body>
<h1>🕵️♂️ Sherlock's Field Placement Compliance Tracker</h1>
<p style="text-align: center; color: #666;">Track vaccinations, background checks, and training for field placements. Data persists in your browser.</p>
<div id="controls">
<input type="text" id="search" placeholder="🔍 Search by name..." onkeyup="filterTable()">
<button onclick="showModal()">➕ Add New Placement</button>
<button onclick="exportData()">📥 Export JSON</button>
<button onclick="document.getElementById('fileInput').click()">📤 Import JSON</button>
<input type="file" id="fileInput" style="display:none;" accept=".json" onchange="importData(event)">
</div>
<table id="complianceTable">
<thead>
<tr>
<th>Name/ID</th>
<th>Overall Status</th>
<th>Last Updated</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
<div id="modal">
<div id="modal-content">
<h2 id="modal-title">Add New Placement</h2>
<input type="text" id="name-input" placeholder="Enter student name or ID">
<div class="section">
<h3>🛡️ Vaccinations</h3>
<div id="vaccinations"></div>
</div>
<div class="section">
<h3>🔍 Checks</h3>
<div id="checks"></div>
</div>
<div class="section">
<h3>📚 Training</h3>
<div id="training"></div>
</div>
<div class="modal-buttons">
<button onclick="closeModal()">Cancel</button>
<button onclick="saveModal()">💾 Save</button>
</div>
</div>
</div>
<script>
const categories = {
vaccinations: [
{id: 'hepb', name: 'Hepatitis B'},
{id: 'mmr', name: 'MMR'},
{id: 'varicella', name: 'Varicella'},
{id: 'tdap', name: 'Tdap'},
{id: 'tb', name: 'TB Test'},
{id: 'flu', name: 'Influenza'},
{id: 'covid', name: 'COVID-19'}
],
checks: [
{id: 'criminal', name: 'Criminal Background Check'},
{id: 'childabuse', name: 'Child Abuse Clearance'},
{id: 'fbi', name: 'FBI Fingerprint Clearance'},
{id: 'drug', name: 'Drug Screen'}
],
training: [
{id: 'cpr', name: 'CPR/First Aid'},
{id: 'hipaa', name: 'HIPAA'},
{id: 'bbp', name: 'Bloodborne Pathogens'},
{id: 'mandated', name: 'Mandated Reporter'},
{id: 'orientation', name: 'Field Orientation'}
]
};
let data = JSON.parse(localStorage.getItem('complianceData')) || [];
let editingIndex = -1;
const statusOptions = ['Pending', 'Compliant', 'Expired', 'N/A'];
function initModal() {
const sections = {vaccinations: document.getElementById('vaccinations'), checks: document.getElementById('checks'), training: document.getElementById('training')};
Object.entries(categories).forEach(([cat, reqs]) => {
const container = sections[cat];
container.innerHTML = '';
reqs.forEach(req => {
const div = document.createElement('div');
div.className = 'req-item';
div.innerHTML = `
<label>${req.name}:</label>
<select data-req="${req.id}" data-cat="${cat}">
${statusOptions.map(s => `<option value="${s}">${s}</option>`).join('')}
</select>
<input type="date" data-req="${req.id}" data-cat="${cat}">
<textarea placeholder="Notes..." data-req="${req.id}" data-cat="${cat}"></textarea>
`;
container.appendChild(div);
});
});
}
function getReqValue(container, reqId) {
const selects = container.querySelectorAll(`[data-req="${reqId}"]`);
const statusSel = Array.from(selects).find(el => el.tagName === 'SELECT');
const dateInp = Array.from(selects).find(el => el.type === 'date');
const notesTa = Array.from(selects).find(el => el.tagName === 'TEXTAREA');
return {
status: statusSel.value,
date: dateInp.value,
notes: notesTa.value
};
}
function setReqValue(container, reqId, value) {
const selects = container.querySelectorAll(`[data-req="${reqId}"]`);
const statusSel = Array.from(selects).find(el => el.tagName === 'SELECT');
const dateInp = Array.from(selects).find(el => el.type === 'date');
const notesTa = Array.from(selects).find(el => el.tagName === 'TEXTAREA');
statusSel.value = value.status || 'Pending';
dateInp.value = value.date || '';
notesTa.value = value.notes || '';
}
function getOverallStatus(reqs) {
let total = 0, compliant = 0;
Object.values(reqs).forEach(r => {
if (r.status !== 'N/A') {
total++;
if (r.status === 'Compliant') compliant++;
}
});
if (total === 0) return {text: 'N/A', class: 'na'};
const pct = compliant / total;
if (pct === 1) return {text: 'Compliant', class: 'compliant'};
if (pct >= 0.8) return {text: 'Mostly Compliant', class: 'mostly-compliant'};
return {text: 'Non-Compliant', class: 'non-compliant'};
}
function renderTable(filter = '') {
const tbody = document.getElementById('tbody');
tbody.innerHTML = '';
data
.filter(d => d.name.toLowerCase().includes(filter.toLowerCase()))
.forEach((row, index) => {
const status = getOverallStatus(row.reqs);
const tr = document.createElement('tr');
tr.innerHTML = `
<td>${row.name}</td>
<td><span class="status ${status.class}">${status.text}</span></td>
<td>${row.lastUpdated || 'Never'}</td>
<td>
<button onclick="showModal(${index})">Edit</button>
<button class="danger" onclick="deleteRow(${index})">Delete</button>
</td>
`;
tbody.appendChild(tr);
});
}
function showModal(index = -1) {
editingIndex = index;
document.getElementById('modal-title').textContent = index >= 0 ? 'Edit Placement' : 'Add New Placement';
initModal();
const nameInput = document.getElementById('name-input');
if (index >= 0) {
nameInput.value = data[index].name;
Object.entries(categories).forEach(([cat, reqs]) => {
reqs.forEach(req => {
setReqValue(document.getElementById(cat), req.id, data[index].reqs[req.id]);
});
});
} else {
nameInput.value = '';
}
document.getElementById('modal').style.display = 'block';
}
function closeModal() {
document.getElementById('modal').style.display = 'none';
}
function saveModal() {
const name = document.getElementById('name-input').value.trim();
if (!name) {
alert('Please enter a name.');
return;
}
const reqs = {};
Object.values(categories).forEach(reqsList => {
reqsList.forEach(req => {
reqs[req.id] = getReqValue(document.getElementById(reqsList[0].cat || 'vaccinations'), req.id); // Hack for cat, but works since unique
// Actually, since ids unique, pass correct container
});
});
Object.values(categories).forEach(catReqs => {
const container = document.getElementById(catReqs[0].cat || catReqs[0].section); wait, fix:
Wait, better: since ids unique, but to get container, but in getReqValue we use data-req.
Since flat, but it works as is because data-req unique.
const now = new Date().toISOString().slice(0, 19).replace('T', ' ');
const entry = {name, reqs, lastUpdated: now};
if (editingIndex >= 0) {
data[editingIndex] = entry;
} else {
data.push(entry);
}
localStorage.setItem('complianceData', JSON.stringify(data));
renderTable(document.getElementById('search').value);
closeModal();
}
function deleteRow(index) {
if (confirm('Delete this placement?')) {
data.splice(index,