-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
304 lines (259 loc) · 8.54 KB
/
index.html
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Quran Surahs</title>
<!-- Link to PWA Manifest -->
<link rel="manifest" href="manifest.json">
<!-- Font Awesome CDN for icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<!-- Link to external CSS -->
<link rel="stylesheet" href="main/css/index.css">
</head>
<body>
<div class="settings-container">
<div class="settings-item" onclick="toggleTheme()">
<i class="fas fa-moon"></i>
<div class="tooltip">Dark Mode</div>
</div>
<div class="settings-item">
<a href="hadith.html">
<i class="fas fa-kaaba"></i>
</a>
<div class="tooltip">Hadith</div>
</div>
<div class="settings-item">
<a href="kalima.html">
<i class="fas fa-hand-point-right"></i>
</a>
<div class="tooltip">Kalima</div>
</div>
<div class="settings-item">
<a href="tasbih.html">
<i class="fas fa-praying-hands"></i>
</a>
<div class="tooltip">Tasbih</div>
</div>
<div class="settings-item">
<a href="99-names.html">
<i class="fas fa-mosque"></i>
</a>
<div class="tooltip">99 Names</div>
</div>
<div class="settings-item">
<a href="prayer.html">
<i class="fas fa-pray"></i>
</a>
<div class="tooltip">Prayer</div>
</div>
<div class="settings-item install-pwa" onclick="installPWA()">
<i class="fas fa-download"></i>
<div class="tooltip">Install PWA</div>
</div>
</div>
<div class="controls">
<input type="text" id="search-input" placeholder="Search Surahs..." oninput="filterSurahs()">
</div>
<div id="surah-list"></div>
<script>
let surahData = [];
let deferredPrompt;
fetch('https://raw.githubusercontent.com/itzfew/Quranv2/main/source/surah.json')
.then(response => response.json())
.then(data => {
surahData = data;
renderSurahs(surahData);
})
.catch(error => {
console.error("Error loading Surah data:", error);
});
function renderSurahs(surahList) {
const listElement = document.getElementById("surah-list");
listElement.innerHTML = '';
surahList.forEach(surah => {
const surahLink = document.createElement('div'); // Changed to div
surahLink.classList.add('surah-link');
surahLink.style.textDecoration = 'none';
const surahItem = document.createElement('div');
surahItem.classList.add('surah-item');
surahItem.innerHTML = `
<div class="surah-number">${parseInt(surah.index)}</div>
<div class="surah-title">${surah.title}</div>
<div class="surah-arabic">${surah.titleAr}</div>
<div class="surah-meta">
<p>${surah.type}</p>
<p>${surah.count}</p>
</div>
`;
surahItem.onclick = () => showSurahOptions(parseInt(surah.index));
surahLink.appendChild(surahItem);
listElement.appendChild(surahLink);
});
}
function showSurahOptions(surahIndex) {
const surah = surahData.find(s => parseInt(s.index) === surahIndex);
const surahName = surah ? surah.title : 'Unknown Surah';
const modal = document.createElement('div');
modal.classList.add('modal');
modal.innerHTML = `
<div class="modal-content">
<button class="close-modal" onclick="closeModal()">
<i class="fas fa-times"></i>
</button>
<h2>${surahName}</h2>
<div class="modal-buttons">
<div class="button-row">
<button onclick="window.location.href='surah?index=${surahIndex}'">
<i class="fas fa-book"></i> Read Surah
</button>
<button onclick="window.location.href='read?index=${surahIndex}/1'">
<i class="fas fa-book-reader"></i> Read Quran
</button>
</div>
<button onclick="openWordToWord(${surahIndex})">
<i class="fas fa-language"></i> Read Word to Word
</button>
</div>
</div>
`;
document.body.appendChild(modal);
const overlay = document.createElement('div');
overlay.classList.add('overlay');
overlay.onclick = closeModal;
document.body.appendChild(overlay);
}
function openWordToWord(surahIndex) {
window.location.href = `wordtoword?index=${surahIndex}#1`; // Start at the first Ayah
}
function closeModal() {
const modal = document.querySelector('.modal');
const overlay = document.querySelector('.overlay');
if (modal) modal.remove();
if (overlay) overlay.remove();
}
function filterSurahs() {
const searchTerm = document.getElementById("search-input").value.toLowerCase();
const filteredSurahs = surahData.filter(surah =>
surah.title.toLowerCase().includes(searchTerm) ||
surah.titleAr.toLowerCase().includes(searchTerm) ||
surah.type.toLowerCase().includes(searchTerm)
);
renderSurahs(filteredSurahs);
}
function toggleTheme() {
const isDark = document.body.classList.toggle('dark-mode');
localStorage.setItem('darkMode', isDark);
}
window.addEventListener('DOMContentLoaded', () => {
const savedTheme = localStorage.getItem('darkMode');
if (savedTheme === 'true') {
document.body.classList.add('dark-mode');
}
});
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
deferredPrompt = e;
});
function installPWA() {
if (deferredPrompt) {
deferredPrompt.prompt();
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log("User accepted the A2HS prompt");
} else {
console.log("User dismissed the A2HS prompt");
}
deferredPrompt = null;
});
}
}
</script>
<style>
/* Modal container styles */
.modal {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
width: 90%;
max-width: 400px;
z-index: 1001;
padding: 20px;
text-align: center;
}
/* Modal overlay background */
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
z-index: 1000;
}
/* Close button at top-right corner */
.close-modal {
position: absolute;
top: 10px;
right: 10px;
background: none;
border: none;
color: #e74c3c;
font-size: 1.2em;
cursor: pointer;
transition: color 0.3s ease;
}
.close-modal:hover {
color: #c0392b;
}
/* Modal heading */
.modal-content h2 {
margin-bottom: 20px;
font-size: 1.5em;
color: #333;
text-transform: capitalize;
}
/* Button styles */
.modal-buttons {
margin-top: 20px;
}
.button-row {
display: flex;
justify-content: center;
gap: 10px;
margin-bottom: 10px;
}
.modal-buttons button {
align-items: center;
justify-content: center;
gap: 8px;
border: 1px solid #333;
background-color: transparent;
color: #333;
padding: 10px 15px;
font-size: 0.9em;
border-radius: 4px;
cursor: pointer;
transition: all 0.3s ease;
text-transform: uppercase;
}
.modal-buttons button:hover {
background-color: #f0f0f0;
border-color: #000;
}
.modal-buttons button i {
font-size: 1em;
}
/* Word to Word button at the bottom */
.modal-buttons button:nth-child(3) {
width: 100%;
justify-content: center;
}
</style>
</body>
</html>