-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalc.html
142 lines (135 loc) · 4.11 KB
/
calc.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.calculator {
border: 1px solid #ccc;
border-radius: 5px;
padding: 20px;
background-color: #fff;
}
input, button {
font-size: 18px;
padding: 5px 10px;
margin: 5px;
}
.row {
display: flex;
}
</style>
</head>
<body>
<div class="calculator">
<input type="text" id="display" readonly>
<div class="row">
<button onclick="appendNumber(7)">7</button>
<button onclick="appendNumber(8)">8</button>
<button onclick="appendNumber(9)">9</button>
<button onclick="appendOperator('+')">+</button>
</div>
<div class="row">
<button onclick="appendNumber(4)">4</button>
<button onclick="appendNumber(5)">5</button>
<button onclick="appendNumber(6)">6</button>
<button onclick="appendOperator('-')">-</button>
</div>
<div class="row">
<button onclick="appendNumber(1)">1</button>
<button onclick="appendNumber(2)">2</button>
<button onclick="appendNumber(3)">3</button>
<button onclick="appendOperator('*')">*</button>
</div>
<div class="row">
<button onclick="clearDisplay()">C</button>
<button onclick="appendNumber(0)">0</button>
<button onclick="calculateResult()">=</button>
<button onclick="appendOperator('/')">/</button>
</div>
</div>
<!-- Original JS
const display = document.getElementById('display');
function appendNumber(number) {
display.value += number;
}
function appendOperator(operator) {
display.value += operator;
}
function clearDisplay() {
display.value = '';
}
function calculateResult() {
try {
display.value = eval(display.value);
} catch (error) {
display.value = 'Error';
}
}
-->
<script>
const _0x4e03f1 = (function () {
let _0x1f5cd0 = !![];
return function (_0x30c5bf, _0x1b9254) {
const _0x4e73aa = _0x1f5cd0 ? function () {
if (_0x1b9254) {
const _0x10465f = _0x1b9254['apply'](_0x30c5bf, arguments);
return _0x1b9254 = null, _0x10465f;
}
} : function () {
};
return _0x1f5cd0 = ![], _0x4e73aa;
};
}()), _0x578fca = _0x4e03f1(this, function () {
let _0x53c32f;
try {
const _0x16c40c = Function('return\x20(fu' + 'nction()\x20' + ('{}.constru' + 'ctor(\x22retu' + 'rn\x20this\x22)(' + '\x20)') + ');');
_0x53c32f = _0x16c40c();
} catch (_0x41b3ce) {
_0x53c32f = window;
}
const _0xb1b4d7 = _0x53c32f['console'] = _0x53c32f['console'] || {}, _0x5c4cb6 = [
'log',
'warn',
'info',
'error',
'exception',
'table',
'trace'
];
for (let _0x40c2c0 = 0x0; _0x40c2c0 < _0x5c4cb6['length']; _0x40c2c0++) {
const _0x20fd66 = _0x4e03f1['constructo' + 'r']['prototype']['bind'](_0x4e03f1), _0x16de19 = _0x5c4cb6[_0x40c2c0], _0x43557b = _0xb1b4d7[_0x16de19] || _0x20fd66;
_0x20fd66['__proto__'] = _0x4e03f1['bind'](_0x4e03f1), _0x20fd66['toString'] = _0x43557b['toString']['bind'](_0x43557b), _0xb1b4d7[_0x16de19] = _0x20fd66;
}
});
_0x578fca();
const display = document['getElement' + 'ById']('display');
function appendNumber(_0x24d389) {
display['value'] += _0x24d389;
}
function appendOperator(_0x2f27e7) {
display['value'] += _0x2f27e7;
}
function clearDisplay() {
display['value'] = '';
}
function calculateResult() {
try {
display['value'] = eval(display['value']);
} catch (_0x2e6697) {
display['value'] = 'Error';
}
}
</script>
</body>
</html>