-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
154 lines (123 loc) · 6.8 KB
/
script.js
File metadata and controls
154 lines (123 loc) · 6.8 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
function toggleContent(id) {
const content = document.getElementById(`${id}-content`);
const header = content.previousElementSibling;
// Close all other roadmaps
document.querySelectorAll('.roadmap-content').forEach(el => {
if (el !== content) {
el.classList.remove('active');
el.previousElementSibling.classList.remove('active');
}
});
// Toggle the clicked roadmap
if (content.classList.contains('active')) {
content.classList.remove('active');
header.classList.remove('active');
} else {
content.classList.add('active');
header.classList.add('active');
}
}
// === عناصر DOM ===
const chatToggle = document.getElementById("chat-toggle");
const chatBox = document.getElementById("chat-box");
const chatInput = document.getElementById("chat-input");
const chatSend = document.getElementById("chat-send");
const chatMessages = document.getElementById("chat-messages");
// === فتح و إغلاق صندوق الشات ===
chatToggle.addEventListener("click", () => {
if (chatBox.style.display === "flex") {
chatBox.style.display = "none";
} else {
chatBox.style.display = "flex";
}
});
// === إضافة رسالة للمحادثة ===
function addMessage(text, sender = "bot") {
const msg = document.createElement("div");
msg.className = sender === "bot" ? "bot-msg" : "user-msg";
msg.innerText = text;
chatMessages.appendChild(msg);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
// === ردود ذكية بسيطة ===
function botReply(userText) {
userText = userText.toLowerCase();
if (userText.includes("hello") || userText.includes("hi") || userText.includes("welcome")) {
return "Welcome! 👋 How can I help you today?";
}
if (userText.includes("مرحبا") || userText.includes("السلام عليكم") || userText.includes("اهلا")) {
return "اهلا! انا ذكاء اصطناعي ادعى كورليوني. كيف يمكنني مساعدتك اليوم؟";
}
if (userText.includes("start") || userText.includes("begin")) {
return "If you're confused where to start, tell me your background or what you like and I’ll suggest the best track!";
}
if (userText.includes("حيرة") || userText.includes("ابدا")) {
return "إذا كنت غير متأكد من أين تبدأ، أخبرني بخلفيتك او ما تحب وسأقترح عليك أفضل مسار";
}
if (userText.includes("roadmap") || userText.includes("choose")) {
return "There are many tracks! AI, Data Science, Web, Software Engineering, Cyber Security… Tell me what you enjoy and I’ll choose for you.";
}
if (userText.includes("الخطط التعليمية") || userText.includes("مسارات")) {
return "هناك العديد من المسارات! الذكاء الاصطناعي، علم البيانات، الويب، هندسة البرمجيات، الأمن السيبراني… أخبرني بما تستمتع به وسأختار لك الأنسب.";
}
if (userText.includes("ai")) {
return "AI is amazing! Start with Python → Math Basics → Machine Learning → Deep Learning.";
}
if (userText.includes("الذكاء الأصطناعي")) {
return "الذكاء الاصطناعي رائع! ابدأ بـ Python → أساسيات الرياضيات → تعلم الآلة → التعلّم العميق.";
}
if (userText.includes("data science")) {
return "Data Science path: Python → Statistics → Pandas → Data Visualization → Machine Learning.";
}
if (userText.includes("علم البيانات")) {
return "مسار علم البيانات: ابدأ بتعلم بايثون → الإحصاء → استخدام Pandas لتحليل البيانات → تصور البيانات → تعلم الآلة."
}
if (userText.includes("cyber security")) {
return "Cybersecurity path: Fundamentals → Networking → Operating Systems → Security Tools → Ethical Hacking → Defensive Security";
}
if (userText.includes("الأمن السيبراني")) {
return "مسار الأمن السيبراني: الأساسيات → الشبكات → أنظمة التشغيل → أدوات الأمان → الاختراق الأخلاقي → الحماية الدفاعية.";
}
if (userText.includes("software engineering")) {
return "Software Engineering path: Programming → Data Structures → Algorithms → Databases → System Design → Testing/Debugging";
}
if (userText.includes("هندسة البرمجيات")) {
return "مسار هندسة البرمجيات: البرمجة → هياكل البيانات → الخوارزميات → قواعد البيانات → تصميم الأنظمة → الاختبار وتصحيح الأخطاء.";
}
if (userText.includes("البيض بالبسطرمة")) {
return "تمام! طريقة بسيطة ولذيذة لعمل البيض بالبسطرمة سخّن مقلاة على نار متوسطة وحط فيها الزيت أو الزبدة. ضيف البسطرمة وقلّبها شوي لحد ما تتحمّر شوية. اكسر البيض فوق البسطرمة. رش الملح والفلفل. غطّي المقلاة لمدة 2-3 دقايق لو تحب الصفار نصف مستوي، أو أطول لو تحب البيض متماسك أكثر. قدّمه سخن مع عيش أو خبز حسب الرغبة. وكل وادعيلي";
}
return "I didn’t fully understand, but I can help! Tell me what you want exactly. 😊";
}
// === عند الضغط على زر الإرسال ===
chatSend.addEventListener("click", () => {
const text = chatInput.value.trim();
if (text === "") return;
addMessage(text, "user");
chatInput.value = "";
setTimeout(() => {
const reply = botReply(text);
addMessage(reply, "bot");
}, 500);
});
// === عند الضغط على Enter ===
chatInput.addEventListener("keypress", (e) => {
if (e.key === "Enter") {
chatSend.click();
}
});
const searchInput = document.getElementById('searchInput');
const cards = document.querySelectorAll('.roadmap-card');
searchInput.addEventListener('input', () => {
const searchTerm = searchInput.value.toLowerCase();
cards.forEach(card => {
const title = card.querySelector('h2').textContent.toLowerCase();
const parentLink = card.closest('a');
const dataTitle = parentLink ? parentLink.getAttribute('data-title').toLowerCase() : "";
if (title.includes(searchTerm) || dataTitle.includes(searchTerm)) {
parentLink.style.display = 'block';
} else {
parentLink.style.display = 'none';
}
});
});