Skip to content
operational 4.21 KiB
Newer Older
Yuanle Song's avatar
Yuanle Song committed
* COMMENT -*- mode: org -*-
#+Date: 2017-01-26
Time-stamp: <2017-01-26>
#+STARTUP: content
* notes                                                               :entry:
* later                                                               :entry:
** 2017-01-26 make the whole thing a polymer web component
<rpn-calculator trail="true"></rpn-calculator>

User can also set height and width on the element, which will resize the
elements inside. When there is no room, show a scrollbar.

shadow dom should make all HTML/CSS/Javascript work together without affecting
the parent DOM.

Yuanle Song's avatar
Yuanle Song committed
* current                                                             :entry:
** 
** 2017-01-26 design data structure for the calculator.
- this can be written and tested independently from the web UI.
- basic data:
  - stack of numbers.
  - current state and data in finite state machine (fsm).
  - data for undo. I think I can just take a snapshot of the fsm.

- how many states are there?

  init state is "waiting for number".

  | this state                   | event                     | next state                                       |
  |------------------------------+---------------------------+--------------------------------------------------|
  | waiting                      | press num keys or dot key | modify number, then waiting for number or action |
  | waiting for number or action | press num keys or dot key | modify number, then waiting for number or action |
  | waiting for number or action | press return key          | commit number, then waiting                      |
  | waiting for number or action | press +-*/                | commit number, do op, then waiting               |
  | waiting for number or action | press < key               | modify number, then waiting for number or action |

  There is no "ending state", the machine can always accept new keyboard events.

- a few display and error handling.

  - when number is "0", press more num0 will just show error and not modify the number.

  - when number is "", press dot will change number to "0."

  - when number already has a dot in it, future dot will just show error and
    not modify the number.

** 2017-01-26 make basic number input and arithmetic work
- DONE make event work.
  - TODO add some visual feedback when clicking a button. like in material design.
- design data structure for the calculator.
- add unit test for the data structure and functions.
- make number input and simple calculation work.

Yuanle Song's avatar
Yuanle Song committed
** 2017-01-26 make trail persistent
trail is a sized fifo queue, it just store recent 1k entries.
when multiple instances of calculator is working. they all write to a single
trail cache. it's not a problem.

** 2017-01-26 make it work offline, add sw.js
** 2017-01-26 make undo work
** 2017-01-26 make stack auto numbering work
** 2017-01-26 make < (backspace) work.
** 2017-01-26 make basic things work.
- DONE draw the keyboard using HTML and CSS
Yuanle Song's avatar
Yuanle Song committed
- make basic number input and arithmetic work
- make DUP and SWP work
- make trail work
* done                                                                :entry:
** 2017-01-26 how to write a fsm simulator in javascript.
- try write an easier example before writing the real thing.
- easy example:
  check whether a string has substring "abb".

  states:
  | this state       | event                 | next state                                                                                    |
  |------------------+-----------------------+-----------------------------------------------------------------------------------------------|
  | wait for "a"     | read new character ch | if ch is "a", wait for 1st "b"; otherwise, wait for "a"                                       |
  | wait for 1st "b" | read new character ch | if ch is "b" => wait for 2nd "b"; if ch is "a" => wait for 1st "b"; otherwise => wait for "a" |
  | wait for 2nd "b" | read new character ch | if ch is "b" => succeed; if ch is "a" => wait for 1st "b"; otherwise => wait for "a"          |
  | succeed          | ∅                     | ∅                                                                                             |

- it works.

** 2017-01-26 draw the keyboard using HTML and CSS
Yuanle Song's avatar
Yuanle Song committed
* wontfix                                                             :entry: