Skip to content

Commit

Permalink
Added Virtual Bookshelf
Browse files Browse the repository at this point in the history
  • Loading branch information
Vin205 committed Aug 10, 2024
1 parent e7ebfbb commit 090c3b8
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
142 changes: 142 additions & 0 deletions assets/html/custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Virtual Bookshelves</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}

.bookshelf-container {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
width: 500px;
}

h1 {
color: #333;
text-align: center;
}

.add-shelf-container, .bookshelves {
margin-top: 20px;
}

.add-shelf-container input {
padding: 10px;
width: calc(100% - 20px);
border-radius: 5px;
border: 1px solid #ccc;
margin-bottom: 10px;
}

.add-shelf-container button {
padding: 10px 20px;
background-color: #007BFF;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
width: 100%;
margin-bottom: 10px;
}

.add-shelf-container button:hover {
background-color: #0056b3;
}

.bookshelf {
margin-top: 10px;
padding: 10px;
background-color: #f0f0f0;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
}

.bookshelf h3 {
margin: 0;
margin-bottom: 10px;
font-size: 18px;
}

.bookshelf ul {
list-style-type: none;
padding: 0;
}

.bookshelf ul li {
padding: 5px;
background-color: #e9e9e9;
margin-bottom: 5px;
border-radius: 5px;
}
</style>
</head>
<body>

<div class="bookshelf-container">
<h1>Virtual Bookshelves</h1>

<div class="add-shelf-container">
<input type="text" id="shelfName" placeholder="Enter Bookshelf Name">
<button onclick="addShelf()">Add Bookshelf</button>
</div>

<div class="bookshelves" id="bookshelves">
<!-- Bookshelves will be dynamically added here -->
</div>
</div>

<script>
function addShelf() {
const shelfName = document.getElementById('shelfName').value;
if (shelfName.trim() === '') {
alert('Please enter a name for the bookshelf.');
return;
}

const bookshelfContainer = document.createElement('div');
bookshelfContainer.className = 'bookshelf';

const bookshelfTitle = document.createElement('h3');
bookshelfTitle.innerText = shelfName;

const bookList = document.createElement('ul');

const addBookButton = document.createElement('button');
addBookButton.innerText = 'Add Book';
addBookButton.onclick = function() {
const bookName = prompt('Enter the name of the book:');
if (bookName && bookName.trim() !== '') {
const bookItem = document.createElement('li');
bookItem.innerText = bookName;
bookList.appendChild(bookItem);
} else {
alert('Book name cannot be empty.');
}
};

bookshelfContainer.appendChild(bookshelfTitle);
bookshelfContainer.appendChild(bookList);
bookshelfContainer.appendChild(addBookButton);

document.getElementById('bookshelves').appendChild(bookshelfContainer);

document.getElementById('shelfName').value = ''; // Clear input field
}
</script>

</body>
</html>
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,9 @@
<li class="dropdown-menu-item">
<a href="./assets/html/mood.html" class="navbar-link">Reading Mood Tracker</a>
</li>
<li class="dropdown-menu-item">
<a href="./assets/html/custom.html" class="navbar-link">Virtual Bookshelves</a>
</li>
<li class="dropdown-menu-item">
<a href="./assets/html/quiz.html" class="navbar-link">Quizes</a>
</li>
Expand Down

0 comments on commit 090c3b8

Please sign in to comment.