Files
2026-11-24 23:40:08 +03:00

15 lines
17 KiB
C#

namespace VibranceHud.Remote;
internal static class PhonePage
{
internal static string Html()
{
return "<!doctype html>\r\n<html lang=\"en\">\r\n<head>\r\n<meta charset=\"utf-8\">\r\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,viewport-fit=cover\">\r\n<meta name=\"robots\" content=\"noindex,nofollow\">\r\n<meta name=\"theme-color\" content=\"#151515\">\r\n<title>PlexusX</title>\r\n<style>\r\n /* final/tokens.css, data-look=\"ash\". Nothing on this page is any other colour. */\r\n :root{\r\n --bg:#151515; --surface-1:#1C1C1C; --surface-2:#232323; --pressed:#393939;\r\n --border:#333333; --border-strong:#747474; --track:#3D3D3D;\r\n --text-1:#F3F3F3; --text-2:#C1C1C1; --text-3:#999999;\r\n --accent:#FFFFFF; --accent-pressed:#C4C4C4; --on-accent:#151515; --focus:#FFFFFF;\r\n --knob-ring:#1C1C1C; --success:#5ECE83; --danger:#FF9E93;\r\n --pad:16px;\r\n /* Half the 44 px touch box the knob is drawn in: where the knob's centre sits at either\r\n end of a slider, so the track, the fill and the default tick run between them. */\r\n --knob:22px;\r\n }\r\n *{box-sizing:border-box; -webkit-tap-highlight-color:transparent}\r\n html,body{overscroll-behavior-y:contain}\r\n body{\r\n /* 150 at the bottom, and it was 120. The compare bar is pinned and about 90px tall\r\n before the safe-area inset, so at 120 it sat 136px over the Scenes card - measured,\r\n and invisible from the code because the bar is out of flow. */\r\n margin:0; padding:24px var(--pad) 150px; background:var(--bg); color:var(--text-1);\r\n font:16px/1.55 -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif;\r\n }\r\n\r\n header{display:flex; align-items:center; justify-content:space-between; margin-bottom:16px}\r\n h1{font-size:20px; line-height:1.3; font-weight:600; margin:0}\r\n\r\n /* components.md §26, inline status: the icon in the status colour, 8, the word in text-1. */\r\n .live{display:flex; align-items:center; gap:8px; font-size:14px; font-weight:600; color:var(--text-1)}\r\n .ico{width:16px; height:16px; flex:none}\r\n .live .ico{display:none}\r\n .live.ok .ico-ok, .live.bad .ico-bad{display:block}\r\n .ico-ok{color:var(--success)}\r\n .ico-bad{color:var(--danger)}\r\n\r\n /* §17: a card - surface-1, a hairline border, radius 8. */\r\n .group{background:var(--surface-1); border:1px solid var(--border); border-radius:8px;\r\n padding:8px var(--pad) 16px; margin-bottom:16px}\r\n .cap{font-size:16px; font-weight:600; color:var(--text-1); margin:8px 0 12px}\r\n\r\n .row{padding:8px 0 0}\r\n .head{display:flex; justify-content:space-between; align-items:baseline}\r\n .name{font-size:16px; color:var(--text-2)}\r\n .val{font-variant-numeric:tabular-nums; color:var(--text-1); font-weight:600; font-size:16px}\r\n .val.off{color:var(--text-3)}\r\n\r\n /* §8, drawn under the range: the 2 px track, the white fill, and the 1 px default tick.\r\n Knowing where \"untouched\" is turns a slider from a number into a decision - it is the\r\n difference between \"gamma 96\" and \"a touch under neutral\". */\r\n .wrap{position:relative}\r\n .line{position:absolute; left:var(--knob); right:var(--knob); top:50%; height:2px;\r\n margin-top:-1px; background:var(--track); pointer-events:none}\r\n .fill{position:absolute; top:50%; height:4px; margin-top:-2px; background:var(--accent);\r\n pointer-events:none}\r\n .tick{position:absolute; top:50%; width:1px; height:14px; margin-top:-7px;\r\n background:var(--text-3); pointer-events:none}\r\n\r\n input[type=range]{\r\n -webkit-appearance:none; appearance:none; width:100%; height:44px;\r\n background:transparent; margin:0; display:block; position:relative;\r\n }\r\n input[type=range]::-webkit-slider-runnable-track{height:44px; background:transparent}\r\n input[type=range]::-moz-range-track{height:44px; background:transparent}\r\n /* The knob: a white disc in its 2 px knob-ring, drawn in the middle of a 44 px touch box. */\r\n input[type=range]::-webkit-slider-thumb{\r\n -webkit-appearance:none; appearance:none; width:44px; height:44px; border:0; border-radius:50%;\r\n background:radial-gradient(circle, var(--accent) 7px, var(--knob-ring) 7px,\r\n var(--knob-ring) 9px, transparent 9px);\r\n }\r\n input[type=range]::-moz-range-thumb{\r\n width:44px; height:44px; border:0; border-radius:50%;\r\n background:radial-gradient(circle, var(--accent) 7px, var(--knob-ring) 7px,\r\n var(--knob-ring) 9px, transparent 9px);\r\n }\r\n input[type=range]:focus-visible{outline:2px solid var(--focus); outline-offset:2px}\r\n\r\n /* §3: every button Secondary but the one Primary; radius 4, 44 tall, 8 apart. */\r\n .presets{display:grid; grid-template-columns:repeat(2,1fr); gap:8px}\r\n button{font:inherit; font-weight:600; color:var(--text-1); background:transparent;\r\n border:1px solid var(--border-strong); border-radius:4px; min-height:44px;\r\n padding:12px 16px; cursor:pointer}\r\n button:active{background:var(--pressed)}\r\n button:focus-visible{outline:2px solid var(--focus); outline-offset:2px}\r\n\r\n /* Compare lives in a bar pinned to the bottom because it is the one control somebody\r\n reaches for without looking - they are watching the screen, not the phone. It is the\r\n page's one Primary; while it is holding neutral it shows the selected mark instead, a\r\n 2 px white edge, so the page says which state it is in. */\r\n .bar{position:fixed; left:0; right:0; bottom:0; padding:12px var(--pad)\r\n calc(12px + env(safe-area-inset-bottom)); background:linear-gradient(\r\n to top, var(--bg) 62%, rgba(21,21,21,0));}\r\n .bar button{width:100%; min-height:48px}\r\n .primary{background:var(--accent); border-color:var(--accent); color:var(--on-accent)}\r\n .primary:active{background:var(--accent-pressed); border-color:var(--accent-pressed)}\r\n .bar button.on{background:transparent; border:2px solid var(--accent); color:var(--text-1)}\r\n\r\n .note{color:var(--text-2); font-size:14px; line-height:1.45; margin:16px 0 0}\r\n\r\n /* §26, block: surface-2, radius 4, the icon, the word in text-1 and the sentence under it. */\r\n .block{display:flex; gap:12px; background:var(--surface-2); border-radius:4px; padding:12px 16px}\r\n .block .ico{width:20px; height:20px; margin-top:2px}\r\n .block p{margin:0; color:var(--text-2)}\r\n .block .word{color:var(--text-1); font-weight:600; margin-bottom:4px}\r\n</style>\r\n</head>\r\n<body>\r\n\r\n<div id=\"ui\" hidden>\r\n <header>\r\n <h1>PlexusX</h1>\r\n <span class=\"live ok\" id=\"live\">\r\n <svg class=\"ico ico-ok\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><circle cx=\"10\" cy=\"10\" r=\"7.5\"/><path d=\"M6.6 10.3l2.3 2.3 4.6-4.8\"/></svg>\r\n <svg class=\"ico ico-bad\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M7 2.5h6l4.5 4.5v6L13 17.5H7L2.5 13V7z\"/><path d=\"M10 6.2v4.8\"/><circle cx=\"10\" cy=\"13.8\" r=\".9\" fill=\"currentColor\" stroke=\"none\"/></svg>\r\n <span id=\"liveWord\">connected</span>\r\n </span>\r\n </header>\r\n\r\n <div class=\"group\" id=\"sliders\"></div>\r\n\r\n <div class=\"group\" id=\"presetGroup\" hidden>\r\n <div class=\"cap\">Scenes</div>\r\n <div class=\"presets\" id=\"presets\"></div>\r\n </div>\r\n\r\n <p class=\"note\">\r\n Your browser says &ldquo;Not secure&rdquo; beside the address. That is correct and expected:\r\n this is a plain connection straight to your own PC on your own wifi, and it never leaves it.\r\n </p>\r\n\r\n <div class=\"bar\">\r\n <button id=\"compare\" type=\"button\" class=\"primary\">Hold on neutral &mdash; see the difference</button>\r\n </div>\r\n</div>\r\n\r\n<div id=\"locked\" hidden>\r\n <div class=\"block\">\r\n <svg class=\"ico ico-bad\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M7 2.5h6l4.5 4.5v6L13 17.5H7L2.5 13V7z\"/><path d=\"M10 6.2v4.8\"/><circle cx=\"10\" cy=\"13.8\" r=\".9\" fill=\"currentColor\" stroke=\"none\"/></svg>\r\n <div>\r\n <p class=\"word\">This link has expired.</p>\r\n <p>\r\n Open the Display page in PlexusX and scan the code again. A new code is made each time,\r\n so an old one stops working on purpose.\r\n </p>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<script>\r\n(function(){\r\n // The key arrives in the FRAGMENT, which browsers never send to a server. Move it into\r\n // sessionStorage and clear it from the address bar straight away: a pull-to-refresh or an\r\n // iOS tab restore must not strand somebody, and the key must not sit in synced history.\r\n var KEY = \"plexusx.key\";\r\n var key = \"\";\r\n try {\r\n if (location.hash.length > 1) {\r\n key = decodeURIComponent(location.hash.slice(1));\r\n sessionStorage.setItem(KEY, key);\r\n history.replaceState(null, \"\", location.pathname);\r\n } else {\r\n key = sessionStorage.getItem(KEY) || \"\";\r\n }\r\n } catch (e) {\r\n if (location.hash.length > 1) key = decodeURIComponent(location.hash.slice(1));\r\n }\r\n\r\n var ui = document.getElementById(\"ui\");\r\n var locked = document.getElementById(\"locked\");\r\n var live = document.getElementById(\"live\");\r\n var liveWord = document.getElementById(\"liveWord\");\r\n if (!key) { locked.hidden = false; return; }\r\n\r\n // The status: its icon says it in its colour, the word stays text-1.\r\n function setLive(ok){\r\n live.className = \"live \" + (ok ? \"ok\" : \"bad\");\r\n liveWord.textContent = ok ? \"connected\" : \"not connected\";\r\n }\r\n\r\n function send(field, value){\r\n return fetch(\"/a?k=\" + encodeURIComponent(key)\r\n + \"&f=\" + encodeURIComponent(field)\r\n + \"&v=\" + encodeURIComponent(value), { method:\"POST\" });\r\n }\r\n\r\n // One request in flight per field, newest value wins. Firing on every input event of a\r\n // dragged slider queues dozens that arrive out of order, and the screen ends up on\r\n // whichever one happened to land last rather than where the thumb was let go.\r\n var busy = {}, queued = {};\r\n function push(field, value){\r\n queued[field] = value;\r\n if (busy[field]) return;\r\n busy[field] = true;\r\n (function step(){\r\n if (!(field in queued)) { busy[field] = false; return; }\r\n var v = queued[field]; delete queued[field];\r\n send(field, v).then(function(r){\r\n setLive(!!(r && r.ok));\r\n }).catch(function(){\r\n setLive(false);\r\n }).then(step);\r\n })();\r\n }\r\n\r\n // Where a fraction of the range sits on the track: between the knob's centre at either end.\r\n function at(t){ return \"calc(var(--knob) + (100% - 2 * var(--knob)) * \" + t + \")\"; }\r\n\r\n function build(controls){\r\n var box = document.getElementById(\"sliders\");\r\n box.innerHTML = \"\";\r\n\r\n controls.forEach(function(c){\r\n var row = document.createElement(\"div\");\r\n row.className = \"row\";\r\n\r\n var head = document.createElement(\"div\");\r\n head.className = \"head\";\r\n\r\n var name = document.createElement(\"span\");\r\n name.className = \"name\";\r\n name.textContent = c.label;\r\n\r\n var val = document.createElement(\"span\");\r\n val.className = \"val\";\r\n\r\n head.appendChild(name);\r\n head.appendChild(val);\r\n row.appendChild(head);\r\n\r\n var wrap = document.createElement(\"div\");\r\n wrap.className = \"wrap\";\r\n\r\n var slider = document.createElement(\"input\");\r\n slider.type = \"range\";\r\n // EVERY ONE OF THESE COMES FROM THE APP. Nothing here decides what a range is.\r\n slider.min = c.min;\r\n slider.max = c.max;\r\n slider.value = c.value;\r\n slider.setAttribute(\"aria-label\", c.label);\r\n\r\n var span = (c.max - c.min) || 1;\r\n\r\n // The track, and the fill: from the start for Saturation and Vibrance, the two headline\r\n // sliders; from the default for the rest, so you see what you changed (§8).\r\n var line = document.createElement(\"span\");\r\n line.className = \"line\";\r\n var fill = document.createElement(\"span\");\r\n fill.className = \"fill\";\r\n var from = (c.key === \"saturation\" || c.key === \"vibrance\") ? c.min : c.neutral;\r\n if (from < c.min || from > c.max) from = c.min;\r\n\r\n // Where \"untouched\" sits, drawn on the track. A signed readout alone does not tell you\r\n // which side of neutral you are on when the range is not centred.\r\n var tick = document.createElement(\"span\");\r\n tick.className = \"tick\";\r\n tick.style.left = at((c.neutral - c.min) / span);\r\n if (c.neutral <= c.min || c.neutral >= c.max) tick.hidden = true;\r\n\r\n function paint(){\r\n var v = Number(slider.value);\r\n var sign = (c.min < 0 && v > 0) ? \"+\" : \"\";\r\n val.textContent = sign + v + (c.suffix || \"\");\r\n val.className = \"val\" + (v === c.neutral ? \" off\" : \"\");\r\n var a = (Math.min(v, from) - c.min) / span, b = (Math.max(v, from) - c.min) / span;\r\n fill.style.left = at(a);\r\n fill.style.width = \"calc((100% - 2 * var(--knob)) * \" + (b - a) + \")\";\r\n }\r\n\r\n slider.addEventListener(\"input\", function(){\r\n paint();\r\n push(c.key, slider.value);\r\n setCompare(false);\r\n });\r\n\r\n paint();\r\n wrap.appendChild(line);\r\n wrap.appendChild(fill);\r\n wrap.appendChild(tick);\r\n wrap.appendChild(slider);\r\n row.appendChild(wrap);\r\n box.appendChild(row);\r\n });\r\n }\r\n\r\n var comparing = false;\r\n var compareBtn = document.getElementById(\"compare\");\r\n\r\n function setCompare(on, sendIt){\r\n if (comparing === on) return;\r\n comparing = on;\r\n compareBtn.className = on ? \"on\" : \"primary\";\r\n compareBtn.textContent = on\r\n ? \"Showing neutral — tap to put your look back\"\r\n : \"Hold on neutral — see the difference\";\r\n if (sendIt !== false) push(\"compare\", on ? 1 : 0);\r\n }\r\n\r\n compareBtn.addEventListener(\"click\", function(){ setCompare(!comparing); });\r\n\r\n fetch(\"/s?k=\" + encodeURIComponent(key)).then(function(r){\r\n if (!r.ok) throw new Error(\"no\");\r\n return r.json();\r\n }).then(function(state){\r\n build(state.controls || []);\r\n\r\n var box = document.getElementById(\"presets\");\r\n (state.presets || []).forEach(function(name, i){\r\n var b = document.createElement(\"button\");\r\n b.type = \"button\";\r\n b.textContent = name;\r\n b.addEventListener(\"click\", function(){ push(\"preset\", i); setCompare(false); });\r\n box.appendChild(b);\r\n });\r\n if ((state.presets || []).length) document.getElementById(\"presetGroup\").hidden = false;\r\n\r\n if (state.comparing) setCompare(true, false);\r\n\r\n ui.hidden = false;\r\n }).catch(function(){\r\n locked.hidden = false;\r\n });\r\n})();\r\n</script>\r\n\r\n</body>\r\n</html>";
}
internal static string WrongNetworkHtml(string theirs, string ours)
{
return $"<!doctype html>\r\n<html lang=\"en\">\r\n<head>\r\n<meta charset=\"utf-8\">\r\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,viewport-fit=cover\">\r\n<meta name=\"robots\" content=\"noindex,nofollow\">\r\n<meta name=\"theme-color\" content=\"#151515\">\r\n<title>Different network - PlexusX</title>\r\n<style>\r\n body{{margin:0; padding:24px 16px; background:#151515; color:#F3F3F3;\r\n font:16px/1.55 -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif}}\r\n h1{{font-size:20px; line-height:1.3; font-weight:600; margin:0 0 12px}}\r\n p{{color:#C1C1C1; margin:0 0 12px}}\r\n .rows{{background:#1C1C1C; border:1px solid #333333; border-radius:8px;\r\n padding:12px 16px; margin:16px 0}}\r\n .row{{display:flex; justify-content:space-between; gap:16px; padding:4px 0;\r\n font:14px/1.5 Consolas,ui-monospace,SFMono-Regular,Menlo,monospace}}\r\n .row span:first-child{{color:#999999}}\r\n ul{{color:#C1C1C1; margin:0 0 12px; padding-left:20px}}\r\n li{{margin:8px 0}}\r\n</style>\r\n</head>\r\n<body>\r\n<h1>Your phone is on a different network</h1>\r\n<p>It reached this PC, but PlexusX only takes commands from your own network.</p>\r\n<div class=\"rows\">\r\n <div class=\"row\"><span>This phone</span><span>{theirs}</span></div>\r\n <div class=\"row\"><span>Your PC</span><span>{ours}</span></div>\r\n</div>\r\n<p>Those two need to start with the same three numbers. Usually one of these fixes it:</p>\r\n<ul>\r\n <li>The phone is on a <strong>guest</strong> wifi. Switch it to your normal one.</li>\r\n <li>The phone is on <strong>mobile data</strong>, not wifi.</li>\r\n <li>Your router has two networks (often one ending 2.4G and one 5G) that it keeps apart.</li>\r\n</ul>\r\n<p>Your PC being on a cable is fine - that is not the problem.</p>\r\n</body>\r\n</html>";
}
}