-
Notifications
You must be signed in to change notification settings - Fork 313
/
app.js
31 lines (27 loc) · 985 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const bookList = document.getElementById('book-list');
const pdfViewer = document.getElementById('pdf-viewer');
// Replace with the actual list of PDF files in your repository
const books = [
'https://github.com/ajitpal/BookBank/raw/main/book1.pdf',
'https://github.com/ajitpal/BookBank/raw/main/book2.pdf',
// Add more book URLs here
];
function renderBookList() {
bookList.innerHTML = '';
books.forEach(book => {
const li = document.createElement('li');
li.textContent = book.split('/').pop().replace('.pdf', '');
li.addEventListener('click', () => renderPDFViewer(book));
bookList.appendChild(li);
});
}
function renderPDFViewer(pdfUrl) {
pdfjsLib.getDocument(pdfUrl).promise.then(pdf => {
const viewer = new pdfjsViewer.PDFViewer({
container: pdfViewer
});
viewer.setDocument(pdf);
viewer.defaultRenderingQueue = pdfRenderingQueue.RENDER_VIEWER;
});
}
renderBookList();