-
Notifications
You must be signed in to change notification settings - Fork 0
/
acal.html
253 lines (245 loc) · 10.8 KB
/
acal.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>🖩 Aculator</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
*{
font-family: monospace;
}
</style>
</head>
<body class="bg-light">
<div class="container">
<div class="row vh-100">
<div class="col-12 col-md-8 col-lg-6 border-dark mx-auto text-center my-auto">
<div class="card">
<h5 class="card-header">
<i class="fa-solid fa-calculator"></i>
Aculator
<span class="badge bg-secondary" style="font-size:10px;">v1.0.0</span>
</h5>
<div class="card-body border-bottom">
<div class="container px-4">
<div class="row align-items-center gx-5">
<input onchange="autof()" oninput= "this.onchange();" id="input" type="text" style="text-align:right;" class="col form-control mx-sm-2 mx-sm-3 mb-1 mt-1 mb-sm-1" placeholder="enter something">
<button onclick="allClear()" class="col-sm-auto mx-0 col-12 btn bg-light mx-sm-2 mx-sm-3 btn-danger text-dark mt-1 mb-1 border">
<i class="fa-solid fa-trash"></i>
</button>
</div>
</div>
</div>
<!-- automatic calculation result area -->
<div id="check" class="card-body border-bottom d-flex align-items-center justify-content-center d-none">
<p id="para" class="m-0">don hu me yaar</p>
</div>
<div class="card-body">
<!-- row-1 -->
<div class="container text-center">
<div class="row">
<div class="col-6">
<button class="btn bg-light w-100 mb-2 border d-flex align-items-center text-center justify-content-center">
<input onchange="chtogg2()" id="mycheck" class="auto-cal" type="checkbox" value="" aria-label="Checkbox for auto calculation">
<span onclick="chtogg()" class="d-inline-block mx-sm-4 mx-1 text-truncate">automatic</span>
</button>
</div>
<div class="col">
<button onclick="deleteFromBack()" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-arrow-left-long"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('/')" class="btn bg-light btn-light w-100 mb-2 border">
<!-- forward slash icon in svg format -->
<svg width="16px" height="16px" viewBox="0 0 16 16" class="bi bi-slash" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path
d="M 8.2465392,0.54071348 C 8.0173805,0.59731787 7.8069368,0.68459876 7.6420744,0.79157359 7.4769354,0.89861445 7.3651458,1.020336 7.3206829,1.1411975 L 2.9994408,11.715647 c -0.066267,0.162403 -0.00791,0.313278 0.1617783,0.419484 0.1697262,0.10606 0.4372723,0.158766 0.7433568,0.14651 0.3063071,-0.01245 0.6260497,-0.08867 0.889431,-0.212277 0.2633545,-0.123617 0.4482854,-0.284194 0.5144964,-0.44672 L 9.6297399,1.0481585 C 9.7244884,0.83873421 9.6120453,0.6493819 9.3314888,0.54651986 9.0509051,0.44355769 8.6415315,0.4412967 8.2466631,0.54065105 Z"
id="path76"
style="stroke-width:0.0494431" />
</svg>
</button>
</div>
</div>
</div>
<!-- row-2 -->
<div class="container text-center">
<div class="row">
<div class="col">
<button onclick="addChar('7')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-7"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('8')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-8"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('9')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-9"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('*')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-asterisk"></i>
</button>
</div>
</div>
</div>
<!-- row-3 -->
<div class="container text-center">
<div class="row">
<div class="col">
<button onclick="addChar('4')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-4"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('5')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-5"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('6')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-6"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('-')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-minus"></i>
</button>
</div>
</div>
</div>
<!-- row-4 -->
<div class="container text-center">
<div class="row">
<div class="col">
<button onclick="addChar('1')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-1"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('2')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-2"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('3')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-3"></i>
</button>
</div>
<div class="col">
<button onclick="addChar('+')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-plus"></i>
</button>
</div>
</div>
</div>
<!-- row-5 -->
<div class="container text-center">
<div class="row">
<div class="col">
<button onclick="addChar('.')" class="btn bg-light btn-light w-100 mb-2 border">
<i style="font-size: 4px;" class="fa-solid fa-circle">.</i>
</button>
</div>
<div class="col">
<button onclick="addChar('0')" class="btn bg-light btn-light w-100 mb-2 border">
<i class="fa-solid fa-0"></i>
</button>
</div>
<div class="col-6">
<button id="enter" onclick="evlu()" class="btn bg-light btn-primary text-dark w-100 mb-2 border">
<i class="fa-solid fa-equals"></i>
</button>
</div>
</div>
</div>
</div>
<div class="card-footer pt-4">
<div class="blockquote-footer mb-0">
Made by
<strong>Aadil Mugal</strong>
made with <span class="text-danger">🎔</span>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<script>
// first change the expr and than assign it to input always
let expr = "";
let input = document.getElementById("input");
// console.log(x);
let addChar = (c)=>{
expr+=c;
input.value = expr;
autof();
}
let allClear = ()=>{
expr = "";
input.value = expr;
}
let deleteFromBack = ()=>{
expr = expr.slice(0, expr.length-1);
input.value = expr;
autof();
}
let evlu = ()=>{
expr = eval(expr);
input.value = expr;
autof();
}
//for check box feature
function chtogg2(){
let element = document.getElementById("check");
element.classList.toggle("d-none");
let mych = document.getElementById("mycheck");
if(mych.checked==true){
expr = input.value;
try{
para.innerHTML = eval(expr);
}catch(err) {
para.innerHTML = "not valid";
}
}
}
function chtogg() {
// console.log('kol to hua hu');
let element = document.getElementById("check");
element.classList.toggle("d-none");
// console.log("you clicked..");
let mych = document.getElementById("mycheck");
if(mych.checked==false){
expr = input.value;
try{
para.innerHTML = eval(expr);
}catch(err) {
para.innerHTML = "not valid";
}
mych.checked = true;
}
else mych.checked = false;
}
function autof(){
// console.log("input change")
let mych = document.getElementById("mycheck");
let para = document.getElementById("para");
expr = input.value;
if(mych.checked==true){
try{
para.innerHTML = eval(expr);
}catch(err) {
para.innerHTML = "not valid";
}
}
}
</script>
</body>
</html>