@@ -32,11 +32,9 @@ function createBookList(bookId) {
3232 }
3333}
3434
35- // createBookList(bookTitles);
36-
3735document . body . appendChild ( ul ) ;
3836
39- // 1.5
37+ // 1.4 create a object of book elements with title,language and author information.
4038
4139// eslint-disable-next-line vars-on-top
4240const books = {
@@ -82,8 +80,7 @@ const books = {
8280 author : 'Charles Dickens' ,
8381 } ,
8482} ;
85-
86- // const ul = document.createElement('ul');
83+ // 1.5 create Html element for Book title,Language and Author.Create id for each li element
8784
8885function createBookListUsingObject ( bookObj ) {
8986 // eslint-disable-next-line guard-for-in
@@ -96,7 +93,7 @@ function createBookListUsingObject(bookObj) {
9693 // console.log(objectKeys[j]);
9794 li . setAttribute ( 'id' , objectKeys [ j ] ) ;
9895
99- const head = document . createElement ( 'h1 ' ) ;
96+ const head = document . createElement ( 'h2 ' ) ;
10097 const headContent = document . createTextNode ( bookObj [ i ] . title ) ;
10198
10299 const headLanguage = document . createElement ( 'h2' ) ;
@@ -112,7 +109,6 @@ function createBookListUsingObject(bookObj) {
112109 li . appendChild ( head ) ;
113110 li . appendChild ( headLanguageContent ) ;
114111 li . appendChild ( headAuthor ) ;
115- li . style . cssFloat = 'left' ;
116112
117113 ul . appendChild ( li ) ;
118114
@@ -123,7 +119,21 @@ function createBookListUsingObject(bookObj) {
123119
124120createBookListUsingObject ( books ) ;
125121
126- // Create a object with Bookid and image
122+ // 1.6 set up display property of ul element
123+
124+ document . getElementById ( 'booktitle' ) . style . display = 'grid' ;
125+ document . getElementById ( 'booktitle' ) . style . gridTemplateColumns = 'auto auto' ;
126+ document . getElementById ( 'booktitle' ) . style . gridAutoColumns = 'minmax(auto, auto)' ;
127+ document . getElementById ( 'booktitle' ) . style . gridAutoRows = 'minmax(auto, auto)' ;
128+ document . getElementById ( 'booktitle' ) . style . gridGap = '2em' ;
129+
130+ // 1.6 Set up the style of ul element
131+
132+ ul . style . listStyle = 'none' ;
133+ ul . style . border = '2px red solid' ;
134+ ul . style . padding = '2em' ;
135+
136+ // 1.7 Create a object with Bookid and image.
127137
128138const bookimage = {
129139 my_experiment_with_truth : 'gandhi.jpg' ,
@@ -135,12 +145,13 @@ const bookimage = {
135145 the_tale_of_two_cities : 'thetaleoftwocities.jpg' ,
136146} ;
137147
148+ // 1.8 Match the book image with book title using unique list id of the book
149+
138150function imageDisplay ( imageObject ) {
139151 // eslint-disable-next-line guard-for-in
140152 let j = 0 ;
141153 // eslint-disable-next-line guard-for-in
142154 for ( const i in imageObject ) {
143- // console.log(Object.keys(imageObject)[j]);
144155 const container = document . getElementById ( Object . keys ( imageObject ) [ j ] ) ;
145156 const imageElement = document . createElement ( 'img' ) ;
146157 imageElement . src = imageObject [ i ] ;
@@ -150,30 +161,3 @@ function imageDisplay(imageObject) {
150161}
151162
152163imageDisplay ( bookimage ) ;
153-
154- // eslint-disable-next-line no-undef
155- ul . style . display = 'grid' ;
156- ul . style . gridTemplateColumns = 'auto auto' ;
157- ul . style . gridAutoColumns = 'minmax(auto,auto)' ;
158- ul . style . gridAutoRows = 'minmax(auto,auto)' ;
159-
160- // eslint-disable-next-line no-unused-vars
161- function createGrid ( x ) {
162- for ( let rows = 0 ; rows < x ; rows ++ ) {
163- for ( let col = 0 ; col < x ; col ++ ) {
164- // eslint-disable-next-line no-undef
165- // $('#booktitle').append("<div> class='grid'></div>");
166- const grid = document . getElementById ( "booktitle" ) ;
167- grid . appendChild ( li )
168- }
169- }
170-
171- // eslint-disable-next-line no-undef
172- $ ( '.grid' ) . height ( 960 / x ) ;
173- // eslint-disable-next-line no-undef
174- $ ( '.grid' ) . width ( 960 / x ) ;
175- }
176-
177- // eslint-disable-next-line no-undef
178- createGrid ( 2 ) ;
179- * /
0 commit comments