inplemented github api to pull projects
This commit is contained in:
parent
5cac61d00d
commit
5f189041cc
2 changed files with 62 additions and 28 deletions
39
githubapi.js
Normal file
39
githubapi.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
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();
|
||||
}
|
51
index.html
51
index.html
|
@ -7,7 +7,7 @@
|
|||
<title>Array in a Matrix</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="theme-color" content="#157878">
|
||||
<script src="/script.js" defer></script>
|
||||
<script src="script.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body data-new-gr-c-s-check-loaded="8.872.0" data-gr-ext-installed="">
|
||||
|
@ -15,7 +15,6 @@
|
|||
<h1 class="project-name">Array in a Matrix</h1>
|
||||
<h2 class="project-tagline"> Welcome!</h2>
|
||||
<a href="https://github.com/array-in-a-matrix" class="btn">GitHub</a>
|
||||
<a href="calculators/main.html" class="btn">Web Calculators</a>
|
||||
|
||||
</header>
|
||||
<main class="main-content">
|
||||
|
@ -27,45 +26,41 @@
|
|||
|
||||
<h2>My projects</h2>
|
||||
<p>You can access and use my projects below.</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: left">Project name</th>
|
||||
<th style="text-align: left">Github projects</th>
|
||||
<th style="text-align: left">Discription</th>
|
||||
<th style="text-align: left">Last updated</th>
|
||||
<th style="text-align: left">GitHub link</th>
|
||||
<th style="text-align: left">Language</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="userRepo">
|
||||
<script src="githubapi.js"></script>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: left">Other projects</th>
|
||||
<th style="text-align: left">Discription</th>
|
||||
<th style="text-align: left">Link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: left"><a
|
||||
href="https://addons.mozilla.org/en-US/firefox/addon/black-red-triangle-theme/">Firefox
|
||||
black & red triangle theme</a>
|
||||
<td style="text-align: left">Firefox
|
||||
black & red triangle theme
|
||||
</p>
|
||||
</td>
|
||||
<td style="text-align: left">A red and black theme for firefox. I didn't come up with a creative name.</td>
|
||||
<td style="text-align: left">14/4/2021</td>
|
||||
<td style="text-align: left">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">-</td>
|
||||
<td style="text-align: left">A red and black theme for firefox tabs.</td>
|
||||
<td style="text-align: left"><a>https://addons.mozilla.org/en-US/firefox/addon/black-red-triangle-theme/</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
<h2>Planned projects</h2>
|
||||
|
|
Loading…
Add table
Reference in a new issue