Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d81fb0f
Ex1
massam89 Dec 12, 2020
e605f25
Ex2
massam89 Dec 12, 2020
b24742c
Ex3
massam89 Dec 12, 2020
be70ba1
code along
massam89 Dec 13, 2020
f291093
Finished Project week1
massam89 Dec 13, 2020
7bf4869
Ex1
massam89 Dec 19, 2020
5c5c993
Ex2
massam89 Dec 19, 2020
7a6f20d
This is test
amirhshad Dec 20, 2020
102f0ef
Ex1 finished
amirhshad Dec 20, 2020
b8df810
Ex3
massam89 Dec 20, 2020
0f905ea
Fixed conflicts by adding to my name's folder
massam89 Dec 21, 2020
7652c8d
Start project week2
massam89 Dec 21, 2020
a579b86
change folder
massam89 Dec 21, 2020
da76e87
change folder
massam89 Dec 21, 2020
01b520d
Ex2 is added
amirhshad Dec 22, 2020
caa2416
Merge branch 'master' into week2-AmirHossein
amirhshad Dec 22, 2020
e31194d
Pokoman app added - folders moved
amirhshad Dec 22, 2020
39e4a5f
Fixed Ex3
massam89 Dec 22, 2020
0d074dd
Ex3 is finished and added
amirhshad Dec 22, 2020
883ae1f
Minor bugs fixed
amirhshad Dec 22, 2020
30c5a23
Fixed Ex3 again :D
massam89 Dec 22, 2020
2914a78
Add folder Amirhossein to hackyourrepo-app
amirhshad Dec 23, 2020
4a5c10a
Week2 project started
amirhshad Dec 23, 2020
5d733ac
Fnished project week2
massam89 Dec 23, 2020
335aa1a
Fixed image problem in project week 2
massam89 Dec 23, 2020
7fdf479
Element factory function is added
amirhshad Dec 23, 2020
6fc3298
Elements are added to project week2
amirhshad Dec 23, 2020
da65b19
Projec's element is added
amirhshad Dec 24, 2020
224295c
Merge pull request #1 from samravan/master
massam89 Dec 24, 2020
e9773e6
fixed
massam89 Dec 24, 2020
dead44a
LEft box is finished
amirhshad Dec 24, 2020
777ae24
Some major bugs of project is fixed
amirhshad Dec 26, 2020
c65245a
Hackyourepo project - insert items to DOM is done
amirhshad Dec 27, 2020
5f72ae7
Hackyourrepo project is finish and added
amirhshad Dec 27, 2020
266e231
Merge pull request #1 from massam89/week1-masoud
n4cr Dec 29, 2020
10a96cf
Merge pull request #4 from Armigerousmonk/week2-AmirHossein
n4cr Dec 29, 2020
63a5404
remove some comments and change input to change
massam89 Dec 29, 2020
6b2ef7e
Merge pull request #3 from massam89/week2-masoud
n4cr Dec 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fnished project week2
  • Loading branch information
massam89 committed Dec 23, 2020
commit 5d733acdec4796e5def1debadd57dd96a0cf28c5
39 changes: 33 additions & 6 deletions hackyourrepo-app/Masoud/week2/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ body{
font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
width: 100vw;
height: calc(100vh - 20px);
overflow: hidden;
}

