Repository navigation
Expand file tree
/
Copy pathtasbih.js
More file actions
254 lines (214 loc) · 10.4 KB
/
Copy pathtasbih.js
File metadata and controls
254 lines (214 loc) · 10.4 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
document.addEventListener('DOMContentLoaded', function() {
const hamburger = document.getElementById('hamburger');
const navLinks = document.getElementById('navLinks');
hamburger.addEventListener('click', function() {
// تبديل حالة القائمة
navLinks.classList.toggle('active');
// تحديث حالة ARIA
const isExpanded = navLinks.classList.contains('active');
this.setAttribute('aria-expanded', isExpanded);
// تبديل الأيقونة بين القائمة والإغلاق
const icon = this.querySelector('i');
if (isExpanded) {
icon.classList.remove('fa-bars');
icon.classList.add('fa-times');
} else {
icon.classList.remove('fa-times');
icon.classList.add('fa-bars');
}
});
// إغلاق القائمة عند النقر على رابط
document.querySelectorAll('.nav-links a').forEach(link => {
link.addEventListener('click', () => {
navLinks.classList.remove('active');
hamburger.querySelector('i').classList.remove('fa-times');
hamburger.querySelector('i').classList.add('fa-bars');
hamburger.setAttribute('aria-expanded', 'false');
});
});
// تحديث سنة حقوق النشر
document.getElementById('current-year').textContent = new Date().getFullYear();
const dropdownBtns = document.querySelectorAll('.dropdown-btn');
dropdownBtns.forEach(btn => {
btn.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
const dropdown = this.closest('.dropdown');
dropdown.classList.toggle('active');
});
});
// إغلاق القوائم المنسدلة عند النقر خارجها
document.addEventListener('click', function() {
document.querySelectorAll('.dropdown').forEach(dropdown => {
dropdown.classList.remove('active');
});
});
// الكود الخاص بالعداد
const counter = document.getElementById('counter');
const resetBtn = document.getElementById('reset-btn');
const decrementBtn = document.getElementById('decrement-btn');
const clickArea = document.querySelector('body');
const scrollTopBtn = document.getElementById('scrollTop');
const notification = document.getElementById('notification');
const dhikrCards = document.querySelectorAll('.dhikr-card');
const sliderArrows = document.querySelectorAll('.slider-arrow');
let currentCount = 0;
let canClick = true;
const clickDelay = 200;
// وظيفة زيادة العداد
function incrementCounter() {
currentCount++;
counter.textContent = currentCount;
// تغيير اللون مؤقتاً للإشارة إلى العد
counter.style.color = '#0e4a30';
setTimeout(() => {
counter.style.color = '#1f7d53';
}, 200);
// التحقق من الوصول إلى معالم معينة
checkMilestones(currentCount);
}
// وظيفة إنقاص العداد
function decrementCounter() {
if (currentCount > 0) {
currentCount--;
counter.textContent = currentCount;
// تغيير اللون مؤقتاً للإشارة إلى العد
counter.style.color = '#c62828';
setTimeout(() => {
counter.style.color = '#1f7d53';
}, 200);
} else {
showNotification('العداد بالفعل عند الصفر');
}
}
// التحقق من المعالم (33، 100، إلخ)
function checkMilestones(count) {
const milestones = [33, 66, 100, 200, 300];
if (milestones.includes(count)) {
showNotification(`تهانينا! لقد وصلت إلى ${count} تسبيحة`);
}
}
// عرض الإشعارات
function showNotification(message) {
notification.textContent = message;
notification.style.display = 'block';
setTimeout(() => {
notification.style.display = 'none';
}, 3000);
}
// النقر على الصفحة لزيادة العداد
clickArea.addEventListener('click', function(e) {
// تجاهل النقر على أزرار التحكم أو الروابط أو السلايدر
if (e.target.closest('button') ||
e.target.closest('.menu__link') ||
e.target.closest('.scroll-top') ||
e.target.closest('.dhikr-card') ||
e.target.closest('.slider-arrow') ||
e.target.closest('.dot')) {
return;
}
if (canClick) {
incrementCounter();
canClick = false;
// تأثير النقر
counter.style.transform = 'scale(0.95)';
setTimeout(() => {
counter.style.transform = 'scale(1)';
}, 100);
// تأخير بين النقرات
setTimeout(() => {
canClick = true;
}, clickDelay);
}
});
// زر إنقاص العداد
decrementBtn.addEventListener('click', function(e) {
e.stopPropagation();
decrementCounter();
// تأثير النقر
this.style.transform = 'scale(0.95)';
setTimeout(() => {
this.style.transform = 'scale(1)';
}, 100);
});
// إعادة تعيين العداد
resetBtn.addEventListener('click', function(e) {
e.stopPropagation();
// تأثير الإعادة
counter.style.transform = 'scale(0.8)';
setTimeout(() => {
counter.style.transform = 'scale(1)';
}, 200);
currentCount = 0;
counter.textContent = currentCount;
showNotification('تم إعادة العداد إلى الصفر');
});
// زر العودة للأعلى
window.addEventListener('scroll', function() {
if (window.pageYOffset > 300) {
scrollTopBtn.classList.add('show');
} else {
scrollTopBtn.classList.remove('show');
}
});
scrollTopBtn.addEventListener('click', function() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
// منع زيادة العداد عند النقر على الأذكار
dhikrCards.forEach(card => {
card.addEventListener('click', function(e) {
e.stopPropagation();
// تم إزالة كود ضبط العداد حسب الطلب
});
});
// منع زيادة العداد عند النقر على أسهم السلايدر
sliderArrows.forEach(arrow => {
arrow.addEventListener('click', function(e) {
e.stopPropagation();
});
});
// كود السلايدر الجديد
const slider = document.getElementById('dhikrSlider');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
const dots = document.querySelectorAll('.dot');
let currentSlide = 0;
const totalSlides = document.querySelectorAll('.slider-group').length;
function showSlide(index) {
const groups = document.querySelectorAll('.slider-group');
groups.forEach((group, i) => {
group.classList.toggle('active', i === index);
});
// تحديث النقاط
dots.forEach((dot, i) => {
dot.classList.toggle('active', i === index);
});
currentSlide = index;
}
prevBtn.addEventListener('click', function() {
let newIndex = currentSlide - 1;
if (newIndex < 0) newIndex = totalSlides - 1;
showSlide(newIndex);
});
nextBtn.addEventListener('click', function() {
let newIndex = currentSlide + 1;
if (newIndex >= totalSlides) newIndex = 0;
showSlide(newIndex);
});
// النقر على النقاط للانتقال للسلايد المحدد
dots.forEach(dot => {
dot.addEventListener('click', function() {
const slideIndex = parseInt(this.getAttribute('data-slide'));
showSlide(slideIndex);
});
});
// التمرير التلقائي كل 10 ثواني (اختياري)
setInterval(() => {
let newIndex = currentSlide + 1;
if (newIndex >= totalSlides) newIndex = 0;
showSlide(newIndex);
}, 10000);
});