-
-
Notifications
You must be signed in to change notification settings - Fork 222
London | 26-ITP-Jan | Angela McLeary | Sprint 2 | Book Library #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AngelaMcLeary
wants to merge
39
commits into
CodeYourFuture:main
Choose a base branch
from
AngelaMcLeary:feature/book-library
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+174
−108
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
6fe2b67
missing bracket closure on line 57
AngelaMcLeary b647506
fix syntax error on line 92 update variable
AngelaMcLeary dc2969c
add title to html file
AngelaMcLeary 6146e7f
update variable name to myLibrary on Line 41
AngelaMcLeary 731ac4c
return of author value on line 40 to allow correct output
AngelaMcLeary 377bd24
fix typo change click to clicks on line 92
AngelaMcLeary 200d98c
fix result of input status of book when read is selected to YES line …
AngelaMcLeary 6d570e5
update validation requiremtns on lines 36-41
AngelaMcLeary ff6b347
fix formatting issues in submit and render functions
AngelaMcLeary 376af2f
update input type for title and author
AngelaMcLeary 1d6d91b
update improper meta tag
AngelaMcLeary 366d541
update html tag to include language
AngelaMcLeary 957ce0b
update remove empty rows
AngelaMcLeary b6bb86f
update scripts to include defer
AngelaMcLeary c87d77d
update add form element for user data input
AngelaMcLeary 89af4d0
update to remove onclick submit from html
AngelaMcLeary 1a97cd5
update to fix remove form and onclick
AngelaMcLeary 6822947
update to remove invalid css in form-group
AngelaMcLeary 5350f6e
update code to clear fields after submission
AngelaMcLeary 9228c2f
update main container in html
AngelaMcLeary 5062215
update css to meet accessibility requirements
AngelaMcLeary 10ae61f
update spacing for form
AngelaMcLeary ece0823
update css for h1, h2 and update changeBut and deleteBut to ..Btn
AngelaMcLeary 6b1fb53
update let to const for myLibrary variable
AngelaMcLeary 380c723
update variable delbut to deleteBtn
AngelaMcLeary 820a4e1
update converted page number from string to number
AngelaMcLeary f170475
update submit function to handle page as numbers and fix validation c…
AngelaMcLeary 94388ba
update if staement and use tenary operator
AngelaMcLeary eb6981c
update unneccessay code changeBtn.id and deleteBtn.id
AngelaMcLeary adfb8c0
update remove index parameter from deleteBtn.addEventListener
AngelaMcLeary d53e21d
update change order of operation for delete alert
AngelaMcLeary e4c4826
update html to at toast div
AngelaMcLeary e29da34
update function for toast when item is deleted
AngelaMcLeary d89ea46
update alert message with function call
AngelaMcLeary 6fff30c
update toast css and change show to visible
AngelaMcLeary eab8a1f
update toast style in css, remove inline style in jumbotron
AngelaMcLeary 851e2ce
update style text in alert
AngelaMcLeary 4e49d1d
update toast style
AngelaMcLeary c96752d
update formatting with prettier
AngelaMcLeary File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ window.addEventListener("load", function (e) { | |
|
|
||
| function populateStorage() { | ||
| if (myLibrary.length == 0) { | ||
| let book1 = new Book("Robison Crusoe", "Daniel Defoe", "252", true); | ||
| let book1 = new Book("Robinson Crusoe", "Daniel Defoe", "252", true); | ||
| let book2 = new Book( | ||
| "The Old Man and the Sea", | ||
| "Ernest Hemingway", | ||
|
|
@@ -29,32 +29,52 @@ const check = document.getElementById("check"); | |
| //via Book function and start render function | ||
| function submit() { | ||
| if ( | ||
| title.value == null || | ||
| title.value == "" || | ||
| pages.value == null || | ||
| pages.value == "" | ||
| !title.value || | ||
| !author.value || | ||
| !pages.value || | ||
| Number(pages.value) <= 0 || | ||
| Number.isNaN(Number(pages.value)) | ||
| ) { | ||
| alert("Please fill all fields!"); | ||
| alert("Please fill all fields with valid input!"); | ||
| return false; | ||
| } else { | ||
| let book = new Book(title.value, title.value, pages.value, check.checked); | ||
| library.push(book); | ||
| let book = new Book( | ||
| title.value, | ||
| author.value, | ||
| Number(pages.value), | ||
| check.checked | ||
| ); | ||
| myLibrary.push(book); | ||
| render(); | ||
|
|
||
| //clears the form for new entries | ||
| title.value = ""; | ||
| author.value = ""; | ||
| pages.value = ""; | ||
| check.checked = false; | ||
| } | ||
| } | ||
|
|
||
| function Book(title, author, pages, check) { | ||
| this.title = title; | ||
| this.author = author; | ||
| this.pages = pages; | ||
| this.pages = Number(pages); | ||
| this.check = check; | ||
| } | ||
| function alertDeleteToast(message) { | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const toast = document.getElementById("toast"); | ||
| toast.innerHTML = message; | ||
| toast.classList.add("visible"); | ||
|
|
||
| setTimeout(() => { | ||
| toast.classList.remove("visible"); | ||
| }, 4000); | ||
| } | ||
| function render() { | ||
| let table = document.getElementById("display"); | ||
| let rowsNumber = table.rows.length; | ||
| //delete old table | ||
| for (let n = rowsNumber - 1; n > 0; n-- { | ||
| for (let n = rowsNumber - 1; n > 0; n--) { | ||
| table.deleteRow(n); | ||
| } | ||
| //insert updated row and cells | ||
|
|
@@ -71,33 +91,31 @@ function render() { | |
| pagesCell.innerHTML = myLibrary[i].pages; | ||
|
|
||
| //add and wait for action for read/unread button | ||
| let changeBut = document.createElement("button"); | ||
| changeBut.id = i; | ||
| changeBut.className = "btn btn-success"; | ||
| wasReadCell.appendChild(changeBut); | ||
| let readStatus = ""; | ||
| if (myLibrary[i].check == false) { | ||
| readStatus = "Yes"; | ||
| } else { | ||
| readStatus = "No"; | ||
| } | ||
| changeBut.innerText = readStatus; | ||
| let changeBtn = document.createElement("button"); | ||
| changeBtn.className = "btn btn-success"; | ||
| wasReadCell.appendChild(changeBtn); | ||
|
|
||
| changeBut.addEventListener("click", function () { | ||
| let readStatus = myLibrary[i].check ? "Yes" : "No"; | ||
| changeBtn.innerText = readStatus; | ||
|
|
||
| changeBtn.addEventListener("click", function () { | ||
| myLibrary[i].check = !myLibrary[i].check; | ||
| render(); | ||
| }); | ||
|
|
||
| //add delete button to every row and render again | ||
| let delButton = document.createElement("button"); | ||
| delBut.id = i + 5; | ||
| deleteCell.appendChild(delBut); | ||
| delBut.className = "btn btn-warning"; | ||
| delBut.innerHTML = "Delete"; | ||
| delBut.addEventListener("clicks", function () { | ||
| alert(`You've deleted title: ${myLibrary[i].title}`); | ||
| let deleteBtn = document.createElement("button"); | ||
| deleteBtn.className = "btn btn-warning"; | ||
| deleteBtn.innerHTML = "Delete"; | ||
| deleteCell.appendChild(deleteBtn); | ||
|
|
||
| deleteBtn.addEventListener("click", function () { | ||
| const deleteTitle = myLibrary[i].title; | ||
| myLibrary.splice(i, 1); | ||
| render(); | ||
| alertDeleteToast( | ||
| `You've deleted title: <br> <strong>${deleteTitle}</strong>` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Since this argument is to be assigned to (No change needed) |
||
| ); | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,94 @@ | ||
| .jumbotron { | ||
| padding: 1.5rem 2rem; | ||
| margin-bottom: 1rem; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .jumbotron h2 { | ||
| font-size: 1.5rem; | ||
| font-weight: 300; | ||
| margin-top: 0.5rem; | ||
| } | ||
|
|
||
| .form-group { | ||
| width: 400px; | ||
| height: 300px; | ||
| align-self: left; | ||
| padding-left: 20px; | ||
| padding-left: 50px; | ||
| } | ||
|
|
||
| #check { | ||
| margin-left: 0; | ||
| margin-top: 10px; | ||
| } | ||
|
|
||
| .btn { | ||
| display: block; | ||
| } | ||
|
|
||
| .form-control { | ||
| border-style: solid; | ||
| border-color: lightslategrey; | ||
| } | ||
|
|
||
| .form-check-label { | ||
| padding-left: 20px; | ||
| margin: 5px 0px 5px 0px; | ||
| } | ||
|
|
||
| button.btn-info { | ||
| margin: 20px; | ||
| .btn-info { | ||
| background-color: blue; | ||
| border-color: blue; | ||
| color: #fff; | ||
| margin: 20px 20px 20px 50px; | ||
| } | ||
|
|
||
| .btn-success { | ||
| background-color: #0d4a0d; | ||
| border-color: #0d4a0d; | ||
| color: #fff; | ||
| } | ||
|
|
||
| .btn-success:hover, | ||
| .btn-success:focus { | ||
| background-color: #1f6e1f; | ||
| border-color: #1f6e1f; | ||
| color: #fff; | ||
| } | ||
|
|
||
| .btn-warning { | ||
| background-color: #9f6000; | ||
| border-color: #9f6000; | ||
| color: #fff; | ||
| } | ||
|
|
||
| .btn-warning:hover, | ||
| .btn-warning:focus { | ||
| background-color: #b76e01; | ||
| border-color: #b76e01; | ||
| color: #fff; | ||
| } | ||
|
|
||
| /* for delete alert */ | ||
| .toast { | ||
| position: fixed; | ||
| top: 130px; | ||
| left: 50%; | ||
| font-size: 1rem; | ||
| transform: translateX(-50%); | ||
| background: #a84600; | ||
| color: white; | ||
| min-width: 300px; | ||
| width: fit-content; | ||
| white-space: normal; | ||
| word-wrap: break-word; | ||
| text-align: center; | ||
| padding: 10px 15px; | ||
| border-radius: 5px; | ||
| opacity: 0; | ||
| transition: opacity 0.3s ease; | ||
| pointer-events: none; | ||
| } | ||
|
|
||
| .toast.visible { | ||
| opacity: 1; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.