-
Notifications
You must be signed in to change notification settings - Fork 0
/
adder-beta.html
473 lines (417 loc) · 11.9 KB
/
adder-beta.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<!doctype HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;400;700&display=swap" rel="stylesheet">
<link rel="icon" href="https://cdn-icons-png.flaticon.com/512/2211/2211435.png" type="image/png">
<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
overflow: hidden;
transition: background-color 0.5s;
}
.container {
background: #ffffff;
border-radius: 30px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
padding: 30px;
text-align: center;
width: 90%;
max-width: 400px;
animation: fadeIn 0.5s ease-in-out;
transition: background 0.5s, color 0.5s;
}
h1 {
font-weight: 700;
color: #0078d7;
margin-bottom: 20px;
}
.input-wrapper {
display: flex;
align-items: center;
position: relative;
margin-bottom: 10px;
}
.input-wrapper .material-icons {
position: absolute;
left: 10px;
color: #b0bec5;
transition: color 0.3s;
}
.input-wrapper .remove-icon {
margin-left: 10px;
color: #b0bec5;
transition: color 0.3s, background-color 0.3s;
cursor: pointer;
font-size: 20px;
padding: 5px;
border-radius: 50%;
margin-left: 10px;
}
.input-wrapper .remove-icon:hover {
background-color: #e0e0e0;
}
.input-wrapper .remove-icon:active {
background-color: red;
}
input[type="number"] {
flex: 1;
padding: 15px 10px 15px 40px;
margin: 10px 0;
border: 2px solid #b0bec5;
border-radius: 30px;
font-size: 18px;
outline: none;
transition: border-color 0.5s;
width: calc(100% - 60px);
}
input[type="number"]:focus {
border-color: #0078d7;
box-shadow: 0 0 10px rgba(0, 120, 215, 0.5);
}
input[type="number"]:focus + .material-icons {
color: #0078d7;
}
select {
width: 100%;
padding: 15px;
margin: 10px 0;
border: 2px solid #b0bec5;
border-radius: 30px;
background: #ffffff url('https://cdn-icons-png.flaticon.com/512/892/892498.png') no-repeat right 15px center;
background-size: 24px;
font-size: 18px;
outline: none;
transition: border-color 0.3s;
appearance: none;
}
select:focus {
border-color: #0078d7;
box-shadow: 0 0 10px rgba(0, 120, 215, 0.5);
}
button {
background-color: #0078d7;
color: white;
border: none;
border-radius: 30px;
padding: 15px;
width: 100%;
cursor: pointer;
font-size: 18px;
margin-top: 20px;
transition: background-color 0.3s;
display: flex;
align-items: center;
justify-content: center;
}
button:hover {
background-color: #005a9e;
box-shadow: 0 0 10px rgba(0, 120, 215, 0.5);
}
.button-loading {
background-color: #005a9e;
cursor: not-allowed;
}
.button-loading::after {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 4px solid #ffffff;
border-top: 4px solid #0078d7;
border-radius: 50%;
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
}
.answer {
margin-top: 20px;
padding: 15px;
border: 2px solid #494949;
border-radius: 30px;
background: #e0f2f1;
font-size: 18px;
animation: fadeIn 0.5s ease-in-out;
}
@keyframes dropdown {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
select option {
animation: dropdown 0.5s ease;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.loading-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #0078d7;
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
.loading-screen.hidden {
display: none;
}
.loading-animation {
border: 8px solid #ffffff;
border-top: 8px solid #0078d7;
border-radius: 50%;
width: 60px;
height: 60px;
animation: spin 1s linear infinite;
box-shadow: 0 0 10px rgba(0, 120, 215, 0.5);
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* Dark mode styles */
body.dark-mode {
background-color: #121212;
color: #ffffff;
}
.container.dark-mode {
background: #1e1e1e;
color: #ffffff;
}
.input-wrapper .material-icons.dark-mode {
color: #ffffff;
}
.input-wrapper .remove-icon.dark-mode {
color: #ffffff;
}
select.dark-mode {
background: #1e1e1e url('https://cdn-icons-png.flaticon.com/512/892/892498.png') no-repeat right 15px center;
color: #ffffff;
}
input[type="number"].dark-mode {
background-color: #1e1e1e;
border: 2px solid #555555;
color: #ffffff;
}
input[type="number"].dark-mode:focus {
border-color: #0078d7;
box-shadow: 0 0 10px rgba(0, 120, 215, 0.5);
}
.answer.dark-mode {
background: #333333;
border: 2px solid #ffffff;
}
button.dark-mode {
background-color: #333333;
}
button.dark-mode:hover {
background-color: #444444;
}
/* Toggle switch styles */
.theme-switch {
position: absolute;
top: 10px;
right: 10px;
display: flex;
align-items: center;
}
.theme-switch input {
display: none;
}
.theme-switch-label {
width: 50px;
height: 25px;
background-color: #0078d7;
border-radius: 25px;
position: relative;
cursor: pointer;
transition: background-color 0.3s;
}
.theme-switch-label:before {
content: '🌞';
position: absolute;
top: 50%;
left: 5px;
transform: translateY(-50%);
font-size: 18px;
transition: transform 0.3s, content 0.3s;
}
.theme-switch input:checked + .theme-switch-label {
background-color: #333333;
}
.theme-switch input:checked + .theme-switch-label:before {
content: '🌜';
transform: translateY(-50%) translateX(20px);
}
</style>
<script>
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function Output() {
var inputs = document.querySelectorAll('input[type="number"]');
var operator = document.getElementById("op").value;
var extraOperator = document.getElementById("extraOp").value;
var outputElement = document.getElementById("Output");
var result = parseFloat(inputs[0].value);
for (var i = 1; i < inputs.length; i++) {
var value = parseFloat(inputs[i].value);
switch (operator) {
case "+":
result += value;
break;
case "-":
result -= value;
break;
case "*":
result *= value;
break;
case "/":
result /= value;
break;
}
}
switch (extraOperator) {
case "pow":
result = Math.pow(result, 2);
break;
case "sqrt":
result = Math.sqrt(result);
break;
case "log":
result = Math.log(result);
break;
case "-":
break;
}
outputElement.innerHTML = result;
}
function addInputField() {
var inputContainer = document.getElementById("inputContainer");
var newInputWrapper = document.createElement("div");
newInputWrapper.className = "input-wrapper";
var newInput = document.createElement("input");
newInput.type = "number";
newInput.placeholder = "Example: " + getRandomInt(1, 100);
var icon = document.createElement("i");
icon.className = "material-icons";
icon.innerText = "filter_9_plus";
var removeIcon = document.createElement("i");
removeIcon.className = "material-icons remove-icon";
removeIcon.innerText = "close";
removeIcon.onclick = function() {
newInputWrapper.style.animation = 'fadeOut 0.3s';
setTimeout(function() {
inputContainer.removeChild(newInputWrapper);
}, 300);
};
newInputWrapper.appendChild(newInput);
newInputWrapper.appendChild(icon);
newInputWrapper.appendChild(removeIcon);
inputContainer.appendChild(newInputWrapper);
}
function toggleTheme() {
document.body.classList.toggle('dark-mode');
document.querySelector('.container').classList.toggle('dark-mode');
document.querySelectorAll('.material-icons').forEach(icon => {
icon.classList.toggle('dark-mode');
});
document.querySelectorAll('input[type="number"]').forEach(input => {
input.classList.toggle('dark-mode');
});
document.querySelectorAll('select').forEach(select => {
select.classList.toggle('dark-mode');
});
document.querySelector('.answer').classList.toggle('dark-mode');
document.querySelectorAll('button').forEach(button => {
button.classList.toggle('dark-mode');
});
}
document.addEventListener("DOMContentLoaded", function() {
setTimeout(function() {
document.querySelector('.loading-screen').classList.add('hidden');
document.body.style.overflow = 'auto';
}, 1000);
document.getElementById("cijfer1").placeholder = "Example: " + getRandomInt(1, 100);
document.getElementById("cijfer2").placeholder = "Example: " + getRandomInt(1, 100);
document.getElementById("theme-switch").addEventListener('change', toggleTheme);
});
</script>
</head>
<body>
<a href="https://devmikey123.github.io/Expiriments/adder.html" style="position: absolute; top: 10px; left: 10px; color: #0078d7; text-decoration: none;">Back to current version</a>
<div class="theme-switch">
<input type="checkbox" id="theme-switch">
<label class="theme-switch-label" for="theme-switch"></label>
</div>
<div class="loading-screen">
<div class="loading-animation"></div>
</div>
<div class="container">
<h1>Adder <i class="material-icons">calculate</i></h1>
<form>
<div id="inputContainer">
<div class="input-wrapper">
<input type="number" id="cijfer1" name="cijfer1">
<i class="material-icons">filter_1</i>
</div>
<div class="input-wrapper">
<input type="number" id="cijfer2" name="cijfer2">
<i class="material-icons">filter_2</i>
</div>
</div>
<button type="button" onclick="addInputField()"><i class="material-icons">add</i> Add another input</button>
<select name="operator" id="op">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">×</option>
<option value="/">÷</option>
</select>
<select name="extraOperator" id="extraOp">
<option value="-">-</option>
<option value="pow">Power</option>
<option value="sqrt">Square Root</option>
<option value="log">Logarithm</option>
</select>
<button type="button" id="Bereken" onclick="Output()"><i class="material-icons">done</i> Calculate</button>
</form>
<div class="answer">
Answer: <span id="Output"></span>
</div>
</div>
</body>
<title>Adder - Betá</title>
</html>