An open API service indexing awesome lists of open source software.

https://github.com/binghuan/calculator

This is a simple calculator app
https://github.com/binghuan/calculator

javascript webapp

Last synced: about 2 months ago
JSON representation

This is a simple calculator app

Awesome Lists containing this project

README

          

# Calculator

## Overview

A simple, responsive web-based calculator application with offline capabilities. This mobile-friendly calculator provides basic arithmetic operations and can be used without an internet connection after the initial load.

## ๐ŸŒ Live Demo

- **Web App**: [http://binghuan.github.io/calculator/](http://binghuan.github.io/calculator/)
- **Blog Post**: [http://studiobinghuan.blogspot.tw/2013/05/calculator.html?view=flipcard](http://studiobinghuan.blogspot.tw/2013/05/calculator.html?view=flipcard)

## โœจ Features

- **Basic Arithmetic Operations**: Addition (+), Subtraction (-), Multiplication (*), Division (/)
- **Offline Functionality**: Works without internet connection using Application Cache
- **Mobile Optimized**: Responsive design using jQuery Mobile framework
- **Touch-Friendly Interface**: Large buttons optimized for mobile devices
- **Clear Function**: Reset calculator with the "C" button
- **Real-time Display**: Shows calculations as you type
- **Progressive Web App**: Can be added to home screen on mobile devices

## ๐Ÿ› ๏ธ Technology Stack

- **HTML5**: Structure and semantic markup with offline manifest
- **CSS3**: Styling with jQuery Mobile theme
- **JavaScript**: Calculator logic and event handling
- **jQuery 1.10.1**: DOM manipulation and event handling
- **jQuery Mobile 1.3.1**: Mobile UI framework for responsive design
- **Application Cache**: Enables offline functionality

## ๐Ÿ“ฑ Supported Operations

| Operation | Symbol | Button |
|-----------|--------|--------|
| Addition | + | + |
| Subtraction | - | - |
| Multiplication | * | * |
| Division | / | / |
| Equals | = | = |
| Clear | C | C |
| Numbers | 0-9 | 0-9 |

## ๐Ÿš€ How to Use

1. **Online**: Visit [the live demo](http://binghuan.github.io/calculator/)
2. **Offline**: After first visit, the app will work without internet connection
3. **Mobile**: Add to home screen for app-like experience

### Calculator Instructions:
1. Tap number buttons to input values
2. Tap operation buttons (+, -, *, /) to perform calculations
3. Tap "=" to see the result
4. Tap "C" to clear and start over
5. Calculations are performed left-to-right as you input operations

## ๐Ÿ“ Project Structure

```
calculator/
โ”œโ”€โ”€ index.html # Main HTML file
โ”œโ”€โ”€ calculator.js # Calculator logic and event handlers
โ”œโ”€โ”€ calculator.css # Custom styles
โ”œโ”€โ”€ calculator.appcache # Offline cache manifest
โ”œโ”€โ”€ jquery-1.10.1.min.js # jQuery library
โ”œโ”€โ”€ jquery.mobile-1.3.1.min.js # jQuery Mobile JavaScript
โ”œโ”€โ”€ jquery.mobile-1.3.1.min.css # jQuery Mobile CSS
โ”œโ”€โ”€ Icon.png # App icon
โ”œโ”€โ”€ README.md # This file
โ”œโ”€โ”€ icons/ # Various app icon sizes
โ”‚ โ”œโ”€โ”€ Icon-16.png
โ”‚ โ”œโ”€โ”€ Icon-32.png
โ”‚ โ”œโ”€โ”€ Icon-48.png
โ”‚ โ””โ”€โ”€ ... (various sizes for different devices)
โ””โ”€โ”€ images/ # UI assets
โ”œโ”€โ”€ ajax-loader.gif
โ”œโ”€โ”€ calculator_icon.png
โ””โ”€โ”€ ... (jQuery Mobile icons)
```

## ๐Ÿ”ง Installation & Development

### Local Development:
1. Clone the repository:
```bash
git clone https://github.com/binghuan/calculator.git
cd calculator
```

2. Open `index.html` in a web browser or serve it using a local web server:
```bash
# Using Python 3
python -m http.server 8000

# Using Python 2
python -m SimpleHTTPServer 8000

# Using Node.js (if you have http-server installed)
npx http-server
```

3. Navigate to `http://localhost:8000` in your browser

### Deployment:
The app is configured for GitHub Pages deployment. Simply push to the `gh-pages` branch to update the live version.

## ๐ŸŒ Browser Compatibility

- **Mobile Browsers**: iOS Safari, Android Chrome, Mobile Firefox
- **Desktop Browsers**: Chrome, Firefox, Safari, Edge
- **Offline Support**: All modern browsers with Application Cache support

## ๐ŸŽฏ Key Implementation Details

- **State Management**: Uses JavaScript variables to track current value, last operator, and calculation state
- **Event Handling**: jQuery event listeners for all button interactions
- **Calculation Logic**: Handles operator precedence and chained calculations
- **Offline Cache**: Application Cache manifest ensures all resources are cached for offline use
- **Mobile Optimization**: Viewport meta tags and jQuery Mobile for touch-friendly interface

## ๐Ÿ“ Future Enhancements

- [ ] Add decimal point support
- [ ] Implement memory functions (M+, M-, MR, MC)
- [ ] Add scientific calculator functions
- [ ] Implement keyboard support
- [ ] Add calculation history
- [ ] Migrate from deprecated Application Cache to Service Workers

## ๐Ÿ‘จโ€๐Ÿ’ป About

This is my second web application, created to demonstrate offline web app capabilities and mobile-first design principles. The primary focus was on creating a functional calculator that works seamlessly without an internet connection.

**Powered by BH_Lin**

---

### ไธญๆ–‡่ชชๆ˜Ž

้€™ๆ˜ฏๆˆ‘็š„็ฌฌไบŒๅ€‹็ถฒ้ ๆ‡‰็”จ็จ‹ๅผใ€‚ๆœฌ็จ‹ๅผ็š„็‰นๆ€งๆ˜ฏ๏ผŒไฝฟ็”จ่€…ๅฏไปฅๅœจ้›ข็ทš็š„็’ฐๅขƒไธ‹๏ผŒไพ็„ถๅฏไปฅไฝฟ็”จๆœฌ็ถฒ้ ๆ‡‰็”จ็จ‹ๅผใ€‚้€™ๅ€‹็ฐกๅ–ฎ็š„่จˆ็ฎ—ๆฉŸๆ‡‰็”จ็จ‹ๅผๆ”ฏๆดๅŸบๆœฌ็š„ๆ•ธๅญธ้‹็ฎ—๏ผŒไธฆไธ”้‡ๅฐ่กŒๅ‹•่ฃ็ฝฎ้€ฒ่กŒไบ†ๆœ€ไฝณๅŒ–ใ€‚