-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
72 lines (65 loc) · 2.71 KB
/
Copy pathscripts.js
File metadata and controls
72 lines (65 loc) · 2.71 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
// Example of a nested JSON call to fetch data through the Github API:
// <li> <img src="${owner["avatar_url"]}" alt=""/> </li>
fetch(
"https://api.github.com/users/davidvandenbor/repos?sort=created&direction=dsc"
)
.then((resp) => resp.json())
.then((resp) => {
for (let repo of resp) {
const { name, description, html_url, topics } = repo;
const repositoryList = document.querySelector(".repo--js");
const myTemplate = `
<ul class="project" id="${name}">
<iframe src="https://htmlpreview.github.io/?https://github.com/davidvandenbor/${name}/blob/master/index.html"></iframe>
<li><a href="${html_url}" title="This is link to ${name} repository from my GitHub list" target="_new">${name}</a></li>
<li>${description} <br /></li>
<span class="course"> <li>CMD Coursenaam: <span style="text-transform:uppercase;font-weight:normal">${topics}</span> <br /></li></span>
<li>Link to Sandbox: <a href="https://githubbox.com/davidvandenbor/${name}" alt="This is a source code of ${name} project." target="_new">Source code</a></li>
<li>Link to <a href="${html_url}" title="This is link to ${name} repository from my GitHub list" target="_new">Github Repo</a></li>
</ul>
`;
repositoryList.innerHTML += myTemplate;
}
})
.catch((error) => {
console.log("error");
});
// Search filter for flitering through the Repository examples by keywords
function zoekfilter() {
var input, filter, repositories, td, i, txtValue, li;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
repositories = document.getElementById("repositories");
li = repositories.querySelectorAll(".project");
for (i = 0; i < li.length; i++) {
console.log(li[i].parentNode);
var rowContent = li[i].textContent;
rowContent = rowContent.replace(/[\s]+/g, " ");
//console.log(rowContent);
if (rowContent) {
if (rowContent.toUpperCase().includes(filter)) {
li[i].style.cssText = "display: block;";
} else {
li[i].style.cssText = "display: none;";
}
}
}
}
function zoekfilterCourse() {
var inputCourse, filter, repositories, td, i, txtValue, courses;
inputCourse = document.getElementById("myInputCourse");
filter = inputCourse.value.toUpperCase();
repositories = document.getElementById("repositories");
courses = repositories.querySelectorAll(".course");
for (i = 0; i < courses.length; i++) {
var rowContent = courses[i].textContent;
rowContent = rowContent.replace(/[\s]+/g, " ");
if (rowContent) {
if (rowContent.toUpperCase().includes(filter)) {
courses[i].closest('.project').style.display = "block";
} else {
courses[i].closest('.project').style.display = "none";
}
}
}
}