aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / docs / design / screens / screen.js
| 1 | // screen.js -- shared behaviour for the first-run mockups: fit the 1920 x 1080 board to the window, draw the |
| 2 | // words in Allen's stroke font, stagger entrances, and the keyboard path (arrows move the lit choice, Enter |
| 3 | // or Space picks it, Escape is "Not now", any letter goes to the bar). Links between screens make the flow |
| 4 | // clickable. ?clean=1 hides the screen's name tag for screenshots. |
| 5 | "use strict"; |
| 6 | (function () { |
| 7 | const board = document.querySelector(".board"); |
| 8 | const params = new URLSearchParams(location.search); |
| 9 | if (params.get("clean") === "1") document.body.classList.add("clean"); |
| 10 | function fit() { |
| 11 | const k = Math.min(innerWidth / 1920, innerHeight / 1080); |
| 12 | board.style.transform = `translate(-50%, -50%) scale(${k})`; |
| 13 | board.style.transformOrigin = "50% 50%"; |
| 14 | } |
| 15 | addEventListener("resize", fit); |
| 16 | fit(); |
| 17 | afRender(board); |
| 18 | |
| 19 | // entrances: each .rise waits its turn (data-at ms, else 90 ms after the one before) |
| 20 | let at = 0; |
| 21 | for (const el of board.querySelectorAll(".rise")) { |
| 22 | at = el.dataset.at ? Number(el.dataset.at) : at + 90; |
| 23 | el.style.animationDelay = `${at}ms`; |
| 24 | } |
| 25 | |
| 26 | // the lit choice |
| 27 | const groups = [...board.querySelectorAll(".choices, .buttons")]; |
| 28 | for (const g of groups) { |
| 29 | const items = [...g.querySelectorAll(".choice, .button")]; |
| 30 | items.forEach((it) => { it.tabIndex = 0; it.setAttribute("role", "button"); |
| 31 | it.addEventListener("mouseenter", () => light(g, it)); it.addEventListener("focus", () => light(g, it)); |
| 32 | it.addEventListener("click", () => go(it)); }); |
| 33 | } |
| 34 | function light(g, it) { for (const o of g.querySelectorAll(".lit")) o.classList.remove("lit"); it.classList.add("lit"); } |
| 35 | function go(it) { if (it && it.dataset.href) location.href = it.dataset.href + (params.get("clean") ? "?clean=1" : ""); } |
| 36 | const notNow = board.querySelector(".not-now"); |
| 37 | if (notNow) { notNow.tabIndex = 0; notNow.setAttribute("role", "button"); notNow.addEventListener("click", () => go(notNow)); } |
| 38 | addEventListener("keydown", (e) => { |
| 39 | const g = groups[0]; |
| 40 | const items = g ? [...g.querySelectorAll(".choice, .button")] : []; |
| 41 | const i = items.findIndex((x) => x.classList.contains("lit")); |
| 42 | if (["ArrowDown", "ArrowRight"].includes(e.key) && items.length) { light(g, items[(i + 1) % items.length]); e.preventDefault(); } |
| 43 | else if (["ArrowUp", "ArrowLeft"].includes(e.key) && items.length) { light(g, items[(i - 1 + items.length) % items.length]); e.preventDefault(); } |
| 44 | else if ((e.key === "Enter" || e.key === " ") && items[i]) { go(items[i]); e.preventDefault(); } |
| 45 | else if (e.key === "Escape" && notNow) go(notNow); |
| 46 | else if (e.key.length === 1 && board.querySelector(".bar")) board.querySelector(".bar").classList.add("focus"); |
| 47 | }); |
| 48 | window.__screen_ready = true; |
| 49 | })(); |