Refactor book management system:
- Updated .gitignore to exclude node_modules directory. - Enhanced index.js with new endpoints for book fetching and checkout requests, integrating nodemailer and express-rate-limit for email notifications and request management. - Added functionality to confirm book presence in the library and improved error handling for external book sources. - Updated package.json and package-lock.json to include new dependencies (nodemailer, express-rate-limit) and their respective versions. - Modified public HTML and JavaScript files to support new features, including a confirm mode for book scanning and improved UI elements. - Updated styles for better user experience in the library interface.
This commit is contained in:
74
public/books-with-images.html
Normal file
74
public/books-with-images.html
Normal file
@@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Books with Images</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.book-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.book-item img {
|
||||
max-width: 200px;
|
||||
height: auto;
|
||||
display: block;
|
||||
cursor: pointer; /* Add cursor style to indicate clickable */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Books with Images</h1>
|
||||
<div id="books-list"></div>
|
||||
|
||||
<script>
|
||||
fetch('/api/books-with-images')
|
||||
.then(response => response.json())
|
||||
.then(books => {
|
||||
const booksList = document.getElementById('books-list');
|
||||
books.forEach(book => {
|
||||
const bookDiv = document.createElement('div');
|
||||
bookDiv.className = 'book-item';
|
||||
|
||||
const title = document.createElement('h2');
|
||||
title.textContent = book.title;
|
||||
bookDiv.appendChild(title);
|
||||
|
||||
const isbn = document.createElement('p');
|
||||
isbn.textContent = 'ISBN: ' + book.isbn;
|
||||
bookDiv.appendChild(isbn);
|
||||
|
||||
// Aurthor
|
||||
const author = document.createElement('p');
|
||||
author.textContent = 'Author: ' + book.authors;
|
||||
bookDiv.appendChild(author);
|
||||
|
||||
let imgSrc = book.cover_large || book.cover_medium || book.cover_small;
|
||||
if (imgSrc) {
|
||||
const img = document.createElement('img');
|
||||
img.src = imgSrc;
|
||||
img.alt = book.title + ' cover';
|
||||
img.addEventListener('click', () => {
|
||||
img.style.display = 'none'; // Hide the clicked image
|
||||
// Hide the title and ISBN as well
|
||||
title.style.display = 'none';
|
||||
isbn.style.display = 'none';
|
||||
});
|
||||
bookDiv.appendChild(img);
|
||||
} else {
|
||||
const noImg = document.createElement('p');
|
||||
noImg.textContent = 'No cover image available.';
|
||||
bookDiv.appendChild(noImg);
|
||||
}
|
||||
|
||||
booksList.appendChild(bookDiv);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching books:', error);
|
||||
const booksList = document.getElementById('books-list');
|
||||
booksList.textContent = 'Failed to load books.';
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user