Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d06a740

Browse files
authored
Add files via upload
1 parent de2abfe commit d06a740

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed

docs/app.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
'use strict';
2+
3+
document.addEventListener('DOMContentLoaded', function() {
4+
const bookTitles = [
5+
// Replace with your own book titles
6+
"sophie's_world",
7+
'lord_of_the_rings',
8+
'of_mice_and_men',
9+
'the_brothers_karamazov',
10+
'a_farewell_to_the_arms',
11+
'lord_of_the_flies',
12+
'the_dark_tower',
13+
'love_story',
14+
'harry_potter_chamber_secrets',
15+
'metamorphoses_and_other_stories',
16+
];
17+
18+
const books = {
19+
harry_potter_chamber_secrets: {
20+
title: 'Harry Potter Chamber Secrets',
21+
language: 'English',
22+
author: 'JK Rowling',
23+
},
24+
"sophie's_world": { title: "Sophie's World", language: 'English', author: 'Josten Gaarder' },
25+
metamorphoses_and_other_stories: {
26+
title: 'Metamorphoses And Other Stories',
27+
language: 'English',
28+
author: 'Franz Kafka',
29+
},
30+
lord_of_the_rings: { title: 'Lord Of The Rings', language: 'English', author: 'JJ Tolkien' },
31+
of_mice_and_men: { title: 'Of Mice And Men', language: 'English', author: 'John Steinbeck' },
32+
the_brothers_karamazov: {
33+
title: 'The Brothers Karamazov',
34+
language: 'English',
35+
author: 'Fyodor Dostoevsky',
36+
},
37+
a_farewell_to_the_arms: {
38+
title: 'A Farewell To The Arms',
39+
language: 'English',
40+
author: 'Ernst Hemmingway',
41+
},
42+
lord_of_the_flies: {
43+
title: 'Lord Of The Flies',
44+
language: 'English',
45+
author: 'William Golding',
46+
},
47+
the_dark_tower: { title: 'The Dark Tower', language: 'English', author: 'Stephen King' },
48+
love_story: { title: 'Love Story', language: 'English', author: 'Erich Segal' },
49+
};
50+
51+
const imgSrc = {
52+
harry_potter_chamber_secrets: './images/harry_potter_chamber_secrets.jpg',
53+
"sophie's_world": "./images/sophie's_world.jpg",
54+
metamorphoses_and_other_stories: './images/metamorphoses_and_other_stories.jpg',
55+
lord_of_the_rings: './images/lord_of_the_rings.jpg',
56+
of_mice_and_men: './images/of_mice_and_men.jpg',
57+
the_brothers_karamazov: './images/the_brothers_karamazov.jpg',
58+
a_farewell_to_the_arms: './images/a_farewell_to_the_arms.jpg',
59+
lord_of_the_flies: './images/lord_of_the_flies.jpg',
60+
the_dark_tower: './images/the_dark_tower.jpg',
61+
love_story: './images/love_story.jpg',
62+
};
63+
64+
function addLi(ul) {
65+
for (let i = 0; i < bookTitles.length; i++) {
66+
const li = document.createElement('li');
67+
const title = document.createElement('h3');
68+
const author = document.createElement('h4');
69+
const language = document.createElement('h4');
70+
ul.appendChild(li);
71+
li.appendChild(title);
72+
li.appendChild(author);
73+
li.appendChild(language);
74+
li.setAttribute('id', bookTitles[i]);
75+
title.innerText = books[bookTitles[i]].title;
76+
author.innerText = books[bookTitles[i]].author;
77+
language.innerText = books[bookTitles[i]].language;
78+
}
79+
}
80+
81+
function addImg() {
82+
for (let i = 0; i < bookTitles.length; i++) {
83+
const li = document.getElementById(bookTitles[i]);
84+
const img = document.createElement('img');
85+
li.appendChild(img);
86+
img.src = imgSrc[li.id];
87+
}
88+
}
89+
90+
function main() {
91+
const div = document.createElement('div');
92+
const ul = document.createElement('ul');
93+
document.body.appendChild(div);
94+
div.appendChild(ul);
95+
addLi(ul);
96+
addImg();
97+
}
98+
99+
window.addEventListener('load', main);
100+
});

docs/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- replace this with your HTML content -->
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
8+
<title>Document</title>
9+
<script src="app.js"></script>
10+
<link rel="stylesheet" href="style.css" />
11+
</head>
12+
<body></body>
13+
</html>

docs/style.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* add your styling here */
2+
body {
3+
background: #f4f4f4;
4+
}
5+
ul {
6+
display: flex;
7+
list-style: none;
8+
flex-wrap: wrap;
9+
background: #f4f4f4;
10+
}
11+
li {
12+
text-align: center;
13+
display: flex;
14+
flex-flow: column;
15+
align-items: center;
16+
justify-items: center;
17+
margin: 0.5%;
18+
background: #dcd0c0;
19+
width: 23%;
20+
font-size: 100%;
21+
border: solid 1px black;
22+
border-radius: 5px;
23+
}
24+
img {
25+
width: 80%;
26+
height: 80%;
27+
padding-bottom: 5%;
28+
}

0 commit comments

Comments
 (0)