Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
GuiTavs7 committed Nov 7, 2024
1 parent 4ca8848 commit fa5a39e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,6 @@ main {
.container .profile-data .events ul li a:hover{
background-color:hotpink;
color: #fff;
padding: 5px;
padding: 3px;
border-radius: 7px;
}
30 changes: 16 additions & 14 deletions src/scripts/objects/screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const screen = {
<a href="${repo.html_url}" target = "_blank">${repo.name}</a>
<div class="repo-info">
<p>🍴 ${repo.forks_count}</p>
<p>🌟 ${repo.stargazers_count}</p>
<p>👀 ${repo.watchers_count}</p>
<p>💻 ${repo.language}</p>
<p>🍴 ${repo.forks_count ?? "Sem forks 😢"}</p>
<p>🌟 ${repo.stargazers_count ?? "Sem estrelas 😢"}</p>
<p>👀 ${repo.watchers_count ?? "Sem observadores 😢"}</p>
<p>💻 ${repo.language ?? "Sem linguagem 😢"}</p>
</div>
</div>
Expand All @@ -58,18 +58,20 @@ const screen = {

let eventsItens = ""

user.events.filter(event => event.type === "CreateEvent" || event.type === "PushEvent").forEach(event => {

if (event.type === "PushEvent"){
eventsItens += `<li> <a href="https://github.com/${event.repo.name}" target="_blank"> ${event.repo.name}</a> - ${event.payload.commits.slice(-1)[0].message} </li>`;
console.log(eventsItens);
user.events.forEach(event =>{
if(event.type === "PushEvent"){
eventsItens += `<li>
<a href="https://github.com/${event.repo.name}" target="_blank">${event.repo.name}</a>
<p> -- ${event.payload.commits[0].message}</p>
</li>`
}

else if (event.type === "CreateEvent"){
eventsItens += `<li> Create ${event.payload.ref_type} (Sem mensagem de commit!) </li>`;
else{
eventsItens += `<li>
<a href="https://github.com/${event.repo.name}" target="_blank">${event.repo.name}</a>
<p> -- Criado um ${event.payload.ref_type}</p>
</li>`
}

});
})

if (eventsItens){
this.userProfile.innerHTML += ` <div class="events section">
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/services/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { baseUrl, eventsQuantity } from "../variables.js";

async function getEvents(userName){
const response = await fetch(`${baseUrl}/${userName}/events?per_page=${eventsQuantity}`);
return await response.json();
const events = await response.json();
return events.filter(element => element.type === "CreateEvent" || element.type === "PushEvent").slice(0,eventsQuantity);
}

export { getEvents };
4 changes: 2 additions & 2 deletions src/scripts/variables.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const baseUrl = "https://api.github.com/users";
const repositoriesQuantity = 16;
const eventsQuantity = 16;
const repositoriesQuantity = 24;
const eventsQuantity = 24;

export {baseUrl, repositoriesQuantity, eventsQuantity};

0 comments on commit fa5a39e

Please sign in to comment.