Skip to content

Commit 6c37107

Browse files
committed
upload new files to my own repo, no fork
1 parent 4b47391 commit 6c37107

38 files changed

Lines changed: 2012 additions & 2 deletions

‎LICENSE‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This work is licensed under the Creative Commons Attribution 4.0 International License.
2+
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/
3+
or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

‎README.md‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
1-
# JavaScript3Mine
2-
repo not forked from HYF
1+
> Please help us improve and share your feedback! If you find better tutorials
2+
or links, please share them by [opening a pull request](https://github.com/HackYourFuture/JavaScript3/pulls).
3+
4+
# HackYourFuture JavaScript 3
5+
6+
Here you can find course content and homework for the JavaScript3 modules
7+
8+
|Week|Topic|Read|Homework|
9+
|----|-----|----|--------|
10+
|1.|• Structure for a basic SPA (Single Page Application) <br>• [XMLHttpRequests](../../../fundamentals/blob/master/fundamentals/XMLHttpRequest.md) <br>• API calls|[Reading Week 1](/Week1/README.md)|[Homework Week 1](/Week1/MAKEME.md)|
11+
|2.|• [Event Loop (order of execution)](../../../fundamentals/blob/master/fundamentals/event_loop.md)<br>• [Promises](../../../fundamentals/blob/master/fundamentals/promises.md)|[Reading Week 2](/Week2/README.md)|[Homework Week 2](/Week2/MAKEME.md)|
12+
|3.|• [try...catch](../../../fundamentals/blob/master/fundamentals/try_catch.md)<br>• [async/await](../../../fundamentals/blob/master/fundamentals/async_await.md)<br>• [The `this` keyword](../../../fundamentals/blob/master/fundamentals/this.md)<br>• call, apply, bind<br>• [Object Oriented Programming and ES6 Classes](../../../fundamentals/blob/master/fundamentals/oop_classes.md)|[Reading Week 3](/Week3/README.md)|[Homework Week 3](/Week3/MAKEME.md)|
13+
14+
__Kind note:__
15+
16+
We expect you to __always__ come prepared to the class on Sunday.
17+
18+
### Overall
19+
A good understanding of all the above mentioned topics. Want to check your Knowledge? Go through the [JavaScript Fundamentals README](../../../fundamentals/blob/master/README.md) and research/ ask for help (Slack!) with the concepts that are not entirely clear.
20+
21+
*The HackYourFuture curriculum is subject to CC BY copyright. This means you can freely use our materials, but just make sure to give us credit for it :)*
22+
23+
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.

