-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
50 lines (43 loc) · 1.66 KB
/
script.js
File metadata and controls
50 lines (43 loc) · 1.66 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
$('#search').click(()=>{
const input = document.getElementById('input').value;
showRepos(input);
return false;
})
function showRepos(input){
const loader = `<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>`;
$('#results').html(loader);
const request = new XMLHttpRequest();
const requestGet = 'https://api.github.com/orgs/'+input+'/repos?type\=public\&per_page\=50'
request.open('GET', requestGet, true);
request.onload = function() {
const data = JSON.parse(this.response);
$.each(data, function(i, status){
if (status =='Not Found'){
$('#results').html("<h4>Organização não encontrada</h4>");
return false;
}
else{
let content = '';
$.each(data, function(i, status){
let description = status.description
if (description==null){
description = 'Sem descrição';
};
content += `<a target="_blank" href="${status.html_url}">
<div class="repository">
<div class="repo-info">
<h2>${status.name}</h2>
<h3>${status.owner.login} - ${i+1} </h3>
</div>
<div class="repo-desc">
${description}
</div>
</div>
</a>\n`
});
$('#results').html(content);
}
});
}
request.send();
}