-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
134 lines (101 loc) · 3.64 KB
/
main.js
File metadata and controls
134 lines (101 loc) · 3.64 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const URL = 'https://api.github.com/users/marvin-ai/repos'; /*github*/
// const URL = `https://randomuser.me/api/`; /*randomname*/
document.documentURI = './pagDeProduto.html';
var pagDeProduto = document.documentURI;
document.documentURI = './index.html';
var index = document.documentURI;
document.documentURI = './pagDeProduto.html';
var pagDeProduto = document.documentURI;
document.documentURI = './index.html';
var index = document.documentURI;
function createElement(tag) {
return document.createElement(tag);
}
function getElemById(id) {
return document.getElementById(id);
}
// function getElemByTagName(tag) {
// return document.getElementsByTagName(tag);
// }
async function requerimento() {
const request = await fetch(URL);
return request.json();
};
const response = requerimento();
response.then(data => {
console.log(data);
})
let i;
let name = [];
// let numForks = [];
// let numStars = [];
// let numContribs = [];
response.then(response => {
// console.log(project.name)
const tam = response.length;
for (i = 0; i < tam; i++) {
name[i] = response[i].name;
// console.log("forks : " + numForks)
// console.log("stars: " + numStars)
// console.log("contibs: " + numContribs)
// let numForks = 1; /*randomname*/
// let numStars = 1; /*github*/ /*randomname*/
// let numContribs = 1; /*github*/ /*randomname*/
let lista = getElemById('nav');
let li = createElement('li');
let a = createElement('a');
a.innerHTML = name[i];
a.href = `./pagDeProjeto.html?name=${response[i].name}` /*github*/
li.appendChild(a);
lista.appendChild(li);
// a.setAttribute('href', `./pagDeProjeto.html?name=${response.results[i].name.first}`) /*randomname*/
// a.innerHTML = response.results[i].name.first; /*randomname*/
}
})
response.then(data => {
const tam = data.length;
for (i = 0; i < tam; i++) {
if( window.location.href.includes(name[i]) ){break;}
}
let forks = getElemById('forks-number');
let stars = getElemById('stars-number');
let contribs = getElemById('contribs-number');
forks.innerHTML = data[i].forks_count;
stars.innerHTML = data[i].stargazers_count;
// contribs.innerHTML = data[i].;
const funcao = async() => {
const requerimento = await fetch('https://api.github.com/repos/marvin-ai/marvin-public-engines/contributors');
return requerimento.json();
};
let req = funcao()
req.then(data =>
console.log(data))
})
'https://api.github.com/repos/marvin-ai/marvin-public-engines/contributors'
function faz(response) {
for (i = 0; i < 14; i++) {
// console.log(numForks)
}
// console.log(res)
let forks = getElemById('forks-number');
// console.log("forks: " , numForks[i])
forks.innerHTML = numForks[i];
let stars = getElemById('stars-number');
stars.innerHTML = numStars[i];
// console.log("stars: " , stars)
let contribs = getElemById('contribs-number');
contribs.innerHTML = numContribs[i];
// forks[i].innerHTML = response[i].name.first; /*randomname*/
}
// var ordenalist = `$(".href")`;
// ordenalist.sort(function(a, b){
// return `$(b).attr(stars)` - `$(a).attr(stars)`
// });
// var divList = $(".produtos");
// divList.sort(function(a, b) {
// // para ordem decrescente; use a - b para crescente
// return $(b).attr("contagem") - $(a).attr("contagem")
// });
// $("#pai").html(divList);
//Clickable Dropdown:
//https://www.w3schools.com/Jsref/tryit.asp?filename=tryjsref_onclick_dropdown