‎Week1/MAKEME.md‎

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
# Homework Week 1
2+
3+
```
4+
Topics discussed this week:
5+
• Structure for a basic SPA
6+
• XMLHttpRequests
7+
• API calls
8+
```
9+
10+
>[Here](/Week3/README.md) you find the readings you have to complete before the ninth lecture.
11+
12+
## Step 1: Feedback
13+
14+
**_Deadline Monday_**
15+
16+
Please provide feedback on last week's homework from a fellow student as a GitHub issue.
17+
18+
## Step 2: Single Page Application :sweat_drops:
19+
20+
**_Deadline Thursday_**
21+
22+
_This homework is more extensive and challenging than previous homework! Please read the instructions below carefully and follow them with great attention to detail. Start this homework as soon as you can and allow time for discussion and questions (slack!)._
23+
24+
### 2.1 Introduction
25+
26+
You are going to write a _Single Page Application_ (SPA) that uses the [GitHub API](https://developer.github.com/guides/getting-started/).
27+
28+
This application should display information about the available [HYF GitHub repositories](https://github.com/hackyourfuture). The functionalities we would like to see in your application are as follows:
29+
30+
- The user should be able to select a repository from a list of available repositories.
31+
- The application should display high-level information about the selected repository and show a list of its contributors.
32+
- When clicking on the name of the selected repository the GitHub page for the corresponding repository should be opened in a new browser tab.
33+
- When clicking on a contributor, the GitHub page for the contributor should be opened in a new browser tab.
34+
35+
Figure 1 below shows an example of what your application could look like. Note that this is just an example. If you find it boring or unimaginative, please improve on it! On the other hand, a simpler version is OK too, so long as you implement the expected functionality.
36+
37+
![UI Example](./assets/hyf-github.png)
38+
39+
In this assignment you will built upon some existing code that is already pre-written by your teachers. Your homework consist of writing the code to make the application work as requested per week.
40+
41+
<small>Figure 1. Example User Interface using [Material Design](https://material.io/guidelines/) principles.</small>
42+
43+
A live version of this application can be found here: http://hyf-github.netlify.com/
44+
45+
### 2.2 The GitHub API
46+
47+
#### 2.2.1 Get a list of HYF repositories
48+
49+
You can fetch a list of HYF repositories through this API endpoint ([What is an API Endpoint?](https://teamtreehouse.com/community/what-is-an-api-endpoint)):
50+
51+
```
52+
https://api.github.com/orgs/HackYourFuture/repos?per_page=100
53+
```
54+
55+
If you open this URL in the browser (_try it!_) you will receive JSON data about the available HYF repositories. This is the data that you will need to work with in this assignment.
56+
57+
<small>Note the query string `?per_page=100` in the above URL. If you don't specify this query string you will only get the first 30 repositories (the default `per_page` is 30). HackYourFuture has more than 30 repositories but less than 100.</small>
58+
59+
The returned JSON data contains some basic information about each repository, such as `name`, `full_name`, `description` etc. There are also many properties that contain URLs that can be used to obtain detail information about certain aspects of the repository.
60+
61+
#### 2.2.2 Get contributor information for a repository
62+
63+
The JSON data that is returned from the initial request to get repository information includes a property named `contributors_url`. Use the value of this property to fetch a list of contributors.
64+
65+
#### 2.2.3 GitHub API documentation
66+
67+
You can find detailed information about the GitHub API by means of the link listed below. However, the documentation is very extensive and not easy to digest. For this homework it is not necessary to study the GitHub API documentation. We provide the link here for completeness.
68+
69+
> GitHub API documentation: https://developer.github.com/v3/
70+
71+
### 2.3 Preparation
72+
73+
You will be working on this same application during the next three weeks. For each week you will need to create a new Git branch, as listed in the Table 1 below.
74+
75+
| Week | Branch | Assignment |
76+
|:----:|--------|------------|
77+
| 1 | `week1` | Create a basic application using callbacks to handle network requests. |
78+
| 2 | `week2` | - Refactor the callbacks to promises.<br>- Make the UI responsive.|
79+
| 3 | `week3` | - Refactor the application to use ES6 Classes and async/await.<br>- Make the app ARIA-compliant. |
80+
81+
<small>Table 1. Homework schedule</small>
82+
83+
**Instructions**
84+
85+
1. Fork the JavaScript3 repository (_this repository_) to your own GitHub account.
86+
2. Clone the fork to your laptop.
87+
3. Open the `homework` folder inside the cloned repository in VSCode.
88+
4. Create a new branch for the week 1 homework with the following command:
89+
90+
```
91+
git checkout -b week1
92+
```
93+
94+
### 2.4 Code Overview
95+
96+
The files that make up the application are located in the `src` folder. It contains the following files:
97+
98+
| Filename | Description |
99+
|------------------|-------------|
100+
| ~~`App.js`~~ | Not used in week 1 and 2. |
101+
| ~~`Contributor.js`~~ | Not used in week 1 and 2. |
102+
| `hyf.png` | Contains the HackYourFuture logo. |
103+
| `index.html` | The application's HTML file. |
104+
| `index.js` | A starter JavaScript file. |
105+
| ~~`Repository.js`~~ | Not used in week 1 and 2. |
106+
| `style.css` | A starter CSS file. |
107+
| ~~`Util.js`~~ | Not used in week 1 and 2. |
108+
109+
In week 1, you should only modify `index.js` and `style.css`.
110+
111+
_**Do not modify any other files at this time!**_
112+
113+
#### 2.4.1 A first examination
114+
115+
1. Open `index.html` and examine its contents (but don't modify anything). Notice that the HTML `body` looks like this:
116+
117+
```html
118+
<body>
119+
<div id="root"></div>
120+
<script src="./index.js"></script>
121+
</body>
122+
```
123+
124+
The `body` tag contains a single `div` to which you will need to dynamically append HTML elements through your JavaScript code in `index.js`.
125+
126+
2. Open `index.js`. This file contains a starter set of code for you to expand. It contains the following three functions:
127+
128+
| Function | Description |
129+
|----------|-------------|
130+
| `fetchJSON` | Uses `XMLHttpRequest` to fetch JSON data from an API end point. This function uses an asynchronous callback. |
131+
| `createAndAppend` | A utility function for easily creating and appending HTML elements. |
132+
| `main` | Contains the start-up code for the application. |
133+
134+
`index.js` also contains a constant with the URL for the HYF repositories as listed in section 2.2.1:
135+
136+
```js
137+
const HYF_REPOS_URL = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100';
138+
```
139+
140+
3. Open the `index.html` file in your browser. Notice that it produces the same JSON output that you saw previously when you opened the URL directly in the browser.
141+
142+
4. Review the `main()` function in `index.js` and examine how this code renders the JSON output in the browser by means of a `pre` HTML element (for demonstration purposes).
143+
144+
### 2.5 Week 1 Assignment
145+
146+
The assignment is to produce an application similar to the one illustrated in Figure 1 above.
147+
148+
It should include the following components:
149+
150+
1. An HTML `select` element from which the user can select a HYF repository. This `select` element must be populated with `option` elements, one for each HYF repository.
151+
2. A left-hand column that displays basic information about the selected repository.
152+
3. A right-hand column that displays a list of contributors to the repository.
153+
154+
>In case you run out of time, you can also do the contributors list in week 2.
155+
156+
**Functional Requirements:**
157+
158+
1. The list of repositories in the `select` element should be sorted (case-insensitive) on repository name.
159+
2. At start-up your application should display information about the first repository as displayed in the `select` element.
160+
3. When the user changes the selection, the information in the web page should be refreshed for the newly selected repository.
161+
4. You should be able to click on the repository name of the selected repository to open a new browser tab with the GitHub page for that repository.
162+
5. You should be able to click on a contributor to open a new browser tab with the GitHub page for that contributor.
163+
6. You should render network errors to the DOM (see Figure 2 below for an example). Do not use `console.log` as regular users will not see the console output.
164+
7. Your UI should be responsive. Try it with Chrome Developer Tools in the browser, using a mobile phone format and a tablet format, portrait and landscape. If necessary, you can also do this work in week 2.
165+
166+
![Error rendering](./assets/hyf-github-error.png)
167+
168+
<small>Figure 2. Rendering of network errors.</small>
169+
170+
**Code modifications:**
171+
172+
**`index.js`**
173+
174+
- Add new functions and modify function `main()` as you see fit. It is not likely that you will need to modify `fetchJSON()` and `createAndAppend()`.
175+
176+
**`style.css`**
177+
178+
- Add your own styling.
179+
180+
**Hints:**
181+
182+
- Add one `option` element per repository to the `select` element, where each `option` element has the array index of the repository as its `value` attribute and the name of the repository as its text content:
183+
184+
```html
185+
<select>
186+
<option value="0">alumni</option>
187+
<option value="1">angular</option>
188+
<!-- etc -->
189+
</select>
190+
```
191+
192+
193+
- To sort the list repositories use [`.sort()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and [`.localeCompare()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
194+
195+
- Use CSS media queries and [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) to make the UI responsive.
196+
197+
- To force a `404` network error so that you can test the rendering of errors, change the URL to make an invalid GitHub request, e.g. append an `x` to `orgs`: `orgsx`.
198+
199+
200+
### 2.5 Handing in your homework
201+
202+
- Have you removed all commented out code (should never be present in a PR)?
203+
- Have you used `const` and `let` and avoided `var`?
204+
- Do the variable, function and argument names you created follow the [Naming Conventions](../../../../fundamentals/blob/master/fundamentals/naming_conventions.md)?
205+
- Is your code well-formatted (see [Code Formatting](../../../../fundamentals/blob/master/fundamentals/code_formatting.md))?
206+
- Have you resolved all issues flagged by ESLint and the spell checker (no wavy red and green underlines in VSCode)?
207+
208+
If the answer is 'yes' to all preceding questions you are ready to follow these instructions:
209+
210+
1. Push your `week1` branch to GitHub:
211+
212+
```
213+
git push -u origin week1
214+
```
215+
216+
2. Create a pull request for your `week1` branch.
217+
218+
---
219+
220+
_BONUS_ : Code Kata Race
221+
222+
- [Codewars](https://www.codewars.com/collections/hyf-homework-number-2)
223+
224+
225+
## Step 3: Read before next lecture
226+
227+
_Deadline Sunday morning_
228+
229+
Go through the reading material in the [README.md](/Week2/README.md) to prepare for your next class.

‎Week1/README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Reading material for the first lecture:
2+
3+
```
4+
In week one we will discuss the following topics:
5+
• Structure for a basic SPA (Single Page Application)
6+
• XMLHttpRequests
7+
• API calls
8+
```
9+
10+
Here are resources that we like you to read as a preparation for the first lecture:
11+
12+
### Fundamentals
13+
14+
- [XMLHttpRequest](../../../../fundamentals/blob/master/fundamentals/XMLHttpRequest.md)
15+
16+
### APIs
17+
18+
- Read about APIS: https://www.programmableweb.com/api-university/what-are-apis-and-how-do-they-work
19+
20+
### XMLHttpRequests
21+
22+
- [Making HTTP Requests in JavaScript](https://www.kirupa.com/html5/making_http_requests_js.htm)

‎Week1/assets/hyf-github-error.png‎

10.5 KB
Loading

‎Week1/assets/hyf-github.png‎

69.6 KB
Loading

‎Week1/homework/.eslintrc‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es6": true,
6+
"node": true
7+
},
8+
"parserOptions": {
9+
"ecmaVersion": 2017,
10+
"ecmaFeatures": {
11+
"jsx": true
12+
},
13+
"sourceType": "module"
14+
},
15+
"extends": [
16+
"eslint:recommended"
17+
],
18+
"rules": {
19+
"no-const-assign": "warn",
20+
"no-this-before-super": "warn",
21+
"no-undef": "warn",
22+
"no-unreachable": "warn",
23+
"no-unused-vars": "warn",
24+
"constructor-super": "warn",
25+
"valid-typeof": "warn",
26+
"no-var": "warn",
27+
"prefer-const": "warn",
28+
"no-multiple-empty-lines": "warn",
29+
"eol-last": [
30+
"error",
31+
"always"
32+
],
33+
"no-console": "off",
34+
"camelcase": "warn",
35+
"eqeqeq": [
36+
"error",
37+
"always",
38+
{
39+
"null": "ignore"
40+
}
41+
],
42+
"semi": [
43+
"warn",
44+
"always"
45+
]
46+
}
47+
}

0 commit comments

Comments
 (0)