-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcalculator.html
148 lines (135 loc) · 6.91 KB
/
calculator.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="google-adsense-account" content="ca-pub-2217728188815563">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Calculator</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css"
integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2217728188815563"
crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="index.html">Simple Tools</a>
</nav>
<div class="container">
<div class="body m-3 card" style="padding:10px">
<div class="text-center">
<p class="lead">Simple Calculator</p>
</div>
<div class="input my-2">
<input type="text" name="writespace" readonly class="form-control form-control-lg" id="writespace">
</div>
<div class="past">
<small>Result : </small><small id="past-val">0</small>
</div>
<div class="input my-2">
<input type="text" value="0" name="printspace" class="form-control form-control-sm" readonly
id="printspace">
</div>
<div class="buttons">
<table style="width:100%">
<tr>
<td><button class="btn btn-outline-primary w-100">1</button></td>
<td><button class="btn btn-outline-primary w-100">2</button></td>
<td><button class="btn btn-outline-primary w-100">3</button></td>
<td>
<div class="btn-group w-100">
<button class="btn btn-primary w-100">+</button>
<button class="btn btn-outline-info w-100">-</button>
</div>
</td>
</tr>
<tr>
<td><button class="btn btn-outline-primary w-100">4</button></td>
<td><button class="btn btn-outline-primary w-100">5</button></td>
<td><button class="btn btn-outline-primary w-100">6</button></td>
<td>
<div class="btn-group w-100">
<button class="btn btn-primary w-100">x</button>
<button class="btn btn-outline-info w-100">/</button>
</div>
</td>
</tr>
<tr>
<td><button class="btn btn-outline-primary w-100">7</button></td>
<td><button class="btn btn-outline-primary w-100">8</button></td>
<td><button class="btn btn-outline-primary w-100">9</button></td>
<td>
<div class="btn-group w-100">
<button class="btn btn-primary w-100">(</button>
<button class="btn btn-outline-info w-100">)</button>
</div>
</td>
</tr>
<tr>
<td><button class="btn btn-outline-primary w-100">0</button></td>
<td><button class="btn btn-outline-danger w-100">C</button></td>
<td>
<button class="btn btn-outline-success w-100">=</button>
</td>
<td>
<div class="btn-group w-100">
<button class="btn btn-primary w-100">^</button>
<button class="btn btn-outline-info w-100">Ans</button>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.js"
integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"
integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn"
crossorigin="anonymous"></script>
<script>
var current_val, collector;
$(function (ready) {
$("input#writespace").on("change", function () {
$("input#writespace").val(eval($("input#writespace").val()));
});
})
$("button").click(function () {
current_val = $(this).html();
if (current_val == "Ans") {
current_val = collector;
}
if (current_val == "C") {
$("input#writespace").val("");
}
else if (current_val == "^") {
$("input#writespace").val($("input#writespace").val() + "**");
}
else if (current_val == "x") {
$("input#writespace").val($("input#writespace").val() + "*");
}
else if (current_val == "=") {
$("input#printspace").val(eval($("input#writespace").val()));
}
else {
$("input#writespace").val($("input#writespace").val() + current_val);
}
if (current_val in "1234567890)".split("")) {
$("input#printspace").val(eval($("input#writespace").val()));
collector = $("input#printspace").val();
$("#past-val").html($("input#writespace").val());
}
})
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-KSX9W2JJ5N"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-KSX9W2JJ5N');
gtag('page', "calculator");
</script>
</body>
</html>