-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4ndyOS_VER_0.0.3_m4trix.html
240 lines (225 loc) · 6.83 KB
/
4ndyOS_VER_0.0.3_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
234
235
236
237
238
239
240
<!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.3 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;
}
#time-date {
position: absolute;
top: 10px;
right: 10px;
color: #ff073a;
font-size: 14px;
}
</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>
<div id="time-date"></div>
<script>
const output = document.getElementById('output');
const input = document.getElementById('input');
const timeDateElement = document.getElementById('time-date');
let username = "user";
function updateTimeDate() {
const now = new Date();
const time = now.toLocaleTimeString();
const date = now.toLocaleDateString();
timeDateElement.textContent = `Fecha: ${date} | Hora: ${time}`;
}
setInterval(updateTimeDate, 1000);
updateTimeDate();
const commands = {
h: () =>
`4ndyOS: Comandos disponibles:
//h - Ayuda
//c - Limpiar
//e [texto] - Escribir texto
//length [texto] - Contar caracteres
//cw [texto] - Contar palabras
//lowercase [texto] - Convertir a minúsculas
//searchword [texto],[palabra] - Contar ocurrencias
//a - Info del sistema
//v - Ver versión
//s [expr] - Resolver expresión
//w [URL] - Abrir web
//r [min] [max] - Random
//u [texto] - Uppercase
/ch u [nombre] - Cambiar usuario
//x - Apagar
//re - Reiniciar`,
c: () => {
output.innerHTML = "";
return "";
},
e: (args) => `4ndyOS: ${args.join(" ")}`,
length: (args) => `4ndyOS: Número de caracteres: ${args.join(" ").length}`,
cw: (args) => {
const text = args.join(" ");
const wordCount = text.split(/\s+/).filter(Boolean).length;
return `4ndyOS: Número de palabras: ${wordCount}`;
},
lowercase: (args) => `4ndyOS: ${args.join(" ").toLowerCase()}`,
searchword: (args) => {
const parts = args.join(" ").split(",");
if (parts.length === 2) {
const text = parts[0].trim();
const word = parts[1].trim();
const count = (text.match(new RegExp(word, 'g')) || []).length;
return `4ndyOS: La palabra '${word}' aparece ${count} veces.`;
}
return "4ndyOS: Error en comando //searchword. Usa //searchword [texto],[palabra].";
},
a: () => "4ndyOS: 4ndyOS VER 0.0.3 m4trix, creado por 4ndy64.",
v: () => "4ndyOS: 4ndyOS VER 0.0.3 m4trix",
s: (args) => {
try {
const expression = args.join(" ");
const result = math.evaluate(expression);
return `4ndyOS: Resultado: ${result}`;
} catch (e) {
return "4ndyOS: Error: expresión inválida.";
}
},
w: (args) => {
if (!args[0]) {
return "4ndyOS: Error: URL requerida. Ej: //w example.com";
}
const url = args[0].startsWith("http") ? args[0] : `https://${args[0]}`;
openWebWindow(url);
return `4ndyOS: Abriendo ${url}`;
},
r: (args) => {
const min = parseInt(args[0], 10) || 0;
const max = parseInt(args[1], 10) || 100;
return `4ndyOS: Random: ${Math.floor(Math.random() * (max - min + 1)) + min}`;
},
u: (args) => `4ndyOS: ${args.join(" ").toUpperCase()}`,
l: (args) => `4ndyOS: ${args.join(" ").toLowerCase()}`,
re: () => {
output.innerHTML = "";
return "4ndyOS: Terminal reiniciada.";
},
"/ch": (args) => {
if (args[0] === "u" && args[1]) {
username = args.slice(1).join(" ");
return `4ndyOS: Usuario cambiado a '${username}'.`;
}
return "4ndyOS: Uso: /ch u [nombre]";
},
x: () => {
window.location.href = "index.html";
return "4ndyOS: Apagado. Redirigiendo...";
}
};
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.slice(2)];
if (/^hola$/i.test(command)) {
return `4ndyOS: Hola, ${username}`;
}
if (cmd) {
return cmd(args);
} else {
return `4ndyOS: '${command}' no es válido. Usa //h.`;
}
}
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, Math.max(delay - Math.floor(text.length / 50), 5));
} 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.3 m4trix.");
await addOutput("4ndyOS: Escribe '//h' para comandos.");
}
window.onload = async () => {
input.focus();
await showWelcomeMessage();
};
</script>
</body>
</html>