Nahrání kódu od kolegy do větve test_web
This commit is contained in:
38
index/projects/script/script.js
Executable file
38
index/projects/script/script.js
Executable file
@ -0,0 +1,38 @@
|
||||
requestUserRepos();
|
||||
|
||||
function requestUserRepos() {
|
||||
const xhr = new XMLHttpRequest();
|
||||
const url = `https://api.github.com/users/array-in-a-matrix/repos`;
|
||||
xhr.open("GET", url, true);
|
||||
|
||||
xhr.onload = function () {
|
||||
const data = JSON.parse(this.response);
|
||||
let root = document.getElementById("userRepo");
|
||||
while (root.firstChild) {
|
||||
root.removeChild(root.firstChild);
|
||||
}
|
||||
let tbody = document.getElementById("userRepo");
|
||||
for (let i in data) {
|
||||
let tr = document.createElement("tr");
|
||||
tr.classList.add("list-group-item");
|
||||
|
||||
function removeNull(disc) {
|
||||
if (disc === null) {
|
||||
const disc = "-";
|
||||
return disc;
|
||||
} else {
|
||||
return data[i].description;
|
||||
}
|
||||
}
|
||||
|
||||
tr.innerHTML = `
|
||||
<td>${data[i].name}</td>
|
||||
<td>${removeNull(data[i].description)}</td>
|
||||
<td><a href="${data[i].html_url}">${data[i].html_url}</a></td>
|
||||
<td>${data[i].language}</td>
|
||||
`;
|
||||
tbody.appendChild(tr);
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
Reference in New Issue
Block a user