-
Notifications
You must be signed in to change notification settings - Fork 0
/
My_Sr_Calci.html
227 lines (190 loc) · 6.73 KB
/
My_Sr_Calci.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100vh;
margin: 0;
background:linear-gradient(to bottom,#33ccff 0%,#ff99cc 100%);
}
.calculator {
padding-top: 25px;
margin-top: 14.5rem;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 5px;
background-color: #e2c64d;
border-radius: 5px;
box-shadow: 40px 40px rgb(68, 74, 77) ;
padding: 20px;
}
.calculator input[type="text"] {
grid-column: span 4;
margin-bottom: 10px;
padding: 10px;
font-size: 18px;
border-style: double;
border-width: 4px;
border-radius: 5px;
background-color: rgb(187, 239, 239);
}
.calculator button {
width: 100%;
height: 45px;
font-size: 18px;
border: none;
border-radius: 15px 50px 30px;
cursor: pointer;
transition: background-color 0.3s;
box-shadow: 10px 10px rgb(112, 142, 157) ;
}
.calculator button:hover {
background-color: #56cd2e;
font-size: 150%;
}
.manual {
margin-top: 20px;
padding: 10px;
background-color: #f0f0f0;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.manual h2 {
margin-top: 0;
font-size: 20px;
}
.manual p {
margin-bottom: 10px;
line-height: 1.5;
}
mark{
background-color: rgb(207, 232, 175);
color: rgb(17, 17, 17);
text-decoration: underline;
}
#water{
font-size: 1.1rem;
border: 4px solid black;
padding: 1.2em;;
}
@media only screen and (max-width: 600px) {
.calculator {
width: 90%;
max-width: 300px;
}
.calculator button {
height: 40px;
font-size: 16px;
}
.manual {
width: 90%;
max-width: 300px;
}
}
@media only screen and (min-width: 601px) {
.calculator {
width: 60%;
max-width: 600px;
}
.manual {
width: 60%;
max-width: 600px;
}
}
</style>
</head>
<body>
<div class="calculator">
<input type="text" id="display" value="|_||_||_||_||_||_||_||_||_||_||_||_|" readonly>
<button onclick="clearDisplay()" class="button-effect">C</button>
<button onclick="backspace()" class="button-effect">←</button>
<button onclick="appendToDisplay('7')" class="button-effect">7</button>
<button onclick="appendToDisplay('8')" class="button-effect">8</button>
<button onclick="appendToDisplay('9')" class="button-effect">9</button>
<button onclick="appendToDisplay('/')" class="button-effect">/</button>
<button onclick="appendToDisplay('4')" class="button-effect">4</button>
<button onclick="appendToDisplay('5')" class="button-effect">5</button>
<button onclick="appendToDisplay('6')" class="button-effect">6</button>
<button onclick="appendToDisplay('*')" class="button-effect">*</button>
<button onclick="appendToDisplay('1')" class="button-effect">1</button>
<button onclick="appendToDisplay('2')" class="button-effect">2</button>
<button onclick="appendToDisplay('3')" class="button-effect">3</button>
<button onclick="appendToDisplay('-')" class="button-effect">-</button>
<button onclick="appendToDisplay('.')" class="button-effect">.</button>
<button onclick="calculate('=')" class="button-effect">=</button>
<button onclick="appendToDisplay('0')" class="button-effect">0</button>
<button onclick="appendToDisplay('+')" class="button-effect operator">+</button>
</div>
<div class="manual">
<h2>How To Use</h2>
<p><mark>Basic Usage:</mark> Use the mouse or your keyboard to input numbers and operators. Press "C" to clear the display, "=" to calculate and "Enter" to calculate as well.</p>
<p><mark>Keyboard Shortcuts:</mark></p>
<ul>
<li><mark >Numbers (0-9):</mark> Type the number keys to input the respective numbers.</li>
<li><mark>Operators (+, -, *, /):</mark> Type the operator keys to input the respective operators.</li>
<li><mark>Enter:</mark> Calculate the result.</li>
<li><mark>Escape:</mark> Clear the display.</li>
<li><mark>Backspace:</mark>Delete one element.(Note it will not take one step backward)</li>
<li><mark>CAUTION:</mark>If using keybord buttons avoid placing mouse cursor. <br>This is a basic calculator uncapable of various functions and complex calculation.</li>
<p id="water">"© Suramya Ranjan" The work is done by me solely.Although ideas and mapping is done through contents available over the internet,you-tube etc"</p>
</ul>
</div>
<script>
alert("You are allowing all your data photos nudes personal semux access to the owner of the page by clicking Ok");
document.addEventListener('keydown', function(event) {
const key = event.key;
if (key >= '0' && key <= '9' || key === '.' || key === '+' || key === '-' || key === '*' || key === '/') {
appendToDisplay(key);
}
else if (key === 'Enter' || key === '=')
{
calculate();
}
else if (key === 'Escape')
{
clearDisplay();
}
else if (key === 'c' || key === 'C')
{
clearDisplay();
}
else if (key === 'Backspace')
{
backspace();
}
});
function appendToDisplay(value) {
const display = document.getElementById("display");
if (display.value === '0' && value !== '.') {
display.value = value;
} else {
display.value += value;
}
}
function clearDisplay() {
document.getElementById("display").value = '0';
}
function backspace() {
const display = document.getElementById("display");
display.value = display.value.slice(0, -1);
if (display.value === '') {
display.value = '0';
}
}
function calculate() {
let expression = document.getElementById("display").value;
let result = eval(expression);
document.getElementById("display").value = result;
}
</script>
</script>
</body>
</html>