diff --git a/public/bundle.js b/public/bundle.js index 10fade9..fd62951 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -1,5 +1,5 @@ //// -// version: 6da838a +// version: 1a97e37 // src/js/dom.ts var content2 = $("content"); @@ -334,13 +334,27 @@ function resizeCinema() { content3.style.transform = `scale(${scale})`; } +// src/js/webapp.ts +var apps = []; +function cacheApps(a) { + apps.length = 0; + apps.unshift(...a); + apps.sort(); + window.dispatchEvent(new CustomEvent("apps:change")); +} + // src/js/session.ts var sessionId = randomId(); var projectName = $("project-name"); var projectCwd = $("project-cwd"); +var projectWww = $("project-www"); var sessionStore = new Map; +function initSession() { + window.addEventListener("apps:change", (e) => updateWww(sessionStore.get("project") || "root")); +} function handleSessionStart(msg) { sessionStore.set("NOSE_DIR", msg.data.NOSE_DIR); + sessionStore.set("hostname", msg.data.hostname); updateProjectName(msg.data.project); updateCwd(msg.data.cwd); browserCommands.mode?.(msg.data.mode); @@ -355,6 +369,7 @@ function handleSessionUpdate(msg) { function updateProjectName(project) { sessionStore.set("project", project); projectName.textContent = project; + updateWww(project); updateCwd("/"); } function updateCwd(cwd) { @@ -362,6 +377,16 @@ function updateCwd(cwd) { sessionStore.set("cwd", cwd); projectCwd.textContent = cwd; } +function updateWww(project) { + if (!apps.includes(project)) { + projectWww.style.display = "none"; + return; + } + projectWww.style.display = ""; + const hostname = sessionStore.get("hostname") || "localhost"; + const s = hostname.startsWith("localhost") ? "" : "s"; + projectWww.href = `http${s}://${project}.${hostname}`; +} function displayProjectPath(path) { let prefix = sessionStore.get("NOSE_DIR") || ""; prefix += "/" + sessionStore.get("project"); @@ -693,6 +718,9 @@ async function dispatchMessage(msg) { case "commands": cacheCommands(msg.data); break; + case "apps": + cacheApps(msg.data); + break; case "error": console.error(msg.data); break; @@ -770,6 +798,25 @@ function retryConnection() { setTimeout(startConnection, 2000); } +// src/js/statusbar.ts +var STATUS_MSG_LENGTH = 3000; +var statusbar = $("statusbar"); +var statusbarMsg = $("statusbar-msg"); +var timer; +function status(msg) { + showStatusMsg(); + statusbarMsg.textContent = msg; + if (timer) + clearTimeout(timer); + timer = setTimeout(hideStatusMsg, STATUS_MSG_LENGTH); +} +function showStatusMsg() { + statusbar.classList.add("showing-msg"); +} +function hideStatusMsg() { + statusbar.className = ""; +} + // src/js/commands.ts var commands = []; var browserCommands = { @@ -790,6 +837,7 @@ var browserCommands = { resize(); focusInput(); }, + status: (msg) => status(msg), reload: () => window.location.reload() }; function cacheCommands(cmds) { @@ -1282,7 +1330,7 @@ function clearInput() { // src/js/vram.ts var vramCounter = $("vram-size"); var startVramCounter = () => { - const timer = setInterval(() => { + const timer2 = setInterval(() => { const count = parseInt(vramCounter.textContent) + 1; let val = count + "KB"; if (count < 10) @@ -1290,7 +1338,7 @@ var startVramCounter = () => { vramCounter.textContent = val; if (count >= 64) { vramCounter.textContent += " OK"; - clearInterval(timer); + clearInterval(timer2); } }, 15); }; @@ -1308,5 +1356,6 @@ initHyperlink(); initInput(); initResize(); initScrollback(); +initSession(); startConnection(); startVramCounter();