Skip to content

Commit 2c2b6f8

Browse files
committed
first commit
1 parent bcf127e commit 2c2b6f8

24 files changed

Lines changed: 212 additions & 8 deletions

‎Week1/homework/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#js2
2+
JavaScript2 week1

‎Week1/homework/app.js‎

Lines changed: 108 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,113 @@
1+
//book list i have read
12
'use strict';
2-
{
3-
const bookTitles = [
4-
// Replace with your own book titles
5-
'harry_potter_chamber_secrets'
3+
let bookTitles = [
4+
5+
'allison graham_cart to business relationship',
6+
'bill vincent_apostolic breakthrough',
7+
'jason kro_web development',
8+
'shama hoque_full stack react project',
9+
'cody lindley_front end handbook',
10+
'adam smith_wealth of nations',
11+
'hunry potter_chamber of secretes',
12+
'karl marx_capital',
13+
'vipul sonpatki_react by example',
14+
'adam smith_moral sentiments',
15+
616
];
717

18+
//
19+
// books changed from JSON to multiple ARRAY.
20+
// be careful unique keyword=>"bookInfo" in JSON data format..
21+
'use strict';
22+
let books = [
23+
{bookInfo :{
24+
title: 'cart to business relationship',
25+
author : 'allison graham',
26+
language : 'english',
27+
}},
28+
{bookInfo :{
29+
title: 'apostolic breakthrough',
30+
author : 'bill vincent',
31+
language : 'english',
32+
}},
33+
{bookInfo :{
34+
title: 'web development',
35+
author : 'jason kro',
36+
language : 'english',
37+
}},
38+
{bookInfo :{
39+
title: 'full stack react project',
40+
author : 'shama hoque',
41+
language : 'english',
42+
}},
43+
{bookInfo :{
44+
title: 'front end handbook',
45+
author : 'cody lindley',
46+
language : 'english',
47+
}},
48+
{bookInfo :{
49+
title: 'wealth of nations',
50+
author : 'adam smith',
51+
language : 'english',
52+
}},
53+
{bookInfo :{
54+
title: 'chamber of secretes',
55+
author : 'hunry potter',
56+
language : 'english',
57+
}},
58+
{bookInfo :{
59+
title: 'capital',
60+
author : 'karl marx',
61+
language : 'english',
62+
}},
63+
{bookInfo :{
64+
title: 'react by example',
65+
author : 'vipul sonpatki',
66+
language : 'english',
67+
}},
68+
{bookInfo :{
69+
title: 'moral sentiments',
70+
author : 'adam smith',
71+
language : 'english',
72+
}}
73+
]
74+
75+
// adding "itemClick" event
76+
let temp = [];
77+
let itemClick = (e) => {
78+
let id = e.target.id;
79+
if(temp.indexOf(id) == -1){
80+
temp.push(id);
81+
82+
let title = books[id]['bookInfo']['title'];
83+
let author = books[id]['bookInfo']['author'];
84+
let language = books[id]['bookInfo']['language'];
885

9-
// Replace with your own code
10-
console.log(bookTitles);
86+
let str = '<div class="card" onclick="myFunction()">';
87+
str += '<p>' + title + '</p>';
88+
str += '<img src="./pictures/'+title+'.jpg">';
89+
str += '<p> author: ' + author + '</p>';
90+
str += '<p> language: ' + language + '</p></div>';
91+
document.getElementById('pagecontent').innerHTML += str;
92+
}
1193
}
94+
// getting list book's id
95+
bookTitles.forEach(function (bookTitle, i) {
96+
97+
let li = document.createElement('p');
98+
li.setAttribute('id', i);
99+
li.classList.add('book');
100+
li.innerHTML = bookTitle;
101+
li.addEventListener('click', itemClick);
102+
103+
document.getElementById('bookcontainer').appendChild(li);
104+
105+
});
106+
// obj with nested props
107+
function myFunction() {
108+
document.getElementById('bookcontainer').height="400"
109+
110+
}
111+
112+
113+

‎Week1/homework/index.html‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
<!-- replace this with your HTML content -->
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>BookTitle</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
9+
10+
</head>
11+
<body>
12+
13+
<div class="pagecontainer">
14+
<h1>Click to see the list of books I have read!</h1>
15+
<div id="bookcontainer" class="card_t"></div>
16+
<div id="pagecontent">
17+
<!--
18+
<div class="card" onclick="myFunction()">
19+
<p>' + title + </p>
20+
<img src="./pictures/chamber_secrets.jpg">
21+
<p> author: ' + author + '</p>';
22+
<p> language: ' + language + '</p></div>-->
23+
</div>
24+
</div>
25+
<script src="app.js"></script>
26+
27+
28+
</body>
29+
</html>
9.32 KB
Loading
11.4 KB
Loading
9.07 KB
Loading
11.4 KB
Loading
7.15 KB
Loading
10.1 KB
Loading
6.44 KB
Loading

0 commit comments

Comments
 (0)