Deckstride/docs/design/presenter-menu.html

80 lines
27 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>PDF Presenter · Menu concept</title>
<style>
:root{color-scheme:dark;--bg:#101517;--panel:#192124;--line:#344145;--muted:#9baeb3;--text:#edf4f4;--accent:#67e2cd}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:15px system-ui,sans-serif}button,select,input{font:inherit}button,select{color:inherit;background:#263236;border:1px solid #45565b;border-radius:8px;padding:10px 14px;cursor:pointer}button:hover{background:#35484c}button:focus-visible,select:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:3px}button:disabled{opacity:.45;cursor:default}.primary{background:var(--accent);color:#102824;border-color:var(--accent);font-weight:700}.primary:hover{background:#a0f1e2}.muted,small{color:var(--muted)}small{font-size:12px}.concept{background:#26322e;border-bottom:1px solid #40554c;padding:9px 24px;display:flex;align-items:center;justify-content:space-between;gap:16px;font-size:12px}.concept strong{letter-spacing:1.4px;color:#a7d9c9}.concept select{padding:4px 8px;font-size:12px}header{display:flex;gap:12px;align-items:center;padding:18px 24px;border-bottom:1px solid var(--line)}.brand{width:32px;height:32px;background:var(--accent);color:#102824;border-radius:8px;display:grid;place-items:center;font-weight:900}.doc{flex:1}.doc b{display:block}.toolbar{display:flex;gap:10px;align-items:center}.timer{font-size:24px;font-variant-numeric:tabular-nums;padding:0 12px}.live{color:var(--accent)}main{padding:22px 24px;max-width:1800px;margin:auto}.previews{display:grid;grid-template-columns:1.6fr 1fr;gap:22px;align-items:start}.caption{display:flex;justify-content:space-between;align-items:center;margin:0 0 10px;font-size:12px;font-weight:600;letter-spacing:1px;color:var(--muted)}.caption b{color:var(--accent)}.slide{aspect-ratio:16/9;border-radius:10px;overflow:hidden;background:#e4eee8;color:#162d2a;padding:7%;position:relative;display:flex;flex-direction:column;justify-content:center;border:1px solid #536962}.slide .eyebrow{font-size:clamp(9px,1vw,16px);letter-spacing:3px;font-weight:700}.slide h1{font-size:clamp(24px,3.8vw,64px);line-height:1.06;margin:18px 0;letter-spacing:-2px;max-width:80%;z-index:1}.slide p{font-size:clamp(10px,1.2vw,20px);max-width:75%;z-index:1}.orb{position:absolute;right:-10%;bottom:-45%;width:65%;aspect-ratio:1;border:32px solid #6db5a3;border-radius:50%;opacity:.65}.next .slide{background:#233f3b;color:#d5eae1}.next h1{font-size:clamp(20px,2.6vw,44px)}.next .orb{border-color:#4a8072}.slide-foot{position:absolute;bottom:7%;font-size:10px;letter-spacing:2px}.next-hint{margin-top:18px;padding:15px;border:1px solid var(--line);border-radius:8px;color:var(--muted);font-size:13px}.notes{margin-top:22px;border:1px solid var(--line);border-radius:10px;background:var(--panel);padding:16px 20px}.notes-tools{display:flex;gap:14px;align-items:center;font-size:12px;letter-spacing:0}.notes-tools button{font-size:12px;padding:5px 9px}.notes-tools label{display:flex;gap:8px;align-items:center}.notes-tools input{width:100px}.note-box{height:165px;overflow:hidden}.note-text{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.35;margin:0;max-width:100%}footer{display:flex;align-items:center;gap:12px;margin-top:18px}footer .status{margin-left:auto;font-size:13px}.kbd{font-size:12px;color:var(--muted);margin-left:8px}#toast{min-height:26px;padding-top:10px;color:var(--accent);font-size:13px}.menu{position:absolute;top:125px;left:24px;width:290px;background:#1d282b;border:1px solid #526267;border-radius:12px;padding:10px;box-shadow:0 20px 70px #0009;z-index:4}.menu button{display:flex;justify-content:space-between;width:100%;border:0;background:transparent;text-align:left}.menu button:hover{background:#344449}.menu hr{border:0;border-top:1px solid var(--line)}dialog{color:var(--text);background:#192124;border:1px solid #52676d;border-radius:16px;padding:0;width:min(860px,94vw);max-height:90vh;box-shadow:0 30px 100px #0008}dialog::backdrop{background:#050a0bcc;backdrop-filter:blur(4px)}.dialog-head{padding:24px 28px 18px;display:flex;justify-content:space-between;align-items:start;border-bottom:1px solid var(--line)}h2{margin:0 0 7px;font-size:25px}.dialog-body{padding:22px 28px}.map{display:flex;align-items:end;justify-content:center;gap:12px;min-height:190px;background:#11191b;border-radius:10px;padding:25px 15px;margin:16px 0}.monitor{width:155px;text-align:center}.monitor-face{border:2px solid #506367;border-radius:6px;aspect-ratio:16/10;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:6px;background:#243236}.monitor.presenter .monitor-face{border-color:var(--accent);background:#1d4039}.monitor.presentation .monitor-face{border-color:#c3b8ff;background:#36314b}.monitor-face b{font-size:25px}.monitor-face small{color:inherit}.monitor-name{font-size:11px;margin-top:10px;color:var(--muted)}.identify .monitor-face b{font-size:50px;color:#fff}.assignments{display:grid;grid-template-columns:1fr auto 1fr;gap:16px;align-items:end}.field label{display:block;margin-bottom:8px;font-size:13px;color:var(--muted)}.field select{width:100%}.checks{display:flex;flex-wrap:wrap;gap:22px;margin-top:24px;font-size:13px}.checks input{accent-color:var(--accent)}.notice{background:#293633;border-left:3px solid var(--accent);padding:12px 15px;font-size:13px;line-height:1.6;margin-top:20px}.dialog-actions{display:flex;gap:12px;justify-content:end;padding:18px 28px;border-top:1px solid var(--line)}.dialog-actions small{margin-right:auto;align-self:center}.settings-row{padding:16px 0;border-bottom:1px solid var(--line);line-height:1.7}.settings-row code{font-size:12px;overflow-wrap:anywhere}.pill{font-size:11px;letter-spacing:1px;color:var(--accent)}[hidden]{display:none!important}@media(max-width:760px){header{flex-wrap:wrap;padding:14px}.toolbar{flex-wrap:wrap}.timer{font-size:18px}.previews{grid-template-columns:1fr 1fr;gap:12px}main{padding:16px}.notes-tools{flex-wrap:wrap}.caption{flex-wrap:wrap;gap:8px}.assignments{grid-template-columns:1fr}.monitor{min-width:70px}.monitor-name{font-size:9px}.map{gap:6px;padding:12px 6px}.monitor-face small{font-size:9px}footer{flex-wrap:wrap}.kbd{display:none}.concept{flex-wrap:wrap}.menu{top:150px}.slide h1{letter-spacing:-1px}.dialog-body{padding:18px}}
/* Layout editing stays beside the live preview, not in a blocking dialog. */
header{flex-wrap:wrap}.toolbar{flex-wrap:wrap}.clock-widget{display:flex;flex-direction:column;align-items:center;min-width:0}.clock-widget small{font-size:10px;text-transform:uppercase;letter-spacing:1px}.timer{line-height:1.15;padding:0 6px}.layout-button[aria-expanded="true"]{border-color:var(--accent);color:var(--accent)}
main{display:flex;flex-direction:column;min-height:430px;max-width:none}.previews{flex:1;min-height:100px;align-items:stretch;gap:16px}.previews>section{min-width:0;min-height:0;display:flex;flex-direction:column;container-type:inline-size}.previews .slide{flex:1;min-height:0;aspect-ratio:auto;padding:8%;}.slide h1,.next h1{font-size:clamp(15px,8cqw,64px);letter-spacing:-1px;margin:12px 0}.slide .eyebrow{font-size:clamp(7px,2cqw,14px)}.slide p{font-size:clamp(9px,3cqw,20px)}.slide-foot{font-size:clamp(6px,1.5cqw,10px)}.previous-preview .slide{background:#253438;color:#b4c7c9}.notes{flex:0 0 28%;min-height:70px;display:flex;flex-direction:column;margin-top:16px}.note-box{height:auto;min-height:0;flex:1}footer{flex-shrink:0;flex-wrap:wrap;margin-top:14px}#toast{flex-shrink:0}.next-hint{display:none}.caption{flex-wrap:wrap;gap:6px}.notes-tools{flex-wrap:wrap}.layout-panel{position:fixed;right:0;top:0;bottom:0;width:330px;background:#192528;border-left:1px solid #4c6368;z-index:5;padding:24px;overflow:auto;box-shadow:-15px 0 60px #0004}.layout-panel h2{font-size:22px}.layout-panel p{font-size:13px;line-height:1.5;color:var(--muted)}.layout-panel .heading{display:flex;justify-content:space-between;align-items:start}.layout-control{padding:16px 0;border-bottom:1px solid var(--line)}.layout-control>label{display:flex;align-items:center;gap:8px;font-weight:600}.layout-control input[type=checkbox]{accent-color:var(--accent);width:17px;height:17px}.size-control{display:flex;align-items:center;gap:12px;margin-top:12px;color:var(--muted);font-size:12px}.size-control input{min-width:0;width:100%;accent-color:var(--accent)}.size-control output{min-width:44px;text-align:right}.layout-panel .presets{display:flex;gap:6px;flex-wrap:wrap;margin:18px 0}.presets button{font-size:12px;padding:8px}.layout-open header,.layout-open main{margin-right:330px}.layout-panel button.close{padding:5px 9px}.layout-panel small{line-height:1.6;display:block;margin-top:18px}@media(max-width:850px){.layout-open header,.layout-open main{margin-right:0}.layout-panel{width:min(330px,90vw)}.concept{padding:8px 14px}main{padding:14px}.slide .eyebrow,.slide-foot,.slide p{display:none}.toolbar{gap:6px}.toolbar button{padding:8px}.notes{padding:12px}.kbd{display:none}}
.slide-stage{flex:1;min-height:0;display:grid;place-items:center;container-type:size;background:#121c1f;border-radius:10px}.previews .slide-stage .slide{flex:none;width:min(100cqw,calc(100cqh * 16 / 9));height:auto;aspect-ratio:16/9;padding:7%;container-type:inline-size}.slide-stage .slide h1{font-size:clamp(12px,8cqw,64px)}
</style>
</head>
<body>
<div class="concept"><span><strong>INTERACTIVE CONCEPT</strong> · Mock slides and screens. No real display or system settings change.</span><label>Test setup <select id="topology"><option value="3">3 screens</option><option value="4">4 screens</option><option value="2">Projector disconnected</option><option value="1">Laptop only</option></select></label></div>
<header><span class="brand">P</span><button id="menuButton" aria-expanded="false" aria-controls="menu">☰ Menu</button><div class="doc"><b>Making room for ideas</b><small>demo.pdf · 12 slides</small></div><div class="toolbar"><button id="displayButton">Displays · 1 → 3</button><button id="blankButton">Blank presentation</button><button id="layoutButton" class="layout-button" aria-controls="layoutPanel" aria-expanded="false">Layout</button><div id="elapsedWidget" class="clock-widget"><small>Elapsed</small><span class="timer" id="timer">00:00</span></div><div id="clockWidget" class="clock-widget"><small>Time</small><span class="timer" id="wallClock">00:00</span></div></div></header>
<nav id="menu" class="menu" aria-label="Presenter menu" hidden><button disabled>Open PDF… <small>Planned</small></button><button disabled>Open picture folder… <small>Planned</small></button><hr><button id="menuDisplays">Displays <small>Assign screens</small></button><button id="menuLayout">Layout <small>Show, hide & resize</small></button><button id="menuSettings">Settings <small>Preview</small></button><hr><button id="resetTimer">Reset timer</button><button id="resetDemo">Reset demo</button></nav>
<main><div class="previews" id="previews"><section id="previousPreview" class="previous-preview"><div class="caption"><span>PREVIOUS</span><span id="previousCount"></span></div><div class="slide"><span class="eyebrow">LOOKING BACK</span><h1 id="previousTitle">Start of presentation</h1><div class="orb"></div></div></section><section id="currentPreview"><div class="caption"><span>CURRENT · <span id="currentCount">1 / 12</span></span><b id="outputBadge">PRESENTATION VISIBLE</b></div><div class="slide"><span class="eyebrow">BEFFROI / FIELD NOTES</span><h1 id="currentTitle">Making room<br>for ideas.</h1><p id="currentSubtitle">A clear view. A little space. A better presentation.</p><div class="orb"></div><span class="slide-foot">DESIGN SESSION · NOVEMBER 2026</span></div></section><section class="next" id="nextPreview"><div class="caption"><span>NEXT</span><span id="nextCount">2 / 12</span></div><div class="slide"><span class="eyebrow">THE STARTING POINT</span><h1 id="nextTitle">Keep the<br>focus.</h1><div class="orb"></div></div><div class="next-hint">Your slides go to <strong id="destination">Screen 3 · Epson projector</strong>.<br>Menus and notes stay on the presenter screen.</div></section></div>
<section class="notes" id="notesWidget"><div class="caption"><span>PRESENTER NOTES <small> · auto-fit</small></span><div class="notes-tools"><button id="longNotes">Try long notes</button><button id="notesLayout">Resize & visibility</button></div></div><div class="note-box" id="noteBox"><p class="note-text" id="noteText"></p></div></section>
<footer><button id="previous">← Previous</button><button class="primary" id="next">Next →</button><span class="kbd">← → slides · B blank · Esc close menu</span><span class="status" id="routeStatus">Presenter 1 · Presentation 3</span></footer><div id="toast" role="status" aria-live="polite"></div></main>
<aside id="layoutPanel" class="layout-panel" aria-labelledby="layoutTitle" hidden>
<div class="heading"><div><h2 id="layoutTitle">Your presenter view</h2><span class="pill">LIVE LAYOUT</span></div><button id="closeLayout" class="close" aria-label="Close layout">✕</button></div>
<p>Keep what helps you speak. Hidden items give their space to the rest. Presentation output stays unchanged.</p>
<div class="presets"><button id="balancedLayout">Balanced</button><button id="focusLayout">Slide focus</button><button id="speakerLayout">Notes first</button></div>
<div id="layoutControls"></div>
<small>Preview sizes share the available width. Notes size controls their share of the height; text always fits. Clock sizes control their text size.</small>
<small>Demo choices last while this page is open. The native app will remember visibility and sizes in your global configuration.</small>
</aside>
<dialog id="displayDialog" aria-labelledby="displayTitle"><div class="dialog-head"><div><h2 id="displayTitle">Where should each view go?</h2><small>Presenter = your controls and notes. Presentation = slides for viewers.</small></div><button aria-label="Close displays" data-close="displayDialog">✕</button></div><div class="dialog-body"><div style="display:flex;justify-content:space-between;align-items:center"><span class="pill">CONNECTED SCREENS · SIMULATED</span><button id="identify">Identify screens</button></div><div class="map" id="screenMap"></div><div class="assignments"><div class="field"><label for="presenterSelect">Presenter screen</label><select id="presenterSelect"></select></div><button id="swap">⇄ Swap</button><div class="field"><label for="presentationSelect">Presentation screen</label><select id="presentationSelect"></select></div></div><div class="checks"><label><input id="presenterFull" type="checkbox" checked> Presenter fullscreen</label><label><input id="presentationFull" type="checkbox" checked> Presentation fullscreen</label><label><input id="remember" type="checkbox" checked> Remember this setup</label></div><div class="notice" id="displayNotice">Choose destinations, then Apply. Unused screens stay untouched.</div></div><div class="dialog-actions"><small>Changes apply together.</small><button data-close="displayDialog">Cancel</button><button class="primary" id="apply">Apply setup</button></div></dialog>
<dialog id="settingsDialog" aria-labelledby="settingsTitle"><div class="dialog-head"><div><h2 id="settingsTitle">Settings</h2><small>Proposed app behavior · not operating-system settings</small></div><button aria-label="Close settings" data-close="settingsDialog">✕</button></div><div class="dialog-body"><div class="settings-row"><b>Remember your screens</b><br><span class="muted">Keep preferred screen identities, fullscreen choices and notes layout in a per-user configuration. Temporary fallback does not replace your preferred setup.</span></div><div class="settings-row"><b>Configuration location</b><br><code>Linux: $XDG_CONFIG_HOME/pdf-presenter/settings.toml</code><br><small>Defaults to ~/.config/pdf-presenter/settings.toml</small><br><code>Windows: %APPDATA%\Beffroi\PdfPresenter\settings.toml</code><br><code>macOS: ~/Library/Application Support/Beffroi/PdfPresenter/settings.toml</code></div><div class="settings-row"><b>Keep screens awake during presentation</b><br><span class="muted">Planned native feature. Includes paused and blanked output; this HTML does not inhibit sleep.</span></div><div class="notice">This demo remembers choices only while this page is open. The native app's global configuration is not implemented yet.</div></div><div class="dialog-actions"><button class="primary" data-close="settingsDialog">Done</button></div></dialog>
<script>
'use strict';
const $=id=>document.getElementById(id);
const screens=[{id:1,name:'Built-in display',size:'1920 × 1200'},{id:2,name:'Dell U2720Q',size:'3840 × 2160'},{id:3,name:'Epson projector',size:'1920 × 1080'},{id:4,name:'Side monitor',size:'2560 × 1440'}];
const titles=['Making room for ideas.','Keep the focus.','A shared perspective.','Less friction.','Space to think.','One clear message.','From idea to action.','Make it tangible.','Keep moving.','A wider view.','What comes next?','Thank you.'];
let count=3,page=0,blank=false,long=false,start=Date.now(),active={presenter:1,presentation:3,presenterFull:true,presentationFull:true},preferred={...active},draft={...active};
const message=text=>$('toast').textContent=text;
document.querySelectorAll('.previews .slide').forEach(slide=>{const stage=document.createElement('div');stage.className='slide-stage';slide.before(stage);stage.append(slide);});
const layoutDefaults={previous:{show:true,size:60},current:{show:true,size:130},next:{show:true,size:75},notes:{show:true,size:28},elapsed:{show:true,size:28},clock:{show:true,size:28}};
let layout=structuredClone(layoutDefaults);
const layoutSpecs=[['previous','Previous slide',30,160,'weight'],['current','Current slide',60,200,'weight'],['next','Next slide',30,160,'weight'],['notes','Notes',12,65,'%'],['elapsed','Elapsed time',16,72,'px'],['clock','Time · HH:MM',16,72,'px']];
const widgets={previous:'previousPreview',current:'currentPreview',next:'nextPreview',notes:'notesWidget',elapsed:'elapsedWidget',clock:'clockWidget'};
function availableHeight(){const main=document.querySelector('main');main.style.height=Math.max(430,innerHeight-main.getBoundingClientRect().top)+'px';}
function applyLayout(){
for(const [key] of layoutSpecs){$(widgets[key]).hidden=!layout[key].show;const toggle=$('show-'+key);if(toggle)toggle.checked=layout[key].show;$('size-'+key).value=layout[key].size;$('size-'+key).disabled=!layout[key].show;$('value-'+key).textContent=layout[key].size+(key==='notes'?'%':['clock','elapsed'].includes(key)?'px':'');}
$('previews').style.gridTemplateColumns=['previous','current','next'].filter(k=>layout[k].show).map(k=>`minmax(0, ${layout[k].size}fr)`).join(' ');
$('notesWidget').style.flexBasis=layout.notes.size+'%';$('timer').style.fontSize=layout.elapsed.size+'px';$('wallClock').style.fontSize=layout.clock.size+'px';availableHeight();fitNotes();
}
function setLayoutOpen(open){$('layoutPanel').hidden=!open;document.body.classList.toggle('layout-open',open);$('layoutButton').setAttribute('aria-expanded',String(open));availableHeight();fitNotes();}
function openLayout(){closeMenu();setLayoutOpen(true);$('closeLayout').focus();}
for(const [key,label,min,max,unit] of layoutSpecs){const row=document.createElement('div');row.className='layout-control';row.innerHTML=`<label>${key==='current'?'':`<input id="show-${key}" type="checkbox" checked>`}${label}</label><div class="size-control"><label for="size-${key}">Size</label><input id="size-${key}" type="range" min="${min}" max="${max}" value="${layout[key].size}" aria-label="${label} size"><output id="value-${key}" for="size-${key}"></output></div>`;$('layoutControls').append(row);if(key!=='current')$('show-'+key).onchange=()=>{layout[key].show=$('show-'+key).checked;applyLayout();};$('size-'+key).oninput=()=>{layout[key].size=Number($('size-'+key).value);applyLayout();};}
$('layoutButton').onclick=()=>{closeMenu();setLayoutOpen($('layoutPanel').hidden);};$('notesLayout').onclick=openLayout;$('closeLayout').onclick=()=>{setLayoutOpen(false);$('layoutButton').focus();};
$('balancedLayout').onclick=()=>{layout=structuredClone(layoutDefaults);applyLayout();};
$('focusLayout').onclick=()=>{layout=structuredClone(layoutDefaults);for(const k of ['previous','next','notes','elapsed','clock'])layout[k].show=false;applyLayout();};
$('speakerLayout').onclick=()=>{layout=structuredClone(layoutDefaults);layout.previous.show=false;layout.notes.size=52;layout.next.size=50;applyLayout();};
new ResizeObserver(availableHeight).observe(document.querySelector('header'));window.addEventListener('resize',availableHeight);
function closeMenu(){$('menu').hidden=true;$('menuButton').setAttribute('aria-expanded','false');}
$('menuButton').onclick=()=>{const open=$('menu').hidden;$('menu').hidden=!open;$('menuButton').setAttribute('aria-expanded',String(open));};
function fitNotes(){const box=$('noteBox'),text=$('noteText');if(!box.clientWidth||!box.clientHeight)return;let lo=.1,hi=48;for(let i=0;i<15;i++){const mid=(lo+hi)/2;text.style.fontSize=mid+'px';if(text.scrollHeight<=box.clientHeight&&text.scrollWidth<=box.clientWidth)lo=mid;else hi=mid;}text.style.fontSize=lo+'px';}
const shortNotes=['Welcome everyone. Give the room a moment to settle.\n\nIntroduce the idea: fewer distractions, more room for the message.','Keep attention on the main point. Let the slide support the story, rather than competing with it.'];
function render(){ $('previousTitle').textContent=titles[page-1]||'Start of presentation';$('previousCount').textContent=page>0?`${page} / 12`:''; $('currentTitle').textContent=titles[page];$('nextTitle').textContent=titles[page+1]||'End of presentation';$('currentCount').textContent=`${page+1} / 12`;$('nextCount').textContent=page<11?`${page+2} / 12`:'';$('previous').disabled=page===0;$('next').disabled=page===11;
$('noteText').textContent=long?Array.from({length:8},(_,i)=>`${i+1}. ${shortNotes[(page+i)%2]} Discuss the practical example, pause for questions, and connect this point to the next slide.`).join('\n\n'):shortNotes[page%2];
$('outputBadge').textContent=!active.presentation?'PRESENTATION SUSPENDED':blank?'PRESENTATION BLANKED':'PRESENTATION VISIBLE';$('blankButton').textContent=blank?'Show presentation':'Blank presentation';$('blankButton').disabled=!active.presentation;$('destination').textContent=active.presentation?`Screen ${active.presentation} · ${screens[active.presentation-1].name}`:'No screen · rehearsal only';$('displayButton').textContent=`Displays · ${active.presenter} → ${active.presentation||'—'}`;$('routeStatus').textContent=`Presenter ${active.presenter} · Presentation ${active.presentation||'suspended'}`;fitNotes();}
function move(delta){page=Math.max(0,Math.min(11,page+delta));render();}
$('previous').onclick=()=>move(-1);$('next').onclick=()=>move(1);$('blankButton').onclick=()=>{blank=!blank;render();};$('longNotes').onclick=()=>{long=!long;$('longNotes').textContent=long?'Use short notes':'Try long notes';render();};new ResizeObserver(fitNotes).observe($('noteBox'));
function drawMap(){ $('screenMap').replaceChildren();for(const screen of screens.slice(0,count)){const role=screen.id===draft.presenter?'Presenter':screen.id===draft.presentation?'Presentation':'Unused';const el=document.createElement('div');el.className='monitor '+role.toLowerCase();el.innerHTML=`<div class="monitor-face"><b>${screen.id}</b><small>${role}</small></div><div class="monitor-name">${screen.name}<br>${screen.size}</div>`;$('screenMap').append(el);} $('presenterSelect').value=String(draft.presenter);$('presentationSelect').value=String(draft.presentation);$('swap').disabled=!draft.presentation;$('displayNotice').textContent=count===1?'Only one screen is connected. Keep the presenter fullscreen and suspend presentation output.': 'Choose destinations, then Apply. Unused screens stay untouched.';}
function openDisplays(){closeMenu();draft={...active};for(const id of ['presenterSelect','presentationSelect']){$(id).replaceChildren();if(id==='presentationSelect')$(id).add(new Option('Off · rehearsal only','0'));for(const s of screens.slice(0,count))$(id).add(new Option(`${s.id} — ${s.name}`,String(s.id)));}$('presenterFull').checked=draft.presenterFull;$('presentationFull').checked=draft.presentationFull;drawMap();if(!$('displayDialog').open)$('displayDialog').showModal();}
$('displayButton').onclick=openDisplays;$('menuDisplays').onclick=openDisplays;
$('presenterSelect').onchange=()=>{const old=draft.presenter;draft.presenter=Number($('presenterSelect').value);if(draft.presenter===draft.presentation)draft.presentation=count>1?old:0;drawMap();};
$('presentationSelect').onchange=()=>{const old=draft.presentation;draft.presentation=Number($('presentationSelect').value);if(draft.presentation===draft.presenter){if(count===1)draft.presentation=0;else draft.presenter=old||screens.slice(0,count).find(s=>s.id!==draft.presentation).id;}drawMap();};
$('swap').onclick=()=>{[draft.presenter,draft.presentation]=[draft.presentation,draft.presenter];drawMap();};
$('identify').onclick=()=>{$('screenMap').classList.add('identify');$('displayNotice').textContent='Native app: briefly overlay these numbers on the physical screens. Here: simulated labels only.';setTimeout(()=>$('screenMap').classList.remove('identify'),1800);};
$('apply').onclick=()=>{draft.presenterFull=$('presenterFull').checked;draft.presentationFull=$('presentationFull').checked;active={...draft};if($('remember').checked)preferred={...active};$('displayDialog').close();render();message($('remember').checked?'Setup applied and remembered for this demo session.':'Setup applied for this session without changing your preferred setup.');};
$('topology').onchange=()=>{count=Number($('topology').value);const available=id=>id>0&&id<=count;const p=available(preferred.presenter)?preferred.presenter:1;const output=available(preferred.presentation)&&preferred.presentation!==p?preferred.presentation:screens.slice(0,count).find(s=>s.id!==p)?.id||0;active={...preferred,presenter:p,presentation:output};blank=true;render();message('Simulated display change: presentation blanked. Review the fallback in Displays; your preferred setup is retained.');if($('displayDialog').open)openDisplays();};
$('menuSettings').onclick=()=>{closeMenu();$('settingsDialog').showModal();};$('menuLayout').onclick=openLayout;$('resetTimer').onclick=()=>{start=Date.now();closeMenu();};$('resetDemo').onclick=()=>location.reload();document.querySelectorAll('[data-close]').forEach(b=>b.onclick=()=>$(b.dataset.close).close());document.addEventListener('pointerdown',e=>{if(!$('menu').contains(e.target)&&!$('menuButton').contains(e.target))closeMenu();});document.addEventListener('keydown',e=>{if(e.key==='Escape'){closeMenu();if(!$('layoutPanel').hidden){setLayoutOpen(false);$('layoutButton').focus();}return;}if(document.querySelector('dialog[open]')||['INPUT','SELECT','BUTTON'].includes(document.activeElement.tagName)||!$('menu').hidden)return;if(e.key==='ArrowRight'||e.key===' '){e.preventDefault();move(1);}if(e.key==='ArrowLeft'){e.preventDefault();move(-1);}if(e.key.toLowerCase()==='b'&&active.presentation){blank=!blank;render();}});function updateClocks(){const seconds=Math.floor((Date.now()-start)/1000);$('timer').textContent=String(Math.floor(seconds/60)).padStart(2,'0')+':'+String(seconds%60).padStart(2,'0');const now=new Date();$('wallClock').textContent=String(now.getHours()).padStart(2,'0')+':'+String(now.getMinutes()).padStart(2,'0');}setInterval(updateClocks,1000);updateClocks();applyLayout();render();
</script>
</body></html>