Compare commits
6 Commits
f8de4e1709
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a24142cd72 | |||
| 4df99d0738 | |||
| 1cef2d2d6a | |||
| 442a97d573 | |||
| 44ce67c5cc | |||
| a7411243de |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# State
|
# State
|
||||||
- Core engine: `src/rpn-calculator.js`
|
- Core engine: `src/rpn-calculator.js`
|
||||||
- Reference demo: `samples/calc-02/` (portrait-first HP48GX layout, compact mode/constants popups)
|
- Reference demo: `samples/calc-02/` (portrait-first HP48GX layout, compact mode/constants popups; Const button comes before Mode in the display row)
|
||||||
- Important UI behavior: mode button shows the current angle mode; keyboard focus stays on the hidden input on desktop; clipboard paste is supported
|
- Important UI behavior: mode button shows the current angle mode; keyboard focus stays on the hidden input on desktop; clipboard paste is supported
|
||||||
- Public API: `push`, `pop`, `clear`, `swap`, `remove`, `edit`, `isValidIndex`, `input`, `command`, `getOperationsByCategory`, `getConstants`, `listConstants`, `setConstant`, `removeConstant`, `hasConstant`
|
- Public API: `push`, `pop`, `clear`, `swap`, `remove`, `edit`, `isValidIndex`, `input`, `command`, `getOperationsByCategory`, `getConstants`, `listConstants`, `setConstant`, `removeConstant`, `hasConstant`
|
||||||
- Config: `maxSize`, `base`, `angleMode`, `enabledCommands`
|
- Config: `maxSize`, `base`, `angleMode`, `enabledCommands`
|
||||||
|
|||||||
+3
-4
@@ -1,9 +1,8 @@
|
|||||||
# State
|
# State
|
||||||
- Core engine: `src/rpn-calculator.js`
|
- Core engine: `src/rpn-calculator.js`
|
||||||
- Active demo: `samples/calc-02/` portrait-only HP48GX layout; display-adjacent button row stays in 4 columns and now shares the same base button styling as the function keys
|
- Default demo: `samples/dev/` classic browser demo; `samples/calc-02/` remains the portrait-first HP48GX-inspired reference
|
||||||
- Mode button shows the current angle mode only; selecting a mode uses a popup menu
|
|
||||||
- Public API: `push`, `pop`, `clear`, `swap`, `remove`, `edit`, `isValidIndex`, `input`, `command`, `getOperationsByCategory`, `getConstants`, `listConstants`, `setConstant`, `removeConstant`, `hasConstant`
|
- Public API: `push`, `pop`, `clear`, `swap`, `remove`, `edit`, `isValidIndex`, `input`, `command`, `getOperationsByCategory`, `getConstants`, `listConstants`, `setConstant`, `removeConstant`, `hasConstant`
|
||||||
- Config: `maxSize`, `base`, `angleMode`, `enabledCommands`
|
- Config: `maxSize`, `base`, `angleMode`, `enabledCommands`
|
||||||
- Commands: arithmetic, stack, trigonometry, constants `pi`, `e`, `phi`, `g`, and `c`; arithmetic now includes `root` for y-th roots; constants can now be added or removed dynamically through the core API
|
- Commands: arithmetic, stack, trigonometry, constants `pi`, `e`, `phi`, `g`, and `c`; arithmetic includes `root` with `y√x`, `yroot`, and `nroot` aliases; constants can be added or removed dynamically through the core API
|
||||||
- Demo actions: keyboard focus is kept on the hidden input on desktop so typing keeps working; the keypad layout places Enter in the bottom-left, ± in the former Enter position, and Esc before Clear for safety; paste parses clipboard text as a number before pushing it to the stack; Ctrl+V is supported via the hidden input paste event; backspace is ignored when the stack is empty; operation errors are shown as an overlay bar on top of the calculator with a shorter timeout and darker red; the display button row uses a 4-column grid with a spacer cell to preserve alignment
|
- Demo behavior: `samples/dev/` keeps hidden input focus on desktop and supports clipboard paste; `samples/calc-02/` uses compact mode/constants popups, a 4-column display-adjacent row, stack selection/move mode, and paste through the hidden input
|
||||||
- Exports: browser `window.RpnCalculator`, CommonJS `module.exports`
|
- Exports: browser `window.RpnCalculator`, CommonJS `module.exports`
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
# RPN Virtual Calculator
|
# RPN Virtual Calculator
|
||||||
|
|
||||||
A browser-friendly RPN calculator built around a small, generic JavaScript API.
|
A browser-friendly RPN calculator built around a small JavaScript API.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
This project provides:
|
This project provides:
|
||||||
|
|
||||||
- a reusable JavaScript RPN engine in `src/rpn-calculator.js`
|
- a reusable JavaScript RPN engine in `src/rpn-calculator.js`
|
||||||
- browser demos in `samples/dev/` and `samples/calc-02/`
|
- a classic browser demo in `samples/dev/`
|
||||||
- a command system centralized in a single operation dictionary
|
- a portrait-first HP48GX-inspired demo in `samples/calc-02/`
|
||||||
- a small public API focused on stack operations and generic command dispatch
|
- a centralized command system with aliases
|
||||||
|
- a compact public API focused on stack operations, editing, and command dispatch
|
||||||
|
|
||||||
The main class is `RpnCalculator`.
|
The main class is `RpnCalculator`.
|
||||||
|
|
||||||
@@ -19,9 +20,6 @@ The main class is `RpnCalculator`.
|
|||||||
- `samples/dev/index.html`: browser demo entry point
|
- `samples/dev/index.html`: browser demo entry point
|
||||||
- `samples/dev/index.css`: demo styles
|
- `samples/dev/index.css`: demo styles
|
||||||
- `samples/dev/index.js`: demo UI and keyboard logic
|
- `samples/dev/index.js`: demo UI and keyboard logic
|
||||||
- `samples/calc-01/index.html`: active browser demo entry point
|
|
||||||
- `samples/calc-01/index.css`: demo styles
|
|
||||||
- `samples/calc-01/index.js`: demo UI and keyboard logic
|
|
||||||
- `samples/calc-02/index.html`: portrait-first HP48GX-style demo entry point
|
- `samples/calc-02/index.html`: portrait-first HP48GX-style demo entry point
|
||||||
- `samples/calc-02/index.css`: portrait-first demo styles
|
- `samples/calc-02/index.css`: portrait-first demo styles
|
||||||
- `samples/calc-02/index.js`: portrait-first HP48GX-style demo UI and keyboard logic
|
- `samples/calc-02/index.js`: portrait-first HP48GX-style demo UI and keyboard logic
|
||||||
@@ -88,6 +86,9 @@ Available constants:
|
|||||||
|
|
||||||
- `pi`
|
- `pi`
|
||||||
- `e`
|
- `e`
|
||||||
|
- `phi`
|
||||||
|
- `g`
|
||||||
|
- `c`
|
||||||
- plus any user-defined constants added through the engine API
|
- plus any user-defined constants added through the engine API
|
||||||
|
|
||||||
They can be used through `command(...)`:
|
They can be used through `command(...)`:
|
||||||
@@ -239,7 +240,7 @@ console.log(calc.pop()); // 0.5
|
|||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
The active demo lives in `samples/dev/`.
|
The default demo lives in `samples/dev/`.
|
||||||
|
|
||||||
Main UI features:
|
Main UI features:
|
||||||
|
|
||||||
@@ -249,7 +250,7 @@ Main UI features:
|
|||||||
- angle mode selector for `deg`, `rad`, and `grad`
|
- angle mode selector for `deg`, `rad`, and `grad`
|
||||||
- status pills for `inputValue` and `isEditing`
|
- status pills for `inputValue` and `isEditing`
|
||||||
- grouped panels for `Stack`, `Arithmetic`, `Trigonometry`, and `Constants`
|
- grouped panels for `Stack`, `Arithmetic`, `Trigonometry`, and `Constants`
|
||||||
- error display area
|
- keyboard-friendly hidden input on desktop
|
||||||
|
|
||||||
## Calc 02 demo
|
## Calc 02 demo
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
<div class="display-buttons-panel">
|
<div class="display-buttons-panel">
|
||||||
<div class="display-buttons-grid">
|
<div class="display-buttons-grid">
|
||||||
<button id="modeButton" class="display-button">Mode</button>
|
|
||||||
<button id="constButton" class="display-button">π</button>
|
<button id="constButton" class="display-button">π</button>
|
||||||
<button id="upButton" class="display-button"><span class="display-button-symbol arrow-symbol">↑</span></button>
|
|
||||||
<div class="display-button-spacer"></div>
|
|
||||||
<button id="pasteButton" class="display-button"><span class="display-button-symbol paste-symbol">⎘</span></button>
|
<button id="pasteButton" class="display-button"><span class="display-button-symbol paste-symbol">⎘</span></button>
|
||||||
|
<button id="upButton" class="display-button"><span class="display-button-symbol arrow-symbol">↑</span></button>
|
||||||
|
<button id="modeButton" class="display-button">Mode</button>
|
||||||
|
<div class="display-button-spacer"></div>
|
||||||
<button id="leftButton" class="display-button display-button-offset"><span class="display-button-symbol arrow-symbol">←</span></button>
|
<button id="leftButton" class="display-button display-button-offset"><span class="display-button-symbol arrow-symbol">←</span></button>
|
||||||
<button id="downButton" class="display-button"><span class="display-button-symbol arrow-symbol">↓</span></button>
|
<button id="downButton" class="display-button"><span class="display-button-symbol arrow-symbol">↓</span></button>
|
||||||
<button id="rightButton" class="display-button"><span class="display-button-symbol arrow-symbol">→</span></button>
|
<button id="rightButton" class="display-button"><span class="display-button-symbol arrow-symbol">→</span></button>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
```
|
```
|
||||||
┌──────── Display Buttons ────────┐
|
┌──────── Display Buttons ────────┐
|
||||||
| Mode | Paste | Up | Const |
|
| Const | Paste | Up | Mode |
|
||||||
| | Left | Down | Right |
|
| | Left | Down | Right |
|
||||||
└─────────────────────────────────┘
|
└─────────────────────────────────┘
|
||||||
```
|
```
|
||||||
@@ -23,30 +23,30 @@
|
|||||||
## Keypad
|
## Keypad
|
||||||
|
|
||||||
```
|
```
|
||||||
┌───────────── Keypad ──────────────┐
|
┌──────────── Keypad ─────────────┐
|
||||||
| +/- | Clear | Esc | backspace |
|
| +/- | Clear | Esc | backspace |
|
||||||
| 7 | 8 | 9 | / |
|
| 7 | 8 | 9 | / |
|
||||||
| 4 | 5 | 6 | * |
|
| 4 | 5 | 6 | * |
|
||||||
| 1 | 2 | 3 | - |
|
| 1 | 2 | 3 | - |
|
||||||
| 0 | . | Enter | + |
|
| 0 | . | Enter | + |
|
||||||
└───────────────────────────────────┘
|
└─────────────────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
```
|
```
|
||||||
┌──────────── Functions ────────────┐
|
┌──────────── Functions ──────────┐
|
||||||
| x^2 | y^x | 1/x | % |
|
| x^2 | y^x | 1/x | % |
|
||||||
| √x | y√x | 10^x | |
|
| √x | y√x | 10^x | |
|
||||||
| log | ln | | |
|
| log | ln | | |
|
||||||
└───────────────────────────────────┘
|
└─────────────────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
## Trigo
|
## Trigo
|
||||||
|
|
||||||
```
|
```
|
||||||
┌───────────── Trigo ───────────────┐
|
┌──────────── Trigo ──────────────┐
|
||||||
| sin | cos | tan | |
|
| sin | cos | tan | |
|
||||||
| asin | acos | atan | |
|
| asin | acos | atan | |
|
||||||
└───────────────────────────────────┘
|
└─────────────────────────────────┘
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user