485 lines
14 KiB
HTML
485 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Split-Flap Board</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
*, *::before, *::after {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
html, body {
|
|
width: 100%;
|
|
height: 100%;
|
|
background: #111;
|
|
font-family: 'Roboto Mono', 'Courier New', monospace;
|
|
overflow-x: auto;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
body {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: flex-start;
|
|
padding: 30px 20px;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
#board-wrapper {
|
|
transform-origin: top center;
|
|
}
|
|
|
|
#board {
|
|
background: #151515;
|
|
padding: 24px 28px;
|
|
border: 3px solid #444;
|
|
border-radius: 4px;
|
|
box-shadow:
|
|
inset 0 2px 8px rgba(0,0,0,0.5),
|
|
0 0 30px rgba(0,0,0,0.6),
|
|
0 4px 16px rgba(0,0,0,0.4);
|
|
position: relative;
|
|
min-width: fit-content;
|
|
}
|
|
|
|
/* Metallic border overlay */
|
|
#board::before {
|
|
content: '';
|
|
position: absolute;
|
|
inset: -3px;
|
|
border-radius: 6px;
|
|
border: 3px solid transparent;
|
|
background: linear-gradient(to bottom, #666, #333, #555) border-box;
|
|
-webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
|
|
-webkit-mask-composite: xor;
|
|
mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
|
|
mask-composite: exclude;
|
|
pointer-events: none;
|
|
}
|
|
|
|
/* Date header */
|
|
#date-header {
|
|
text-align: center;
|
|
margin-bottom: 20px;
|
|
padding-bottom: 16px;
|
|
border-bottom: 2px solid #252525;
|
|
}
|
|
|
|
#date-row {
|
|
display: inline-flex;
|
|
justify-content: center;
|
|
flex-wrap: nowrap;
|
|
}
|
|
|
|
/* Section labels */
|
|
.section-label {
|
|
color: #ffb300;
|
|
font-weight: 700;
|
|
font-size: 16px;
|
|
letter-spacing: 2px;
|
|
margin: 18px 0 8px 0;
|
|
font-family: 'Roboto Mono', 'Courier New', monospace;
|
|
}
|
|
|
|
/* Column headers */
|
|
.header-row {
|
|
display: flex;
|
|
margin-bottom: 2px;
|
|
}
|
|
|
|
.header-cell {
|
|
background: #252525;
|
|
color: #999;
|
|
font-family: 'Roboto Mono', 'Courier New', monospace;
|
|
font-size: 13px;
|
|
font-weight: 700;
|
|
padding: 4px 0;
|
|
text-align: center;
|
|
letter-spacing: 1px;
|
|
border-radius: 2px;
|
|
margin-right: 2px;
|
|
}
|
|
|
|
.header-cell:last-child {
|
|
margin-right: 0;
|
|
}
|
|
|
|
/* Data rows */
|
|
.data-row {
|
|
display: flex;
|
|
margin-bottom: 1px;
|
|
height: 30px;
|
|
align-items: center;
|
|
}
|
|
|
|
/* Flap character unit */
|
|
.flap {
|
|
display: inline-block;
|
|
width: 18px;
|
|
height: 28px;
|
|
position: relative;
|
|
margin: 0 0.5px;
|
|
font-family: 'Roboto Mono', 'Courier New', monospace;
|
|
}
|
|
|
|
.flap-top, .flap-bottom {
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
height: 50%;
|
|
overflow: hidden;
|
|
background: #1a1a1a;
|
|
color: #e8e0c8;
|
|
text-align: center;
|
|
}
|
|
|
|
.flap-top {
|
|
top: 0;
|
|
border-bottom: 1px solid #111;
|
|
}
|
|
|
|
.flap-bottom {
|
|
bottom: 0;
|
|
}
|
|
|
|
.flap-top .flap-char,
|
|
.flap-bottom .flap-char {
|
|
display: block;
|
|
font-size: 18px;
|
|
line-height: 28px;
|
|
}
|
|
|
|
.flap-bottom .flap-char {
|
|
margin-top: -14px;
|
|
}
|
|
|
|
/* Date header flaps are larger */
|
|
#date-row .flap {
|
|
width: 27px;
|
|
height: 42px;
|
|
}
|
|
|
|
#date-row .flap-top .flap-char,
|
|
#date-row .flap-bottom .flap-char {
|
|
font-size: 27px;
|
|
line-height: 42px;
|
|
}
|
|
|
|
#date-row .flap-bottom .flap-char {
|
|
margin-top: -21px;
|
|
}
|
|
|
|
/* Color classes for special characters */
|
|
.flap-green .flap-char { color: #4caf50 !important; }
|
|
.flap-red .flap-char { color: #f44336 !important; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="board-wrapper">
|
|
<div id="board">
|
|
<div id="date-header">
|
|
<div id="date-row"></div>
|
|
</div>
|
|
|
|
<div id="sections"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
(function() {
|
|
'use strict';
|
|
|
|
// ─── Constants ──────────────────────────────────────────────────────
|
|
const CHARSET = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:.-/,&()+\u2713\u2717';
|
|
const COLS = [
|
|
{ key: 'time', width: 7, header: 'TIME' },
|
|
{ key: 'type', width: 10, header: 'TYPE' },
|
|
{ key: 'title', width: 22, header: 'TITLE' },
|
|
{ key: 'src', width: 5, header: 'SRC' },
|
|
{ key: 'body_part', width: 20, header: 'BODY PART' },
|
|
{ key: 'pt', width: 4, header: 'PT' },
|
|
{ key: 'scr', width: 1, header: 'S' },
|
|
{ key: 'ins', width: 1, header: 'I' },
|
|
];
|
|
const TOTAL_CHARS = COLS.reduce((s, c) => s + c.width, 0);
|
|
const MAX_ROWS = 20;
|
|
const FLIP_STEP_MS = 200;
|
|
const STAGGER_MS = 20;
|
|
const CHAR_WIDTH = 18;
|
|
|
|
// ─── State ──────────────────────────────────────────────────────────
|
|
const flapChars = new Map();
|
|
|
|
// ─── Flap Element Creation ─────────────────────────────────────────
|
|
function createFlap(ch) {
|
|
ch = ch || ' ';
|
|
const el = document.createElement('div');
|
|
el.className = 'flap';
|
|
flapChars.set(el, ch);
|
|
|
|
const top = document.createElement('div');
|
|
top.className = 'flap-top';
|
|
const topChar = document.createElement('span');
|
|
topChar.className = 'flap-char';
|
|
topChar.textContent = ch;
|
|
top.appendChild(topChar);
|
|
|
|
const bottom = document.createElement('div');
|
|
bottom.className = 'flap-bottom';
|
|
const bottomChar = document.createElement('span');
|
|
bottomChar.className = 'flap-char';
|
|
bottomChar.textContent = ch;
|
|
bottom.appendChild(bottomChar);
|
|
|
|
el.appendChild(top);
|
|
el.appendChild(bottom);
|
|
|
|
applyCharColor(el, ch);
|
|
return el;
|
|
}
|
|
|
|
function applyCharColor(flapEl, ch) {
|
|
flapEl.classList.remove('flap-green', 'flap-red');
|
|
if (ch === '\u2713') flapEl.classList.add('flap-green');
|
|
else if (ch === '\u2717') flapEl.classList.add('flap-red');
|
|
}
|
|
|
|
// ─── Sound ─────────────────────────────────────────────────────────
|
|
const flipAudio = new Audio('/split.mp3');
|
|
flipAudio.loop = true;
|
|
flipAudio.volume = 0;
|
|
let fadeInterval = null;
|
|
|
|
function startFlipSound() {
|
|
clearInterval(fadeInterval);
|
|
flipAudio.currentTime = 3;
|
|
flipAudio.volume = 0;
|
|
flipAudio.play().catch(() => {});
|
|
const target = 0.5;
|
|
const step = target / 8;
|
|
fadeInterval = setInterval(() => {
|
|
flipAudio.volume = Math.min(flipAudio.volume + step, target);
|
|
if (flipAudio.volume >= target) clearInterval(fadeInterval);
|
|
}, 10);
|
|
}
|
|
|
|
function stopFlipSound() {
|
|
clearInterval(fadeInterval);
|
|
const step = flipAudio.volume / 12;
|
|
fadeInterval = setInterval(() => {
|
|
flipAudio.volume = Math.max(flipAudio.volume - step, 0);
|
|
if (flipAudio.volume <= 0) {
|
|
clearInterval(fadeInterval);
|
|
flipAudio.pause();
|
|
}
|
|
}, 10);
|
|
}
|
|
|
|
// ─── Batch Flip Animation Engine ────────────────────────────────────
|
|
const activeFlips = [];
|
|
let animRunning = false;
|
|
|
|
function buildSteps(oldChar, newChar) {
|
|
const oldIdx = CHARSET.indexOf(oldChar);
|
|
const newIdx = CHARSET.indexOf(newChar);
|
|
if (oldIdx === -1 || newIdx === -1) return [newChar];
|
|
|
|
const steps = [];
|
|
if (newIdx >= oldIdx) {
|
|
for (let i = oldIdx + 1; i <= newIdx; i++) steps.push(CHARSET[i]);
|
|
} else {
|
|
for (let i = oldIdx + 1; i < CHARSET.length; i++) steps.push(CHARSET[i]);
|
|
for (let i = 0; i <= newIdx; i++) steps.push(CHARSET[i]);
|
|
}
|
|
if (steps.length === 0) return [newChar];
|
|
|
|
const maxSteps = 12;
|
|
if (steps.length <= maxSteps) return steps;
|
|
const sampled = [];
|
|
for (let i = 0; i < maxSteps - 1; i++) {
|
|
sampled.push(steps[Math.floor(i * (steps.length - 1) / (maxSteps - 1))]);
|
|
}
|
|
sampled.push(steps[steps.length - 1]);
|
|
return sampled;
|
|
}
|
|
|
|
function scheduleFlip(flapEl, newChar, delay) {
|
|
const oldChar = flapChars.get(flapEl) || ' ';
|
|
if (oldChar === newChar) return;
|
|
|
|
const topSpan = flapEl.querySelector('.flap-top .flap-char');
|
|
const bottomSpan = flapEl.querySelector('.flap-bottom .flap-char');
|
|
const steps = buildSteps(oldChar, newChar);
|
|
const startTime = performance.now() + delay;
|
|
|
|
activeFlips.push({
|
|
flapEl, topSpan, bottomSpan, steps,
|
|
stepIdx: 0,
|
|
nextTime: startTime
|
|
});
|
|
|
|
if (!animRunning) {
|
|
animRunning = true;
|
|
startFlipSound();
|
|
requestAnimationFrame(animLoop);
|
|
}
|
|
}
|
|
|
|
function animLoop(timestamp) {
|
|
let stillActive = false;
|
|
|
|
for (let i = 0; i < activeFlips.length; i++) {
|
|
const flip = activeFlips[i];
|
|
if (flip.stepIdx >= flip.steps.length) continue;
|
|
|
|
stillActive = true;
|
|
if (timestamp >= flip.nextTime) {
|
|
const ch = flip.steps[flip.stepIdx];
|
|
flip.topSpan.textContent = ch;
|
|
flip.bottomSpan.textContent = ch;
|
|
flapChars.set(flip.flapEl, ch);
|
|
flip.stepIdx++;
|
|
flip.nextTime = timestamp + FLIP_STEP_MS;
|
|
if (flip.stepIdx >= flip.steps.length) {
|
|
applyCharColor(flip.flapEl, ch);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (stillActive) {
|
|
requestAnimationFrame(animLoop);
|
|
} else {
|
|
activeFlips.length = 0;
|
|
animRunning = false;
|
|
stopFlipSound();
|
|
}
|
|
}
|
|
|
|
// ─── Row helpers ───────────────────────────────────────────────────
|
|
function createFlapRow(container, numChars) {
|
|
const row = document.createElement('div');
|
|
row.className = 'data-row';
|
|
for (let i = 0; i < numChars; i++) {
|
|
row.appendChild(createFlap(' '));
|
|
}
|
|
container.appendChild(row);
|
|
return row;
|
|
}
|
|
|
|
function setRowText(rowEl, text) {
|
|
const flaps = rowEl.children;
|
|
const padded = text.padEnd(flaps.length);
|
|
for (let i = 0; i < flaps.length; i++) {
|
|
scheduleFlip(flaps[i], padded[i], i * STAGGER_MS);
|
|
}
|
|
}
|
|
|
|
// ─── Header Row ───────────────────────────────────────────────────
|
|
function createHeaderRow(container) {
|
|
const row = document.createElement('div');
|
|
row.className = 'header-row';
|
|
for (const col of COLS) {
|
|
const cell = document.createElement('div');
|
|
cell.className = 'header-cell';
|
|
cell.style.width = (col.width * (CHAR_WIDTH + 1) + 2) + 'px';
|
|
cell.textContent = col.header;
|
|
row.appendChild(cell);
|
|
}
|
|
container.appendChild(row);
|
|
}
|
|
|
|
// ─── Date Row ─────────────────────────────────────────────────────
|
|
function setDateText(text) {
|
|
const container = document.getElementById('date-row');
|
|
const upper = text.toUpperCase();
|
|
|
|
// Rebuild if length changed
|
|
if (container.children.length !== upper.length) {
|
|
container.innerHTML = '';
|
|
for (let i = 0; i < upper.length; i++) {
|
|
container.appendChild(createFlap(' '));
|
|
}
|
|
}
|
|
|
|
for (let i = 0; i < upper.length; i++) {
|
|
scheduleFlip(container.children[i], upper[i], i * STAGGER_MS);
|
|
}
|
|
}
|
|
|
|
// ─── Format Row ───────────────────────────────────────────────────
|
|
function formatRow(item) {
|
|
let result = '';
|
|
for (const col of COLS) {
|
|
let val;
|
|
if (col.key === 'scr' || col.key === 'ins') {
|
|
val = item[col.key] === true ? '\u2713' : item[col.key] === false ? '\u2717' : ' ';
|
|
} else {
|
|
val = (item[col.key] || '').toUpperCase();
|
|
}
|
|
result += val.padEnd(col.width);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// ─── Build Sections ───────────────────────────────────────────────
|
|
function buildSection(parent, label) {
|
|
const labelEl = document.createElement('div');
|
|
labelEl.className = 'section-label';
|
|
labelEl.textContent = label;
|
|
parent.appendChild(labelEl);
|
|
|
|
createHeaderRow(parent);
|
|
|
|
const rowContainer = document.createElement('div');
|
|
parent.appendChild(rowContainer);
|
|
|
|
const rows = [];
|
|
for (let r = 0; r < MAX_ROWS; r++) {
|
|
rows.push(createFlapRow(rowContainer, TOTAL_CHARS));
|
|
}
|
|
return rows;
|
|
}
|
|
|
|
// ─── Init ─────────────────────────────────────────────────────────
|
|
function init() {
|
|
const sections = document.getElementById('sections');
|
|
|
|
const p1Rows = buildSection(sections, 'P1 PRISMA');
|
|
|
|
const spacer = document.createElement('div');
|
|
spacer.style.marginTop = '24px';
|
|
sections.appendChild(spacer);
|
|
|
|
const p2Rows = buildSection(sections, 'P2 PRISMA FIT');
|
|
|
|
// Demo: static content
|
|
setDateText('SATURDAY, MARCH 01, 2025');
|
|
|
|
const demoData = [
|
|
{ time: '8:00A', type: 'MRI', title: 'BRAIN W/O CONTRAST', src: 'OP', body_part: 'BRAIN', pt: 'J.D.', scr: true, ins: true },
|
|
{ time: '8:30A', type: 'CT', title: 'CHEST W/ CONTRAST', src: 'ER', body_part: 'CHEST', pt: 'M.S.', scr: true, ins: false },
|
|
{ time: '9:00A', type: 'XRAY', title: 'LEFT HAND 3 VIEW', src: 'OP', body_part: 'LEFT HAND', pt: 'A.B.', scr: false, ins: true },
|
|
];
|
|
|
|
for (let r = 0; r < MAX_ROWS; r++) {
|
|
const text = r < demoData.length ? formatRow(demoData[r]) : ''.padEnd(TOTAL_CHARS);
|
|
setRowText(p1Rows[r], text);
|
|
}
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', init);
|
|
} else {
|
|
init();
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|