Skip to content

Commit ca6cef2

Browse files
committed
Add fullscreen functionality to simulators with button and styles
1 parent 7c80097 commit ca6cef2

10 files changed

Lines changed: 101 additions & 7 deletions

File tree

‎simulators/index.html‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<header>
1515
<h1>Control Systems</h1>
1616
<p class="subtitle">Interactive Simulators</p>
17+
<button id="fsBtn" class="icon-btn" title="Enter fullscreen">&#x26F6; Full Screen</button>
1718
</header>
1819

1920
<main>
@@ -109,5 +110,24 @@ <h2>PID Controller</h2>
109110
});
110111
</script>
111112

113+
<script>
114+
(function () {
115+
const fsBtn = document.getElementById('fsBtn');
116+
function updateFsBtn() {
117+
const inFs = !!document.fullscreenElement;
118+
fsBtn.innerHTML = inFs ? '&#x2715; Exit Full Screen' : '&#x26F6; Full Screen';
119+
fsBtn.title = inFs ? 'Exit fullscreen' : 'Enter fullscreen';
120+
}
121+
fsBtn.addEventListener('click', () => {
122+
if (!document.fullscreenElement) {
123+
document.documentElement.requestFullscreen();
124+
} else {
125+
document.exitFullscreen();
126+
}
127+
});
128+
document.addEventListener('fullscreenchange', updateFsBtn);
129+
})();
130+
</script>
131+
112132
</body>
113133
</html>

‎simulators/linear-system-1st-order/app.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,20 @@ window.addEventListener('DOMContentLoaded', () => {
340340
syncInputs('tau-slider', 'tau-number', val => { tau = val; updateChart(); });
341341
syncInputs('k-slider', 'k-number', val => { K = val; updateChart(); });
342342
});
343+
344+
// ── Fullscreen ─────────────────────────────────────────────────────────────────
345+
const fsBtn = document.getElementById('fsBtn');
346+
347+
function updateFsBtn() {
348+
const inFs = !!document.fullscreenElement;
349+
fsBtn.innerHTML = inFs ? '&#x2715; Exit Full Screen' : '&#x26F6; Full Screen';
350+
fsBtn.title = inFs ? 'Exit fullscreen' : 'Enter fullscreen';
351+
}
352+
fsBtn.addEventListener('click', () => {
353+
if (!document.fullscreenElement) {
354+
document.documentElement.requestFullscreen();
355+
} else {
356+
document.exitFullscreen();
357+
}
358+
});
359+
document.addEventListener('fullscreenchange', updateFsBtn);

‎simulators/linear-system-1st-order/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<a href="../index.html" class="back-link">&#8592; All Simulators</a>
1717
<h1>1st-Order Linear System</h1>
1818
<p class="subtitle">Step Response Simulator &ensp;&mdash;&ensp; \(G(s) = \dfrac{K}{\tau s + 1}\)</p>
19+
<button id="fsBtn" title="Enter fullscreen">&#x26F6; Full Screen</button>
1920
</header>
2021

2122
<main>

‎simulators/linear-system-2nd-order/app.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,20 @@ window.addEventListener('DOMContentLoaded', () => {
420420
syncInputs('wn-slider', 'wn-number', val => { wn = val; updateChart(); });
421421
syncInputs('zeta-slider', 'zeta-number', val => { zeta = val; updateChart(); });
422422
});
423+
424+
// ── Fullscreen ─────────────────────────────────────────────────────────────────
425+
const fsBtn = document.getElementById('fsBtn');
426+
427+
function updateFsBtn() {
428+
const inFs = !!document.fullscreenElement;
429+
fsBtn.innerHTML = inFs ? '&#x2715; Exit Full Screen' : '&#x26F6; Full Screen';
430+
fsBtn.title = inFs ? 'Exit fullscreen' : 'Enter fullscreen';
431+
}
432+
fsBtn.addEventListener('click', () => {
433+
if (!document.fullscreenElement) {
434+
document.documentElement.requestFullscreen();
435+
} else {
436+
document.exitFullscreen();
437+
}
438+
});
439+
document.addEventListener('fullscreenchange', updateFsBtn);

‎simulators/linear-system-2nd-order/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ <h1>2nd-Order Linear System</h1>
1818
<p class="subtitle">Step Response Simulator &ensp;&mdash;&ensp;
1919
\(\displaystyle G(s) = \frac{K\omega_n^2}{s^2 + 2\zeta\omega_n s + \omega_n^2}\)
2020
</p>
21+
<button id="fsBtn" title="Enter fullscreen">&#x26F6; Full Screen</button>
2122
</header>
2223

2324
<main>

