-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscientific.html
More file actions
209 lines (193 loc) · 7.31 KB
/
Copy pathscientific.html
File metadata and controls
209 lines (193 loc) · 7.31 KB
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
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>الآلة الحاسبة العلمية</title>
<link rel="manifest" href="/manifest.json" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/10.0.1/math.js"></script>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"/>
<style>
:root {
--main-bg: #f0f4f8;
--text-color: #1f2937;
--btn-bg: #f3f4f6;
--btn-hover-bg: #60a5fa;
--btn-active-bg: #2563eb;
--display-bg: #f9fafb;
--display-color: #1f2937;
}
body {
font-family: 'Cairo', sans-serif;
background-color: var(--main-bg);
transition: background-color 0.3s ease, color 0.3s ease;
}
.dark-mode {
background-color: #1f2937;
color: #f9fafb;
}
.dark-mode .bg-white {
background-color: #374151 !important;
}
.dark-mode .text-blue-700 {
color: #60a5fa !important;
}
.dark-mode .text-gray-500 {
color: #d1d5db;
}
.dark-mode textarea,
.dark-mode .border {
background-color: #4b5563;
color: white;
}
.dark-mode footer {
color: #9ca3af;
}
.calculator-button {
background-color: var(--btn-bg);
border: 1px solid #e5e7eb;
color: var(--text-color);
font-size: 1.5rem;
padding: 1.5rem;
width: 80px;
height: 80px;
border-radius: 12px;
transition: all 0.3s ease;
}
.calculator-button:hover {
background-color: var(--btn-hover-bg);
color: white;
cursor: pointer;
}
.calculator-button:active {
background-color: var(--btn-active-bg);
}
.calculator-button:disabled {
background-color: #d1d5db;
cursor: not-allowed;
}
.display {
background-color: var(--display-bg);
border: 1px solid #e5e7eb;
font-size: 2.5rem;
padding: 1.5rem;
width: 100%;
text-align: right;
border-radius: 12px;
margin-bottom: 1rem;
color: var(--display-color);
}
footer {
font-size: 0.85rem;
text-align: center;
margin-top: 2rem;
color: #6b7280;
}
.header-button {
font-size: 1rem;
color: var(--text-color);
padding: 0.75rem 1.5rem;
background-color: #e5e7eb;
border: none;
border-radius: 6px;
transition: all 0.3s ease;
}
.header-button:hover {
background-color: var(--btn-hover-bg);
color: white;
}
.header-button:active {
background-color: var(--btn-active-bg);
}
</style>
</head>
<body class="text-right p-6">
<div class="max-w-3xl mx-auto bg-white rounded-2xl shadow-lg p-6 space-y-6">
<div class="flex justify-between items-center">
<h1 class="text-3xl font-bold text-blue-700">الآلة الحاسبة العلمية</h1>
<button onclick="toggleDarkMode()" class="header-button">
🌓 وضع الليل
</button>
</div>
<div class="bg-blue-50 p-4 rounded-lg text-sm leading-relaxed text-gray-800">
<h2 class="text-lg font-semibold text-blue-700 mb-2">نبذة عن الآلة الحاسبة</h2>
<p>
هذه الآلة الحاسبة العلمية تساعدك على إجراء العمليات الرياضية المعقدة مثل الجذور والدوال المثلثية وغيرها.
</p>
</div>
<div class="display" id="display">0</div>
<div class="grid grid-cols-4 gap-6 mt-6">
<button class="calculator-button" onclick="appendToDisplay('7')">٧</button>
<button class="calculator-button" onclick="appendToDisplay('8')">٨</button>
<button class="calculator-button" onclick="appendToDisplay('9')">٩</button>
<button class="calculator-button" onclick="appendToDisplay('/')">/</button>
<button class="calculator-button" onclick="appendToDisplay('4')">٤</button>
<button class="calculator-button" onclick="appendToDisplay('5')">٥</button>
<button class="calculator-button" onclick="appendToDisplay('6')">٦</button>
<button class="calculator-button" onclick="appendToDisplay('*')">*</button>
<button class="calculator-button" onclick="appendToDisplay('1')">١</button>
<button class="calculator-button" onclick="appendToDisplay('2')">٢</button>
<button class="calculator-button" onclick="appendToDisplay('3')">٣</button>
<button class="calculator-button" onclick="appendToDisplay('-')">-</button>
<button class="calculator-button" onclick="appendToDisplay('0')">٠</button>
<button class="calculator-button" onclick="appendToDisplay('.')">.</button>
<button class="calculator-button" onclick="appendToDisplay('(')">(</button>
<button class="calculator-button" onclick="appendToDisplay(')')">)</button>
</div>
<div class="grid grid-cols-4 gap-6 mt-6">
<button class="calculator-button" onclick="appendToDisplay('sin(')">جا</button>
<button class="calculator-button" onclick="appendToDisplay('cos(')">جتا</button>
<button class="calculator-button" onclick="appendToDisplay('tan(')">ظل</button>
<button class="calculator-button" onclick="clearDisplay()">C</button>
<button class="calculator-button" onclick="appendToDisplay('sqrt(')">جذر</button>
<button class="calculator-button" onclick="appendToDisplay('^')">^</button>
<button class="calculator-button" onclick="calculate()">=</button>
<button class="calculator-button" onclick="appendToDisplay('+')">+</button>
</div>
<div class="mt-6 text-center">
<button onclick="changeColor()" class="header-button">
تغيير الألوان
</button>
</div>
</div>
<footer class="mt-10 text-center text-xs text-gray-400">
آلة حاسبة علمية من الطالب عمر أبو بكر
</footer>
<script>
let displayValue = "0";
let history = JSON.parse(localStorage.getItem('history')) || [];
function toggleDarkMode() {
const body = document.body;
body.classList.toggle('dark-mode');
}
function appendToDisplay(value) {
if (displayValue === "0" || displayValue === "خطأ") {
displayValue = value;
} else {
displayValue += value;
}
document.getElementById('display').textContent = displayValue;
}
function clearDisplay() {
displayValue = "0";
document.getElementById('display').textContent = displayValue;
}
function calculate() {
try {
const result = math.evaluate(displayValue);
history.push(displayValue + ' = ' + result);
localStorage.setItem('history', JSON.stringify(history));
displayValue = result.toString();
} catch (error) {
displayValue = "خطأ";
}
document.getElementById('display').textContent = displayValue;
}
function changeColor() {
const colors = ['#f0f4f8', '#e4f9f5', '#e9f7fc', '#f3f6f8', '#fff0f5'];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
document.documentElement.style.setProperty('--main-bg', randomColor);
}
</script>
</body>
</html>