-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
285 lines (263 loc) · 8.1 KB
/
Copy pathindex.html
File metadata and controls
285 lines (263 loc) · 8.1 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
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
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>حاسبة العمر (هجري / ميلادي) - Open Source Age Calculator</title>
<style>
:root {
--ac-bg: #0f172a;
--ac-card: #1e293b;
--ac-accent: #14b8a6;
--ac-text: #f1f5f9;
--ac-muted: #94a3b8;
}
* { box-sizing: border-box; }
body {
font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
background: var(--ac-bg);
color: var(--ac-text);
margin: 0;
padding: 2rem 1rem;
display: flex;
justify-content: center;
}
.ac-card {
background: var(--ac-card);
border-radius: 16px;
padding: 2rem;
max-width: 480px;
width: 100%;
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.ac-card h1 {
font-size: 1.4rem;
text-align: center;
margin-bottom: 1.5rem;
}
.ac-toggle {
display: flex;
gap: 0.5rem;
margin-bottom: 1.2rem;
background: #0f172a;
border-radius: 10px;
padding: 4px;
}
.ac-toggle button {
flex: 1;
padding: 0.6rem;
border: none;
border-radius: 8px;
background: transparent;
color: var(--ac-muted);
cursor: pointer;
font-size: 0.95rem;
}
.ac-toggle button.active {
background: var(--ac-accent);
color: #fff;
}
.ac-field {
margin-bottom: 1rem;
}
.ac-field label {
display: block;
margin-bottom: 0.4rem;
color: var(--ac-muted);
font-size: 0.9rem;
}
.ac-row {
display: flex;
gap: 0.5rem;
}
.ac-row select {
flex: 1;
padding: 0.6rem;
border-radius: 8px;
border: 1px solid #334155;
background: #0f172a;
color: var(--ac-text);
font-size: 0.95rem;
}
.ac-btn {
width: 100%;
padding: 0.8rem;
background: var(--ac-accent);
color: #fff;
border: none;
border-radius: 10px;
font-size: 1rem;
cursor: pointer;
margin-top: 0.5rem;
}
.ac-btn:hover { opacity: 0.9; }
.ac-results {
margin-top: 1.5rem;
display: none;
}
.ac-results.show { display: block; }
.ac-big {
text-align: center;
font-size: 2.2rem;
font-weight: bold;
color: var(--ac-accent);
margin-bottom: 0.3rem;
}
.ac-sub {
text-align: center;
color: var(--ac-muted);
margin-bottom: 1.2rem;
font-size: 0.9rem;
}
.ac-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.6rem;
}
.ac-grid div {
background: #0f172a;
border-radius: 10px;
padding: 0.7rem;
text-align: center;
}
.ac-grid strong {
display: block;
font-size: 1.1rem;
color: var(--ac-text);
}
.ac-grid span {
font-size: 0.75rem;
color: var(--ac-muted);
}
.ac-footer {
text-align: center;
margin-top: 1.5rem;
font-size: 0.8rem;
color: var(--ac-muted);
}
.ac-footer a {
color: var(--ac-accent);
text-decoration: none;
}
</style>
</head>
<body>
<div class="ac-card">
<h1>حاسبة العمر — هجري / ميلادي</h1>
<div class="ac-toggle">
<button id="acBtnGreg" class="active">ميلادي</button>
<button id="acBtnHijri">هجري</button>
</div>
<div class="ac-field">
<label>تاريخ الميلاد</label>
<div class="ac-row">
<select id="acDay"></select>
<select id="acMonth"></select>
<select id="acYear"></select>
</div>
</div>
<button class="ac-btn" id="acCalcBtn">احسب العمر</button>
<div class="ac-results" id="acResults">
<div class="ac-big" id="acYearsBig">—</div>
<div class="ac-sub" id="acDateSub">سنة</div>
<div class="ac-grid">
<div><strong id="acMonths">—</strong><span>أشهر</span></div>
<div><strong id="acDays">—</strong><span>أيام</span></div>
<div><strong id="acWeeks">—</strong><span>أسابيع</span></div>
<div><strong id="acHours">—</strong><span>ساعات</span></div>
<div><strong id="acMinutes">—</strong><span>دقائق</span></div>
<div><strong id="acNextBday">—</strong><span>يوم لعيد ميلادك</span></div>
</div>
</div>
<div class="ac-footer">
نسخة مبسطة ومفتوحة المصدر —
النسخة الكاملة مع التقويم الهجري الدقيق وتحليل الشخصية ومشاركة النتائج
على <a href="https://hisabaleumr.com/" target="_blank" rel="noopener">HisabAlUmr.com</a>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const daySelect = document.getElementById('acDay');
const monthSelect = document.getElementById('acMonth');
const yearSelect = document.getElementById('acYear');
const calcBtn = document.getElementById('acCalcBtn');
const results = document.getElementById('acResults');
const arMonths = ['يناير','فبراير','مارس','أبريل','مايو','يونيو','يوليو','أغسطس','سبتمبر','أكتوبر','نوفمبر','ديسمبر'];
function populateSelects() {
for (let d = 1; d <= 31; d++) {
const opt = document.createElement('option');
opt.value = d;
opt.textContent = d;
daySelect.appendChild(opt);
}
arMonths.forEach((m, i) => {
const opt = document.createElement('option');
opt.value = i + 1;
opt.textContent = m;
monthSelect.appendChild(opt);
});
const currentYear = new Date().getFullYear();
for (let y = currentYear; y >= currentYear - 110; y--) {
const opt = document.createElement('option');
opt.value = y;
opt.textContent = y;
yearSelect.appendChild(opt);
}
}
function calculateAge() {
const day = parseInt(daySelect.value, 10);
const month = parseInt(monthSelect.value, 10) - 1;
const year = parseInt(yearSelect.value, 10);
const birthDate = new Date(year, month, day);
const now = new Date();
if (birthDate > now || isNaN(birthDate.getTime())) {
alert('من فضلك أدخل تاريخ ميلاد صحيح');
return;
}
let years = now.getFullYear() - birthDate.getFullYear();
let months = now.getMonth() - birthDate.getMonth();
let days = now.getDate() - birthDate.getDate();
if (days < 0) {
months--;
const lastMonth = new Date(now.getFullYear(), now.getMonth(), 0);
days += lastMonth.getDate();
}
if (months < 0) {
years--;
months += 12;
}
const diffMs = now - birthDate;
const totalDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
const totalWeeks = Math.floor(totalDays / 7);
const totalHours = Math.floor(diffMs / (1000 * 60 * 60));
const totalMinutes = Math.floor(diffMs / (1000 * 60));
let nextBday = new Date(now.getFullYear(), birthDate.getMonth(), birthDate.getDate());
if (nextBday < now) {
nextBday.setFullYear(now.getFullYear() + 1);
}
const daysToNextBday = Math.ceil((nextBday - now) / (1000 * 60 * 60 * 24));
document.getElementById('acYearsBig').textContent = years;
document.getElementById('acDateSub').textContent = years + ' سنة، ' + months + ' شهر، ' + days + ' يوم';
document.getElementById('acMonths').textContent = years * 12 + months;
document.getElementById('acDays').textContent = totalDays.toLocaleString('ar');
document.getElementById('acWeeks').textContent = totalWeeks.toLocaleString('ar');
document.getElementById('acHours').textContent = totalHours.toLocaleString('ar');
document.getElementById('acMinutes').textContent = totalMinutes.toLocaleString('ar');
document.getElementById('acNextBday').textContent = daysToNextBday.toLocaleString('ar');
results.classList.add('show');
}
document.getElementById('acBtnGreg').addEventListener('click', function () {
this.classList.add('active');
document.getElementById('acBtnHijri').classList.remove('active');
});
document.getElementById('acBtnHijri').addEventListener('click', function () {
this.classList.add('active');
document.getElementById('acBtnGreg').classList.remove('active');
alert('تحويل الهجري الدقيق متوفر في النسخة الكاملة على hisabaleumr.com');
});
calcBtn.addEventListener('click', calculateAge);
populateSelects();
});
</script>
</body>
</html>