-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
103 lines (94 loc) · 6.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quick MathJS Web Calculator</title>
<link rel="icon" type="image/x-icon" href="logo.ico">
<meta property="og:title" content="Quick MathJS Web Calculator">
<meta property="og:description" content="An intuitive web-based plaintext calculator using math.js. Features inline results and supports free-form calculations.">
<meta property="og:image" content="./logo.png">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="calculator">
<textarea id="input" placeholder="Enter math expressions... (Example: '1 + 1 = ?' or 'a = 3' then 'a + 1 = ?')" spellcheck="false" onkeydown="handleKeyDown(event)"></textarea>
</div>
<div class="bottom-bar">
<div class="bottom-row">
<span id="title" >Quick MathsJS Web Calc</span>
<div class="actions"> <!-- This is a new container for padControls and mobileOperatorKeypad -->
<div class="padControls">
<button onclick="clearpad()">CLEAR</button>
<button onclick="triggerRecalc()">RECALC</button>
</div>
<div class="mobileOperatorKeypad">
<!-- These operators can take more than one shift button clicks in android keyboard to reach -->
<button onclick="insertText('^')">^</button>
<button onclick="insertText('%')">%</button>
<button onclick="insertText('=')">=</button>
</div>
</div>
</div>
<!-- Quick Start Section -->
<details class="quickstart">
<summary>Show Quick Start</summary>
<div id="quickstartDetails">
<h2>Quick Start</h2>
<strong>Example: Given this input</strong>:
<pre>
# Basic Expressions with Direct Calculation
1 + 1 = ?
= ?
# Variable Assignment with Explicit Value Retrieval
a = 3
a: ?
# Simultaneous Assignment And Results
c = a + 3 = ?
# 2> spaces as alt method for Explicit Value Retrieval
c = ?</pre>
<strong>After calculation, you will get this output</strong>:
<pre>
# Basic Expressions with Direct Calculation
1 + 1 = 2
= 2
# Variable Assignment with Explicit Value Retrieval
a = 3
a: 3
# Simultaneous Assignment And Results
c = a + 3 = 6
# 2> spaces as alt method for Explicit Value Retrieval
c = 6</pre>
<ol>
<li>Open the calculator by simply loading this webpage in your preferred web browser.</li>
<li>Type mathematical expressions in the provided textarea.</li>
<li>To assign a value to a variable, use the format: <code>a = 5</code>.</li>
<li>To evaluate an expression, write it and then append with <code>=</code>. For example: <code>a * 2 =</code>. The result will automatically be displayed next to the expression.</li>
<li>For multi-variable assignments or expressions with provided results, use the format: <code>a = b = 2 + 3 =</code>.</li>
<li>For explicit output add 2 spaces or more before a variable <code>=</code>.</li>
<li><code>=</code> by itself will imply displaying results from previous calcuation.</li>
<li>Errors, such as division by zero or undefined variables, will be indicated next to the problematic expression. For example: <code>1 / 0 = Error: Division by zero</code>.</li>
<li>English sentences can be supported as variable names as long as it does not conflict with MathJS reserved keywords like `in`, `i`, `or` and any other reserved keywords. e.g. 'People Count' can be a variable</li>
</li>
<li>To save your calculations, simply copy the URL which now contains your compressed data.</li>
<li>To load previously saved calculations, paste the copied URL into your browser.</li>
</ol>
<p><a href="#H4sIAAAAAAAAA3VVbW/bNhD+rl9xQzFMXl1F7y8b+kG1ncSD42S23CEIUkCWGJuIJKokFdv/fkfKztwmMyJGIu+ee8i7e/gB/u5o8XyTy634awn/kPUorwpYCcLhqqMlMYwPkG2pAFFw2spPQh4qAhu1BCWpWSMkzyURsGU7kAw6QeAl55R1AmpEJTjQIq+AtQQNKTpA3pTwRHLZcfSjzbsULFCRv6TL6QjSxTS7vplk+Hp7N1mk2fR2vlTLaVlSBWkE8BE8+Ayxml12a+RU6IUIPoGPC55auOkqSdsK6ei1EH7XTo72GtMXKtR0DBfg4rSvZu/YjnDDg28aJXY0DCu7CrdnLnBztCnxqPInieMJYmA4NvzaY2ua46/p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Bj/8bKmUt+1QssTRwLDXDnaAagLdClqKjr11YoUbPBqvUZVPgdaO8lLPv5C8Q6/7BwAA" target="_blank">Click To Load Example</a></p>
<p>For a comprehensive guide, more detailed instructions and source code, <a href="https://github.com/mofosyne/QuickMathJS" target="_blank">check out the full README</a>. Additionally, for details on supported mathematical syntax and operations, <a href="https://mathjs.org/docs/expressions/syntax.html" target="_blank">refer to the math.js documentation</a>.</p>
<p>For developers, there is an NPM package located <a href="https://www.npmjs.com/package/quickmathjs" target="_blank">QuickMathJS NPM Package</a></a> so you can integrate this in your projects like a text editor extention.</p>
<p><a href="https://www.quickmathjs.com/" target="_blank">quickmathjs.com</a>. Copyright © 2023 Brian Khuu • powered by <a href="https://mathjs.org/" target="_blank">math.js</a>.</p>
</details>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/13.1.1/math.min.js"></script>
<!-- Local math.js fallback if above link fails to load-->
<script>
if (typeof math === 'undefined') {
var script = document.createElement('script');
script.src = 'math.min.js';
document.body.appendChild(script);
}
</script>
<script src="calculator.js"></script>
<script src="script.js"></script>
</body>
</html>