-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
72 lines (60 loc) · 2.62 KB
/
Copy pathscript.js
File metadata and controls
72 lines (60 loc) · 2.62 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
// انتظر تحميل الصفحة بالكامل
document.addEventListener('DOMContentLoaded', () => {
// --- 1. نظام الدارك مود ---
const themeToggle = document.getElementById('theme-toggle');
const themeIcon = document.getElementById('theme-icon');
const root = document.documentElement;
// استعادة الثيم المحفوظ
const savedTheme = localStorage.getItem('theme') || 'light';
root.setAttribute('data-theme', savedTheme);
updateThemeIcon(savedTheme);
themeToggle.addEventListener('click', () => {
const currentTheme = root.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
root.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
updateThemeIcon(newTheme);
});
function updateThemeIcon(theme) {
if (theme === 'dark') {
themeIcon.className = 'fas fa-sun';
} else {
themeIcon.className = 'fas fa-moon';
}
}
// --- 2. التنقل بين الصفحات ---
const navLinks = document.querySelectorAll('.top-nav a');
const sections = document.querySelectorAll('.section');
navLinks.forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const targetId = link.getAttribute('data-target');
sections.forEach(s => s.classList.remove('active'));
navLinks.forEach(l => l.classList.remove('active'));
document.getElementById(targetId).classList.add('active');
link.classList.add('active');
});
});
// --- 3. التخصصات الديناميكية ---
const mainSpecialty = document.getElementById('main-specialty');
const subSpecialty = document.getElementById('sub-specialty');
const subData = {
engineering: ["مدنية", "معمارية", "برمجيات"],
medicine: ["طب عام", "صيدلة", "أسنان"],
it: ["أمن سيبراني", "تطوير ويب"]
};
if(mainSpecialty) {
mainSpecialty.addEventListener('change', function() {
const val = this.value;
subSpecialty.innerHTML = '<option value="">اختر التخصص الدقيق</option>';
if(subData[val]) {
subData[val].forEach(item => {
const opt = document.createElement('option');
opt.value = item;
opt.textContent = item;
subSpecialty.appendChild(opt);
});
}
});
}
});