-
-
Notifications
You must be signed in to change notification settings - Fork 221
London | 25-ITP-SEP | Imran Mohamed | Sprint 2 | Book Library #329
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
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
fee43ee
Refactor HTML structure, enhance form validation, and improve JavaScr…
i786m 2f35ce1
Merge branch 'CodeYourFuture:main' into coursework/booklibrary
i786m 2648f54
fix meta tag errors in html
i786m bcf8c09
update script tag to use module type
i786m f95fbc6
fix ID for add book button in event listener
i786m 9304166
use querySelector to target form tag
i786m df6e09d
convert pages value to a number when adding a book
i786m 778d81d
change variable names for input elements to reflect what they store
i786m aea2a43
fix typo in book1
i786m 58798b5
normalize, sanitize and validate data on input
i786m 2a58ad6
refactor to delete rows in one operation
i786m 8ac46e3
fix delete message timing issue
i786m 5691196
use textContent instead of innerText for rendering book details
i786m f6a4060
improve button naming and clarity
i786m d9acf45
fix page numbers in populateStorage function to use numbers
i786m c6bf51d
refactor addBook and render functions
i786m e6143cb
use textContent instead of innerText for buttons
i786m ea49aa2
removed trailing slash on void elements
i786m f2a5fcf
remove empty table row in book display
i786m 620b93c
refactor render to protect against null tbody
i786m 0b76c33
format button label for better readability and update button styles
i786m d349fa1
update button colors for accessibility
i786m cbcd993
tidy up
i786m 7f03371
add button color for improved visibility
i786m 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,96 +1,67 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title> </title> | ||
| <meta | ||
| charset="utf-8" | ||
| name="viewport" | ||
| content="width=device-width, initial-scale=1.0" | ||
| /> | ||
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | ||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script> | ||
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> | ||
| <link | ||
| rel="stylesheet" | ||
| href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" | ||
| /> | ||
| <link rel="stylesheet" type="text/css" href="style.css" /> | ||
| </head> | ||
| <html lang="en-GB"> | ||
|
|
||
| <body> | ||
| <div class="jumbotron text-center"> | ||
| <h1>Library</h1> | ||
| <p>Add books to your virtual library</p> | ||
| </div> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta name="description" content="A simple book library application"> | ||
| <title>My Virtual Library</title> | ||
| <script | ||
| src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | ||
| <script | ||
| src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script> | ||
| <script | ||
| src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> | ||
| <link rel="stylesheet" | ||
| href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> | ||
| <link rel="stylesheet" type="text/css" href="style.css"> | ||
| </head> | ||
|
|
||
| <button data-toggle="collapse" data-target="#demo" class="btn btn-info"> | ||
| Add new book | ||
| </button> | ||
| <body> | ||
| <div class="jumbotron text-center"> | ||
| <h1>Library</h1> | ||
| <p>Add books to your virtual library</p> | ||
| </div> | ||
|
|
||
| <div id="demo" class="collapse"> | ||
| <div class="form-group"> | ||
| <label for="title">Title:</label> | ||
| <input | ||
| type="title" | ||
| class="form-control" | ||
| id="title" | ||
| name="title" | ||
| required | ||
| /> | ||
| <label for="author">Author: </label> | ||
| <input | ||
| type="author" | ||
| class="form-control" | ||
| id="author" | ||
| name="author" | ||
| required | ||
| /> | ||
| <label for="pages">Pages:</label> | ||
| <input | ||
| type="number" | ||
| class="form-control" | ||
| id="pages" | ||
| name="pages" | ||
| required | ||
| /> | ||
| <label class="form-check-label"> | ||
| <input | ||
| type="checkbox" | ||
| class="form-check-input" | ||
| id="check" | ||
| value="" | ||
| />Read | ||
| </label> | ||
| <input | ||
| type="submit" | ||
| value="Submit" | ||
| class="btn btn-primary" | ||
| onclick="submit();" | ||
| /> | ||
| </div> | ||
| </div> | ||
| <button type="button" data-toggle="collapse" data-target="#demo" | ||
| class="btn btn-primary"> | ||
| Add new book | ||
| </button> | ||
|
|
||
| <table class="table" id="display"> | ||
| <thead class="thead-dark"> | ||
| <tr> | ||
| <th>Title</th> | ||
| <th>Author</th> | ||
| <th>Number of Pages</th> | ||
| <th>Read</th> | ||
| <th></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr> | ||
| <td></td> | ||
| <td></td> | ||
| <td></td> | ||
| <td></td> | ||
| <td></td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
| <div id="demo" class="collapse"> | ||
| <form class="form-group"> | ||
| <label for="title">Title:</label> | ||
| <input type="text" class="form-control" id="title" name="title" required> | ||
| <label for="author">Author: </label> | ||
| <input type="text" class="form-control" id="author" name="author" | ||
| required> | ||
| <label for="pages">Pages:</label> | ||
| <input type="number" class="form-control" id="pages" name="pages" min="1" | ||
| required> | ||
| <label class="form-check-label" for="check"> | ||
| <input type="checkbox" class="form-check-input" id="check">Read | ||
| </label> | ||
| <button id="add-book-btn" type="button" class="btn btn-primary"> | ||
| Add Book | ||
| </button> | ||
| </form> | ||
| </div> | ||
|
|
||
| <script src="script.js"></script> | ||
| </body> | ||
| </html> | ||
| <table class="table" id="display"> | ||
| <thead class="thead-dark"> | ||
| <tr> | ||
| <th>Title</th> | ||
| <th>Author</th> | ||
| <th>Number of Pages</th> | ||
| <th>Read</th> | ||
| <th>Delete</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| <script src="script.js" type="module"></script> | ||
| </body> | ||
|
|
||
| </html> |
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
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,45 @@ | ||
| .collapse.show{ | ||
| display: flex; | ||
| } | ||
|
|
||
| .form-group { | ||
| width: 400px; | ||
| height: 300px; | ||
| align-self: left; | ||
| align-self: flex-start; | ||
| padding-left: 20px; | ||
| } | ||
|
|
||
| .btn { | ||
| display: block; | ||
| .table .btn, | ||
| .form-group .btn { | ||
| color: white; | ||
| } | ||
|
|
||
| .form-check-label { | ||
| padding-left: 20px; | ||
| margin: 5px 0px 5px 0px; | ||
| padding-top: 10px; | ||
| margin: 5px ; | ||
i786m marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| button.btn-info { | ||
| button[data-toggle="collapse"] { | ||
| margin: 20px; | ||
| } | ||
|
|
||
| #add-book-btn { | ||
| display: block; | ||
| margin-top: 10px; | ||
| } | ||
|
|
||
| .btn-primary { | ||
| background-color: blue; | ||
| border-color: blue; | ||
| } | ||
|
|
||
| .btn-success { | ||
| background-color: green; | ||
| border-color: green; | ||
| } | ||
|
|
||
| .btn-danger { | ||
| background-color: rgb(199, 0, 0); | ||
| border-color: rgb(199, 0, 0); | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note:
alert()is not a friendly way to display messages in an app, especially non-critical messages.It is ok to use
alert()in this "exercise" app, just don't make it a habit.Also,
alert()can block the execution of the application. For example, even if you movedalert0afterrender(), the rendering will still be blocked byalert(). So in both "addition" and "deletion" (lines 97-99), the updated list of books will only be rendered after the user closed the dialog box.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking into Bootstrap's alert classes and realised I could have in-page messages as opposed to alerts. I will implement this as a workaround.