Skip to content

Commit 8997e74

Browse files
authored
Merge branch 'main' into fix/navbar-translation
2 parents a9c9c6f + bc2d20c commit 8997e74

17 files changed

Lines changed: 906 additions & 80 deletions

Images/1984.jpg

68.4 KB
Loading

Images/Pride-and-prejudice.jpg

65.8 KB
Loading

Images/To_kill_a_mockingbird.jpg

89.7 KB
Loading

Images/god_delusion.jpg

805 KB
Loading

Images/great_gatsby.jpeg

13.4 KB
Loading

Images/moby-dick.jpg

150 KB
Loading

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,29 @@ MIT License
144144
<sub><b>Varad Sunil Jadhav</b></sub>
145145
</a>
146146
</td>
147+
<td align="center">
148+
<a href="https://github.com/My-Mation">
149+
<img src="https://avatars.githubusercontent.com/u/215493851?v=4" width="100;" alt="My-Mation"/>
150+
<br />
151+
<sub><b>Debargha Sarkar</b></sub>
152+
</a>
153+
</td>
147154
<td align="center">
148155
<a href="https://github.com/sujalcharati">
149156
<img src="https://avatars.githubusercontent.com/u/146851304?v=4" width="100;" alt="sujalcharati"/>
150157
<br />
151158
<sub><b>Sujal charati</b></sub>
152159
</a>
153160
</td>
161+
</tr>
162+
<tr>
154163
<td align="center">
155164
<a href="https://github.com/khandelwal20sid">
156165
<img src="https://avatars.githubusercontent.com/u/58730831?v=4" width="100;" alt="khandelwal20sid"/>
157166
<br />
158167
<sub><b>Siddharth Khandelwal</b></sub>
159168
</a>
160169
</td>
161-
</tr>
162-
<tr>
163170
<td align="center">
164171
<a href="https://github.com/Tomkndn">
165172
<img src="https://avatars.githubusercontent.com/u/105445488?v=4" width="100;" alt="Tomkndn"/>
@@ -194,13 +201,6 @@ MIT License
194201
<br />
195202
<sub><b>Mohit Kambli</b></sub>
196203
</a>
197-
</td>
198-
<td align="center">
199-
<a href="https://github.com/My-Mation">
200-
<img src="https://avatars.githubusercontent.com/u/215493851?v=4" width="100;" alt="My-Mation"/>
201-
<br />
202-
<sub><b>Debargha Sarkar</b></sub>
203-
</a>
204204
</td>
205205
</tr>
206206
<tr>

about.html

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,37 @@
4747
<div class="circle"></div>
4848
<div class="circle"></div>
4949

50-
<div id="loader" class="spinner-container">
50+
<!-- <div id="loader" class="spinner-container">
5151
<div
5252
class="spinner-border"
5353
role="status"
5454
style="width: 4rem; height: 4rem; color: #1db954"
5555
>
5656
<span class="visually-hidden">Loading...</span>
5757
</div>
58+
</div> -->
59+
60+
<div id="loader">
61+
<div class="pacman-container">
62+
<div class="pacman">
63+
<div class="pacman-top"></div>
64+
<div class="pacman-bottom"></div>
65+
</div>
66+
</div>
67+
68+
<div class="dot dot-1"></div>
69+
<div class="dot dot-2"></div>
70+
<div class="dot dot-3"></div>
71+
<div class="dot dot-4"></div>
72+
<div class="dot dot-5"></div>
73+
<div class="dot dot-6"></div>
74+
</div>
5875
</div>
5976

77+
</div>
78+
</div>
79+
80+
6081
<!-- Navbar -->
6182
<!-- <div id="header-placeholder" class="sticky top-0 z-20"></div> -->
6283
<header class="sticky top-0 z-20 bg-gray-800 p-4 shadow-sm">
@@ -461,5 +482,7 @@ <h2 class="h1 fw-semibold">Join our open-source project!</h2>
461482
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
462483
crossorigin="anonymous"
463484
></script>
485+
486+
<script src="scripts.js"></script>
464487
</body>
465488
</html>

