Add bad coders webring, update kumaos.
This commit is contained in:
parent
770369c84b
commit
dc0b9b14cb
17 changed files with 401 additions and 155 deletions
10
static/kumos/system/init.mjs
Normal file
10
static/kumos/system/init.mjs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import "../apps/pkg.mjs";
|
||||
import { Process } from "../kernel.mjs";
|
||||
import interactiveLogin from "./targets/interactive-login.mjs";
|
||||
|
||||
function init(p) {
|
||||
console.log("Welcome to KumOS!");
|
||||
interactiveLogin(p);
|
||||
}
|
||||
|
||||
new Process("init", init);
|
||||
43
static/kumos/system/login.mjs
Normal file
43
static/kumos/system/login.mjs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { Process, Window, getScreenRoot, promoteWindow } from "../kernel.mjs";
|
||||
import createShell from "./shell.mjs";
|
||||
|
||||
export default function init(p) {
|
||||
function login(password) {
|
||||
if (password == "demo") {
|
||||
p.detach();
|
||||
new Process("shell", createShell);
|
||||
w.destroy();
|
||||
} else {
|
||||
console.log("Invalid password.")
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Please log in with login(password)!");
|
||||
window.login = login;
|
||||
const w = new Window(p);
|
||||
w.setTitle("Login");
|
||||
w.window.style.height = "fit-content";
|
||||
w.window.style.width = "fit-content";
|
||||
w.window.style.resize = "none";
|
||||
|
||||
const loginForm = document.createElement("div");
|
||||
loginForm.style.display = "flex";
|
||||
|
||||
const passwordInput = document.createElement("input");
|
||||
passwordInput.type = "password";
|
||||
passwordInput.placeholder = "Password is 'demo'";
|
||||
|
||||
const loginButton = document.createElement("button");
|
||||
loginButton.innerText = "login";
|
||||
loginButton.addEventListener('click', () => {
|
||||
login(passwordInput.value);
|
||||
})
|
||||
|
||||
loginForm.appendChild(passwordInput);
|
||||
loginForm.appendChild(loginButton);
|
||||
w.content.appendChild(loginForm);
|
||||
|
||||
w.close.remove();
|
||||
getScreenRoot().appendChild(w.window);
|
||||
promoteWindow(w);
|
||||
}
|
||||
33
static/kumos/system/shell.mjs
Normal file
33
static/kumos/system/shell.mjs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { getScreenRoot, getApplications, Process } from "../kernel.mjs";
|
||||
import { showNotification } from "../../scripts/notification.js";
|
||||
|
||||
export function notify(title, text, time) {
|
||||
showNotification(title, text, time);
|
||||
}
|
||||
|
||||
function runApp(name) {
|
||||
let launched = false;
|
||||
getApplications().forEach(app => {
|
||||
if (app.name == name) {
|
||||
app.bootstrap();
|
||||
launched = true;
|
||||
}
|
||||
})
|
||||
if (!launched) alert("Not found.");
|
||||
}
|
||||
|
||||
export default function createShell(p) {
|
||||
const bar = document.createElement('div');
|
||||
bar.classList.add("kumosBar");
|
||||
|
||||
const run = document.createElement('input');
|
||||
const runButton = document.createElement('button');
|
||||
run.type = "text";
|
||||
runButton.innerText = "Run";
|
||||
runButton.id = "kumosBarRunButton"
|
||||
runButton.addEventListener('click', () => runApp(run.value));
|
||||
bar.appendChild(run);
|
||||
bar.appendChild(runButton);
|
||||
|
||||
getScreenRoot().appendChild(bar);
|
||||
}
|
||||
5
static/kumos/system/targets/interactive-login.mjs
Normal file
5
static/kumos/system/targets/interactive-login.mjs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import login from "../login.mjs";
|
||||
|
||||
export default (p) => {
|
||||
p.child("login", login);
|
||||
}
|
||||
Loading…
Reference in a new issue