execute command for math and logic calculations
This commit is contained in:
parent
c66d7c7386
commit
a11b93480d
@ -5,4 +5,24 @@ function cmd_help() {
|
|||||||
function cmd_clear() {
|
function cmd_clear() {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
return "";
|
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}`))();
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user