You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 14, 2024. It is now read-only.
@@ -18,6 +18,6 @@ We expect you to __always__ come prepared to the class on Sunday.
18
18
### Overall
19
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
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 :)*
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
22
23
23
<arel="license"href="http://creativecommons.org/licenses/by/4.0/"><imgalt="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 <arel="license"href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
Copy file name to clipboardExpand all lines: Week1/MAKEME.md
+23-54Lines changed: 23 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -19,14 +19,12 @@ _This homework is more extensive and challenging than previous homework! Please
19
19
20
20
You are going to write a _Single Page Application_ (SPA) that uses the [GitHub API](https://developer.github.com/guides/getting-started/).
21
21
22
-
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:
22
+
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 in the first week are as follows:
23
23
24
-
- The user should be able to select a repository from a list of available repositories.
25
-
- The application should display high-level information about the selected repository and show a list of its contributors.
26
-
- When clicking on the name of the selected repository the GitHub page for the corresponding repository should be opened in a new browser tab.
27
-
- When clicking on a contributor, the GitHub page for the contributor should be opened in a new browser tab.
24
+
- The application should fetch repository information for the HYF GitHub account and display summary information for each repository.
25
+
- This list of repositories should be sorted alphabetically by repository name.
28
26
29
-
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.
27
+
Figure 1 below shows an example of what your application could look like.
30
28
31
29

32
30
@@ -48,11 +46,7 @@ If you open this URL in the browser (_try it!_) you will receive JSON data about
48
46
49
47
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.
50
48
51
-
#### 1.2.2 Get contributor information for a repository
52
-
53
-
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.
54
-
55
-
#### 1.2.3 GitHub API documentation
49
+
#### 1.2.2 GitHub API documentation
56
50
57
51
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.
58
52
@@ -70,11 +64,11 @@ While you do not need to read this guide in detail, it is recommended that you r
70
64
71
65
You will be working on the 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.
| 1 |`week1`| - Create a basic application using callbacks to handle network requests. |
76
-
| 2 |`week2`| Based on the `week1` branch:<br>- Refactor the callbacks to promises.<br>- Make the UI responsive. |
77
-
| 3 |`week3`| Based on the `week2` branch:<br>- Refactor the application to use ES6 Classes and async/await.<br>- Make the app ARIA-compliant. |
67
+
| Week | Branch | Assignment |
68
+
| :--: | ------- | ---------- |
69
+
| 1 |`week1`| - Create a basic application using callbacks to handle network requests. |
70
+
| 2 |`week2`| Based on the `week1` branch:<br>- Display details on a single repository and its contributors<br>- Refactor the callbacks to promises.|
71
+
| 3 |`week3`| Based on the `week2` branch:<br>- Refactor the application to use `fetch`and `async`/`await`.<br>- Reuse portions of the code to complete a provided Object Oriented (OOP) version of the application that uses ES6 classes. |
78
72
79
73
<small>Table 1. Homework schedule</small>
80
74
@@ -83,17 +77,13 @@ You will be working on the same application during the next three weeks. For eac
83
77
1. Fork the JavaScript3 repository (_this repository_) to your own GitHub account.
84
78
2. Clone the fork to your laptop.
85
79
3. Open the newly created `JavaScript3` folder from the cloned repository in VSCode.
86
-
4. Install the following extension in VSCode:
87
-
88
-
**Prettier - Code formatter**.
89
-
90
-
5. Open a Terminal window in VSCode and type the following command to install Prettier and ESLint tools as required for the homework:
80
+
4. Open a Terminal window in VSCode and type the following command to install Prettier and ESLint tools as required for the homework:
91
81
92
82
```
93
83
npm install
94
84
```
95
85
96
-
6. Create a new branch for the week 1 homework with the following command:
86
+
5. Create a new branch for the week 1 homework with the following command:
97
87
98
88
```
99
89
git checkout -b week1
@@ -135,37 +125,23 @@ _**Do not change or delete any files outside of the `homework` folder!**_
135
125
|`createAndAppend`| A utility function for easily creating and appending HTML elements. |
136
126
|`main`| Contains the start-up code for the application. |
137
127
138
-
`index.js` also contains a constant with the URL for the HYF repositories as listed in section 2.2.1:
128
+
`index.js` also contains a constant with the URL required for fetching information about the HYF repositories:
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.
134
+
3. Open the `index.html` file in your browser. You will see an unordered list with the names of the HYF repositories.
145
135
146
-
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).
136
+
4. Review the `main()` function in `index.js` and examine how this code fetches the JSON data and calls renders the data as unordered list in the web page.
147
137
148
138
### 1.6 Week 1 Assignment
149
139
150
-
The assignment is to produce an application similar to the one illustrated in Figure 1 above.
151
-
152
-
It should include the following components:
153
-
154
-
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.
155
-
2. A left-hand column that displays basic information about the selected repository.
156
-
3. A right-hand column that displays a list of contributors to the repository.
140
+
1. The assignment is to produce an application similar to the one illustrated in Figure 1 above.
157
141
158
-
> In case you run out of time, you can also do the contributors list in week 2.
142
+
2. 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. Use the predefined `alert-error` class from `style.css` to style your error.
159
143
160
-
**Functional Requirements:**
161
-
162
-
1. The list of repositories in the `select` element should be sorted (case-insensitive) on repository name.
163
-
2. At start-up your application should display information about the first repository as displayed in the `select` element.
164
-
3. When the user changes the selection, the information in the web page should be refreshed for the newly selected repository.
165
-
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.
166
-
5. You should be able to click on a contributor to open a new browser tab with the GitHub page for that contributor.
167
-
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. Use the predefined `alert-error` class from `style.css` to style your error.
168
-
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.
144
+
3. 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.
169
145
170
146

171
147
@@ -179,31 +155,24 @@ It should include the following components:
179
155
180
156
**`style.css`**
181
157
182
-
- Add your own styling.
183
-
184
-
**Hints:**
158
+
- Add your own CSS styling. Use `style.css` for all your styling your HTML. Avoid using JavaScript for styling unless there is a genuine need.
185
159
186
-
- 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:
160
+
**You are not allowed to use a CSS library such as Bootstrap.**
187
161
188
-
```html
189
-
<select>
190
-
<optionvalue="0">alumni</option>
191
-
<optionvalue="1">angular</option>
192
-
<!-- etc -->
193
-
</select>
194
-
```
162
+
**Hints:**
195
163
196
164
* 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).
197
165
198
166
* Use CSS media queries and [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) to make the UI responsive.
199
167
200
168
* 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`.
201
169
170
+
202
171
### 1.7 Handing in your homework
203
172
204
173
If necessary, review the instructions how to [Hand in homework](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/homework_pr.md) using GitHub pull request.
205
174
206
-
To test whether your code will be accepted when you submit your homework as a pull request you need to ensure that it does not contain ESLinr errors. Open a terminal window in VSCode and type the following command:
175
+
To test whether your code will be accepted when you submit your homework as a pull request you need to ensure that it does not contain ESLint errors. Open a terminal window in VSCode and type the following command:
To refresh your DOM manipulation skills, watch this YouTube video series from Traversy Media:
15
15
16
-
### APIs
16
+
-[JavaScript DOM Crash Course](https://youtu.be/0ik6X4DJKCc).
17
17
18
-
- Read about APIS: https://www.programmableweb.com/api-university/what-are-apis-and-how-do-they-work
18
+
You will be using these particular DOM manipulation methods and properties in the JS3 homework for the next three weeks:
19
19
20
-
### XMLHttpRequests
20
+
#### Course Video Part 1 (39 mins):
21
+
22
+
-`document.getElementById()`
23
+
-`element.textContent`
24
+
25
+
#### Course Video Part 2 (21 mins):
26
+
27
+
-`document.createElement()`
28
+
-`element.setAttribute()`
29
+
-`element.appendChild()`
30
+
31
+
#### Course Video Part 3 (34 mins):
32
+
33
+
-`change` event (`<select>` element)
34
+
-`element.addEventListener()`
35
+
36
+
Note that throughout the video lectures the presenter uses `var` to declare variables. We prefer that you use `const` and `let` instead in your homework.
37
+
38
+
## 2. APIs
39
+
40
+
In the homework we will be using the GitHub API. Learn about remote Web APIs in general from this YouTube video (18 min) from Traversy Media:
41
+
42
+
-[What Is A RESTful API? Explanation of REST & HTTP](https://youtu.be/Q-BpqyOT3a8).
43
+
44
+
For more research, check out the following resources:
45
+
46
+
-[What are APIs - series](https://www.youtube.com/watch?v=cpRcK4GS068&list=PLcgRuP1JhcBP8Kh0MC53GH_pxqfOhTVLa)
47
+
48
+
## 3. AJAX & XMLHttpRequests
49
+
50
+
Please watch the first 45 mins of the Ajax Crash Course (up until the PHP examples) by Traversy Media:
The example code in this course is using on ES5 syntax. In the **traversy_ajax_crash** folder in this repo you will find updated example code (**ajax1**...**ajax3**) that use the ES6 syntax and styling that we prefer in HYF. Specifically, the following changes have been made:
55
+
56
+
1. The JavaScript code has been placed in a separate file, loaded with a `<script>` tag from the HTML file.
57
+
2. Instead of **var** to declare a variable, **const** and **let** are used.
58
+
3. The non-strict equality operator `==` has been replaced with the strict version `===`.
59
+
4. Functions are defined before they are used.
60
+
5. Anonymous functions use the arrow syntax instead of the **function** keyword. Consequently, the `this` value inside the **XMLHttpRequest** event handlers have been replaced with the `xhr` variable name.
61
+
6. The `for...in` loops for iterating through an array have been replace with `for...of`.
62
+
63
+
Read more about using **XMLHttpRequest**:
21
64
22
65
-[Making HTTP Requests in JavaScript](https://www.kirupa.com/html5/making_http_requests_js.htm)
23
66
24
67
### Clean Code
25
68
26
-
-[How to write clean code? Lessons learnt from “The Clean Code” — Robert C. Martin](https://medium.com/mindorks/how-to-write-clean-code-lessons-learnt-from-the-clean-code-robert-c-martin-9ffc7aef870c).
27
-
28
-
> Note that this article includes some code examples writte in Java, but the same principles can equally be applied to JavaScript.
69
+
-[How to write clean code? Lessons learnt from “The Clean Code” — Robert C. Martin](https://medium.com/mindorks/how-to-write-clean-code-lessons-learnt-from-the-clean-code-robert-c-martin-9ffc7aef870c). Note that this article includes some code examples written in Java, but the same principles can equally be applied to JavaScript.
29
70
30
71
-[Clean Code concepts adapted for JavaScript](https://github.com/ryanmcdermott/clean-code-javascript)
31
72
32
73
### Handing in homework using GitHub pull requests
33
74
34
-
-[Handing in homework](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/homework_pr.md)
75
+
-HYF Fundamental - [Handing in homework](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/homework_pr.md)
Please watch the first 45 mins of the Ajax Crash Course by Traversy Media (see link below).
4
+
5
+
The example code in this course is using on ES5 syntax. In the **ajaxcrash** folder in this repo you will find updated example code (**ajax1** to **ajax3**) that use the ES6 syntax and styling that we prefer in HYF. Specifically, the following changes have been made:
6
+
7
+
1. The JavaScript code has been placed in a separate file, loaded with a `<script>` tag from the HTML file.
8
+
2. Instead of **var** to declare a variable, **const** and **let** are used.
9
+
3. The non-strict equality operator `==` has been replaced with the strict version `===`.
10
+
4. Functions are defined before they are used.
11
+
5. Anonymous functions use the arrow syntax instead of the **function** keyword. Consequently, the `this` value inside the **XMLHttpRequest** event handlers have been replaced with the `xhr` variable name.
12
+
6. The `for...in` loops for iterating through an array have been replace with `for...of`.
13
+
14
+
Watch this YouTube video up until the PHP examples (the first 45 mins):
15
+
16
+
- Traversy Media - [Ajax Crash Course](https://youtu.be/82hnvUYY6QA)
0 commit comments