feat: add some hidden apps, logging and settings menu
This commit is contained in:
@@ -1,3 +1,46 @@
|
||||
// This file is used for global shit thats useful for os-gui
|
||||
|
||||
function setDisplayURL(newURL) {
|
||||
window.history.pushState(null, '', newURL);
|
||||
}
|
||||
|
||||
var yourFuckingSavefile = {
|
||||
debugMode: false
|
||||
};
|
||||
|
||||
var globalSaveid = 5;
|
||||
|
||||
function save(saveid) {
|
||||
console.log("Saving...");
|
||||
const savefile = saveid || 1;
|
||||
window.localStorage.setItem("__LAMINAXOS:SAVEFILE_".concat(savefile.toString()),
|
||||
JSON.stringify(yourFuckingSavefile));
|
||||
console.log("Saved to SAVE#".concat(savefile.toString()));
|
||||
}
|
||||
|
||||
function load(saveid) {
|
||||
console.log("Loaded...");
|
||||
const savefile = saveid || 1;
|
||||
const eee = window.localStorage.getItem("__LAMINAXOS:SAVEFILE_".concat(savefile.toString()));
|
||||
if (eee === "undefined") {
|
||||
throw new Error(`Key "${key}" not found in localStorage.`);
|
||||
}
|
||||
yourFuckingSavefile = JSON.parse(
|
||||
eee
|
||||
)
|
||||
console.log("Loaded from SAVE#".concat(savefile.toString()));
|
||||
}
|
||||
|
||||
// Add stuff that would make David cry
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
console.log("%c" + "Hold Up!", "color: #7289DA; -webkit-text-stroke: 2px black; font-size: 72px; font-weight: bold;");
|
||||
console.warn("IF YOU USE THIS CONSOLE YOUR SAVE IS NOT CANON!!");
|
||||
console.log("... Also dont edit your savefile like an idiot. Btw its at the var yourFuckingSavefile");
|
||||
}
|
||||
try {
|
||||
load(globalSaveid);
|
||||
} catch (eee) {
|
||||
console.log(eee);
|
||||
save(globalSaveid);
|
||||
}
|
||||
@@ -86,6 +86,7 @@ function createWindow(url, settings) {
|
||||
|
||||
const windowDiv = document.createElement('div');
|
||||
windowDiv.classList.add('window');
|
||||
if (headerless) windowDiv.classList.add('window-noborder');
|
||||
if (shouldIndent) windowDiv.style.top = '50px';
|
||||
if (shouldIndent) windowDiv.style.left = '50px';
|
||||
windowDiv.style.zIndex = zIndexCounter++;
|
||||
|
||||
183
shell.js
183
shell.js
@@ -3,6 +3,43 @@ var embeddedApps = {
|
||||
notepad: "data:text/html;charset=utf-8;base64,PGh0bWw+PGhlYWQ+PHRpdGxlPm5vdGVwYWQ8L3RpdGxlPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+Ym9keXttYXJnaW46MH10ZXh0YXJlYXtyZXNpemU6bm9uZTt3aWR0aDo5OCU7aGVpZ2h0Ojk4JTtwb3NpdGlvbjphYnNvbHV0ZTt0b3A6MDtib3JkZXI6bm9uZTttYXJnaW46MSU7Zm9udC1mYW1pbHk6bW9ub3NwYWNlO2ZvbnQtc2l6ZToxZW07b3ZlcmZsb3c6aGlkZGVufXRleHRhcmVhOmZvY3Vze291dGxpbmU6MH08L3N0eWxlPjwvaGVhZD48Ym9keT48dGV4dGFyZWE+PC90ZXh0YXJlYT48L2JvZHk+PC9odG1sPg=="
|
||||
}
|
||||
|
||||
function download(filename, text) {
|
||||
var element = document.createElement('a');
|
||||
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
|
||||
element.setAttribute('download', filename);
|
||||
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
|
||||
element.click();
|
||||
|
||||
document.body.removeChild(element);
|
||||
}
|
||||
function openJsonFilePrompt(callback) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = '.json,application/json';
|
||||
|
||||
input.onchange = (event) => {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
try {
|
||||
const json = JSON.parse(reader.result);
|
||||
callback(null, json);
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
};
|
||||
|
||||
input.click();
|
||||
}
|
||||
|
||||
|
||||
var shell = {
|
||||
taskbar_wind: null,
|
||||
taskbar_size: 25,
|
||||
@@ -22,13 +59,15 @@ function doTheBullshitByShellBruh() {
|
||||
)
|
||||
}
|
||||
|
||||
shell.launch = function(app) {
|
||||
if (app === "Notepad") {
|
||||
shell.launch = function (app) {
|
||||
switch (app) {
|
||||
case "Notepad":
|
||||
createWindow(embeddedApps.notepad, {
|
||||
resizable: true,
|
||||
name: "Notepad"
|
||||
}); // Launch notepad
|
||||
} else if (app === "Calculator") {
|
||||
break;
|
||||
case "Calculator":
|
||||
const calc = createWindow(embeddedApps.calc, {
|
||||
resizable: true,
|
||||
name: "Calculator"
|
||||
@@ -36,6 +75,125 @@ shell.launch = function(app) {
|
||||
calc.minSizeX = 500;
|
||||
calc.minSizeY = 444;
|
||||
updateWindowMin(calc.windID);
|
||||
break;
|
||||
case "laminax":
|
||||
createWindow("https://www.youtube.com/embed/6uN3dxJRnss", { name: "You found the easter egg!" });
|
||||
break;
|
||||
case "lamver": {
|
||||
const wind = createWindow("about:blank", {
|
||||
name: "About LaminaxOS"
|
||||
});
|
||||
const smDoc = wind.iframe.contentDocument || wind.iframe.contentWindow.document;
|
||||
smDoc.open();
|
||||
smDoc.write(`
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
background: #222;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
h2 {
|
||||
margin-top: 0;
|
||||
font-size: 1.2em;
|
||||
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
padding: 6px 10px;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
}
|
||||
li:hover {
|
||||
background: #444;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>LaminaxOS 8 Enterprise</h2>
|
||||
<hr>
|
||||
<p>LaminaxOS</p>
|
||||
<p>Version 7.6 (Build 17503: Service Pack 2)</p>
|
||||
<p>"Copyright" 2040 LAMINAX Corporation; Some Rights Reserved</p>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
smDoc.close();
|
||||
break;
|
||||
}
|
||||
case "Settings":
|
||||
{
|
||||
const wind = createWindow("about:blank", {
|
||||
name: "LaminaxOS Settings"
|
||||
});
|
||||
const smDoc = wind.iframe.contentDocument || wind.iframe.contentWindow.document;
|
||||
smDoc.open();
|
||||
smDoc.write(`
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
background: #222;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
h2 {
|
||||
margin-top: 0;
|
||||
font-size: 1.2em;
|
||||
border-bottom: 1px solid #555;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
padding: 6px 10px;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
color: lightblue;
|
||||
}
|
||||
li:hover {
|
||||
background: #444;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Adjust your computer's settings</h2>
|
||||
<ul>
|
||||
<li onclick="parent.postMessage({type:'startItem', action:'openApp', app:'lamver'}, '*')">About This OS</li>
|
||||
<ul>
|
||||
<hr>
|
||||
<ul>
|
||||
<li onclick="parent.postMessage({type:'saveExport'}, '*')">Save User</li>
|
||||
<li onclick="parent.postMessage({type:'loadExport'}, '*')">Load User</li>
|
||||
<ul>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
smDoc.close();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log("%c" + "You Silly goober!", "color: #7289DA; -webkit-text-stroke: 2px black; font-size: 32px; font-weight: bold;");
|
||||
console.log("This app doesnt exist! :3c");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -207,13 +365,13 @@ shell.init = function () {
|
||||
const height = shell.startmenuHeight;
|
||||
const x = 0;
|
||||
const y = desktopRect.height - taskbarHeight - height;
|
||||
transformWindow(startMenu.windID, width, height, x, y,true);
|
||||
transformWindow(startMenu.windID, width, height, x, y, true);
|
||||
focusWindow(startMenu.windID);
|
||||
}
|
||||
|
||||
// Helper function to hide start menu
|
||||
function hideStartMenu() {
|
||||
transformWindow(startMenu.windID, 0, 0, 0, window.innerHeight + shell.startmenuHeight,true);
|
||||
transformWindow(startMenu.windID, 0, 0, 0, window.innerHeight + shell.startmenuHeight, true);
|
||||
}
|
||||
|
||||
let startMenuVisible = false;
|
||||
@@ -249,6 +407,21 @@ shell.init = function () {
|
||||
startMenuVisible = false;
|
||||
shell.launch(event.data.app);
|
||||
}
|
||||
if (event.data?.type === "saveExport") {
|
||||
download("savefile.json", JSON.stringify(yourFuckingSavefile));
|
||||
}
|
||||
if (event.data?.type === "loadExport") {
|
||||
openJsonFilePrompt((err, data) => {
|
||||
if (err) {
|
||||
console.error('Invalid JSON file:', err);
|
||||
} else {
|
||||
yourFuckingSavefile = data;
|
||||
save(globalSaveid);
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
hideStartMenu();
|
||||
|
||||
Reference in New Issue
Block a user