‎simulators/pid/app.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ dFiltEnCk.addEventListener('change', () => updateFilterRow());
359359
// ── Fullscreen ─────────────────────────────────────────────────────────────────
360360
function updateFsBtn() {
361361
const inFs = !!document.fullscreenElement;
362-
fsBtn.innerHTML = inFs ? '&#x2715;' : '&#x26F6;';
362+
fsBtn.innerHTML = inFs ? '&#x2715; Exit Full Screen' : '&#x26F6; Full Screen';
363363
fsBtn.title = inFs ? 'Exit fullscreen' : 'Enter fullscreen';
364364
}
365365
fsBtn.addEventListener('click', () => {

‎simulators/pid/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<a href="../index.html" class="back-link">&#8592; Control Systems</a>
1717
<h1>PID Controller Simulator</h1>
1818
<p class="subtitle">\(C(s) = K_p + \dfrac{K_i}{s} + K_d s\)</p>
19+
<button id="fsBtn" title="Enter fullscreen">&#x26F6; Full Screen</button>
1920
</header>
2021

2122
<main>
@@ -143,7 +144,6 @@ <h1>PID Controller Simulator</h1>
143144
<input type="range" id="timeWin" min="10" max="120" step="5" value="45" />
144145
<span id="twVal" class="val">45 s</span>
145146
</label>
146-
<button id="fsBtn" class="icon-btn" title="Enter fullscreen">&#x26F6;</button>
147147
</div>
148148

149149
</section>

‎simulators/pole-zero/app.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,3 +861,20 @@ window.addEventListener('DOMContentLoaded', () => {
861861
syncInputs('real-zero-a-slider', 'real-zero-a-number', val => { state.realZeroA.value = val; markCustomPreset(); updateChart(); });
862862
syncInputs('real-zero-b-slider', 'real-zero-b-number', val => { state.realZeroB.value = val; markCustomPreset(); updateChart(); });
863863
});
864+
865+
// ── Fullscreen ─────────────────────────────────────────────────────────────────
866+
const fsBtn = document.getElementById('fsBtn');
867+
868+
function updateFsBtn() {
869+
const inFs = !!document.fullscreenElement;
870+
fsBtn.innerHTML = inFs ? '&#x2715; Exit Full Screen' : '&#x26F6; Full Screen';
871+
fsBtn.title = inFs ? 'Exit fullscreen' : 'Enter fullscreen';
872+
}
873+
fsBtn.addEventListener('click', () => {
874+
if (!document.fullscreenElement) {
875+
document.documentElement.requestFullscreen();
876+
} else {
877+
document.exitFullscreen();
878+
}
879+
});
880+
document.addEventListener('fullscreenchange', updateFsBtn);

‎simulators/pole-zero/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<a href="../index.html" class="back-link">&#8592; All Simulators</a>
1616
<h1>Pole-Zero Map Simulator</h1>
1717
<p class="subtitle">Pole and zero locations, \(G(s) = K\dfrac{\prod(s-z_i)}{\prod(s-p_i)}\)</p>
18+
<button id="fsBtn" title="Enter fullscreen">&#x26F6; Full Screen</button>
1819
</header>
1920

2021
<main>

‎simulators/styles.css‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ header {
3737
color: var(--header-text);
3838
padding: 1.1rem 2rem;
3939
user-select: none;
40+
position: relative;
4041
}
4142

4243
header h1 {
@@ -56,6 +57,26 @@ header h1 {
5657
letter-spacing: -0.02em;
5758
}
5859

60+
header #fsBtn {
61+
position: absolute;
62+
top: 1rem;
63+
right: 1.5rem;
64+
background: transparent;
65+
color: #94a3b8;
66+
border: 1.5px solid #475569;
67+
padding: 5px 10px;
68+
font-size: 0.8rem;
69+
line-height: 1;
70+
border-radius: 6px;
71+
cursor: pointer;
72+
transition: color 0.15s, border-color 0.15s, background 0.15s;
73+
}
74+
header #fsBtn:hover {
75+
color: #f1f5f9;
76+
border-color: #94a3b8;
77+
background: rgba(255, 255, 255, 0.06);
78+
}
79+
5980
/* ─── Subtitle ───────────────────────────────────────────────────────────── */
6081
.subtitle {
6182
font-size: 0.82rem;
@@ -575,11 +596,10 @@ td.value {
575596
top: 2px;
576597
}
577598

578-
/* ─── Fullscreen (PID) ───────────────────────────────────────────────────── */
579-
:fullscreen main,
580-
:-webkit-full-screen main {
581-
max-width: 100%;
582-
padding: 1rem 1.25rem 1.5rem;
599+
/* ─── Fullscreen ─────────────────────────────────────────────────────────── */
600+
:fullscreen body,
601+
:-webkit-full-screen body {
602+
overflow-y: auto;
583603
}
584604

585605
/* ─── Responsive ─────────────────────────────────────────────────────────── */

0 commit comments

Comments
 (0)