Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <div class='Row1'>
  2. <button class="clear" id="allClear">AC</button>
  3. <button id="plus-minus">+/-</button>
  4. <button class="operators" id="decimal">.</button>
  5. <button class="operators divide">&divide;</button>
  6. </div>
  7. </td>
  8. </tr>
  9. <!-- new line -->
  10. <tr>
  11. <td>
  12. <div class "row2">
  13. <button class="num-button seven">7</button>
  14. <button class="num-button eight">8</button>
  15. <button class="num-button nine">9</button>
  16. <button class="operators multiply">x</button>
  17. </div>
  18. </td>
  19. </tr>
  20.  
  21. $('.operators').click(function(){
  22. if(check()) {
  23. $('.display').val('ERR');
  24. } else {
  25. var displayVal = $('.display').val();
  26. operator = $(this).text();
  27. var showOpp = displayVal + operator;
  28. $('.display').val(showOpp);
  29. }
  30. });
  31.  
  32. /*
  33. * Takes display value as a string and does calculation
  34. */
  35. $('#equal').click(function() {
  36. var calculation = $('.display').val();
  37. var operatorIndex = calculation.indexOf(operator);
  38. var value1 = parseFloat(calculation.slice(0,operatorIndex));
  39. var value2 = parseFloat(calculation.slice(operatorIndex+1));
  40. console.log(value1);
  41. console.log(value2);
  42. var operation = '';
  43. switch(operator) {
  44. case '÷':
  45. operation = divide(value1,value2);
  46. break;
  47. case 'x':
  48. operation = multiply(value1,value2);
  49. break;
  50. case '+':
  51. operation = add(value1,value2);
  52. break;
  53. case '-':
  54. operation = sub(value1,value2);
  55. break;
  56. }
  57. $(".display").val(operation);
  58.  
  59. })
  60.  
  61. $('#decimal').click(funciton(){
  62.  
  63.  
  64. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement