-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4ndyOS_VER_0.0.1_m4trix.html
233 lines (214 loc) · 6.9 KB
/
4ndyOS_VER_0.0.1_m4trix.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>4ndyOS VER 0.0.1 m4trix</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
body {
background-color: black;
color: #ff073a;
font-family: 'VT323', monospace;
font-size: 18px;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
height: 100vh;
justify-content: flex-end;
}
#terminal {
flex-grow: 1;
overflow-y: auto;
padding: 10px;
}
#input-line {
display: flex;
align-items: center;
position: relative;
bottom: 0;
padding: 10px;
}
#input-line span {
margin-right: 5px;
}
#input {
background: none;
border: none;
color: #ff073a;
font-family: 'VT323', monospace;
font-size: 18px;
width: 100%;
outline: none;
}
#output {
white-space: pre-wrap;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/10.0.0/math.min.js"></script>
</head>
<body>
<div id="terminal">
<div id="output"></div>
</div>
<div id="input-line">
<span>USER:</span>
<input type="text" id="input" autofocus>
</div>
<script>
const output = document.getElementById('output');
const input = document.getElementById('input');
let username = "user";
const commands = {
help: () =>
`4ndyOS: Comandos disponibles:
help - Muestra este menú
clear - Limpia la pantalla
echo [texto] - Repite el texto ingresado
echo [n] [texto] - Repite el texto 'n' veces
about - Muestra información del sistema
version - Muestra la versión de 4ndyOS
time GMT - Muestra la hora en formato GMT
time - Muestra la hora local en formato AM/PM
date - Muestra la fecha y hora actual
solve [expresión] - Resuelve una expresión matemática avanzada
web [URL] - Abre una página web
random [min] [max] - Genera un número aleatorio
upper [texto] - Convierte el texto a mayúsculas
lower [texto] - Convierte el texto a minúsculas
/change username [nombre] - Cambia el nombre de usuario
shutdown - Apaga el sistema directamente
restart - Reinicia la terminal`,
clear: () => {
output.innerHTML = "";
return "";
},
echo: (args) => `4ndyOS: ${args.join(" ")}`,
"echo_count": (args) => {
const count = parseInt(args[0], 10);
const text = args.slice(1).join(" ");
return `4ndyOS: ${Array(count).fill(text).join(" ")}`;
},
about: () => "4ndyOS: 4ndyOS VER 0.0.1 m4trix, creado por 4ndy64,primer sistema operativo que creó a base de comandos.",
version: () => "4ndyOS: 4ndyOS VER 0.0.1 m4trix",
time: () => {
const date = new Date();
const hours = date.getHours();
const minutes = date.getMinutes();
const ampm = hours >= 12 ? "PM" : "AM";
const localTime = `${hours % 12 || 12}:${minutes < 10 ? "0" + minutes : minutes} ${ampm}`;
return `4ndyOS: Hora local: ${localTime}`;
},
"time GMT": () => {
const date = new Date();
const gmtTime = date.toUTCString();
return `4ndyOS: Hora GMT: ${gmtTime}`;
},
date: () => {
const date = new Date();
return `4ndyOS: Fecha y hora actual: ${date.toLocaleString()}`;
},
solve: (args) => {
try {
const expression = args.join(" ");
const result = math.evaluate(expression);
return `4ndyOS: Resultado: ${result}`;
} catch (e) {
return "4ndyOS: Error: expresión matemática inválida.";
}
},
web: (args) => {
if (!args[0]) {
return "4ndyOS: Error: Especifica una URL. Ejemplo: web https://example.com";
}
const url = args[0].startsWith("http") ? args[0] : `https://${args[0]}`;
openWebWindow(url);
return `4ndyOS: Abriendo: ${url}`;
},
random: (args) => {
const min = parseInt(args[0], 10) || 0;
const max = parseInt(args[1], 10) || 100;
return `4ndyOS: Número aleatorio: ${Math.floor(Math.random() * (max - min + 1)) + min}`;
},
upper: (args) => `4ndyOS: ${args.join(" ").toUpperCase()}`,
lower: (args) => `4ndyOS: ${args.join(" ").toLowerCase()}`,
restart: () => {
output.innerHTML = "";
return "4ndyOS: Se ha reiniciado la terminal. Bienvenido.";
},
"/change": (args) => {
if (args[0] === "username" && args[1]) {
username = args.slice(1).join(" ");
return `4ndyOS: Nombre de usuario cambiado a '${username}'.`;
}
return "4ndyOS: Uso: /change username [nuevo_nombre]";
},
shutdown: () => {
window.location.href = "index.html";
return `4ndyOS: Sistema apagado. Redirigiendo a la página de inicio...`;
}
};
function openWebWindow(url) {
const width = 800;
const height = 600;
const left = (screen.width - width) / 2;
const top = (screen.height - height) / 2;
window.open(
url,
"_blank",
`width=${width},height=${height},left=${left},top=${top},resizable=yes`
);
}
function executeCommand(commandLine) {
const [command, ...args] = commandLine.split(" ");
const cmd = commands[command];
if (/^hola$/i.test(command)) {
return `4ndyOS: Hola, ${username}`;
}
if (cmd) {
return cmd(args);
} else {
return `4ndyOS: '${command}' no es un comando reconocido. Escribe 'help' para ver la lista de comandos.`;
}
}
function addOutput(text, delay = 30) {
return new Promise((resolve) => {
const newLine = document.createElement("div");
output.appendChild(newLine);
let index = 0;
function typeChar() {
if (index < text.length) {
newLine.textContent += text[index];
index++;
setTimeout(typeChar, delay);
} else {
resolve();
}
}
typeChar();
output.scrollTop = output.scrollHeight;
});
}
input.addEventListener("keydown", async (e) => {
if (e.key === "Enter") {
const commandLine = input.value.trim();
if (commandLine) {
await addOutput(`4ndyOS: ${commandLine}`);
const result = executeCommand(commandLine);
if (result) await addOutput(result);
}
input.value = "";
}
});
async function showWelcomeMessage() {
await addOutput("4ndyOS: Bienvenido a 4ndyOS VER 0.0.1 m4trix.");
await addOutput("4ndyOS: Escribe 'help' para ver los comandos disponibles.");
}
window.onload = async () => {
input.focus();
await showWelcomeMessage();
};
</script>
</body>
</html>