-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
78 lines (71 loc) · 2.44 KB
/
scripts.js
File metadata and controls
78 lines (71 loc) · 2.44 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
const container = document.querySelector('#repositories .container');
fetch('https://api.github.com/users/your_username/repos')
.then(response => response.json())
.then(data => {
data.forEach(repo => {
const repoCard = document.createElement('div');
repoCard.classList.add('repo-card');
repoCard.innerHTML = `
<a href="${repo.html_url}" target="_blank">${repo.name}</a>
<p>${repo.description ? repo.description : 'No description available'}</p>
`;
container.appendChild(repoCard);
});
})
.catch(error => console.error('Error fetching repositories:', error));
function showSection(sectionId) {
const sections = document.querySelectorAll('.content-section');
sections.forEach(section => {
if (section.id === sectionId) {
section.style.display = 'block';
} else {
section.style.display = 'none';
}
});
}
function showSubSection(subSectionId) {
const subSections = document.querySelectorAll('.sub-section');
subSections.forEach(subSection => {
if (subSection.id === subSectionId) {
subSection.style.display = 'block';
} else {
subSection.style.display = 'none';
}
});
}
// Show the 'home' section by default
window.onload = function() {
showSection('home');
};
function searchSites() {
const input = document.getElementById('searchBar').value.toLowerCase();
const sites = document.querySelectorAll('.repo-card');
sites.forEach(site => {
const title = site.querySelector('a').textContent.toLowerCase();
const description = site.querySelector('p').textContent.toLowerCase();
if (title.includes(input) || description.includes(input)) {
site.style.display = 'block';
} else {
site.style.display = 'none';
}
});
}
function showSection(sectionId) {
const sections = document.querySelectorAll('.content-section');
sections.forEach(section => {
if (section.id === sectionId) {
section.style.display = 'block';
} else {
section.style.display = 'none';
}
});
if (sectionId === 'home') {
document.body.classList.add('home-active');
} else {
document.body.classList.remove('home-active');
}
}
// Show the 'home' section by default
window.onload = function() {
showSection('home');
};