|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 6 | + <title>@PORTCE_WEB_TITLE_TEXT@</title> |
| 7 | + <style> |
| 8 | + :root { |
| 9 | + --bg: #121212; |
| 10 | + --panel: #1d1d1d; |
| 11 | + --accent: #f2c879; |
| 12 | + --text: #e6e6e6; |
| 13 | + } |
| 14 | + html, body { |
| 15 | + margin: 0; |
| 16 | + height: 100%; |
| 17 | + background: radial-gradient(circle at 20% 0%, #1f1c16 0%, #121212 50%); |
| 18 | + color: var(--text); |
| 19 | + font-family: "Georgia", "Times New Roman", serif; |
| 20 | + } |
| 21 | + .wrap { |
| 22 | + display: grid; |
| 23 | + grid-template-rows: auto 1fr; |
| 24 | + height: 100%; |
| 25 | + } |
| 26 | + header { |
| 27 | + padding: 10px 14px; |
| 28 | + background: linear-gradient(135deg, #1b1b1b, #2a2a2a); |
| 29 | + border-bottom: 1px solid #2f2f2f; |
| 30 | + letter-spacing: 0.5px; |
| 31 | + } |
| 32 | + header span { |
| 33 | + font-size: 14px; |
| 34 | + opacity: 0.8; |
| 35 | + margin-left: 6px; |
| 36 | + } |
| 37 | + .stage { |
| 38 | + display: grid; |
| 39 | + place-items: center; |
| 40 | + position: relative; |
| 41 | + padding: 16px; |
| 42 | + } |
| 43 | + .panel { |
| 44 | + background: var(--panel); |
| 45 | + border: 1px solid #2b2b2b; |
| 46 | + box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); |
| 47 | + padding: 16px; |
| 48 | + border-radius: 10px; |
| 49 | + } |
| 50 | + .toolbar { |
| 51 | + display: grid; |
| 52 | + grid-template-columns: 1fr auto; |
| 53 | + align-items: center; |
| 54 | + margin-bottom: 10px; |
| 55 | + } |
| 56 | + .toolbar .scales { |
| 57 | + display: flex; |
| 58 | + gap: 8px; |
| 59 | + align-items: center; |
| 60 | + } |
| 61 | + .toolbar button { |
| 62 | + background: #2a2a2a; |
| 63 | + border: 1px solid #3b3b3b; |
| 64 | + color: var(--text); |
| 65 | + padding: 6px 10px; |
| 66 | + border-radius: 6px; |
| 67 | + cursor: pointer; |
| 68 | + font-size: 12px; |
| 69 | + } |
| 70 | + .toolbar button.active { |
| 71 | + border-color: var(--accent); |
| 72 | + color: var(--accent); |
| 73 | + } |
| 74 | + .screen { |
| 75 | + display: grid; |
| 76 | + place-items: center; |
| 77 | + background: #0b0b0b; |
| 78 | + border: 1px solid #333; |
| 79 | + border-radius: 8px; |
| 80 | + padding: 10px; |
| 81 | + } |
| 82 | + #canvas { |
| 83 | + width: 320px; |
| 84 | + height: 240px; |
| 85 | + image-rendering: pixelated; |
| 86 | + image-rendering: crisp-edges; |
| 87 | + background: #000; |
| 88 | + display: block; |
| 89 | + } |
| 90 | + .hint { |
| 91 | + position: absolute; |
| 92 | + top: 10px; |
| 93 | + right: 12px; |
| 94 | + font-size: 12px; |
| 95 | + opacity: 0.6; |
| 96 | + } |
| 97 | + .note { |
| 98 | + font-size: 12px; |
| 99 | + opacity: 0.7; |
| 100 | + margin-top: 10px; |
| 101 | + } |
| 102 | + @media (max-width: 640px) { |
| 103 | + .panel { |
| 104 | + width: 100%; |
| 105 | + box-sizing: border-box; |
| 106 | + } |
| 107 | + #canvas { |
| 108 | + width: 100%; |
| 109 | + height: auto; |
| 110 | + aspect-ratio: 4 / 3; |
| 111 | + } |
| 112 | + } |
| 113 | + </style> |
| 114 | + </head> |
| 115 | + <body> |
| 116 | + <div class="wrap"> |
| 117 | + <header> |
| 118 | + @PORTCE_WEB_TITLE_TEXT@ |
| 119 | + </header> |
| 120 | + <div class="stage"> |
| 121 | + <div class="panel"> |
| 122 | + <div class="toolbar"> |
| 123 | + <div class="scales"> |
| 124 | + <button type="button" data-scale="1">1x</button> |
| 125 | + <button type="button" data-scale="2" class="active">2x</button> |
| 126 | + <button type="button" data-scale="3">3x</button> |
| 127 | + <button type="button" id="fullscreen-btn">Full-screen</button> |
| 128 | + </div> |
| 129 | + <button type="button" id="reset-btn">Reset</button> |
| 130 | + </div> |
| 131 | + <div class="screen"> |
| 132 | + <canvas id="canvas" width="320" height="240"></canvas> |
| 133 | + </div> |
| 134 | + <div class="note">Click the canvas to focus input.</div> |
| 135 | + </div> |
| 136 | + <div class="hint">PortCE Web</div> |
| 137 | + </div> |
| 138 | + </div> |
| 139 | + <script> |
| 140 | + (function () { |
| 141 | + const baseW = 320; |
| 142 | + const baseH = 240; |
| 143 | + const canvas = document.getElementById("canvas"); |
| 144 | + const buttons = document.querySelectorAll("[data-scale]"); |
| 145 | + const resetBtn = document.getElementById("reset-btn"); |
| 146 | + const fullscreenBtn = document.getElementById("fullscreen-btn"); |
| 147 | + const panel = document.querySelector(".panel"); |
| 148 | + const screen = document.querySelector(".screen"); |
| 149 | + let fullscreenActive = false; |
| 150 | + |
| 151 | + function setScale(scale) { |
| 152 | + fullscreenActive = false; |
| 153 | + canvas.style.width = (baseW * scale) + "px"; |
| 154 | + canvas.style.height = (baseH * scale) + "px"; |
| 155 | + buttons.forEach(function (btn) { |
| 156 | + btn.classList.toggle("active", btn.dataset.scale === String(scale)); |
| 157 | + }); |
| 158 | + fullscreenBtn.classList.remove("active"); |
| 159 | + canvas.style.maxWidth = ""; |
| 160 | + canvas.style.maxHeight = ""; |
| 161 | + screen.style.width = ""; |
| 162 | + screen.style.height = ""; |
| 163 | + } |
| 164 | + function fitCanvasToScreen() { |
| 165 | + const screenRect = screen.getBoundingClientRect(); |
| 166 | + const maxW = screenRect.width - 20; |
| 167 | + const maxH = screenRect.height - 20; |
| 168 | + let scale = Math.floor(Math.min(maxW / baseW, maxH / baseH) * 100) / 100; |
| 169 | + scale = Math.max(scale, 1); |
| 170 | + canvas.style.width = (baseW * scale) + "px"; |
| 171 | + canvas.style.height = (baseH * scale) + "px"; |
| 172 | + } |
| 173 | + buttons.forEach(function (btn) { |
| 174 | + btn.addEventListener("click", function () { |
| 175 | + setScale(Number(btn.dataset.scale)); |
| 176 | + }); |
| 177 | + }); |
| 178 | + resetBtn.addEventListener("click", function () { |
| 179 | + location.reload(); |
| 180 | + }); |
| 181 | + fullscreenBtn.addEventListener("click", function () { |
| 182 | + if (!document.fullscreenElement) { |
| 183 | + (panel.requestFullscreen || panel.webkitRequestFullscreen || panel.msRequestFullscreen).call(panel); |
| 184 | + } else { |
| 185 | + (document.exitFullscreen || document.webkitExitFullscreen || document.msExitFullscreen).call(document); |
| 186 | + } |
| 187 | + }); |
| 188 | + document.addEventListener("fullscreenchange", function () { |
| 189 | + fullscreenActive = !!document.fullscreenElement; |
| 190 | + fullscreenBtn.classList.toggle("active", fullscreenActive); |
| 191 | + if (fullscreenActive) { |
| 192 | + screen.style.width = "100%"; |
| 193 | + screen.style.height = "calc(100vh - 120px)"; |
| 194 | + fitCanvasToScreen(); |
| 195 | + } else { |
| 196 | + screen.style.width = ""; |
| 197 | + screen.style.height = ""; |
| 198 | + setScale(2); |
| 199 | + } |
| 200 | + }); |
| 201 | + window.addEventListener("resize", function () { |
| 202 | + if (fullscreenActive) { |
| 203 | + fitCanvasToScreen(); |
| 204 | + } |
| 205 | + }); |
| 206 | + setScale(2); |
| 207 | + })(); |
| 208 | + var Module = { |
| 209 | + canvas: (function () { |
| 210 | + const canvas = document.getElementById("canvas"); |
| 211 | + canvas.tabIndex = 0; |
| 212 | + canvas.focus(); |
| 213 | + return canvas; |
| 214 | + })() |
| 215 | + }; |
| 216 | + </script> |
| 217 | + <script src="@PORTCE_APP_JS@"></script> |
| 218 | + </body> |
| 219 | +</html> |
0 commit comments