Skip to content

London | Nadarajah_Sripathmanathan | book-library | Module-Data-Flows #196

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debugging/book-library/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ <h1>Library</h1>

<script src="script.js"></script>
</body>
</html>
</html>
8 changes: 2 additions & 6 deletions debugging/book-library/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ const author = document.getElementById("author");
const pages = document.getElementById("pages");
const check = document.getElementById("check");

//check the right input from forms and if its ok -> add the new book (object in array)
//via Book function and start render function
function submit() {
if (
title.value == null ||
Expand Down Expand Up @@ -55,13 +53,13 @@ function Book(title, author, pages, check) {
function render() {
let table = document.getElementById("display");
let rowsNumber = table.rows.length;

console.log(myLibrary)

//delete old table
for (let n = rowsNumber - 1; n > 0; n--) {
table.deleteRow(n);
}
//insert updated row and cells
let length = myLibrary.length;
for (let i = 0; i < length; i++) {
let row = table.insertRow(1);
Expand All @@ -74,7 +72,6 @@ function render() {
authorCell.innerHTML = myLibrary[i].author;
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";
Expand All @@ -92,7 +89,6 @@ function render() {
render();
});

//add delete button to every row and render again
let delButton = document.createElement("button");
delButton.id = i + 5;
deleteCell.appendChild(delButton);
Expand All @@ -104,4 +100,4 @@ function render() {
render();
});
}
}
}