|
|
Not a trivial fix + it's not a calculator, it's an adding machine
So to everyone that's whining about this, the way it behaves right now it it NOT a calculator, it's an 'adding machine', plain and simple. For everyone comparing it to $5 calculators .. they are not calculators either then, they are also adding machines. The cost of the calculator should not determine whether it obeys the laws of mathematics or not.
So here's their methods for doing the actual work, and as you can see it's not a trivial fix to make it work properly LOL
They need to rewrite a big piece of it (while they are at it they should just replace the whole thing, it's pretty messy). They should be keeping a running 'equation' in the process and not just blindly doing what they are doing above. To work like a real calculator it should evaluate this running equation at each step and report this back to the output display ... It's not rocket science (or is it? this thread makes me wonder LOL). Let's just say that whoever wrote this 'calculator' widget wouldn't make it onto my development team, paid or not!
Not a trivial fix + it's not a calculator, it's an adding machine
incidentally is it just me, or is dashboard/widget combo just a security breach waiting to happen? And I don't mean just in the malicious widget front ... I mean you are getting a lot of access here, and for some reason I suspect that there are many things that a crafty coder can take advantage of here . . .
Yes it is a trivial fix
Yes, it's a trivial fix.
I wrote this after work last night. Here you go. It works both ways and has a persistant preference to let you pick which you want. The reason it's a trivial fix is the same reason that pasting "1+2*3" calculates properly. The basic resolver is eval(display). As long as you build a string, it can resolve it.
Yes it is a trivial fix
"Trivial fix" and "Easy Fix" are 2 different things ... it was an "easy fix" because you did it correctly by keeping a running tally of the equation. I don't consider a 400 line diff trivial considering it was a 540 line javascript to start with ;) hehe .. it's all relative!
OK, it's an easy fix
Yeah, well. Calculator.js was as small as it was before because it didn't have an info button and backside and those require a lot of new functions to be copied and pasted from the documentation.
More on why it's a trivial fix
The key here isn't to change the add/sub/mult/div methods, but to intercept the keydown and add it to the display string.
This is how I handled the add key in the variant I posted. deferredEvaluation is a variable I set at startup to tell me which file to process. OpList is a list of operators that can't be entered twice (no "9++4"). The final "else" is the prior "case add" code to call function add if deferredEvaluation is false. It took me more time to work through making and saving a preference, a back, flipping the app, etc., than it did to update the JavaScript.
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.10 seconds |
|