KirkMcDonald / kirkmcdonald.github.io

Simple web-based calculator for the game Factorio.
Apache License 2.0
553 stars 147 forks source link

[Suggestion] Allow more calculations in input boxes #108

Closed L0laapk3 closed 5 years ago

L0laapk3 commented 5 years ago

I noticed that you allow some basic calculations in the input boxes on the top. The implementation is quite inconsistent right now. The items/second boxes replaces the expression with the result of the expression, the factorios input doesn't.

Also, only division is allowed, and it will not work for numbers that are not integers, regardless if , or . is used. other expressions, for example, +, -, *, or ^ are not allowed.

I propose an easy to implement, more robust system to evaluate expressions: value = eval(input.value.replace(/,/g, ".").

The value in the input box would consistently be replaced with the new evaluated value on the onblur event, or when the enter key is pressed.

KirkMcDonald commented 5 years ago

No.

The syntax it accepts is a reflection of the output when the calculator is placed into "rational" mode. I have no intention of making it a generalized calculator.