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

Rewrite Calculator code and moved code to separate js file to make it easier to deal with in VSCode #584

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michmela44
Copy link
Contributor

No description provided.

@V1EngineeringInc
Copy link
Owner

Okay, so far so good. I need to study it a bit more. I can follow it, just not sure I can edit it when the time comes for a new machine if you are not around.

I need to poke at it some more.

The first day I messed with it I got a little lost, today it makes much more sense.

Thank you thank you, I am excited to learn a bit more about it. The comments are a great help I just need to figure out the workflow a bit more I think.

@V1EngineeringInc
Copy link
Owner

Honestly, I think if I just go for it, I will be forced to learn it.

@michmela44
Copy link
Contributor Author

The function of it hasn't really changed much.

It's still all driven by the input controls defined in the markdown.

The only real difference is how it gets the values.

Previously, the flow would work like this....

  • User makes change to input.
  • onkeyup="from_working()" causes the javascript function from_working() to fire
  • from_working() would then do the following
    • Call function to retrieve offsets object
    • Pull values from input controls
    • Calculate values from inputs and offsets
    • Round values and set them into the calculator area

This had some drawbacks in that you couldn't round-trip through the units, and the rounding in from_working() had issues which caused the 2mm cushion to sometimes apply, and sometimes not since it did a true round which could go up or down

The new calculator doesn't rely on the input value in the box except for when it changes.

The flow is now like this:

  • User makes change to input, which calls a specific method from each input i.e. oninput="xwork_changed()"
  • Input gets normalized to metric values without rounding, and stored in a global variable
  • calculate(), which is the renamed version of from_working(), gets called to update the calculator section
  • calculate() does the following
    • Calculate values from inputs and offsets using the global variables as they were last updated, and using the offsets static structure defined at the top of the file.
    • Round values and set them into the calculator area. This chooses round up or down in specific scenarios to ensure the cushion is always properly applied for the X Rails

Hope this helps a little.

Feel free to ask about anything specific if you want some more clarity

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