header{
Expand Down Expand Up @@ -39,13 +38,13 @@ img{

.selector{
padding: 10px;
font-size: 1.7em;
font-size: 1.4em;
background-color: rgb(252, 103, 49);
color: white;
}

#repo-items{
font-size: 16px;
font-size: 12px;
font-family: sans-serif;
font-weight: 700;
color: #444;
Expand All @@ -65,10 +64,31 @@ img{
}

.description, .contributers{
width: 50%;
border: 3px rgb(223, 152, 152) solid;
border: 2px rgb(223, 152, 152) solid;
margin: 5px;

height: 70vh;
overflow: auto;
}

.description {
width: 40%;
}

.contributers{
width: 60%;
}

.contributers img{
width: 20%;
border-radius: 50%;
}

.items {
display: flex;
justify-content: space-between;
padding: 5px 15px;
margin: 5px;
align-items: center;
}

table{
Expand All @@ -82,11 +102,18 @@ table{
}
.description, .contributers{
width: 90%;
overflow:visible;
height: auto;
}
.selector{
text-align: center;
}
#repo-items{
margin-top: 10px;
}

body{
width: 100%;
height: 100%;
}
}
50 changes: 0 additions & 50 deletions hackyourrepo-app/Masoud/week2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,6 @@
</head>

<body>
<header>
<a href="#"><img src="img/hyf.png"></a>
</header>

<div class="container">
<main>
<section class="selector">
<label for="repo-items">Hack Your Future Repositories:</label>
<select id="repo-items">
<option value="SampleRepo1">SampleRepo1</option>
<option value="AndAnotherOne">AndAnotherOne</option>
<option value="HYF-Is-The-Best">HYF-Is-The-Best</option>
</select>
</section>

<div class="des-con">
<section class="description">
<table>
<tbody>
<tr>
<td>Repository</td>
<td>SampleRepo1</td>
</tr>
<tr>
<td>Description</td>
<td>This repository is meant to be a sample</td>
</tr>
<tr>
<td>Forks</td>
<td>5</td>
</tr>
<tr>
<td>Updated</td>
<td>2020-05-27 12:00:00</td>
</tr>
<tr>
</tr>
</tbody>
</table>
</section>

<section class="contributers">
<h3>contributers</h3>
</section>
</div>

</main>

</div>


<script src="js/script.js"></script>
</body>
Expand Down
166 changes: 165 additions & 1 deletion hackyourrepo-app/Masoud/week2/js/script.js
Original file line number Diff line number Diff line change
@@ -1 +1,165 @@
console.log('ssadfd');
//Calling main function after window load
window.onload = main;

//Define main function
function main() {
//Create header element and its children
const header = document.createElement('header');
const imgLink = document.createElement('a');
const imgHeader = document.createElement('img');

imgLink.href = '#';
imgHeader.src = '../img/hyf.png';
imgHeader.alt = 'HYF logo';
document.body.appendChild(header);
header.appendChild(imgLink);
imgLink.appendChild(imgHeader);

//Create container and main tag
const container = document.createElement('div');
const main = document.createElement('main');

container.classList.add('container');
document.body.appendChild(container);
container.appendChild(main);

//Create section for select repositories
const selectorSection = document.createElement('section');
selectorSection.classList.add('selector');
main.appendChild(selectorSection);

const labelElement = document.createElement('label');
labelElement.for = 'repo-items';
labelElement.textContent = 'Hack Your Future Repositories:';
selectorSection.appendChild(labelElement);

const selectElement = document.createElement('select');
selectElement.id = 'repo-items';
selectorSection.appendChild(selectElement);


//Create description and contributers
//Description
const desconElement = document.createElement('div');
desconElement.classList.add('des-con');
main.appendChild(desconElement);

const descriptionSection = document.createElement('section');
descriptionSection.classList.add('description');
desconElement.appendChild(descriptionSection);

const desTable = document.createElement('table');
descriptionSection.appendChild(desTable);

const bodyTable = document.createElement('tbody');
desTable.appendChild(bodyTable);

//Contributers
const contributersSection = document.createElement('section');
contributersSection.classList.add('contributers');
desconElement.appendChild(contributersSection);

fetchRepoList(selectElement, bodyTable, contributersSection);
};


function fetchRepoList(selectElement, bodyTable, contributersSection) {
const url = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100';
fetch(url)
.then(function (response) {
return response.json();
})
.then(function (myJson) {
myJson.forEach(element => {
const option = document.createElement('option');
option.value = element.name;
option.textContent = element.name;
selectElement.appendChild(option);
})
addDataToDOM(myJson, selectElement, bodyTable, contributersSection);
})
.catch(function (error) {
const errElement = document.createElement('h3');
errElement.style.backgroundColor = 'orange';
errElement.style.color = 'white';
errElement.style.display = 'block';
errElement.style.padding = '10px';
errElement.innerHTML = `
network request failed
<br>
${error}`;
bodyTable.parentNode.insertBefore(errElement, bodyTable);
});
};


function addDataToDOM(data, selectElement, bodyTable, contributersSection) {
selectElement.addEventListener('input', () => {
contributersSection.innerHTML = '';
data.forEach(element => {
if (element.name == selectElement.value) {
const table = `
<tr>
<td>Repository</td>
<td>${element.name}</td>
</tr>
<tr>
<td>Description</td>
<td>${element.description}</td>
</tr>
<tr>
<td>Forks</td>
<td>${element.forks}</td>
</tr>
<tr>
<td>Updated</td>
<td>${element.updated_at}</td>
</tr>`;
bodyTable.innerHTML = table;

const url = element.contributors_url;
fetchContributers(url, contributersSection);
}
})
})
};

function fetchContributers(url, contributersSection) {
fetch(url)
.then(function (response) {
return response.json();
})
.then(function (myJson) {

myJson.forEach(element => {
const contItem = document.createElement('div');
const image = document.createElement('img');
const gitName = document.createElement('h3');
const contributionsNum = document.createElement('h4');

contItem.appendChild(image);
contItem.appendChild(gitName);
contItem.appendChild(contributionsNum);

contributersSection.appendChild(contItem);

image.src = element.avatar_url;
gitName.textContent = element.login;
contributionsNum.textContent = element.contributions;
contItem.classList.add('items');
})

})
.catch(function (error) {
const errElement = document.createElement('h3');
errElement.style.backgroundColor = 'orange';
errElement.style.color = 'white';
errElement.style.display = 'block';
errElement.style.padding = '10px';
errElement.innerHTML = `
network request failed
<br>
${error}`;
contributersSection.parentNode.insertBefore(errElement, contributersSection);
});
};