DOCTYPE HTML
DOCTYPE HTML
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Library Login</title>
</head>
<body>
<div class="login-container">
<div class="login-box">
<select id="role">
<option value="user">User</option>
<option value="admin">Admin</option>
</select>
<button onclick="login()">Login</button>
</div>
</div>
<script>
function login() {
"user": "user123",
"admin": "admin123"
};
localStorage.setItem("loggedInRole", role);
window.location.href = "library.html";
} else {
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="container">
<div class="search-container">
</div>
</div>
<!-- Book List -->
<div class="table-container">
<table>
<thead>
<tr>
<th>Title</th>
<th>Author</th>
<th>ISBN</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="book-list"></tbody>
</table>
</div>
</div>
<script src="script.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
if (!role) {
window.location.href = "index.html";
document.getElementById("admin-actions").style.display = "none";
}
});
function logout() {
localStorage.removeItem("loggedInRole");
window.location.href = "index.html";
</script>
</body>
</html>
document.addEventListener("DOMContentLoaded", () => {
preloadBooks();
loadBooks();
});
// Preload 20 books
function preloadBooks() {
let sampleBooks = [
{ title: "The Great Gatsby", author: "F. Scott Fitzgerald", isbn: "9780743273565" },
];
localStorage.setItem("books", JSON.stringify(sampleBooks));
function loadBooks() {
bookList.innerHTML = "";
books.forEach((book, index) => {
<td>${book.author}</td>
<td>${book.isbn}</td>
</tr>`;
bookList.innerHTML += row;
});
function addBook() {
return;
localStorage.setItem("books", JSON.stringify(books));
loadBooks();
document.getElementById("book-title").value = "";
document.getElementById("book-author").value = "";
document.getElementById("book-isbn").value = "";
function removeBook(index) {
books.splice(index, 1);
localStorage.setItem("books", JSON.stringify(books));
loadBooks();
// Search Books
function searchBooks() {
bookList.innerHTML = "";
book.title.toLowerCase().includes(query) ||
book.author.toLowerCase().includes(query) ||
book.isbn.includes(query)
);
filteredBooks.forEach((book, index) => {
<td>${book.author}</td>
<td>${book.isbn}</td>
</tr>`;
bookList.innerHTML += row;
});
}
/* General Styles */
body {
background: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
/* Login Container */
.login-container {
width: 100%;
max-width: 400px;
background: white;
padding: 25px;
border-radius: 10px;
text-align: center;
width: 100%;
padding: 12px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
button {
width: 100%;
padding: 12px;
border: none;
background: #27ae60;
color: white;
font-size: 18px;
cursor: pointer;
border-radius: 5px;
transition: 0.3s;
button:hover {
background: #2ecc71;
/* Logout Button */
.logout-btn {
background: #e74c3c;
margin-bottom: 15px;
}
.logout-btn:hover {
background: #c0392b;
/* Error Message */
.error {
color: red;
font-weight: bold;
margin-top: 10px;
.container {
width: 90%;
max-width: 1000px;
background: white;
padding: 30px;
border-radius: 10px;
text-align: center;
/* Form Container */
.form-container {
background: #ecf0f1;
padding: 20px;
border-radius: 8px;
margin-bottom: 25px;
/* Table Styling */
.table-container {
overflow-x: auto;
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
th, td {
padding: 12px;
text-align: left;
th {
background: #2980b9;
color: white;
font-size: 18px;
}
td {
background: #f4f4f4;
font-size: 16px;
/* Delete Button */
.delete {
background: #e74c3c;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
transition: 0.3s;
.delete:hover {
background: #c0392b;
/* Responsive Design */
.container, .login-container {
width: 95%;
}
.form-container {
padding: 15px;
table {
font-size: 14px;
th, td {
padding: 8px;
body {
display: block;
padding: 20px;
.container {
width: 100%;
padding: 20px;
table {
font-size: 14px;
}
th, td {
padding: 6px;
font-size: 14px;
.container {
max-width: 1200px;
.table-container {
th, td {
font-size: 20px;
padding: 14px;
.delete {
font-size: 18px;
}
.search-container {
display: flex;
justify-content: center;
margin-bottom: 20px;
.search-container input {
width: 60%;
padding: 10px;
border-radius: 5px;
font-size: 16px;
.search-container button {
margin-left: 10px;
border: none;
background: #2980b9;
color: white;
cursor: pointer;
border-radius: 5px;
.search-container button:hover {
background: #1e5c87;