Compare commits
No commits in common. "cae2c1a9b1f44b0f472785586563ba90bec41741" and "094499b8e9f29414956cf8ec9520d8214e52fb66" have entirely different histories.
cae2c1a9b1
...
094499b8e9
|
|
@ -1,5 +1,5 @@
|
||||||
////
|
////
|
||||||
// version: 3e67d66
|
// version: 1a97e37
|
||||||
|
|
||||||
// src/js/dom.ts
|
// src/js/dom.ts
|
||||||
var content2 = $("content");
|
var content2 = $("content");
|
||||||
|
|
@ -64,11 +64,6 @@ function initScrollback() {
|
||||||
function insert(node) {
|
function insert(node) {
|
||||||
scrollback.append(node);
|
scrollback.append(node);
|
||||||
}
|
}
|
||||||
function latestId() {
|
|
||||||
const nodes = document.querySelectorAll("[data-id]");
|
|
||||||
if (nodes.length)
|
|
||||||
return nodes[nodes.length - 1].dataset.id;
|
|
||||||
}
|
|
||||||
function addInput(id, input, status) {
|
function addInput(id, input, status) {
|
||||||
const parent = $$("li.input");
|
const parent = $$("li.input");
|
||||||
const statusSpan = $$(`span.status.${statusColors[status || "waiting"]}`, "•");
|
const statusSpan = $$(`span.status.${statusColors[status || "waiting"]}`, "•");
|
||||||
|
|
@ -347,14 +342,6 @@ function cacheApps(a) {
|
||||||
apps.sort();
|
apps.sort();
|
||||||
window.dispatchEvent(new CustomEvent("apps:change"));
|
window.dispatchEvent(new CustomEvent("apps:change"));
|
||||||
}
|
}
|
||||||
function currentAppUrl() {
|
|
||||||
const project = sessionStore.get("project") || "root";
|
|
||||||
if (!apps.includes(project))
|
|
||||||
return;
|
|
||||||
const hostname = sessionStore.get("hostname") || "localhost";
|
|
||||||
const s = hostname.startsWith("localhost") ? "" : "s";
|
|
||||||
return `http${s}://${project}.${hostname}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// src/js/session.ts
|
// src/js/session.ts
|
||||||
var sessionId = randomId();
|
var sessionId = randomId();
|
||||||
|
|
@ -833,15 +820,7 @@ function hideStatusMsg() {
|
||||||
// src/js/commands.ts
|
// src/js/commands.ts
|
||||||
var commands = [];
|
var commands = [];
|
||||||
var browserCommands = {
|
var browserCommands = {
|
||||||
browse: (url) => {
|
browse: (url) => openBrowser(url, "command"),
|
||||||
const currentUrl = url ?? currentAppUrl();
|
|
||||||
if (currentUrl) {
|
|
||||||
openBrowser(currentUrl, "command");
|
|
||||||
} else {
|
|
||||||
setTimeout(() => setStatus(latestId(), "error"), 0);
|
|
||||||
return "usage: browse <url>";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"browser-session": () => sessionId,
|
"browser-session": () => sessionId,
|
||||||
clear: () => scrollback.innerHTML = "",
|
clear: () => scrollback.innerHTML = "",
|
||||||
commands: () => {
|
commands: () => {
|
||||||
|
|
|
||||||
|
|
@ -9,21 +9,11 @@ import { resize } from "./resize"
|
||||||
import { sessionId } from "./session"
|
import { sessionId } from "./session"
|
||||||
import { send } from "./websocket"
|
import { send } from "./websocket"
|
||||||
import { status } from "./statusbar"
|
import { status } from "./statusbar"
|
||||||
import { setStatus, latestId } from "./scrollback"
|
|
||||||
import { currentAppUrl } from "./webapp"
|
|
||||||
|
|
||||||
export const commands: string[] = []
|
export const commands: string[] = []
|
||||||
|
|
||||||
export const browserCommands: Record<string, (...args: string[]) => void | Promise<void> | CommandOutput> = {
|
export const browserCommands: Record<string, (...args: string[]) => void | Promise<void> | CommandOutput> = {
|
||||||
browse: (url?: string) => {
|
browse: (url: string) => openBrowser(url, "command"),
|
||||||
const currentUrl = url ?? currentAppUrl()
|
|
||||||
if (currentUrl) {
|
|
||||||
openBrowser(currentUrl, "command")
|
|
||||||
} else {
|
|
||||||
setTimeout(() => setStatus(latestId()!, "error"), 0)
|
|
||||||
return "usage: browse <url>"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"browser-session": () => sessionId,
|
"browser-session": () => sessionId,
|
||||||
clear: () => scrollback.innerHTML = "",
|
clear: () => scrollback.innerHTML = "",
|
||||||
commands: () => {
|
commands: () => {
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,6 @@ export function insert(node: HTMLElement) {
|
||||||
scrollback.append(node)
|
scrollback.append(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function latestId(): string | undefined {
|
|
||||||
const nodes = document.querySelectorAll("[data-id]")
|
|
||||||
if (nodes.length)
|
|
||||||
return (nodes[nodes.length - 1] as HTMLElement).dataset.id
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addInput(id: string, input: string, status?: InputStatus) {
|
export function addInput(id: string, input: string, status?: InputStatus) {
|
||||||
const parent = $$("li.input")
|
const parent = $$("li.input")
|
||||||
const statusSpan = $$(`span.status.${statusColors[status || "waiting"]}`, "•")
|
const statusSpan = $$(`span.status.${statusColors[status || "waiting"]}`, "•")
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
////
|
////
|
||||||
// NOSE webapps
|
// NOSE webapps
|
||||||
|
|
||||||
import { sessionStore } from "./session"
|
|
||||||
|
|
||||||
export const apps: string[] = []
|
export const apps: string[] = []
|
||||||
|
|
||||||
export function cacheApps(a: string[]) {
|
export function cacheApps(a: string[]) {
|
||||||
|
|
@ -12,13 +10,3 @@ export function cacheApps(a: string[]) {
|
||||||
|
|
||||||
window.dispatchEvent(new CustomEvent("apps:change"))
|
window.dispatchEvent(new CustomEvent("apps:change"))
|
||||||
}
|
}
|
||||||
|
|
||||||
export function currentAppUrl(): string | undefined {
|
|
||||||
const project = sessionStore.get("project") || "root"
|
|
||||||
|
|
||||||
if (!apps.includes(project)) return
|
|
||||||
|
|
||||||
const hostname = sessionStore.get("hostname") || "localhost"
|
|
||||||
const s = hostname.startsWith("localhost") ? "" : "s"
|
|
||||||
return `http${s}://${project}.${hostname}`
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user