Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve/calculator #56

Merged
merged 8 commits into from
Oct 30, 2023
Merged

Improve/calculator #56

merged 8 commits into from
Oct 30, 2023

Conversation

Yopai
Copy link
Contributor

@Yopai Yopai commented Oct 30, 2023

Some refactoring and improvements on the calculator widget

  • fix HTML5 compliance (put style and script in the head. and comment after the DOCTYPE declaration)
  • fix "floating point evil" when computing values near zero (like cos(pi/2))
  • fix reusing results expressed in scientific notation
  • Use pi as an alias for pi.
  • Remove a ghostly "x" between the metas
  • Make the widget responsive
  • Use a true input, which allows to type 4*3+2,
    then select 3+2 and type or click a parenthese
    to have an expression that shows 4*(3+2)
  • Refactor into a javascript object
  • When computing, show the evaluated expression above the result
  • Fix non working buttons (atan, ...)

You know what it is : you make a little modification... then you spend the day on it :), but I think it should preferable to use an existing library

see https://github.com/topics/javascript-calculator

* Use a true input, which allows to type "4*3+2",
then select 3+2 and type or click a parentheses
to have an expression that shows "4*(3+2)"
* Refactor into a javascript object
* When computing, show the evaluated expression above the result
* Fix non working buttons (atan, ...)

That made my day :), but I think it should preferable to use an existing library

see https://github.com/topics/javascript-calculator
@beyluta
Copy link
Owner

beyluta commented Oct 30, 2023

I'd have no issues using a library for this. This widget came as a submission so it wasn't up to me but I probably would have used one too. I'm working on a "note" widget using a library too :)

image

@beyluta beyluta merged commit 2f2ea9e into beyluta:development Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants