Compare commits
2 Commits
1cef2d2d6a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a24142cd72 | |||
| 4df99d0738 |
+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
|
||||||
@@ -68,10 +66,10 @@ State exposed on instances:
|
|||||||
|
|
||||||
```js README.md
|
```js README.md
|
||||||
const calc = new RpnCalculator({
|
const calc = new RpnCalculator({
|
||||||
maxSize: 2048,
|
maxSize: 2048,
|
||||||
base: 10,
|
base: 10,
|
||||||
angleMode: 'deg',
|
angleMode: 'deg',
|
||||||
enabledCommands: ['add', 'sub', 'mul', 'div']
|
enabledCommands: ['add', 'sub', 'mul', 'div']
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -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(...)`:
|
||||||
@@ -194,10 +195,10 @@ console.log(calc.pop()); // 5
|
|||||||
```html README.md
|
```html README.md
|
||||||
<script src="./src/rpn-calculator.js"></script>
|
<script src="./src/rpn-calculator.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const calc = new RpnCalculator({ angleMode: 'deg' });
|
const calc = new RpnCalculator({ angleMode: 'deg' });
|
||||||
calc.push(9);
|
calc.push(9);
|
||||||
calc.command('sqrt');
|
calc.command('sqrt');
|
||||||
console.log(calc.pop());
|
console.log(calc.pop());
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user