data/books.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"id": "1",
44
"title": "To Kill a Mockingbird",
55
"author": "Harper Lee",
6-
"cover": "https://picsum.photos/200",
6+
"cover": "Images/To_kill_a_mockingbird.jpg",
77
"genre": "Fiction",
88
"description": "A novel that explores racial injustice in the Deep South through the eyes of young Scout Finch, as her father, Atticus, defends a black man wrongly accused of raping a white woman.",
99
"chapters": [
@@ -25,7 +25,7 @@
2525
"id": "2",
2626
"title": "1984",
2727
"author": "George Orwell",
28-
"cover": "https://picsum.photos/200",
28+
"cover": "Images/1984.jpg",
2929
"genre": "Dystopian",
3030
"description": "A harrowing vision of a totalitarian future, where surveillance and propaganda are omnipresent and individualism is crushed by the Party led by Big Brother.",
3131
"chapters": [
@@ -47,7 +47,7 @@
4747
"id": "3",
4848
"title": "The Great Gatsby",
4949
"author": "F. Scott Fitzgerald",
50-
"cover": "https://picsum.photos/200",
50+
"cover": "Images/great_gatsby.jpeg",
5151
"genre": "Tragedy",
5252
"description": "A story of wealth, obsession, and the American dream, set in the Jazz Age, centering on the mysterious millionaire Jay Gatsby and his love for Daisy Buchanan.",
5353
"chapters": [
@@ -69,15 +69,15 @@
6969
"id": "4",
7070
"title": "Pride and Prejudice",
7171
"author": "Jane Austen",
72-
"cover": "https://picsum.photos/200",
72+
"cover": "Images/Pride-and-prejudice.jpg",
7373
"genre": "Romance",
7474
"description": "A classic romantic tale of the strong-willed Elizabeth Bennet and the wealthy but reserved Mr. Darcy, exploring themes of class, love, and misunderstandings.",
7575
"chapters": [
7676
{
7777
"id": "1",
7878
"index": 1,
7979
"title": "Chapter 1",
80-
"audio_file": "audio/pride_ch1.mp3"
80+
"audio_file": "audio/moby-dick.mp3"
8181
},
8282
{
8383
"id": "2",
@@ -113,7 +113,7 @@
113113
"id": "6",
114114
"title": "Moby-Dick",
115115
"author": "Herman Melville",
116-
"cover": "https://picsum.photos/200",
116+
"cover": "Images/moby-dick.jpg",
117117
"genre": "Adventure",
118118
"description": "An epic tale of obsession and revenge, chronicling Captain Ahab’s relentless pursuit of the white whale Moby Dick, while exploring themes of fate, religion, and the human condition.",
119119
"chapters": [
@@ -135,7 +135,7 @@
135135
"id": "7",
136136
"title": "God Delusion",
137137
"author": "Richard Dawkins",
138-
"cover": "Images/GD.jpeg",
138+
"cover": "Images/god_delusion.jpg",
139139
"description": "The God Delusion is a book by English biologist Richard Dawkins that argues against the existence of a supernatural creator.",
140140
"genre": "Adventure",
141141
"chapters": [
@@ -184,3 +184,4 @@
184184
]
185185
}
186186
]
187+

explore.js

Lines changed: 148 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,152 @@
11
document.addEventListener('DOMContentLoaded', () => {
2-
fetch('https://raw.githubusercontent.com/Ctoic/Lisbook/refs/heads/main/data/books.json')
3-
.then(response => response.json())
4-
.then(data => {
5-
const bookContainer = document.getElementById('book-container');
6-
data.forEach(book => {
7-
const card = document.createElement('div');
8-
card.className = 'card';
9-
card.innerHTML = `
10-
<div class="card-inner">
11-
<div class="card-front">
12-
<img src="${book.cover}" alt="${book.title}">
13-
<h3>${book.title}</h3>
14-
</div>
15-
<div class="card-back">
16-
<p>${book.description}</p>
17-
</div>
2+
// Try to load from local data first, then fallback to remote
3+
const loadBooksData = async () => {
4+
try {
5+
// First try to load local data
6+
const response = await fetch('./data/books.json');
7+
if (response.ok) {
8+
return await response.json();
9+
}
10+
throw new Error('Local data not found');
11+
} catch (error) {
12+
console.warn('Loading from local data failed, trying remote:', error);
13+
// Fallback to remote data
14+
try {
15+
const response = await fetch('https://raw.githubusercontent.com/Ctoic/Lisbook/refs/heads/main/data/books.json');
16+
return await response.json();
17+
} catch (remoteError) {
18+
console.error('Failed to load book data from both sources:', remoteError);
19+
return [];
20+
}
21+
}
22+
};
23+
24+
const createBookCard = (book) => {
25+
const card = document.createElement('div');
26+
card.className = 'card';
27+
28+
// Create image element with error handling
29+
const createImageWithFallback = (src, alt) => {
30+
const img = document.createElement('img');
31+
img.alt = alt;
32+
img.loading = 'lazy';
33+
34+
// Add loading placeholder
35+
img.style.backgroundColor = '#555';
36+
img.style.minHeight = '200px';
37+
img.style.display = 'flex';
38+
img.style.alignItems = 'center';
39+
img.style.justifyContent = 'center';
40+
41+
// Handle image load error
42+
img.onerror = function() {
43+
console.warn(`Failed to load image: ${src}`);
44+
// Create a placeholder with book title
45+
this.style.display = 'none';
46+
const placeholder = document.createElement('div');
47+
placeholder.className = 'image-placeholder';
48+
placeholder.innerHTML = `
49+
<div class="placeholder-content">
50+
<i class="bi bi-book" style="font-size: 3rem; color: #10b981; margin-bottom: 1rem;"></i>
51+
<p style="font-size: 0.9rem; text-align: center; margin: 0;">${alt}</p>
1852
</div>
1953
`;
20-
bookContainer.appendChild(card);
21-
});
22-
})
23-
.catch(error => console.error('Error loading book data:', error));
54+
this.parentNode.insertBefore(placeholder, this);
55+
};
56+
57+
img.onload = function() {
58+
// Remove loading styles when image loads successfully
59+
this.style.backgroundColor = '';
60+
this.style.minHeight = '';
61+
};
62+
63+
img.src = src;
64+
return img;
65+
};
66+
67+
card.innerHTML = `
68+
<div class="card-inner">
69+
<div class="card-front">
70+
<div class="image-container">
71+
${createImageWithFallback(book.cover, book.title).outerHTML}
72+
</div>
73+
<div class="book-info">
74+
<h3 class="book-title">${book.title}</h3>
75+
<p class="book-author">by ${book.author}</p>
76+
<span class="book-genre">${book.genre || 'Unknown'}</span>
77+
</div>
78+
</div>
79+
<div class="card-back">
80+
<div class="book-description">
81+
<h4>${book.title}</h4>
82+
<p class="author-name">by ${book.author}</p>
83+
<p class="description-text">${book.description}</p>
84+
<div class="book-actions">
85+
<button class="btn-read" onclick="readBook('${book.id}')">
86+
<i class="bi bi-book-open"></i> Read
87+
</button>
88+
<button class="btn-listen" onclick="listenBook('${book.id}')">
89+
<i class="bi bi-headphones"></i> Listen
90+
</button>
91+
</div>
92+
</div>
93+
</div>
94+
</div>
95+
`;
96+
97+
return card;
98+
};
99+
100+
// Load and display books
101+
loadBooksData().then(data => {
102+
const bookContainer = document.getElementById('book-container');
103+
104+
if (data.length === 0) {
105+
bookContainer.innerHTML = `
106+
<div class="no-books-message">
107+
<i class="bi bi-exclamation-triangle" style="font-size: 3rem; color: #f59e0b;"></i>
108+
<h3>No books available</h3>
109+
<p>Unable to load book data. Please try again later.</p>
110+
</div>
111+
`;
112+
return;
113+
}
114+
115+
data.forEach(book => {
116+
const card = createBookCard(book);
117+
bookContainer.appendChild(card);
118+
});
119+
120+
// Re-apply error handling to dynamically created images
121+
const images = bookContainer.querySelectorAll('img');
122+
images.forEach(img => {
123+
if (!img.complete) {
124+
img.addEventListener('error', function() {
125+
console.warn(`Failed to load image: ${this.src}`);
126+
const placeholder = document.createElement('div');
127+
placeholder.className = 'image-placeholder';
128+
placeholder.innerHTML = `
129+
<div class="placeholder-content">
130+
<i class="bi bi-book" style="font-size: 3rem; color: #10b981; margin-bottom: 1rem;"></i>
131+
<p style="font-size: 0.9rem; text-align: center; margin: 0;">${this.alt}</p>
132+
</div>
133+
`;
134+
this.parentNode.replaceChild(placeholder, this);
135+
});
136+
}
137+
});
138+
});
24139
});
140+
141+
// Placeholder functions for book actions
142+
function readBook(bookId) {
143+
console.log(`Reading book with ID: ${bookId}`);
144+
// Add your read book logic here
145+
alert(`Opening book reader for book ID: ${bookId}`);
146+
}
147+
148+
function listenBook(bookId) {
149+
console.log(`Listening to book with ID: ${bookId}`);
150+
// Add your audio book logic here
151+
alert(`Opening audio player for book ID: ${bookId}`);
152+
}

0 commit comments

Comments
 (0)