Monday, November 25, 2013

Calculated Risk

Calculated Risk

After trying to think of what to code for a quick review, I landed on a calculator. It'll be simple, but it will help me bring together several things I've been having trouble with. 

Idea:
A Rails calculator app with Ajax, JS, JSON, etc. For fun I'll use bootstrap to make it look nicer.

This isn't going to make much sense, but it's kinda my notes. Maybe at some point I'll clear this up at some point ...

<div class="container">
  <button data-num: 2> </button>
</div>


$(".container").on("click", "button", function() {
  $(this).data("num");
});

Is this going to get what I want it to?


Thought process for making this:

1. A user "clicks" a button
    for num1

2. A user "clicks" a button
    for operation
        a. num1 stored in an array
        b. operation stored
        c. clear input

3. A user "clicks" a button
    for num2

4. "clicks" "="
    a. num2 stored in array
    b. $submit => AJAX

5. wait for "done" event
    a. display answer

Wow, a lot for what seems to be a simple calculator!

EDIT:
2. a. add the selected operation to the input[operation] input field
    b. I have to switch currentInput to input[num2]

No comments:

Post a Comment