From 8822ecfc5f2f5cc5a27374deade995b9e864952f Mon Sep 17 00:00:00 2001 From: Smig <89040888+smiggiddy@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:56:27 -0500 Subject: [PATCH] Library (#7) * feat: initial commit * feat: initial javascript complete * feat: modal added * feat: logic completed. * feat: modal base styling complete * feat: more styling * feat: styling complete * fix: checkbox works now --- library/js/script.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/library/js/script.js b/library/js/script.js index a6c1dcb..b529ac0 100644 --- a/library/js/script.js +++ b/library/js/script.js @@ -48,7 +48,6 @@ function displayBooks(books) { const readBtn = document.createElement('button'); const readBtnFlag = element.read ? "read" : "not read"; const readBtnColor = element.read ? "green-btn-color" : "red-btn-color"; - console.log(readBtnColor, element.read, readBtnFlag); readBtn.classList.add('btn','read-btn',readBtnColor); readBtn.textContent = readBtnFlag; @@ -89,15 +88,15 @@ booksDiv.addEventListener('click', event => { submitButton.addEventListener('click', event => { const author = document.querySelector('#author').value; const title = document.querySelector('#title').value; - const readBtn = document.querySelector('#read-button').value; - const bookIsRead = readBtn === 'on' ? true : false; + const readBtn = document.querySelector('#read-button').checked; + if (author === "" || title === "") { return } + + const newBook = new Book(title, author, readBtn); - // create book object - const newBook = new Book(title, author, bookIsRead); addBookToLibrary(newBook); displayBooks(myLibrary);