1- // The strict mode in JavaScript prevents several bugs. For example, it won't let you use undeclared variables.
2- " use strict" ;
1+ // The strict mode in JavaScript prevents several bugs. For example, it won't let you use undeclared variables.
2+ ' use strict' ;
33
44// Global variables
55const USER = 'isomoth' ;
@@ -33,35 +33,36 @@ getUserProfile();
3333// Fetch all of the user's projects where a pull request has been made
3434const getPullRequests = ( allRepos ) => {
3535 allRepos . forEach ( ( repo ) => {
36- const PULL_URL = `https://api.github.com/repos/Technigo/${ repo . name } /pulls?per_page=100`
36+ const PULL_URL = `https://api.github.com/repos/Technigo/${ repo . name } /pulls?per_page=100` ;
3737 fetch ( PULL_URL )
3838 . then ( ( response ) => response . json ( ) )
3939 . then ( ( data ) => {
4040 const userPullRequest = data . find (
4141 ( pull ) => pull . user . login === repo . owner . login
4242 ) ;
4343 // Filter out pull requests from other users and fetch commits from them
44- if ( userPullRequest ) {
44+ if ( userPullRequest ) {
4545 getCommits ( userPullRequest . commits_url , repo . name ) ;
4646 } else {
4747 // Catch exception when no pull request has been made
48- document . getElementById ( `commit-${ repo . name } ` ) . innerHTML = 'No pull requests so far.' ;
48+ document . getElementById ( `commit-${ repo . name } ` ) . innerHTML =
49+ 'No pull requests so far.' ;
4950 }
5051 } ) ;
5152 } ) ;
5253} ;
5354
5455//Fetch all commits from filtered projects
5556const getCommits = ( myCommitsUrl , myRepoName ) => {
56- fetch ( myCommitsUrl ) // this will be 'commits_url' from line 45
57- . then ( ( res ) => res . json ( ) )
58- . then ( ( data ) => {
59- // Count amount of commits
60- document . getElementById ( `commit-${ myRepoName } ` ) . innerHTML += data . length ;
61- } ) ;
57+ fetch ( myCommitsUrl ) // this will be 'commits_url' from line 45
58+ . then ( ( res ) => res . json ( ) )
59+ . then ( ( data ) => {
60+ // Count amount of commits
61+ document . getElementById ( `commit-${ myRepoName } ` ) . innerHTML += data . length ;
62+ } ) ;
6263} ;
6364
64- // Fetch all repositories that the user has forked from Technigo
65+ // Fetch all repositories that the user has forked from Technigo
6566const getRepositories = ( ) => {
6667 fetch ( REPOS_URL )
6768 . then ( ( response ) => response . json ( ) )
@@ -71,27 +72,24 @@ const getRepositories = () => {
7172 ) ;
7273 // Sort repos based on date of creation ("created_at")
7374 forkedRepos . sort (
74- ( a , b ) => new Date ( b . created_at ) - new Date ( a . created_at )
75+ ( b , a ) => new Date ( a . created_at ) - new Date ( b . created_at )
7576 ) ;
76- // Display them from earliest to latest
77- forkedRepos = forkedRepos . reverse ( ) ;
7877 // Finally, use a loop to generate a card container for each project and fetch other relevant info about it
79- forkedRepos . forEach (
80- ( repo ) => {
81- projectsContainer . innerHTML +=
82- `<div class=" repo-card">
83- <h3><a class="repo-link" href=" ${ repo . html_url } "> ${ repo . name } </a><h3>
78+ forkedRepos . forEach ( ( repo ) => {
79+ projectsContainer . innerHTML += `<div class="repo-card">
80+ <h3><a class="repo-link" href=" ${ repo . html_url } " target="_blank"> ${
81+ repo . name
82+ } </a><h3>
8483 <span>
8584 <p>Default branch: ${ repo . default_branch } </p>
8685 <p>Latest push: ${ new Date ( repo . pushed_at ) . toDateString ( ) } </p>
8786 <p id="commit-${ repo . name } ">Amount of commits: </p>
8887 <span>
89- </div>`
90- } ,
91- ) ;
88+ </div>` ;
89+ } ) ;
9290 getPullRequests ( forkedRepos ) ,
93- //Use the data above to generate the chart from chart.js, displaying elapsed vs. remaining projects
94- drawChart ( forkedRepos . length ) ;
91+ //Use the data above to generate the chart from chart.js, displaying elapsed vs. remaining projects
92+ drawChart ( forkedRepos . length ) ;
9593 } ) ;
9694} ;
9795
0 commit comments