mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-25 22:10:43 -05:00
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
This commit is contained in:
parent
7a40d907d9
commit
8822ecfc5f
1 changed files with 4 additions and 5 deletions
|
@ -48,7 +48,6 @@ function displayBooks(books) {
|
||||||
const readBtn = document.createElement('button');
|
const readBtn = document.createElement('button');
|
||||||
const readBtnFlag = element.read ? "read" : "not read";
|
const readBtnFlag = element.read ? "read" : "not read";
|
||||||
const readBtnColor = element.read ? "green-btn-color" : "red-btn-color";
|
const readBtnColor = element.read ? "green-btn-color" : "red-btn-color";
|
||||||
console.log(readBtnColor, element.read, readBtnFlag);
|
|
||||||
readBtn.classList.add('btn','read-btn',readBtnColor);
|
readBtn.classList.add('btn','read-btn',readBtnColor);
|
||||||
|
|
||||||
readBtn.textContent = readBtnFlag;
|
readBtn.textContent = readBtnFlag;
|
||||||
|
@ -89,15 +88,15 @@ booksDiv.addEventListener('click', event => {
|
||||||
submitButton.addEventListener('click', event => {
|
submitButton.addEventListener('click', event => {
|
||||||
const author = document.querySelector('#author').value;
|
const author = document.querySelector('#author').value;
|
||||||
const title = document.querySelector('#title').value;
|
const title = document.querySelector('#title').value;
|
||||||
const readBtn = document.querySelector('#read-button').value;
|
const readBtn = document.querySelector('#read-button').checked;
|
||||||
const bookIsRead = readBtn === 'on' ? true : false;
|
|
||||||
|
|
||||||
if (author === "" || title === "") {
|
if (author === "" || title === "") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// create book object
|
const newBook = new Book(title, author, readBtn);
|
||||||
const newBook = new Book(title, author, bookIsRead);
|
|
||||||
|
|
||||||
addBookToLibrary(newBook);
|
addBookToLibrary(newBook);
|
||||||
displayBooks(myLibrary);
|
displayBooks(myLibrary);
|
||||||
|
|
Loading…
Reference in a new issue