Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .DS_Store
Binary file not shown.
Binary file added Week1/.DS_Store
Binary file not shown.
Binary file added homework/.DS_Store
Binary file not shown.
67 changes: 63 additions & 4 deletions homework/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xhr.open('GET', url);
xhr.responseType = 'json';
xhr.onload = () => {
if (xhr.status < 400) {
if (xhr.status < 400 && xhr.readyState === 4) {
cb(null, xhr.response);
} else {
cb(new Error(`Network error: ${xhr.status} - ${xhr.statusText}`));
Expand All @@ -29,18 +29,77 @@
});
return elem;
}
function addRow(table, label, value) {
const tr = createAndAppend('tr', table);
createAndAppend('td', tr, { 'html': label, 'class': 'tr' });
createAndAppend('td', tr, { 'html': value });
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general remark upfront: there are a lot of ESLint warnings for your code, in addition to some spelling errors. You will probably have seen them in VSCode as wavy underlines. You should not leave such warnings uncorrected. Strive to have zero of these warnings. Here is the list:


/Users/jimcramer/hackyourfuture/class16/satambanja/homework/src/index.js
   37:95  warning  Missing semicolon                            semi
   40:55  warning  Missing semicolon                            semi
   41:65  warning  Missing semicolon                            semi
   42:66  warning  Missing semicolon                            semi
   49:17  warning  'option' is assigned a value but never used  no-unused-vars
   57:1   warning  More than 2 blank lines not allowed          no-multiple-empty-lines
   62:32  warning  Missing semicolon                            semi
   63:15  warning  Missing semicolon                            semi
   64:1   warning  More than 2 blank lines not allowed          no-multiple-empty-lines
   69:13  warning  Missing semicolon                            semi
   71:11  warning  Missing semicolon                            semi
   72:1   warning  More than 2 blank lines not allowed          no-multiple-empty-lines
   79:29  warning  Missing semicolon                            semi
   81:47  warning  Missing semicolon                            semi
   82:1   warning  More than 2 blank lines not allowed          no-multiple-empty-lines
   85:11  warning  Missing semicolon                            semi
   86:1   warning  More than 2 blank lines not allowed          no-multiple-empty-lines
   94:52  warning  Missing semicolon                            semi
   95:48  warning  Missing semicolon                            semi
   96:15  warning  'td1_1' is assigned a value but never used   no-unused-vars
   96:15  warning  Identifier 'td1_1' is not in camel case      camelcase
   96:93  warning  Missing semicolon                            semi
   97:15  warning  Identifier 'td1_2' is not in camel case      camelcase
   97:15  warning  'td1_2' is assigned a value but never used   no-unused-vars
   97:71  warning  Missing semicolon                            semi
  100:49  warning  Missing semicolon                            semi
  101:15  warning  Identifier 'td2_1' is not in camel case      camelcase
  101:15  warning  'td2_1' is assigned a value but never used   no-unused-vars
  101:94  warning  Missing semicolon                            semi
  102:15  warning  Identifier 'td2_2' is not in camel case      camelcase
  102:15  warning  'td2_2' is assigned a value but never used   no-unused-vars
  102:79  warning  Missing semicolon                            semi
  104:49  warning  Missing semicolon                            semi
  105:15  warning  'td3_1' is assigned a value but never used   no-unused-vars
  105:15  warning  Identifier 'td3_1' is not in camel case      camelcase
  105:88  warning  Missing semicolon                            semi
  106:15  warning  'td3_2' is assigned a value but never used   no-unused-vars
  106:15  warning  Identifier 'td3_2' is not in camel case      camelcase
  106:79  warning  Missing semicolon                            semi
  110:49  warning  Missing semicolon                            semi
  111:15  warning  'td4_1' is assigned a value but never used   no-unused-vars
  111:15  warning  Identifier 'td4_1' is not in camel case      camelcase
  111:94  warning  Missing semicolon                            semi
  112:15  warning  'td4_2' is assigned a value but never used   no-unused-vars
  112:15  warning  Identifier 'td4_2' is not in camel case      camelcase
  112:68  warning  Missing semicolon                            semi
  118:76  warning  Missing semicolon                            semi
  121:65  warning  Missing semicolon                            semi
  122:82  warning  Missing semicolon                            semi
  123:93  warning  Missing semicolon                            semi
  124:1   warning  More than 2 blank lines not allowed          no-multiple-empty-lines

✖ 51 problems (0 errors, 51 warnings)

function main(url) {
fetchJSON(url, (err, data) => {
const root = document.getElementById('root');
const header = createAndAppend('header', root, { 'html': '<h3> HYF Repositories <h3>' });
const select = createAndAppend('select', header);
const div = createAndAppend('div', root, { 'id': 'div1' });
const div2 = createAndAppend('div', root, { 'id': 'div2' });

if (err) {
createAndAppend('div', root, { html: err.message, class: 'alert-error' });
createAndAppend('p', div2, { html: err.message, class: 'alert-error' });
} else {
createAndAppend('pre', root, { html: JSON.stringify(data, null, 2) });
data.sort((a, b) => a.name.localeCompare(b.name, { ignorePunctuation: true }));
data.forEach((repo, index) => {
createAndAppend('option', select, { html: repo.name, value: index });
});

const contrubutorsURL = data[0].contributors_url;
fetchJSON(contrubutorsURL, (err, contdata) => {
if (err) {
createAndAppend('p', div2, { html: err.message, class: 'alert-error' });
} else {
contdata.forEach((contr) => {
rightSection(contr);
});
}
});

select.addEventListener('change', (event) => {
const contrubutorsURL = data[event.target.value].contributors_url;
div2.innerHTML = '';
fetchJSON(contrubutorsURL, (err, contdata) => {
if (err) {
createAndAppend('p', div2, { html: err.message, class: 'alert-error' });
} else {
contdata.forEach((contr) => {
rightSection(contr);
});
}
});
});

leftSection(data[0]);
select.addEventListener('change', (event) => {
div.innerHTML = '';
leftSection(data[event.target.value]);
});
}
function leftSection(repo) {

const table = createAndAppend('table', div);
addRow(table, 'Repository :', repo.name);
addRow(table, 'Description :', repo.description);
addRow(table, 'Forks :', repo.forks_count);
const date = new Date(repo.updated_at).toLocaleString();
addRow(table, 'last update :', date);
}

function rightSection(repo) {
const div3 = createAndAppend('div', div2, { 'class': 'container' });
createAndAppend('img', div3, { 'src': repo.avatar_url });
createAndAppend('a', div3, { 'html': repo.login, 'href': repo.html_url });
createAndAppend('p', div3, { 'html': repo.contributions, 'class': 'contributions' });
}
});
}

const HYF_REPOS_URL = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100';

window.onload = () => main(HYF_REPOS_URL);
Expand Down
125 changes: 122 additions & 3 deletions homework/src/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,122 @@
.alert-error {
color: red;
}
.alert-error{
color:black;
}
select{

height: 30px;
overflow: hidden;

}

body {font-size:20px;
color:white;
padding: 0 25%;
font-weight: 900;

}
p , a{ text-decoration: none;
color:white;
font-size:20px;
margin-top:25px;

}
h3{
margin-right:20px;
margin-left:20px
}

header {min-width: 350px;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
background-color: orange;
}

#div1 {
min-width: 350px;

max-height: 250px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
background-color: orange;
}
#div2 {min-width: 350px;

box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
background-color: orange;

}




td {
vertical-align: top;

}

td:first-child {
min-width: 150px;

}

#root {
display: flex;
flex-flow: row wrap;
font-weight: bold;

}





img{
height: 100px;
width : 100px;

}
.contributions{
padding-right:20px;
}
.container{
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
background-color: orange;


display: flex;
flex-direction: row;

flex: auto;
justify-content: space-between;
align-content: center;
margin-bottom: 10px;


}


#root > * {
margin: 20px;
padding: 10px;
flex: 1 100%;
}


@media all and (min-width: 600px) {
header{ flex-direction: row;}
#div1 {

flex: 1 auto; }
#div2 { flex: 1 auto; }
}

@media all and (min-width: 800px) {

#div1 {
min-width: auto;
flex: 3 0px; order: 1; }
#div2 { order: 2; }

}