Exercises 4 : Load and parse JSON (22p)
Remember use JAMK/GitLab to return your exercises. Student need to test that exercise really work.
Exercise 01 - Houses [6p]
Create a web page which shows a below real estate sales announcements. You should use HTML/CSS/JavaScript/JSON and Fetch API. You can use already made text data or you can create your own data and images.
- Create JSON data from this text data - talotiedot.txt
- Check that your JSON data is valid http://jsonformatter.curiousconcept.com
- Save your JSON data to same folder with your HTML file
A few tips:
- Use array as a root in your JSON
- Array should contain house objects
- House object will have
image
,address
,size
,price
andtext
1 2 3 4 5 6 7 8 9 |
|
You can use our images or your own. Save images for example images
folder near to your HTML file.
Create a HTML file which has empty div
element with id="houses"
.
You can create your own styles for this exercise. A few tips are visible below.
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 7 8 9 |
|
1 2 3 4 5 6 |
|
1 2 3 4 |
|
1 2 3 4 |
|
Create separate JavaScript file and use it in your HTML file. Follow course material to load and render JSON data (Highscores to list). Create fetchHouses()
function to fetch houses JSON and then create renderHouses()
to create needed elements to DOM.
A few tips:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
Exercise 02 - Filter houses [6p]
You should modify exercise 1 to contain a few checkboxes to filter houses. Your application should display houses that are below 200m2 or below 1 000 000 euros (look more information from below images). A new data/houses are shown immediately after checkboxes are checked/unchecked.
Exercise 03 - Search form [10p]
Create a application which works as shown in below images. Use HTML/CSS/JavaScript/JSON and Fetch API. Application is waiting that user is typing a some first name and shows a possible names which are starting with a given letters (names are stored in JSON file). User can use arrow keys to select possible name from a list. Name will be displayed in a input field when an enter key is pressed.
Keycodes
You can check key codes for example here: Keycodes demo
Challenge
This exerice can be a challenging.