TerminalHomepage/js/commands.js

28 lines
767 B
JavaScript
Raw Normal View History

function cmd_help() {
return "You need help? Sucks to be you! Hahahahaha";
2023-01-13 06:27:13 +00:00
}
function cmd_clear() {
window.location.reload();
return "";
}
function cmd_exec(input) {
if (input === undefined)
return "You must enter parameters!";
const str = input.join(' ');
if (/[',:;a-zA-Z]/.test(str) || str === "")
return "Invalid input!";
const chars = str.split('').filter(e => {
const code = e.charCodeAt(0);
const s = code === 32;
const a = code > 36;
const b = code < 63;
const c = code === 94;
const d = code === 124;
return !(s || a && b || c || d);
});
if (chars.length > 0)
return "Invalid input!";
return (new Function(`return ${str}`))();
}