Showing
2 changed files
with
38 additions
and
11 deletions
1 | const userContributionsBox = document.querySelector(".user-status__contributions"); | 1 | const userContributionsBox = document.querySelector(".user-status__contributions"); |
2 | const totalContributionIndicator = document.getElementById("jsTotalContributions"); | 2 | const totalContributionIndicator = document.getElementById("jsTotalContributions"); |
3 | - | 3 | +const userCharacterBox = document.querySelector(".user-status__character"); |
4 | +const userRepoBox = document.querySelector(".user-repo"); | ||
5 | +const URL = "https://api.github.com/users/lsj8706/repos?sort=updated&per_page=2"; | ||
4 | 6 | ||
5 | 7 | ||
6 | const handleImage = () =>{ | 8 | const handleImage = () =>{ |
7 | const total = totalContributionIndicator.innerText; | 9 | const total = totalContributionIndicator.innerText; |
8 | - console.log(total); | 10 | + const img = new Image(); |
11 | + if (total>=0 && total<200){ | ||
12 | + img.src ="https://oss-2020105657.s3.amazonaws.com/first.png"; | ||
13 | + img.alt = "1단계"; | ||
14 | + }else if (total>=200 && total<600){ | ||
15 | + img.src ="https://oss-2020105657.s3.amazonaws.com/second.png"; | ||
16 | + img.alt = "2단계"; | ||
17 | + }else if (total>=600 && total<1200){ | ||
18 | + img.src = "https://oss-2020105657.s3.amazonaws.com/third.png"; | ||
19 | + img.alt = "3단계"; | ||
20 | + }else if (total>=1200 && total<2000){ | ||
21 | + img.src = "https://oss-2020105657.s3.amazonaws.com/four.png"; | ||
22 | + img.alt = "4단계"; | ||
23 | + }else{ | ||
24 | + img.src = "https://oss-2020105657.s3.amazonaws.com/fifth.png"; | ||
25 | + img.alt = "5단계"; | ||
26 | + } | ||
27 | + userCharacterBox.appendChild(img); | ||
9 | }; | 28 | }; |
10 | 29 | ||
30 | +const handleRepo = (list) =>{ | ||
31 | + list.forEach(element => { | ||
32 | + const anchor = document.createElement("a"); | ||
33 | + anchor.href = element.html_url; | ||
34 | + anchor.target = "_blank" | ||
35 | + anchor.innerHTML = `<div class =number><span class="repoName">${element.name}</span> : <span class="repoUrl">${element.html_url} </span></div>` | ||
36 | + userRepoBox.appendChild(anchor); | ||
37 | + }); | ||
38 | + | ||
39 | +}; | ||
11 | 40 | ||
12 | const getGithubRepo = () =>{ | 41 | const getGithubRepo = () =>{ |
13 | - console.log("Get Api here"); | 42 | + const response = fetch(URL).then(function(response){ |
43 | + return response.json(); | ||
44 | + }).then(function(data){ | ||
45 | + const trendRepoList = data.slice(0,2); | ||
46 | + handleRepo(trendRepoList); | ||
47 | + }); | ||
14 | }; | 48 | }; |
15 | 49 | ||
16 | const init=()=>{ | 50 | const init=()=>{ | ... | ... |
... | @@ -46,15 +46,8 @@ block content | ... | @@ -46,15 +46,8 @@ block content |
46 | img(src=`http://ghchart.rshah.org/${user.githubName}` alt="Name Your Github chart") | 46 | img(src=`http://ghchart.rshah.org/${user.githubName}` alt="Name Your Github chart") |
47 | .user-status__character | 47 | .user-status__character |
48 | h3 Your step | 48 | h3 Your step |
49 | - img(src="https://preview.free3d.com/img/2019/12/2269306250288170045/1oe8ymrc-900.jpg" alt="character" style="height:200px; width:250px;") | ||
50 | .user-repositories | 49 | .user-repositories |
51 | .user-repo | 50 | .user-repo |
52 | - a(href=firstRepoUrl) | 51 | + h3 Repositories |
53 | - h3 REPO 1 | ||
54 | - p=fitstRepoName | ||
55 | - br | ||
56 | - a(href=secondRepoUrl) | ||
57 | - h3 REPO 2 | ||
58 | - p=secondRepoName | ||
59 | block scripts | 52 | block scripts |
60 | script(src="/static/js/githubInfo.js") | 53 | script(src="/static/js/githubInfo.js") | ... | ... |
-
Please register or login to post a comment