-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
184 lines (172 loc) · 6.49 KB
/
index.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
<link rel="shortcut icon" type="image/png" href="https://i.ibb.co/R6SXmLz/Untitled-design-40.png">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Polish: Calculator</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #181818; /* Dark background */
}
#loading {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.85); /* Semi-transparent dark background */
display: flex;
justify-content: center;
align-items: center;
z-index: 9999; /* High z-index to cover calculator */
opacity: 1;
transition: opacity 0.5s ease; /* Fade transition */
}
#loading.hidden {
opacity: 0;
pointer-events: none; /* Prevent interactions when hidden */
}
#logo {
width: 150px; /* Logo width */
animation: fadeIn 1s ease; /* Fade-in animation for logo */
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
#calculator {
display: none; /* Hide the calculator initially */
background-color: #2c2c2c; /* Darker background for the calculator */
border-radius: 10px;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5); /* Soft shadow */
padding: 20px;
max-width: 400px; /* Limiting width */
width: 100%;
}
#result {
width: 100%;
height: 60px;
font-size: 32px; /* Larger input text for improved readability */
text-align: right;
border: none; /* Remove border */
border-radius: 6px;
padding: 10px;
box-sizing: border-box;
margin-bottom: 20px;
background-color: #404040; /* Soft dark background */
color: #ffffff; /* White text for visibility */
outline: none; /* Remove outline */
}
.button {
width: 70px;
height: 70px; /* Button size */
font-size: 28px; /* Font size */
margin: 5px;
border: none;
border-radius: 10px;
background-color: #4e4e4e; /* Standard button background */
color: white;
cursor: pointer;
transition: background-color 0.3s, transform 0.1s; /* Smooth transitions */
}
.button:hover {
background-color: #666666; /* Darker grey on hover */
}
.button.operator {
background-color: #007bff; /* Blue for operators */
}
.button.operator:hover {
background-color: #0056b3; /* Darker blue */
}
.button.clear {
background-color: #dc3545; /* Red for clear */
}
.button.clear:hover {
background-color: #c82333; /* Darker red */
}
.button.equals {
background-color: #28a745; /* Green for equals */
}
.button.equals:hover {
background-color: #218838; /* Darker green */
}
.grid {
display: grid;
grid-template-columns: repeat(4, 1fr); /* Four columns */
gap: 10px; /* Space between buttons */
}
@media (max-width: 400px) {
#calculator {
width: 90%; /* Responsively adjust width */
}
.button {
width: 60px; /* Reduce button size for smaller screens */
height: 60px;
}
}
</style>
</head>
<body>
<div id="loading">
<img id="logo" src="https://i.ibb.co/hYpZcnB/SCIENTIFIC-1.png" alt="Loading..."> <!-- Replace with your logo -->
</div>
<div id="calculator">
<input type="text" id="result" disabled>
<div class="grid">
<button class="button clear" onclick="clearResult()">C</button>
<button class="button operator" onclick="appendToResult('/')">÷</button>
<button class="button operator" onclick="appendToResult('*')">×</button>
<button class="button operator" onclick="appendToResult('-')">−</button>
<button class="button" onclick="appendToResult('7')">7</button>
<button class="button" onclick="appendToResult('8')">8</button>
<button class="button" onclick="appendToResult('9')">9</button>
<button class="button operator" onclick="appendToResult('+')">+</button>
<button class="button" onclick="appendToResult('4')">4</button>
<button class="button" onclick="appendToResult('5')">5</button>
<button class="button" onclick="appendToResult('6')">6</button>
<button class="button equals" onclick="calculateResult()">=</button>
<button class="button" onclick="appendToResult('1')">1</button>
<button class="button" onclick="appendToResult('2')">2</button>
<button class="button" onclick="appendToResult('3')">3</button>
<button class="button" onclick="appendToResult('0')">0</button>
</div>
</div>
<script>
function appendToResult(value) {
document.getElementById('result').value += value;
}
function clearResult() {
document.getElementById('result').value = '';
}
function calculateResult() {
const resultField = document.getElementById('result');
try {
// Using eval for simplicity; in production, consider a safer parsing method
resultField.value = eval(resultField.value.replace(/×/g, "*").replace(/÷/g, "/"));
} catch (error) {
resultField.value = 'Error'; // Show error if calculation fails
}
}
// Show the calculator after the loading is done
window.onload = function() {
const loading = document.getElementById('loading');
const calculator = document.getElementById('calculator');
// Hide loading screen after a delay
setTimeout(() => {
loading.classList.add('hidden'); // Add class to trigger fade-out
calculator.style.display = 'block'; // Show calculator
}, 2000); // Delay for 2 seconds for the loading screen
};
</script>
</body>
</html>