-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexplore.js
More file actions
56 lines (48 loc) · 2.31 KB
/
Copy pathexplore.js
File metadata and controls
56 lines (48 loc) · 2.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
// explore.js – SkillSwap Explore Page
(function () {
injectShell('nav-explore');
// ── Tab switching (Mentors / Group Sessions) ──────────────
const mainTabs = document.getElementById('mainTabs');
mainTabs.querySelectorAll('.tab-btn').forEach(btn => {
btn.addEventListener('click', function () {
mainTabs.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
this.classList.add('active');
});
});
// ── Category chip filtering ───────────────────────────────
const chips = document.querySelectorAll('#catChips .cat-chip');
const cards = document.querySelectorAll('#mentorsGrid .mentor-card');
chips.forEach(chip => {
chip.addEventListener('click', function () {
chips.forEach(c => c.classList.remove('active'));
this.classList.add('active');
const cat = this.dataset.cat;
cards.forEach(card => {
const cats = (card.dataset.cat || '').split(' ');
card.style.display = (cat === 'all' || cats.includes(cat)) ? '' : 'none';
});
});
});
// ── Live search filter ────────────────────────────────────
const searchInput = document.getElementById('mentorSearch');
searchInput.addEventListener('input', function () {
const q = this.value.toLowerCase();
cards.forEach(card => {
const text = card.textContent.toLowerCase();
card.style.display = text.includes(q) ? '' : 'none';
});
// Reset chip active state when searching
if (q) chips.forEach(c => c.classList.remove('active'));
});
// ── Mentor card click → mentor profile page ─────────────
cards.forEach(card => {
card.addEventListener('click', function () {
window.location.href = 'mentor.html';
});
});
// ── AI Search button ──────────────────────────────────────
document.querySelector('.ai-search-btn').addEventListener('click', function () {
const goal = prompt('Describe your learning goal and we\'ll find the best mentor for you:');
if (goal) alert('Finding mentors for: "' + goal + '"…\n\nAI search coming soon!');
});
})();