Spaces:
Running
Running
connect with database that store books that imported - Follow Up Deployment
Browse files- index.html +66 -3
index.html
CHANGED
|
@@ -501,7 +501,7 @@
|
|
| 501 |
<input type="text" class="search-bar" placeholder="Search books..." id="searchInput" onkeyup="searchBooks()">
|
| 502 |
</div>
|
| 503 |
|
| 504 |
-
<div class="p-4">
|
| 505 |
<label class="btn btn-primary w-full cursor-pointer">
|
| 506 |
<i class="fas fa-upload mr-2"></i>Import Books
|
| 507 |
<input type="file" multiple accept=".tie,.epub" style="display: none;" onchange="handleFileImport(event)">
|
|
@@ -1322,13 +1322,76 @@
|
|
| 1322 |
});
|
| 1323 |
}
|
| 1324 |
|
| 1325 |
-
// File Import
|
| 1326 |
function handleFileImport(event) {
|
| 1327 |
const files = event.target.files;
|
| 1328 |
-
// Handle file import logic here
|
| 1329 |
showNotification(`${files.length} file(s) imported successfully!`, 'success');
|
| 1330 |
}
|
| 1331 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1332 |
// Notification System
|
| 1333 |
function showNotification(message, type = 'info') {
|
| 1334 |
const notification = document.createElement('div');
|
|
|
|
| 501 |
<input type="text" class="search-bar" placeholder="Search books..." id="searchInput" onkeyup="searchBooks()">
|
| 502 |
</div>
|
| 503 |
|
| 504 |
+
<div class="p-4 space-y-2">
|
| 505 |
<label class="btn btn-primary w-full cursor-pointer">
|
| 506 |
<i class="fas fa-upload mr-2"></i>Import Books
|
| 507 |
<input type="file" multiple accept=".tie,.epub" style="display: none;" onchange="handleFileImport(event)">
|
|
|
|
| 1322 |
});
|
| 1323 |
}
|
| 1324 |
|
| 1325 |
+
// File Import Functions
|
| 1326 |
function handleFileImport(event) {
|
| 1327 |
const files = event.target.files;
|
| 1328 |
+
// Handle general file import logic here
|
| 1329 |
showNotification(`${files.length} file(s) imported successfully!`, 'success');
|
| 1330 |
}
|
| 1331 |
|
| 1332 |
+
function handleEpubImport(event) {
|
| 1333 |
+
const files = event.target.files;
|
| 1334 |
+
if (files.length === 0) return;
|
| 1335 |
+
|
| 1336 |
+
// For demo purposes, we'll create a sample book from the first EPUB file
|
| 1337 |
+
const file = files[0];
|
| 1338 |
+
const bookId = 'epub-' + Date.now();
|
| 1339 |
+
|
| 1340 |
+
// Create a sample book entry (in a real app, you would parse the EPUB)
|
| 1341 |
+
const newBook = {
|
| 1342 |
+
id: bookId,
|
| 1343 |
+
title: file.name.replace('.epub', ''),
|
| 1344 |
+
author: 'Imported Author',
|
| 1345 |
+
format: 'epub',
|
| 1346 |
+
icon: 'fas fa-file-alt',
|
| 1347 |
+
chapters: [
|
| 1348 |
+
{
|
| 1349 |
+
title: 'Chapter 1',
|
| 1350 |
+
content: `<h1>${file.name.replace('.epub', '')}</h1>
|
| 1351 |
+
<p>This is an imported EPUB file. In a real application, this would contain the actual book content parsed from the EPUB.</p>
|
| 1352 |
+
<p>File details:</p>
|
| 1353 |
+
<ul>
|
| 1354 |
+
<li>Name: ${file.name}</li>
|
| 1355 |
+
<li>Size: ${(file.size / 1024 / 1024).toFixed(2)} MB</li>
|
| 1356 |
+
<li>Last modified: ${new Date(file.lastModified).toLocaleDateString()}</li>
|
| 1357 |
+
</ul>`
|
| 1358 |
+
}
|
| 1359 |
+
],
|
| 1360 |
+
toc: [
|
| 1361 |
+
{ title: 'Chapter 1', id: 'ch1' }
|
| 1362 |
+
]
|
| 1363 |
+
};
|
| 1364 |
+
|
| 1365 |
+
// Add to sample books and library
|
| 1366 |
+
sampleBooks[bookId] = newBook;
|
| 1367 |
+
|
| 1368 |
+
// Create a new book card in the library
|
| 1369 |
+
const libraryGrid = document.querySelector('.library-grid');
|
| 1370 |
+
const bookCard = document.createElement('div');
|
| 1371 |
+
bookCard.className = 'book-card';
|
| 1372 |
+
bookCard.dataset.bookId = bookId;
|
| 1373 |
+
bookCard.innerHTML = `
|
| 1374 |
+
<div class="book-cover">
|
| 1375 |
+
<i class="${newBook.icon}"></i>
|
| 1376 |
+
</div>
|
| 1377 |
+
<div class="book-info">
|
| 1378 |
+
<div class="book-title">${newBook.title}</div>
|
| 1379 |
+
<div class="book-author">by ${newBook.author}</div>
|
| 1380 |
+
<div class="book-actions">
|
| 1381 |
+
<button class="btn btn-primary" onclick="openBook('${bookId}')">
|
| 1382 |
+
<i class="fas fa-eye mr-1"></i>Read
|
| 1383 |
+
</button>
|
| 1384 |
+
<button class="btn btn-success" onclick="addToMyStore('${bookId}')">
|
| 1385 |
+
<i class="fas fa-plus mr-1"></i>Add
|
| 1386 |
+
</button>
|
| 1387 |
+
</div>
|
| 1388 |
+
</div>
|
| 1389 |
+
`;
|
| 1390 |
+
libraryGrid.appendChild(bookCard);
|
| 1391 |
+
|
| 1392 |
+
showNotification(`"${newBook.title}" imported successfully!`, 'success');
|
| 1393 |
+
}
|
| 1394 |
+
|
| 1395 |
// Notification System
|
| 1396 |
function showNotification(message, type = 'info') {
|
| 1397 |
const notification = document.createElement('div');
|