54f427ea217e00471d140f17ce8192329efba37c
Some checks failed
Deploy to GitHub Pages / build-and-deploy (push) Has been cancelled
Geek Calculator
A single-file, offline-capable calculator with a terminal-like interface. Features basic arithmetic operations, RPN mode, keyboard-first operation, and a "geek vibe" aesthetic.
Features
- Basic arithmetic operations (+, -, ×, ÷)
- Parentheses support for complex expressions
- Percentage calculations
- Positive/negative toggle (±)
- RPN (Reverse Polish Notation) mode
- Full keyboard operation
- Command palette (access with @ key)
- Calculation history with re-run capability
- Terminal-themed UI with ASCII banner
- Full offline capability
- Keyboard accessibility (ARIA roles, focus indicators)
Usage
Basic Operations
- Click buttons or use keyboard:
+,-,*,/,= - Use
Enterto evaluate expressions - Use
Escapeto clear current input - Use
Backspaceto delete last character
RPN Mode
- Toggle RPN mode with the RPN button
- Enter numbers followed by operators
- Example: To calculate
4 + 6, enter:4 ENTER 6 +
Keyboard Controls
- Numbers:
0-9 - Operators:
+,-,*,/ - Equals:
Enteror= - Clear:
EscapeorC - Decimal:
. - Backspace:
Backspace - RPN Enter:
Enter(in RPN mode) - Toggle RPN:
R - Command Palette:
@ - History Navigation:
↑and↓ - Help:
?
Command Palette
- Press
@to open the command palette - Type commands like "clear", "history", "theme", etc.
Offline Capability
The calculator works completely offline. The first time you load it, it will cache all necessary files using a service worker.
Technical Details
- Pure HTML/CSS/JavaScript (no external dependencies)
- Total payload < 50KB
- Uses ES6 modules for code organization
- Service worker for offline functionality
- LocalStorage for calculation history
- Accessible with full keyboard navigation and ARIA roles
Development
To run tests:
- Open
tests/index.htmlin your browser - Tests will run automatically
Architecture
calculator.js: Core calculator logicrpn-calculator.js: RPN calculator implementationui.js: User interface interactionsstate.js: Application state managementutils.js: Utility functionsstyles.css: All styling (dark theme, ASCII art, responsive)service-worker.js: Offline functionalitymanifest.webmanifest: PWA features
Size Budget
The entire application is designed to stay under 50KB total payload.
Description
Languages
JavaScript
55.2%
Shell
37.8%
HTML
7%