intel / webapps-scientific-calculator

Apache License 2.0
27 stars 33 forks source link

the calculation is wrong after I press clear (AC) #17

Closed telvin closed 10 years ago

telvin commented 10 years ago

In the demo version https://01.org/html5webapps/online/scientific-calculator/, it works fine. But in the release version, some places are converted from javascript to jQuery syntax, there is bug.

Example: 1 + 2 = 3 [click clear AC] => 3 + 4 should = 7 Wrong: 1 + 2 =3 [click clear AC] => + 3 = malform syntax error

I fixed this line in calc.js $("#currentformula").html(Calculator.getMainEntry() + operator ); change it to $("#currentformula").html( $("#currentformula").html() + Calculator.getMainEntry() + operator );

Actually the old version is right, its here document.getElementById("currentformula").innerHTML += Calculator.getMainEntry(); document.getElementById("currentformula").innerHTML += operator;

davidmaxwaterman commented 10 years ago

Hi, thanks for spotting that. I suppose I could make the change myself, but it'd be easier if you could make a Pull Request so I can just quickly try it out before merging.

HageMaster3108 commented 10 years ago

As nobody else did it, I put it up as a pull request...